Project

General

Profile

Download (42.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
// $Id$
3

    
4
/**
5
 * Copyright (C) 2007 EDIT
6
 * European Distributed Institute of Taxonomy
7
 * http://www.e-taxonomy.eu
8
 *
9
 * The contents of this file are subject to the Mozilla Public License Version 1.1
10
 * See http://www.mozilla.org/MPL/MPL-1.1.html for the full license terms.
11
 */
12

    
13

    
14
function theme_cdm_feature_nodesTOC($featureNodes){
15

    
16
  $out .= '<ul>';
17

    
18
  foreach($featureNodes as $node){
19

    
20
    if(hasFeatureNodeDescriptionElements($node)){
21

    
22
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
23
      // HACK to implement images for taxa, should be removed
24
      if($node->feature->uuid != UUID_IMAGE){
25
        $out .= '<li>'.l(t(theme('cdm_feature_name', $featureRepresentation)), $_GET['q'], array("class"=>"toc"), NULL, generalizeString($featureRepresentation)).'</li>';
26
      }
27
    }
28
  }
29

    
30
  $out .= '</ul>';
31
  return $out;
32
}
33

    
34
function theme_cdm_feature_name($feature_name){
35
  //TODO replace by using translations ?
36
  switch($feature_name){
37
    default: return t(ucfirst($feature_name));
38
  }
39
}
40

    
41
/**
42
 * Renders the taxon profile. The taxon profile consists of description elements
43
 * which are ordered by the structure defined by specific FeatureTree. The chosen
44
 * FeatureTree is merged with the list of desctiprion elements prior to using this
45
 * method (see function cdm_ws_descriptions_by_featuretree() ).
46
 *
47
 * @param unknown_type $mergedTrees
48
 * @param unknown_type $taxon The taxon whose sprofile to show
49
 */
50
function theme_cdm_featureTrees($mergedTrees, $taxon){
51
  if(!$mergedTrees){
52
    return;
53
  }
54
  foreach($mergedTrees as &$mTree){
55
    //TODO display title and reference in case of multiple $mergedTrees -> theme
56
    $out .= theme('cdm_feature_nodes', $mTree->root->children, $taxon);
57
  }
58
  return $out;
59
}
60

    
61

    
62

    
63
function theme_cdm_featureTreeTOCs($mergedTrees){
64

    
65
  if(!$mergedTrees){
66
    return;
67
  }
68
  //FIXME
69
  $out = '<div id="featureTOC">';
70
  $out .= '<h2>' . t('Content') .'</h2>';
71

    
72
  //TODO diplay title and reference in case of multiple $mergedTrees -> theme
73

    
74
  foreach($mergedTrees as &$mTree){
75
    $out .= theme('cdm_feature_nodesTOC', $mTree->root->children);
76
  }
77

    
78
  $out .= '</div>';
79
  return $out;
80
}
81

    
82

    
83
/**
84
 * Renders the $mergedFeatureNodes for the given $taxon.
85
 * The merged nodes can be obtained by making use of the
86
 * function cdm_ws_descriptions_by_featuretree()
87
 *
88
 * @param unknown_type $featureNodes
89
 * @param unknown_type $taxon
90
 */
91
function theme_cdm_feature_nodes($mergedFeatureNodes, $taxon){
92

    
93
  RenderHints::pushToRenderStack('feature_nodes');
94
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME);
95

    
96
  foreach($mergedFeatureNodes as $node){
97

    
98
    if(hasFeatureNodeDescriptionElements($node)) {
99

    
100
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
101
      $block->module = 'cdm_dataportal';
102

    
103
      $media_list = array();
104

    
105
      if($node->feature->uuid != UUID_IMAGE) {
106

    
107
        $block->delta = generalizeString($featureRepresentation);
108
        $block->subject = '<span class="feature.uuid:'.$node->feature->uuid.'">' . theme('cdm_feature_name', $featureRepresentation) . '</span>';
109
        $block->module = "cdm_dataportal-feature";
110
        $block->content = '';
111

    
112
        /*
113
         * Content/DISTRIBUTION
114
         */
115
        if($node->feature->uuid == UUID_DISTRIBUTION){
116

    
117
          if(variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)){
118
            $distributionTextDataList = array();
119
            $distributionElementsList = array();
120
            foreach($node->descriptionElements as $descriptionElement){
121
              if($descriptionElement->class == "TextData"){
122
                $distributionTextDataList[] = $descriptionElement;
123
              } else {
124
                $distributionElementsList[] = $descriptionElement;
125
              }
126
            }
127
            if(count($distributionTextDataList) > 0){
128
              $node->descriptionElements = $distributionElementsList;
129
              $block->content .= theme('cdm_descriptionElements', $distributionTextDataList, $node->feature->uuid, $taxon->uuid);
130
            }
131
          }
132

    
133
          // Display cdm distribution map TODO this is a HACK to a proper generic implementation?
134
          $block->content .= theme('cdm_distribution_map', $taxon);
135
          $block->content .= theme('cdm_descriptionElements', $node->descriptionElements, $node->feature->uuid, $taxon->uuid);
136
        }
137

    
138
        /*
139
         * Content/COMMON_NAME
140
         */
141
        else if ($node->feature->uuid == UUID_COMMON_NAME){
142
          $block->content .= theme('cdm_common_names', $node->descriptionElements);
143
        /*
144
        }else if($node->feature->uuid == UUID_IMAGE_SOURCES) {
145
          $block->content .= theme('cdm_image_sources', $node->descriptionElements);
146
        */
147
        }
148

    
149
        /*
150
         * Content/ALL OTHER FEATURES
151
         */
152
        else {
153
          $block->content .= theme('cdm_descriptionElements', $node->descriptionElements, $node->feature->uuid, $taxon->uuid);
154

    
155
          /*
156
           *  Content/ALL OTHER FEATURES/Subordinate Features
157
           *
158
           *  subordinate features are printed inline in one floating text,
159
           *  it is expected that supordinate features only "contain" TextData elements
160
           */
161
          // TODO move into own theme
162
          if(count($node->children) > 0){
163

    
164
            //TODO support more than one level of childen http://dev.e-taxonomy.eu/trac/ticket/2393
165
            $text = '';
166
            foreach ($node->children as $child){
167

    
168
             if (is_array($child->descriptionElements)){
169
               foreach ($child->descriptionElements as $element) {
170

    
171
                 if(is_array($element->media)){
172
                   // append media of supordinate emelents to list of main feature
173
                   $media_list = array_merge($media_list, $element->media);
174
                 }
175

    
176
                 $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
177
                //TODO use localized version of feature name, the locale must match the locale of the multilanguage text (http://dev.e-taxonomy.eu/trac/ticket/2394)
178
                 $description = str_replace($element->feature->titleCache, '<em>' . $element->feature->titleCache . '</em>', $description);
179
               }
180
               $text .= " " . $description;
181
               $description = '';
182
             }
183

    
184
            }
185
            $block->content .= $text;
186
          }
187

    
188
        }
189

    
190
        /*
191
         * Media/ALL FEATURES
192
         */
193
        $media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
194
        $captionElements = array('title', 'rights');
195

    
196
        $gallery = theme('cdm_media_gallerie', $media_list, CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME.'_'.$node->feature->uuid,
197
              $gallery_settings['cdm_dataportal_media_maxextend'],
198
              $gallery_settings['cdm_dataportal_media_cols'],
199
              $gallery_settings['cdm_dataportal_media_maxRows'],
200
              $captionElements
201
        );
202

    
203
        $block->content .= $gallery;
204
        $block->content .= theme('cdm_footnotes', $node->feature->uuid);
205
        $block->content .= theme('cdm_annotation_footnotes', $node->feature->uuid);
206

    
207
        // add anchor to subject
208
        $block->subject = '<a name="'.$block->delta.'"></a>'.  $block->subject;
209

    
210
        $out .= theme('block', $block);
211
      }
212
    }
213

    
214
  }
215
  RenderHints::popFromRenderStack();
216
  return $out;
217
}
218

    
219
function theme_FeatureTree_hierarchy($FeatureTreeUuid){
220

    
221
  if(!is_uuid($FeatureTreeUuid)){
222
    return;
223
  }
224
  $out = '';
225
  $featureTree = cdm_ws_get(CDM_WS_FEATURETREE, array($FeatureTreeUuid));
226
  if($featureTree && $featureTree->root){
227
    $out = '<ul class="'.$featureTree->class.'">';
228
    $out .= theme('FeatureTree_hierarchy_children', $featureTree->root);
229
    $out .= '</ul>';
230
  }
231
  return $out;
232
}
233

    
234
function theme_FeatureTree_hierarchy_children($node){
235

    
236
  $out = '';
237
  if($node->children){
238

    
239
    foreach($node->children as $childNode){
240
      $out .= '<li>'.check_plain($childNode->feature->representation_L10n);
241
      if($childNode->children && count($childNode->children) > 0){
242
        $out .= '<ul>'.theme('FeatureTree_hierarchy_children', $childNode).'</ul>';
243
      }
244
      $out .= '</li>';
245
    }
246
  }
247
  return $out;
248
}
249

    
250

    
251

    
252
/**
253
 *
254
 * Join the texts in $elementArray and enclose with a HTML tag
255
 * @param unknown_type $elementArray
256
 * @param unknown_type $feature the feature to which the elements given in $elementArray are belonging to
257
 * @param unknown_type $glue defaults to empty string
258
 * @param unknown_type $sortArray whether to sort the $elementArray alphabetically
259
 * @param unknown_type $enclosingHtml
260
 */
261
function theme_cdm_descriptionElementArray($elementArray, $feature, $glue = '', $sortArray = false, $enclosingHtml = 'ul'){
262
  $out = '<'.$enclosingHtml.' class="description" id="'.$feature->representation_L10n.'">';
263

    
264
  if($sortArray) sort($elementArray);
265

    
266
  $out .= join($elementArray, $glue);
267

    
268
  $out .= '</'.$enclosingHtml.'>';
269
  return $out;
270
}
271

    
272

    
273
function theme_cdm_descriptionElement_CommonTaxonName($element){
274
  $out = $element->language->representation_L10n . ' (' . $element->area->titleCache . '): ' . $element->name;
275
  return $out;
276
}
277

    
278

    
279
/**
280
 * TODO: assign a new name to the function? because it is used for the citations
281
 *       textdata elements and not for all text data description elements
282
 * @param $element The description element which contains the text information
283
 * @param $asListElement A boolean which determines whether the citations should
284
 *                       be renderer as a list or not
285
 * @return unknown_type Html to be renderized in drupal
286
 */
287
function theme_cdm_descriptionElementTextData($element, $asListElement, $feature_uuid = null){
288

    
289
  $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
290
  $sourceRefs = '';
291
  $result = array();
292
  $out;
293
  $res_author;
294
  $res_date;
295

    
296
  if(is_array($element->sources)){
297
    foreach($element->sources as $source){
298
      $referenceCitation = theme('cdm_DescriptionElementSource', $source);
299
      if($description && strlen($description) > 0 && $referenceCitation ){
300
        $sourceRefs .= ' ('.$referenceCitation.')' ;
301
      }else if ($referenceCitation){
302
        $sourceRefs = $referenceCitation;
303
      }
304

    
305
      if(strlen($sourceRefs) > 0){
306
        $sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
307
      }
308

    
309
      if ($source->nameUsedInSource->uuid){ //do a link to name page
310
        $name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache,
311
        path_to_name($source->nameUsedInSource->uuid),
312
        array(), NULL, NULL, FALSE ,TRUE);
313
      }else if (strlen($source->nameUsedInSource->originalNameString) > 0){ //show a text without link
314
        $name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
315
      }
316

    
317
      if ($asListElement){
318
        $out = '<li class="descriptionText">' . $name_used_in_source_link_to_show;
319
        //adding ":" if necesary
320
        if ($name_used_in_source_link_to_show && ($description || $sourceRefs)){
321
          $out .= ': ';
322
        }
323
        $out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', $element, $feature_uuid) . '</li>';
324
      }else{
325
        if ($name_used_in_source_link_to_show){
326
          $name_used_in_source_link_to_show = ' (name in source: '. $name_used_in_source_link_to_show . ')';
327
        }
328
        $out = $description . $sourceRefs . $name_used_in_source_link_to_show;
329
      }
330
    }
331
  }
332
  //if no sources, print the description
333
  if(!isset($out)) {
334
    $out = $description;
335
  }
336

    
337
  return $out;
338
}
339

    
340

    
341
function theme_cdm_common_names($elements){
342
  $text_data_out = '';
343
  $common_name_out = '';
344
  $separator = ',';
345
  $textData_commonNames = array();
346

    
347

    
348
  if (is_array($elements)){
349
    foreach ($elements as $element){
350
      if ($element->class == 'CommonTaxonName'){
351
        //$key = '<b>' . $element->language->representation_L10n . '</b> (' . $element->area->titleCache . ')';
352
        if ($element->language->representation_L10n){
353
          $key = '<b>' . $element->language->representation_L10n . '</b>';
354
          $key .= (strlen($element->area->titleCache)>0) ? ' (' . $element->area->titleCache . ')' : '';
355
        }
356
        $common_names[$key][] = $element;
357
      }else if ($element->class == 'TextData'){
358
     //else if ($element->class == 'TextData' && $element->feature->uuid == UUID_COMMON_NAME){
359
        $textData_commonNames[] = $element;
360
      }
361
    }
362
  }
363
  //handling common names
364

    
365
  if (count($common_names) > 0){
366
    //sorting the a-array based on the area (key)
367
    ksort($common_names);
368
    //creating the output to be render by drupal
369
    foreach ($common_names as $key => $elements){
370
      $rendered_element_list = '';
371
      foreach($elements as $element){
372
        $sourcesFootnoteKeyList = '';
373
        // adding footnotes sources
374
        foreach($element->sources as $source){
375
          if(_is_original_source_type($source)){
376
            $_fkey = FootnoteManager::addNewFootnote(UUID_COMMON_NAME, theme('cdm_DescriptionElementSource', $source, false));
377
            $sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, ($sourcesFootnoteKeyList ? $separator : ''));
378
          }
379
        }
380
        if($element->name){
381
          $rendered_element_list .= (strlen($rendered_element_list) > 0 ? ', ': '') . $element->name . $sourcesFootnoteKeyList;
382
        }
383
      }
384
      if ($key){
385
       $common_name_out .= (strlen($common_name_out) > 0 ? '; ': '') . $key . ': ' . $rendered_element_list;
386
      }else{
387
        $common_name_out .= (strlen($common_name_out) > 0 ? '; ': '') . $rendered_element_list;
388
      }
389
    }
390
  }
391
  //handling commons names as text data
392
  foreach($textData_commonNames as $text_data_element){
393
    $text_data_out .= theme('cdm_descriptionElementTextData', $text_data_element, true, $text_data_element->feature->uuid);
394
  }
395

    
396
  $common_name_out = "<div class=common_names_as_common_names> $common_name_out </div>";
397
    $out_array[] = $text_data_out;
398
  $common_name_out_text_data = '<div class=common_names_as_text_data>' . theme('cdm_descriptionElementArray', $out_array, $element->feature) . '</div>';
399

    
400
  return $common_name_out . $common_name_out_text_data;
401
  //return $common_name_out . theme('cdm_descriptionElementArray', $out_array, $element->feature);
402
  //return "<div class=common_names> $common_name_out $common_name_out_text_data";
403
}
404

    
405
/**
406
 * Theme a list of description elements, usually of a specific feature type
407
 * @param $descriptionElements
408
 * @return unknown_type
409
 */
410
function theme_cdm_descriptionElements($descriptionElements, $featureUuid, $taxon_uuid){
411

    
412
  $outArray = array();
413

    
414
/*
415
  $userDefined = mixed_variable_get(LAYOUT_SETTING_PREFIX . $featureUuid, FEATURE_TREE_LAYOUT_DEFAULTS);
416
  if(variable_get('distribution_sort', 'NO_SORT')  != 'NO_SORT'){
417
    $glue = '';
418
    $enclosingTag = 'dl';
419
    $entryEnclosingTag = null;
420
  } else if($userDefined && $userDefined['enabled']){
421
      $glue = $userDefined['glue'];
422
      $enclosingTag = $userDefined['enclosingTag'];
423
      $entryEnclosingTag = $userDefined['entryEnclosingTag'];
424
  } else {
425
    // TODO remove once LAYOUT_SETTING_PREFIX-{uuid} seeting are confired to work for all portals (selenium test still missing!!!)
426
    $glue = '';
427
    $enclosingTag = 'ul';
428
    $entryEnclosingTag = null ;
429
  }
430
*/
431

    
432
	if(variable_get('distribution_sort', 'NO_SORT')  != 'NO_SORT'){
433
		$glue = '';
434
		$enclosingTag = 'dl';
435
	} else {
436
		$glue = '';
437
		$enclosingTag = 'ul';
438
	}
439

    
440
  $sortOutArray = false;
441
  $distributionElements = array();
442

    
443
  RenderHints::pushToRenderStack('cdm_descriptionElements');
444

    
445
  if(is_array($descriptionElements)){//avoiding warning box in drupal for flora malesiana
446
    foreach($descriptionElements as $descriptionElement) {
447

    
448
      // --- DISTRIBUTION ---- //
449
      if($descriptionElement->feature->uuid == UUID_DISTRIBUTION){
450
        if($descriptionElement->class == 'Distribution'){
451
          $sortKey = $descriptionElement->area->representation_L10n;
452
          $distributionElements[$sortKey]= $descriptionElement;
453
        } else if($descriptionElement->class == 'TextData'){
454
          $asListElement = false;
455
          $repr = theme ('cdm_descriptionElementTextData', $descriptionElement, $asListElement, $descriptionElement->feature->uuid);
456

    
457
          if( !array_search($repr, $outArray)){
458
          	$outArray[] = $repr;
459
            //TODO HINT: sorting in theme_cdm_descriptionElementArray will not work since this array contains html attributes with uuids !!!!
460
            $sortOutArray = true;
461
            $glue = '<br/> ';
462
            $enclosingTag = 'p';
463
          }
464
        }
465
      }
466

    
467
       // --- IMAGE_SOURCES --- //
468
      else if($descriptionElement->feature->uuid == UUID_IMAGE_SOURCES){
469
        $image_sources[] = $descriptionElement;
470
      }
471

    
472
      // ---- class == TextData ---- //
473
      else if($descriptionElement->class == 'TextData'){
474
        $asListElement = true;
475
        $outArray[] = theme('cdm_descriptionElementTextData', $descriptionElement, $asListElement, $descriptionElement->feature->uuid);
476
      }else if ($descriptionElement->class == 'CommonTaxonName') {
477
        $outArray[] = theme('cdm_descriptionElement_CommonTaxonName', $descriptionElement);
478
      }else {
479
        $outArray[] = '<li>No method for rendering unknown description class: '.$descriptionElement->classType.'</li>';
480
      }
481
    }
482
  }
483

    
484
  //if feature = NAME USAGE sort the list of sources
485
  //this is ONLY for FLORA MALESIANA and FLORE d'AFRIQUE CENTRALE
486
  if($descriptionElement->feature->uuid == UUID_NAME_USAGE){
487
    sort($outArray);
488
  }
489

    
490

    
491
  if($image_sources){
492
      $outArray[] = theme('cdm_description_element_image_source', $image_sources, true);
493

    
494
  }
495

    
496
  if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){
497
    $outArray[] = theme('cdm_description_ordered_distributions', $taxon_uuid, $distributionElements);
498
  }else{
499
    ksort($distributionElements);
500
    $outArray[] = theme('cdm_descriptionElementDistribution', $distributionElements); // TODO , $entryEnclosingTag);
501
  }
502

    
503
  // take the feature of the last $descriptionElement
504
  $feature = $descriptionElement->feature;
505
  $out = theme('cdm_descriptionElementArray', $outArray, $feature, $glue, $sortOutArray, $enclosingTag);
506

    
507
  RenderHints::popFromRenderStack();
508
  return $out;
509
}
510

    
511
/**
512
 *
513
 * Enter description here ...
514
 * @param unknown_type $a
515
 * @param unknown_type $b
516
 */
517
function compare_image_sources($a, $b){
518
    if($a->multilanguageText_L10n->text == $b->multilanguageText_L10n->text){
519
      return 0;
520
    }
521
    return ($a->multilanguageText_L10n->text < $b->multilanguageText_L10n->text) ? -1 : 1;
522
}
523

    
524
/**
525
 *
526
 */
527
function theme_cdm_description_element_image_source($image_sources, $asListElement) {
528
    $out = '';
529
    $separator = ',';
530
    RenderHints::pushToRenderStack('descriptionElementImageSource');
531
    RenderHints::setFootnoteListKey(UUID_IMAGE_SOURCES);
532

    
533
    //sorting the image sources
534
    usort($image_sources, "compare_image_sources");
535
    //generate the footnotes
536
    foreach($image_sources as $image_source){
537
        $footNoteKeys = cdm_annotations_as_footnotekeys($image_source);
538
        foreach($image_source->sources as $source){
539
            if(_is_original_source_type($source)){
540
                $fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
541
                cdm_add_footnote_to_array($footNoteKeys, $fn_key);// ensure uniqueness of the footnote keys
542
            }
543
        }
544
        //sort and render footnote keys
545
        $footnoteKeyListStr = '';
546
        asort($footNoteKeys);
547
        foreach($footNoteKeys as $footNoteKey){
548
            $footnoteKeyListStr .= theme('cdm_footnote_key', $footNoteKey, ($footnoteKeyListStr ? $separator : ''));
549
        }
550
        //return value!
551
        $out .= '<span class="descriptionElement descriptionElement-'.$image_source->uuid.'">'.$image_source->multilanguageText_L10n->text . $footnoteKeyListStr . '; </span>';
552

    
553
    }
554

    
555
    RenderHints::popFromRenderStack();
556
    return $out;
557
}
558

    
559
/**
560
 *
561
 * @param unknown_type $descriptionElements
562
 * @param String $enclosingTag
563
 */
564
function theme_cdm_descriptionElementDistribution($descriptionElements, $enclosingTag = "span"){
565

    
566

    
567
	if(!$enclosingTag){
568
		$enclosingTag = "span";
569
	}
570

    
571
  $out = '';
572
  $separator = ',';
573
  RenderHints::pushToRenderStack('descriptionElementDistribution');
574
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
575

    
576
  foreach($descriptionElements as $descriptionElement){
577

    
578
    // annotations as footnotes
579
    $footNoteKeys = cdm_annotations_as_footnotekeys($descriptionElement);
580
    // source references as footnotes
581
    foreach($descriptionElement->sources as $source){
582
      if(_is_original_source_type($source)){
583
        $fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
584
        cdm_add_footnote_to_array($footNoteKeys, $fn_key);// ensure uniqueness of the footnote keys
585
      }
586
    }
587
    // sort and render footnote keys
588
    $footnoteKeyListStr = '';
589
    asort($footNoteKeys);
590
    foreach($footNoteKeys as $footNoteKey){
591
      $footnoteKeyListStr .= theme('cdm_footnote_key', $footNoteKey, ($footnoteKeyListStr ? $separator : ''));
592
    }
593

    
594
    $out .= '<'. $enclosingTag .' class="descriptionElement descriptionElement-'.$descriptionElement->uuid.'">'
595
      . $descriptionElement->area->representation_L10n . $footnoteKeyListStr . ' </'. $enclosingTag .'>';
596
  }
597

    
598
  RenderHints::popFromRenderStack();
599
  return $out;
600
}
601

    
602
/**
603
 * Function target is to compare two different foootnotes objects.
604
 * The comparation is based on the footnote key. The one which is
605
 * displayed as footnote number.
606
 *
607
 * @param footnote object $a
608
 * @param footnote object $b
609
 */
610
function footnotes_key_compare($a, $b){
611
  $res = 0;
612
  if ($a->keyStr < $b->keyStr){
613
    $res = -1;
614
  }elseif ($a->keyStr > $b->keyStr){
615
    $res = 1;
616
  }
617
  return $res;
618
}
619

    
620
function theme_cdm_description_ordered_distributions($taxon_uuid, $descriptionElements){
621
  //returning null if no description elements
622
  if ($descriptionElements == null){
623
    return '';
624
  }
625
  //initialization some variables
626
  $out = '';
627
  $separator = ',';
628
  RenderHints::pushToRenderStack('descriptionElementDistribution');
629
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
630
  //getting all the taxon description for a given taxon
631
  $taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon_uuid);
632
  foreach ($taxonDescriptions as $description){
633
    $descriptions_uuids[] = $description->uuid;
634
  }
635
  //getting the sortered distributions (omiting level ??)
636
  $request_params = array();
637
  $request_params['omitLevels'] = UUID_NAMEDAREALEVEL_TDWGLEVEL_2;
638
  $ordered_areas = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION_DISTRIBUTION_TREE, join(',',$descriptions_uuids), queryString($request_params));
639
  $ordered_areas = $ordered_areas->rootElement->children;
640

    
641
  //printing the distributions
642
  foreach ($ordered_areas as $element_level1){
643
    //level1
644
    if ($element_level1->data){
645
      $out .= '<dt>' . $element_level1->data->area->representation_L10n . ':</dt> ';
646
    }
647
    $out .= '<dd>';
648

    
649
    //level3
650
    foreach ($element_level1->children as $element_level3){
651
      if ($element_level3->data){
652
        $text_l3 = $element_level3->data->area->representation_L10n;
653
      }
654
      $fnKeysLevel3Str = '';
655
      $fnKeysLevel3 = cdm_annotations_as_footnotekeys($element_level3->data);
656
      foreach($element_level3->data->sources as $source){
657
        if(_is_original_source_type($source)){
658
          $fn_key3 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
659
          cdm_add_footnote_to_array($fnKeysLevel3, $fn_key3);
660
        }
661
      }
662
      //level4
663
      $l4_regions = array();
664
      foreach ($element_level3->children as $element_level4){
665
        if ($element_level4->data){
666
          $text_l4 = $element_level4->data->area->representation_L10n;
667
          $l4_regions[$element_level3->data->area->representation_L10n] = '';
668
          $fnKeysLevel4Str = '';
669
          $fnKeysLevel4 = cdm_annotations_as_footnotekeys($element_level4->data);
670
          foreach($element_level4->data->sources as $source){
671
            if(_is_original_source_type($source)){
672
              $fn_key4 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
673
              cdm_add_footnote_to_array($fnKeysLevel4, $fn_key4);
674
            }
675
          }
676
          usort($fnKeysLevel4, "footnotes_key_compare");
677
          $l4_regions[$text_l4] = $fnKeysLevel4;
678
        }
679
      }//level4
680
      //managing level3 and level4 for generating the right output
681
      usort($fnKeysLevel3, "footnotes_key_compare");
682
      foreach ($fnKeysLevel3 as $key3){
683
        foreach ($l4_regions as $key4 => $value4){
684
          cdm_add_footnote_to_array($l4_regions[$key4], $key3);
685
        }
686
      }
687
      if ($element_level3->numberOfChildren == 1 &&
688
       $text_l3 == $element_level3->children[0]->data->area->representation_L10n){
689
        //var_dump($element_level3->children[0]->data->area->representation_L10n);
690
        $fnStr = '';
691
        $region = array_pop($l4_regions);
692
        foreach($region as $key){
693
          $fnStr .= theme('cdm_footnote_key', $key, ($fnStr ? $separator : ''));
694
        }
695
        $out .= "$text_l3 $fnStr; ";
696
              //removing whitespaces when &fnStr is empty
697
        if(substr($out, -3) == ' ; '){
698
          $out = substr($out, 0, -3) . '; ';
699
        }
700
      }else{
701
        $fnKeysLevel3Str = '';
702
        foreach($fnKeysLevel3 as $key){
703
          $fnKeysLevel3Str .= theme('cdm_footnote_key', $key, ($fnKeysLevel3Str ? $separator : ''));
704
        }
705
        $text_l4_aux = '';
706
        foreach ($l4_regions as $key => $value){
707
          $fnKeysLevel4Str = '';
708
          if (is_array($l4_regions[$key])) {
709
            foreach ($l4_regions[$key] as $fnkey){//warning why?
710
              $fnKeysLevel4Str .= theme('cdm_footnote_key', $fnkey, ($fnKeysLevel4Str ? $separator : ''));
711
            }
712
          }
713
          //if ($key != $text_l3 || sizeof($l4_regions > 1)){
714
          if ($key != $text_l3){
715
            $text_l4_aux .= "$key $fnKeysLevel4Str, ";
716
          }
717
        }
718
        $text_l4_aux = substr($text_l4_aux, 0, -2);
719

    
720
        if (strlen($text_l4_aux) > 0){
721
          $out .= "$text_l3 $fnKeysLevel3Str ($text_l4_aux); ";
722
        }else{
723
          $out .= "$text_l3 $fnKeysLevel3Str; ";
724
        }
725

    
726
      }
727
    }//level3
728
    $out = substr($out, 0, -2);
729
    $out .= '.</dd>';
730
  }//level1
731

    
732
  RenderHints::popFromRenderStack();
733
  return $out;
734
}
735

    
736
function theme_cdm_DescriptionElementSource($descriptionElementSource, $doLink = TRUE){
737

    
738
  if(isset($descriptionElementSource->citation)){
739
    $out = theme('cdm_reference', $descriptionElementSource->citation, $descriptionElementSource->citationMicroReference, $doLink);
740
  }
741
  return $out;
742
}
743

    
744
function theme_cdm_IdentifieableSource($source, $doLink = TRUE){
745

    
746
  if(isset($source->citation)){
747
    $out = theme('cdm_reference', $source->citation, $source->citationMicroReference, $doLink);
748
  }
749
  return $out;
750
}
751

    
752

    
753

    
754

    
755

    
756
/*
757
 function theme_cdm_descriptionElementDistribution($descriptionElements){
758

    
759
 $out = '';
760
 $separator = ',';
761
 RenderHints::pushToRenderStack('descriptionElementDistribution');
762
 RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
763
 foreach($descriptionElements as $descriptionElement){
764
 // annotations as footnotes
765
 $annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys', $descriptionElement);
766
 // source references as footnotes
767
 $sourcesFootnoteKeyList = '';
768
 foreach($descriptionElement->sources as $source){
769
 if(_is_original_source_type($source)){
770
 $_fkey = FootnoteManager::addNewFootnote(UUID_DISTRIBUTION, theme('cdm_DescriptionElementSource', $source, false));
771
 $sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, UUID_DISTRIBUTION, ($sourcesFootnoteKeyList ? $separator : ''));
772
 }
773
 }
774
 if($annotationFootnoteKeys && $sourcesFootnoteKeyList){
775
 $annotationFootnoteKeys .= $separator;
776
 }
777
 $out .= $descriptionElement->area->representation_L10n . $annotationFootnoteKeys . $sourcesFootnoteKeyList . ' ';
778
 }
779

    
780
 $out = substr($out, 0, strlen($out)-strlen($separator) );
781

    
782
 RenderHints::popFromRenderStack();
783
 return $out;
784

    
785
 }
786
 */
787

    
788

    
789
/**
790
 * TODO
791
 * Quick-and-dirty solution to show distribution service to exemplar groups
792
 *
793
 * @param unknown_type $featureTo
794
 * @return unknown
795
 */
796
function theme_cdm_distribution_map($taxon){
797

    
798
  $server = getEDITMapServiceURI();
799

    
800
  if(!$server){
801
    //warning message
802
    drupal_set_message('No \'Geoservice Access Point\' has been set so far. '
803
    . 'Please configure the variable \'Geoservice Access Point\' here '
804
    . l('CDM Dataportal Settings', 'admin/settings/cdm_dataportal/geo'), 'warning');
805
    //message to render
806
    return "<p>No geoservice specified</p>";
807
  }else{
808
    $fontStyles = array(0 => "plane", 1 => "italic");
809

    
810
    // query cdm server for map service uri parameters
811
    $map_data_parameters = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
812
    $out .= "<!-- map_data_parameters:". print_r($map_data_parameters, true) . " -->";
813
    $query_string = $map_data_parameters->String;
814
    if(!$query_string){
815
      // the $query_string is empty if there are no distribution areas defined
816
      return ;
817
    }
818

    
819
    // some cleaning of the URI paramters, TODO is this still needed?
820
    $query_string = str_replace('%3A', ":", $query_string);
821

    
822
    // additional query parameters as set in the data portal admin section
823
    $display_width = variable_get('cdm_dataportal_geoservice_display_width', false);
824
    $bounding_box = variable_get('cdm_dataportal_geoservice_bounding_box', false);
825
    $labels_on = variable_get('cdm_dataportal_geoservice_labels_on', 0);
826

    
827
    $query_string .= ($display_width ? '&ms=' . $display_width: '').
828
    ($bounding_box ? '&bbox=' .  $bounding_box : '')
829
    . ($labels_on ? '&label=' .  $labels_on : '');
830

    
831
    /* ------ choose the display mode, either openlayers or static image ------ */
832

    
833
    if(variable_get('cdm_dataportal_map_openlayers', 1)){
834

    
835
      $query_string .= '&img=false';
836

    
837
      /* =========== display distributions using the openlayers map viewer =========== */
838

    
839
      $legend_url_font_size = variable_get('cdm_dataportal_geoservice_legend_font_size', 10);
840
      $legend_url_font_style = variable_get('cdm_dataportal_geoservice_legend_font_style', 1);
841
      $legend_url_font_style = $fontStyles[$legend_url_font_style];
842
      $legend_url_icon_width  = variable_get('cdm_dataportal_geoservice_legend_icon_width', 35);
843
      $legend_url_icon_height = variable_get('cdm_dataportal_geoservice_legend_icon_height', 15);
844

    
845
      $legendFormatQueryStr  = "format=image".urlencode('/')."png&TRANSPARENT=TRUE";
846
      $legendFormatQueryStr .= "&WIDTH=".$legend_url_icon_width."&HEIGHT=".$legend_url_icon_height."&";
847
      //TODO why is the layer=topp:tdwg_level_4 parameter neede at all here??
848
      $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=".urlencode($sldLegend);
849

    
850
      $out .= get_openlayers_map(
851
        $display_width,
852
        null,
853
        $query_string,
854
        $legendFormatQueryStr,
855
        variable_get('cdm_dataportal_geoservice_map_caption', '')
856
      );
857

    
858
    } else {
859

    
860
      // simple image
861
      $mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
862

    
863
      $query_string .= '&img=true';
864
      $query_string .= '&legend=1&mlp=3' . $mapStaticCaption . '&recalculate=false';
865

    
866
      $map_service_script_name = "areas.php";
867

    
868
      // apply Plain Image map settings
869
      if (variable_get('edit_map_server', EDIT_MAPSERVER_V1_URI) ==  EDIT_MAPSERVER_V11_URI){
870
        /*
871
         * example : title=a:Naturalized++non-invasive
872
         * &ad=cyprusdivs:bdcode:a:5&as=a:ff9900,,0.1,&l=tdwg4
873
         * &ms=500&bbox=32,34,35,36&img=true&legend=1&mlp=3
874
         * &mc_s=Georgia,15,blue&mc=&recalculate=false
875
         *
876
         * http://edit.br.fgov.be/edit_wp5/v1/rest_gen.php?
877
         * l=background_gis:b,cyprusdivs&ad=cyprusdivs%3Abdcode%3Aa%3A8%2C4
878
         * &as=a%3A339966%2C%2C0.1%2C|b:0000ff,,
879
         * &bbox=32%2C34%2C35%2C36&img=true&legend=1&mc=&mc_s=Georgia%2C15%2Cblue
880
         * &mlp=3&ms=500&recalculate=false&title=a%3Aindigenous
881
         */
882

    
883
        $map_service_script_name = "rest_gen.php";
884

    
885
        $bgcolor_areaStyleId= "y";
886
        $baselayer_areaStyleId= "z";
887
        $bgcolor_layer='';
888
        $additional_area_styles = array();
889

    
890
        // background color:
891
        if(variable_get('map_bg_color', '')){
892
          $bgcolor_layer = "background_gis:".$bgcolor_areaStyleId;
893
          $additional_area_styles[] = $bgcolor_areaStyleId . ":" . variable_get('map_bg_color', '') . ",,";
894
        }
895

    
896
        //TODO HACK to replace the default base layer which currently is tdwg4 !!!
897
        if(strpos($query_string, "?l=") !== FALSE){
898
          $layer_param_token = "?l=";
899
        } else {
900
          $layer_param_token = "&l=";
901
        }
902
        if(strpos($query_string, "?as=") !== FALSE){
903
          $areystyle_param_token = "?as=";
904
        } else {
905
          $areystyle_param_token = "&as=";
906
        }
907

    
908
        if(variable_get('map_base_layer', '')){
909
          $query_string = str_replace($layer_param_token."tdwg4", "$layer_param_token".variable_get('map_base_layer', ''). ":" . $baselayer_areaStyleId, $query_string);
910
        } else {
911
          $query_string = str_replace($layer_param_token."tdwg4", $layer_param_token."tdwg4:".$baselayer_areaStyleId . ",", $query_string);
912
        }
913

    
914
        if($bgcolor_layer){
915
          $query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
916
        }
917

    
918
        if(variable_get('map_base_layer_style', '')){
919
          $additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
920
        }
921

    
922
        foreach ($additional_area_styles as $as) {
923
          $query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
924
        }
925

    
926
      }
927

    
928
      $mapUri = url("$server/$map_service_script_name?$query_string");
929
      $out .= '<img class="distribution_map" src="' . $mapUri . '" alt="Distribution Map" />';
930
    }
931
    return $out;
932
  }
933
}
934

    
935
/**
936
 * Returns a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
937
 * @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
938
 *          valid values are : PolytomousKey, MediaKey, MultiAccessKey
939
 * @param $taxonUuid if given this parameter restrict the listed keys to
940
 *          those which have the taxon identified be this uuid in scope.
941
 */
942
function _list_IdentificationKeys($type, $taxonUuid = null, $pageSize = null, $pageNumber = null){
943

    
944
  if(!$type){
945
    drupal_set_message("Type parameter is missing", "error");
946
    return;
947
  }
948
  $cdm_ws_pasepath = null;
949
  switch($type){
950
    case "PolytomousKey" : $cdm_ws_pasepath = CDM_WS_POLYTOMOUSKEY; break;
951
    case "MediaKey" : $cdm_ws_pasepath = CDM_WS_MEDIAKEY; break;
952
    case "MultiAccessKey" : $cdm_ws_pasepath = CDM_WS_MULTIACCESSKEY; break;
953
  }
954

    
955
  if(!$cdm_ws_pasepath){
956
    drupal_set_message("Type parameter is not valid: ".$type, "error");
957
  }
958

    
959
  $queryParameters  = '';
960
  if(is_numeric($pageSize)){
961
    $queryParameters  = "pageSize=".$pageSize;
962
  } else {
963
    $queryParameters  = "pageSize=0";
964
  }
965

    
966
  if(is_numeric($pageNumber)){
967
    $queryParameters  = "pageNumber=".$pageNumber;
968
  } else {
969
    $queryParameters  = "pageNumber=0";
970
  }
971
  $queryParameters  = null;
972
  if($taxonUuid){
973
    $queryParameters = "findByTaxonomicScope=$taxonUuid";
974
  }
975
  $pager = cdm_ws_get($cdm_ws_pasepath, null, $queryParameters);
976

    
977
  if(!$pager || $pager->count == 0){
978
      return array();
979
  }
980
  return $pager->records;
981
}
982

    
983
function theme_cdm_IdentificationKey($identificationKey, $doLinkToKeyPage = true, $showIdentificationKeyTitle = true){
984

    
985
   $parentRenderPath = RenderHints::getRenderPath();
986
   RenderHints::pushToRenderStack("IdentificationKey");
987

    
988
   if($showIdentificationKeyTitle){
989
     if($doLinkToKeyPage) {
990
       $out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid));
991
     } else {
992
       $out = $identificationKey->titleCache;
993
     }
994
   }
995
   if(is_array($identificationKey->sources)){
996
     // display sources
997
     $i = 0;
998
     $out .= '<div>';
999
     foreach($identificationKey->sources as $source){
1000
      $out .= ($i++ > 0 ? ', ' : '' ) . theme("cdm_IdentifieableSource", $source);
1001
     }
1002
     $out .= '</div>';
1003
   }
1004
     // display annotations
1005
   $out .= theme('cdm_annotations', cdm_ws_getAnnotationsFor($identificationKey), 'div');
1006
   RenderHints::popFromRenderStack();
1007
   return $out;
1008
}
1009

    
1010
function theme_cdm_polytomousKey(&$polytomousKey){
1011

    
1012
  $keyStyle = "linkedStyle"; // TODO settings needed
1013

    
1014
  RenderHints::pushToRenderStack("polytomousKey");
1015
  // key nodes in linked style
1016
  $out = '<table class="polytomousKey polytomousKey_'.$keyStyle.'">';
1017
  $out .= theme('cdm_polytomousKey_'.$keyStyle.'_subgraph', $polytomousKey->root);
1018
  $out .= '</table>';
1019
  RenderHints::popFromRenderStack();
1020
  return $out;
1021
}
1022

    
1023
function theme_cdm_polytomousKey_linkedStyle_subgraph(&$polytomousKeyNode){
1024

    
1025
  static $statementCountCharacter = '\'';
1026

    
1027
  $out = "";
1028

    
1029
  if(is_array($polytomousKeyNode->children)){
1030

    
1031
    $childCount = 0;
1032

    
1033
    // render edges of the current node
1034
    foreach($polytomousKeyNode->children as &$child){
1035

    
1036
      if(!isset($child->statement)){
1037
        // skip node with empty statements (see below for explanation: "Special case")
1038
        continue;
1039
      }
1040

    
1041
      $out .= '<tr class="childCount_' . $childCount . '">';
1042

    
1043
      $out .= '<td class="nodeNumber">'. uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childCount++ , $statementCountCharacter)) . "</td>";
1044

    
1045
      /*
1046
       * Special case:
1047
       * Child nodes with empty statements but taxa as leaf are to
1048
       * treated as if all those taxa where direct children of the source node.
1049
       */
1050
      $islinkToManyTaxa = !isset($child->children[0]->statement) && isset($child->children[0]->taxon->uuid);
1051
      $islinkToTaxon = isset($child->taxon->uuid);
1052
      $islinkToSubKey = isset($child->subkey->uuid);
1053
      $islinkToOtherNode = isset($child->otherNode);
1054
      $islinkToNode = $child->nodeNumber && !$islinkToManyTaxa && !$islinkToOtherNode; // either null or 0
1055

    
1056
      $out .= '<td ' . RenderHints::getHtmlElementID($child) . '  class="edge">';
1057
      if(isset($polytomousKeyNode->question->label_l10n)){
1058
        $out .= $polytomousKeyNode->question->label_l10n .  ": ";
1059
      }
1060
      $out .= $child->statement->label_l10n;
1061

    
1062
      // --- links to nodes taxa and subkeys
1063
      $out .= '<div class="nodeLink">';
1064

    
1065
     // link to a PolytomousKeyNode
1066
      if($islinkToNode){
1067
        $out .= '<div class="nodeLinkToNode">' . l($child->nodeNumber, $_REQUEST["q"], null, null, $child->uuid) . '</div>';
1068
      }
1069

    
1070
      // link to a PolytomousKeyNode
1071
      if($islinkToOtherNode){
1072
        $out .= '<div class="nodeLinkToOtherNode">' . l($child->otherNode->nodeNumber, $_REQUEST["q"], null, null, $child->otherNode->uuid) . '</div>';
1073
      }
1074

    
1075
      // link to one or many taxa
1076
      if($islinkToTaxon || $islinkToManyTaxa){
1077

    
1078
        if($islinkToManyTaxa){
1079
          $taxonChildren = $child->children;
1080
        } else {
1081
          $taxonChildren = array($child);
1082
        }
1083

    
1084
        foreach($taxonChildren as $taxonChild){
1085
          // TODO many taxa $child->children->taxon
1086
          $out .= '<div class="nodeLinkToTaxon">';
1087
          if(is_object($taxonChild->modifyingText)){
1088
            $i = 0;
1089
            foreach(get_object_vars($taxonChild->modifyingText) as $language=>$languageString){
1090
              $out .= ($i++ > 0 ? ', ' : '') . '<span class="modifyingText">'. $languageString->text . '</span> ';
1091
            }
1092
          }
1093
          $out .=  theme("cdm_taxonName", $taxonChild->taxon->name, url(path_to_taxon($taxonChild->taxon->uuid)));
1094
          $out .=  '</div>';
1095
        }
1096

    
1097
        // link to a subkey
1098
        if($islinkToSubKey){
1099
          $out .= '<div class="nodeLinkToSubkey">' . theme('cdm_IdentificationKey', $child->subkey) . '</div>';
1100
        }
1101

    
1102
      }
1103

    
1104
      $out .= '</div>'; // end node link
1105
      $out .= '</td>'; // end edge
1106
      $out .= '</tr>';
1107

    
1108
    }
1109

    
1110
    // recurse into child nodes
1111
    foreach($polytomousKeyNode->children as &$child){
1112
      $out .= theme('cdm_polytomousKey_linkedStyle_subgraph', $child);
1113
    }
1114

    
1115
  }
1116
  return $out;
1117
}
1118

    
1119
/**
1120
 * Renders a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
1121
 * @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
1122
 *          valid values are : PolytomousKey, MediaKey, MultiAccessKey
1123
 * @param $taxonUuid if given this parameter restrict the listed keys to
1124
 *          those which have the taxon identified be this uuid in scope.
1125
 */
1126
function theme_cdm_list_IdentificationKeys($type, $taxonUuid = null, $pageSize, $pageNumber){
1127

    
1128
  $keyList = _list_IdentificationKeys($type, $taxonUuid);
1129
  if(!$keyList || count ($keyList) == 0){
1130
    return;
1131
  }
1132

    
1133
  RenderHints::pushToRenderStack('list_IdentificationKeys');
1134
  $out = '<ul>';
1135
  foreach ($keyList as $key){
1136
    $out .= '<li>';
1137
    $out .= theme('cdm_IdentificationKey', $key);
1138
    $out .= '</li>';
1139
  }
1140
  $out .= '</ul>';
1141
  $out .= theme("cdm_annotation_footnotes", RenderHints::getRenderPath());
1142
  RenderHints::popFromRenderStack();
1143

    
1144
  return $out;
1145
}
1146

    
1147
function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize = null){
1148

    
1149
  static $types = array("PolytomousKey"=>"Polytomous", "MediaKey"=>"Media", "MultiAccessKey"=>"Multiaccess");
1150
  RenderHints::pushToRenderStack('block_IdentificationKeys');
1151
  $out = '';
1152
  foreach($types as $type=>$label){
1153
    $keylist = theme('cdm_list_IdentificationKeys', $type, $taxonUuid, $pageSize, $pageNumber);
1154
    if(!$keylist){
1155
      continue;
1156
    }
1157
    $out .= '<div class="'.$type.'">';
1158
    $out .= '<h3>'.t($label)."</h3>";
1159
    $out .= $keylist;
1160
    $out .= '</div>';
1161
  }
1162
  RenderHints::popFromRenderStack();
1163
  return $out;
1164
}
(2-2/8)