264 |
264 |
if (!isset($exclude_occurrence_fields)) {
|
265 |
265 |
$exclude_occurrence_fields = array(
|
266 |
266 |
'derivationEvents',
|
267 |
|
'extensions', // TODO ignored for now, how to handle extensions?
|
268 |
267 |
'titleCache',
|
269 |
268 |
'protectedTitleCache',
|
270 |
269 |
'derivedUnitMedia',
|
... | ... | |
303 |
302 |
if (isset($specimenOrObservation->specimenTypeDesignations)) {
|
304 |
303 |
$type_status = array();
|
305 |
304 |
foreach ($specimenOrObservation->specimenTypeDesignations as $typeDesignation) {
|
306 |
|
if (isset($typeDesignation->typeStatus->representation_L10n)){
|
|
305 |
if (isset($typeDesignation->typeStatus->representation_L10n)) {
|
307 |
306 |
$type_status[] = $typeDesignation->typeStatus->representation_L10n;
|
308 |
307 |
}
|
309 |
308 |
}
|
310 |
|
if (count($type_status) > 0){
|
|
309 |
if (count($type_status) > 0) {
|
311 |
310 |
$type_label = implode(', ', $type_status);
|
312 |
311 |
}
|
313 |
312 |
}
|
314 |
313 |
|
315 |
|
$title = $type_label . ': '. $specimenOrObservation->titleCache;
|
|
314 |
$title = $type_label . ': ' . $specimenOrObservation->titleCache;
|
316 |
315 |
|
317 |
316 |
$groups = array();
|
318 |
317 |
// --- add initialized fields
|
... | ... | |
322 |
321 |
|
323 |
322 |
/* ---- java.lang.Object --- */
|
324 |
323 |
case 'class':
|
325 |
|
if($value != '' /* FieldUnit' */){
|
|
324 |
if ($value != '' /* FieldUnit' */) {
|
326 |
325 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
327 |
326 |
}
|
328 |
|
break;
|
|
327 |
break;
|
329 |
328 |
|
330 |
329 |
case 'markers':
|
331 |
330 |
$dd_elements = array();
|
... | ... | |
366 |
365 |
$groups,
|
367 |
366 |
cdm_occurrence_field_name_label($field),
|
368 |
367 |
array(
|
369 |
|
'#markup'=>theme('cdm_typedesignations', array('typeDesignations' => $value)),
|
|
368 |
'#markup' => theme('cdm_typedesignations', array('typeDesignations' => $value)),
|
370 |
369 |
)
|
371 |
370 |
);
|
372 |
371 |
break;
|
... | ... | |
375 |
374 |
$dd_elements = array();
|
376 |
375 |
$glue = ', ';
|
377 |
376 |
|
378 |
|
foreach ($value as $determinationEvent){
|
379 |
|
$timeperiod_string = NULL;
|
380 |
|
if (isset($determinationEvent->timeperiod)) {
|
381 |
|
$timeperiod_string = timePeriodToString($determinationEvent->timeperiod);
|
382 |
|
}
|
383 |
|
$weight = isset($determinationEvent->preferred) && $determinationEvent->preferred == 1 ? '0' : ($timeperiod_string ? $timeperiod_string : '1');
|
384 |
|
// check key exists
|
385 |
|
while (array_key_exists($weight, $dd_elements)) {
|
386 |
|
$weight .= '0';
|
387 |
|
}
|
388 |
|
if($determinationEvent->taxonName){
|
389 |
|
$taxon_name = $determinationEvent->taxonName;
|
390 |
|
$name_link = "";
|
391 |
|
}
|
392 |
|
else if($determinationEvent->taxon){
|
393 |
|
$taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
|
394 |
|
$name_link = path_to_taxon($determinationEvent->taxon->uuid);
|
395 |
|
}
|
|
377 |
foreach ($value as $determinationEvent) {
|
|
378 |
$timeperiod_string = NULL;
|
|
379 |
if (isset($determinationEvent->timeperiod)) {
|
|
380 |
$timeperiod_string = timePeriodToString($determinationEvent->timeperiod);
|
|
381 |
}
|
|
382 |
$weight = isset($determinationEvent->preferred) && $determinationEvent->preferred == 1 ? '0' : ($timeperiod_string ? $timeperiod_string : '1');
|
|
383 |
// check key exists
|
|
384 |
while (array_key_exists($weight, $dd_elements)) {
|
|
385 |
$weight .= '0';
|
|
386 |
}
|
|
387 |
|
|
388 |
$taxon_name = '';
|
|
389 |
$name_link = '';
|
|
390 |
if ($determinationEvent->taxonName) {
|
|
391 |
$taxon_name = $determinationEvent->taxonName;
|
|
392 |
} else if ($determinationEvent->taxon) {
|
|
393 |
$taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
|
|
394 |
$name_link = path_to_taxon($determinationEvent->taxon->uuid);
|
|
395 |
}
|
|
396 |
if ($taxon_name) {
|
396 |
397 |
$taxon_html = render_taxon_or_name($taxon_name, $name_link);
|
397 |
398 |
$dd_elements[$weight] = $taxon_html;
|
398 |
|
if (isset($determinationEvent->modifier)) {
|
399 |
|
$dd_elements[$weight] .= cdm_term_representation($determinationEvent->modifier);
|
400 |
|
}
|
401 |
|
if ($timeperiod_string) {
|
402 |
|
$dd_elements[$weight] .= $glue . $timeperiod_string;
|
403 |
|
}
|
404 |
|
if (isset($determinationEvent->actor->titleCache)) {
|
405 |
|
$dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache;
|
406 |
|
}
|
407 |
|
if (isset($determinationEvent->description)) {
|
408 |
|
$dd_elements[$weight] .= $glue . $determinationEvent->description;
|
409 |
|
}
|
|
399 |
}
|
|
400 |
if (isset($determinationEvent->modifier)) {
|
|
401 |
$dd_elements[$weight] .= cdm_term_representation($determinationEvent->modifier);
|
|
402 |
}
|
|
403 |
if ($timeperiod_string) {
|
|
404 |
$dd_elements[$weight] .= $glue . $timeperiod_string;
|
|
405 |
}
|
|
406 |
if (isset($determinationEvent->actor->titleCache)) {
|
|
407 |
$dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache;
|
|
408 |
}
|
|
409 |
if (isset($determinationEvent->description)) {
|
|
410 |
$dd_elements[$weight] .= $glue . $determinationEvent->description;
|
|
411 |
}
|
410 |
412 |
}
|
411 |
413 |
ksort($dd_elements);
|
412 |
414 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements);
|
413 |
415 |
break;
|
414 |
416 |
|
415 |
417 |
case 'descriptions':
|
416 |
|
$descriptions = $value;
|
417 |
418 |
$occurrence_featureTree = cdm_get_occurrence_featureTree();
|
418 |
419 |
$dd_elements = array();
|
419 |
420 |
|
... | ... | |
431 |
432 |
break;
|
432 |
433 |
|
433 |
434 |
case 'sources':
|
434 |
|
$dd_elements = array();
|
435 |
|
foreach ($value as $identifiable_source) {
|
436 |
|
$dd_elements[] = theme('cdm_OriginalSource', array('source' => $identifiable_source));
|
437 |
|
}
|
438 |
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
439 |
|
break;
|
|
435 |
$dd_elements = array();
|
|
436 |
foreach ($value as $identifiable_source) {
|
|
437 |
$dd_elements[] = theme('cdm_OriginalSource', array('source' => $identifiable_source));
|
|
438 |
}
|
|
439 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
|
440 |
break;
|
440 |
441 |
|
441 |
442 |
|
442 |
443 |
/* ---- DerivedUnitBase --- */
|
... | ... | |
447 |
448 |
case 'collection':
|
448 |
449 |
$sub_dl_groups = array();
|
449 |
450 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1);
|
450 |
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2);
|
|
451 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2);
|
451 |
452 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3);
|
452 |
453 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4);
|
453 |
454 |
// TODO "superCollection"
|
454 |
455 |
// TODO may have media
|
455 |
456 |
|
456 |
457 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
|
457 |
|
array(
|
458 |
|
array('#markup' => $value->titleCache),
|
459 |
|
array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
|
460 |
|
)
|
|
458 |
array(
|
|
459 |
array('#markup' => $value->titleCache),
|
|
460 |
array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
|
|
461 |
)
|
461 |
462 |
);
|
462 |
463 |
break;
|
463 |
464 |
|
464 |
|
case 'storedUnder':
|
465 |
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value));
|
466 |
|
break;
|
|
465 |
case 'storedUnder':
|
|
466 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value));
|
|
467 |
break;
|
467 |
468 |
|
468 |
469 |
|
469 |
|
/* ---- Specimen --- */
|
470 |
|
case 'sequences':
|
471 |
|
$dd_elements = array();
|
472 |
|
foreach ($value as $sequence) {
|
473 |
|
$dd_elements[] = compose_cdm_sequence($sequence);
|
474 |
|
}
|
475 |
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
|
470 |
/* ---- Specimen --- */
|
|
471 |
case 'sequences':
|
|
472 |
$dd_elements = array();
|
|
473 |
foreach ($value as $sequence) {
|
|
474 |
$dd_elements[] = compose_cdm_sequence($sequence);
|
|
475 |
}
|
|
476 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
476 |
477 |
break;
|
477 |
478 |
|
478 |
|
// TODO preservation
|
479 |
|
// TODO exsiccatum
|
|
479 |
// TODO preservation
|
|
480 |
// TODO exsiccatum
|
480 |
481 |
|
481 |
482 |
|
482 |
483 |
/* ---- FieldObservation --- */
|
... | ... | |
502 |
503 |
|
503 |
504 |
if (isset($value->collectingAreas)) {
|
504 |
505 |
$area_representations = array();
|
505 |
|
foreach($value->collectingAreas as $area) {
|
|
506 |
foreach ($value->collectingAreas as $area) {
|
506 |
507 |
$area_representations[] = $area->representation_L10n;
|
507 |
508 |
}
|
508 |
509 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'), implode(', ', $area_representations));
|
... | ... | |
517 |
518 |
}
|
518 |
519 |
|
519 |
520 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
|
|
521 |
array(
|
|
522 |
array('#markup' => $value->exactLocation->sexagesimalString),
|
520 |
523 |
array(
|
521 |
|
array('#markup' => $value->exactLocation->sexagesimalString),
|
522 |
|
array(
|
523 |
|
'#theme' => 'description_list',
|
524 |
|
'#groups' => $sub_dl_groups
|
525 |
|
),
|
526 |
|
)
|
|
524 |
'#theme' => 'description_list',
|
|
525 |
'#groups' => $sub_dl_groups
|
|
526 |
),
|
|
527 |
)
|
527 |
528 |
);
|
528 |
529 |
}
|
529 |
530 |
break;
|
530 |
531 |
|
531 |
532 |
default:
|
532 |
|
if(is_object($value) || is_array($value)){
|
|
533 |
if (is_object($value) || is_array($value)) {
|
533 |
534 |
drupal_set_message("Unhandled type in compose_cdm_specimenOrObservation() for field " . $field, "warning");
|
534 |
535 |
} else {
|
535 |
536 |
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
... | ... | |
540 |
541 |
}
|
541 |
542 |
} // END of loop over $derivedUnitFacade fields
|
542 |
543 |
|
|
544 |
// Extensions
|
|
545 |
$extensions = cdm_ws_fetch_all(CDM_WS_PORTAL_OCCURRENCE . '/' . $specimenOrObservation->uuid . '/extensions', array($specimenOrObservation->uuid));
|
|
546 |
if ($extensions && count($extensions)) {
|
|
547 |
|
|
548 |
$extensions_render_array = compose_extensions($extensions);
|
|
549 |
@_description_list_group_add($groups, t('Extensions') . ':',
|
|
550 |
$extensions_render_array,
|
|
551 |
'', 100);
|
|
552 |
}
|
|
553 |
|
543 |
554 |
|
544 |
555 |
// template_preprocess_description_list() is not worting by weight so we do it right here
|
545 |
556 |
uasort($groups, 'element_sort');
|
... | ... | |
596 |
607 |
return $derivatives;
|
597 |
608 |
}
|
598 |
609 |
|
|
610 |
|
599 |
611 |
/**
|
600 |
612 |
* Compose an render array from a CDM Sequence object.
|
601 |
613 |
*
|
ref #2985 output of extensions implemented generically and for occurrences