Project

General

Profile

Download (60.4 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
 * @todo Please document this function.
44
 * @see http://drupal.org/node/1354
45
 */
46
function theme_cdm_feature_name($variables) {
47
  $feature_name = $variables['feature_name'];
48
  // TODO replace by using translations ?
49
  return t(ucfirst($feature_name));
50
}
51

    
52
/**
53
 * Returns HTML for a taxon profile.
54
 *
55
 * The taxon profile consists of description elements which are ordered by the
56
 * structure defined by specific FeatureTree. The chosen FeatureTree is merged
57
 * with the list of desctiprion elements prior to using this method.
58
 *
59
 * @see cdm_ws_descriptions_by_featuretree()
60
 *
61
 * @param array $variables
62
 *   An associative array containing:
63
 *   - mergedTrees
64
 *   - taxon: The taxon whose sprofile to show.
65
 *
66
 * @ingroup themeable
67
 */
68
function theme_cdm_featureTrees($variables) {
69
  $mergedTrees = $variables['mergedTrees'];
70
  $taxon = $variables['taxon'];
71
  $out = '';
72
  if (!isset($mergedTrees)) {
73
    return;
74
  }
75

    
76
  foreach ($mergedTrees as &$mTree) {
77
    // TODO display title and reference in case of multiple $mergedTrees ->
78
    // theme
79
    $out .= theme('cdm_feature_nodes', array('mergedFeatureNodes' => $mTree->root->children, 'taxon' => $taxon));
80
  }
81

    
82
  return $out;
83
}
84

    
85
/**
86
 * @todo Please document this function.
87
 * @see http://drupal.org/node/1354
88
 */
89
function theme_cdm_featureTreeTOCs($variables) {
90
  $mergedTrees = $variables['mergedTrees'];
91
  if (!$mergedTrees) {
92
    return;
93
  }
94
  // FIXME.
95
  $out = '<div id="featureTOC">';
96
  $out .= '<h2>' . t('Content') . '</h2>';
97

    
98
  // TODO diplay title and reference in case of multiple $mergedTrees -> theme.
99
  foreach ($mergedTrees as &$mTree) {
100
    $out .= theme('cdm_feature_nodesTOC', array('featureNodes' => $mTree->root->children));
101
  }
102

    
103
  $out .= '</div>';
104
  return $out;
105
}
106

    
107
/**
108
 * Returns HTML for the $mergedFeatureNodes of a given $taxon.
109
 *
110
 * The merged nodes can be obtained by making use of the
111
 * function cdm_ws_descriptions_by_featuretree().
112
 *
113
 * @param array $variables
114
 *   An associative array containing:
115
 *   - mergedFeatureNodes
116
 *   -taxon
117
 *
118
 * @ingroup themeable
119
 */
120
function theme_cdm_feature_nodes($variables) {
121

    
122
  $mergedFeatureNodes = $variables['mergedFeatureNodes'];
123
  $taxon = $variables['taxon'];
124
  $out = '';
125

    
126
  RenderHints::pushToRenderStack('feature_nodes');
127
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME);
128

    
129
  // Creating an array to place the description elements in.
130
  $block = new stdclass(); // Empty object.
131
  foreach ($mergedFeatureNodes as $node) {
132

    
133
    if (hasFeatureNodeDescriptionElements($node)) {
134

    
135
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
136
      $block->module = 'cdm_dataportal';
137
      $media_list = array();
138

    
139
      if ($node->feature->uuid != UUID_IMAGE) {
140

    
141
        $block->delta = generalizeString($featureRepresentation);
142
        $block->subject = '<span class="' . html_class_atttibute_ref($node->feature) . '">' . theme('cdm_feature_name', array('feature_name' => $featureRepresentation)) . '</span>';
143
        $block->module = "cdm_dataportal-feature";
144
        $block->content = '';
145

    
146
        /*
147
        Content/DISTRIBUTION.
148
         */
149
        if ($node->feature->uuid == UUID_DISTRIBUTION) {
150

    
151
          if (variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
152
            $distributionTextDataList = array();
153
            $distributionElementsList = array();
154
            foreach ($node->descriptionElements as $descriptionElement) {
155
              if ($descriptionElement->class == "TextData") {
156
                $distributionTextDataList[] = $descriptionElement;
157
              }
158
              else {
159
                $distributionElementsList[] = $descriptionElement;
160
              }
161
            }
162
            if (count($distributionTextDataList) > 0) {
163
              $node->descriptionElements = $distributionElementsList;
164
              $block->content .= theme('cdm_descriptionElements', array(
165
                'descriptionElements' => $distributionTextDataList,
166
                'featureUuid' => $node->feature->uuid,
167
                'taxon_uuid' => $taxon->uuid,
168
              ));
169
            }
170
          }
171

    
172
          // Display cdm distribution map TODO this is a HACK to a proper
173
          // generic implementation?
174
          $block->content .= theme('cdm_distribution_map', array('taxon' => $taxon));
175
          $block->content .= theme('cdm_descriptionElements', array(
176
            'descriptionElements' => $node->descriptionElements,
177
            'featureUuid' => $node->feature->uuid,
178
            'taxon_uuid' => $taxon->uuid,
179
          ));
180
        }
181

    
182
        /*
183
        Content/COMMON_NAME.
184
        */
185
        elseif ($node->feature->uuid == UUID_COMMON_NAME) {
186
          // TODO why is theme_cdm_descriptionElement_CommonTaxonName not
187
          // beeing used???
188
         $block->content .= theme('cdm_common_names', array('elements' => $node->descriptionElements));
189
          /*
190
          }else if($node->feature->uuid == UUID_IMAGE_SOURCES) {
191
          $block->content .= theme('cdm_image_sources',
192
          $node->descriptionElements);
193
          */
194
        }
195

    
196
        /*
197
        Content/ALL OTHER FEATURES.
198
        */
199
        else {
200
          if (isset($node->descriptionElements)) {
201
            $block->content .= theme('cdm_descriptionElements', array(
202
              'descriptionElements' => $node->descriptionElements,
203
              'featureUuid' => $node->feature->uuid,
204
              'taxon_uuid' => $taxon->uuid,
205
            ));
206
          }
207
          /*
208
          Content/ALL OTHER FEATURES/Subordinate Features subordinate
209
          features are printed inline in one floating text, it is expected
210
          hat supordinate features only "contain" TextData elements
211
          */
212
          // TODO move into own theme.
213
          if (count($node->children) > 0) {
214

    
215
            // TODO support more than one level of children.
216
            // @see http://dev.e-taxonomy.eu/trac/ticket/2393
217
            $text = '';
218
            foreach ($node->children as $child) {
219

    
220
              if (isset($child->descriptionElements) && is_array($child->descriptionElements)) {
221
                foreach ($child->descriptionElements as $element) {
222

    
223
                  if (is_array($element->media)) {
224
                    // Append media of supordinate elements to list of main
225
                    // feature.
226
                    $media_list = array_merge($media_list, $element->media);
227
                  }
228

    
229
                  $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
230
                  // TODO use localized version of feature name, the locale
231
                  // must match the locale of the multilanguage text.
232
                  // @see http://dev.e-taxonomy.eu/trac/ticket/2394
233
                  $description = str_replace($element->feature->titleCache, '<em>' . $element->feature->titleCache . '</em>', $description);
234
                }
235
                $text .= " " . $description;
236
                $description = '';
237
              }
238
            }
239
            $block->content .= $text;
240
          }
241
        }
242

    
243
        /*
244
        Media/ALL FEATURES.
245
         */
246
        if (isset($node->descriptionElements)) {
247
          $media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
248
        }
249
        $captionElements = array('title', 'rights');
250
        $gallery = '';
251
        if (isset($gallery_settings['cdm_dataportal_media_maxextend']) && isset($gallery_settings['cdm_dataportal_media_maxRows']) && isset($gallery_settings['cdm_dataportal_media_cols'])) {
252
          $gallery = theme('cdm_media_gallerie', array(
253
            'mediaList' => $media_list,
254
            'galleryName' => CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME . '_' . $node->feature->uuid,
255
            'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
256
            'cols' => $gallery_settings['cdm_dataportal_media_cols'],
257
            'maxRows' => $gallery_settings['cdm_dataportal_media_maxRows'],
258
            'captionElements' => $captionElements,
259
          ));
260
        }
261
        $block->content .= $gallery;
262
        $block->content .= theme('cdm_footnotes', array('footnoteListKey' => $node->feature->uuid));
263
        $block->content .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $node->feature->uuid));
264

    
265
        // Add anchor to subject.
266
        $block->subject = '<a name="' . $block->delta . '"></a>' . $block->subject;
267

    
268
        // In D6: $out .= theme('block', $block);
269
        // Comment @WA @TODO check if need to set a region, and which one.
270
        $block->region = FALSE;
271
        $out .= theme('block', array('elements' => array(
272
          '#block' => $block,
273
          '#children' => $block->content,
274
        )));
275
      }
276
    }
277
  }
278
  RenderHints::popFromRenderStack();
279
  return $out;
280
}
281

    
282
/**
283
 * @todo Please document this function.
284
 * @see http://drupal.org/node/1354
285
 */
286
function theme_FeatureTree_hierarchy($variables) {
287

    
288
  $FeatureTreeUuid = $variables['FeatureTreeUuid'];
289
  if (!is_uuid($FeatureTreeUuid)) {
290
    return;
291
  }
292

    
293
  $out = '';
294
  $featureTree = cdm_ws_get(CDM_WS_FEATURETREE, array(
295
    $FeatureTreeUuid,
296
  ));
297

    
298
  if (isset($featureTree) && isset($featureTree->root)) {
299
    $out = '<ul class="' . $featureTree->class . '">';
300
    $out .= theme('FeatureTree_hierarchy_children', array('node' => $featureTree->root));
301
    $out .= '</ul>';
302
  }
303
  return $out;
304
}
305

    
306
/**
307
 * @todo Please document this function.
308
 * @see http://drupal.org/node/1354
309
 */
310
function theme_FeatureTree_hierarchy_children($variables) {
311

    
312
  $node = $variables['node'];
313
  $out = '';
314
  if (isset($node->children)) {
315

    
316
    foreach ($node->children as $childNode) {
317
      $out .= '<li>' . check_plain($childNode->feature->representation_L10n);
318
      if (isset($childNode->children) && count($childNode->children) > 0) {
319
        $out .= '<ul>' . theme('FeatureTree_hierarchy_children', array('node' => $childNode)) . '</ul>';
320
      }
321
      $out .= '</li>';
322
    }
323
  }
324
  return $out;
325
}
326

    
327
/**
328
 * Returns HTML for the texts in a description $elementArray.
329
 *
330
 * Joins the texts in $elementArray and encloses with a HTML tag.
331
 *
332
 * @param array $variables
333
 *   An associative array containing:
334
 *   - elementArray
335
 *   - feature: The feature to which the elements given in $elementArray are
336
 *     belonging to.
337
 *   - glue: Defaults to empty string.
338
 *   - sortArray: Whether to sort the $elementArray alphabetically.
339
 *   - enclosingHtml
340
 *
341
 * @ingroup themeable
342
 */
343
function theme_cdm_descriptionElementArray($variables) {
344
  $elementArray = $variables['elementArray'];
345

    
346
  $feature = $variables['feature'];
347
  $glue = $variables['glue'];
348
  $sortArray = $variables['sortArray'];
349
  $enclosingHtml = $variables['enclosingHtml'];
350
  $out = '<' . $enclosingHtml . ' class="description" id="' . $feature->representation_L10n . '">';
351

    
352
  if ($sortArray) {
353
    sort($elementArray);
354
  }
355

    
356
  $out .= join($elementArray, $glue);
357

    
358
  $out .= '</' . $enclosingHtml . '>';
359
  return $out;
360
}
361

    
362
/**
363
 * @todo Please document this function.
364
 * @see http://drupal.org/node/1354
365
 */
366
function theme_cdm_descriptionElement_CommonTaxonName($variables) {
367
  $element = $variables['element'];
368
  $out = '<span class="' . html_class_atttibute_ref($element) . '">' . $element->language->representation_L10n . ' (' . $element->area->titleCache . '): ' . $element->name . '</span>';
369
  return $out;
370
}
371

    
372
/**
373
* @todo Please document this function.
374
* @see http://drupal.org/node/1354
375
*/
376
function theme_cdm_descriptionElement_CategoricalData($variables) {
377
  $element = $variables['element'];
378
  $state_data_strings = array();
379
  if (isset($element->states)) {
380
    foreach ($element->states as $stateData) {
381
        $state = cdm_term_representation($stateData->state);
382

    
383
        $modifyingText = NULL;
384
        if (isset($stateData->modifyingText_L10n)) {
385
          $stateData->modifyingText_L10n;
386
        }
387

    
388
        $modifiers_strings = array();
389
        if (isset($stateData->modifiers)) {
390
          foreach ($stateData->modifiers as $modifier) {
391
            $modifiers_strings[] = cdm_term_representation($modifier);
392
          }
393
        }
394

    
395
        $state_data_strings[] = $state
396
          . ($modifyingText ? $modifyingText : '')
397
          . (count($modifiers_strings) > 0 ? implode(', ', $modifiers_strings): '');
398

    
399
    }
400
  }
401
  $out = '<span class="' . html_class_atttibute_ref($element) . '">' . implode(', ', $state_data_strings) . '</span>';
402
  return $out;
403
}
404

    
405
/**
406
 * Returns HTML for citations textdata elements.
407
 *
408
 * TODO: assign a new name to the function? Because it is used for the citations
409
 * textdata elements and not for all text data description elements.
410
 *
411
 * @param array $variables
412
 *   An associative array containing:
413
 *   - element: The description element which contains the text information.
414
 *   - asListElement: A boolean which determines whether the citations should
415
 *     be rendered as a list or not.
416
 *   - feature_uuid
417
 *
418
 * @ingroup themeable
419
 */
420
function theme_cdm_descriptionElementTextData($variables) {
421
  $element = $variables['element'];
422
  $asListElement = $variables['asListElement'];
423
  $feature_uuid = $variables['feature_uuid'];
424
  $description = '';
425
  if (isset($element->multilanguageText_L10n->text)) {
426
    $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
427
  }
428
  $sourceRefs = '';
429
  $result = array();
430
  $out = '';
431
  $res_author = '';
432
  $res_date = '';
433
  if (isset($element->sources) && is_array($element->sources) && count($element->sources) > 0) {
434
    foreach ($element->sources as $source) {
435
      $referenceCitation = theme('cdm_DescriptionElementSource', array('descriptionElementSource' => $source));
436
      if ($description && strlen($description) > 0 && $referenceCitation) {
437
        $sourceRefs .= ' (' . $referenceCitation . ')';
438
      }
439
      elseif ($referenceCitation) {
440
        $sourceRefs = $referenceCitation;
441
      }
442

    
443
      if (strlen($sourceRefs) > 0) {
444
        $sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
445
      }
446
      $name_used_in_source_link_to_show = '';
447
      // Do a link to name page.
448
      if (isset($source->nameUsedInSource->uuid) && isset($source->nameUsedInSource->titleCache)) {
449
        $name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache, path_to_name($source->nameUsedInSource->uuid), array(
450
          'attributes' => array(),
451
          'absolute' => TRUE,
452
          'html' => TRUE,
453
        ));
454
      }
455
      // Show a text without link.
456
      elseif (isset($source->nameUsedInSource->originalNameString) && strlen($source->nameUsedInSource->originalNameString) > 0) {
457
        $name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
458
      }
459

    
460
      if ($asListElement) {
461

    
462
        $out = '<li class="descriptionText DescriptionElement">' . $name_used_in_source_link_to_show;
463
        // Adding ":" if necessary.
464
        if ($name_used_in_source_link_to_show && ($description || $sourceRefs)) {
465
          $out .= ': ';
466
        }
467
        $out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $element, 'footnote_list_key' => $feature_uuid)) . '</li>';
468
      }
469
      else {
470
        if ($name_used_in_source_link_to_show) {
471
          $name_used_in_source_link_to_show = ' (name in source: ' . $name_used_in_source_link_to_show . ')';
472
        }
473

    
474
        $out = '<span class="DescriptionElement DescriptionElement-' . $element->class . '">' . $description . $sourceRefs . $name_used_in_source_link_to_show . '</span>';
475
      }
476
    }
477
  }
478
  else {
479
    // If no sources, print the description.
480
    $out = $description;
481
  }
482
  return $out;
483
}
484

    
485
/**
486
 * @todo Please document this function.
487
 * @see http://drupal.org/node/1354
488
 */
489
function theme_cdm_common_names($variables) {
490
  $elements = $variables['elements'];
491
  $text_data_out = '';
492
  $common_name_out = '';
493
  $separator = ',';
494
  $textData_commonNames = array();
495

    
496
  if (is_array($elements)) {
497
    foreach ($elements as $element) {
498
      if ($element->class == 'CommonTaxonName') {
499
        // $key = '<b>' . $element->language->representation_L10n . '</b> (' .
500
        // $element->area->titleCache . ')';
501
        if (isset($element->language->representation_L10n)) {
502
          $key = '<b>' . $element->language->representation_L10n . '</b>';
503
          $key .= (isset($element->area->titleCache) && strlen($element->area->titleCache) > 0) ? ' (' . $element->area->titleCache . ')' : '';
504
          $common_names[$key][] = $element;
505
        }
506
        else {
507
          // @Comment WA: common name without a language, should this happen?
508
          // example: flore_gabon/cdm_dataportal/taxon/24f36d18-a6e8-4edb-93bf-4a30f3394bf5.
509
          // if(!isset($key)) { // Just to mimic same behaviour as in D5.
510
          $key = '';
511
          // }
512
          $common_names[$key][] = $element;
513
        }
514
      }
515
      elseif ($element->class == 'TextData') {
516
        // else if ($element->class == 'TextData' && $element->feature->uuid
517
        // == UUID_COMMON_NAME){
518
        $textData_commonNames[] = $element;
519
      }
520
    }
521
  }
522
  // Handling common names.
523
  if (isset($common_names) && count($common_names) > 0) {
524
    // Sorting the array based on the key (language, + area if set).
525
    // Comment @WA there are common names without a language, so this sorting
526
    // can give strange results.
527
    ksort($common_names);
528

    
529
    // Creating the output to be render by Drupal.
530
    foreach ($common_names as $key => $elements) {
531
      $rendered_element_list = '';
532
      foreach ($elements as $element) {
533
        $sourcesFootnoteKeyList = '';
534
        // Adding footnotes sources.
535
        foreach ($element->sources as $source) {
536
          if (_is_original_source_type($source)) {
537
            $_fkey = FootnoteManager::addNewFootnote(UUID_COMMON_NAME, theme('cdm_DescriptionElementSource', array('descriptionElementSource' => $source, 'doLink' => FALSE)));
538
            $sourcesFootnoteKeyList .= theme('cdm_footnote_key', array('footnoteKey' => $_fkey, 'separator' => ($sourcesFootnoteKeyList ? $separator : '')));
539
          }
540
        }
541
        if ($element->name) {
542
          $rendered_element_list .= '<span class="' . html_class_atttibute_ref($element) . '">' . (strlen($rendered_element_list) > 0 ? ', ' : '') . $element->name . $sourcesFootnoteKeyList . '</span>';
543
        }
544
      }
545
      if ($key) {
546
        $common_name_out .= (strlen($common_name_out) > 0 ? '; ' : '') . $key . ': ' . $rendered_element_list;
547
      }
548
      else {
549
        $common_name_out .= (strlen($common_name_out) > 0 ? '; ' : '') . $rendered_element_list;
550
      }
551
    }
552
  }
553
  // Handling commons names as text data.
554
  foreach ($textData_commonNames as $text_data_element) {
555
    $text_data_out .= theme('cdm_descriptionElementTextData', array(
556
      'element' => $text_data_element,
557
      'asListElement' => TRUE,
558
      'feature_uuid' => $text_data_element->feature->uuid,
559
    ));
560
  }
561

    
562
  $common_name_out = "<div class=common_names_as_common_names> $common_name_out </div>";
563
  $out_array[] = $text_data_out;
564
  $common_name_out_text_data = '<div class=common_names_as_text_data>' . theme('cdm_descriptionElementArray', array('elementArray' => $out_array, 'feature' => $element->feature)) . '</div>';
565

    
566
  return $common_name_out . $common_name_out_text_data;
567
  /*
568
  return $common_name_out . theme('cdm_descriptionElementArray', $out_array,
569
  $element->feature);
570
  return "<div class=common_names> $common_name_out
571
  $common_name_out_text_data";
572
  */
573
}
574

    
575
/**
576
 * Return HTML for a list of description elements.
577
 *
578
 * Usually these are of a specific feature type.
579
 *
580
 * @param array $variables
581
 *   An associative array containing:
582
 *   - descriptionElements
583
 *   - featureUuid
584
 *   - taxon_uuid
585
 *
586
 * @ingroup themeable
587
 */
588
function theme_cdm_descriptionElements($variables) {
589
  $descriptionElements = $variables['descriptionElements'];
590
  $featureUuid = $variables['featureUuid'];
591
  $taxon_uuid = $variables['taxon_uuid'];
592
  $outArray = array();
593

    
594
  /*
595
  $userDefined = mixed_variable_get(LAYOUT_SETTING_PREFIX . $featureUuid,
596
  FEATURE_TREE_LAYOUT_DEFAULTS); if(variable_get('distribution_sort',
597
  'NO_SORT') != 'NO_SORT'){ $glue = ''; $enclosingTag = 'dl';
598
  $entryEnclosingTag = NULL; } else if($userDefined &&
599
  $userDefined['enabled']){ $glue = $userDefined['glue']; $enclosingTag =
600
  $userDefined['enclosingTag']; $entryEnclosingTag =
601
  $userDefined['entryEnclosingTag']; } else { // TODO remove once
602
  LAYOUT_SETTING_PREFIX-{uuid} seeting are confired to work for all portals
603
  (selenium test still missing!!!) $glue = ''; $enclosingTag = 'ul';
604
  $entryEnclosingTag = NULL ; }
605
  */
606

    
607
  if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') {
608
    $glue = '';
609
    $enclosingTag = 'dl';
610
  }
611
  else {
612
    $glue = '';
613
    $enclosingTag = 'ul';
614
  }
615

    
616
  $sortOutArray = FALSE;
617
  $distributionElements = array();
618

    
619
  RenderHints::pushToRenderStack('cdm_descriptionElements');
620

    
621
  // Avoiding warning box in drupal for flora malesiana.
622
  if (is_array($descriptionElements)) {
623
    foreach ($descriptionElements as $descriptionElement) {
624

    
625
      // --- DISTRIBUTION ---- //
626
      if ($descriptionElement->feature->uuid == UUID_DISTRIBUTION) {
627
        if ($descriptionElement->class == 'Distribution') {
628
          $sortKey = $descriptionElement->area->representation_L10n;
629
          $distributionElements[$sortKey] = $descriptionElement;
630
        }
631
        elseif ($descriptionElement->class == 'TextData') {
632
          $asListElement = FALSE;
633
          $repr = theme('cdm_descriptionElementTextData', array(
634
            'element' => $descriptionElement,
635
            'asListElement' => $asListElement,
636
            'feature_uuid' => $descriptionElement->feature->uuid,
637
          ));
638

    
639
          if (!array_search($repr, $outArray)) {
640
            $outArray[] = $repr;
641
            // TODO HINT: sorting in theme_cdm_descriptionElementArray will
642
            // not work since this array contains html attributes with uuids
643
            // !!!!
644
            $sortOutArray = TRUE;
645
            $glue = '<br/> ';
646
            $enclosingTag = 'p';
647
          }
648
        }
649
      }
650

    
651
      // --- IMAGE_SOURCES --- //
652
      elseif ($descriptionElement->feature->uuid == UUID_IMAGE_SOURCES) {
653
        $image_sources[] = $descriptionElement;
654
      }
655
      // --- USE TEXTDATA --- //
656
      elseif ($descriptionElement->feature->uuid == UUID_USE) {
657
        // Do nothing to avoid rendering.
658
      } else {
659
        /* decide based on the description element class
660
         *
661
         * TODO provide api_hook as extension point for this
662
         */
663
        switch ($descriptionElement->class) {
664
          case 'TextData':
665
            $asListElement = TRUE;
666
            $outArray[] = theme('cdm_descriptionElementTextData', array(
667
              'element' => $descriptionElement,
668
              'asListElement' => $asListElement,
669
              'feature_uuid' => $descriptionElement->feature->uuid,
670
            ));
671
            break;
672
          case 'CommonTaxonName':
673
            $outArray[] = theme('cdm_descriptionElement_CommonTaxonName', array('element' => $descriptionElement));
674
          break;
675
          case 'CategoricalData':
676
            $outArray[] = theme('cdm_descriptionElement_CategoricalData', array('element' => $descriptionElement));
677
            break;
678
        case 'Uses':
679
        	/* IGNORE Uses classes, these are handled completely in theme_cdm_UseDescription */
680
          break;
681
        default:
682
        $outArray[] = '<li>No method for rendering unknown description class: ' . $descriptionElement->class . '</li>';
683
      }
684
    }
685
    }
686
  }
687

    
688
  // If feature = NAME USAGE sort the list of sources.
689
  // This is ONLY for FLORA MALESIANA and FLORE d'AFRIQUE CENTRALE.
690
  if ($descriptionElement->feature->uuid == UUID_NAME_USAGE) {
691
    sort($outArray);
692
  }
693

    
694
  if (isset($image_sources)) {
695
    $outArray[] = theme('cdm_description_element_image_source', array('image_sources' => $image_sources, 'asListElement' => TRUE));
696
  }
697

    
698
  if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') {
699
    $outArray[] = theme('cdm_description_ordered_distributions', array('taxon_uuid' => $taxon_uuid, 'descriptionElements' => $distributionElements));
700
  }
701
  else {
702
    ksort($distributionElements);
703
    // TODO , $entryEnclosingTag);
704
    $outArray[] = theme('cdm_descriptionElementDistribution', array(
705
      'descriptionElements' => $distributionElements,
706
    ));
707
  }
708

    
709
  // Take the feature of the last $descriptionElement.
710
  $feature = $descriptionElement->feature;
711

    
712
  $out = theme('cdm_descriptionElementArray', array(
713
    'elementArray' => $outArray,
714
    'feature' => $feature,
715
    'glue' => $glue,
716
    'sortArray' => $sortOutArray,
717
    'enclosingHtml' => $enclosingTag,
718
  ));
719

    
720
  RenderHints::popFromRenderStack();
721
  return $out;
722
}
723

    
724
/**
725
 * @todo Please document this function.
726
 * @see http://drupal.org/node/1354
727
 */
728
function compare_image_sources($a, $b) {
729
  if ($a->multilanguageText_L10n->text == $b->multilanguageText_L10n->text) {
730
    return 0;
731
  }
732
  return ($a->multilanguageText_L10n->text < $b->multilanguageText_L10n->text) ? -1 : 1;
733
}
734

    
735
/**
736
 * @todo Please document this function.
737
 * @see http://drupal.org/node/1354
738
 */
739
function theme_cdm_description_element_image_source($variables) {
740
  $image_sources = $variables['image_sources'];
741
  $asListElement = $variables['asListElement'];
742
  $out = '';
743
  $separator = ',';
744
  RenderHints::pushToRenderStack('descriptionElementImageSource');
745
  RenderHints::setFootnoteListKey(UUID_IMAGE_SOURCES);
746

    
747
  // Sorting the image sources.
748
  usort($image_sources, "compare_image_sources");
749
  // Generate the footnotes.
750
  foreach ($image_sources as $image_source) {
751
    $footNoteKeys = cdm_annotations_as_footnotekeys($image_source);
752
    foreach ($image_source->sources as $source) {
753
      if (_is_original_source_type($source)) {
754
        $fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', array(
755
          'descriptionElementSource' => $source,
756
          'doLink' => FALSE,
757
        )));
758
        // Ensure uniqueness of the footnote keys.
759
        cdm_add_footnote_to_array($footNoteKeys, $fn_key);
760
      }
761
    }
762
    // Sort and render footnote keys.
763
    $footnoteKeyListStr = '';
764
    asort($footNoteKeys);
765
    foreach ($footNoteKeys as $footNoteKey) {
766
      $footnoteKeyListStr .= theme('cdm_footnote_key', array('footnoteKey' => $footNoteKey, 'separator' => ($footnoteKeyListStr ? $separator : '')));
767
    }
768
    // Return value!
769
    $out .= '<span class="descriptionElement descriptionElement-' . $image_source->uuid . '">' . $image_source->multilanguageText_L10n->text . $footnoteKeyListStr . '; </span>';
770
  }
771

    
772
  RenderHints::popFromRenderStack();
773
  return $out;
774
}
775

    
776
/**
777
 * @todo Please document this function.
778
 * @see http://drupal.org/node/1354
779
 */
780
function theme_cdm_descriptionElementDistribution($variables) {
781
  $descriptionElements = $variables['descriptionElements'];
782
  $enclosingTag = $variables['enclosingTag'];
783
  if (!$enclosingTag) {
784
    $enclosingTag = "span";
785
  }
786

    
787
  $out = '';
788
  $separator = ',';
789
  RenderHints::pushToRenderStack('descriptionElementDistribution');
790
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
791

    
792
  foreach ($descriptionElements as $descriptionElement) {
793

    
794
    // Annotations as footnotes.
795
    $footNoteKeys = cdm_annotations_as_footnotekeys($descriptionElement);
796
    // Source references as footnotes.
797
    foreach ($descriptionElement->sources as $source) {
798
      if (_is_original_source_type($source)) {
799
        $fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', array(
800
          'descriptionElementSource' => $source,
801
          'doLink' => FALSE,
802
        )));
803
        // Ensure uniqueness of the footnote keys.
804
        cdm_add_footnote_to_array($footNoteKeys, $fn_key);
805
      }
806
    }
807
    // Sort and render footnote keys.
808
    $footnoteKeyListStr = '';
809
    asort($footNoteKeys);
810
    foreach ($footNoteKeys as $footNoteKey) {
811
      $footnoteKeyListStr .= theme('cdm_footnote_key', array('footnoteKey' => $footNoteKey, 'separator' => ($footnoteKeyListStr ? $separator : '')));
812
    }
813

    
814
    $out .= '<' . $enclosingTag . ' class="descriptionElement descriptionElement-' . $descriptionElement->uuid . '">' . $descriptionElement->area->representation_L10n . $footnoteKeyListStr . ' </' . $enclosingTag . '>';
815
  }
816

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

    
821
/**
822
 * Compare two different footnotes objects.
823
 *
824
 * The comparison is based on the footnote key. The one which is
825
 * displayed as footnote number.
826
 *
827
 * @param mixed $a
828
 *   Footnote object $a.
829
 * @param mixed $b
830
 *   Footnote object $b.
831
 */
832
function footnotes_key_compare($a, $b) {
833
  $res = 0;
834
  if (empty($a) || empty($b)) {
835
    return $res;
836
  }
837
  if ($a->keyStr < $b->keyStr) {
838
    $res = -1;
839
  }
840
  elseif ($a->keyStr > $b->keyStr) {
841
    $res = 1;
842
  }
843
  return $res;
844
}
845

    
846
/**
847
 * @todo Please document this function.
848
 * @see http://drupal.org/node/1354
849
 */
850
function theme_cdm_description_ordered_distributions($variables) {
851
  $taxon_uuid = $variables['taxon_uuid'];
852
  $descriptionElements = $variables['descriptionElements'];
853
  // Returning NULL if there are no description elements.
854
  if ($descriptionElements == NULL) {
855
    return '';
856
  }
857
  // Initialization of some variables.
858
  $out = '';
859
  $separator = ',';
860
  RenderHints::pushToRenderStack('descriptionElementDistribution');
861
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
862
  // Getting all the taxon description for a given taxon.
863
  $markerTypesEmpty = array();
864
  // $markerTypesEmpty['markerTypes'] = 'af9860ff-08f5-4b4d-863c-49ae96985115';
865
  $markerTypesEmpty['markerTypes'] = '';
866
  $taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon_uuid, queryString($markerTypesEmpty));
867
  foreach ($taxonDescriptions as $description) {
868
    $descriptions_uuids[] = $description->uuid;
869
  }
870
  // Getting the sortered distributions (omitting level ??).
871
  $request_params = array();
872
  $request_params['omitLevels'] = UUID_NAMEDAREALEVEL_TDWGLEVEL_2;
873
  $ordered_areas = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION_DISTRIBUTION_TREE, join(',', $descriptions_uuids), queryString($request_params));
874
  if (isset($ordered_areas->rootElement->children)) {
875
    $ordered_areas = $ordered_areas->rootElement->children;
876
  }
877

    
878
  // Printing the distributions.
879
  if (is_array($ordered_areas) && count($ordered_areas) > 0) {
880
    foreach ($ordered_areas as $element_level1) {
881
      // Level1.
882
      if ($element_level1->data) {
883
        $out .= '<dt>' . $element_level1->data->area->representation_L10n . ':</dt> ';
884
      }
885
      $out .= '<dd>';
886

    
887
      // Level3.
888
      foreach ($element_level1->children as $element_level3) {
889
        if ($element_level3->data) {
890
          $text_l3 = $element_level3->data->area->representation_L10n;
891
        }
892
        $fnKeysLevel3Str = '';
893
        $fnKeysLevel3 = cdm_annotations_as_footnotekeys($element_level3->data);
894
        foreach ($element_level3->data->sources as $source) {
895
          if (_is_original_source_type($source)) {
896
            $fn_key3 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', array('descriptionElementSource' => $source, 'doLink' => FALSE)));
897
            cdm_add_footnote_to_array($fnKeysLevel3, $fn_key3);
898
          }
899
        }
900
        // Level4.
901
        $l4_regions = array();
902
        foreach ($element_level3->children as $element_level4) {
903
          if ($element_level4->data) {
904
            $text_l4 = $element_level4->data->area->representation_L10n;
905
            $l4_regions[$element_level3->data->area->representation_L10n] = '';
906
            $fnKeysLevel4Str = '';
907
            $fnKeysLevel4 = cdm_annotations_as_footnotekeys($element_level4->data);
908
            foreach ($element_level4->data->sources as $source) {
909
              if (_is_original_source_type($source)) {
910
                $fn_key4 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', array('descriptionElementSource' => $source, 'doLink' => FALSE)));
911
                cdm_add_footnote_to_array($fnKeysLevel4, $fn_key4);
912
              }
913
            }
914
            usort($fnKeysLevel4, "footnotes_key_compare");
915
            $l4_regions[$text_l4] = $fnKeysLevel4;
916
          }
917
        }// Level4.
918
        // Managing level3 and level4 for generating the right output.
919
        usort($fnKeysLevel3, "footnotes_key_compare");
920
        foreach ($fnKeysLevel3 as $key3) {
921
          foreach ($l4_regions as $key4 => $value4) {
922
            cdm_add_footnote_to_array($l4_regions[$key4], $key3);
923
          }
924
        }
925
        if ($element_level3->numberOfChildren == 1 && $text_l3 == $element_level3->children[0]->data->area->representation_L10n) {
926
          // var_dump($element_level3->children[0]->data->area->representation_L10n);
927
          $fnStr = '';
928
          $region = array_pop($l4_regions);
929
          foreach ($region as $key) {
930
            $fnStr .= theme('cdm_footnote_key', array('footnoteKey' => $key, 'separator' => ($fnStr ? $separator : '')));
931
          }
932
          $out .= "$text_l3 $fnStr; ";
933
          // Removing whitespaces when &fnStr is empty.
934
          if (substr($out, -3) == ' ; ') {
935
            $out = substr($out, 0, -3) . '; ';
936
          }
937
        }
938
        else {
939
          $fnKeysLevel3Str = '';
940
          foreach ($fnKeysLevel3 as $key) {
941
            $fnKeysLevel3Str .= theme('cdm_footnote_key', array('footnoteKey' => $key, 'separator' => ($fnKeysLevel3Str ? $separator : '')));
942
          }
943
          $text_l4_aux = '';
944
          foreach ($l4_regions as $key => $value) {
945
            $fnKeysLevel4Str = '';
946
            if (is_array($l4_regions[$key])) {
947
              foreach ($l4_regions[$key] as $fnkey) {// Warning why?
948
                $fnKeysLevel4Str .= theme('cdm_footnote_key', array('footnoteKey' => $fnkey, 'separator' => ($fnKeysLevel4Str ? $separator : '')));
949
              }
950
            }
951
            // if ($key != $text_l3 || sizeof($l4_regions > 1)){
952
            if ($key != $text_l3) {
953
              $text_l4_aux .= "$key $fnKeysLevel4Str, ";
954
            }
955
          }
956
          $text_l4_aux = substr($text_l4_aux, 0, -2);
957

    
958
          if (strlen($text_l4_aux) > 0) {
959
            $out .= "$text_l3 $fnKeysLevel3Str ($text_l4_aux); ";
960
          }
961
          else {
962
            $out .= "$text_l3 $fnKeysLevel3Str; ";
963
          }
964
        }
965
      }// Level3.
966
      $out = substr($out, 0, -2);
967
      $out .= '.</dd>';
968
    }// Level1.
969
  }
970
  RenderHints::popFromRenderStack();
971
  return $out;
972
}
973
/**
974
 * @todo Please document this function.
975
 * @see http://drupal.org/node/1354
976
 */
977
function theme_cdm_DescriptionElementSource($variables) {
978
  $out = '';
979
  $descriptionElementSource = $variables['descriptionElementSource'];
980
  $doLink = $variables['doLink'];
981
  if (isset($descriptionElementSource->citation)) {
982
    $out = theme('cdm_reference', array(
983
     'reference' => $descriptionElementSource->citation,
984
     'microReference' => $descriptionElementSource->citationMicroReference,
985
     'doLink' => $doLink,
986
    ));
987
  }
988
  return $out;
989
}
990
/**
991
 * @todo Please document this function.
992
 * @see http://drupal.org/node/1354
993
 */
994
function theme_cdm_IdentifieableSource($variables) {
995
  $out = '';
996
  $source = $variables['source'];
997
  $doLink = $variables['doLink'];
998
  if (isset($source->citation)) {
999
    $out = theme('cdm_reference', array(
1000
      'reference' => $source->citation,
1001
      'microReference' => $source->citationMicroReference,
1002
      'doLink' => $doLink,
1003
    ));
1004
  }
1005
  return $out;
1006
}
1007

    
1008
/*
1009
function theme_cdm_descriptionElementDistribution($descriptionElements){ $out
1010
  = ''; $separator = ',';
1011
  RenderHints::pushToRenderStack('descriptionElementDistribution');
1012
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
1013
  foreach($descriptionElements as $descriptionElement){ // annotations as
1014
  footnotes $annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys',
1015
  $descriptionElement); // source references as footnotes
1016
  $sourcesFootnoteKeyList = ''; foreach($descriptionElement->sources as
1017
  $source){ if(_is_original_source_type($source)){ $_fkey =
1018
  FootnoteManager::addNewFootnote(UUID_DISTRIBUTION,
1019
  theme('cdm_DescriptionElementSource', $source, FALSE));
1020
  $sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey,
1021
  UUID_DISTRIBUTION, ($sourcesFootnoteKeyList ? $separator : '')); } }
1022
  if($annotationFootnoteKeys && $sourcesFootnoteKeyList){
1023
  $annotationFootnoteKeys .= $separator; } $out .=
1024
  $descriptionElement->area->representation_L10n . $annotationFootnoteKeys .
1025
  $sourcesFootnoteKeyList . ' '; } $out = substr($out, 0,
1026
  strlen($out)-strlen($separator) ); RenderHints::popFromRenderStack(); return
1027
  $out; }
1028
*/
1029

    
1030
/**
1031
 * TODO
1032
 * Quick-and-dirty solution to show distribution service to exemplar groups.
1033
 */
1034
function theme_cdm_distribution_map($variables) {
1035
  $taxon = $variables['taxon'];
1036
  $out = '';
1037
  $server = getEDITMapServiceURI();
1038

    
1039
  if (!$server) {
1040
    // Warning message.
1041
    drupal_set_message(t("No 'Geoservice Access Point' has been set so far. Please configure the variable 'Geoservice Access Point' here ") . l(t('CDM Dataportal Settings'), 'admin/config/cdm_dataportal/geo'), 'warning');
1042
    // Message to render.
1043
    return "<p>No geoservice specified</p>";
1044
  }
1045

    
1046
  $fontStyles = array(
1047
    0 => "plane",
1048
    1 => "italic",
1049
  );
1050

    
1051
  // Query cdm server for map service uri parameters.
1052
  $map_data_parameters = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
1053
  $out .= "<!-- map_data_parameters:" . print_r($map_data_parameters, TRUE) . " -->";
1054
  $query_string = $map_data_parameters->String;
1055
  if (!$query_string) {
1056
    // The $query_string is empty if there are no distribution areas defined.
1057
    return;
1058
  }
1059

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

    
1063
  /* ------ choose the display mode, either openlayers or static image ------ */
1064
  if (variable_get('cdm_dataportal_map_openlayers', 1)) {
1065

    
1066
    /* =========== display distributions using the openlayers map viewer =========== */
1067
    $legend_url_font_size = variable_get('cdm_dataportal_geoservice_legend_font_size', 10);
1068
    $legend_url_font_style = variable_get('cdm_dataportal_geoservice_legend_font_style', 1);
1069
    $legend_url_font_style = $fontStyles[$legend_url_font_style];
1070
    $legend_url_icon_width = variable_get('cdm_dataportal_geoservice_legend_icon_width', 35);
1071
    $legend_url_icon_height = variable_get('cdm_dataportal_geoservice_legend_icon_height', 15);
1072

    
1073
    $legendFormatQueryStr = "format=image" . urlencode('/') . "png&TRANSPARENT=TRUE";
1074
    $legendFormatQueryStr .= "&WIDTH=" . $legend_url_icon_width . "&HEIGHT=" . $legend_url_icon_height . "&";
1075
    // TODO why is the layer=topp:tdwg_level_4 parameter neede at all here??
1076
    // Comment @WA $sldLegend is not used.
1077
    // $legendFormatQueryStr
1078
    // .="layer=topp".urlencode(':')."tdwg_level_4&LEGEND_OPTIONS=forceLabels".urlencode(':')."on;fontStyle".urlencode(':').$legend_url_font_style.";fontSize".urlencode(':').$legend_url_font_size."&SLD=".urlencode($sldLegend);
1079
    $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=";
1080

    
1081
    $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', ''));
1082
  }
1083
  else {
1084
    $legendFormatQueryStr = '';
1085
    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', ''));
1086

    
1087
    // Simple image.
1088
    $mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
1089

    
1090
    $query_string .= '&img=true';
1091
    $query_string .= '&legend=1&mlp=3' . $mapStaticCaption . '&recalculate=FALSE';
1092

    
1093
    $map_service_script_name = "areas.php";
1094

    
1095
    // Apply Plain Image map settings.
1096
    if (getEDITMapServiceVersionNumber() >= 1.1) {
1097
      /*
1098
       * example : title=a:Naturalized++non-invasive
1099
       * &ad=cyprusdivs:bdcode:a:5&as=a:ff9900,,0.1,&l=tdwg4
1100
       * &ms=500&bbox=32,34,35,36&img=true&legend=1&mlp=3
1101
       * &mc_s=Georgia,15,blue&mc=&recalculate=FALSE
1102
       * http://edit.br.fgov.be/edit_wp5/v1/rest_gen.php?
1103
       * l=background_gis:b,cyprusdivs&ad=cyprusdivs%3Abdcode%3Aa%3A8%2C4
1104
       * &as=a%3A339966%2C%2C0.1%2C|b:0000ff,,
1105
       * &bbox=32%2C34%2C35%2C36&img=true&legend=1&mc=&mc_s=Georgia%2C15%2Cblue
1106
       * &mlp=3&ms=500&recalculate=FALSE&title=a%3Aindigenous
1107
       */
1108

    
1109
      $map_service_script_name = "rest_gen.php";
1110

    
1111
      $bgcolor_areaStyleId = "y";
1112
      $baselayer_areaStyleId = "z";
1113
      $bgcolor_layer = '';
1114
      $additional_area_styles = array();
1115

    
1116
      // Background color.
1117
      if (variable_get('map_bg_color', '')) {
1118
        $bgcolor_layer = "background_gis:" . $bgcolor_areaStyleId;
1119
        $additional_area_styles[] = $bgcolor_areaStyleId . ":" . variable_get('map_bg_color', '') . ",,";
1120
      }
1121

    
1122
      // TODO HACK to replace the default base layer which currently is tdwg4
1123
      // !!!
1124
      if (strpos($query_string, "?l=") !== FALSE) {
1125
        $layer_param_token = "?l=";
1126
      }
1127
      else {
1128
        $layer_param_token = "&l=";
1129
      }
1130
      if (strpos($query_string, "?as=") !== FALSE) {
1131
        $areystyle_param_token = "?as=";
1132
      }
1133
      else {
1134
        $areystyle_param_token = "&as=";
1135
      }
1136

    
1137
      if (variable_get('map_base_layer', '')) {
1138
        $query_string = str_replace($layer_param_token . "tdwg4", "$layer_param_token" . variable_get('map_base_layer', '') . ":" . $baselayer_areaStyleId, $query_string);
1139
      }
1140
      else {
1141
        $query_string = str_replace($layer_param_token . "tdwg4", $layer_param_token . "tdwg4:" . $baselayer_areaStyleId . ",", $query_string);
1142
      }
1143

    
1144
      if ($bgcolor_layer) {
1145
        $query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
1146
      }
1147

    
1148
      if (variable_get('map_base_layer_style', '')) {
1149
        $additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
1150
      }
1151

    
1152
      foreach ($additional_area_styles as $as) {
1153
        $query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
1154
      }
1155
    }
1156

    
1157
    $mapUri = url("$server/$map_service_script_name?$query_string");
1158
    $out .= '<img class="distribution_map" src="' . $mapUri . '" alt="Distribution Map" />';
1159
  }
1160
  return $out;
1161
}
1162

    
1163
/**
1164
 * Returns a list of a specific type of IdentificationKeys.
1165
 *
1166
 * The list can be restricteded by a taxon.
1167
 *
1168
 * @param string $type
1169
 *   The simple name of the cdm class implementing the interface
1170
 *   IdentificationKey, valid values are:
1171
 *   PolytomousKey, MediaKey, MultiAccessKey.
1172
 * @param string $taxonUuid
1173
 *   If given this parameter restrict the listed keys to those which have
1174
 *   the taxon identified be this uuid in scope.
1175
 *
1176
 * @return array
1177
 *   List with identification keys.
1178
 */
1179
function _list_IdentificationKeys($type, $taxonUuid = NULL, $pageSize = NULL, $pageNumber = NULL) {
1180
  if (!$type) {
1181
    drupal_set_message(t('Type parameter is missing'), 'error');
1182
    return;
1183
  }
1184
  $cdm_ws_pasepath = NULL;
1185
  switch ($type) {
1186
    case "PolytomousKey":
1187
      $cdm_ws_pasepath = CDM_WS_POLYTOMOUSKEY;
1188
      break;
1189

    
1190
    case "MediaKey":
1191
      $cdm_ws_pasepath = CDM_WS_MEDIAKEY;
1192
      break;
1193

    
1194
    case "MultiAccessKey":
1195
      $cdm_ws_pasepath = CDM_WS_MULTIACCESSKEY;
1196
      break;
1197

    
1198
  }
1199

    
1200
  if (!$cdm_ws_pasepath) {
1201
    drupal_set_message(t('Type parameter is not valid: ') . $type, 'error');
1202
  }
1203

    
1204
  $queryParameters = '';
1205
  if (is_numeric($pageSize)) {
1206
    $queryParameters = "pageSize=" . $pageSize;
1207
  }
1208
  else {
1209
    $queryParameters = "pageSize=0";
1210
  }
1211

    
1212
  if (is_numeric($pageNumber)) {
1213
    $queryParameters = "pageNumber=" . $pageNumber;
1214
  }
1215
  else {
1216
    $queryParameters = "pageNumber=0";
1217
  }
1218
  $queryParameters = NULL;
1219
  if ($taxonUuid) {
1220
    $queryParameters = "findByTaxonomicScope=$taxonUuid";
1221
  }
1222
  $pager = cdm_ws_get($cdm_ws_pasepath, NULL, $queryParameters);
1223

    
1224
  if (!$pager || $pager->count == 0) {
1225
    return array();
1226
  }
1227
  return $pager->records;
1228
}
1229

    
1230
/**
1231
 * @todo Please document this function.
1232
 * @see http://drupal.org/node/1354
1233
 */
1234
function theme_cdm_IdentificationKey($variables) {
1235
  $out = '';
1236
  $identificationKey = $variables['identificationKey'];
1237
  $doLinkToKeyPage = $variables['doLinkToKeyPage'];
1238
  $showIdentificationKeyTitle = $variables['showIdentificationKeyTitle'];
1239
  $parentRenderPath = RenderHints::getRenderPath();
1240
  RenderHints::pushToRenderStack("IdentificationKey");
1241

    
1242
  if ($showIdentificationKeyTitle) {
1243
    if ($doLinkToKeyPage) {
1244
      $out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid));
1245
    }
1246
    else {
1247
      $out = $identificationKey->titleCache;
1248
    }
1249
  }
1250
  if (isset($identificationKey->sources) && is_array($identificationKey->sources)) {
1251
    // Display sources.
1252
    $i = 0;
1253
    $out .= '<div>';
1254
    foreach ($identificationKey->sources as $source) {
1255
      $out .= ($i++ > 0 ? ', ' : '') . theme("cdm_IdentifieableSource", array('source' => $source));
1256
    }
1257
    $out .= '</div>';
1258
  }
1259
  // Display annotations.
1260
  $out .= theme('cdm_annotations', array('annotations' => cdm_ws_getAnnotationsFor($identificationKey), 'enclosingTag' => 'div'));
1261
  RenderHints::popFromRenderStack();
1262
  return $out;
1263
}
1264

    
1265
/**
1266
 * @todo Please document this function.
1267
 * @see http://drupal.org/node/1354
1268
 */
1269
function theme_cdm_polytomousKey($variables) {
1270
  $polytomousKey = $variables['polytomousKey'];
1271

    
1272
  // TODO settings needed.
1273
  // @see http://en.wikipedia.org/wiki/Single_access_key#Presentation_styles
1274
  // @see http://dev.e-taxonomy.eu/trac/ticket/2152
1275
  $keyStyle = "linkedStyle";
1276

    
1277
  RenderHints::pushToRenderStack("polytomousKey");
1278
  // Key nodes in linked style.
1279
  $out = '<table class="polytomousKey polytomousKey_' . $keyStyle . '">';
1280
  $out .= theme('cdm_polytomousKey_' . $keyStyle . '_subgraph', array('polytomousKeyNode' => $polytomousKey->root));
1281
  $out .= '</table>';
1282
  RenderHints::popFromRenderStack();
1283
  return $out;
1284
}
1285

    
1286
/**
1287
 * @todo Please document this function.
1288
 * @see http://drupal.org/node/1354
1289
 */
1290
function theme_cdm_polytomousKey_linkedStyle_subgraph($variables) {
1291
  $polytomousKeyNode = $variables['polytomousKeyNode'];
1292
  static $statementCountCharacter = '\'';
1293
  $out = "";
1294

    
1295
  if (is_array($polytomousKeyNode->children)) {
1296
    $childIndex = 0;
1297

    
1298
    // Render edges of the current node.
1299
    foreach ($polytomousKeyNode->children as &$child) {
1300

    
1301
      if (!isset($child->statement) && isset($child->taxon->uuid)) {
1302
        // Skip node with empty statements (see below for explanation: "Special
1303
        // case").
1304
        // this skipping here happens always in the next deeper level of iteration
1305
        // the check below is node on the level above
1306
        continue;
1307
      }
1308

    
1309
      /*
1310
       * Special case: Child nodes with empty statements but taxa as leaf are to
1311
       * treated as if all those taxa where direct children of the source node.
1312
       */
1313
      $islinkToManyTaxa = !isset($child->children[0]->statement) && isset($child->children[0]->taxon->uuid);
1314
      $islinkToTaxon = isset($child->taxon->uuid);
1315
      $islinkToSubKey = isset($child->subkey->uuid);
1316
      $islinkToOtherNode = isset($child->otherNode);
1317
      // Either NULL or 0.
1318
      $islinkToNode = $child->nodeNumber && !$islinkToManyTaxa && !$islinkToOtherNode;
1319
      $hasQuestion = isset($polytomousKeyNode->question->label_l10n);
1320
      $hasFeature = isset($polytomousKeyNode->feature);
1321

    
1322
      // $indentEdge = $hasQuestion && $childIndex > 0;
1323
      // Question.
1324
      if ($hasQuestion && $childIndex == 0) {
1325
        // Place question, as extra table row.
1326
        $out .= '<tr class="question new_section">';
1327
        $out .= '<td class="nodeNumber">' . uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber) . "</td>";
1328
        $out .= '<td class="question">' . $polytomousKeyNode->question->label_l10n . '</td>';
1329
        $out .= '</tr>';
1330
      }
1331

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

    
1334
      if ($hasQuestion) {
1335
        $out .= '<td class="nodeNumber"></td>';
1336
      }
1337
      else {
1338
        $out .= '<td class="nodeNumber">' . uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childIndex, $statementCountCharacter)) . "</td>";
1339
      }
1340

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

    
1343
      // Feature.
1344
      if ($hasFeature) {
1345
        $out .= $polytomousKeyNode->feature->representation_L10n . ": ";
1346
      }
1347

    
1348
      // Statement.
1349
      $out .= $child->statement->label_l10n;
1350

    
1351
      // --- Links to nodes taxa and subkeys.
1352
      $out .= '<div class="nodeLink">';
1353

    
1354
      // Link to a PolytomousKeyNode.
1355
      if ($islinkToNode) {
1356
        $out .= '<div class="nodeLinkToNode">';
1357
        if (is_object($child->modifyingText)) {
1358
          $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $child->modifyingText));
1359
        }
1360
        $out .= l($child->nodeNumber, request_path(), array(
1361
          'attributes' => NULL,
1362
          'query' => NULL,
1363
          'fragment' => $child->uuid,
1364
        )) . '</div>';
1365
      }
1366

    
1367
      // Link to a PolytomousKeyNode.
1368
      if ($islinkToOtherNode) {
1369
        $out .= '<div class="nodeLinkToOtherNode">';
1370
        if (is_object($child->modifyingText)) {
1371
          $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $child->modifyingText));
1372
        }
1373
        $out .= l($child->otherNode->nodeNumber, $_REQUEST["q"], array(
1374
          'attributes' => NULL,
1375
          'query' => NULL,
1376
          'fragment' => $child->otherNode->uuid,
1377
        )) . '</div>';
1378
      }
1379

    
1380
      // Link to one or many taxa.
1381
      if ($islinkToTaxon || $islinkToManyTaxa) {
1382

    
1383
        if ($islinkToManyTaxa) {
1384
          $taxonChildren = $child->children;
1385
        }
1386
        else {
1387
          $taxonChildren = array(
1388
            $child,
1389
          );
1390
        }
1391

    
1392
        foreach ($taxonChildren as $taxonChild) {
1393
          // TODO many taxa $child->children->taxon.
1394
          $out .= '<div class="nodeLinkToTaxon">';
1395
          if (is_object($taxonChild->modifyingText)) {
1396
            $out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $taxonChild->modifyingText));
1397
          }
1398
          $out .= theme("cdm_taxonName", array('taxonName' => $taxonChild->taxon->name, 'nameLink' => url(path_to_taxon($taxonChild->taxon->uuid))));
1399
          $out .= '</div>';
1400
        }
1401

    
1402
        // Link to a subkey.
1403
        if ($islinkToSubKey) {
1404
          $out .= '<div class="nodeLinkToSubkey">' . theme('cdm_IdentificationKey', array('identificationKey' => $child->subkey)) . '</div>';
1405
        }
1406
      }
1407

    
1408
      $out .= '</div>'; // End node link.
1409
      $out .= '</td>'; // End edge.
1410
      $out .= '</tr>';
1411

    
1412
      $childIndex++;
1413
    }
1414

    
1415
    // Recurse into child nodes.
1416
    foreach ($polytomousKeyNode->children as &$child) {
1417
      $out .= theme('cdm_polytomousKey_linkedStyle_subgraph', array('polytomousKeyNode' => $child));
1418
    }
1419
  }
1420

    
1421
  return $out;
1422
}
1423

    
1424
/**
1425
 * @todo Please document this function.
1426
 * @see http://drupal.org/node/1354
1427
 */
1428
function theme_cdm_poytomousKeyNode_modifyingText($variables) {
1429
  $out = '';
1430
  $modifyingText = $variables['modifyingText'];
1431
  if (is_object($modifyingText)) {
1432
    $i = 0;
1433
    foreach (get_object_vars($modifyingText) as $lang => $languageString) {
1434
      $out .= ($i++ > 0 ? ', ' : '') . '<span class="modifyingText">' . $languageString->text . '</span> ';
1435
    }
1436
  }
1437
  return $out;
1438
}
1439

    
1440
/**
1441
 * Returns HTML for a list of a specific type of IdentificationKeys.
1442
 *
1443
 * The list can be restricteded by a taxon.
1444
 *
1445
 * @param array $variables
1446
 *   An associative array containing:
1447
 *   - type: The simple name of the cdm class implementing the interface
1448
 *     IdentificationKey, valid values are:
1449
 *     PolytomousKey, MediaKey, MultiAccessKey
1450
 *   - taxonUuid: If given, this parameter restrict the listed keys to those
1451
 *     which have the taxon identified be this uuid in scope.
1452
 *
1453
 * @ingroup themeable
1454
 */
1455
function theme_cdm_list_IdentificationKeys($variables) {
1456
  $type = $variables['type'];
1457
  $taxonUuid = $variables['taxonUuid'];
1458
  $keyList = _list_IdentificationKeys($type, $taxonUuid);
1459
  if (!$keyList || count($keyList) == 0) {
1460
    return;
1461
  }
1462

    
1463
  RenderHints::pushToRenderStack('list_IdentificationKeys');
1464
  $out = '<ul>';
1465
  foreach ($keyList as $key) {
1466
    $out .= '<li>';
1467
    $out .= theme('cdm_IdentificationKey', array('identificationKey' => $key));
1468
    $out .= '</li>';
1469
  }
1470
  $out .= '</ul>';
1471
  $out .= theme("cdm_annotation_footnotes", array('footnoteListKey' => RenderHints::getRenderPath()));
1472
  RenderHints::popFromRenderStack();
1473

    
1474
  return $out;
1475
}
1476

    
1477
// @WA $pageSize is not used..
1478
// function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize =
1479
// null){
1480
/**
1481
 * @todo Please document this function.
1482
 * @see http://drupal.org/node/1354
1483
 */
1484
function theme_cdm_block_IdentificationKeys($variables) {
1485
  $taxonUuid = $variables['taxonUuid'];
1486
  static $types = array(
1487
    "PolytomousKey" => "Polytomous",
1488
    "MediaKey" => "Media",
1489
    "MultiAccessKey" => "Multiaccess",
1490
  );
1491
  RenderHints::pushToRenderStack('block_IdentificationKeys');
1492
  $out = '';
1493
  foreach ($types as $type => $label) {
1494
    // @WA $pageNumber is not defined, $pageSize is not used in the theme
1495
    // function
1496
    // $keylist = theme('cdm_list_IdentificationKeys', $type, $taxonUuid,
1497
    // $pageSize, $pageNumber);
1498
    $keylist = theme('cdm_list_IdentificationKeys', array('type' => $type, 'taxonUuid' => $taxonUuid));
1499
    if (!$keylist) {
1500
      continue;
1501
    }
1502
    $out .= '<div class="' . $type . '">';
1503
    $out .= '<h3>' . t($label) . "</h3>";
1504
    $out .= $keylist;
1505
    $out .= '</div>';
1506
  }
1507
  RenderHints::popFromRenderStack();
1508
  return $out;
1509
}
1510

    
1511
// This theming function formats the use description and use record list for
1512
// these descriptions.
1513
// Comment @WA: $pageSize and $pageNumber are not used.
1514
// function theme_cdm_UseDescription($descriptions = NULL, $taxonUuid = NULL,
1515
// $pageSize, $pageNumber) {
1516
/**
1517
 * @todo Please document this function.
1518
 * @see http://drupal.org/node/1354
1519
 */
1520
function theme_cdm_UseDescription($variables) {
1521
  $descriptions = $variables['description'];
1522
  $taxonUuid = $variables['taxonUuid'];
1523
  $out = '<div id="content"><ul id="Description" class ="description">';
1524
  if ($descriptions == NULL) {
1525
    return;
1526
  }
1527
  $descriptionSynonyms = '';
1528
  $descriptionOut = '';
1529
  $synonymOut = '';
1530
  $currentTaxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $taxonUuid);
1531

    
1532
  foreach ($descriptions as $description) {
1533
    $useSummary = "";
1534
    // Comment @WA: $synonyms is not defined.
1535
    // $serializedSynonyms = serialize($synonyms).
1536
    foreach ($description->elements as $element) {
1537

    
1538
      if ($element->feature->uuid == UUID_USE && !(strlen($useSummary) > 0)) {
1539
        $useSummary = $element->multilanguageText_L10n->text;
1540
      }
1541
    }
1542
    foreach ($description->sources as $source) {
1543
      $isSynonym = FALSE;
1544
      $originalTaxonUsedInSource = NULL;
1545
      $originalTaxonPager = NULL;
1546
      if ($source->originalNameString) {
1547
        $request_params = array();
1548
        $request_params['query'] = $source->originalNameString;
1549
        $request_params['matchMode'] = "EXACT";
1550
        $originalTaxonPager = cdm_ws_get(CDM_WS_PORTAL_NAME_FINDBYNAME, NULL, queryString($request_params));
1551
        if ($originalTaxonPager->count > 0) {
1552
          $originalTaxonUsedInSource = $originalTaxonPager->records[0];
1553
        }
1554
        else {
1555
          $originalTaxonUsedInSource = $currentTaxon->name;
1556
        }
1557
      }
1558
      else {
1559
        $originalTaxonUsedInSource = $currentTaxon->name;
1560
      }
1561

    
1562
      if ($currentTaxon->name->uuid != $originalTaxonUsedInSource->uuid) {
1563
        $isSynonym = TRUE;
1564
      }
1565

    
1566
      if (!$isSynonym) {
1567
        $descriptionOut .= '<li class="descriptionText DescriptionElement">';
1568
        $name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
1569
          'absolute' => TRUE,
1570
          'html' => TRUE,
1571
        ));
1572
        $descriptionOut .= $name_used_in_source_link_to_show_use . ': ';
1573
        $descriptionOut .= $useSummary;
1574
        foreach ($description->sources as $source) {
1575
          $descriptionOut .= " (" . theme('cdm_DescriptionElementSource', array('descriptionElementSource' => $source, 'doLink' => TRUE)) . ")";
1576
        }
1577
        $hasUseRecords = FALSE;
1578
        $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>';
1579
        foreach ($description->elements as $descriptionElement) {
1580
          if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
1581
            $hasUseRecords = TRUE;
1582
            $useRecordTags = explode(';', $descriptionElement->modifyingText->English->text);
1583
            $descriptionUseRecordOut .= '<tr>';
1584
            $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>';
1585
            $descriptionUseRecordOut .= '</tr>';
1586
          }
1587
        }
1588
        $descriptionUseRecordOut .= '</table></div>';
1589
        if ($hasUseRecords) {
1590
          $descriptionOut .= $descriptionUseRecordOut . '</li>';
1591
        }
1592
      }
1593
      else {
1594

    
1595
        $synonymOut .= '<li class="descriptionText DescriptionElement">';
1596
        $name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
1597
          'absolute' => TRUE,
1598
          'html' => TRUE,
1599
        ));
1600

    
1601
        $synonymOut .= $name_used_in_source_link_to_show_use . ': ';
1602
        $synonymOut .= $useSummary;
1603
        foreach ($description->sources as $source) {
1604
          $synonymOut .= " (" . theme('cdm_DescriptionElementSource', array('descriptionElementSource' => $source, 'doLink' => TRUE)) . ")";
1605
        }
1606

    
1607
        $hasUseRecords = FALSE;
1608
        $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>';
1609
        foreach ($description->elements as $descriptionElement) {
1610
          if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
1611
            $hasUseRecords = TRUE;
1612
            $useRecordTags = explode(';', $descriptionElement->modifyingText->English->text);
1613
            $useRecordTableOut .= '<tr>';
1614
            $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>';
1615
            $useRecordTableOut .= '</tr>';
1616
          }
1617
        }
1618
        $useRecordTableOut .= '</table></div>';
1619
        if ($hasUseRecords) {
1620
          $synonymOut .= $useRecordTableOut . '</li>';
1621
        }
1622
        $isSynonym = FALSE;
1623
      }
1624

    
1625
      // }
1626
    }
1627
  }
1628
  $out .= $descriptionOut . $synonymOut;
1629
  $out .= "</ul></div>";
1630
  return $out;
1631
}
1632

    
1633
// The Uses theming function here will handle the display of the
1634
// Uses Descriptions.
1635
// Comment @WA: $pageSize is not used.
1636
// function theme_cdm_block_Uses ($taxonUuid = NULL, $pageSize = NULL {
1637
/**
1638
 * @todo Please document this function.
1639
 * @see http://drupal.org/node/1354
1640
 */
1641
function theme_cdm_block_Uses($variables) {
1642
  $taxonUuid = $variables['taxonUuid'];
1643
  RenderHints::pushToRenderStack('block_Uses');
1644

    
1645
  if ($taxonUuid == NULL) {
1646
    return;
1647
  }
1648
  $out = '';
1649
  $markerTypes = array();
1650
  $markerTypes['markerTypes'] = UUID_MARKERTYPE_USE;
1651
  $useDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxonUuid, queryString($markerTypes));
1652
  if (!empty($useDescriptions)) {
1653
    $out .= '<div id="block-cdm_dataportal-feature-description" class="clear-block block block-cdm_dataportal-feature"><H2><a name="userecords"> </a> Uses </H2>';
1654
    // @WA $pageNumber is not defined
1655
    // $formatUseDescriptions = theme('cdm_UseDescription', $useDescriptions,
1656
    // $taxonUuid, $pageSize, $pageNumber);
1657
    $formatUseDescriptions = theme('cdm_UseDescription', array('description' => $useDescriptions, 'taxonUuid' => $taxonUuid));
1658

    
1659
    $out .= $formatUseDescriptions;
1660
    $out .= "</div>";
1661
  }
1662

    
1663
  return $out;
1664
}
(3-3/9)