cdm-dataportal / modules / cdm_dataportal / includes / occurrences.inc @ 4186a152
History | View | Annotate | Download (54.8 KB)
1 |
<?php |
---|---|
2 |
/** |
3 |
* @file |
4 |
* Functions for dealing with CDM entities of type SpecimenOrOccurrences |
5 |
* |
6 |
* @copyright |
7 |
* (C) 2007-2012 EDIT |
8 |
* European Distributed Institute of Taxonomy |
9 |
* http://www.e-taxonomy.eu |
10 |
* |
11 |
* The contents of this module are subject to the Mozilla |
12 |
* Public License Version 1.1. |
13 |
* @see http://www.mozilla.org/MPL/MPL-1.1.html |
14 |
* |
15 |
* @author |
16 |
* - Andreas Kohlbecker <a.kohlbecker@BGBM.org> |
17 |
*/ |
18 |
|
19 |
|
20 |
/** |
21 |
* Provides the HTML markup for a specimen page |
22 |
* |
23 |
* @param $specimen |
24 |
* |
25 |
* @return string |
26 |
* The markup for a specimen page |
27 |
*/ |
28 |
function render_cdm_specimen_page($specimen) |
29 |
{ |
30 |
|
31 |
$specimen_details = compose_cdm_specimen_or_observation($specimen, true); |
32 |
//$detail_html .= drupal_render($specimen_details); |
33 |
|
34 |
$specimen->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array( |
35 |
$specimen->uuid, |
36 |
'fieldObjectMediaDTO', |
37 |
)); |
38 |
$specimen->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array( |
39 |
$specimen->uuid, |
40 |
'derivedUnitMedia', |
41 |
)); |
42 |
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME); |
43 |
$captionElements = array( |
44 |
'#uri' => t('open media'), |
45 |
); |
46 |
if (isset($specimen->fieldObjectMediaDTO) ) { |
47 |
$gallery_html = compose_cdm_media_gallerie(array( |
48 |
'mediaList' => $specimen->fieldObjectMediaDTO, |
49 |
'galleryName' => $specimen->titleCache, |
50 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
51 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
52 |
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null, |
53 |
'captionElements' => $captionElements, |
54 |
'mediaLinkType' => 'LIGHTBOX', |
55 |
'alternativeMediaUri' => NULL, |
56 |
'galleryLinkUri' => NULL, |
57 |
)); |
58 |
$specimen_details[] = markup_to_render_array($gallery_html); |
59 |
} |
60 |
|
61 |
if (isset($specimen->_derivedUnitMedia) ) { |
62 |
$gallery_html = compose_cdm_media_gallerie(array( |
63 |
'mediaList' => $specimen->_derivedUnitMedia, |
64 |
'galleryName' => $specimen->titleCache, |
65 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
66 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
67 |
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null, |
68 |
'captionElements' => $captionElements, |
69 |
'mediaLinkType' => 'LIGHTBOX', |
70 |
'alternativeMediaUri' => NULL, |
71 |
'galleryLinkUri' => NULL, |
72 |
)); |
73 |
$specimen_details[] = markup_to_render_array($gallery_html); |
74 |
} |
75 |
|
76 |
$specimen_array = $specimen_details; |
77 |
$output = ""; |
78 |
foreach($specimen_array as $value){ |
79 |
$renderArray = array( |
80 |
'#theme' => 'item_list', |
81 |
'#items' => array($value), |
82 |
'#type' => 'ul'); |
83 |
$output .= drupal_render($renderArray); |
84 |
} |
85 |
|
86 |
|
87 |
return $output; |
88 |
} |
89 |
|
90 |
|
91 |
/** |
92 |
* Provides the HTML markup for a specimen page |
93 |
* |
94 |
* @param $specimen |
95 |
* |
96 |
* @return string |
97 |
* The markup for a specimen page |
98 |
*/ |
99 |
function render_cdm_specimenDTO_page($specimen, $is_specimen_page = false) |
100 |
{ |
101 |
$detail_html = ""; |
102 |
//link to specimen page |
103 |
$pathToSpecimen = path_to_specimen($specimen->uuid); |
104 |
if (!$is_specimen_page) { |
105 |
$specimenPageLink = l($specimen->accessionNumber, $pathToSpecimen, array('attributes' => array('target' => '_blank'))); |
106 |
$detail_html .= "<strong>Specimen summary: $specimenPageLink</strong><br>"; |
107 |
} |
108 |
|
109 |
|
110 |
if($is_specimen_page) { |
111 |
if($specimen->citation){ |
112 |
$detail_html .= "<br>".$specimen->citation."<br>"; |
113 |
|
114 |
} |
115 |
} |
116 |
if ($specimen->preferredStableUri) { |
117 |
$stableIdentifierLink = l($specimen->preferredStableUri, $specimen->preferredStableUri, array('attributes' => array('target' => '_blank'))); |
118 |
$detail_html .= create_label("Preferred stable URI") . $stableIdentifierLink . "<br>"; |
119 |
} |
120 |
if ($is_specimen_page) { |
121 |
// associated taxa |
122 |
if ($specimen->associatedTaxa) { |
123 |
$detail_html .= "<br>"; |
124 |
$detail_html .= create_label("Associated with"); |
125 |
if (sizeof($specimen->associatedTaxa) > 1) { |
126 |
$detail_html .= "<br>"; |
127 |
} |
128 |
foreach ($specimen->associatedTaxa as $associatedTaxon) { |
129 |
$detail_html .= l($associatedTaxon->value, path_to_taxon($associatedTaxon->key, "specimens"));//$associatedTaxon->second."<br>"; |
130 |
} |
131 |
$detail_html .= "<br>"; |
132 |
} |
133 |
} |
134 |
// - type information |
135 |
$types = ""; |
136 |
if (isset($specimen->types)) { |
137 |
//typed taxa |
138 |
foreach ($specimen->types as $typeStatus => $typedTaxa) { |
139 |
if($specimen->types){ |
140 |
if(empty($typeStatus) || $typeStatus == "_empty_"|| $typeStatus == ""){ |
141 |
$detail_html .= "<i>Type for:</i> "; |
142 |
} else { |
143 |
$detail_html .= "<i>".$typeStatus."</i> of "; |
144 |
} |
145 |
foreach($typedTaxa as $typedTaxon){ |
146 |
$detail_html .= $typedTaxon." "; |
147 |
|
148 |
} |
149 |
} else { |
150 |
$types .= $typeStatus . " "; |
151 |
|
152 |
} |
153 |
} |
154 |
} |
155 |
$derivateDataDTO = $specimen->derivateDataDTO; |
156 |
// - specimen scans |
157 |
$specimenScans = create_html_links($derivateDataDTO->specimenScans, true); |
158 |
// - molecular data |
159 |
$molecularData = ""; |
160 |
if ($derivateDataDTO->molecularDataList) { |
161 |
foreach ($derivateDataDTO->molecularDataList as $molecular) { |
162 |
//provider link |
163 |
if (isset($molecular->providerLink)) { |
164 |
$molecularData .= create_html_link($molecular->providerLink, true); |
165 |
} else { |
166 |
$molecularData .= "[no provider]"; |
167 |
} |
168 |
//contig link |
169 |
if (isset($molecular->contigFiles)) { |
170 |
$molecularData .= "["; |
171 |
if (sizeof($molecular->contigFiles) > 0) { |
172 |
foreach ($molecular->contigFiles as $contigFile) { |
173 |
if (isset($contigFile->contigLink)) { |
174 |
if (isset($contigFile->contigLink->uri) and $contigFile->contigLink->uri != null) { |
175 |
$molecularData .= create_html_link($contigFile->contigLink, true) . " "; |
176 |
} |
177 |
} else { |
178 |
$molecularData .= "no contig "; |
179 |
} |
180 |
//primer links |
181 |
if (isset($contigFile->primerLinks)) { |
182 |
$molecularData .= create_html_links($contigFile->primerLinks, true); |
183 |
} |
184 |
} |
185 |
} |
186 |
$molecularData = rtrim($molecularData, " "); |
187 |
$molecularData .= "]"; |
188 |
} |
189 |
//FIXME separate with comma (remove trailing comma) |
190 |
} |
191 |
} |
192 |
// - detail images |
193 |
$detailImages = create_html_links($derivateDataDTO->detailImages, true); |
194 |
|
195 |
if ($types) { |
196 |
$detail_html .= $is_specimen_page ? "<br>" : ""; |
197 |
$detail_html .= create_label("Type(s)") . $types . "<br>"; |
198 |
} |
199 |
if ($specimenScans and !$is_specimen_page) { |
200 |
$detail_html .= create_label("Specimen Scans") . $specimenScans . "<br>"; |
201 |
} |
202 |
//specimen scan image gallery |
203 |
if ($is_specimen_page and isset($derivateDataDTO->specimenScanUuids) and !empty($derivateDataDTO->specimenScanUuids)) { |
204 |
$detail_html .= addImageGallery("Specimen scans", $derivateDataDTO->specimenScanUuids); |
205 |
} |
206 |
|
207 |
if ($molecularData) { |
208 |
$detail_html .= $is_specimen_page ? "<br>" : ""; |
209 |
$detail_html .= create_label("Molecular Data") . $molecularData . "<br>"; |
210 |
} |
211 |
|
212 |
if ($detailImages and !$is_specimen_page) { |
213 |
$detail_html .= create_label("Detail Images") . $detailImages . "<br>"; |
214 |
} |
215 |
|
216 |
//detail image gallery |
217 |
if ($is_specimen_page and isset($derivateDataDTO->detailImageUuids) and !empty($derivateDataDTO->detailImageUuids)) { |
218 |
$detail_html .= addImageGallery("Detail Images", $derivateDataDTO->detailImageUuids); |
219 |
} |
220 |
|
221 |
//character data |
222 |
if ($specimen->characterData) { |
223 |
$detail_html .= $is_specimen_page ? "<br>" : ""; |
224 |
$detail_html .= create_label("Character Data"); |
225 |
if ($is_specimen_page) { |
226 |
$detail_html .= "<br>"; |
227 |
foreach ($specimen->characterData as $characterStatePair) { |
228 |
$detail_html .= "<i>" . $characterStatePair->first . "</i>:" . $characterStatePair->second; |
229 |
$detail_html .= "<br>"; |
230 |
} |
231 |
} else { |
232 |
$detail_html .= l("detail page", $pathToSpecimen, array('attributes' => array('target' => '_blank'))); |
233 |
$detail_html .= "<br>"; |
234 |
} |
235 |
} |
236 |
return $detail_html; |
237 |
} |
238 |
|
239 |
function addImageGallery($galleryName, $imageUuids) |
240 |
{ |
241 |
$images = array(); |
242 |
foreach ($imageUuids as $uuid) { |
243 |
$images[] = cdm_ws_get(CDM_WS_PORTAL_MEDIA, $uuid); |
244 |
} |
245 |
|
246 |
$gallery_html = ''; |
247 |
if (count($imageUuids) > 0) { |
248 |
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME); |
249 |
$captionElements = array( |
250 |
'title', |
251 |
'rights', |
252 |
); |
253 |
$alternativeMediaUris = array(); |
254 |
foreach ($images as $image) { |
255 |
$mediaUri = getMediaUri($image); |
256 |
if ($mediaUri) { |
257 |
$alternativeMediaUris[] = $mediaUri; |
258 |
} else { |
259 |
$alternativeMediaUris[] = path_to_media($image->uuid); |
260 |
} |
261 |
} |
262 |
|
263 |
$gallery_html = compose_cdm_media_gallerie(array( |
264 |
'mediaList' => $images, |
265 |
'galleryName' => $galleryName, |
266 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
267 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
268 |
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null, |
269 |
'captionElements' => $captionElements, |
270 |
'mediaLinkType' => 'LIGHTBOX', |
271 |
'alternativeMediaUri' => $alternativeMediaUris, |
272 |
'galleryLinkUri' => NULL, |
273 |
)); |
274 |
} |
275 |
return "<br>" . create_label($galleryName) . "<br>" . $gallery_html; |
276 |
} |
277 |
|
278 |
function getMediaUri($media) |
279 |
{ |
280 |
if (isset($media->representations) && sizeof($media->representations) == 1 |
281 |
&& isset($media->representations[0]->parts) && |
282 |
sizeof($media->representations[0]->parts) == 1) { |
283 |
return $media->representations[0]->parts[0]->uri; |
284 |
} |
285 |
return null; |
286 |
} |
287 |
|
288 |
|
289 |
/** |
290 |
* Formats the given string to a label for displaying key-object pairs in HTML |
291 |
* @return string |
292 |
*/ |
293 |
function create_label($label) |
294 |
{ |
295 |
return "<span class='specimen_table_label'>" . $label . ": </span>"; |
296 |
} |
297 |
|
298 |
/** |
299 |
* Compose an render array from a CDM DerivedUnitFacade object. |
300 |
* |
301 |
* compose_hook() implementation |
302 |
* |
303 |
* @param object $specimenOrObservation |
304 |
* the CDM instance of type SpecimenOrObservation to compose |
305 |
* the render array for |
306 |
* @param array $derivatives |
307 |
* the render array which contains the compositions of the derivatives |
308 |
* of the supplied $specimenOrObservation |
309 |
* |
310 |
* @return array |
311 |
* the supplied render array $derivatives to which the composition of the supplied |
312 |
* $specimenOrObservation has been added to |
313 |
* |
314 |
* @ingroup compose |
315 |
*/ |
316 |
|
317 |
function compose_cdm_specimen_or_observation($specimen_or_observation, $isSpecimen_page = false, &$derivatives = null) |
318 |
{ |
319 |
$exclude_occurrence_fields = &drupal_static(__FUNCTION__); |
320 |
if (!isset($exclude_occurrence_fields)) { |
321 |
$exclude_occurrence_fields = array( |
322 |
|
323 |
'titleCache', |
324 |
'protectedTitleCache', |
325 |
'derivedUnitMedia', |
326 |
'created', |
327 |
'publish', |
328 |
'updated', |
329 |
'class', |
330 |
'uuid', |
331 |
'' |
332 |
); |
333 |
} |
334 |
if (variable_get('cdm_dataportal_compressed_specimen_derivate_table') || !$isSpecimen_page){ |
335 |
$exclude_occurrence_fields[] = 'derivationEvents'; |
336 |
} |
337 |
|
338 |
|
339 |
// only show uuid it the user is logged in |
340 |
// if(user_is_logged_in() && ($a_idx = array_search('uuid', $exclude_occurrence_fields)) !== FALSE ) { |
341 |
// unset($exclude_occurrence_fields[$a_idx]); |
342 |
// } |
343 |
|
344 |
if (!isset($derivatives)) { |
345 |
$derivatives = array(); |
346 |
} |
347 |
|
348 |
$descriptions = null; |
349 |
$derivedFrom = null; |
350 |
|
351 |
|
352 |
|
353 |
if (is_object($specimen_or_observation)) { |
354 |
|
355 |
// request again for deeper initialization |
356 |
$specimen_or_observation = cdm_ws_get("portal/" . CDM_WS_OCCURRENCE, $specimen_or_observation->uuid); |
357 |
if ($specimen_or_observation->class == 'FieldUnit'){ |
358 |
$specimen_or_observation->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array( |
359 |
$specimen_or_observation->uuid, |
360 |
'fieldObjectMediaDTO', |
361 |
)); |
362 |
}else{ |
363 |
$specimen_or_observation->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array( |
364 |
$specimen_or_observation->uuid, |
365 |
'derivedUnitMedia', |
366 |
)); |
367 |
} |
368 |
|
369 |
$type_label = $specimen_or_observation->class; |
370 |
RenderHints::setFootnoteListKey($type_label . '-' . $specimen_or_observation->uuid); |
371 |
|
372 |
// collect typeStatus as label |
373 |
if (isset($specimen_or_observation->specimenTypeDesignations)) { |
374 |
$type_status = array(); |
375 |
foreach ($specimen_or_observation->specimenTypeDesignations as $typeDesignation) { |
376 |
if (isset($typeDesignation->typeStatus->representation_L10n)) { |
377 |
$type_status[] = $typeDesignation->typeStatus->representation_L10n; |
378 |
} |
379 |
} |
380 |
if (count($type_status) > 0) { |
381 |
$type_label = implode(', ', $type_status); |
382 |
} |
383 |
} |
384 |
|
385 |
$title = $type_label . ': ' . $specimen_or_observation->titleCache; |
386 |
|
387 |
$groups = array(); |
388 |
|
389 |
// --- add initialized fields |
390 |
foreach (get_object_vars($specimen_or_observation) as $field => $value) { |
391 |
if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) { |
392 |
switch ($field) { |
393 |
|
394 |
/* ---- java.lang.Object --- */ |
395 |
case 'class': |
396 |
if ($value != '' /* FieldUnit' */) { |
397 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value); |
398 |
} |
399 |
break; |
400 |
|
401 |
case 'markers': |
402 |
$dd_elements = array(); |
403 |
foreach ($value as $marker) { |
404 |
$dd_elements[] = compose_cdm_marker($marker); |
405 |
} |
406 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements); |
407 |
break; |
408 |
|
409 |
|
410 |
case 'annotations': |
411 |
$dd_elements = array(); |
412 |
foreach ($value as $annotation) { |
413 |
// TODO respect annotation type filter settings |
414 |
$dd_elements[] = $annotation->text; |
415 |
} |
416 |
@_description_list_group_add($groups, t('Notes'), $dd_elements); |
417 |
break; |
418 |
|
419 |
/* ---- SpecimenOrObservationBase --- */ |
420 |
case 'sex': |
421 |
case 'lifeStage': |
422 |
case 'kindOfUnit': |
423 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->representation_L10n); |
424 |
break; |
425 |
|
426 |
case 'definition': |
427 |
// TODO |
428 |
break; |
429 |
|
430 |
case 'preferredStableUri': |
431 |
|
432 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), array(array('#markup' => cdm_external_uri($value, false)))); |
433 |
break; |
434 |
|
435 |
case 'specimenTypeDesignations': |
436 |
|
437 |
//TODO: better display of details!! |
438 |
@_description_list_group_add( |
439 |
$groups, |
440 |
cdm_occurrence_field_name_label($field), |
441 |
array( |
442 |
'#markup' => theme('cdm_typedesignations', array('typeDesignations' => $value)), |
443 |
) |
444 |
); |
445 |
break; |
446 |
|
447 |
case 'determinations': |
448 |
$dd_elements = array(); |
449 |
$glue = ', '; |
450 |
|
451 |
foreach ($value as $determinationEvent) { |
452 |
$timeperiod_string = NULL; |
453 |
if (isset($determinationEvent->timeperiod)) { |
454 |
$timeperiod_string = timePeriodToString($determinationEvent->timeperiod); |
455 |
} |
456 |
$weight = isset($determinationEvent->preferred) && $determinationEvent->preferred == 1 ? '0' : ($timeperiod_string ? $timeperiod_string : '1'); |
457 |
// check key exists |
458 |
while (array_key_exists($weight, $dd_elements)) { |
459 |
$weight .= '0'; |
460 |
} |
461 |
|
462 |
$taxon_name = ''; |
463 |
$name_link = ''; |
464 |
if ($determinationEvent->taxonName) { |
465 |
$taxon_name = $determinationEvent->taxonName; |
466 |
} else if ($determinationEvent->taxon) { |
467 |
$taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid); |
468 |
$name_link = path_to_taxon($determinationEvent->taxon->uuid); |
469 |
} |
470 |
if ($taxon_name) { |
471 |
$taxon_html = render_taxon_or_name($taxon_name, $name_link); |
472 |
$dd_elements[$weight] = $taxon_html; |
473 |
} |
474 |
if (isset($determinationEvent->modifier)) { |
475 |
$dd_elements[$weight] .= cdm_term_representation($determinationEvent->modifier); |
476 |
} |
477 |
if ($timeperiod_string) { |
478 |
$dd_elements[$weight] .= $glue . $timeperiod_string; |
479 |
} |
480 |
if (isset($determinationEvent->actor->titleCache)) { |
481 |
$dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache; |
482 |
} |
483 |
if (isset($determinationEvent->description)) { |
484 |
$dd_elements[$weight] .= $glue . $determinationEvent->description; |
485 |
} |
486 |
} |
487 |
ksort($dd_elements); |
488 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements); |
489 |
break; |
490 |
|
491 |
case 'descriptions': |
492 |
$occurrence_featureTree = cdm_get_occurrence_featureTree(); |
493 |
$dd_elements = array(); |
494 |
|
495 |
foreach ($value as $description) { |
496 |
$description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, $description->uuid); |
497 |
|
498 |
if($description->imageGallery == TRUE) { |
499 |
continue; |
500 |
} |
501 |
$elements_by_feature = _mergeFeatureTreeDescriptions($occurrence_featureTree->root->childNodes, $description->elements); |
502 |
$description_render_elements = _block_get_renderable_array(make_feature_block_list($elements_by_feature, null)); |
503 |
$dd_elements[] = $description_render_elements; |
504 |
} |
505 |
|
506 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements); |
507 |
break; |
508 |
case '_derivedUnitMedia': |
509 |
if ($isSpecimen_page){ |
510 |
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME); |
511 |
$captionElements = array( |
512 |
'#uri' => t('open media'), |
513 |
); |
514 |
$gallery_html = compose_cdm_media_gallerie(array( |
515 |
'mediaList' => $value, |
516 |
'galleryName' => $specimen_or_observation->titleCache, |
517 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
518 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
519 |
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null, |
520 |
'captionElements' => $captionElements, |
521 |
'mediaLinkType' => 'LIGHTBOX', |
522 |
'alternativeMediaUri' => NULL, |
523 |
'galleryLinkUri' => NULL, |
524 |
)); |
525 |
@_description_list_group_add($groups, "Detail Images:" , markup_to_render_array($gallery_html),'',20); |
526 |
} |
527 |
|
528 |
// $dd_elements[] = markup_to_render_array($gallery_html); |
529 |
|
530 |
break; |
531 |
case 'sources': |
532 |
$annotations_and_sources = handle_annotations_and_sources( |
533 |
$specimen_or_observation, |
534 |
array( |
535 |
'sources_as_content' => true, |
536 |
'link_to_name_used_in_source' => 1, |
537 |
'link_to_reference' => 0, |
538 |
'add_footnote_keys' => 0 |
539 |
), |
540 |
NULL, |
541 |
'' |
542 |
); |
543 |
if(!empty($annotations_and_sources['source_references'])){ |
544 |
@_description_list_group_add($groups, t('Sources') . ':', join(', ', $annotations_and_sources['source_references']),'',12 ); |
545 |
} |
546 |
break; |
547 |
|
548 |
|
549 |
/* ---- DerivedUnitBase --- */ |
550 |
case 'derivedFrom': |
551 |
$derivedFrom = $value; |
552 |
if ($isSpecimen_page) { |
553 |
foreach ($derivedFrom->originals as $original) { |
554 |
$pathToSpecimen = path_to_specimen($original->uuid); |
555 |
$description = ""; |
556 |
if (isset( $derivedFrom->description) && $derivedFrom->description != ''){ |
557 |
$description = $derivedFrom->description . ": "; |
558 |
} |
559 |
|
560 |
$originals[] = markup_to_render_array(l($description . $original->titleCache, $pathToSpecimen, array('attributes' => array('target' => '_blank')))); |
561 |
if ($original->class == 'FieldUnit'){ |
562 |
$label = t('Field data'); |
563 |
}else{ |
564 |
$label = t('Derived from'); |
565 |
} |
566 |
@_description_list_group_add($groups, $label . ':', |
567 |
$originals, |
568 |
'', 13); |
569 |
} |
570 |
} |
571 |
break; |
572 |
case 'derivationEvents': |
573 |
$derivationEvents = $value; |
574 |
$derived_units = array(); |
575 |
if ($isSpecimen_page) { |
576 |
foreach ($derivationEvents as $derivationEvent) { |
577 |
foreach ($derivationEvent->derivatives as $derived_unit) { |
578 |
$pathToSpecimen = path_to_specimen($derived_unit->uuid); |
579 |
$description = ""; |
580 |
if (isset($derived_unit->description) && $derived_unit->description != '') { |
581 |
$description = $derived_unit->description . ": "; |
582 |
} |
583 |
|
584 |
$derived_units[] = markup_to_render_array(l($description . $derived_unit->titleCache, $pathToSpecimen, array('attributes' => array('target' => '_blank')))); |
585 |
} |
586 |
} @_description_list_group_add($groups, t('Derivates') . ':', |
587 |
$derived_units, |
588 |
'', 100); |
589 |
|
590 |
} |
591 |
break; |
592 |
|
593 |
case 'collection': |
594 |
$sub_dl_groups = array(); |
595 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1); |
596 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2); |
597 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3); |
598 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4); |
599 |
// TODO "superCollection" |
600 |
// TODO may have media |
601 |
|
602 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), |
603 |
array( |
604 |
array('#markup' => $value->titleCache), |
605 |
array('#theme' => 'description_list', '#groups' => $sub_dl_groups) |
606 |
) |
607 |
); |
608 |
break; |
609 |
|
610 |
case 'storedUnder': |
611 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value)); |
612 |
break; |
613 |
|
614 |
|
615 |
/* ---- Specimen --- */ |
616 |
case 'sequences': |
617 |
$dd_elements = array(); |
618 |
foreach ($value as $sequence) { |
619 |
$dd_elements[] = compose_cdm_sequence($sequence); |
620 |
} |
621 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements); |
622 |
break; |
623 |
|
624 |
// TODO preservation |
625 |
// TODO exsiccatum |
626 |
|
627 |
|
628 |
/* ---- FieldObservation --- */ |
629 |
case 'gatheringEvent': |
630 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->actor->titleCache, '', 1); |
631 |
@_description_list_group_add($groups, t('Gathering date'), timePeriodToString($value->timeperiod), '', 2); |
632 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description, '', 3); |
633 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality->text, '', 10); |
634 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country->representation_L10n, '', 4); |
635 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod,'',5); |
636 |
if (isset($value->absoluteElevation)) { |
637 |
$min_max_markup = min_max_measure($value, 'absoluteElevation'); |
638 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('absoluteElevation'), $min_max_markup, '',6); |
639 |
} |
640 |
if (isset($value->distanceToGround)) { |
641 |
$min_max_markup = min_max_measure($value, 'distanceToGround'); |
642 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToGround'), $min_max_markup,'',7); |
643 |
} |
644 |
if (isset($value->distanceToWaterSurface)) { |
645 |
$min_max_markup = min_max_measure($value, 'distanceToWaterSurface'); |
646 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToWaterSurface'), $min_max_markup, '',8); |
647 |
} |
648 |
if (isset($value->collectingAreas) && count($value->collectingAreas) > 0) { |
649 |
$area_representations = array(); |
650 |
foreach ($value->collectingAreas as $area) { |
651 |
$area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid)); |
652 |
} |
653 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'), |
654 |
array( |
655 |
array('#markup' => implode(', ', $area_representations)) |
656 |
),'',9 |
657 |
); |
658 |
} |
659 |
if (isset($value->exactLocation) && $value->exactLocation->sexagesimalString) { |
660 |
$sub_dl_groups = array(); |
661 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1); |
662 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2); |
663 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('latitude'), round($value->exactLocation->latitude, 7), '°', 3); |
664 |
if (isset($value->exactLocation->referenceSystem)) { |
665 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4); |
666 |
} |
667 |
|
668 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'), |
669 |
array( |
670 |
array('#markup' => $value->exactLocation->sexagesimalString), |
671 |
array( |
672 |
'#theme' => 'description_list', |
673 |
'#groups' => $sub_dl_groups |
674 |
), |
675 |
),'',11 |
676 |
); |
677 |
} |
678 |
break; |
679 |
|
680 |
default: |
681 |
if (is_object($value) || is_array($value)) { |
682 |
drupal_set_message("Unhandled type in compose_cdm_specimen_or_observation() for field " . $field, "warning"); |
683 |
} else { |
684 |
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), cdm_occurrence_field_name_label($value)); |
685 |
} |
686 |
|
687 |
} |
688 |
|
689 |
} |
690 |
} // END of loop over $derivedUnitFacade fields |
691 |
|
692 |
// Extensions |
693 |
$extensions = cdm_ws_fetch_all(CDM_WS_PORTAL_OCCURRENCE . '/' . $specimen_or_observation->uuid . '/extensions', array($specimen_or_observation->uuid)); |
694 |
if ($extensions && count($extensions)) { |
695 |
|
696 |
$extensions_render_array = compose_extensions($extensions); |
697 |
@_description_list_group_add($groups, t('Extensions') . ':', |
698 |
$extensions_render_array, |
699 |
'', 100); |
700 |
} |
701 |
|
702 |
|
703 |
|
704 |
// template_preprocess_description_list() is not worting by weight so we do it right here |
705 |
uasort($groups, 'element_sort'); |
706 |
|
707 |
$occurrence_elements = array( |
708 |
// '#title' => $title, |
709 |
'#theme' => 'description_list', |
710 |
'#groups' => $groups, |
711 |
'#attributes' => array('class' => html_class_attribute_ref($specimen_or_observation)), |
712 |
); |
713 |
|
714 |
$derivatives[] = drupal_render($occurrence_elements); |
715 |
// all footnotes which has been assembled so far (e.g. from typeDesignations) to here |
716 |
// $foonote_li_elements = theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'span')); |
717 |
// if (!empty($foonote_li_elements)) { |
718 |
// $derivatives[] = array( |
719 |
// '#markup' => '<div class="footnotes">' . $foonote_li_elements . '</div>', |
720 |
// ); |
721 |
// } |
722 |
|
723 |
// --- recurse into originals |
724 |
if (!isset($derivedFrom) && !$isSpecimen_page) { |
725 |
$derivedFrom = cdm_ws_get( |
726 |
CDM_WS_OCCURRENCE, |
727 |
array($specimen_or_observation->uuid, 'derivedFrom') |
728 |
); |
729 |
} |
730 |
if (isset($derivedFrom) && !$isSpecimen_page) { |
731 |
if (isset($derivedFrom->originals)) { |
732 |
$derived_from_label = t('derived'); |
733 |
$preposition = t('from'); |
734 |
if(isset($derivedFrom->type)){ |
735 |
$derived_from_label = $derivedFrom->type->representation_L10n; |
736 |
if($derivedFrom->type->uuid == UUID_DERIVATIONEVENTTYPE_ACCESSIONING){ |
737 |
$preposition = t('of'); |
738 |
} |
739 |
} |
740 |
if (count($groups) > 0) { |
741 |
// TODO annotations |
742 |
|
743 |
// only display the derived from information when the derivative has any element which will be diplayed |
744 |
$derivatives[] = array( |
745 |
'#markup' => '<div class="derived_from">' . $derived_from_label . ' ' . $preposition . ': </div>', |
746 |
); |
747 |
} |
748 |
foreach ($derivedFrom->originals as $original) { |
749 |
compose_cdm_specimen_or_observation($original, $isSpecimen_page, $derivatives); |
750 |
} |
751 |
} |
752 |
} |
753 |
|
754 |
|
755 |
|
756 |
|
757 |
} // END of $specimenOrObservation exists |
758 |
|
759 |
return $derivatives; |
760 |
} |
761 |
|
762 |
|
763 |
/** |
764 |
* Compose an render array from a CDM Sequence object. |
765 |
* |
766 |
* compose_hook() implementation |
767 |
* |
768 |
* @param object $sequence |
769 |
* CDM instance of type Sequence |
770 |
* @return array |
771 |
* A render array containing the fields of the supplied $sequence |
772 |
* |
773 |
* @ingroup compose |
774 |
*/ |
775 |
function compose_cdm_sequence($sequence, $isSpecimenPage = false) |
776 |
{ |
777 |
|
778 |
$exclude_sequence_fields = &drupal_static(__FUNCTION__); |
779 |
if (!isset($exclude_sequence_fields)) { |
780 |
$exclude_sequence_fields = array( |
781 |
'titleCache', |
782 |
'protectedTitleCache', |
783 |
'microReference', |
784 |
'created', |
785 |
'updated', |
786 |
'class', |
787 |
); |
788 |
} |
789 |
|
790 |
$groups = array(); |
791 |
|
792 |
// -- retrieve additional data if neesscary |
793 |
// TODO below call disabled since sequences are not yet supported, |
794 |
// see #3347 (services and REST service controller for molecular classes implemented) |
795 |
// |
796 |
// cdm_load_annotations($sequence); |
797 |
|
798 |
foreach (get_object_vars($sequence) as $field => $value) { |
799 |
|
800 |
|
801 |
if (!in_array($field, $exclude_sequence_fields) && ($value && (!is_object($value) || isset($value->class)))) { |
802 |
switch ($field) { |
803 |
|
804 |
case 'geneticAccessionNumber'; |
805 |
|
806 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 2); |
807 |
break; |
808 |
|
809 |
|
810 |
case 'dnaMarker': // FIXME 3.3 now dnaMarker (DefinedTerm) if multiple amplifications where used to build this consensus sequence it may be the super set of the markers used in amplification. |
811 |
if (isset($value->name)) { |
812 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->name, NULL, 3); |
813 |
} |
814 |
if (isset($value->description)) { |
815 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field) . ' ' . t('description'), $value->description, NULL, 4); |
816 |
} |
817 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field) , $value, NULL, 4); |
818 |
break; |
819 |
|
820 |
case 'consensusSequence': |
821 |
// format in genbank style, force linebreaks after each 70 nucleotites |
822 |
// see also http://stackoverflow.com/questions/499137/css-how-can-i-force-a-long-string-without-any-blank-to-be-wrapped-in-xul-and |
823 |
if ($value->length > 0) { |
824 |
@_description_list_group_add( |
825 |
$groups, |
826 |
cdm_occurrence_field_name_label($field), |
827 |
array( |
828 |
array( |
829 |
'#markup' => '<div class="sequence-length">' . $value->length . ' ' . t('pb') . '</div><div>' . wordwrap($value->string, 70, '</br>', TRUE) . '</div>', |
830 |
'#wrapper_attributes' => array('class' => 'dna-sequence') |
831 |
) |
832 |
), |
833 |
5); |
834 |
} |
835 |
break; |
836 |
|
837 |
case 'dnaSample': // FIXME 3.3 implement |
838 |
break; |
839 |
case 'singleReads': // FIXME 3.3 implement |
840 |
break; |
841 |
case 'contigFile': // FIXME 3.3 implement - Media |
842 |
break; |
843 |
case 'pherograms': // FIXME 3.3 implement - Media |
844 |
break; |
845 |
case 'haplotype': // FIXME 3.3 implement |
846 |
break; |
847 |
case 'dateSequenced': // FIXME 3.3 now in SingelRead |
848 |
@_description_list_group_add($groups, t('Sequencing date'), timePeriodToString($value), NULL, 6); |
849 |
break; |
850 |
|
851 |
case 'barcode': // boolean |
852 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value ? 'Yes' : 'No', NULL, 7); |
853 |
break; |
854 |
case 'barcodeSequencePart': // FIXME 3.3 implement, compose sequence |
855 |
break; |
856 |
|
857 |
case 'citation': |
858 |
@_description_list_group_add($groups, |
859 |
cdm_occurrence_field_name_label($field), |
860 |
theme('cdm_reference', array('reference' => $value, 'microReference' => $sequence->microReference)), |
861 |
NULL, |
862 |
8 |
863 |
); |
864 |
break; |
865 |
|
866 |
case 'publishedIn': |
867 |
@_description_list_group_add($groups, |
868 |
cdm_occurrence_field_name_label($field), |
869 |
theme('cdm_reference', array('reference' => $value)), |
870 |
NULL, |
871 |
7 |
872 |
); |
873 |
break; |
874 |
|
875 |
case 'rights': |
876 |
array_merge($groups, cdm_rights_as_dl_groups($value)); |
877 |
break; |
878 |
|
879 |
case 'annotations': |
880 |
$dd_elements = array(); |
881 |
foreach ($value as $annotation) { |
882 |
// TODO respect annotation type filter settings |
883 |
$dd_elements[] = $annotation->text; |
884 |
} |
885 |
@_description_list_group_add($groups, t('Notes'), $dd_elements, NULL, 9); |
886 |
break; |
887 |
|
888 |
case 'markers': |
889 |
$dd_elements = array(); |
890 |
foreach ($value as $marker) { |
891 |
$dd_elements[] = compose_cdm_marker($marker); |
892 |
} |
893 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 10); |
894 |
break; |
895 |
|
896 |
case 'chromatograms': |
897 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), |
898 |
array( |
899 |
'#markup' => compose_cdm_media_gallerie(array('medialist' => $value)), |
900 |
), |
901 |
NULL, |
902 |
11); |
903 |
break; |
904 |
|
905 |
default: |
906 |
if (is_object($value) || is_array($value)) { |
907 |
drupal_set_message("Unhandled type in compose_cdm_sequence() for field " . $field, "warning"); |
908 |
} else { |
909 |
if (!is_array($value) && strpos($value, 'http:') !== false ){ |
910 |
//make links for urls |
911 |
$value = l($value, $value, array('attributes' => array('target' => '_blank'))); |
912 |
$value = markup_to_render_array($value); |
913 |
} |
914 |
|
915 |
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 20); |
916 |
} |
917 |
} |
918 |
} |
919 |
} |
920 |
|
921 |
// template_preprocess_description_list() is not worting by weight so we do it right here |
922 |
uasort($groups, 'element_sort'); |
923 |
if ($isSpecimenPage) { |
924 |
$sequence_elements = array( |
925 |
'#title' => $sequence->dnaMarker, |
926 |
'#theme' => 'description_list', |
927 |
'#groups' => $groups |
928 |
); |
929 |
} else{ |
930 |
$sequence_elements = array( |
931 |
'#title' => $sequence->dnaMarker -> titleCache, |
932 |
'#theme' => 'description_list', |
933 |
'#groups' => $groups |
934 |
); |
935 |
} |
936 |
|
937 |
return $sequence_elements; |
938 |
} |
939 |
/** |
940 |
* Creates an array from a list of FieldUnitDTOs. |
941 |
* |
942 |
* |
943 |
* @param object $specimenOrObservations |
944 |
* list of FieldUnitDTOs |
945 |
* @return array |
946 |
* An array containing the hierarchy of the field units corresponding to the taxon |
947 |
* |
948 |
* @ingroup compose |
949 |
*/ |
950 |
function compose_specimen_array(array $specimenOrObservations){ |
951 |
$items_specimen = array(); |
952 |
$items = array(); |
953 |
|
954 |
//we need one more item to contain the items of one level (fieldunit, derivate data etc.) |
955 |
foreach ($specimenOrObservations as &$specimenOrObservation) { |
956 |
|
957 |
$items['data'] = $specimenOrObservation->listLabel ; |
958 |
$specimen = compose_cdm_specimen_or_observation_tree_entry($specimenOrObservation); |
959 |
$children = array(); |
960 |
$child = array(); |
961 |
$child['data'] =$specimen; |
962 |
// $children[] = create_specimen_array($specimenOrObservation->derivates); |
963 |
if (isset($specimenOrObservation->derivates) && sizeof($specimenOrObservation->derivates) > 0){ |
964 |
$child['children']= compose_specimen_array($specimenOrObservation->derivates); |
965 |
} |
966 |
$children[]=$child; |
967 |
$items['children'] = $children; |
968 |
$items_specimen[] = $items; |
969 |
} |
970 |
return $items_specimen; |
971 |
} |
972 |
|
973 |
|
974 |
/** |
975 |
* Compose an render array from a CDM DerivedUnitFacade object. |
976 |
* |
977 |
* compose_hook() implementation |
978 |
* |
979 |
* @param object $specimenOrObservation |
980 |
* the CDM instance of type SpecimenOrObservation to compose |
981 |
* the render array for |
982 |
* @param array $derivatives |
983 |
* the render array which contains the compositions of the derivatives |
984 |
* of the supplied $specimenOrObservation |
985 |
* |
986 |
* @return array |
987 |
* the supplied render array $derivatives to which the composition of the supplied |
988 |
* $specimenOrObservation has been added to |
989 |
* |
990 |
* @ingroup compose |
991 |
*/ |
992 |
|
993 |
function compose_cdm_specimen_or_observation_tree_entry($specimen_or_observation) |
994 |
{ |
995 |
$exclude_occurrence_fields = &drupal_static(__FUNCTION__); |
996 |
if (!isset($exclude_occurrence_fields)) { |
997 |
$exclude_occurrence_fields = array( |
998 |
'type', |
999 |
'taxonRelatedDerivedUnits', |
1000 |
'label', |
1001 |
'titleCache', |
1002 |
'listLabel', |
1003 |
'protectedTitleCache', |
1004 |
'class', |
1005 |
'uuid', |
1006 |
'derivates', |
1007 |
'collection' |
1008 |
); |
1009 |
} |
1010 |
$items = array(); |
1011 |
|
1012 |
// only show uuid it the user is logged in |
1013 |
if (user_is_logged_in() && ($a_idx = array_search('uuid', $exclude_occurrence_fields)) !== FALSE) { |
1014 |
// unset($exclude_occurrence_fields[$a_idx]); |
1015 |
} |
1016 |
|
1017 |
|
1018 |
if (is_object($specimen_or_observation)) { |
1019 |
|
1020 |
$type_label = $specimen_or_observation->recordBase; |
1021 |
RenderHints::setFootnoteListKey($type_label . '-' . $specimen_or_observation->uuid); |
1022 |
|
1023 |
// collect typeStatus as label |
1024 |
if (isset($specimen_or_observation->specimenTypeDesignations)) { |
1025 |
$type_status = array(); |
1026 |
foreach ($specimen_or_observation->specimenTypeDesignations as $typeDesignation) { |
1027 |
if (isset($typeDesignation->typeStatus->representation_L10n)) { |
1028 |
$type_status[] = $typeDesignation->typeStatus->representation_L10n; |
1029 |
} |
1030 |
} |
1031 |
if (count($type_status) > 0) { |
1032 |
$type_label = implode(', ', $type_status); |
1033 |
} |
1034 |
} |
1035 |
|
1036 |
$title = $type_label . ': ' . $specimen_or_observation->titleCache; |
1037 |
$items['data'] = $title; |
1038 |
|
1039 |
$groups = array(); |
1040 |
$items['children'] = $groups; |
1041 |
$children_items = array(); |
1042 |
// --- add initialized fields |
1043 |
foreach (get_object_vars($specimen_or_observation) as $field => $value) { |
1044 |
$child_item = array(); |
1045 |
|
1046 |
if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) { |
1047 |
switch ($field) { |
1048 |
|
1049 |
/* ---- SpecimenOrObservationBase --- */ |
1050 |
case 'derivationEvent': |
1051 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 1); |
1052 |
break; |
1053 |
case 'kindOfUnit': |
1054 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 1); |
1055 |
break; |
1056 |
|
1057 |
|
1058 |
case 'preferredStableUri': |
1059 |
|
1060 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), array(array('#markup' => cdm_external_uri($value, false)))); |
1061 |
break; |
1062 |
|
1063 |
case 'specimenTypeDesignations': |
1064 |
@_description_list_group_add( |
1065 |
$groups, |
1066 |
cdm_occurrence_field_name_label($field), |
1067 |
array( |
1068 |
'#markup' => theme('cdm_typedesignations', array('typeDesignations' => $value)), |
1069 |
) |
1070 |
); |
1071 |
break; |
1072 |
|
1073 |
|
1074 |
|
1075 |
case 'listOfMedia': |
1076 |
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME); |
1077 |
$captionElements = array( |
1078 |
'#uri' => t('open media'), |
1079 |
); |
1080 |
$gallery_html = compose_cdm_media_gallerie(array( |
1081 |
'mediaList' => $value, |
1082 |
'galleryName' => $specimen_or_observation->label, |
1083 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
1084 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
1085 |
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null, |
1086 |
'captionElements' => $captionElements, |
1087 |
'mediaLinkType' => 'LIGHTBOX', |
1088 |
'alternativeMediaUri' => NULL, |
1089 |
'galleryLinkUri' => NULL, |
1090 |
)); |
1091 |
|
1092 |
//@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $gallery_html); |
1093 |
break; |
1094 |
|
1095 |
|
1096 |
|
1097 |
/* ---- DerivedUnitBase --- */ |
1098 |
|
1099 |
|
1100 |
case 'collectionDTO': |
1101 |
|
1102 |
$sub_dl_groups = array(); |
1103 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1); |
1104 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2); |
1105 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3); |
1106 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4); |
1107 |
// TODO "superCollection" |
1108 |
// TODO may have media |
1109 |
|
1110 |
@_description_list_group_add($groups, 'Collection', |
1111 |
array( |
1112 |
array('#markup' => $value->titleCache), |
1113 |
array('#theme' => 'description_list', '#groups' => $sub_dl_groups) |
1114 |
) |
1115 |
); |
1116 |
|
1117 |
break; |
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 |
/* ---- Specimen --- */ |
1123 |
case 'sequences': |
1124 |
$dd_elements = array(); |
1125 |
foreach ($value as $sequence) { |
1126 |
$dd_elements[] = compose_cdm_sequence($sequence, true); |
1127 |
$dd_elements[] = ""; |
1128 |
} |
1129 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements,'', 100); |
1130 |
break; |
1131 |
|
1132 |
// TODO preservation |
1133 |
// TODO exsiccatum |
1134 |
|
1135 |
|
1136 |
/* ---- FieldObservation --- */ |
1137 |
case 'gatheringEvent': |
1138 |
|
1139 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->collector); |
1140 |
@_description_list_group_add($groups, t('Gathering date'), timePeriodToString($value->timeperiod)); |
1141 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description); |
1142 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality, '', 10); |
1143 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country); |
1144 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod); |
1145 |
if (isset($value->absoluteElevation)) { |
1146 |
$min_max_markup = min_max_measure($value, 'absoluteElevation'); |
1147 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('absoluteElevation'), $min_max_markup); |
1148 |
} |
1149 |
if (isset($value->distanceToGround) && $value->distanceToGround >0) { |
1150 |
$min_max_markup = min_max_measure($value, 'distanceToGround'); |
1151 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToGround'), $min_max_markup); |
1152 |
} |
1153 |
if (isset($value->distanceToWaterSurface) && $value->distanceToWaterSurface > 0) { |
1154 |
$min_max_markup = min_max_measure($value, 'distanceToWaterSurface'); |
1155 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToWaterSurface'), $min_max_markup); |
1156 |
} |
1157 |
|
1158 |
if (isset($value->collectingAreas)) { |
1159 |
$area_representations = array(); |
1160 |
foreach ($value->collectingAreas as $area) { |
1161 |
// $area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid)); |
1162 |
$area_representations[] = $area; |
1163 |
} |
1164 |
if (!empty($area_representations)) |
1165 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'), |
1166 |
array( |
1167 |
array('#markup' => implode(', ', $area_representations)) |
1168 |
) |
1169 |
); |
1170 |
} |
1171 |
if (isset($value->exactLocation) ) { |
1172 |
$sub_dl_groups = array(); |
1173 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1); |
1174 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2); |
1175 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('latitude'), round($value->exactLocation->latitude, 7), '°', 3); |
1176 |
if (isset($value->exactLocation->referenceSystem)) { |
1177 |
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4); |
1178 |
} |
1179 |
if ( isSet($value->exactLocation->sexagesimalString)){ |
1180 |
@_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'), |
1181 |
array( |
1182 |
array('#markup' => $value->exactLocation->sexagesimalString), |
1183 |
array( |
1184 |
'#theme' => 'description_list', |
1185 |
'#groups' => $sub_dl_groups |
1186 |
), |
1187 |
), '', 11 |
1188 |
); |
1189 |
} |
1190 |
} |
1191 |
|
1192 |
break; |
1193 |
|
1194 |
/* ---- DerivationEvent --- */ |
1195 |
case 'derivationEvents': |
1196 |
//@_description_list_group_add($groups, t('Association type'), $value->description); |
1197 |
break; |
1198 |
|
1199 |
|
1200 |
default: |
1201 |
if (is_object($value) || is_array($value)) { |
1202 |
drupal_set_message("Unhandled type in compose_cdm_specimenOrObservation() for field " . $field, "warning"); |
1203 |
} else { |
1204 |
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value); |
1205 |
} |
1206 |
|
1207 |
} |
1208 |
|
1209 |
|
1210 |
} |
1211 |
} // END of loop over $derivedUnitFacade fields |
1212 |
|
1213 |
|
1214 |
|
1215 |
// template_preprocess_description_list() is not worting by weight so we do it right here |
1216 |
uasort($groups, 'element_sort'); |
1217 |
|
1218 |
$occurrence_elements = array( |
1219 |
// '#title' => $title, |
1220 |
'#theme' => 'description_list', |
1221 |
'#groups' => $groups, |
1222 |
'#attributes' => array('class' => html_class_attribute_ref($specimen_or_observation)), |
1223 |
); |
1224 |
$output = drupal_render($occurrence_elements); |
1225 |
if (isset($gallery_html)){ |
1226 |
$output .= $gallery_html; |
1227 |
} |
1228 |
$pathToSpecimen = path_to_specimen($specimen_or_observation->uuid); |
1229 |
$output .= l("detail page", $pathToSpecimen, array('attributes' => array('target' => '_blank'))); |
1230 |
} // END of $specimenOrObservation exists |
1231 |
|
1232 |
return $output; |
1233 |
} |
1234 |
|