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