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, $is_specimen_page = false)
|
29
|
{
|
30
|
$detail_html = "";
|
31
|
//link to specimen page
|
32
|
$pathToSpecimen = path_to_specimen($specimen->uuid);
|
33
|
if (!$is_specimen_page) {
|
34
|
$specimenPageLink = l($specimen->accessionNumber, $pathToSpecimen, array('attributes' => array('target' => '_blank')));
|
35
|
$detail_html .= "<strong>$specimenPageLink</strong><br>";
|
36
|
}
|
37
|
|
38
|
if ($is_specimen_page) {
|
39
|
if ($specimen->citation) {
|
40
|
$detail_html .= "<br>" . create_label("Citation") . $specimen->citation . "<br>";
|
41
|
}
|
42
|
}
|
43
|
if ($specimen->preferredStableUri) {
|
44
|
$stableIdentifierLink = l($specimen->preferredStableUri, $specimen->preferredStableUri, array('attributes' => array('target' => '_blank')));
|
45
|
$detail_html .= create_label("Preferred stable URI") . $stableIdentifierLink . "<br>";
|
46
|
}
|
47
|
if ($is_specimen_page) {
|
48
|
// associated taxa
|
49
|
if ($specimen->associatedTaxa) {
|
50
|
$detail_html .= "<br>";
|
51
|
$detail_html .= create_label("Associated with");
|
52
|
if (sizeof($specimen->associatedTaxa) > 1) {
|
53
|
$detail_html .= "<br>";
|
54
|
}
|
55
|
foreach ($specimen->associatedTaxa as $associatedTaxon) {
|
56
|
$detail_html .= l($associatedTaxon->second, path_to_taxon($associatedTaxon->first, "specimens"));//$associatedTaxon->second."<br>";
|
57
|
}
|
58
|
$detail_html .= "<br>";
|
59
|
}
|
60
|
}
|
61
|
// - type information
|
62
|
$types = "";
|
63
|
if (isset($specimen->types)) {
|
64
|
//typed taxa
|
65
|
foreach ($specimen->types as $typeStatus => $typedTaxa) {
|
66
|
/* Updated upstream
|
67
|
if($specimen->types){
|
68
|
$detail_html .= "<i>".$typeStatus."</i> of ";
|
69
|
foreach($typedTaxa as $typedTaxon){
|
70
|
$detail_html .= $typedTaxon." ";
|
71
|
}
|
72
|
$detail_html .= "<br>";
|
73
|
*/
|
74
|
if ($is_specimen_page) {
|
75
|
if ($specimen->types) {
|
76
|
$detail_html .= "<i>" . $typeStatus . "</i>: ";
|
77
|
foreach ($typedTaxa as $typedTaxon) {
|
78
|
$detail_html .= $typedTaxon . " ";
|
79
|
}
|
80
|
$detail_html .= "<br>";
|
81
|
}
|
82
|
} else {
|
83
|
$types .= $typeStatus . " ";
|
84
|
|
85
|
}
|
86
|
}
|
87
|
}
|
88
|
$derivateDataDTO = $specimen->derivateDataDTO;
|
89
|
// - specimen scans
|
90
|
$specimenScans = create_html_links($derivateDataDTO->specimenScans, true);
|
91
|
// - molecular data
|
92
|
$molecularData = "";
|
93
|
if ($derivateDataDTO->molecularDataList) {
|
94
|
foreach ($derivateDataDTO->molecularDataList as $molecular) {
|
95
|
//provider link
|
96
|
if (isset($molecular->providerLink)) {
|
97
|
$molecularData .= create_html_link($molecular->providerLink, true);
|
98
|
} else {
|
99
|
$molecularData .= "[no provider]";
|
100
|
}
|
101
|
//contig link
|
102
|
if (isset($molecular->contigFiles)) {
|
103
|
$molecularData .= "[";
|
104
|
if (sizeof($molecular->contigFiles) > 0) {
|
105
|
foreach ($molecular->contigFiles as $contigFile) {
|
106
|
if (isset($contigFile->contigLink)) {
|
107
|
if (isset($contigFile->contigLink->uri) and $contigFile->contigLink->uri != null) {
|
108
|
$molecularData .= create_html_link($contigFile->contigLink, true) . " ";
|
109
|
}
|
110
|
} else {
|
111
|
$molecularData .= "no contig ";
|
112
|
}
|
113
|
//primer links
|
114
|
if (isset($contigFile->primerLinks)) {
|
115
|
$molecularData .= create_html_links($contigFile->primerLinks, true);
|
116
|
}
|
117
|
}
|
118
|
}
|
119
|
$molecularData = rtrim($molecularData, " ");
|
120
|
$molecularData .= "]";
|
121
|
}
|
122
|
//FIXME separate with comma (remove trailing comma)
|
123
|
}
|
124
|
}
|
125
|
// - detail images
|
126
|
$detailImages = create_html_links($derivateDataDTO->detailImages, true);
|
127
|
|
128
|
if ($types) {
|
129
|
$detail_html .= $is_specimen_page ? "<br>" : "";
|
130
|
$detail_html .= create_label("Type(s)") . $types . "<br>";
|
131
|
}
|
132
|
if ($specimenScans and !$is_specimen_page) {
|
133
|
$detail_html .= create_label("Specimen Scans") . $specimenScans . "<br>";
|
134
|
}
|
135
|
//specimen scan image gallery
|
136
|
if ($is_specimen_page and isset($derivateDataDTO->specimenScanUuids) and !empty($derivateDataDTO->specimenScanUuids)) {
|
137
|
$detail_html .= addImageGallery("Specimen scans", $derivateDataDTO->specimenScanUuids);
|
138
|
}
|
139
|
|
140
|
if ($molecularData) {
|
141
|
$detail_html .= $is_specimen_page ? "<br>" : "";
|
142
|
$detail_html .= create_label("Molecular Data") . $molecularData . "<br>";
|
143
|
}
|
144
|
|
145
|
if ($detailImages and !$is_specimen_page) {
|
146
|
$detail_html .= create_label("Detail Images") . $detailImages . "<br>";
|
147
|
}
|
148
|
|
149
|
//detail image gallery
|
150
|
if ($is_specimen_page and isset($derivateDataDTO->detailImageUuids) and !empty($derivateDataDTO->detailImageUuids)) {
|
151
|
$detail_html .= addImageGallery("Detail Images", $derivateDataDTO->detailImageUuids);
|
152
|
}
|
153
|
|
154
|
//character data
|
155
|
if ($specimen->characterData) {
|
156
|
$detail_html .= $is_specimen_page ? "<br>" : "";
|
157
|
$detail_html .= create_label("Character Data");
|
158
|
if ($is_specimen_page) {
|
159
|
$detail_html .= "<br>";
|
160
|
foreach ($specimen->characterData as $characterStatePair) {
|
161
|
$detail_html .= "<i>" . $characterStatePair->first . "</i>:" . $characterStatePair->second;
|
162
|
$detail_html .= "<br>";
|
163
|
}
|
164
|
} else {
|
165
|
$detail_html .= l("detail page", $pathToSpecimen, array('attributes' => array('target' => '_blank')));
|
166
|
$detail_html .= "<br>";
|
167
|
}
|
168
|
}
|
169
|
return $detail_html;
|
170
|
}
|
171
|
|
172
|
function addImageGallery($galleryName, $imageUuids)
|
173
|
{
|
174
|
$images = array();
|
175
|
foreach ($imageUuids as $uuid) {
|
176
|
$images[] = cdm_ws_get(CDM_WS_PORTAL_MEDIA, $uuid);
|
177
|
}
|
178
|
|
179
|
$gallery_html = '';
|
180
|
if (count($imageUuids) > 0) {
|
181
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
182
|
$captionElements = array(
|
183
|
'title',
|
184
|
'rights',
|
185
|
);
|
186
|
$alternativeMediaUris = array();
|
187
|
foreach ($images as $image) {
|
188
|
$mediaUri = getMediaUri($image);
|
189
|
if ($mediaUri) {
|
190
|
$alternativeMediaUris[] = $mediaUri;
|
191
|
} else {
|
192
|
$alternativeMediaUris[] = path_to_media($image->uuid);
|
193
|
}
|
194
|
}
|
195
|
|
196
|
$gallery_html = compose_cdm_media_gallerie(array(
|
197
|
'mediaList' => $images,
|
198
|
'galleryName' => $galleryName,
|
199
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
200
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
201
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
202
|
'captionElements' => $captionElements,
|
203
|
'mediaLinkType' => 'LIGHTBOX',
|
204
|
'alternativeMediaUri' => $alternativeMediaUris,
|
205
|
'galleryLinkUri' => NULL,
|
206
|
));
|
207
|
}
|
208
|
return "<br>" . create_label($galleryName) . "<br>" . $gallery_html;
|
209
|
}
|
210
|
|
211
|
function getMediaUri($media)
|
212
|
{
|
213
|
if (isset($media->representations) && sizeof($media->representations) == 1
|
214
|
&& isset($media->representations[0]->parts) &&
|
215
|
sizeof($media->representations[0]->parts) == 1) {
|
216
|
return $media->representations[0]->parts[0]->uri;
|
217
|
}
|
218
|
return null;
|
219
|
}
|
220
|
|
221
|
|
222
|
/**
|
223
|
* Formats the given string to a label for displaying key-object pairs in HTML
|
224
|
* @return string
|
225
|
*/
|
226
|
function create_label($label)
|
227
|
{
|
228
|
return "<span class='specimen_table_label'>" . $label . ": </span>";
|
229
|
}
|
230
|
|
231
|
/**
|
232
|
* Compose an render array from a CDM DerivedUnitFacade object.
|
233
|
*
|
234
|
* compose_hook() implementation
|
235
|
*
|
236
|
* @param object $specimenOrObservation
|
237
|
* the CDM instance of type SpecimenOrObservation to compose
|
238
|
* the render array for
|
239
|
* @param array $derivatives
|
240
|
* the render array which contains the compositions of the derivatives
|
241
|
* of the supplied $specimenOrObservation
|
242
|
*
|
243
|
* @return array
|
244
|
* the supplied render array $derivatives to which the composition of the supplied
|
245
|
* $specimenOrObservation has been added to
|
246
|
*
|
247
|
* @ingroup compose
|
248
|
*/
|
249
|
/*<<<<<<< Updated upstream
|
250
|
function compose_cdm_specimen_or_observation($specimenOrObservation, &$derivatives = null) {
|
251
|
|
252
|
$exclude_occurrence_fields = &drupal_static(__FUNCTION__);
|
253
|
if (!isset($exclude_occurrence_fields)) {
|
254
|
$exclude_occurrence_fields = array(
|
255
|
'derivationEvents',
|
256
|
'titleCache',
|
257
|
'protectedTitleCache',
|
258
|
'derivedUnitMedia',
|
259
|
'created',
|
260
|
'publish',
|
261
|
'updated',
|
262
|
'class',
|
263
|
'uuid',
|
264
|
''
|
265
|
);
|
266
|
}
|
267
|
|
268
|
|
269
|
// only show uuid it the user is logged in
|
270
|
if(user_is_logged_in() && ($a_idx = array_search('uuid', $exclude_occurrence_fields)) !== FALSE ) {
|
271
|
unset($exclude_occurrence_fields[$a_idx]);
|
272
|
}
|
273
|
|
274
|
if (!isset($derivatives)) {
|
275
|
$derivatives = array();
|
276
|
}
|
277
|
|
278
|
$descriptions = null;
|
279
|
$derivedFrom = null;
|
280
|
=======*/
|
281
|
function compose_cdm_specimenOrObservation($specimenOrObservation, &$derivatives = null)
|
282
|
{
|
283
|
|
284
|
//>>>>>>> Stashed changes
|
285
|
$exclude_occurrence_fields = &drupal_static(__FUNCTION__);
|
286
|
if (!isset($exclude_occurrence_fields)) {
|
287
|
$exclude_occurrence_fields = array(
|
288
|
// 'derivationEvents',
|
289
|
'titleCache',
|
290
|
'protectedTitleCache',
|
291
|
'derivedUnitMedia',
|
292
|
'created',
|
293
|
'publish',
|
294
|
'updated',
|
295
|
'class',
|
296
|
'uuid',
|
297
|
''
|
298
|
);
|
299
|
}
|
300
|
|
301
|
|
302
|
// only show uuid it the user is logged in
|
303
|
if (user_is_logged_in() && ($a_idx = array_search('uuid', $exclude_occurrence_fields)) !== FALSE) {
|
304
|
unset($exclude_occurrence_fields[$a_idx]);
|
305
|
}
|
306
|
|
307
|
if (!isset($derivatives)) {
|
308
|
$derivatives = array();
|
309
|
}
|
310
|
|
311
|
$descriptions = null;
|
312
|
$derivedFrom = null;
|
313
|
$derivates = null;
|
314
|
|
315
|
if (is_object($specimenOrObservation)) {
|
316
|
|
317
|
// request again for deeper initialization
|
318
|
// $specimenOrObservation = cdm_ws_get("portal/" . CDM_WS_OCCURRENCE, $specimenOrObservation->uuid);
|
319
|
|
320
|
|
321
|
$type_label = $specimenOrObservation->recordBase;
|
322
|
RenderHints::setFootnoteListKey($type_label . '-' . $specimenOrObservation->uuid);
|
323
|
/*
|
324
|
* $label_html = cdm_dynabox(
|
325
|
$specimenOrObservation->uuid,
|
326
|
$type_label . $specimenOrObservation->titleCache,
|
327
|
$derived_unit_ws_request, //cdm_ws_get("portal/" . CDM_WS_OCCURRENCE, $specimenOrObservation->uuid);
|
328
|
'cdm_specimenOrObservation',
|
329
|
'Click for details',
|
330
|
array('div', 'div'),
|
331
|
array(),
|
332
|
null, // $content_element_selector
|
333
|
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').hide(); }', // open_callback
|
334
|
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').show(); }' // close_callback
|
335
|
);
|
336
|
|
337
|
*/
|
338
|
// collect typeStatus as label
|
339
|
if (isset($specimenOrObservation->specimenTypeDesignations)) {
|
340
|
$type_status = array();
|
341
|
foreach ($specimenOrObservation->specimenTypeDesignations as $typeDesignation) {
|
342
|
if (isset($typeDesignation->typeStatus->representation_L10n)) {
|
343
|
$type_status[] = $typeDesignation->typeStatus->representation_L10n;
|
344
|
}
|
345
|
}
|
346
|
if (count($type_status) > 0) {
|
347
|
$type_label = implode(', ', $type_status);
|
348
|
}
|
349
|
}
|
350
|
|
351
|
$title = $type_label . ': ' . $specimenOrObservation->titleCache;
|
352
|
|
353
|
$groups = array();
|
354
|
// --- add initialized fields
|
355
|
foreach (get_object_vars($specimenOrObservation) as $field => $value) {
|
356
|
if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
|
357
|
switch ($field) {
|
358
|
// case 'recordBasis':
|
359
|
// if ($value != '' /* FieldUnit' */) {
|
360
|
// @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
361
|
// }
|
362
|
// break;
|
363
|
/* ---- java.lang.Object --- */
|
364
|
case 'class':
|
365
|
if ($value != '' /* FieldUnit' */) {
|
366
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
367
|
}
|
368
|
break;
|
369
|
|
370
|
case 'markers':
|
371
|
$dd_elements = array();
|
372
|
foreach ($value as $marker) {
|
373
|
$dd_elements[] = compose_cdm_marker($marker);
|
374
|
}
|
375
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
376
|
break;
|
377
|
|
378
|
|
379
|
case 'annotations':
|
380
|
$dd_elements = array();
|
381
|
foreach ($value as $annotation) {
|
382
|
// TODO respect annotation type filter settings
|
383
|
$dd_elements[] = $annotation->text;
|
384
|
}
|
385
|
@_description_list_group_add($groups, t('Notes'), $dd_elements);
|
386
|
break;
|
387
|
|
388
|
/* ---- SpecimenOrObservationBase --- */
|
389
|
case 'sex':
|
390
|
case 'lifeStage':
|
391
|
case 'kindOfUnit':
|
392
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->representation_L10n, NULL, 1);
|
393
|
break;
|
394
|
|
395
|
case 'definition':
|
396
|
// TODO
|
397
|
break;
|
398
|
|
399
|
case 'preferredStableUri':
|
400
|
|
401
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), array(array('#markup' => cdm_external_uri($value, false))));
|
402
|
break;
|
403
|
|
404
|
case 'specimenTypeDesignations':
|
405
|
@_description_list_group_add(
|
406
|
$groups,
|
407
|
cdm_occurrence_field_name_label($field),
|
408
|
array(
|
409
|
'#markup' => theme('cdm_typedesignations', array('typeDesignations' => $value)),
|
410
|
)
|
411
|
);
|
412
|
break;
|
413
|
|
414
|
case 'determinations':
|
415
|
$dd_elements = array();
|
416
|
$glue = ', ';
|
417
|
|
418
|
foreach ($value as $determinationEvent) {
|
419
|
$timeperiod_string = NULL;
|
420
|
if (isset($determinationEvent->timeperiod)) {
|
421
|
$timeperiod_string = timePeriodToString($determinationEvent->timeperiod);
|
422
|
}
|
423
|
$weight = isset($determinationEvent->preferred) && $determinationEvent->preferred == 1 ? '0' : ($timeperiod_string ? $timeperiod_string : '1');
|
424
|
// check key exists
|
425
|
while (array_key_exists($weight, $dd_elements)) {
|
426
|
$weight .= '0';
|
427
|
}
|
428
|
|
429
|
$taxon_name = '';
|
430
|
$name_link = '';
|
431
|
if ($determinationEvent->taxonName) {
|
432
|
$taxon_name = $determinationEvent->taxonName;
|
433
|
} else if ($determinationEvent->taxon) {
|
434
|
$taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
|
435
|
$name_link = path_to_taxon($determinationEvent->taxon->uuid);
|
436
|
}
|
437
|
if ($taxon_name) {
|
438
|
$taxon_html = render_taxon_or_name($taxon_name, $name_link);
|
439
|
$dd_elements[$weight] = $taxon_html;
|
440
|
}
|
441
|
if (isset($determinationEvent->modifier)) {
|
442
|
$dd_elements[$weight] .= cdm_term_representation($determinationEvent->modifier);
|
443
|
}
|
444
|
if ($timeperiod_string) {
|
445
|
$dd_elements[$weight] .= $glue . $timeperiod_string;
|
446
|
}
|
447
|
if (isset($determinationEvent->actor->titleCache)) {
|
448
|
$dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache;
|
449
|
}
|
450
|
if (isset($determinationEvent->description)) {
|
451
|
$dd_elements[$weight] .= $glue . $determinationEvent->description;
|
452
|
}
|
453
|
}
|
454
|
ksort($dd_elements);
|
455
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements);
|
456
|
break;
|
457
|
|
458
|
case 'descriptions':
|
459
|
$occurrence_featureTree = cdm_get_occurrence_featureTree();
|
460
|
$dd_elements = array();
|
461
|
|
462
|
foreach ($value as $description) {
|
463
|
$description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, $description->uuid);
|
464
|
// if($description->imageGallery == TRUE) {
|
465
|
// continue;
|
466
|
// }
|
467
|
$elements_by_feature = _mergeFeatureTreeDescriptions($occurrence_featureTree->root->childNodes, $description->elements);
|
468
|
$description_render_elements = _block_get_renderable_array(make_feature_block_list($elements_by_feature, null));
|
469
|
$dd_elements[] = $description_render_elements;
|
470
|
if ($description->isImageGallery) {
|
471
|
$mediaList = array();
|
472
|
if (is_array($description->elements)) {
|
473
|
$mediaList = $description->elements;
|
474
|
}
|
475
|
$gallery_html = '';
|
476
|
if (count($mediaList) > 0) {
|
477
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
478
|
$captionElements = array(
|
479
|
'#uri' => t('open media'),
|
480
|
);
|
481
|
|
482
|
$gallery_html = compose_cdm_media_gallerie(array(
|
483
|
'mediaList' => $mediaList,
|
484
|
'galleryName' => $gallery_name,
|
485
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
486
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
487
|
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
488
|
'captionElements' => $captionElements,
|
489
|
'mediaLinkType' => 'LIGHTBOX',
|
490
|
'alternativeMediaUri' => NULL,
|
491
|
'galleryLinkUri' => NULL,
|
492
|
));
|
493
|
}
|
494
|
|
495
|
}
|
496
|
}
|
497
|
|
498
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
499
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $gallery_html);
|
500
|
break;
|
501
|
|
502
|
case 'sources':
|
503
|
$dd_elements = array();
|
504
|
foreach ($value as $identifiable_source) {
|
505
|
$dd_elements[] = theme('cdm_OriginalSource', array('source' => $identifiable_source));
|
506
|
}
|
507
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 10);
|
508
|
break;
|
509
|
|
510
|
|
511
|
/* ---- DerivedUnitBase --- */
|
512
|
case 'derivedFrom':
|
513
|
$derivedFrom = $value;
|
514
|
break;
|
515
|
|
516
|
case 'collection':
|
517
|
$sub_dl_groups = array();
|
518
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1);
|
519
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2);
|
520
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3);
|
521
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4);
|
522
|
// TODO "superCollection"
|
523
|
// TODO may have media
|
524
|
|
525
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
|
526
|
array(
|
527
|
array('#markup' => $value->titleCache),
|
528
|
array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
|
529
|
)
|
530
|
);
|
531
|
break;
|
532
|
|
533
|
case 'storedUnder':
|
534
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value));
|
535
|
break;
|
536
|
|
537
|
|
538
|
/* ---- Specimen --- */
|
539
|
case 'sequences':
|
540
|
$dd_elements = array();
|
541
|
foreach ($value as $sequence) {
|
542
|
$dd_elements[] = compose_cdm_sequence($sequence);
|
543
|
}
|
544
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
|
545
|
break;
|
546
|
|
547
|
// TODO preservation
|
548
|
// TODO exsiccatum
|
549
|
|
550
|
|
551
|
/* ---- FieldObservation --- */
|
552
|
case 'gatheringEvent':
|
553
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->actor->titleCache);
|
554
|
@_description_list_group_add($groups, t('Gathering time'), timePeriodToString($value->timeperiod));
|
555
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description);
|
556
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality->text);
|
557
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country->representation_L10n);
|
558
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod);
|
559
|
if (isset($value->absoluteElevation)) {
|
560
|
$min_max_markup = min_max_measure($value, 'absoluteElevation');
|
561
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('absoluteElevation'), $min_max_markup);
|
562
|
}
|
563
|
if (isset($value->distanceToGround)) {
|
564
|
$min_max_markup = min_max_measure($value, 'distanceToGround');
|
565
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToGround'), $min_max_markup);
|
566
|
}
|
567
|
if (isset($value->distanceToWaterSurface)) {
|
568
|
$min_max_markup = min_max_measure($value, 'distanceToWaterSurface');
|
569
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToWaterSurface'), $min_max_markup);
|
570
|
}
|
571
|
|
572
|
if (isset($value->collectingAreas)) {
|
573
|
$area_representations = array();
|
574
|
foreach ($value->collectingAreas as $area) {
|
575
|
$area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid));
|
576
|
}
|
577
|
if (!empty($area_representations))
|
578
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'),
|
579
|
array(
|
580
|
array('#markup' => implode(', ', $area_representations))
|
581
|
)
|
582
|
);
|
583
|
}
|
584
|
if (isset($value->exactLocation) && $value->exactLocation->sexagesimalString) {
|
585
|
$sub_dl_groups = array();
|
586
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1);
|
587
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2);
|
588
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('latitude'), round($value->exactLocation->latitude, 7), '°', 3);
|
589
|
if (isset($value->exactLocation->referenceSystem)) {
|
590
|
@_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4);
|
591
|
}
|
592
|
|
593
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
|
594
|
array(
|
595
|
array('#markup' => $value->exactLocation->sexagesimalString),
|
596
|
array(
|
597
|
'#theme' => 'description_list',
|
598
|
'#groups' => $sub_dl_groups
|
599
|
),
|
600
|
)
|
601
|
);
|
602
|
}
|
603
|
break;
|
604
|
|
605
|
/* ---- DerivationEvent --- */
|
606
|
case 'derivationEvents':
|
607
|
@_description_list_group_add($groups, t('Association type'), $value->description);
|
608
|
break;
|
609
|
case 'preservedSpecimenDTOs':
|
610
|
$derivates = $value;
|
611
|
break;
|
612
|
case 'derivates':
|
613
|
$derivates = $value;
|
614
|
break;
|
615
|
|
616
|
default:
|
617
|
if (is_object($value) || is_array($value)) {
|
618
|
drupal_set_message("Unhandled type in compose_cdm_specimenOrObservation() for field " . $field, "warning");
|
619
|
} else {
|
620
|
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
621
|
}
|
622
|
|
623
|
}
|
624
|
|
625
|
/*
|
626
|
*
|
627
|
default:
|
628
|
if (is_object($value) || is_array($value)) {
|
629
|
drupal_set_message("Unhandled type in compose_cdm_specimen_or_observation() for field " . $field, "warning");
|
630
|
} else {
|
631
|
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
|
632
|
*/
|
633
|
// Stashed changes
|
634
|
}
|
635
|
} // END of loop over $derivedUnitFacade fields
|
636
|
|
637
|
// Extensions
|
638
|
$extensions = cdm_ws_fetch_all(CDM_WS_PORTAL_OCCURRENCE . '/' . $specimenOrObservation->uuid . '/extensions', array($specimenOrObservation->uuid));
|
639
|
if ($extensions && count($extensions)) {
|
640
|
|
641
|
$extensions_render_array = compose_extensions($extensions);
|
642
|
@_description_list_group_add($groups, t('Extensions') . ':',
|
643
|
$extensions_render_array,
|
644
|
'', 100);
|
645
|
}
|
646
|
|
647
|
|
648
|
// template_preprocess_description_list() is not worting by weight so we do it right here
|
649
|
uasort($groups, 'element_sort');
|
650
|
|
651
|
$occurrence_elements = array(
|
652
|
'#title' => $title,
|
653
|
'#theme' => 'description_list',
|
654
|
'#groups' => $groups,
|
655
|
'#attributes' => array('class' => html_class_attribute_ref($specimenOrObservation)),
|
656
|
);
|
657
|
$derivatives[] = $occurrence_elements;
|
658
|
// all footnotes which has been assembled so far (e.g. from typeDesignations) to here
|
659
|
$foonote_li_elements = theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'span'));
|
660
|
if (!empty($foonote_li_elements)) {
|
661
|
$derivatives[] = array(
|
662
|
'#markup' => '<div class="footnotes">' . $foonote_li_elements . '</div>',
|
663
|
);
|
664
|
}
|
665
|
|
666
|
// --- recurse into originals
|
667
|
if (!isset($derivedFrom)) {
|
668
|
$derivedFrom = cdm_ws_get(
|
669
|
CDM_WS_OCCURRENCE,
|
670
|
array($specimenOrObservation->uuid, 'derivedFrom')
|
671
|
);
|
672
|
}
|
673
|
|
674
|
if (isset($derivates)) {
|
675
|
if (isset($derivedFrom->originals)) {
|
676
|
$derived_from_label = t('derivated');
|
677
|
// $preposition = t('from');
|
678
|
if (isset($derivedFrom->type)) {
|
679
|
$derived_from_label = $derivedFrom->type->representation_L10n;
|
680
|
if (isset($derivedFrom->description)) {
|
681
|
$derived_from_label = $derivedFrom->description;
|
682
|
}
|
683
|
// if($derivedFrom->type->uuid == UUID_DERIVATIONEVENTTYPE_ACCESSIONING){
|
684
|
// $preposition = t('of');
|
685
|
// }
|
686
|
}
|
687
|
if (count($groups) > 0) {
|
688
|
// TODO annotations
|
689
|
|
690
|
// only display the derived from information when the derivative has any element which will be diplayed
|
691
|
$derivatives[] = array(
|
692
|
'#markup' => '<div class="derived_from">' . $derived_from_label . ': </div>',//' ' . $preposition . ': </div>',
|
693
|
);
|
694
|
}
|
695
|
// foreach ($derivedFrom->originals as $original) {
|
696
|
|
697
|
|
698
|
|
699
|
}
|
700
|
}
|
701
|
/*<<<<<<< Updated upstream
|
702
|
foreach ($derivedFrom->originals as $original) {
|
703
|
compose_cdm_specimen_or_observation($original, $derivatives);
|
704
|
=======*/
|
705
|
if (isset($derivates )) {
|
706
|
|
707
|
foreach ($derivates as $derivate){
|
708
|
compose_cdm_specimenOrObservation($derivate, $derivatives);
|
709
|
}
|
710
|
//>>>>>>> Stashed changes
|
711
|
}
|
712
|
|
713
|
} // END of $specimenOrObservation exists
|
714
|
|
715
|
return $derivatives;
|
716
|
}
|
717
|
|
718
|
|
719
|
/**
|
720
|
* Compose an render array from a CDM Sequence object.
|
721
|
*
|
722
|
* compose_hook() implementation
|
723
|
*
|
724
|
* @param object $sequence
|
725
|
* CDM instance of type Sequence
|
726
|
* @return array
|
727
|
* A render array containing the fields of the supplied $sequence
|
728
|
*
|
729
|
* @ingroup compose
|
730
|
*/
|
731
|
function compose_cdm_sequence($sequence)
|
732
|
{
|
733
|
|
734
|
$exclude_sequence_fields = &drupal_static(__FUNCTION__);
|
735
|
if (!isset($exclude_sequence_fields)) {
|
736
|
$exclude_sequence_fields = array(
|
737
|
'titleCache',
|
738
|
'protectedTitleCache',
|
739
|
'microReference',
|
740
|
'created',
|
741
|
'updated',
|
742
|
'class',
|
743
|
);
|
744
|
}
|
745
|
|
746
|
$groups = array();
|
747
|
|
748
|
// -- retrieve additional data if neesscary
|
749
|
// TODO below call disabled since sequences are not yet supported,
|
750
|
// see #3347 (services and REST service controller for molecular classes implemented)
|
751
|
//
|
752
|
// cdm_load_annotations($sequence);
|
753
|
|
754
|
foreach (get_object_vars($sequence) as $field => $value) {
|
755
|
|
756
|
|
757
|
if (!in_array($field, $exclude_sequence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
|
758
|
switch ($field) {
|
759
|
|
760
|
case 'geneticAccessionNumber';
|
761
|
$dd_elements = array();
|
762
|
foreach ($value as $accession) {
|
763
|
if (isset($accession->uri)) {
|
764
|
$dd_elements[] = l($accession->accessionNumber, $accession->uri);
|
765
|
} else {
|
766
|
$dd_elements[] = $accession->accessionNumber;
|
767
|
}
|
768
|
}
|
769
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 2);
|
770
|
break;
|
771
|
|
772
|
|
773
|
case 'locus': // 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.
|
774
|
if (isset($value->name)) {
|
775
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->name, NULL, 3);
|
776
|
}
|
777
|
if (isset($value->description)) {
|
778
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field) . ' ' . t('description'), $value->description, NULL, 4);
|
779
|
}
|
780
|
break;
|
781
|
|
782
|
case 'consensusSequence':
|
783
|
// format in genbank style, force linebreaks after each 70 nucleotites
|
784
|
// see also http://stackoverflow.com/questions/499137/css-how-can-i-force-a-long-string-without-any-blank-to-be-wrapped-in-xul-and
|
785
|
@_description_list_group_add(
|
786
|
$groups,
|
787
|
cdm_occurrence_field_name_label($field),
|
788
|
array(
|
789
|
array(
|
790
|
'#markup' => '<div class="sequence-length">' . $value->length . ' ' . t('pb') . '</div><div>' . wordwrap($value->string, 70, '</br>', TRUE) . '</div>',
|
791
|
'#wrapper_attributes' => array('class' => 'dna-sequence')
|
792
|
)
|
793
|
),
|
794
|
5);
|
795
|
break;
|
796
|
|
797
|
case 'dnaSample': // FIXME 3.3 implement
|
798
|
break;
|
799
|
case 'singleReads': // FIXME 3.3 implement
|
800
|
break;
|
801
|
case 'contigFile': // FIXME 3.3 implement - Media
|
802
|
break;
|
803
|
case 'pherograms': // FIXME 3.3 implement - Media
|
804
|
break;
|
805
|
case 'haplotype': // FIXME 3.3 implement
|
806
|
break;
|
807
|
case 'dateSequenced': // FIXME 3.3 now in SingelRead
|
808
|
@_description_list_group_add($groups, t('Sequencing date'), timePeriodToString($value), NULL, 6);
|
809
|
break;
|
810
|
|
811
|
case 'barcode': // boolean
|
812
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value ? 'Yes' : 'No', NULL, 7);
|
813
|
break;
|
814
|
case 'barcodeSequencePart': // FIXME 3.3 implement, compose sequence
|
815
|
break;
|
816
|
|
817
|
case 'citation':
|
818
|
@_description_list_group_add($groups,
|
819
|
cdm_occurrence_field_name_label($field),
|
820
|
theme('cdm_reference', array('reference' => $value, 'microReference' => $sequence->microReference)),
|
821
|
NULL,
|
822
|
8
|
823
|
);
|
824
|
break;
|
825
|
|
826
|
case 'publishedIn':
|
827
|
@_description_list_group_add($groups,
|
828
|
cdm_occurrence_field_name_label($field),
|
829
|
theme('cdm_reference', array('reference' => $value)),
|
830
|
NULL,
|
831
|
7
|
832
|
);
|
833
|
break;
|
834
|
|
835
|
case 'rights':
|
836
|
array_merge($groups, cdm_rights_as_dl_groups($value));
|
837
|
break;
|
838
|
|
839
|
case 'annotations':
|
840
|
$dd_elements = array();
|
841
|
foreach ($value as $annotation) {
|
842
|
// TODO respect annotation type filter settings
|
843
|
$dd_elements[] = $annotation->text;
|
844
|
}
|
845
|
@_description_list_group_add($groups, t('Notes'), $dd_elements, NULL, 9);
|
846
|
break;
|
847
|
|
848
|
case 'markers':
|
849
|
$dd_elements = array();
|
850
|
foreach ($value as $marker) {
|
851
|
$dd_elements[] = compose_cdm_marker($marker);
|
852
|
}
|
853
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 10);
|
854
|
break;
|
855
|
|
856
|
case 'chromatograms':
|
857
|
@_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
|
858
|
array(
|
859
|
'#markup' => compose_cdm_media_gallerie(array('medialist' => $value)),
|
860
|
),
|
861
|
NULL,
|
862
|
11);
|
863
|
break;
|
864
|
|
865
|
default:
|
866
|
if (is_object($value) || is_array($value)) {
|
867
|
drupal_set_message("Unhandled type in compose_cdm_sequence() for field " . $field, "warning");
|
868
|
} else {
|
869
|
_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 20);
|
870
|
}
|
871
|
}
|
872
|
}
|
873
|
}
|
874
|
|
875
|
// template_preprocess_description_list() is not worting by weight so we do it right here
|
876
|
uasort($groups, 'element_sort');
|
877
|
|
878
|
$sequence_elements = array(
|
879
|
'#theme' => 'description_list',
|
880
|
'#groups' => $groups
|
881
|
);
|
882
|
|
883
|
return $sequence_elements;
|
884
|
}
|
885
|
|
886
|
|