Project

General

Profile

Download (53.9 KB) Statistics
| Branch: | Tag: | Revision:
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
            if ($is_specimen_page) {
67
                if ($specimen->types) {
68
                    $detail_html .= "<i>" . $typeStatus . "</i>: ";
69
                    foreach ($typedTaxa as $typedTaxon) {
70
                        $detail_html .= $typedTaxon . " ";
71
                    }
72
                    $detail_html .= "<br>";
73
                }
74
            } else {
75
                $types .= $typeStatus . " ";
76

    
77
            }
78
        }
79
    }
80
    $derivateDataDTO = $specimen->derivateDataDTO;
81
    // - specimen scans
82
    $specimenScans = create_html_links($derivateDataDTO->specimenScans, true);
83
    // - molecular data
84
    $molecularData = "";
85
    if ($derivateDataDTO->molecularDataList) {
86
        foreach ($derivateDataDTO->molecularDataList as $molecular) {
87
            //provider link
88
            if (isset($molecular->providerLink)) {
89
                $molecularData .= create_html_link($molecular->providerLink, true);
90
            } else {
91
                $molecularData .= "[no provider]";
92
            }
93
            //contig link
94
            if (isset($molecular->contigFiles)) {
95
                $molecularData .= "[";
96
                if (sizeof($molecular->contigFiles) > 0) {
97
                    foreach ($molecular->contigFiles as $contigFile) {
98
                        if (isset($contigFile->contigLink)) {
99
                            if (isset($contigFile->contigLink->uri) and $contigFile->contigLink->uri != null) {
100
                                $molecularData .= create_html_link($contigFile->contigLink, true) . " ";
101
                            }
102
                        } else {
103
                            $molecularData .= "no contig ";
104
                        }
105
                        //primer links
106
                        if (isset($contigFile->primerLinks)) {
107
                            $molecularData .= create_html_links($contigFile->primerLinks, true);
108
                        }
109
                    }
110
                }
111
                $molecularData = rtrim($molecularData, " ");
112
                $molecularData .= "]";
113
            }
114
            //FIXME separate with comma (remove trailing comma)
115
        }
116
    }
117
    // - detail images
118
    $detailImages = create_html_links($derivateDataDTO->detailImages, true);
119

    
120
    if ($types) {
121
        $detail_html .= $is_specimen_page ? "<br>" : "";
122
        $detail_html .= create_label("Type(s)") . $types . "<br>";
123
    }
124
    if ($specimenScans and !$is_specimen_page) {
125
        $detail_html .= create_label("Specimen Scans") . $specimenScans . "<br>";
126
    }
127
    //specimen scan image gallery
128
    if ($is_specimen_page and isset($derivateDataDTO->specimenScanUuids) and !empty($derivateDataDTO->specimenScanUuids)) {
129
        $detail_html .= addImageGallery("Specimen scans", $derivateDataDTO->specimenScanUuids);
130
    }
131

    
132
    if ($molecularData) {
133
        $detail_html .= $is_specimen_page ? "<br>" : "";
134
        $detail_html .= create_label("Molecular Data") . $molecularData . "<br>";
135
    }
136

    
137
    if ($detailImages and !$is_specimen_page) {
138
        $detail_html .= create_label("Detail Images") . $detailImages . "<br>";
139
    }
140

    
141
    //detail image gallery
142
    if ($is_specimen_page and isset($derivateDataDTO->detailImageUuids) and !empty($derivateDataDTO->detailImageUuids)) {
143
        $detail_html .= addImageGallery("Detail Images", $derivateDataDTO->detailImageUuids);
144
    }
145

    
146
    //character data
147
    if ($specimen->characterData) {
148
        $detail_html .= $is_specimen_page ? "<br>" : "";
149
        $detail_html .= create_label("Character Data");
150
        if ($is_specimen_page) {
151
            $detail_html .= "<br>";
152
            foreach ($specimen->characterData as $characterStatePair) {
153
                $detail_html .= "<i>" . $characterStatePair->first . "</i>:" . $characterStatePair->second;
154
                $detail_html .= "<br>";
155
            }
156
        } else {
157
            $detail_html .= l("detail page", $pathToSpecimen, array('attributes' => array('target' => '_blank')));
158
            $detail_html .= "<br>";
159
        }
160
    }
161
    return $detail_html;
162
}
163

    
164
function addImageGallery($galleryName, $imageUuids)
165
{
166
    $images = array();
167
    foreach ($imageUuids as $uuid) {
168
        $images[] = cdm_ws_get(CDM_WS_PORTAL_MEDIA, $uuid);
169
    }
170

    
171
    $gallery_html = '';
172
    if (count($imageUuids) > 0) {
173
        $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
174
        $captionElements = array(
175
            'title',
176
            'rights',
177
        );
178
        $alternativeMediaUris = array();
179
        foreach ($images as $image) {
180
            $mediaUri = getMediaUri($image);
181
            if ($mediaUri) {
182
                $alternativeMediaUris[] = $mediaUri;
183
            } else {
184
                $alternativeMediaUris[] = path_to_media($image->uuid);
185
            }
186
        }
187

    
188
        $gallery_html = compose_cdm_media_gallerie(array(
189
            'mediaList' => $images,
190
            'galleryName' => $galleryName,
191
            'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
192
            'cols' => $gallery_settings['cdm_dataportal_media_cols'],
193
            'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
194
            'captionElements' => $captionElements,
195
            'mediaLinkType' => 'LIGHTBOX',
196
            'alternativeMediaUri' => $alternativeMediaUris,
197
            'galleryLinkUri' => NULL,
198
        ));
199
    }
200
    return "<br>" . create_label($galleryName) . "<br>" . $gallery_html;
201
}
202

    
203
function getMediaUri($media)
204
{
205
    if (isset($media->representations) && sizeof($media->representations) == 1
206
        && isset($media->representations[0]->parts) &&
207
        sizeof($media->representations[0]->parts) == 1) {
208
        return $media->representations[0]->parts[0]->uri;
209
    }
210
    return null;
211
}
212

    
213

    
214
/**
215
 * Formats the given string to a label for displaying key-object 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

    
242
function compose_cdm_specimen_or_observation($specimenOrObservation, &$derivatives = null)
243
{
244
    $exclude_occurrence_fields = &drupal_static(__FUNCTION__);
245
    if (!isset($exclude_occurrence_fields)) {
246
        $exclude_occurrence_fields = array(
247
            'derivationEvent',
248
            'taxonRelatedDerivedUnits',
249
            'titleCache',
250
            'protectedTitleCache',
251
            'derivedUnitMedia',
252
            'created',
253
            'publish',
254
            'updated',
255
            'class',
256
            'uuid',
257
            'collectionDTO'
258
        );
259
    }
260

    
261

    
262
    // only show uuid it the user is logged in
263
    if (user_is_logged_in() && ($a_idx = array_search('uuid', $exclude_occurrence_fields)) !== FALSE) {
264
        unset($exclude_occurrence_fields[$a_idx]);
265
    }
266

    
267
    if (!isset($derivatives)) {
268
        $derivatives = array();
269
    }
270

    
271
    $descriptions = null;
272
    $derivedFrom = null;
273
    $derivates = null;
274

    
275
    if (is_object($specimenOrObservation)) {
276

    
277
        // request again for deeper initialization
278
      //  $specimenOrObservation = cdm_ws_get("portal/" . CDM_WS_OCCURRENCE, $specimenOrObservation->uuid);
279

    
280

    
281
        $type_label = $specimenOrObservation->recordBase;
282
        RenderHints::setFootnoteListKey($type_label . '-' . $specimenOrObservation->uuid);
283

    
284
        // collect typeStatus as label
285
        if (isset($specimenOrObservation->specimenTypeDesignations)) {
286
            $type_status = array();
287
            foreach ($specimenOrObservation->specimenTypeDesignations as $typeDesignation) {
288
                if (isset($typeDesignation->typeStatus->representation_L10n)) {
289
                    $type_status[] = $typeDesignation->typeStatus->representation_L10n;
290
                }
291
            }
292
            if (count($type_status) > 0) {
293
                $type_label = implode(', ', $type_status);
294
            }
295
        }
296

    
297
        $title = $type_label . ': ' . $specimenOrObservation->titleCache;
298

    
299
        $groups = array();
300
        // --- add initialized fields
301
        foreach (get_object_vars($specimenOrObservation) as $field => $value) {
302
            if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
303
                switch ($field) {
304
//            case 'recordBasis':
305
//                if ($value != '' /* FieldUnit' */) {
306
//                    @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
307
//                }
308
//                break;
309
                    /* ---- java.lang.Object --- */
310
                    case 'class':
311
                        if ($value != '' /* FieldUnit' */) {
312
                            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
313
                        }
314
                        break;
315

    
316
                    case 'markers':
317
                        $dd_elements = array();
318
                        foreach ($value as $marker) {
319
                            $dd_elements[] = compose_cdm_marker($marker);
320
                        }
321
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
322
                        break;
323

    
324

    
325
                    case 'annotations':
326
                        $dd_elements = array();
327
                        foreach ($value as $annotation) {
328
                            // TODO respect annotation type filter settings
329
                            $dd_elements[] = $annotation->text;
330
                        }
331
                        @_description_list_group_add($groups, t('Notes'), $dd_elements);
332
                        break;
333

    
334
                    /* ---- SpecimenOrObservationBase --- */
335
                    case 'sex':
336
                    case 'lifeStage':
337
                    case 'kindOfUnit':
338
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->representation_L10n, NULL, 1);
339
                        break;
340

    
341
                    case 'definition':
342
                        // TODO
343
                        break;
344

    
345
                    case 'preferredStableUri':
346

    
347
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), array(array('#markup' => cdm_external_uri($value, false))));
348
                        break;
349

    
350
                    case 'specimenTypeDesignations':
351
                        @_description_list_group_add(
352
                            $groups,
353
                            cdm_occurrence_field_name_label($field),
354
                            array(
355
                                '#markup' => theme('cdm_typedesignations', array('typeDesignations' => $value)),
356
                            )
357
                        );
358
                        break;
359

    
360
                    case 'determinations':
361
                        $dd_elements = array();
362
                        $glue = ', ';
363

    
364
                        foreach ($value as $determinationEvent) {
365
                            $timeperiod_string = NULL;
366
                            if (isset($determinationEvent->timeperiod)) {
367
                                $timeperiod_string = timePeriodToString($determinationEvent->timeperiod);
368
                            }
369
                            $weight = isset($determinationEvent->preferred) && $determinationEvent->preferred == 1 ? '0' : ($timeperiod_string ? $timeperiod_string : '1');
370
                            // check key exists
371
                            while (array_key_exists($weight, $dd_elements)) {
372
                                $weight .= '0';
373
                            }
374

    
375
                            $taxon_name = '';
376
                            $name_link = '';
377
                            if ($determinationEvent->taxonName) {
378
                                $taxon_name = $determinationEvent->taxonName;
379
                            } else if ($determinationEvent->taxon) {
380
                                $taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
381
                                $name_link = path_to_taxon($determinationEvent->taxon->uuid);
382
                            }
383
                            if ($taxon_name) {
384
                                $taxon_html = render_taxon_or_name($taxon_name, $name_link);
385
                                $dd_elements[$weight] = $taxon_html;
386
                            }
387
                            if (isset($determinationEvent->modifier)) {
388
                                $dd_elements[$weight] .= cdm_term_representation($determinationEvent->modifier);
389
                            }
390
                            if ($timeperiod_string) {
391
                                $dd_elements[$weight] .= $glue . $timeperiod_string;
392
                            }
393
                            if (isset($determinationEvent->actor->titleCache)) {
394
                                $dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache;
395
                            }
396
                            if (isset($determinationEvent->description)) {
397
                                $dd_elements[$weight] .= $glue . $determinationEvent->description;
398
                            }
399
                        }
400
                        ksort($dd_elements);
401
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements);
402
                        break;
403

    
404
                    case 'descriptions':
405
                        $occurrence_featureTree = cdm_get_occurrence_featureTree();
406
                        $dd_elements = array();
407

    
408
                        foreach ($value as $description) {
409
                            $description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, $description->uuid);
410
//               if($description->imageGallery == TRUE) {
411
//                 continue;
412
//               }
413
                            $elements_by_feature = _mergeFeatureTreeDescriptions($occurrence_featureTree->root->childNodes, $description->elements);
414
                            $description_render_elements = _block_get_renderable_array(make_feature_block_list($elements_by_feature, null));
415
                            $dd_elements[] = $description_render_elements;
416
                            if ($description->isImageGallery) {
417
                                $mediaList = array();
418
                                if (is_array($description->elements)) {
419
                                    $mediaList = $description->elements;
420
                                }
421
                                $gallery_html = '';
422
                                if (count($mediaList) > 0) {
423
                                    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
424
                                    $captionElements = array(
425
                                        '#uri' => t('open media'),
426
                                    );
427

    
428
                                    $gallery_html = compose_cdm_media_gallerie(array(
429
                                        'mediaList' => $mediaList,
430
                                        'galleryName' => $gallery_name,
431
                                        'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
432
                                        'cols' => $gallery_settings['cdm_dataportal_media_cols'],
433
                                        'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
434
                                        'captionElements' => $captionElements,
435
                                        'mediaLinkType' => 'LIGHTBOX',
436
                                        'alternativeMediaUri' => NULL,
437
                                        'galleryLinkUri' => NULL,
438
                                    ));
439
                                }
440

    
441
                            }
442
                        }
443

    
444
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
445
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $gallery_html);
446
                        break;
447

    
448
                    case 'sources':
449
                        $dd_elements = array();
450
                        foreach ($value as $identifiable_source) {
451
                            $dd_elements[] = theme('cdm_OriginalSource', array('source' => $identifiable_source));
452
                        }
453
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 10);
454
                        break;
455

    
456

    
457
                    /* ---- DerivedUnitBase --- */
458
                    case 'derivedFrom':
459
                        $derivedFrom = $value;
460
                        break;
461

    
462
                    case 'collection':
463
                        $sub_dl_groups = array();
464
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1);
465
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2);
466
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3);
467
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4);
468
                        // TODO "superCollection"
469
                        // TODO may have media
470

    
471
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
472
                            array(
473
                                array('#markup' => $value->titleCache),
474
                                array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
475
                            )
476
                        );
477
                        break;
478

    
479
                    case 'storedUnder':
480
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value));
481
                        break;
482

    
483

    
484
                    /* ---- Specimen --- */
485
                    case 'sequences':
486
                        $dd_elements = array();
487
                        foreach ($value as $sequence) {
488
                            $dd_elements[] = compose_cdm_sequence($sequence);
489
                        }
490
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
491
                        break;
492

    
493
                    // TODO preservation
494
                    // TODO exsiccatum
495

    
496

    
497
                    /* ---- FieldObservation --- */
498
                    case 'gatheringEvent':
499
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->actor->titleCache);
500
                        @_description_list_group_add($groups, t('Gathering time'), timePeriodToString($value->timeperiod));
501
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description);
502
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality->text);
503
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country->representation_L10n);
504
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod);
505
                        if (isset($value->absoluteElevation)) {
506
                            $min_max_markup = min_max_measure($value, 'absoluteElevation');
507
                            @_description_list_group_add($groups, cdm_occurrence_field_name_label('absoluteElevation'), $min_max_markup);
508
                        }
509
                        if (isset($value->distanceToGround)) {
510
                            $min_max_markup = min_max_measure($value, 'distanceToGround');
511
                            @_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToGround'), $min_max_markup);
512
                        }
513
                        if (isset($value->distanceToWaterSurface)) {
514
                            $min_max_markup = min_max_measure($value, 'distanceToWaterSurface');
515
                            @_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToWaterSurface'), $min_max_markup);
516
                        }
517

    
518
                        if (isset($value->collectingAreas)) {
519
                            $area_representations = array();
520
                            foreach ($value->collectingAreas as $area) {
521
                                $area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid));
522
                            }
523
                            if (!empty($area_representations))
524
                                @_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'),
525
                                    array(
526
                                        array('#markup' => implode(', ', $area_representations))
527
                                    )
528
                                );
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
                    /* ---- DerivationEvent --- */
552
                    case 'derivationEvents':
553
                        @_description_list_group_add($groups, t('Association type'), $value->description);
554
                        break;
555
                    case 'preservedSpecimenDTOs':
556
                        $derivates = $value;
557
                        break;
558
                    case 'derivates':
559
                        $derivates = $value;
560
                        break;
561

    
562
                    default:
563
                        if (is_object($value) || is_array($value)) {
564
                            drupal_set_message("Unhandled type in compose_cdm_specimenOrObservation() for field " . $field, "warning");
565
                        } else {
566
                            _description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
567
                        }
568

    
569
                }
570

    
571

    
572
            }
573
        } // END of loop over $derivedUnitFacade fields
574

    
575
        // Extensions
576
        $extensions = cdm_ws_fetch_all(CDM_WS_PORTAL_OCCURRENCE . '/' . $specimenOrObservation->uuid . '/extensions', array($specimenOrObservation->uuid));
577
        if ($extensions && count($extensions)) {
578

    
579
            $extensions_render_array = compose_extensions($extensions);
580
            @_description_list_group_add($groups, t('Extensions') . ':',
581
                $extensions_render_array,
582
                '', 100);
583
        }
584

    
585

    
586
        // template_preprocess_description_list() is not worting by weight so we do it right here
587
        uasort($groups, 'element_sort');
588

    
589
        $occurrence_elements = array(
590
            '#title' => $title,
591
            '#theme' => 'description_list',
592
            '#groups' => $groups,
593
            '#attributes' => array('class' => html_class_attribute_ref($specimenOrObservation)),
594
        );
595
        $derivatives[] = $occurrence_elements;
596
        // all footnotes which has been assembled so far (e.g. from typeDesignations) to here
597
        $foonote_li_elements = theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'span'));
598
        if (!empty($foonote_li_elements)) {
599
            $derivatives[] = array(
600
                '#markup' => '<div class="footnotes">' . $foonote_li_elements . '</div>',
601
            );
602
        }
603

    
604
        // --- recurse into originals
605
        if (!isset($derivedFrom)) {
606
            $derivedFrom = cdm_ws_get(
607
                CDM_WS_OCCURRENCE,
608
                array($specimenOrObservation->uuid, 'derivedFrom')
609
            );
610
        }
611

    
612
        if (isset($derivates)) {
613
            if (isset($derivates->originals)) {
614
                $derived_from_label = t('derivated');
615
                // $preposition = t('from');
616
                if (isset($derivedFrom->type)) {
617
                    $derived_from_label = $derivedFrom->type->representation_L10n;
618
                    if (isset($derivedFrom->description)) {
619
                        $derived_from_label = $derivedFrom->description;
620
                    }
621
                    //  if($derivedFrom->type->uuid == UUID_DERIVATIONEVENTTYPE_ACCESSIONING){
622
                    //  $preposition = t('of');
623
                    // }
624
                }
625
                if (count($groups) > 0) {
626
                    // TODO  annotations
627

    
628
                    // only display the derived from information when the derivative has any element which will be diplayed
629
                    $derivatives[] = array(
630
                        '#markup' => '<div class="derived_from">' . $derived_from_label . ': </div>',//' ' . $preposition . ': </div>',
631
                    );
632
                }
633
                // foreach ($derivedFrom->originals as $original) {
634

    
635

    
636

    
637
            }
638
        }
639

    
640
        if (isset($derivates )) {
641

    
642
            foreach ($derivates as $derivate){
643
                compose_cdm_specimen_or_observation($derivate, $derivatives);
644
            }
645

    
646
        }
647

    
648
    } // END of $specimenOrObservation exists
649

    
650
    return $derivatives;
651
}
652

    
653

    
654
/**
655
 * Compose an render array from a CDM Sequence object.
656
 *
657
 * compose_hook() implementation
658
 *
659
 * @param object $sequence
660
 *   CDM instance of type Sequence
661
 * @return array
662
 *   A render array containing the fields of the supplied $sequence
663
 *
664
 * @ingroup compose
665
 */
666
function compose_cdm_sequence($sequence)
667
{
668

    
669
    $exclude_sequence_fields = &drupal_static(__FUNCTION__);
670
    if (!isset($exclude_sequence_fields)) {
671
        $exclude_sequence_fields = array(
672
            'titleCache',
673
            'protectedTitleCache',
674
            'microReference',
675
            'created',
676
            'updated',
677
            'class',
678
        );
679
    }
680

    
681
    $groups = array();
682

    
683
    // -- retrieve additional data if neesscary
684
    // TODO below call disabled since sequences are not yet supported,
685
    //      see  #3347 (services and REST service controller for molecular classes implemented)
686
    //
687
    // cdm_load_annotations($sequence);
688

    
689
    foreach (get_object_vars($sequence) as $field => $value) {
690

    
691

    
692
        if (!in_array($field, $exclude_sequence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
693
            switch ($field) {
694

    
695
                case 'geneticAccessionNumber';
696
                    $dd_elements = array();
697
                    foreach ($value as $accession) {
698
                        if (isset($accession->uri)) {
699
                            $dd_elements[] = l($accession->accessionNumber, $accession->uri);
700
                        } else {
701
                            $dd_elements[] = $accession->accessionNumber;
702
                        }
703
                    }
704
                    @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 2);
705
                    break;
706

    
707

    
708
                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.
709
                    if (isset($value->name)) {
710
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->name, NULL, 3);
711
                    }
712
                    if (isset($value->description)) {
713
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field) . ' ' . t('description'), $value->description, NULL, 4);
714
                    }
715
                    break;
716

    
717
                case 'consensusSequence':
718
                    // format in genbank style, force linebreaks after each 70 nucleotites
719
                    // see also http://stackoverflow.com/questions/499137/css-how-can-i-force-a-long-string-without-any-blank-to-be-wrapped-in-xul-and
720
                    @_description_list_group_add(
721
                        $groups,
722
                        cdm_occurrence_field_name_label($field),
723
                        array(
724
                            array(
725
                                '#markup' => '<div class="sequence-length">' . $value->length . ' ' . t('pb') . '</div><div>' . wordwrap($value->string, 70, '</br>', TRUE) . '</div>',
726
                                '#wrapper_attributes' => array('class' => 'dna-sequence')
727
                            )
728
                        ),
729
                        5);
730
                    break;
731

    
732
                case 'dnaSample': // FIXME 3.3 implement
733
                    break;
734
                case 'singleReads': // FIXME 3.3 implement
735
                    break;
736
                case 'contigFile': // FIXME 3.3 implement - Media
737
                    break;
738
                case 'pherograms': // FIXME 3.3 implement - Media
739
                    break;
740
                case 'haplotype': // FIXME 3.3 implement
741
                    break;
742
                case 'dateSequenced': // FIXME 3.3 now in SingelRead
743
                    @_description_list_group_add($groups, t('Sequencing date'), timePeriodToString($value), NULL, 6);
744
                    break;
745

    
746
                case 'barcode': // boolean
747
                    @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value ? 'Yes' : 'No', NULL, 7);
748
                    break;
749
                case 'barcodeSequencePart': // FIXME 3.3 implement, compose sequence
750
                    break;
751

    
752
                case 'citation':
753
                    @_description_list_group_add($groups,
754
                        cdm_occurrence_field_name_label($field),
755
                        theme('cdm_reference', array('reference' => $value, 'microReference' => $sequence->microReference)),
756
                        NULL,
757
                        8
758
                    );
759
                    break;
760

    
761
                case 'publishedIn':
762
                    @_description_list_group_add($groups,
763
                        cdm_occurrence_field_name_label($field),
764
                        theme('cdm_reference', array('reference' => $value)),
765
                        NULL,
766
                        7
767
                    );
768
                    break;
769

    
770
                case 'rights':
771
                    array_merge($groups, cdm_rights_as_dl_groups($value));
772
                    break;
773

    
774
                case 'annotations':
775
                    $dd_elements = array();
776
                    foreach ($value as $annotation) {
777
                        // TODO respect annotation type filter settings
778
                        $dd_elements[] = $annotation->text;
779
                    }
780
                    @_description_list_group_add($groups, t('Notes'), $dd_elements, NULL, 9);
781
                    break;
782

    
783
                case 'markers':
784
                    $dd_elements = array();
785
                    foreach ($value as $marker) {
786
                        $dd_elements[] = compose_cdm_marker($marker);
787
                    }
788
                    @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 10);
789
                    break;
790

    
791
                case 'chromatograms':
792
                    @_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
793
                        array(
794
                            '#markup' => compose_cdm_media_gallerie(array('medialist' => $value)),
795
                        ),
796
                        NULL,
797
                        11);
798
                    break;
799

    
800
                default:
801
                    if (is_object($value) || is_array($value)) {
802
                        drupal_set_message("Unhandled type in compose_cdm_sequence() for field " . $field, "warning");
803
                    } else {
804
                        _description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 20);
805
                    }
806
            }
807
        }
808
    }
809

    
810
    // template_preprocess_description_list() is not worting by weight so we do it right here
811
    uasort($groups, 'element_sort');
812

    
813
    $sequence_elements = array(
814
        '#theme' => 'description_list',
815
        '#groups' => $groups
816
    );
817

    
818
    return $sequence_elements;
819
}
820
/**
821
 * Creates an array from a list of FieldUnitDTOs.
822
 *
823
 *
824
 * @param object $specimenOrObservations
825
 *   list of FieldUnitDTOs
826
 * @return array
827
 *   An array containing the hierarchy of the field units corresponding to the taxon
828
 *
829
 * @ingroup compose
830
 */
831
function create_specimen_array(array $specimenOrObservations){
832
    $items_specimen = array();
833
    $items = array();
834
    $children = array();
835
    //we need one more item to contain the items of one level (fieldunit, derivate data etc.)
836
    foreach ($specimenOrObservations as &$specimenOrObservation) {
837
        $items['data'] = $specimenOrObservation->listLabel;
838
        $specimen = create_cdm_specimen_or_observation($specimenOrObservation);
839
        $children = array();
840
        $child = array();
841
        $child['data'] =$specimen;
842
       // $children[] = create_specimen_array($specimenOrObservation->derivates);
843
       if (isset($specimenOrObservation->derivates) && sizeof($specimenOrObservation->derivates) > 0){
844
           $child['children']= create_specimen_array($specimenOrObservation->derivates);
845
       }
846
       $children[]=$child;
847
       $items['children'] = $children;
848
       $items_specimen[] = $items;
849
    }
850
    return $items_specimen;
851
}
852

    
853

    
854
/**
855
 * Compose an render array from a CDM DerivedUnitFacade object.
856
 *
857
 * compose_hook() implementation
858
 *
859
 * @param object $specimenOrObservation
860
 *   the CDM instance of type SpecimenOrObservation to compose
861
 *   the render array for
862
 * @param array $derivatives
863
 *   the render array which contains the compositions of the derivatives
864
 *   of the supplied $specimenOrObservation
865
 *
866
 * @return array
867
 *   the supplied render array $derivatives to which the composition of the supplied
868
 *   $specimenOrObservation has been added to
869
 *
870
 * @ingroup compose
871
 */
872

    
873
function create_cdm_specimen_or_observation($specimenOrObservation)
874
{
875
    $exclude_occurrence_fields = &drupal_static(__FUNCTION__);
876
    if (!isset($exclude_occurrence_fields)) {
877
        $exclude_occurrence_fields = array(
878
            'type',
879
            'derivationEvent',
880
            'taxonRelatedDerivedUnits',
881
            'label',
882
            'titleCache',
883
            'listLabel',
884
            'protectedTitleCache',
885
            'derivedUnitMedia',
886
            'created',
887
            'publish',
888
            'updated',
889
            'class',
890
            'uuid',
891
            'collectionDTO'
892
        );
893
    }
894
    $items = array();
895

    
896
    // only show uuid it the user is logged in
897
    if (user_is_logged_in() && ($a_idx = array_search('uuid', $exclude_occurrence_fields)) !== FALSE) {
898
      //  unset($exclude_occurrence_fields[$a_idx]);
899
    }
900

    
901

    
902
    if (is_object($specimenOrObservation)) {
903

    
904
        $type_label = $specimenOrObservation->recordBase;
905
        RenderHints::setFootnoteListKey($type_label . '-' . $specimenOrObservation->uuid);
906

    
907
        // collect typeStatus as label
908
        if (isset($specimenOrObservation->specimenTypeDesignations)) {
909
            $type_status = array();
910
            foreach ($specimenOrObservation->specimenTypeDesignations as $typeDesignation) {
911
                if (isset($typeDesignation->typeStatus->representation_L10n)) {
912
                    $type_status[] = $typeDesignation->typeStatus->representation_L10n;
913
                }
914
            }
915
            if (count($type_status) > 0) {
916
                $type_label = implode(', ', $type_status);
917
            }
918
        }
919

    
920
        $title = $type_label . ': ' . $specimenOrObservation->titleCache;
921
        $items['data'] = $title;
922

    
923
        $groups = array();
924
        $items['children'] = $groups;
925
        $children_items = array();
926
        // --- add initialized fields
927
        foreach (get_object_vars($specimenOrObservation) as $field => $value) {
928
            $child_item = array();
929

    
930
            if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
931
                switch ($field) {
932
//            case 'recordBasis':
933
//                if ($value != '' /* FieldUnit' */) {
934
//                    @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
935
//                }
936
//                break;
937
                    /* ---- java.lang.Object --- */
938

    
939
                    case 'markers':
940
                       /* $dd_elements = array();
941
                        foreach ($value as $marker) {
942
                            $dd_elements[] = compose_cdm_marker($marker);
943
                        }
944
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
945
                       */
946
                       break;
947

    
948

    
949
                    case 'annotations':
950
                        /*$dd_elements = array();
951
                        foreach ($value as $annotation) {
952
                            // TODO respect annotation type filter settings
953
                            $dd_elements[] = $annotation->text;
954
                        }
955
                        @_description_list_group_add($groups, t('Notes'), $dd_elements);
956
                        */
957
                        break;
958

    
959
                    /* ---- SpecimenOrObservationBase --- */
960
                    case 'sex':
961
                    case 'lifeStage':
962
                    case 'kindOfUnit':
963
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->representation_L10n, NULL, 1);
964
                        break;
965

    
966
                    case 'definition':
967
                        // TODO
968
                        break;
969

    
970
                    case 'preferredStableUri':
971

    
972
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), array(array('#markup' => cdm_external_uri($value, false))));
973
                        break;
974

    
975
                    case 'specimenTypeDesignations':
976
                      /*     $groups,
977
                            cdm_occurrence_field_name_label($field),
978
                            array(
979
                                '#markup' => theme('cdm_typedesignations', array('typeDesignations' => $value)),
980
                            )
981
                        );
982
                      */
983
                        break;
984

    
985
                    case 'determinations':
986
                        /*$dd_elements = array();
987
                        $glue = ', ';
988

    
989
                        foreach ($value as $determinationEvent) {
990
                            $timeperiod_string = NULL;
991
                            if (isset($determinationEvent->timeperiod)) {
992
                                $timeperiod_string = timePeriodToString($determinationEvent->timeperiod);
993
                            }
994
                            $weight = isset($determinationEvent->preferred) && $determinationEvent->preferred == 1 ? '0' : ($timeperiod_string ? $timeperiod_string : '1');
995
                            // check key exists
996
                            while (array_key_exists($weight, $dd_elements)) {
997
                                $weight .= '0';
998
                            }
999

    
1000
                            $taxon_name = '';
1001
                            $name_link = '';
1002
                            if ($determinationEvent->taxonName) {
1003
                                $taxon_name = $determinationEvent->taxonName;
1004
                            } else if ($determinationEvent->taxon) {
1005
                                $taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
1006
                                $name_link = path_to_taxon($determinationEvent->taxon->uuid);
1007
                            }
1008
                            if ($taxon_name) {
1009
                                $taxon_html = render_taxon_or_name($taxon_name, $name_link);
1010
                                $dd_elements[$weight] = $taxon_html;
1011
                            }
1012
                            if (isset($determinationEvent->modifier)) {
1013
                            }
1014
                            if ($timeperiod_string) {
1015
                                $dd_elements[$weight] .= $glue . $timeperiod_string;
1016
                            }
1017
                            if (isset($determinationEvent->actor->titleCache)) {
1018
                                $dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache;
1019
                            }
1020
                            if (isset($determinationEvent->description)) {
1021
                                $dd_elements[$weight] .= $glue . $determinationEvent->description;
1022
                            }
1023
                        }
1024
                        ksort($dd_elements);
1025
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements);
1026
                        */
1027
                        break;
1028

    
1029
                    case 'listOfMedia':
1030
                        $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
1031
                        $captionElements = array(
1032
                            '#uri' => t('open media'),
1033
                        );
1034
                        $gallery_html = compose_cdm_media_gallerie(array(
1035
                            'mediaList' => $value,
1036
                            'galleryName' => $specimenOrObservation->label,
1037
                            'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
1038
                            'cols' => $gallery_settings['cdm_dataportal_media_cols'],
1039
                            'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
1040
                            'captionElements' => $captionElements,
1041
                            'mediaLinkType' => 'LIGHTBOX',
1042
                            'alternativeMediaUri' => NULL,
1043
                            'galleryLinkUri' => NULL,
1044
                        ));
1045

    
1046
                         @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $gallery_html);
1047
                         break;
1048

    
1049
                    case 'sources':
1050
                        /*
1051
                        $dd_elements = array();
1052
                        foreach ($value as $identifiable_source) {
1053
                            $dd_elements[] = theme('cdm_OriginalSource', array('source' => $identifiable_source));
1054
                        }
1055
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 10);
1056
                        */
1057
                        break;
1058

    
1059

    
1060
                    /* ---- DerivedUnitBase --- */
1061

    
1062

    
1063
                    case 'collection':
1064

    
1065
                        $sub_dl_groups = array();
1066
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1);
1067
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2);
1068
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3);
1069
                        @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4);
1070
                        // TODO "superCollection"
1071
                        // TODO may have media
1072

    
1073
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
1074
                            array(
1075
                                array('#markup' => $value->titleCache),
1076
                                array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
1077
                            )
1078
                        );
1079

    
1080
                        break;
1081

    
1082
                    case 'storedUnder':
1083

    
1084
                        //@_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value));
1085
                        break;
1086

    
1087

    
1088
                    /* ---- Specimen --- */
1089
                    case 'sequences':
1090
                        /*
1091
                        $dd_elements = array();
1092
                        foreach ($value as $sequence) {
1093
                            $dd_elements[] = compose_cdm_sequence($sequence);
1094
                        }
1095
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
1096
                        */
1097
                        break;
1098

    
1099
                    // TODO preservation
1100
                    // TODO exsiccatum
1101

    
1102

    
1103
                    /* ---- FieldObservation --- */
1104
                    case 'gatheringEvent':
1105

    
1106
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->actor->titleCache);
1107
                        @_description_list_group_add($groups, t('Gathering time'), timePeriodToString($value->timeperiod));
1108
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description);
1109
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality->text);
1110
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country->representation_L10n);
1111
                        @_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod);
1112
                        if (isset($value->absoluteElevation)) {
1113
                            $min_max_markup = min_max_measure($value, 'absoluteElevation');
1114
                            @_description_list_group_add($groups, cdm_occurrence_field_name_label('absoluteElevation'), $min_max_markup);
1115
                        }
1116
                        if (isset($value->distanceToGround)) {
1117
                            $min_max_markup = min_max_measure($value, 'distanceToGround');
1118
                            @_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToGround'), $min_max_markup);
1119
                        }
1120
                        if (isset($value->distanceToWaterSurface)) {
1121
                            $min_max_markup = min_max_measure($value, 'distanceToWaterSurface');
1122
                            @_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToWaterSurface'), $min_max_markup);
1123
                        }
1124

    
1125
                        if (isset($value->collectingAreas)) {
1126
                            $area_representations = array();
1127
                            foreach ($value->collectingAreas as $area) {
1128
                                $area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid));
1129
                            }
1130
                            if (!empty($area_representations))
1131
                                @_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'),
1132
                                    array(
1133
                                        array('#markup' => implode(', ', $area_representations))
1134
                                    )
1135
                                );
1136
                        }
1137
                        if (isset($value->exactLocation)  && $value->exactLocation->sexagesimalString) {
1138
                            $sub_dl_groups = array();
1139
                            @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1);
1140
                            @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2);
1141
                            @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('latitude'), round($value->exactLocation->latitude, 7), '°', 3);
1142
                            if (isset($value->exactLocation->referenceSystem)) {
1143
                                @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4);
1144
                            }
1145

    
1146
                            @_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
1147
                                array(
1148
                                    array('#markup' => $value->exactLocation->sexagesimalString),
1149
                                    array(
1150
                                        '#theme' => 'description_list',
1151
                                        '#groups' => $sub_dl_groups
1152
                                    ),
1153
                                )
1154
                            );
1155
                        }
1156

    
1157
                        break;
1158

    
1159
                    /* ---- DerivationEvent --- */
1160
                    case 'derivationEvents':
1161
                        //@_description_list_group_add($groups, t('Association type'), $value->description);
1162
                        break;
1163

    
1164

    
1165
                    default:
1166
                        if (is_object($value) || is_array($value)) {
1167
                           // drupal_set_message("Unhandled type in compose_cdm_specimenOrObservation() for field " . $field, "warning");
1168
                        } else {
1169
                            _description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
1170
                        }
1171

    
1172
                }
1173

    
1174

    
1175
            }
1176
        } // END of loop over $derivedUnitFacade fields
1177

    
1178
        // Extensions
1179
       /* $extensions = cdm_ws_fetch_all(CDM_WS_PORTAL_OCCURRENCE . '/' . $specimenOrObservation->uuid . '/extensions', array($specimenOrObservation->uuid));
1180
        if ($extensions && count($extensions)) {
1181

    
1182
            $extensions_render_array = compose_extensions($extensions);
1183
            @_description_list_group_add($groups, t('Extensions') . ':',
1184
                $extensions_render_array,
1185
                '', 100);
1186
        }
1187
*/
1188

    
1189
        // template_preprocess_description_list() is not worting by weight so we do it right here
1190
        uasort($groups, 'element_sort');
1191

    
1192
        $occurrence_elements = array(
1193
           // '#title' => $title,
1194
            '#theme' => 'description_list',
1195
            '#groups' => $groups,
1196
            '#attributes' => array('class' => html_class_attribute_ref($specimenOrObservation)),
1197
        );
1198
        $output = drupal_render($occurrence_elements);
1199

    
1200

    
1201

    
1202

    
1203

    
1204

    
1205

    
1206

    
1207
    } // END of $specimenOrObservation exists
1208

    
1209
    return $output;
1210
}
1211

    
(6-6/10)