Project

General

Profile

Download (60.6 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">';
463
        // Adding ":" if necessary.
464
        if (!empty($name_used_in_source_link_to_show)) {
465
          if ( (!empty($description)|| !empty($sourceRefs)) && $feature_uuid != UUID_CHROMOSOMES_NUMBERS) {
466
            $out .= $name_used_in_source_link_to_show . ': ';
467
          } else {
468
            $out .= $name_used_in_source_link_to_show . ' ';
469
          }
470
        }
471
        $out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $element, 'footnote_list_key' => $feature_uuid)) . '</li>';
472
      }
473
      else {
474
        if ($name_used_in_source_link_to_show) {
475
          $name_used_in_source_link_to_show = ' (name in source: ' . $name_used_in_source_link_to_show . ')';
476
        }
477

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

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

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

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

    
566
  $common_name_out = "<div class=common_names_as_common_names> $common_name_out </div>";
567
  $out_array[] = $text_data_out;
568
  $common_name_out_text_data = '<div class=common_names_as_text_data>' . theme('cdm_descriptionElementArray', array('elementArray' => $out_array, 'feature' => $element->feature)) . '</div>';
569

    
570
  return $common_name_out . $common_name_out_text_data;
571
  /*
572
  return $common_name_out . theme('cdm_descriptionElementArray', $out_array,
573
  $element->feature);
574
  return "<div class=common_names> $common_name_out
575
  $common_name_out_text_data";
576
  */
577
}
578

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

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

    
611
  if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') {
612
    $glue = '';
613
    $enclosingTag = 'dl';
614
  }
615
  else {
616
    $glue = '';
617
    $enclosingTag = 'ul';
618
  }
619

    
620
  $sortOutArray = FALSE;
621
  $distributionElements = array();
622

    
623
  RenderHints::pushToRenderStack('cdm_descriptionElements');
624

    
625
  // Avoiding warning box in drupal for flora malesiana.
626
  if (is_array($descriptionElements)) {
627
    foreach ($descriptionElements as $descriptionElement) {
628

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

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

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

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

    
698
  if (isset($image_sources)) {
699
    $outArray[] = theme('cdm_description_element_image_source', array('image_sources' => $image_sources, 'asListElement' => TRUE));
700
  }
701

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

    
713
  // Take the feature of the last $descriptionElement.
714
  $feature = $descriptionElement->feature;
715

    
716
  $out = theme('cdm_descriptionElementArray', array(
717
    'elementArray' => $outArray,
718
    'feature' => $feature,
719
    'glue' => $glue,
720
    'sortArray' => $sortOutArray,
721
    'enclosingHtml' => $enclosingTag,
722
  ));
723

    
724
  RenderHints::popFromRenderStack();
725
  return $out;
726
}
727

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

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

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

    
776
  RenderHints::popFromRenderStack();
777
  return $out;
778
}
779

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

    
791
  $out = '';
792
  $separator = ',';
793
  RenderHints::pushToRenderStack('descriptionElementDistribution');
794
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
795

    
796
  foreach ($descriptionElements as $descriptionElement) {
797

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

    
818
    $out .= '<' . $enclosingTag . ' class="descriptionElement descriptionElement-' . $descriptionElement->uuid . '">' . $descriptionElement->area->representation_L10n . $footnoteKeyListStr . ' </' . $enclosingTag . '>';
819
  }
820

    
821
  RenderHints::popFromRenderStack();
822
  return $out;
823
}
824

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

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

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

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

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

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

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

    
1043
  if (!$server) {
1044
    // Warning message.
1045
    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');
1046
    // Message to render.
1047
    return "<p>No geoservice specified</p>";
1048
  }
1049

    
1050
  $fontStyles = array(
1051
    0 => "plane",
1052
    1 => "italic",
1053
  );
1054

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

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

    
1067
  /* ------ choose the display mode, either openlayers or static image ------ */
1068
  if (variable_get('cdm_dataportal_map_openlayers', 1)) {
1069

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

    
1077
    $legendFormatQueryStr = "format=image" . urlencode('/') . "png&TRANSPARENT=TRUE";
1078
    $legendFormatQueryStr .= "&WIDTH=" . $legend_url_icon_width . "&HEIGHT=" . $legend_url_icon_height . "&";
1079
    // TODO why is the layer=topp:tdwg_level_4 parameter neede at all here??
1080
    // Comment @WA $sldLegend is not used.
1081
    // $legendFormatQueryStr
1082
    // .="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);
1083
    $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=";
1084

    
1085
    $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', ''));
1086
  }
1087
  else {
1088
    $legendFormatQueryStr = '';
1089
    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', ''));
1090

    
1091
    // Simple image.
1092
    $mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
1093

    
1094
    $query_string .= '&img=true';
1095
    $query_string .= '&legend=1&mlp=3' . $mapStaticCaption . '&recalculate=FALSE';
1096

    
1097
    $map_service_script_name = "areas.php";
1098

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

    
1113
      $map_service_script_name = "rest_gen.php";
1114

    
1115
      $bgcolor_areaStyleId = "y";
1116
      $baselayer_areaStyleId = "z";
1117
      $bgcolor_layer = '';
1118
      $additional_area_styles = array();
1119

    
1120
      // Background color.
1121
      if (variable_get('map_bg_color', '')) {
1122
        $bgcolor_layer = "background_gis:" . $bgcolor_areaStyleId;
1123
        $additional_area_styles[] = $bgcolor_areaStyleId . ":" . variable_get('map_bg_color', '') . ",,";
1124
      }
1125

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

    
1141
      if (variable_get('map_base_layer', '')) {
1142
        $query_string = str_replace($layer_param_token . "tdwg4", "$layer_param_token" . variable_get('map_base_layer', '') . ":" . $baselayer_areaStyleId, $query_string);
1143
      }
1144
      else {
1145
        $query_string = str_replace($layer_param_token . "tdwg4", $layer_param_token . "tdwg4:" . $baselayer_areaStyleId . ",", $query_string);
1146
      }
1147

    
1148
      if ($bgcolor_layer) {
1149
        $query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
1150
      }
1151

    
1152
      if (variable_get('map_base_layer_style', '')) {
1153
        $additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
1154
      }
1155

    
1156
      foreach ($additional_area_styles as $as) {
1157
        $query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
1158
      }
1159
    }
1160

    
1161
    $mapUri = url("$server/$map_service_script_name?$query_string");
1162
    $out .= '<img class="distribution_map" src="' . $mapUri . '" alt="Distribution Map" />';
1163
  }
1164
  return $out;
1165
}
1166

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

    
1194
    case "MediaKey":
1195
      $cdm_ws_pasepath = CDM_WS_MEDIAKEY;
1196
      break;
1197

    
1198
    case "MultiAccessKey":
1199
      $cdm_ws_pasepath = CDM_WS_MULTIACCESSKEY;
1200
      break;
1201

    
1202
  }
1203

    
1204
  if (!$cdm_ws_pasepath) {
1205
    drupal_set_message(t('Type parameter is not valid: ') . $type, 'error');
1206
  }
1207

    
1208
  $queryParameters = '';
1209
  if (is_numeric($pageSize)) {
1210
    $queryParameters = "pageSize=" . $pageSize;
1211
  }
1212
  else {
1213
    $queryParameters = "pageSize=0";
1214
  }
1215

    
1216
  if (is_numeric($pageNumber)) {
1217
    $queryParameters = "pageNumber=" . $pageNumber;
1218
  }
1219
  else {
1220
    $queryParameters = "pageNumber=0";
1221
  }
1222
  $queryParameters = NULL;
1223
  if ($taxonUuid) {
1224
    $queryParameters = "findByTaxonomicScope=$taxonUuid";
1225
  }
1226
  $pager = cdm_ws_get($cdm_ws_pasepath, NULL, $queryParameters);
1227

    
1228
  if (!$pager || $pager->count == 0) {
1229
    return array();
1230
  }
1231
  return $pager->records;
1232
}
1233

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

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

    
1269
/**
1270
 * @todo Please document this function.
1271
 * @see http://drupal.org/node/1354
1272
 */
1273
function theme_cdm_polytomousKey($variables) {
1274
  $polytomousKey = $variables['polytomousKey'];
1275

    
1276
  // TODO settings needed.
1277
  // @see http://en.wikipedia.org/wiki/Single_access_key#Presentation_styles
1278
  // @see http://dev.e-taxonomy.eu/trac/ticket/2152
1279
  $keyStyle = "linkedStyle";
1280

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

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

    
1299
  if (is_array($polytomousKeyNode->children)) {
1300
    $childIndex = 0;
1301

    
1302
    // Render edges of the current node.
1303
    foreach ($polytomousKeyNode->children as &$child) {
1304

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

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

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

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

    
1338
      if ($hasQuestion) {
1339
        $out .= '<td class="nodeNumber"></td>';
1340
      }
1341
      else {
1342
        $out .= '<td class="nodeNumber">' . uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childIndex, $statementCountCharacter)) . "</td>";
1343
      }
1344

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

    
1347
      // Feature.
1348
      if ($hasFeature) {
1349
        $out .= $polytomousKeyNode->feature->representation_L10n . ": ";
1350
      }
1351

    
1352
      // Statement.
1353
      $out .= $child->statement->label_l10n;
1354

    
1355
      // --- Links to nodes taxa and subkeys.
1356
      $out .= '<div class="nodeLink">';
1357

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

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

    
1384
      // Link to one or many taxa.
1385
      if ($islinkToTaxon || $islinkToManyTaxa) {
1386

    
1387
        if ($islinkToManyTaxa) {
1388
          $taxonChildren = $child->children;
1389
        }
1390
        else {
1391
          $taxonChildren = array(
1392
            $child,
1393
          );
1394
        }
1395

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

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

    
1412
      $out .= '</div>'; // End node link.
1413
      $out .= '</td>'; // End edge.
1414
      $out .= '</tr>';
1415

    
1416
      $childIndex++;
1417
    }
1418

    
1419
    // Recurse into child nodes.
1420
    foreach ($polytomousKeyNode->children as &$child) {
1421
      $out .= theme('cdm_polytomousKey_linkedStyle_subgraph', array('polytomousKeyNode' => $child));
1422
    }
1423
  }
1424

    
1425
  return $out;
1426
}
1427

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

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

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

    
1478
  return $out;
1479
}
1480

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

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

    
1536
  foreach ($descriptions as $description) {
1537
    $useSummary = "";
1538
    // Comment @WA: $synonyms is not defined.
1539
    // $serializedSynonyms = serialize($synonyms).
1540
    foreach ($description->elements as $element) {
1541

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

    
1566
      if ($currentTaxon->name->uuid != $originalTaxonUsedInSource->uuid) {
1567
        $isSynonym = TRUE;
1568
      }
1569

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

    
1599
        $synonymOut .= '<li class="descriptionText DescriptionElement">';
1600
        $name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
1601
          'absolute' => TRUE,
1602
          'html' => TRUE,
1603
        ));
1604

    
1605
        $synonymOut .= $name_used_in_source_link_to_show_use . ': ';
1606
        $synonymOut .= $useSummary;
1607
        foreach ($description->sources as $source) {
1608
          $synonymOut .= " (" . theme('cdm_DescriptionElementSource', array('descriptionElementSource' => $source, 'doLink' => TRUE)) . ")";
1609
        }
1610

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

    
1629
      // }
1630
    }
1631
  }
1632
  $out .= $descriptionOut . $synonymOut;
1633
  $out .= "</ul></div>";
1634
  return $out;
1635
}
1636

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

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

    
1663
    $out .= $formatUseDescriptions;
1664
    $out .= "</div>";
1665
  }
1666

    
1667
  return $out;
1668
}
(3-3/9)