Project

General

Profile

Download (61.3 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Description theming functions.
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

    
16
/**
17
 * @todo Please document this function.
18
 * @see http://drupal.org/node/1354
19
 */
20
function theme_cdm_feature_nodesTOC($variables) {
21
  $featureNodes = $variables['featureNodes'];
22
  $out = '';
23
  $out .= '<ul>';
24

    
25
  foreach ($featureNodes as $node) {
26

    
27
    if (hasFeatureNodeDescriptionElements($node)) {
28

    
29
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
30
      // HACK to implement images for taxa, should be removed.
31
      if ($node->feature->uuid != UUID_IMAGE) {
32
        $out .= '<li>' . l(t(theme('cdm_feature_name', array('feature_name' => $featureRepresentation))), $_GET['q'], array(
33
         'attributes' => array('class' => array('toc')), 'fragment' => generalizeString($featureRepresentation))) . '</li>';
34
      }
35
    }
36
  }
37

    
38
  $out .= '</ul>';
39
  return $out;
40
}
41

    
42
/**
43
 * Theme function to alter the feature representation.
44
 *
45
 * It is highly qeutionalbe if this function should be completely removed.
46
 * If a feature needs a different representation this should be edited directly
47
 * in the cdm data but it shoud not be tweeked like this in the portal.
48
 *
49
 * Used in:
50
 *  - theme_cdm_feature_nodesTOC()
51
 *  - theme_cdm_feature_nodes()
52
 *  - theme_cdm_media_mime_application()
53
 *  - theme_cdm_media_mime_text()
54
 *
55
 * TODO delete this function? (a.kohlbecker feb 2013)
56
 *
57
 */
58
function theme_cdm_feature_name($variables) {
59
  $feature_name = $variables['feature_name'];
60
  // TODO replace by using translations ?
61
  return t($feature_name);
62
}
63

    
64
/**
65
 * Returns HTML for a taxon profile.
66
 *
67
 * The taxon profile consists of description elements which are ordered by the
68
 * structure defined by specific FeatureTree. The chosen FeatureTree is merged
69
 * with the list of desctiprion elements prior to using this method.
70
 *
71
 * @see cdm_ws_descriptions_by_featuretree()
72
 *
73
 * @param array $variables
74
 *   An associative array containing:
75
 *   - mergedTrees
76
 *   - taxon: The taxon whose sprofile to show.
77
 *
78
 * @ingroup themeable
79
 */
80
function theme_cdm_featureTrees($variables) {
81
  $mergedTrees = $variables['mergedTrees'];
82
  $taxon = $variables['taxon'];
83
  $out = '';
84
  if (!isset($mergedTrees)) {
85
    return;
86
  }
87

    
88
  foreach ($mergedTrees as &$mTree) {
89
    // TODO display title and reference in case of multiple $mergedTrees ->
90
    // theme
91
    $out .= theme('cdm_feature_nodes', array('mergedFeatureNodes' => $mTree->root->children, 'taxon' => $taxon));
92
  }
93

    
94
  return $out;
95
}
96

    
97
/**
98
 * @todo Please document this function.
99
 * @see http://drupal.org/node/1354
100
 */
101
function theme_cdm_featureTreeTOCs($variables) {
102
  $mergedTrees = $variables['mergedTrees'];
103
  if (!$mergedTrees) {
104
    return;
105
  }
106
  // FIXME.
107
  $out = '<div id="featureTOC">';
108
  $out .= '<h2>' . t('Content') . '</h2>';
109

    
110
  // TODO diplay title and reference in case of multiple $mergedTrees -> theme.
111
  foreach ($mergedTrees as &$mTree) {
112
    $out .= theme('cdm_feature_nodesTOC', array('featureNodes' => $mTree->root->children));
113
  }
114

    
115
  $out .= '</div>';
116
  return $out;
117
}
118

    
119
/**
120
 * Returns HTML for the $mergedFeatureNodes of a given $taxon.
121
 *
122
 * The merged nodes can be obtained by making use of the
123
 * function cdm_ws_descriptions_by_featuretree().
124
 *
125
 * @param array $variables
126
 *   An associative array containing:
127
 *   - mergedFeatureNodes
128
 *   -taxon
129
 *
130
 * @ingroup themeable
131
 */
132
function theme_cdm_feature_nodes($variables) {
133

    
134
  $mergedFeatureNodes = $variables['mergedFeatureNodes'];
135
  $taxon = $variables['taxon'];
136
  $out = '';
137

    
138
  RenderHints::pushToRenderStack('feature_nodes');
139

    
140
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME);
141

    
142
  // Creating an array to place the description elements in.
143
  foreach ($mergedFeatureNodes as $node) {
144

    
145
    if (hasFeatureNodeDescriptionElements($node)) {
146

    
147
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
148
      $block = new stdclass(); // Empty object.
149
      $block->module = 'cdm_dataportal';
150
      $media_list = array();
151

    
152
      if (true || $node->feature->uuid != UUID_IMAGE) {
153

    
154
        $block->delta = generalizeString($featureRepresentation);
155
        $block->subject = '<span class="' . html_class_atttibute_ref($node->feature) . '">' . theme('cdm_feature_name', array('feature_name' => $featureRepresentation)) . '</span>';
156
        $block->module = "cdm_dataportal-feature";
157
        $block->content = '';
158

    
159
        /*
160
         * Content/DISTRIBUTION.
161
         */
162
        if ($node->feature->uuid == UUID_DISTRIBUTION) {
163

    
164
          $node->descriptionElements = cdm_description_elements_prefer_computed($node->descriptionElements);
165

    
166
          if (variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
167
            $distributionTextDataList = array();
168
            $distributionElementsList = array();
169

    
170
            foreach ($node->descriptionElements as $descriptionElement) {
171
              if ($descriptionElement->class == "TextData") {
172
                $distributionTextDataList[] = $descriptionElement;
173
              }
174
              else {
175
                $distributionElementsList[] = $descriptionElement;
176
              }
177
            }
178

    
179

    
180
            if (count($distributionTextDataList) > 0) {
181
              $node->descriptionElements = $distributionElementsList;
182
              $block->content .= theme('cdm_descriptionElements', array(
183
                'descriptionElements' => $distributionTextDataList,
184
                'featureUuid' => $node->feature->uuid,
185
                'taxon_uuid' => $taxon->uuid,
186
              ));
187
            }
188
          }
189

    
190
          // Display cdm distribution map TODO this is a HACK to a proper
191
          // generic implementation?
192
          $block->content .= theme('cdm_distribution_map', array('taxon' => $taxon));
193
          $block->content .= theme('cdm_descriptionElements', array(
194
            'descriptionElements' => $node->descriptionElements,
195
            'featureUuid' => $node->feature->uuid,
196
            'taxon_uuid' => $taxon->uuid,
197
          ));
198

    
199
        }
200

    
201
        /*
202
         * Content/COMMON_NAME.
203
         */
204
        elseif ($node->feature->uuid == UUID_COMMON_NAME) {
205
          // TODO why is theme_cdm_descriptionElement_CommonTaxonName not
206
          // beeing used???
207
         $block->content .= theme('cdm_common_names', array('elements' => $node->descriptionElements));
208
          /*
209
          }else if($node->feature->uuid == UUID_IMAGE_SOURCES) {
210
          $block->content .= theme('cdm_image_sources',
211
          $node->descriptionElements);
212
          */
213
        }
214

    
215
        /*
216
         * Content/ALL OTHER FEATURES.
217
         */
218
        else {
219
          if (isset($node->descriptionElements)) {
220
            $taxon_uuid = NULL;
221
            if(isset($taxon) ) {
222
              $taxon_uuid = $taxon->uuid;
223
            }
224
            $block->content .= theme('cdm_descriptionElements', array(
225
              'descriptionElements' => $node->descriptionElements,
226
              'featureUuid' => $node->feature->uuid,
227
              'taxon_uuid' => $taxon_uuid,
228
            ));
229
          }
230

    
231
//           Content/ALL OTHER FEATURES/Subordinate Features
232
//           subordinate features are printed inline in one floating text,
233
//           it is expected hat supordinate features can "contain" TextData,
234
//           Qualitative- and Qualitative- DescriptioneElements
235
          if (isset($node->children[0])) {
236

    
237
            // TODO support more than one level of children.
238
            // can this be solved by resursively calling this very function?
239
            // @see http://dev.e-taxonomy.eu/trac/ticket/2393
240
            $text = '';
241
            foreach ($node->children as $child) {
242

    
243
              if (isset($child->descriptionElements) && is_array($child->descriptionElements)) {
244
                foreach ($child->descriptionElements as $element) {
245

    
246
                  if (is_array($element->media)) {
247
                    // Append media of supordinate elements to list of main
248
                    // feature.
249
                    $media_list = array_merge($media_list, $element->media);
250
                  }
251

    
252
                  switch ($element->class) {
253
                    case 'TextData':
254
                      // TODO use theme_cdm_descriptionElementTextData()
255
                      $out_child_elements = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
256
                      $out_child_elements = str_replace($child->feature->titleCache, '<em>' . $child->feature->representation_L10n . '</em>', $out_child_elements);
257
                      break;
258
                    case 'CategoricalData':
259
                      $out_child_elements  = '<em>' . $child->feature->representation_L10n . '</em> '
260
                        . theme('cdm_descriptionElement_CategoricalData', array('element' => $element));
261
                      break;
262
                    case 'QuantitativeData':
263
                      $out_child_elements = '<em>' . $child->feature->representation_L10n . '</em> '
264
                        . theme('cdm_descriptionElement_QuantitativeData', array('element' => $element));
265

    
266
                  }
267

    
268
                }
269
                $text .= " " . $out_child_elements;
270
                $out_child_elements = '';
271
              }
272
            }
273
            $block->content .= $text;
274
          }
275
        }
276

    
277
        /*
278
         * Media/ALL FEATURES.
279
         */
280
        if (isset($node->descriptionElements)) {
281
          $media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
282
        }
283
        $captionElements = array('title', 'rights');
284
        $gallery = '';
285
        if (isset($gallery_settings['cdm_dataportal_media_maxextend']) && isset($gallery_settings['cdm_dataportal_media_cols'])) {
286
          $gallery = theme('cdm_media_gallerie', array(
287
            'mediaList' => $media_list,
288
            'galleryName' => CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME . '_' . $node->feature->uuid,
289
            'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
290
            'cols' => $gallery_settings['cdm_dataportal_media_cols'],
291
            'captionElements' => $captionElements,
292
          ));
293
        }
294
        $block->content .= $gallery;
295
        $block->content .= theme('cdm_footnotes', array('footnoteListKey' => $node->feature->uuid));
296
        $block->content .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $node->feature->uuid));
297

    
298
        // Add anchor to subject.
299
        $block->subject = '<a name="' . $block->delta . '"></a>' . $block->subject;
300

    
301
        // In D6: $out .= theme('block', $block);
302
        // Comment @WA @TODO check if need to set a region, and which one.
303
        $block->region = FALSE;
304
        $out .= theme('block', array('elements' => array(
305
          '#block' => $block,
306
          '#children' => $block->content,
307
        )));
308
      }
309
    }
310
  }
311
  RenderHints::popFromRenderStack();
312
  return $out;
313
}
314

    
315
/**
316
 * @todo Please document this function.
317
 * @see http://drupal.org/node/1354
318
 */
319
function theme_FeatureTree_hierarchy($variables) {
320

    
321
  $FeatureTreeUuid = $variables['FeatureTreeUuid'];
322
  if (!is_uuid($FeatureTreeUuid)) {
323
    return;
324
  }
325

    
326
  $out = '';
327
  $featureTree = cdm_ws_get(CDM_WS_FEATURETREE, array(
328
    $FeatureTreeUuid,
329
  ));
330

    
331
  if (isset($featureTree) && isset($featureTree->root)) {
332
    $out = '<ul class="' . $featureTree->class . '">';
333
    $out .= theme('FeatureTree_hierarchy_children', array('node' => $featureTree->root));
334
    $out .= '</ul>';
335
  }
336
  return $out;
337
}
338

    
339
/**
340
 * @todo Please document this function.
341
 * @see http://drupal.org/node/1354
342
 */
343
function theme_FeatureTree_hierarchy_children($variables) {
344

    
345
  $node = $variables['node'];
346
  $out = '';
347
  if (isset($node->children)) {
348

    
349
    foreach ($node->children as $childNode) {
350
      $out .= '<li>' . check_plain($childNode->feature->representation_L10n);
351
      if (isset($childNode->children) && count($childNode->children) > 0) {
352
        $out .= '<ul>' . theme('FeatureTree_hierarchy_children', array('node' => $childNode)) . '</ul>';
353
      }
354
      $out .= '</li>';
355
    }
356
  }
357
  return $out;
358
}
359

    
360
/**
361
 * Returns HTML for the texts in a description $elementArray.
362
 *
363
 * Joins the texts in $elementArray and encloses with a HTML tag.
364
 *
365
 * @param array $variables
366
 *   An associative array containing:
367
 *   - elementArray
368
 *   - feature: The feature to which the elements given in $elementArray are
369
 *     belonging to.
370
 *   - glue: Defaults to empty string.
371
 *   - sortArray: Whether to sort the $elementArray alphabetically.
372
 *   - enclosingHtml
373
 *
374
 * @ingroup themeable
375
 */
376
function theme_cdm_descriptionElementArray($variables) {
377
  $elementArray = $variables['elementArray'];
378

    
379
  $feature = $variables['feature'];
380
  $glue = $variables['glue'];
381
  $sortArray = $variables['sortArray'];
382
  $enclosingHtml = $variables['enclosingHtml'];
383
  $out = '<' . $enclosingHtml . ' class="description" id="' . $feature->representation_L10n . '">';
384

    
385
  if ($sortArray) {
386
    sort($elementArray);
387
  }
388

    
389
  $out .= join($elementArray, $glue);
390

    
391
  $out .= '</' . $enclosingHtml . '>';
392
  return $out;
393
}
394

    
395
/**
396
 * @todo Please document this function.
397
 * @see http://drupal.org/node/1354
398
 */
399
function theme_cdm_descriptionElement_CommonTaxonName($variables) {
400
  $element = $variables['element'];
401
  $out = '<span class="' . html_class_atttibute_ref($element) . '">' . $element->language->representation_L10n . ' (' . $element->area->titleCache . '): ' . $element->name . '</span>';
402
  return $out;
403
}
404

    
405
/**
406
* @todo Please document this function.
407
* @see http://drupal.org/node/1354
408
*/
409
function theme_cdm_descriptionElement_CategoricalData($variables) {
410
  $element = $variables['element'];
411

    
412
  $state_data_strings = array();
413
  if (isset($element->states)) {
414
    foreach ($element->states as $stateData) {
415

    
416
      $state  = NULL;
417

    
418
      if(isset($stateData->state)){
419
        $state = cdm_term_representation($stateData->state);
420
      }
421

    
422
      if (isset($stateData->modifyingText_L10n)) {
423
        $state = ' ' . $stateData->modifyingText_L10n;
424
      }
425

    
426
      $modifiers_strings = cdm_modifers_representations($stateData);
427

    
428
      $state_data_strings[] = $state . ($modifiers_strings ? ' ' . $modifiers_strings : '');
429

    
430
      // FIXME render sources
431

    
432
    }
433
  }
434
  $out = '<span class="' . html_class_atttibute_ref($element) . '">' . implode(', ', $state_data_strings) . '</span>';
435
  return $out;
436
}
437

    
438
function theme_cdm_descriptionElement_QuantitativeData($variables) {
439
  /*
440
   * - statisticalValues
441
   *   - value
442
   *   - modifiers
443
   *   - type
444
   * - unit->representation_L10n
445
   * - modifyingText
446
   * - modifiers
447
   * - sources
448
   */
449
  $element = $variables['element'];
450

    
451
  $out = '';
452

    
453
  $type_representation = NULL;
454
  $modifiers_strings = array();
455

    
456

    
457
  if (isset($element->statisticalValues)) {
458
    $value_array = array();
459
    foreach ($element->statisticalValues as $val) {
460
      if (isset($val->value)) {
461
        $value_array[] = $val->value;
462
      }
463
    }
464

    
465
    $out .= implode($value_array, ', ');
466
  }
467

    
468
  if (isset($element->unit)) {
469
    $out .= ' '. cdm_term_representation($element->unit);
470
  }
471

    
472
  if (isset($element->statisticalValues->modifyingText_L10n)) {
473
    $out .=  ' ' . $element->statisticalValues->modifyingText_L10n;
474
  }
475
  $modifers_string = cdm_modifers_representations($element->statisticalValues);
476
  $out .= ($modifers_string ? ' ' . cdm_modifers_representations($element->statisticalValues) : '');
477

    
478
  // FIXME render sources
479

    
480
  return $out;
481

    
482
}
483

    
484
/**
485
 * Returns HTML for citations textdata elements.
486
 *
487
 * TODO: assign a new name to the function? Because it is used for the citations
488
 * textdata elements and not for all text data description elements.
489
 *
490
 * @param array $variables
491
 *   An associative array containing:
492
 *   - element: The description element which contains the text information.
493
 *   - asListElement: A boolean which determines whether the citations should
494
 *     be rendered as a list or not.
495
 *   - feature_uuid
496
 *
497
 * @ingroup themeable
498
 */
499
function theme_cdm_descriptionElementTextData($variables) {
500

    
501
  $element = $variables['element'];
502
  $asListElement = $variables['asListElement'];
503
  $feature_uuid = $variables['feature_uuid'];
504

    
505
  $description = '';
506
  if (isset($element->multilanguageText_L10n->text)) {
507
    $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
508
  }
509
  $sourceRefs = '';
510
  $result = array();
511
  $out = '';
512
  $res_author = '';
513
  $res_date = '';
514
  if (isset($element->sources) && is_array($element->sources) && count($element->sources) > 0) {
515
    foreach ($element->sources as $source) {
516
      $referenceCitation = theme('cdm_OriginalSource', array('source' => $source));
517
      if ($description && strlen($description) > 0 && $referenceCitation) {
518
        $sourceRefs .= ' (' . $referenceCitation . ')';
519
      }
520
      elseif ($referenceCitation) {
521
        $sourceRefs = $referenceCitation;
522
      }
523

    
524
      if (strlen($sourceRefs) > 0) {
525
        $sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
526
      }
527
      $name_used_in_source_link_to_show = '';
528
      // Do a link to name page.
529
      if (isset($source->nameUsedInSource->uuid) && isset($source->nameUsedInSource->titleCache)) {
530
        $name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache, path_to_name($source->nameUsedInSource->uuid), array(
531
          'attributes' => array(),
532
          'absolute' => TRUE,
533
          'html' => TRUE,
534
        ));
535
      }
536
      // Show a text without link.
537
      elseif (isset($source->nameUsedInSource->originalNameString) && strlen($source->nameUsedInSource->originalNameString) > 0) {
538
        $name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
539
      }
540

    
541
      if ($asListElement) {
542

    
543
       $out = '<li class="descriptionText DescriptionElement">';
544
        // Adding ":" if necessary.
545
        if (!empty($name_used_in_source_link_to_show)) {
546
          if ( (!empty($description)|| !empty($sourceRefs)) && $feature_uuid != UUID_CHROMOSOMES_NUMBERS) {
547
            $out .= $name_used_in_source_link_to_show . ': ';
548
          } else {
549
            $out .= $name_used_in_source_link_to_show . ' ';
550
          }
551
        }
552
        $out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $element, 'footnote_list_key' => $feature_uuid)) . '</li>';
553
      }
554
      else {
555
        if ($name_used_in_source_link_to_show) {
556
          $name_used_in_source_link_to_show = ' (name in source: ' . $name_used_in_source_link_to_show . ')';
557
        }
558

    
559
        $out = '<span class="DescriptionElement DescriptionElement-' . $element->class . '">' . $description . $sourceRefs . $name_used_in_source_link_to_show . '</span>';
560
      }
561
    }
562
  }
563
  else {
564
    // If no sources, print the description.
565
    $out = $description;
566
  }
567
  return $out;
568
}
569

    
570
/**
571
 * @todo Please document this function.
572
 * @see http://drupal.org/node/1354
573
 */
574
function theme_cdm_common_names($variables) {
575
  $elements = $variables['elements'];
576
  $text_data_out = '';
577
  $common_name_out = '';
578
  $separator = ',';
579
  $textData_commonNames = array();
580

    
581
  if (is_array($elements)) {
582
    foreach ($elements as $element) {
583
      if ($element->class == 'CommonTaxonName') {
584
        // $key = '<b>' . $element->language->representation_L10n . '</b> (' .
585
        // $element->area->titleCache . ')';
586
        if (isset($element->language->representation_L10n)) {
587
          $key = '<b>' . $element->language->representation_L10n . '</b>';
588
          $key .= (isset($element->area->titleCache) && strlen($element->area->titleCache) > 0) ? ' (' . $element->area->titleCache . ')' : '';
589
          $common_names[$key][] = $element;
590
        }
591
        else {
592
          // @Comment WA: common name without a language, should this happen?
593
          // example: flore_gabon/cdm_dataportal/taxon/24f36d18-a6e8-4edb-93bf-4a30f3394bf5.
594
          // if(!isset($key)) { // Just to mimic same behaviour as in D5.
595
          $key = '';
596
          // }
597
          $common_names[$key][] = $element;
598
        }
599
      }
600
      elseif ($element->class == 'TextData') {
601
        // else if ($element->class == 'TextData' && $element->feature->uuid
602
        // == UUID_COMMON_NAME){
603
        $textData_commonNames[] = $element;
604
      }
605
    }
606
  }
607
  // Handling common names.
608
  if (isset($common_names) && count($common_names) > 0) {
609
    // Sorting the array based on the key (language, + area if set).
610
    // Comment @WA there are common names without a language, so this sorting
611
    // can give strange results.
612
    ksort($common_names);
613

    
614
    // Creating the output to be render by Drupal.
615
    foreach ($common_names as $key => $elements) {
616
      $rendered_element_list = '';
617
      foreach ($elements as $element) {
618
        $sourcesFootnoteKeyList = '';
619
        // Adding footnotes sources.
620
        foreach ($element->sources as $source) {
621
          if (_is_original_source_type($source)) {
622
            $_fkey = FootnoteManager::addNewFootnote(UUID_COMMON_NAME, theme('cdm_OriginalSource', array('source' => $source, 'doLink' => FALSE)));
623
            $sourcesFootnoteKeyList .= theme('cdm_footnote_key', array('footnoteKey' => $_fkey, 'separator' => ($sourcesFootnoteKeyList ? $separator : '')));
624
          }
625
        }
626
        if ($element->name) {
627
          $rendered_element_list .= '<span class="' . html_class_atttibute_ref($element) . '">' . (strlen($rendered_element_list) > 0 ? ', ' : '') . $element->name . $sourcesFootnoteKeyList . '</span>';
628
        }
629
      }
630
      if ($key) {
631
        $common_name_out .= (strlen($common_name_out) > 0 ? '; ' : '') . $key . ': ' . $rendered_element_list;
632
      }
633
      else {
634
        $common_name_out .= (strlen($common_name_out) > 0 ? '; ' : '') . $rendered_element_list;
635
      }
636
    }
637
  }
638
  // Handling commons names as text data.
639
  foreach ($textData_commonNames as $text_data_element) {
640
    $text_data_out .= theme('cdm_descriptionElementTextData', array(
641
      'element' => $text_data_element,
642
      'asListElement' => TRUE,
643
      'feature_uuid' => $text_data_element->feature->uuid,
644
    ));
645
  }
646

    
647
  $common_name_out = "<div class=common_names_as_common_names> $common_name_out </div>";
648
  $out_array[] = $text_data_out;
649
  $common_name_out_text_data = '<div class=common_names_as_text_data>' . theme('cdm_descriptionElementArray', array('elementArray' => $out_array, 'feature' => $element->feature)) . '</div>';
650

    
651
  return $common_name_out . $common_name_out_text_data;
652
  /*
653
  return $common_name_out . theme('cdm_descriptionElementArray', $out_array,
654
  $element->feature);
655
  return "<div class=common_names> $common_name_out
656
  $common_name_out_text_data";
657
  */
658
}
659

    
660
/**
661
 * Return HTML for a list of description elements.
662
 *
663
 * Usually these are of a specific feature type.
664
 *
665
 * @param array $variables
666
 *   An associative array containing:
667
 *   - array of descriptionElements which belong to the same feature.
668
 *     These descriptions elements of a Description must be ordered by the chosen feature tree by
669
 *     calling the function _mergeFeatureTreeDescriptions().
670
 *     @see _mergeFeatureTreeDescriptions()
671
 *   - featureUuid: currently unused, accoding code disabled
672
 *   - taxon_uuid: only used for ordered dditributions (will be removed!)
673
 *
674
 * @ingroup themeable
675
 */
676
function theme_cdm_descriptionElements($variables) {
677

    
678
  $descriptionElements = $variables['descriptionElements'];
679
  $featureUuid = $variables['featureUuid'];
680
  $taxon_uuid = $variables['taxon_uuid'];
681
  $outArray = array();
682

    
683
  /*
684
  $userDefined = mixed_variable_get(LAYOUT_SETTING_PREFIX . $featureUuid, FEATURE_TREE_LAYOUT_DEFAULTS);
685
  if(variable_get('distribution_sort',
686
      'NO_SORT') != 'NO_SORT'){
687
      $glue = '';
688
      $enclosingTag = 'dl';
689
      $entryEnclosingTag = NULL;
690
  } else if($userDefined &&
691
      $userDefined['enabled']){
692
    $glue = $userDefined['glue'];
693
    $enclosingTag =  $userDefined['enclosingTag'];
694
    $entryEnclosingTag = $userDefined['entryEnclosingTag'];
695
  } else { // TODO remove once  LAYOUT_SETTING_PREFIX-{uuid} setting are configured to work for all portals(selenium test still missing!!!)
696
    $glue = ''; $enclosingTag = 'ul';
697
    $entryEnclosingTag = NULL ;
698
  }
699
  */
700

    
701

    
702
  if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') {
703
    $glue = '';
704
    $enclosingTag = 'dl';
705
  }
706
  else {
707
    $glue = '';
708
    $enclosingTag = 'ul';
709
  }
710

    
711
  $sortOutArray = FALSE;
712
  $distributionElements = array();
713

    
714
  RenderHints::pushToRenderStack('cdm_descriptionElements');
715

    
716
  // Avoiding warning box in drupal for flora malesiana.
717
  if (is_array($descriptionElements)) {
718
    foreach ($descriptionElements as $descriptionElement) {
719

    
720
      // --- DISTRIBUTION ---- //
721
      if ($descriptionElement->feature->uuid == UUID_DISTRIBUTION) {
722
        if ($descriptionElement->class == 'Distribution' && is_object($descriptionElement->area)) {
723
          $sortKey = $descriptionElement->area->representation_L10n;
724
          $distributionElements[$sortKey] = $descriptionElement;
725
        }
726
        elseif ($descriptionElement->class == 'TextData') {
727
          $asListElement = FALSE;
728
          $repr = theme('cdm_descriptionElementTextData', array(
729
            'element' => $descriptionElement,
730
            'asListElement' => $asListElement,
731
            'feature_uuid' => $descriptionElement->feature->uuid,
732
          ));
733

    
734
          if (!array_search($repr, $outArray)) {
735
            $outArray[] = $repr;
736
            // TODO HINT: sorting in theme_cdm_descriptionElementArray will
737
            // not work since this array contains html attributes with uuids
738
            // !!!!
739
            $sortOutArray = TRUE;
740
            $glue = '<br/> ';
741
            $enclosingTag = 'p';
742
          }
743
        }
744
      }
745

    
746
      // --- IMAGE_SOURCES --- //
747
      elseif ($descriptionElement->feature->uuid == UUID_IMAGE_SOURCES) {
748
        $image_sources[] = $descriptionElement;
749
      }
750
      // --- USE TEXTDATA --- //
751
      elseif ($descriptionElement->feature->uuid == UUID_USE) {
752
        // Do nothing to avoid rendering.
753
      } else {
754
        /* decide based on the description element class
755
         *
756
         * TODO provide api_hook as extension point for this
757
         */
758
        switch ($descriptionElement->class) {
759
          case 'TextData':
760
            $asListElement = TRUE;
761
            $outArray[] = theme('cdm_descriptionElementTextData', array(
762
              'element' => $descriptionElement,
763
              'asListElement' => $asListElement,
764
              'feature_uuid' => $descriptionElement->feature->uuid,
765
            ));
766
            break;
767
          case 'CommonTaxonName':
768
            $outArray[] = theme('cdm_descriptionElement_CommonTaxonName', array('element' => $descriptionElement));
769
          break;
770
          case 'CategoricalData':
771
            $outArray[] = theme('cdm_descriptionElement_CategoricalData', array('element' => $descriptionElement));
772
            break;
773
          case 'QuantitativeData':
774
            $outArray[] = theme('cdm_descriptionElement_QuantitativeData', array('element' => $descriptionElement));
775
            break;
776
          case 'Uses':
777
          /* IGNORE Uses classes, these are handled completely in theme_cdm_UseDescription */
778
          break;
779
        default:
780
        $outArray[] = '<li>No method for rendering unknown description class: ' . $descriptionElement->class . '</li>';
781
      }
782
    }
783
    }
784
  }
785

    
786
  // If feature = NAME USAGE sort the list of sources.
787
  // This is ONLY for FLORA MALESIANA and FLORE d'AFRIQUE CENTRALE.
788
  if ($descriptionElement->feature->uuid == UUID_NAME_USAGE) {
789
    sort($outArray);
790
  }
791

    
792
  if (isset($image_sources)) {
793
    $outArray[] = theme('cdm_description_element_image_source', array('image_sources' => $image_sources, 'asListElement' => TRUE));
794
  }
795

    
796
  if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') {
797
    $outArray[] = theme('cdm_description_ordered_distributions', array('taxon_uuid' => $taxon_uuid, 'descriptionElements' => $distributionElements));
798
  }
799
  else {
800
    ksort($distributionElements);
801
    // TODO , $entryEnclosingTag);
802
    $outArray[] = theme('cdm_descriptionElementDistribution', array(
803
      'descriptionElements' => $distributionElements,
804
    ));
805
  }
806

    
807
  // Take the feature of the last $descriptionElement.
808
  $feature = $descriptionElement->feature;
809

    
810
  $out = theme('cdm_descriptionElementArray', array(
811
    'elementArray' => $outArray,
812
    'feature' => $feature,
813
    'glue' => $glue,
814
    'sortArray' => $sortOutArray,
815
    'enclosingHtml' => $enclosingTag,
816
  ));
817

    
818
  RenderHints::popFromRenderStack();
819
  return $out;
820
}
821

    
822
/**
823
 * @todo Please document this function.
824
 * @see http://drupal.org/node/1354
825
 */
826
function compare_image_sources($a, $b) {
827
  if ($a->multilanguageText_L10n->text == $b->multilanguageText_L10n->text) {
828
    return 0;
829
  }
830
  return ($a->multilanguageText_L10n->text < $b->multilanguageText_L10n->text) ? -1 : 1;
831
}
832

    
833
/**
834
 * @todo Please document this function.
835
 * @see http://drupal.org/node/1354
836
 */
837
function theme_cdm_description_element_image_source($variables) {
838
  $image_sources = $variables['image_sources'];
839
  $asListElement = $variables['asListElement'];
840
  $out = '';
841
  $separator = ',';
842
  RenderHints::pushToRenderStack('descriptionElementImageSource');
843
  RenderHints::setFootnoteListKey(UUID_IMAGE_SOURCES);
844

    
845
  // Sorting the image sources.
846
  usort($image_sources, "compare_image_sources");
847
  // Generate the footnotes.
848
  foreach ($image_sources as $image_source) {
849
    $footNoteKeys = cdm_annotations_as_footnotekeys($image_source);
850
    foreach ($image_source->sources as $source) {
851
      if (_is_original_source_type($source)) {
852
        $fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_OriginalSource', array(
853
          'source' => $source,
854
          'doLink' => FALSE,
855
        )));
856
        // Ensure uniqueness of the footnote keys.
857
        cdm_add_footnote_to_array($footNoteKeys, $fn_key);
858
      }
859
    }
860
    // Sort and render footnote keys.
861
    $footnoteKeyListStr = '';
862
    asort($footNoteKeys);
863
    foreach ($footNoteKeys as $footNoteKey) {
864
      $footnoteKeyListStr .= theme('cdm_footnote_key', array('footnoteKey' => $footNoteKey, 'separator' => ($footnoteKeyListStr ? $separator : '')));
865
    }
866
    // Return value!
867
    $out .= '<span class="descriptionElement descriptionElement-' . $image_source->uuid . '">' . $image_source->multilanguageText_L10n->text . $footnoteKeyListStr . '; </span>';
868
  }
869

    
870
  RenderHints::popFromRenderStack();
871
  return $out;
872
}
873

    
874
/**
875
 * @todo Please document this function.
876
 * @see http://drupal.org/node/1354
877
 */
878
function theme_cdm_descriptionElementDistribution($variables) {
879
  $descriptionElements = $variables['descriptionElements'];
880
  $enclosingTag = $variables['enclosingTag'];
881
  if (!$enclosingTag) {
882
    $enclosingTag = "span";
883
  }
884

    
885
  $out = '';
886
  $separator = ',';
887
  RenderHints::pushToRenderStack('descriptionElementDistribution');
888
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
889

    
890
  foreach ($descriptionElements as $descriptionElement) {
891

    
892
    // Annotations as footnotes.
893
    $footNoteKeys = cdm_annotations_as_footnotekeys($descriptionElement);
894
    // Source references as footnotes.
895
    foreach ($descriptionElement->sources as $source) {
896
      if (_is_original_source_type($source)) {
897
        $fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_OriginalSource', array(
898
          'source' => $source,
899
          'doLink' => FALSE,
900
        )));
901
        // Ensure uniqueness of the footnote keys.
902
        cdm_add_footnote_to_array($footNoteKeys, $fn_key);
903
      }
904
    }
905
    // Sort and render footnote keys.
906
    $footnoteKeyListStr = '';
907
    asort($footNoteKeys);
908
    foreach ($footNoteKeys as $footNoteKey) {
909
      $footnoteKeyListStr .= theme('cdm_footnote_key', array('footnoteKey' => $footNoteKey, 'separator' => ($footnoteKeyListStr ? $separator : '')));
910
    }
911

    
912
    $out .= '<' . $enclosingTag . ' class="descriptionElement descriptionElement-' . $descriptionElement->uuid . '">' . $descriptionElement->area->representation_L10n . $footnoteKeyListStr . ' </' . $enclosingTag . '>';
913
  }
914

    
915
  RenderHints::popFromRenderStack();
916
  return $out;
917
}
918

    
919
/**
920
 * Compare two different footnotes objects.
921
 *
922
 * The comparison is based on the footnote key. The one which is
923
 * displayed as footnote number.
924
 *
925
 * @param mixed $a
926
 *   Footnote object $a.
927
 * @param mixed $b
928
 *   Footnote object $b.
929
 */
930
function footnotes_key_compare($a, $b) {
931
  $res = 0;
932
  if (empty($a) || empty($b)) {
933
    return $res;
934
  }
935
  if ($a->keyStr < $b->keyStr) {
936
    $res = -1;
937
  }
938
  elseif ($a->keyStr > $b->keyStr) {
939
    $res = 1;
940
  }
941
  return $res;
942
}
943

    
944
/**
945
 * @todo Please document this function.
946
 * @see http://drupal.org/node/1354
947
 */
948
function theme_cdm_description_ordered_distributions($variables) {
949

    
950
  $taxon_uuid = $variables['taxon_uuid'];
951
  $descriptionElements = $variables['descriptionElements'];
952

    
953
  // Returning NULL if there are no description elements.
954
  if ($taxon_uuid == null || $descriptionElements == NULL) {
955
    return NULL;
956
  }
957

    
958
  // Initialization of some variables.
959
  $out = '';
960
  $separator = ',';
961
  RenderHints::pushToRenderStack('descriptionElementDistribution');
962
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
963

    
964
  // Getting all the taxon description for a given taxon.
965
  $markerTypesEmpty = array();
966
  // $markerTypesEmpty['markerTypes'] = 'af9860ff-08f5-4b4d-863c-49ae96985115';
967
  $markerTypesEmpty['markerTypes'] = '';
968
  $queryString = $markerTypesEmpty['markerTypes'] ? queryString($markerTypesEmpty) : '';
969

    
970
  $taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon_uuid, $queryString);
971
  foreach ($taxonDescriptions as $description) {
972
    $descriptions_uuids[] = $description->uuid;
973
  }
974

    
975
  // Getting the sortered distributions (omitting level ??).
976
  $request_params = array();
977
  $request_params['omitLevels'] = UUID_NAMEDAREALEVEL_TDWGLEVEL_2;
978
  $ordered_areas = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION_DISTRIBUTION_TREE, join(',', $descriptions_uuids), queryString($request_params));
979
  if (isset($ordered_areas->rootElement->children)) {
980
    $ordered_areas = $ordered_areas->rootElement->children;
981
  }
982

    
983
  // Printing the distributions.
984
  if (is_array($ordered_areas) && count($ordered_areas) > 0) {
985
    foreach ($ordered_areas as $element_level1) {
986
      // Level1.
987
      if ($element_level1->data) {
988
        $out .= '<dt>' . $element_level1->data->area->representation_L10n . ':</dt> ';
989
      }
990
      $out .= '<dd>';
991

    
992
      // Level3.
993
      foreach ($element_level1->children as $element_level3) {
994
        if ($element_level3->data) {
995
          $text_l3 = $element_level3->data->area->representation_L10n;
996
        }
997
        $fnKeysLevel3Str = '';
998
        $fnKeysLevel3 = cdm_annotations_as_footnotekeys($element_level3->data);
999
        foreach ($element_level3->data->sources as $source) {
1000
          if (_is_original_source_type($source)) {
1001
            $fn_key3 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_OriginalSource', array('source' => $source, 'doLink' => FALSE)));
1002
            cdm_add_footnote_to_array($fnKeysLevel3, $fn_key3);
1003
          }
1004
        }
1005
        // Level4.
1006
        $l4_regions = array();
1007
        foreach ($element_level3->children as $element_level4) {
1008
          if ($element_level4->data) {
1009
            $text_l4 = $element_level4->data->area->representation_L10n;
1010
            $l4_regions[$element_level3->data->area->representation_L10n] = '';
1011
            $fnKeysLevel4Str = '';
1012
            $fnKeysLevel4 = cdm_annotations_as_footnotekeys($element_level4->data);
1013
            foreach ($element_level4->data->sources as $source) {
1014
              if (_is_original_source_type($source)) {
1015
                $fn_key4 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_OriginalSource', array('source' => $source, 'doLink' => FALSE)));
1016
                cdm_add_footnote_to_array($fnKeysLevel4, $fn_key4);
1017
              }
1018
            }
1019
            usort($fnKeysLevel4, "footnotes_key_compare");
1020
            $l4_regions[$text_l4] = $fnKeysLevel4;
1021
          }
1022
        }// Level4.
1023
        // Managing level3 and level4 for generating the right output.
1024
        usort($fnKeysLevel3, "footnotes_key_compare");
1025
        foreach ($fnKeysLevel3 as $key3) {
1026
          foreach ($l4_regions as $key4 => $value4) {
1027
            cdm_add_footnote_to_array($l4_regions[$key4], $key3);
1028
          }
1029
        }
1030
        if ($element_level3->numberOfChildren == 1 && $text_l3 == $element_level3->children[0]->data->area->representation_L10n) {
1031
          // var_dump($element_level3->children[0]->data->area->representation_L10n);
1032
          $fnStr = '';
1033
          $region = array_pop($l4_regions);
1034
          foreach ($region as $key) {
1035
            $fnStr .= theme('cdm_footnote_key', array('footnoteKey' => $key, 'separator' => ($fnStr ? $separator : '')));
1036
          }
1037
          $out .= "$text_l3 $fnStr; ";
1038
          // Removing whitespaces when &fnStr is empty.
1039
          if (substr($out, -3) == ' ; ') {
1040
            $out = substr($out, 0, -3) . '; ';
1041
          }
1042
        }
1043
        else {
1044
          $fnKeysLevel3Str = '';
1045
          foreach ($fnKeysLevel3 as $key) {
1046
            $fnKeysLevel3Str .= theme('cdm_footnote_key', array('footnoteKey' => $key, 'separator' => ($fnKeysLevel3Str ? $separator : '')));
1047
          }
1048
          $text_l4_aux = '';
1049
          foreach ($l4_regions as $key => $value) {
1050
            $fnKeysLevel4Str = '';
1051
            if (is_array($l4_regions[$key])) {
1052
              foreach ($l4_regions[$key] as $fnkey) {// Warning why?
1053
                $fnKeysLevel4Str .= theme('cdm_footnote_key', array('footnoteKey' => $fnkey, 'separator' => ($fnKeysLevel4Str ? $separator : '')));
1054
              }
1055
            }
1056
            // if ($key != $text_l3 || sizeof($l4_regions > 1)){
1057
            if ($key != $text_l3) {
1058
              $text_l4_aux .= "$key $fnKeysLevel4Str, ";
1059
            }
1060
          }
1061
          $text_l4_aux = substr($text_l4_aux, 0, -2);
1062

    
1063
          if (strlen($text_l4_aux) > 0) {
1064
            $out .= "$text_l3 $fnKeysLevel3Str ($text_l4_aux); ";
1065
          }
1066
          else {
1067
            $out .= "$text_l3 $fnKeysLevel3Str; ";
1068
          }
1069
        }
1070
      }// Level3.
1071
      $out = substr($out, 0, -2);
1072
      $out .= '.</dd>';
1073
    }// Level1.
1074
  }
1075
  RenderHints::popFromRenderStack();
1076
  return $out;
1077
}
1078

    
1079

    
1080
/*
1081
function theme_cdm_descriptionElementDistribution($descriptionElements){ $out
1082
  = ''; $separator = ',';
1083
  RenderHints::pushToRenderStack('descriptionElementDistribution');
1084
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
1085
  foreach($descriptionElements as $descriptionElement){ // annotations as
1086
  footnotes $annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys',
1087
  $descriptionElement); // source references as footnotes
1088
  $sourcesFootnoteKeyList = ''; foreach($descriptionElement->sources as
1089
  $source){ if(_is_original_source_type($source)){ $_fkey =
1090
  FootnoteManager::addNewFootnote(UUID_DISTRIBUTION,
1091
  theme('cdm_OriginalSource', $source, FALSE));
1092
  $sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey,
1093
  UUID_DISTRIBUTION, ($sourcesFootnoteKeyList ? $separator : '')); } }
1094
  if($annotationFootnoteKeys && $sourcesFootnoteKeyList){
1095
  $annotationFootnoteKeys .= $separator; } $out .=
1096
  $descriptionElement->area->representation_L10n . $annotationFootnoteKeys .
1097
  $sourcesFootnoteKeyList . ' '; } $out = substr($out, 0,
1098
  strlen($out)-strlen($separator) ); RenderHints::popFromRenderStack(); return
1099
  $out; }
1100
*/
1101

    
1102
/**
1103
 * TODO
1104
 * Quick-and-dirty solution to show distribution service to exemplar groups.
1105
 */
1106
function theme_cdm_distribution_map($variables) {
1107
  $taxon = $variables['taxon'];
1108
  $out = '';
1109
  $settings = get_edit_map_service_settings();
1110

    
1111
  $fontStyles = array(
1112
    0 => "plane",
1113
    1 => "italic",
1114
  );
1115

    
1116
  // Query cdm server for map service uri parameters.
1117
  $map_data_parameters = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
1118
  $out .= "<!-- map_data_parameters:" . print_r($map_data_parameters, TRUE) . " -->";
1119
  $query_string = $map_data_parameters->String;
1120
  if (!$query_string) {
1121
    // The $query_string is empty if there are no distribution areas defined.
1122
    return;
1123
  }
1124

    
1125
  // Some cleaning of the URI paramters, TODO is this still needed?
1126
  $query_string = str_replace('%3A', ":", $query_string);
1127

    
1128
  /* ------ choose the display mode, either openlayers or static image ------ */
1129
  if (variable_get('cdm_dataportal_map_openlayers', 1)) {
1130

    
1131
    /* =========== display distributions using the openlayers map viewer =========== */
1132
    $legend_url_font_size = variable_get('cdm_dataportal_geoservice_legend_font_size', 10);
1133
    $legend_url_font_style = variable_get('cdm_dataportal_geoservice_legend_font_style', 1);
1134
    $legend_url_font_style = $fontStyles[$legend_url_font_style];
1135
    $legend_url_icon_width = variable_get('cdm_dataportal_geoservice_legend_icon_width', 35);
1136
    $legend_url_icon_height = variable_get('cdm_dataportal_geoservice_legend_icon_height', 15);
1137

    
1138
    $legendFormatQueryStr = "format=image" . urlencode('/') . "png&TRANSPARENT=TRUE";
1139
    $legendFormatQueryStr .= "&WIDTH=" . $legend_url_icon_width . "&HEIGHT=" . $legend_url_icon_height . "&";
1140
    // TODO why is the layer=topp:tdwg_level_4 parameter needed at all here??
1141
    $legendFormatQueryStr .= "layer=topp" . urlencode(':') . "tdwg_level_4&LEGEND_OPTIONS=forceLabels" . urlencode(':') . "on;fontStyle" . urlencode(':') . $legend_url_font_style . ";fontSize" . urlencode(':') . $legend_url_font_size . "&SLD=";
1142

    
1143
    $out .= get_openlayers_map(variable_get('cdm_dataportal_geoservice_display_width', 300), variable_get('cdm_dataportal_geoservice_bounding_box', FALSE), NULL, $query_string, $legendFormatQueryStr, variable_get('cdm_dataportal_geoservice_map_caption', ''));
1144
  }
1145
  else {
1146
    $legendFormatQueryStr = '';
1147
    return get_image_map(variable_get('cdm_dataportal_geoservice_display_width', 300), variable_get('cdm_dataportal_geoservice_bounding_box', FALSE), NULL, $query_string, $legendFormatQueryStr, variable_get('cdm_dataportal_geoservice_map_caption', ''));
1148

    
1149
    // Simple image.
1150
    $mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
1151

    
1152
    $query_string .= '&img=true';
1153
    $query_string .= '&legend=1&mlp=3' . $mapStaticCaption . '&recalculate=FALSE';
1154

    
1155
    $map_service_script_name = "areas.php";
1156

    
1157
    // Apply Plain Image map settings.
1158
    if (get_edit_map_service_version_number() >= 1.1) {
1159
      /*
1160
       * example : title=a:Naturalized++non-invasive
1161
       * &ad=cyprusdivs:bdcode:a:5&as=a:ff9900,,0.1,&l=tdwg4
1162
       * &ms=500&bbox=32,34,35,36&img=true&legend=1&mlp=3
1163
       * &mc_s=Georgia,15,blue&mc=&recalculate=FALSE
1164
       * http://edit.br.fgov.be/edit_wp5/v1/rest_gen.php?
1165
       * l=background_gis:b,cyprusdivs&ad=cyprusdivs%3Abdcode%3Aa%3A8%2C4
1166
       * &as=a%3A339966%2C%2C0.1%2C|b:0000ff,,
1167
       * &bbox=32%2C34%2C35%2C36&img=true&legend=1&mc=&mc_s=Georgia%2C15%2Cblue
1168
       * &mlp=3&ms=500&recalculate=FALSE&title=a%3Aindigenous
1169
       */
1170

    
1171
      $map_service_script_name = "rest_gen.php";
1172

    
1173
      $bgcolor_areaStyleId = "y";
1174
      $baselayer_areaStyleId = "z";
1175
      $bgcolor_layer = '';
1176
      $additional_area_styles = array();
1177

    
1178
      // Background color.
1179
      if (variable_get('map_bg_color', '')) {
1180
        $bgcolor_layer = "background_gis:" . $bgcolor_areaStyleId;
1181
        $additional_area_styles[] = $bgcolor_areaStyleId . ":" . variable_get('map_bg_color', '') . ",,";
1182
      }
1183

    
1184
      // TODO HACK to replace the default base layer which currently is tdwg4
1185
      // !!!
1186
      if (strpos($query_string, "?l=") !== FALSE) {
1187
        $layer_param_token = "?l=";
1188
      }
1189
      else {
1190
        $layer_param_token = "&l=";
1191
      }
1192
      if (strpos($query_string, "?as=") !== FALSE) {
1193
        $areystyle_param_token = "?as=";
1194
      }
1195
      else {
1196
        $areystyle_param_token = "&as=";
1197
      }
1198

    
1199
      if (variable_get('map_base_layer', '')) {
1200
        $query_string = str_replace($layer_param_token . "tdwg4", "$layer_param_token" . variable_get('map_base_layer', '') . ":" . $baselayer_areaStyleId, $query_string);
1201
      }
1202
      else {
1203
        $query_string = str_replace($layer_param_token . "tdwg4", $layer_param_token . "tdwg4:" . $baselayer_areaStyleId . ",", $query_string);
1204
      }
1205

    
1206
      if ($bgcolor_layer) {
1207
        $query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
1208
      }
1209

    
1210
      if (variable_get('map_base_layer_style', '')) {
1211
        $additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
1212
      }
1213

    
1214
      foreach ($additional_area_styles as $as) {
1215
        $query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
1216
      }
1217
    }
1218

    
1219
    $mapUri = url(get_edit_map_service_full_uri() . '/' . $map_service_script_name . '? '. $query_string);
1220
    $out .= '<img class="distribution_map" src="' . urlencode($mapUri) . '" alt="Distribution Map" />';
1221
  }
1222
  return $out;
1223
}
1224

    
1225
/**
1226
 * Returns a list of a specific type of IdentificationKeys.
1227
 *
1228
 * The list can be restricteded by a taxon.
1229
 *
1230
 * @param string $type
1231
 *   The simple name of the cdm class implementing the interface
1232
 *   IdentificationKey, valid values are:
1233
 *   PolytomousKey, MediaKey, MultiAccessKey.
1234
 * @param string $taxonUuid
1235
 *   If given this parameter restrict the listed keys to those which have
1236
 *   the taxon identified be this uuid in scope.
1237
 *
1238
 * @return array
1239
 *   List with identification keys.
1240
 */
1241
function _list_IdentificationKeys($type, $taxonUuid = NULL, $pageSize = NULL, $pageNumber = NULL) {
1242
  if (!$type) {
1243
    drupal_set_message(t('Type parameter is missing'), 'error');
1244
    return;
1245
  }
1246
  $cdm_ws_pasepath = NULL;
1247
  switch ($type) {
1248
    case "PolytomousKey":
1249
      $cdm_ws_pasepath = CDM_WS_POLYTOMOUSKEY;
1250
      break;
1251

    
1252
    case "MediaKey":
1253
      $cdm_ws_pasepath = CDM_WS_MEDIAKEY;
1254
      break;
1255

    
1256
    case "MultiAccessKey":
1257
      $cdm_ws_pasepath = CDM_WS_MULTIACCESSKEY;
1258
      break;
1259

    
1260
  }
1261

    
1262
  if (!$cdm_ws_pasepath) {
1263
    drupal_set_message(t('Type parameter is not valid: ') . $type, 'error');
1264
  }
1265

    
1266
  $queryParameters = '';
1267
  if (is_numeric($pageSize)) {
1268
    $queryParameters = "pageSize=" . $pageSize;
1269
  }
1270
  else {
1271
    $queryParameters = "pageSize=0";
1272
  }
1273

    
1274
  if (is_numeric($pageNumber)) {
1275
    $queryParameters = "pageNumber=" . $pageNumber;
1276
  }
1277
  else {
1278
    $queryParameters = "pageNumber=0";
1279
  }
1280
  $queryParameters = NULL;
1281
  if ($taxonUuid) {
1282
    $queryParameters = "findByTaxonomicScope=$taxonUuid";
1283
  }
1284
  $pager = cdm_ws_get($cdm_ws_pasepath, NULL, $queryParameters);
1285

    
1286
  if (!$pager || $pager->count == 0) {
1287
    return array();
1288
  }
1289
  return $pager->records;
1290
}
1291

    
1292
/**
1293
 * @todo Please document this function.
1294
 * @see http://drupal.org/node/1354
1295
 */
1296
function theme_cdm_IdentificationKey($variables) {
1297
  $out = '';
1298
  $identificationKey = $variables['identificationKey'];
1299
  $doLinkToKeyPage = $variables['doLinkToKeyPage'];
1300
  $showIdentificationKeyTitle = $variables['showIdentificationKeyTitle'];
1301
  $parentRenderPath = RenderHints::getRenderPath();
1302
  RenderHints::pushToRenderStack("IdentificationKey");
1303

    
1304
  if ($showIdentificationKeyTitle) {
1305
    if ($doLinkToKeyPage) {
1306
      $out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid));
1307
    }
1308
    else {
1309
      $out = $identificationKey->titleCache;
1310
    }
1311
  }
1312
  if (isset($identificationKey->sources) && is_array($identificationKey->sources)) {
1313
    // order and display sources.
1314
    $sources = oder_sources($identificationKey->sources, TRUE);
1315
    $out .= '<div class="sources">';
1316
    $out .=  implode('', $sources);
1317
    $out .= '</div>';
1318
  }
1319
  // Display annotations.
1320
  $out .= theme('cdm_annotations', array('annotations' => cdm_ws_getAnnotationsFor($identificationKey), 'enclosingTag' => 'div'));
1321
  RenderHints::popFromRenderStack();
1322
  return $out;
1323
}
1324

    
1325
/**
1326
 * @todo Please document this function.
1327
 * @see http://drupal.org/node/1354
1328
 */
1329
function theme_cdm_polytomousKey($variables) {
1330
  $polytomousKey = $variables['polytomousKey'];
1331

    
1332
  // TODO settings needed.
1333
  // @see http://en.wikipedia.org/wiki/Single_access_key#Presentation_styles
1334
  // @see http://dev.e-taxonomy.eu/trac/ticket/2152
1335
  $keyStyle = "linkedStyle";
1336

    
1337
  RenderHints::pushToRenderStack("polytomousKey");
1338
  // Key nodes in linked style.
1339
  $out = '<table class="polytomousKey polytomousKey_' . $keyStyle . '">';
1340
  $out .= theme('cdm_polytomousKey_' . $keyStyle . '_subgraph', array('polytomousKeyNode' => $polytomousKey->root));
1341
  $out .= '</table>';
1342
  RenderHints::popFromRenderStack();
1343
  return $out;
1344
}
1345

    
1346
/**
1347
 * @todo Please document this function.
1348
 * @see http://drupal.org/node/1354
1349
 */
1350
function theme_cdm_polytomousKey_linkedStyle_subgraph($variables) {
1351
  $polytomousKeyNode = $variables['polytomousKeyNode'];
1352
  static $statementCountCharacter = '\'';
1353
  $out = "";
1354

    
1355
  if (is_array($polytomousKeyNode->children)) {
1356
    $childIndex = 0;
1357

    
1358
    // Render edges of the current node.
1359
    foreach ($polytomousKeyNode->children as &$child) {
1360

    
1361
      if (!isset($child->statement) && isset($child->taxon->uuid)) {
1362
        // Skip node with empty statements (see below for explanation: "Special
1363
        // case").
1364
        // this skipping here happens always in the next deeper level of iteration
1365
        // the check below is node on the level above
1366
        continue;
1367
      }
1368

    
1369
      /*
1370
       * Special case: Child nodes with empty statements but taxa as leaf are to
1371
       * treated as if all those taxa where direct children of the source node.
1372
       */
1373
      $islinkToManyTaxa = !isset($child->children[0]->statement) && isset($child->children[0]->taxon->uuid);
1374
      $islinkToTaxon = isset($child->taxon->uuid);
1375
      $islinkToSubKey = isset($child->subkey->uuid);
1376
      $islinkToOtherNode = isset($child->otherNode);
1377
      // Either NULL or 0.
1378
      $islinkToNode = $child->nodeNumber && !$islinkToManyTaxa && !$islinkToOtherNode;
1379
      $hasQuestion = !empty($polytomousKeyNode->question->label_l10n);
1380
      $hasFeature = isset($polytomousKeyNode->feature);
1381

    
1382
      // $indentEdge = $hasQuestion && $childIndex > 0;
1383
      // Question.
1384
      if ($hasQuestion && $childIndex == 0) {
1385
        // Place question, as extra table row.
1386
        $out .= '<tr class="question new_section">';
1387
        $out .= '<td class="nodeNumber">' . uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber) . "</td>";
1388
        $out .= '<td class="question">' . $polytomousKeyNode->question->label_l10n . '</td>';
1389
        $out .= '</tr>';
1390
      }
1391

    
1392
      $out .= '<tr class="childCount_' . $childIndex . (!$hasQuestion && $childIndex == 0 ? ' new_section' : '') . '">';
1393

    
1394
      if ($hasQuestion) {
1395
        $out .= '<td class="nodeNumber"></td>';
1396
      }
1397
      else {
1398
        $out .= '<td class="nodeNumber">' . uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childIndex, $statementCountCharacter)) . "</td>";
1399
      }
1400

    
1401
      $out .= '<td ' . RenderHints::getHtmlElementID($child) . '  class="edge' . ($hasQuestion ? ' edge-indent' : '') . '">';
1402

    
1403
      // Feature.
1404
      if ($hasFeature) {
1405
        $out .= $polytomousKeyNode->feature->representation_L10n . ": ";
1406
      }
1407

    
1408
      // Statement.
1409
      $out .= $child->statement->label_l10n;
1410

    
1411
      // --- Links to nodes taxa and subkeys.
1412
      $out .= '<div class="nodeLink">';
1413

    
1414
      // Link to a PolytomousKeyNode.
1415
      if ($islinkToNode) {
1416
        $out .= '<div class="nodeLinkToNode">';
1417
        if (is_object($child->modifyingText)) {
1418
          $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $child->modifyingText));
1419
        }
1420
        $out .= l($child->nodeNumber, request_path(), array(
1421
          'attributes' => NULL,
1422
          'query' => NULL,
1423
          'fragment' => $child->uuid,
1424
        )) . '</div>';
1425
      }
1426

    
1427
      // Link to a PolytomousKeyNode.
1428
      if ($islinkToOtherNode) {
1429
        $out .= '<div class="nodeLinkToOtherNode">';
1430
        if (is_object($child->modifyingText)) {
1431
          $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $child->modifyingText));
1432
        }
1433
        $out .= l($child->otherNode->nodeNumber, $_REQUEST["q"], array(
1434
          'attributes' => NULL,
1435
          'query' => NULL,
1436
          'fragment' => $child->otherNode->uuid,
1437
        )) . '</div>';
1438
      }
1439

    
1440
      // Link to one or many taxa.
1441
      if ($islinkToTaxon || $islinkToManyTaxa) {
1442

    
1443
        if ($islinkToManyTaxa) {
1444
          $taxonChildren = $child->children;
1445
        }
1446
        else {
1447
          $taxonChildren = array(
1448
            $child,
1449
          );
1450
        }
1451

    
1452
        foreach ($taxonChildren as $taxonChild) {
1453
          // TODO many taxa $child->children->taxon.
1454
          $out .= '<div class="nodeLinkToTaxon">';
1455
          if (is_object($taxonChild->modifyingText)) {
1456
            $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $taxonChild->modifyingText));
1457
          }
1458
          $out .= theme("cdm_taxonName", array('taxonName' => $taxonChild->taxon->name, 'nameLink' => url(path_to_taxon($taxonChild->taxon->uuid))));
1459
          $out .= '</div>';
1460
        }
1461

    
1462
        // Link to a subkey.
1463
        if ($islinkToSubKey) {
1464
          $out .= '<div class="nodeLinkToSubkey">' . theme('cdm_IdentificationKey', array('identificationKey' => $child->subkey)) . '</div>';
1465
        }
1466
      }
1467

    
1468
      $out .= '</div>'; // End node link.
1469
      $out .= '</td>'; // End edge.
1470
      $out .= '</tr>';
1471

    
1472
      $childIndex++;
1473
    }
1474

    
1475
    // Recurse into child nodes.
1476
    foreach ($polytomousKeyNode->children as &$child) {
1477
      $out .= theme('cdm_polytomousKey_linkedStyle_subgraph', array('polytomousKeyNode' => $child));
1478
    }
1479
  }
1480

    
1481
  return $out;
1482
}
1483

    
1484
/**
1485
 * @todo Please document this function.
1486
 * @see http://drupal.org/node/1354
1487
 */
1488
function theme_cdm_poytomousKeyNode_modifyingText($variables) {
1489
  $out = '';
1490
  $modifyingText = $variables['modifyingText'];
1491
  if (is_object($modifyingText)) {
1492
    $i = 0;
1493
    foreach (get_object_vars($modifyingText) as $lang => $languageString) {
1494
      $out .= ($i++ > 0 ? ', ' : '') . '<span class="modifyingText">' . $languageString->text . '</span> ';
1495
    }
1496
  }
1497
  return $out;
1498
}
1499

    
1500
/**
1501
 * Returns HTML for a list of a specific type of IdentificationKeys.
1502
 *
1503
 * The list can be restricteded by a taxon.
1504
 *
1505
 * @param array $variables
1506
 *   An associative array containing:
1507
 *   - type: The simple name of the cdm class implementing the interface
1508
 *     IdentificationKey, valid values are:
1509
 *     PolytomousKey, MediaKey, MultiAccessKey
1510
 *   - taxonUuid: If given, this parameter restrict the listed keys to those
1511
 *     which have the taxon identified be this uuid in scope.
1512
 *
1513
 * @ingroup themeable
1514
 */
1515
function theme_cdm_list_IdentificationKeys($variables) {
1516
  $type = $variables['type'];
1517
  $taxonUuid = $variables['taxonUuid'];
1518
  $keyList = _list_IdentificationKeys($type, $taxonUuid);
1519
  if (!$keyList || count($keyList) == 0) {
1520
    return;
1521
  }
1522

    
1523
  RenderHints::pushToRenderStack('list_IdentificationKeys');
1524
  $out = '<ul>';
1525
  foreach ($keyList as $key) {
1526
    $out .= '<li>';
1527
    $out .= theme('cdm_IdentificationKey', array('identificationKey' => $key));
1528
    $out .= '</li>';
1529
  }
1530
  $out .= '</ul>';
1531
  $out .= theme("cdm_annotation_footnotes", array('footnoteListKey' => RenderHints::getRenderPath()));
1532
  RenderHints::popFromRenderStack();
1533

    
1534
  return $out;
1535
}
1536

    
1537
// @WA $pageSize is not used..
1538
// function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize =
1539
// null){
1540
/**
1541
 * @todo Please document this function.
1542
 * @see http://drupal.org/node/1354
1543
 */
1544
function theme_cdm_block_IdentificationKeys($variables) {
1545
  $taxonUuid = $variables['taxonUuid'];
1546
  static $types = array(
1547
    "PolytomousKey" => "Polytomous",
1548
    "MediaKey" => "Media",
1549
    "MultiAccessKey" => "Multiaccess",
1550
  );
1551
  RenderHints::pushToRenderStack('block_IdentificationKeys');
1552
  $out = '';
1553
  foreach ($types as $type => $label) {
1554
    $keylist = theme('cdm_list_IdentificationKeys', array('type' => $type, 'taxonUuid' => $taxonUuid));
1555
    if (!$keylist) {
1556
      continue;
1557
    }
1558
    $out .= '<div class="' . $type . '">';
1559
    $out .= '<h3>' . t($label) . "</h3>";
1560
    $out .= $keylist;
1561
    $out .= '</div>';
1562
  }
1563
  RenderHints::popFromRenderStack();
1564
  return $out;
1565
}
1566

    
1567
// This theming function formats the use description and use record list for
1568
// these descriptions.
1569
// Comment @WA: $pageSize and $pageNumber are not used.
1570
// function theme_cdm_UseDescription($descriptions = NULL, $taxonUuid = NULL,
1571
// $pageSize, $pageNumber) {
1572
/**
1573
 * @todo Please document this function.
1574
 * @see http://drupal.org/node/1354
1575
 */
1576
function theme_cdm_UseDescription($variables) {
1577
  $descriptions = $variables['description'];
1578
  $taxonUuid = $variables['taxonUuid'];
1579
  $out = '<div id="content"><ul id="Description" class ="description">';
1580
  if ($descriptions == NULL) {
1581
    return;
1582
  }
1583
  $descriptionSynonyms = '';
1584
  $descriptionOut = '';
1585
  $synonymOut = '';
1586
  $currentTaxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $taxonUuid);
1587

    
1588
  foreach ($descriptions as $description) {
1589
    $useSummary = '';
1590
    foreach ($description->elements as $element) {
1591

    
1592
      if ($element->feature->uuid == UUID_USE && !(strlen($useSummary) > 0)) {
1593
        $useSummary = $element->multilanguageText_L10n->text;
1594
      }
1595
    }
1596
    // uses will be ordered by source
1597
    foreach ($description->sources as $source) {
1598
      $is_about_current_taxon = FALSE;
1599
      $originalTaxonUsedInSource = NULL;
1600
      $originalTaxonPager = NULL;
1601
      if ($source->originalNameString) {
1602
        $request_params = array();
1603
        $request_params['query'] = $source->originalNameString;
1604
        $request_params['matchMode'] = "EXACT";
1605
        $originalTaxonPager = cdm_ws_get(CDM_WS_PORTAL_NAME_FINDBYNAME, NULL, queryString($request_params));
1606
        if ($originalTaxonPager->count > 0) {
1607
          $originalTaxonUsedInSource = $originalTaxonPager->records[0];
1608
        }
1609
        else {
1610
          $originalTaxonUsedInSource = $currentTaxon->name;
1611
        }
1612
      }
1613
      else {
1614
        $originalTaxonUsedInSource = $currentTaxon->name;
1615
      }
1616

    
1617
      $is_about_current_taxon = $currentTaxon->name->uuid == $originalTaxonUsedInSource->uuid;
1618

    
1619
      if (!$is_about_current_taxon) {
1620
        $descriptionOut .= '<li class="descriptionText DescriptionElement">';
1621
        $name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
1622
          'absolute' => TRUE,
1623
          'html' => TRUE,
1624
        ));
1625
        $descriptionOut .= $name_used_in_source_link_to_show_use . ': ';
1626
        $descriptionOut .= $useSummary;
1627
        foreach ($description->sources as $source) {
1628
          $descriptionOut .= " (" . theme('cdm_OriginalSource', array('source' => $source, 'doLink' => TRUE)) . ")";
1629
        }
1630
        $hasUseRecords = FALSE;
1631
        $descriptionUseRecordOut = '<div id=useRecords><table><th>Use Category</th><th>Use Sub Category</th><th>Plant Part</th><th>Human Group</th><th>Ethnic Group</th><th>Country</th>';
1632
        foreach ($description->elements as $descriptionElement) {
1633
          if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
1634
            $hasUseRecords = TRUE;
1635
            // FIXME localization hardcoded to English
1636
            $useRecordTags = explode(';', $descriptionElement->modifyingText->English->text);
1637
            $descriptionUseRecordOut .= '<tr>';
1638
            $descriptionUseRecordOut .= '<td>' . $useRecordTags[0] . '</td>' . '<td>' . $useRecordTags[1] . '</td>' . '<td>' . $useRecordTags[3] . '</td>' . '<td>' . $useRecordTags[4] . '</td>' . '<td>' . $useRecordTags[5] . '</td>' . '<td>' . $useRecordTags[2] . '</td>';
1639
            $descriptionUseRecordOut .= '</tr>';
1640
          }
1641
        }
1642
        $descriptionUseRecordOut .= '</table></div>';
1643
        if ($hasUseRecords) {
1644
          $descriptionOut .= $descriptionUseRecordOut . '</li>';
1645
        }
1646
      }
1647
      else {
1648
        // TODO +/- duplicate of above, unify this code
1649
        $synonymOut .= '<li class="descriptionText DescriptionElement">';
1650
        $name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
1651
          'absolute' => TRUE,
1652
          'html' => TRUE,
1653
        ));
1654

    
1655
        $synonymOut .= $name_used_in_source_link_to_show_use . ': ';
1656
        $synonymOut .= $useSummary;
1657
        foreach ($description->sources as $source) {
1658
          $synonymOut .= " (" . theme('cdm_OriginalSource', array('source' => $source, 'doLink' => TRUE)) . ")";
1659
        }
1660

    
1661
        $hasUseRecords = FALSE;
1662
        $useRecordTableOut = '<div id=useRecords><table><th>Use Category</th><th>Use Sub Category</th><th>Plant Part</th><th>Human Group</th><th>Ethnic Group</th><th>Country</th>';
1663
        foreach ($description->elements as $descriptionElement) {
1664
          if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
1665
            $hasUseRecords = TRUE;
1666
            $useRecordTags = explode(';', $descriptionElement->modifyingText->English->text);
1667
            $useRecordTableOut .= '<tr>';
1668
            $useRecordTableOut .= '<td>' . $useRecordTags[0] . '</td>' . '<td>' . $useRecordTags[1] . '</td>' . '<td>' . $useRecordTags[3] . '</td>' . '<td>' . $useRecordTags[4] . '</td>' . '<td>' . $useRecordTags[5] . '</td>' . '<td>' . $useRecordTags[2] . '</td>';
1669
            $useRecordTableOut .= '</tr>';
1670
          }
1671
        }
1672
        $useRecordTableOut .= '</table></div>';
1673
        if ($hasUseRecords) {
1674
          $synonymOut .= $useRecordTableOut . '</li>';
1675
        }
1676
      }
1677

    
1678
      // }
1679
    }
1680
  }
1681
  $out .= $descriptionOut . $synonymOut;
1682
  $out .= "</ul></div>";
1683
  return $out;
1684
}
1685

    
1686
// The Uses theming function here will handle the display of the
1687
// Uses Descriptions.
1688
// Comment @WA: $pageSize is not used.
1689
// function theme_cdm_block_Uses ($taxonUuid = NULL, $pageSize = NULL {
1690
/**
1691
 * @todo Please document this function.
1692
 * @see http://drupal.org/node/1354
1693
 */
1694
function theme_cdm_block_Uses($variables) {
1695
  $taxonUuid = $variables['taxonUuid'];
1696
  RenderHints::pushToRenderStack('block_Uses');
1697

    
1698
  if ($taxonUuid == NULL) {
1699
    return;
1700
  }
1701
  $out = '';
1702
  $markerTypes = array();
1703
  $markerTypes['markerTypes'] = UUID_MARKERTYPE_USE;
1704
  $useDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxonUuid, queryString($markerTypes));
1705
  if (!empty($useDescriptions)) {
1706
    // FIXME use theme_block instaed of hardcoding the block html here !!!!
1707
    $out .= '<div id="block-cdm_dataportal-feature-description" class="clear-block block block-cdm_dataportal-feature"><H2><a name="userecords"> </a> Uses </H2>';
1708
    $formatUseDescriptions = theme('cdm_UseDescription', array('description' => $useDescriptions, 'taxonUuid' => $taxonUuid));
1709

    
1710
    $out .= $formatUseDescriptions;
1711
    $out .= "</div>";
1712
  }
1713

    
1714
  return $out;
1715
}
(3-3/10)