Project

General

Profile

Revision c10f70e4

IDc10f70e47b400b1936298f9b5801718a8cb5a531
Parent 2d3d6556
Child 98262d29

Added by Katja Luther over 2 years ago

first steps of specimen page with DTOs

View differences:

modules/cdm_dataportal/includes/occurrences.inc
35 35
        $detail_html .= "<strong>$specimenPageLink</strong><br>";
36 36
    }
37 37

  
38
    if($is_specimen_page) {
39
        if($specimen->citation){
40
            $detail_html .= "<br>".create_label("Citation") . $specimen->citation . "<br>";
38
    if ($is_specimen_page) {
39
        if ($specimen->citation) {
40
            $detail_html .= "<br>" . create_label("Citation") . $specimen->citation . "<br>";
41 41
        }
42 42
    }
43
    if($specimen->preferredStableUri){
44
        $stableIdentifierLink  = l($specimen->preferredStableUri, $specimen->preferredStableUri, array('attributes' => array('target' => '_blank')));
43
    if ($specimen->preferredStableUri) {
44
        $stableIdentifierLink = l($specimen->preferredStableUri, $specimen->preferredStableUri, array('attributes' => array('target' => '_blank')));
45 45
        $detail_html .= create_label("Preferred stable URI") . $stableIdentifierLink . "<br>";
46 46
    }
47
    if($is_specimen_page){
47
    if ($is_specimen_page) {
48 48
        // associated taxa
49
        if($specimen->associatedTaxa){
49
        if ($specimen->associatedTaxa) {
50 50
            $detail_html .= "<br>";
51
          $detail_html .= create_label("Associated with");
52
          if(sizeof($specimen->associatedTaxa)>1){
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
            }
53 58
            $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 59
        }
60 60
    }
61
  // - type information
61
    // - type information
62 62
    $types = "";
63 63
    if (isset($specimen->types)) {
64 64
        //typed taxa
65 65
        foreach ($specimen->types as $typeStatus => $typedTaxa) {
66
/* Updated upstream
66 67
            if($specimen->types){
67 68
                $detail_html .= "<i>".$typeStatus."</i> of ";
68 69
                foreach($typedTaxa as $typedTaxon){
69 70
                    $detail_html .= $typedTaxon." ";
70 71
                }
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

  
72 85
            }
73 86
        }
74 87
    }
......
94 107
                            if (isset($contigFile->contigLink->uri) and $contigFile->contigLink->uri != null) {
95 108
                                $molecularData .= create_html_link($contigFile->contigLink, true) . " ";
96 109
                            }
97
                        }
98
                        else {
110
                        } else {
99 111
                            $molecularData .= "no contig ";
100 112
                        }
101 113
                        //primer links
102
                        if(isset($contigFile->primerLinks)) {
114
                        if (isset($contigFile->primerLinks)) {
103 115
                            $molecularData .= create_html_links($contigFile->primerLinks, true);
104 116
                        }
105 117
                    }
......
114 126
    $detailImages = create_html_links($derivateDataDTO->detailImages, true);
115 127

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

  
128 140
    if ($molecularData) {
129
        $detail_html .= $is_specimen_page?"<br>":"";
141
        $detail_html .= $is_specimen_page ? "<br>" : "";
130 142
        $detail_html .= create_label("Molecular Data") . $molecularData . "<br>";
131 143
    }
132 144

  
......
135 147
    }
136 148

  
137 149
    //detail image gallery
138
    if($is_specimen_page and isset($derivateDataDTO->detailImageUuids) and !empty($derivateDataDTO->detailImageUuids)){
150
    if ($is_specimen_page and isset($derivateDataDTO->detailImageUuids) and !empty($derivateDataDTO->detailImageUuids)) {
139 151
        $detail_html .= addImageGallery("Detail Images", $derivateDataDTO->detailImageUuids);
140 152
    }
141 153

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

  
161
function addImageGallery($galleryName, $imageUuids){
172
function addImageGallery($galleryName, $imageUuids)
173
{
162 174
    $images = array();
163 175
    foreach ($imageUuids as $uuid) {
164 176
        $images[] = cdm_ws_get(CDM_WS_PORTAL_MEDIA, $uuid);
......
172 184
            'rights',
173 185
        );
174 186
        $alternativeMediaUris = array();
175
        foreach($images as $image){
176
          $mediaUri = getMediaUri($image);
177
          if($mediaUri){
178
            $alternativeMediaUris[] = $mediaUri;
179
          }
180
          else{
181
            $alternativeMediaUris[] = path_to_media($image->uuid);
182
          }
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
            }
183 194
        }
184 195

  
185 196
        $gallery_html = compose_cdm_media_gallerie(array(
......
194 205
            'galleryLinkUri' => NULL,
195 206
        ));
196 207
    }
197
    return "<br>".create_label($galleryName)."<br>".$gallery_html;
208
    return "<br>" . create_label($galleryName) . "<br>" . $gallery_html;
198 209
}
199 210

  
200
function getMediaUri($media){
201
  if(isset($media->representations) && sizeof($media->representations)==1
202
    && isset($media->representations[0]->parts) &&
203
    sizeof($media->representations[0]->parts)==1) {
204
    return $media->representations[0]->parts[0]->uri;
205
  }
206
  return null;
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;
207 219
}
208 220

  
209 221

  
......
213 225
 */
214 226
function create_label($label)
215 227
{
216
    return "<span class='specimen_table_label'>".$label.": </span>";
228
    return "<span class='specimen_table_label'>" . $label . ": </span>";
217 229
}
218 230

  
219 231
/**
......
234 246
 *
235 247
 * @ingroup compose
236 248
 */
249
/*<<<<<<< Updated upstream
237 250
function compose_cdm_specimen_or_observation($specimenOrObservation, &$derivatives = null) {
238 251

  
239 252
  $exclude_occurrence_fields = &drupal_static(__FUNCTION__);
......
264 277

  
265 278
  $descriptions = null;
266 279
  $derivedFrom = null;
280
=======*/
281
function compose_cdm_specimenOrObservation($specimenOrObservation, &$derivatives = null)
282
{
267 283

  
268
  if (is_object($specimenOrObservation)) {
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
    }
269 300

  
270
    // request again for deeper initialization
271
    $specimenOrObservation = cdm_ws_get("portal/" . CDM_WS_OCCURRENCE, $specimenOrObservation->uuid);
272 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
    }
273 306

  
274
    $type_label = $specimenOrObservation->class;
275
    RenderHints::setFootnoteListKey($type_label . '-' . $specimenOrObservation->uuid);
307
    if (!isset($derivatives)) {
308
        $derivatives = array();
309
    }
276 310

  
277
    // collect typeStatus as label
278
    if (isset($specimenOrObservation->specimenTypeDesignations)) {
279
      $type_status = array();
280
      foreach ($specimenOrObservation->specimenTypeDesignations as $typeDesignation) {
281
        if (isset($typeDesignation->typeStatus->representation_L10n)) {
282
          $type_status[] = $typeDesignation->typeStatus->representation_L10n;
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
            }
283 349
        }
284
      }
285
      if (count($type_status) > 0) {
286
        $type_label = implode(', ', $type_status);
287
      }
288
    }
289 350

  
290
    $title = $type_label . ': ' . $specimenOrObservation->titleCache;
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;
291 369

  
292
    $groups = array();
293
    // --- add initialized fields
294
    foreach (get_object_vars($specimenOrObservation) as $field => $value) {
295
      if (!in_array($field, $exclude_occurrence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
296
        switch ($field) {
297

  
298
          /* ---- java.lang.Object --- */
299
          case 'class':
300
            if ($value != '' /* FieldUnit' */) {
301
              @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
302
            }
303
            break;
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;
304 377

  
305
          case 'markers':
306
            $dd_elements = array();
307
            foreach ($value as $marker) {
308
              $dd_elements[] = compose_cdm_marker($marker);
309
            }
310
            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
311
            break;
312 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
                            }
313 428

  
314
          case 'annotations':
315
            $dd_elements = array();
316
            foreach ($value as $annotation) {
317
              // TODO respect annotation type filter settings
318
              $dd_elements[] = $annotation->text;
319
            }
320
            @_description_list_group_add($groups, t('Notes'), $dd_elements);
321
            break;
322

  
323
          /* ---- SpecimenOrObservationBase --- */
324
          case 'sex':
325
          case 'lifeStage':
326
          case 'kindOfUnit':
327
            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value->representation_L10n);
328
            break;
329

  
330
          case 'definition':
331
            // TODO
332
            break;
333

  
334
          case 'preferredStableUri':
335

  
336
            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), array(array('#markup' => cdm_external_uri($value, false))));
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

  
364
              $taxon_name = '';
365
              $name_link = '';
366
              if ($determinationEvent->taxonName) {
367
                $taxon_name = $determinationEvent->taxonName;
368
              } else if ($determinationEvent->taxon) {
369
                $taxon_name = cdm_ws_get(CDM_WS_TAXON . '/$0/name', $determinationEvent->taxon->uuid);
370
                $name_link = path_to_taxon($determinationEvent->taxon->uuid);
371
              }
372
              if ($taxon_name) {
373
                $taxon_html = render_taxon_or_name($taxon_name, $name_link);
374
                $dd_elements[$weight] = $taxon_html;
375
              }
376
              if (isset($determinationEvent->modifier)) {
377
                $dd_elements[$weight] .= cdm_term_representation($determinationEvent->modifier);
378
              }
379
              if ($timeperiod_string) {
380
                $dd_elements[$weight] .= $glue . $timeperiod_string;
381
              }
382
              if (isset($determinationEvent->actor->titleCache)) {
383
                $dd_elements[$weight] .= $glue . $determinationEvent->actor->titleCache;
384
              }
385
              if (isset($determinationEvent->description)) {
386
                $dd_elements[$weight] .= $glue . $determinationEvent->description;
387
              }
388
            }
389
            ksort($dd_elements);
390
            @_description_list_group_add($groups, cdm_occurrence_field_name_label('determinations'), $dd_elements);
391
            break;
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;
392 457

  
393
          case 'descriptions':
394
            $occurrence_featureTree = cdm_get_occurrence_featureTree();
395
            $dd_elements = array();
458
                    case 'descriptions':
459
                        $occurrence_featureTree = cdm_get_occurrence_featureTree();
460
                        $dd_elements = array();
396 461

  
397
            foreach ($value as $description) {
398
              $description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, $description->uuid);
462
                        foreach ($value as $description) {
463
                            $description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, $description->uuid);
399 464
//               if($description->imageGallery == TRUE) {
400 465
//                 continue;
401 466
//               }
402
              $elements_by_feature = _mergeFeatureTreeDescriptions($occurrence_featureTree->root->childNodes, $description->elements);
403
              $description_render_elements = _block_get_renderable_array(make_feature_block_list($elements_by_feature, null));
404
              $dd_elements[] = $description_render_elements;
405
            }
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
                                }
406 494

  
407
            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
408
            break;
495
                            }
496
                        }
409 497

  
410
          case 'sources':
411
            $dd_elements = array();
412
            foreach ($value as $identifiable_source) {
413
              $dd_elements[] = theme('cdm_OriginalSource', array('source' => $identifiable_source));
414
            }
415
            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
416
            break;
417

  
418

  
419
          /* ---- DerivedUnitBase --- */
420
          case 'derivedFrom':
421
            $derivedFrom = $value;
422
            break;
423

  
424
          case 'collection':
425
            $sub_dl_groups = array();
426
            @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('code'), $value->code, NULL, 1);
427
            @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('codeStandard'), $value->codeStandard, NULL, 2);
428
            @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('institute'), $value->institute, NULL, 3);
429
            @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('townOrLocation'), $value->townOrLocation, NULL, 4);
430
            // TODO "superCollection"
431
            // TODO may have media
432

  
433
            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
434
              array(
435
                array('#markup' => $value->titleCache),
436
                array('#theme' => 'description_list', '#groups' => $sub_dl_groups)
437
              )
438
            );
439
            break;
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;
440 501

  
441
          case 'storedUnder':
442
            @_description_list_group_add($groups, cdm_occurrence_field_name_label('storedUnder'), render_taxon_or_name($value));
443
            break;
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
                        }
444 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
                            }
445 592

  
446
          /* ---- Specimen --- */
447
          case 'sequences':
448
            $dd_elements = array();
449
            foreach ($value as $sequence) {
450
              $dd_elements[] = compose_cdm_sequence($sequence);
451
            }
452
            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements);
453
            break;
454

  
455
          // TODO preservation
456
          // TODO exsiccatum
457

  
458

  
459
          /* ---- FieldObservation --- */
460
          case 'gatheringEvent':
461
            @_description_list_group_add($groups, cdm_occurrence_field_name_label('collector'), $value->actor->titleCache);
462
            @_description_list_group_add($groups, t('Gathering time'), timePeriodToString($value->timeperiod));
463
            @_description_list_group_add($groups, cdm_occurrence_field_name_label('description'), $value->description);
464
            @_description_list_group_add($groups, cdm_occurrence_field_name_label('locality'), $value->locality->text);
465
            @_description_list_group_add($groups, cdm_occurrence_field_name_label('country'), $value->country->representation_L10n);
466
            @_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingMethod'), $value->collectingMethod);
467
            if (isset($value->absoluteElevation)) {
468
              $min_max_markup = min_max_measure($value, 'absoluteElevation');
469
              @_description_list_group_add($groups, cdm_occurrence_field_name_label('absoluteElevation'), $min_max_markup);
470
            }
471
            if (isset($value->distanceToGround)) {
472
              $min_max_markup = min_max_measure($value, 'distanceToGround');
473
              @_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToGround'), $min_max_markup);
474
            }
475
            if (isset($value->distanceToWaterSurface)) {
476
              $min_max_markup = min_max_measure($value, 'distanceToWaterSurface');
477
              @_description_list_group_add($groups, cdm_occurrence_field_name_label('distanceToWaterSurface'), $min_max_markup);
478
            }
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
                        }
479 622

  
480
            if (isset($value->collectingAreas)) {
481
              $area_representations = array();
482
              foreach ($value->collectingAreas as $area) {
483
                $area_representations[] = l($area->representation_L10n, path_to_named_area($area->uuid));
484
              }
485
              @_description_list_group_add($groups, cdm_occurrence_field_name_label('collectingAreas'),
486
                array(
487
                  array('#markup' => implode(', ', $area_representations))
488
                )
489
              );
490
            }
491
            if (isset($value->exactLocation) && $value->exactLocation->sexagesimalString) {
492
              $sub_dl_groups = array();
493
              @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('errorRadius'), $value->exactLocation->errorRadius, ' m', 1);
494
              @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('longitude'), round($value->exactLocation->longitude, 7), '°', 2);
495
              @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('latitude'), round($value->exactLocation->latitude, 7), '°', 3);
496
              if (isset($value->exactLocation->referenceSystem)) {
497
                @_description_list_group_add($sub_dl_groups, cdm_occurrence_field_name_label('referenceSystem'), $value->exactLocation->referenceSystem->representation_L10n, '', 4);
498
              }
499

  
500
              @_description_list_group_add($groups, cdm_occurrence_field_name_label('exactLocation'),
501
                array(
502
                  array('#markup' => $value->exactLocation->sexagesimalString),
503
                  array(
504
                    '#theme' => 'description_list',
505
                    '#groups' => $sub_dl_groups
506
                  ),
507
                )
508
              );
509
            }
510
            break;
623
                }
511 624

  
625
/*
626
 *
512 627
          default:
513 628
            if (is_object($value) || is_array($value)) {
514 629
              drupal_set_message("Unhandled type in compose_cdm_specimen_or_observation() for field " . $field, "warning");
515 630
            } else {
516 631
              _description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value);
632
*/
633
// Stashed changes
517 634
            }
635
        } // END of loop over $derivedUnitFacade fields
518 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);
519 645
        }
520 646

  
521
      }
522
    } // END of loop over $derivedUnitFacade fields
523 647

  
524
    // Extensions
525
    $extensions = cdm_ws_fetch_all(CDM_WS_PORTAL_OCCURRENCE . '/'  . $specimenOrObservation->uuid . '/extensions', array($specimenOrObservation->uuid));
526
    if ($extensions && count($extensions)) {
648
        // template_preprocess_description_list() is not worting by weight so we do it right here
649
        uasort($groups, 'element_sort');
527 650

  
528
      $extensions_render_array = compose_extensions($extensions);
529
      @_description_list_group_add($groups, t('Extensions') . ':',
530
        $extensions_render_array,
531
        '', 100);
532
    }
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
        }
533 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
        }
534 673

  
535
    // template_preprocess_description_list() is not worting by weight so we do it right here
536
    uasort($groups, 'element_sort');
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
537 689

  
538
    $occurrence_elements = array(
539
        '#title' => $title,
540
        '#theme' => 'description_list',
541
        '#groups' => $groups,
542
        '#attributes' => array('class' => html_class_attribute_ref($specimenOrObservation)),
543
    );
544
    $derivatives[] = $occurrence_elements;
545
    // all footnotes which has been assembled so far (e.g. from typeDesignations) to here
546
    $foonote_li_elements = theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'span'));
547
    if (!empty($foonote_li_elements)) {
548
      $derivatives[] =  array(
549
          '#markup' =>  '<div class="footnotes">' . $foonote_li_elements . '</div>',
550
      );
551
    }
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) {
552 696

  
553
    // --- recurse into originals
554
    if (!isset($derivedFrom)) {
555
      $derivedFrom = cdm_ws_get(
556
          CDM_WS_OCCURRENCE,
557
          array($specimenOrObservation->uuid, 'derivedFrom')
558
        );
559
    }
560 697

  
561
    if (isset($derivedFrom)) {
562
      if (isset($derivedFrom->originals)) {
563
        $derived_from_label = t('derived');
564
        $preposition = t('from');
565
        if(isset($derivedFrom->type)){
566
          $derived_from_label = $derivedFrom->type->representation_L10n;
567
          if($derivedFrom->type->uuid == UUID_DERIVATIONEVENTTYPE_ACCESSIONING){
568
            $preposition = t('of');
569
          }
570
        }
571
        if (count($groups) > 0) {
572
          // TODO  annotations
573 698

  
574
          // only display the derived from information when the derivative has any element which will be diplayed
575
          $derivatives[] = array(
576
              '#markup' => '<div class="derived_from">' . $derived_from_label . ' ' . $preposition . ': </div>',
577
          );
699
            }
578 700
        }
701
/*<<<<<<< Updated upstream
579 702
        foreach ($derivedFrom->originals as $original) {
580 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
581 711
        }
582
      }
583
    }
584 712

  
585
  } // END of $specimenOrObservation exists
713
    } // END of $specimenOrObservation exists
586 714

  
587
  return $derivatives;
715
    return $derivatives;
588 716
}
589 717

  
590 718

  
......
600 728
 *
601 729
 * @ingroup compose
602 730
 */
603
function compose_cdm_sequence($sequence) {
604

  
605
  $exclude_sequence_fields = &drupal_static(__FUNCTION__);
606
  if (!isset($exclude_sequence_fields)) {
607
    $exclude_sequence_fields = array(
608
      'titleCache',
609
      'protectedTitleCache',
610
      'microReference',
611
      'created',
612
      'updated',
613
      'class',
614
    );
615
  }
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
    }
616 745

  
617
  $groups = array();
746
    $groups = array();
618 747

  
619
  // -- retrieve additional data if neesscary
620
  // TODO below call disabled since sequences are not yet supported,
621
  //      see  #3347 (services and REST service controller for molecular classes implemented)
622
  //
623
  // cdm_load_annotations($sequence);
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);
624 753

  
625
  foreach (get_object_vars($sequence) as $field => $value) {
754
    foreach (get_object_vars($sequence) as $field => $value) {
626 755

  
627 756

  
628
    if (!in_array($field, $exclude_sequence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
629
      switch ($field) {
757
        if (!in_array($field, $exclude_sequence_fields) && ($value && (!is_object($value) || isset($value->class)))) {
758
            switch ($field) {
630 759

  
631
        case 'geneticAccessionNumber';
632
          $dd_elements = array();
633
          foreach ($value as $accession) {
634
            if (isset($accession->uri) ){
635
              $dd_elements[] = l($accession->accessionNumber, $accession->uri);
636
            } else {
637
              $dd_elements[] = $accession->accessionNumber;
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
                    }
638 871
            }
639
          }
640
          @_description_list_group_add($groups, cdm_occurrence_field_name_label($field),  $dd_elements, NULL, 1);
641
          break;
642

  
643

  
644
        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.
645
          if (isset($value->name)) {
646
            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field),  $value->name, NULL, 3);
647
          }
648
          if (isset($value->description)) {
649
            @_description_list_group_add($groups, cdm_occurrence_field_name_label($field) . ' ' . t('description') , $value->description, NULL, 4);
650
          }
651
          break;
652

  
653
        case 'consensusSequence':
654
          // format in genbank style, force linebreaks after each 70 nucleotites
655
          // see also http://stackoverflow.com/questions/499137/css-how-can-i-force-a-long-string-without-any-blank-to-be-wrapped-in-xul-and
656
          @_description_list_group_add(
657
            $groups,
658
            cdm_occurrence_field_name_label($field),
659
            array(
660
              array(
661
                '#markup' => '<div class="sequence-length">' . $value->length . ' ' . t('pb'). '</div><div>' . wordwrap($value->string, 70, '</br>', TRUE) . '</div>',
662
                '#wrapper_attributes' => array('class'=>'dna-sequence')
663
                )
664
              ),
665
            5);
666
          break;
667

  
668
         case 'dnaSample': // FIXME 3.3 implement
669
            break;
670
        case 'singleReads': // FIXME 3.3 implement
671
          break;
672
        case 'contigFile': // FIXME 3.3 implement - Media
673
            break;
674
        case 'pherograms': // FIXME 3.3 implement - Media
675
          break;
676
        case 'haplotype': // FIXME 3.3 implement
677
            break;
678
        case 'dateSequenced': // FIXME 3.3 now in SingelRead
679
          @_description_list_group_add($groups, t('Sequencing date'),  timePeriodToString($value), NULL, 6);
680
          break;
681

  
682
        case 'barcode': // boolean
683
          @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value ? 'Yes': 'No', NULL, 7);
684
          break;
685
        case 'barcodeSequencePart': // FIXME 3.3 implement, compose sequence
686
            break;
687

  
688
        case 'citation':
689
          @_description_list_group_add($groups,
690
            cdm_occurrence_field_name_label($field),
691
            theme('cdm_reference', array('reference' =>$value, 'microReference' => $sequence->microReference)),
692
            NULL,
693
            8
694
          );
695
          break;
696

  
697
        case 'publishedIn':
698
          @_description_list_group_add($groups,
699
            cdm_occurrence_field_name_label($field),
700
            theme('cdm_reference', array('reference'=>$value)),
701
            NULL,
702
            7
703
          );
704
          break;
705

  
706
        case 'rights':
707
          array_merge($groups, cdm_rights_as_dl_groups($value));
708
          break;
709

  
710
        case 'annotations':
711
          $dd_elements = array();
712
          foreach ($value as $annotation) {
713
            // TODO respect annotation type filter settings
714
            $dd_elements[] = $annotation->text;
715
          }
716
          @_description_list_group_add($groups, t('Notes'), $dd_elements, NULL, 9);
717
          break;
718

  
719
        case 'markers':
720
          $dd_elements = array();
721
          foreach ($value as $marker) {
722
            $dd_elements[] = compose_cdm_marker($marker);
723
          }
724
          @_description_list_group_add($groups, cdm_occurrence_field_name_label($field), $dd_elements, NULL, 10);
725
          break;
726

  
727
        case 'chromatograms':
728
          @_description_list_group_add($groups, cdm_occurrence_field_name_label($field),
729
              array(
730
                  '#markup'=>compose_cdm_media_gallerie(array('medialist'=>$value)),
731
              ),
732
              NULL,
733
              11);
734
          break;
735

  
736
        default:
737
          if(is_object($value) || is_array($value)){
738
            drupal_set_message("Unhandled type in compose_cdm_sequence() for field " . $field, "warning");
739
          } else {
740
            _description_list_group_add($groups, cdm_occurrence_field_name_label($field), $value, NULL, 20);
741
          }
742
      }
872
        }
743 873
    }
744
  }
745 874

  
746
  // template_preprocess_description_list() is not worting by weight so we do it right here
747
  uasort($groups, 'element_sort');
875
    // template_preprocess_description_list() is not worting by weight so we do it right here
876
    uasort($groups, 'element_sort');
748 877

  
749
  $sequence_elements = array(
750
      '#theme' => 'description_list',
751
      '#groups' => $groups
752
  );
878
    $sequence_elements = array(
879
        '#theme' => 'description_list',
880
        '#groups' => $groups
881
    );
753 882

  
754
  return $sequence_elements;
883
    return $sequence_elements;
755 884
}
756 885

  
757 886

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)