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->second, path_to_taxon($associatedTaxon->first, "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
|
@_description_list_group_add(
|
437
|
$groups,
|
438
|
cdm_occurrence_field_name_label($field),
|
439
|
array(
|
440
|
'#markup' => theme('cdm_typedesignations', array('typeDesignations' => $value)),
|
441
|
)
|
442
|
);
|
443
|
break;
|
444
|
|
445
|
case 'determinations':
|
446
|
$dd_elements = array();
|
447
|
$glue = ', ';
|
448
|
|
449
|
foreach ($value as $determinationEvent) {
|
450
|
$timeperiod_string = NULL;
|
451
|
if (isset($determinationEvent->timeperiod)) {
|
452
|
$timeperiod_string = timePeriodToString($determinationEvent->timeperiod);
|
453
|
}
|
454
|
$weight = isset($determinationEvent->preferred) && $determinationEvent->preferred == 1 ? '0' : ($timeperiod_string ? $timeperiod_string : '1');
|
455
|
// check key exists
|
456
|
while (array_key_exists($weight, $dd_elements)) {
|
457
|
$weight .= '0';
|
458
|
}
|
459
|
|
460
|
$taxon_name = '';
|
461
|
$name_link = '';
|
462
|
if ($determinationEvent->taxonName) {
|
463
|
$taxon_name = $determinationEvent->taxonName;
|
464
|
} else if ($determinationEvent->taxon) {
|
465
|
$taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
|
466
|
$name_link = path_to_taxon($determinationEvent->taxon->uuid);
|
467
|
}
|
468
|
if ($taxon_name) {
|
469
|
$taxon_html = render_taxon_or_name($taxon_name, $name_link);
|
470
|
$dd_elements[$weight] = $taxon_html;
|
471
|
}
|
472
|
if (isset($determinationEvent->modifier)) {
|
473
|
$dd_elements[$weight] .= cdm_term_representation($determinationEvent->modifier);
|
474
|
}
|
475
|
if ($timeperiod_string) {
|
476
|
$dd_elements[$weight] .= $glue . $timeperiod_string;
|
477
|
}
|
478
|
if (isset($determinationEvent->actor->titleCache)) {
|
479
|
$dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache;
|
480
|
}
|
481
|
if (isset($determinationEvent->description)) {
|
482
|
$dd_elements[$weight] .= $glue . $determinationEvent->description;
|
483
|
}
|
484
|
}
|
485
|
ksort($dd_elements);
|
486
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements);
|
487
|
break;
|
488
|
|
489
|
case 'descriptions':
|
490
|
$occurrence_featureTree = cdm_get_occurrence_featureTree();
|
491
|
$dd_elements = array();
|
492
|
|
493
|
foreach ($value as $description) {
|
494
|
$description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, $description->uuid);
|
495
|
|
496
|
if($description->imageGallery == TRUE) {
|
497
|
continue;
|
498
|
}
|
499
|
$elements_by_feature = _mergeFeatureTreeDescriptions($occurrence_featureTree->root->childNodes, $description->elements);
|
500
|
$description_render_elements = _block_get_renderable_array(make_feature_block_list($elements_by_feature, null));
|
501
|
$dd_elements[] = $description_render_elements;
|
502
|
}
|
503
|
|
504
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
505
|
break;
|
506
|
case '_derivedUnitMedia':
|
507
|
if ($isSpecimen_page){
|
508
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
509
|
$captionElements = array(
|
510
|
'#uri' => t('open media'),
|
511
|
);
|
512
|
$gallery_html = compose_cdm_media_gallerie(array(
|
513
|
'mediaList' => $value,
|
514
|
'galleryName' => $specimen_or_observation->titleCache,
|
515
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
516
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
517
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
518
|
'captionElements' => $captionElements,
|
519
|
'mediaLinkType' => 'LIGHTBOX',
|
520
|
'alternativeMediaUri' => NULL,
|
521
|
'galleryLinkUri' => NULL,
|
522
|
));
|
523
|
@_description_list_group_add($groups, "Detail Images:" , markup_to_render_array($gallery_html));
|
524
|
}
|
525
|
|
526
|
// $dd_elements[] = markup_to_render_array($gallery_html);
|
527
|
|
528
|
break;
|
529
|
case 'sources':
|
530
|
$dd_elements = array();
|
531
|
foreach ($value as $identifiable_source) {
|
532
|
$dd_elements[] = theme('cdm_OriginalSource', array('source' => $identifiable_source));
|
533
|
}
|
534
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
535
|
break;
|
536
|
|
537
|
|
538
|
/* ---- DerivedUnitBase --- */
|
539
|
case 'derivedFrom':
|
540
|
$derivedFrom = $value;
|
541
|
if ($isSpecimen_page) {
|
542
|
foreach ($derivedFrom->originals as $original) {
|
543
|
$pathToSpecimen = path_to_specimen($original->uuid);
|
544
|
$description = "";
|
545
|
if (isset( $derivedFrom->description) && $derivedFrom->description != ''){
|
546
|
$description = $derivedFrom->description . ": ";
|
547
|
}
|
548
|
|
549
|
$originals[] = markup_to_render_array(l($description . $original->titleCache, $pathToSpecimen, array('attributes' => array('target' => '_blank'))));
|
550
|
@_description_list_group_add($groups, t('Originals') . ':',
|
551
|
$originals,
|
552
|
'', 1);
|
553
|
}
|
554
|
}
|
555
|
break;
|
556
|
case 'derivationEvents':
|
557
|
$derivationEvents = $value;
|
558
|
$derived_units = array();
|
559
|
if ($isSpecimen_page) {
|
560
|
foreach ($derivationEvents as $derivationEvent) {
|
561
|
foreach ($derivationEvent->derivatives as $derived_unit) {
|
562
|
$pathToSpecimen = path_to_specimen($derived_unit->uuid);
|
563
|
$description = "";
|
564
|
if (isset($derived_unit->description) && $derived_unit->description != '') {
|
565
|
$description = $derived_unit->description . ": ";
|
566
|
}
|
567
|
|
568
|
$derived_units[] = markup_to_render_array(l($description . $derived_unit->titleCache, $pathToSpecimen, array('attributes' => array('target' => '_blank'))));
|
569
|
}
|
570
|
} @_description_list_group_add($groups, t('Derivates') . ':',
|
571
|
$derived_units,
|
572
|
'', 100);
|
573
|
|
574
|
}
|
575
|
break;
|
576
|
|
577
|
case 'collection':
|
578
|
$sub_dl_groups = array();
|
579
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1);
|
580
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2);
|
581
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3);
|
582
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4);
|
583
|
// TODO "superCollection"
|
584
|
// TODO may have media
|
585
|
|
586
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
|
587
|
array(
|
588
|
array('#markup' => $value->titleCache),
|
589
|
array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
|
590
|
)
|
591
|
);
|
592
|
break;
|
593
|
|
594
|
case 'storedUnder':
|
595
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value));
|
596
|
break;
|
597
|
|
598
|
|
599
|
/* ---- Specimen --- */
|
600
|
case 'sequences':
|
601
|
$dd_elements = array();
|
602
|
foreach ($value as $sequence) {
|
603
|
$dd_elements[] = compose_cdm_sequence($sequence);
|
604
|
}
|
605
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
606
|
break;
|
607
|
|
608
|
// TODO preservation
|
609
|
// TODO exsiccatum
|
610
|
|
611
|
|
612
|
/* ---- FieldObservation --- */
|
613
|
case 'gatheringEvent':
|
614
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->actor->titleCache);
|
615
|
@_description_list_group_add($groups, t('Gathering time'), timePeriodToString($value->timeperiod));
|
616
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description);
|
617
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality->text);
|
618
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country->representation_L10n);
|
619
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod);
|
620
|
if (isset($value->absoluteElevation)) {
|
621
|
$min_max_markup = min_max_measure($value, 'absoluteElevation');
|
622
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('absoluteElevation'), $min_max_markup);
|
623
|
}
|
624
|
if (isset($value->distanceToGround)) {
|
625
|
$min_max_markup = min_max_measure($value, 'distanceToGround');
|
626
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToGround'), $min_max_markup);
|
627
|
}
|
628
|
if (isset($value->distanceToWaterSurface)) {
|
629
|
$min_max_markup = min_max_measure($value, 'distanceToWaterSurface');
|
630
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToWaterSurface'), $min_max_markup);
|
631
|
}
|
632
|
|
633
|
if (isset($value->collectingAreas) && count($value->collectingAreas) > 0) {
|
634
|
$area_representations = array();
|
635
|
foreach ($value->collectingAreas as $area) {
|
636
|
$area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid));
|
637
|
}
|
638
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'),
|
639
|
array(
|
640
|
array('#markup' => implode(', ', $area_representations))
|
641
|
)
|
642
|
);
|
643
|
}
|
644
|
if (isset($value->exactLocation) && $value->exactLocation->sexagesimalString) {
|
645
|
$sub_dl_groups = array();
|
646
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1);
|
647
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2);
|
648
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('latitude'), round($value->exactLocation->latitude, 7), '°', 3);
|
649
|
if (isset($value->exactLocation->referenceSystem)) {
|
650
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4);
|
651
|
}
|
652
|
|
653
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
|
654
|
array(
|
655
|
array('#markup' => $value->exactLocation->sexagesimalString),
|
656
|
array(
|
657
|
'#theme' => 'description_list',
|
658
|
'#groups' => $sub_dl_groups
|
659
|
),
|
660
|
)
|
661
|
);
|
662
|
}
|
663
|
break;
|
664
|
|
665
|
default:
|
666
|
if (is_object($value) || is_array($value)) {
|
667
|
drupal_set_message("Unhandled type in compose_cdm_specimen_or_observation() for field " . $field, "warning");
|
668
|
} else {
|
669
|
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
670
|
}
|
671
|
|
672
|
}
|
673
|
|
674
|
}
|
675
|
} // END of loop over $derivedUnitFacade fields
|
676
|
|
677
|
// Extensions
|
678
|
$extensions = cdm_ws_fetch_all(CDM_WS_PORTAL_OCCURRENCE . '/' . $specimen_or_observation->uuid . '/extensions', array($specimen_or_observation->uuid));
|
679
|
if ($extensions && count($extensions)) {
|
680
|
|
681
|
$extensions_render_array = compose_extensions($extensions);
|
682
|
@_description_list_group_add($groups, t('Extensions') . ':',
|
683
|
$extensions_render_array,
|
684
|
'', 100);
|
685
|
}
|
686
|
|
687
|
|
688
|
|
689
|
// template_preprocess_description_list() is not worting by weight so we do it right here
|
690
|
uasort($groups, 'element_sort');
|
691
|
|
692
|
$occurrence_elements = array(
|
693
|
'#title' => $title,
|
694
|
'#theme' => 'description_list',
|
695
|
'#groups' => $groups,
|
696
|
'#attributes' => array('class' => html_class_attribute_ref($specimen_or_observation)),
|
697
|
);
|
698
|
|
699
|
$derivatives[] = $occurrence_elements;
|
700
|
// all footnotes which has been assembled so far (e.g. from typeDesignations) to here
|
701
|
$foonote_li_elements = theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'span'));
|
702
|
if (!empty($foonote_li_elements)) {
|
703
|
$derivatives[] = array(
|
704
|
'#markup' => '<div class="footnotes">' . $foonote_li_elements . '</div>',
|
705
|
);
|
706
|
}
|
707
|
|
708
|
// --- recurse into originals
|
709
|
if (!isset($derivedFrom) && !$isSpecimen_page) {
|
710
|
$derivedFrom = cdm_ws_get(
|
711
|
CDM_WS_OCCURRENCE,
|
712
|
array($specimen_or_observation->uuid, 'derivedFrom')
|
713
|
);
|
714
|
}
|
715
|
if (isset($derivedFrom) && !$isSpecimen_page) {
|
716
|
if (isset($derivedFrom->originals)) {
|
717
|
$derived_from_label = t('derived');
|
718
|
$preposition = t('from');
|
719
|
if(isset($derivedFrom->type)){
|
720
|
$derived_from_label = $derivedFrom->type->representation_L10n;
|
721
|
if($derivedFrom->type->uuid == UUID_DERIVATIONEVENTTYPE_ACCESSIONING){
|
722
|
$preposition = t('of');
|
723
|
}
|
724
|
}
|
725
|
if (count($groups) > 0) {
|
726
|
// TODO annotations
|
727
|
|
728
|
// only display the derived from information when the derivative has any element which will be diplayed
|
729
|
$derivatives[] = array(
|
730
|
'#markup' => '<div class="derived_from">' . $derived_from_label . ' ' . $preposition . ': </div>',
|
731
|
);
|
732
|
}
|
733
|
foreach ($derivedFrom->originals as $original) {
|
734
|
compose_cdm_specimen_or_observation($original, $isSpecimen_page, $derivatives);
|
735
|
}
|
736
|
}
|
737
|
}
|
738
|
|
739
|
|
740
|
|
741
|
|
742
|
} // END of $specimenOrObservation exists
|
743
|
|
744
|
return $derivatives;
|
745
|
}
|
746
|
|
747
|
|
748
|
/**
|
749
|
* Compose an render array from a CDM Sequence object.
|
750
|
*
|
751
|
* compose_hook() implementation
|
752
|
*
|
753
|
* @param object $sequence
|
754
|
* CDM instance of type Sequence
|
755
|
* @return array
|
756
|
* A render array containing the fields of the supplied $sequence
|
757
|
*
|
758
|
* @ingroup compose
|
759
|
*/
|
760
|
function compose_cdm_sequence($sequence, $isSpecimenPage = false)
|
761
|
{
|
762
|
|
763
|
$exclude_sequence_fields = &drupal_static(__FUNCTION__);
|
764
|
if (!isset($exclude_sequence_fields)) {
|
765
|
$exclude_sequence_fields = array(
|
766
|
'titleCache',
|
767
|
'protectedTitleCache',
|
768
|
'microReference',
|
769
|
'created',
|
770
|
'updated',
|
771
|
'class',
|
772
|
);
|
773
|
}
|
774
|
|
775
|
$groups = array();
|
776
|
|
777
|
// -- retrieve additional data if neesscary
|
778
|
// TODO below call disabled since sequences are not yet supported,
|
779
|
// see #3347 (services and REST service controller for molecular classes implemented)
|
780
|
//
|
781
|
// cdm_load_annotations($sequence);
|
782
|
|
783
|
foreach (get_object_vars($sequence) as $field => $value) {
|
784
|
|
785
|
|
786
|
if (!in_array($field, $exclude_sequence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
|
787
|
switch ($field) {
|
788
|
|
789
|
case 'geneticAccessionNumber';
|
790
|
|
791
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 2);
|
792
|
break;
|
793
|
|
794
|
|
795
|
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.
|
796
|
if (isset($value->name)) {
|
797
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->name, NULL, 3);
|
798
|
}
|
799
|
if (isset($value->description)) {
|
800
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field) . ' ' . t('description'), $value->description, NULL, 4);
|
801
|
}
|
802
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field) , $value, NULL, 4);
|
803
|
break;
|
804
|
|
805
|
case 'consensusSequence':
|
806
|
// format in genbank style, force linebreaks after each 70 nucleotites
|
807
|
// see also http://stackoverflow.com/questions/499137/css-how-can-i-force-a-long-string-without-any-blank-to-be-wrapped-in-xul-and
|
808
|
if ($value->length > 0) {
|
809
|
@_description_list_group_add(
|
810
|
$groups,
|
811
|
cdm_occurrence_field_name_label($field),
|
812
|
array(
|
813
|
array(
|
814
|
'#markup' => '<div class="sequence-length">' . $value->length . ' ' . t('pb') . '</div><div>' . wordwrap($value->string, 70, '</br>', TRUE) . '</div>',
|
815
|
'#wrapper_attributes' => array('class' => 'dna-sequence')
|
816
|
)
|
817
|
),
|
818
|
5);
|
819
|
}
|
820
|
break;
|
821
|
|
822
|
case 'dnaSample': // FIXME 3.3 implement
|
823
|
break;
|
824
|
case 'singleReads': // FIXME 3.3 implement
|
825
|
break;
|
826
|
case 'contigFile': // FIXME 3.3 implement - Media
|
827
|
break;
|
828
|
case 'pherograms': // FIXME 3.3 implement - Media
|
829
|
break;
|
830
|
case 'haplotype': // FIXME 3.3 implement
|
831
|
break;
|
832
|
case 'dateSequenced': // FIXME 3.3 now in SingelRead
|
833
|
@_description_list_group_add($groups, t('Sequencing date'), timePeriodToString($value), NULL, 6);
|
834
|
break;
|
835
|
|
836
|
case 'barcode': // boolean
|
837
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value ? 'Yes' : 'No', NULL, 7);
|
838
|
break;
|
839
|
case 'barcodeSequencePart': // FIXME 3.3 implement, compose sequence
|
840
|
break;
|
841
|
|
842
|
case 'citation':
|
843
|
@_description_list_group_add($groups,
|
844
|
cdm_occurrence_field_name_label($field),
|
845
|
theme('cdm_reference', array('reference' => $value, 'microReference' => $sequence->microReference)),
|
846
|
NULL,
|
847
|
8
|
848
|
);
|
849
|
break;
|
850
|
|
851
|
case 'publishedIn':
|
852
|
@_description_list_group_add($groups,
|
853
|
cdm_occurrence_field_name_label($field),
|
854
|
theme('cdm_reference', array('reference' => $value)),
|
855
|
NULL,
|
856
|
7
|
857
|
);
|
858
|
break;
|
859
|
|
860
|
case 'rights':
|
861
|
array_merge($groups, cdm_rights_as_dl_groups($value));
|
862
|
break;
|
863
|
|
864
|
case 'annotations':
|
865
|
$dd_elements = array();
|
866
|
foreach ($value as $annotation) {
|
867
|
// TODO respect annotation type filter settings
|
868
|
$dd_elements[] = $annotation->text;
|
869
|
}
|
870
|
@_description_list_group_add($groups, t('Notes'), $dd_elements, NULL, 9);
|
871
|
break;
|
872
|
|
873
|
case 'markers':
|
874
|
$dd_elements = array();
|
875
|
foreach ($value as $marker) {
|
876
|
$dd_elements[] = compose_cdm_marker($marker);
|
877
|
}
|
878
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 10);
|
879
|
break;
|
880
|
|
881
|
case 'chromatograms':
|
882
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
|
883
|
array(
|
884
|
'#markup' => compose_cdm_media_gallerie(array('medialist' => $value)),
|
885
|
),
|
886
|
NULL,
|
887
|
11);
|
888
|
break;
|
889
|
|
890
|
default:
|
891
|
if (is_object($value) || is_array($value)) {
|
892
|
drupal_set_message("Unhandled type in compose_cdm_sequence() for field " . $field, "warning");
|
893
|
} else {
|
894
|
if (!is_array($value) && strpos($value, 'http:') !== false ){
|
895
|
//make links for urls
|
896
|
$value = l($value, $value, array('attributes' => array('target' => '_blank')));
|
897
|
$value = markup_to_render_array($value);
|
898
|
}
|
899
|
|
900
|
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 20);
|
901
|
}
|
902
|
}
|
903
|
}
|
904
|
}
|
905
|
|
906
|
// template_preprocess_description_list() is not worting by weight so we do it right here
|
907
|
uasort($groups, 'element_sort');
|
908
|
if ($isSpecimenPage) {
|
909
|
$sequence_elements = array(
|
910
|
'#title' => $sequence->dnaMarker,
|
911
|
'#theme' => 'description_list',
|
912
|
'#groups' => $groups
|
913
|
);
|
914
|
} else{
|
915
|
$sequence_elements = array(
|
916
|
'#title' => $sequence->dnaMarker -> titleCache,
|
917
|
'#theme' => 'description_list',
|
918
|
'#groups' => $groups
|
919
|
);
|
920
|
}
|
921
|
|
922
|
return $sequence_elements;
|
923
|
}
|
924
|
/**
|
925
|
* Creates an array from a list of FieldUnitDTOs.
|
926
|
*
|
927
|
*
|
928
|
* @param object $specimenOrObservations
|
929
|
* list of FieldUnitDTOs
|
930
|
* @return array
|
931
|
* An array containing the hierarchy of the field units corresponding to the taxon
|
932
|
*
|
933
|
* @ingroup compose
|
934
|
*/
|
935
|
function compose_specimen_array(array $specimenOrObservations){
|
936
|
$items_specimen = array();
|
937
|
$items = array();
|
938
|
|
939
|
//we need one more item to contain the items of one level (fieldunit, derivate data etc.)
|
940
|
foreach ($specimenOrObservations as &$specimenOrObservation) {
|
941
|
|
942
|
$items['data'] = $specimenOrObservation->listLabel ;
|
943
|
$specimen = compose_cdm_specimen_or_observation_tree_entry($specimenOrObservation);
|
944
|
$children = array();
|
945
|
$child = array();
|
946
|
$child['data'] =$specimen;
|
947
|
// $children[] = create_specimen_array($specimenOrObservation->derivates);
|
948
|
if (isset($specimenOrObservation->derivates) && sizeof($specimenOrObservation->derivates) > 0){
|
949
|
$child['children']= compose_specimen_array($specimenOrObservation->derivates);
|
950
|
}
|
951
|
$children[]=$child;
|
952
|
$items['children'] = $children;
|
953
|
$items_specimen[] = $items;
|
954
|
}
|
955
|
return $items_specimen;
|
956
|
}
|
957
|
|
958
|
|
959
|
/**
|
960
|
* Compose an render array from a CDM DerivedUnitFacade object.
|
961
|
*
|
962
|
* compose_hook() implementation
|
963
|
*
|
964
|
* @param object $specimenOrObservation
|
965
|
* the CDM instance of type SpecimenOrObservation to compose
|
966
|
* the render array for
|
967
|
* @param array $derivatives
|
968
|
* the render array which contains the compositions of the derivatives
|
969
|
* of the supplied $specimenOrObservation
|
970
|
*
|
971
|
* @return array
|
972
|
* the supplied render array $derivatives to which the composition of the supplied
|
973
|
* $specimenOrObservation has been added to
|
974
|
*
|
975
|
* @ingroup compose
|
976
|
*/
|
977
|
|
978
|
function compose_cdm_specimen_or_observation_tree_entry($specimen_or_observation)
|
979
|
{
|
980
|
$exclude_occurrence_fields = &drupal_static(__FUNCTION__);
|
981
|
if (!isset($exclude_occurrence_fields)) {
|
982
|
$exclude_occurrence_fields = array(
|
983
|
'type',
|
984
|
'taxonRelatedDerivedUnits',
|
985
|
'label',
|
986
|
'titleCache',
|
987
|
'listLabel',
|
988
|
'protectedTitleCache',
|
989
|
'class',
|
990
|
'uuid',
|
991
|
'derivates'
|
992
|
);
|
993
|
}
|
994
|
$items = array();
|
995
|
|
996
|
// only show uuid it the user is logged in
|
997
|
if (user_is_logged_in() && ($a_idx = array_search('uuid', $exclude_occurrence_fields)) !== FALSE) {
|
998
|
// unset($exclude_occurrence_fields[$a_idx]);
|
999
|
}
|
1000
|
|
1001
|
|
1002
|
if (is_object($specimen_or_observation)) {
|
1003
|
|
1004
|
$type_label = $specimen_or_observation->recordBase;
|
1005
|
RenderHints::setFootnoteListKey($type_label . '-' . $specimen_or_observation->uuid);
|
1006
|
|
1007
|
// collect typeStatus as label
|
1008
|
if (isset($specimen_or_observation->specimenTypeDesignations)) {
|
1009
|
$type_status = array();
|
1010
|
foreach ($specimen_or_observation->specimenTypeDesignations as $typeDesignation) {
|
1011
|
if (isset($typeDesignation->typeStatus->representation_L10n)) {
|
1012
|
$type_status[] = $typeDesignation->typeStatus->representation_L10n;
|
1013
|
}
|
1014
|
}
|
1015
|
if (count($type_status) > 0) {
|
1016
|
$type_label = implode(', ', $type_status);
|
1017
|
}
|
1018
|
}
|
1019
|
|
1020
|
$title = $type_label . ': ' . $specimen_or_observation->titleCache;
|
1021
|
$items['data'] = $title;
|
1022
|
|
1023
|
$groups = array();
|
1024
|
$items['children'] = $groups;
|
1025
|
$children_items = array();
|
1026
|
// --- add initialized fields
|
1027
|
foreach (get_object_vars($specimen_or_observation) as $field => $value) {
|
1028
|
$child_item = array();
|
1029
|
|
1030
|
if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
|
1031
|
switch ($field) {
|
1032
|
|
1033
|
/* ---- SpecimenOrObservationBase --- */
|
1034
|
case 'derivationEvent':
|
1035
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 1);
|
1036
|
break;
|
1037
|
case 'kindOfUnit':
|
1038
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 1);
|
1039
|
break;
|
1040
|
|
1041
|
|
1042
|
case 'preferredStableUri':
|
1043
|
|
1044
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), array(array('#markup' => cdm_external_uri($value, false))));
|
1045
|
break;
|
1046
|
|
1047
|
case 'specimenTypeDesignations':
|
1048
|
@_description_list_group_add(
|
1049
|
$groups,
|
1050
|
cdm_occurrence_field_name_label($field),
|
1051
|
array(
|
1052
|
'#markup' => theme('cdm_typedesignations', array('typeDesignations' => $value)),
|
1053
|
)
|
1054
|
);
|
1055
|
break;
|
1056
|
|
1057
|
|
1058
|
|
1059
|
case 'listOfMedia':
|
1060
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
1061
|
$captionElements = array(
|
1062
|
'#uri' => t('open media'),
|
1063
|
);
|
1064
|
$gallery_html = compose_cdm_media_gallerie(array(
|
1065
|
'mediaList' => $value,
|
1066
|
'galleryName' => $specimen_or_observation->label,
|
1067
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
1068
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
1069
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
1070
|
'captionElements' => $captionElements,
|
1071
|
'mediaLinkType' => 'LIGHTBOX',
|
1072
|
'alternativeMediaUri' => NULL,
|
1073
|
'galleryLinkUri' => NULL,
|
1074
|
));
|
1075
|
|
1076
|
//@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $gallery_html);
|
1077
|
break;
|
1078
|
|
1079
|
|
1080
|
|
1081
|
/* ---- DerivedUnitBase --- */
|
1082
|
|
1083
|
|
1084
|
case 'collectionDTO':
|
1085
|
|
1086
|
$sub_dl_groups = array();
|
1087
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1);
|
1088
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2);
|
1089
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3);
|
1090
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4);
|
1091
|
// TODO "superCollection"
|
1092
|
// TODO may have media
|
1093
|
|
1094
|
@_description_list_group_add($groups, 'Collection',
|
1095
|
array(
|
1096
|
array('#markup' => $value->titleCache),
|
1097
|
array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
|
1098
|
)
|
1099
|
);
|
1100
|
|
1101
|
break;
|
1102
|
|
1103
|
|
1104
|
|
1105
|
|
1106
|
/* ---- Specimen --- */
|
1107
|
case 'sequences':
|
1108
|
$dd_elements = array();
|
1109
|
foreach ($value as $sequence) {
|
1110
|
$dd_elements[] = compose_cdm_sequence($sequence, true);
|
1111
|
$dd_elements[] = "";
|
1112
|
}
|
1113
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements,'', 100);
|
1114
|
break;
|
1115
|
|
1116
|
// TODO preservation
|
1117
|
// TODO exsiccatum
|
1118
|
|
1119
|
|
1120
|
/* ---- FieldObservation --- */
|
1121
|
case 'gatheringEvent':
|
1122
|
|
1123
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->collector);
|
1124
|
@_description_list_group_add($groups, t('Gathering time'), timePeriodToString($value->timeperiod));
|
1125
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description);
|
1126
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality);
|
1127
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country);
|
1128
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod);
|
1129
|
if (isset($value->absoluteElevation)) {
|
1130
|
$min_max_markup = min_max_measure($value, 'absoluteElevation');
|
1131
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('absoluteElevation'), $min_max_markup);
|
1132
|
}
|
1133
|
if (isset($value->distanceToGround) && $value->distanceToGround >0) {
|
1134
|
$min_max_markup = min_max_measure($value, 'distanceToGround');
|
1135
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToGround'), $min_max_markup);
|
1136
|
}
|
1137
|
if (isset($value->distanceToWaterSurface) && $value->distanceToWaterSurface > 0) {
|
1138
|
$min_max_markup = min_max_measure($value, 'distanceToWaterSurface');
|
1139
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToWaterSurface'), $min_max_markup);
|
1140
|
}
|
1141
|
|
1142
|
if (isset($value->collectingAreas)) {
|
1143
|
$area_representations = array();
|
1144
|
foreach ($value->collectingAreas as $area) {
|
1145
|
// $area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid));
|
1146
|
$area_representations[] = $area;
|
1147
|
}
|
1148
|
if (!empty($area_representations))
|
1149
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'),
|
1150
|
array(
|
1151
|
array('#markup' => implode(', ', $area_representations))
|
1152
|
)
|
1153
|
);
|
1154
|
}
|
1155
|
if (isset($value->exactLocation) ) {
|
1156
|
$sub_dl_groups = array();
|
1157
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1);
|
1158
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2);
|
1159
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('latitude'), round($value->exactLocation->latitude, 7), '°', 3);
|
1160
|
if (isset($value->exactLocation->referenceSystem)) {
|
1161
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4);
|
1162
|
}
|
1163
|
if ( isSet($value->exactLocation->sexagesimalString)){
|
1164
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
|
1165
|
array(
|
1166
|
array('#markup' => $value->exactLocation->sexagesimalString),
|
1167
|
array(
|
1168
|
'#theme' => 'description_list',
|
1169
|
'#groups' => $sub_dl_groups
|
1170
|
),
|
1171
|
)
|
1172
|
);
|
1173
|
}
|
1174
|
}
|
1175
|
|
1176
|
break;
|
1177
|
|
1178
|
/* ---- DerivationEvent --- */
|
1179
|
case 'derivationEvents':
|
1180
|
//@_description_list_group_add($groups, t('Association type'), $value->description);
|
1181
|
break;
|
1182
|
|
1183
|
|
1184
|
default:
|
1185
|
if (is_object($value) || is_array($value)) {
|
1186
|
drupal_set_message("Unhandled type in compose_cdm_specimenOrObservation() for field " . $field, "warning");
|
1187
|
} else {
|
1188
|
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
1189
|
}
|
1190
|
|
1191
|
}
|
1192
|
|
1193
|
|
1194
|
}
|
1195
|
} // END of loop over $derivedUnitFacade fields
|
1196
|
|
1197
|
|
1198
|
|
1199
|
// template_preprocess_description_list() is not worting by weight so we do it right here
|
1200
|
uasort($groups, 'element_sort');
|
1201
|
|
1202
|
$occurrence_elements = array(
|
1203
|
// '#title' => $title,
|
1204
|
'#theme' => 'description_list',
|
1205
|
'#groups' => $groups,
|
1206
|
'#attributes' => array('class' => html_class_attribute_ref($specimen_or_observation)),
|
1207
|
);
|
1208
|
$output = drupal_render($occurrence_elements);
|
1209
|
if (isset($gallery_html)){
|
1210
|
$output .= $gallery_html;
|
1211
|
}
|
1212
|
$pathToSpecimen = path_to_specimen($specimen_or_observation->uuid);
|
1213
|
$output .= l("detail page", $pathToSpecimen, array('attributes' => array('target' => '_blank')));
|
1214
|
} // END of $specimenOrObservation exists
|
1215
|
|
1216
|
return $output;
|
1217
|
}
|
1218
|
|