Project

General

Profile

Download (42.6 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 = theme('cdm_feature_name', $featureRepresentation);
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) . '</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
  //printing annotations footnotes
337
  //$out .= theme('cdm_annotations_as_footnotekeys', $element);
338
  // add annotations as footnote key
339
  //$out .= theme('cdm_annotations_as_footnotekeys', $element); move above
340
  return $out;
341
}
342

    
343

    
344
function theme_cdm_common_names($elements){
345
  $text_data_out = '';
346
  $common_name_out = '';
347
  $separator = ',';
348
  $textData_commonNames = array();
349

    
350

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

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

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

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

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

    
415
  $outArray = array();
416

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

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

    
443
  $sortOutArray = false;
444
  $distributionElements = array();
445

    
446
  RenderHints::pushToRenderStack('cdm_descriptionElements');
447

    
448
  if(is_array($descriptionElements)){//avoiding warning box in drupal for flora malesiana
449
    foreach($descriptionElements as $descriptionElement) {
450

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

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

    
470
       // --- IMAGE_SOURCES --- //
471
      else if($descriptionElement->feature->uuid == UUID_IMAGE_SOURCES){
472
        $image_sources[] = $descriptionElement;
473
      }
474

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

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

    
493

    
494
  if($image_sources){
495
      $outArray[] = theme('cdm_description_element_image_source', $image_sources, true);
496

    
497
  }
498

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

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

    
510
  RenderHints::popFromRenderStack();
511
  return $out;
512
}
513

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

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

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

    
556
    }
557

    
558
    RenderHints::popFromRenderStack();
559
    return $out;
560
}
561

    
562
/**
563
 *
564
 * @param unknown_type $descriptionElements
565
 * @param String $enclosingTag
566
 */
567
function theme_cdm_descriptionElementDistribution($descriptionElements, $enclosingTag = "span"){
568

    
569

    
570
	if(!$enclosingTag){
571
		$enclosingTag = "span";
572
	}
573

    
574
  $out = '';
575
  $separator = ',';
576
  RenderHints::pushToRenderStack('descriptionElementDistribution');
577
  RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
578

    
579
  foreach($descriptionElements as $descriptionElement){
580

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

    
597
    $out .= '<'. $enclosingTag .' class="descriptionElement descriptionElement-'.$descriptionElement->uuid.'">'
598
      . $descriptionElement->area->representation_L10n . $footnoteKeyListStr . ' </'. $enclosingTag .'>';
599
  }
600

    
601
  RenderHints::popFromRenderStack();
602
  return $out;
603
}
604

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

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

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

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

    
723
        if (strlen($text_l4_aux) > 0){
724
          $out .= "$text_l3 $fnKeysLevel3Str ($text_l4_aux); ";
725
        }else{
726
          $out .= "$text_l3 $fnKeysLevel3Str; ";
727
        }
728

    
729
      }
730
    }//level3
731
    $out = substr($out, 0, -2);
732
    $out .= '.</dd>';
733
  }//level1
734

    
735
  RenderHints::popFromRenderStack();
736
  return $out;
737
}
738

    
739
function theme_cdm_DescriptionElementSource($descriptionElementSource, $doLink = TRUE){
740

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

    
747
function theme_cdm_IdentifieableSource($source, $doLink = TRUE){
748

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

    
755

    
756

    
757

    
758

    
759
/*
760
 function theme_cdm_descriptionElementDistribution($descriptionElements){
761

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

    
783
 $out = substr($out, 0, strlen($out)-strlen($separator) );
784

    
785
 RenderHints::popFromRenderStack();
786
 return $out;
787

    
788
 }
789
 */
790

    
791

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

    
801
  $server = getEDITMapServiceURI();
802

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

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

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

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

    
830
    $query_string .= ($display_width ? '&ms=' . $display_width: '').
831
    ($bounding_box ? '&bbox=' .  $bounding_box : '')
832
    . ($labels_on ? '&label=' .  $labels_on : '');
833

    
834
    /* ------ choose the display mode, either openlayers or static image ------ */
835

    
836
    if(variable_get('cdm_dataportal_map_openlayers', 1)){
837

    
838
      $query_string .= '&img=false';
839

    
840
      /* =========== display distributions using the openlayers map viewer =========== */
841

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

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

    
853
      $out .= get_openlayers_map(
854
        $display_width,
855
        null,
856
        $query_string,
857
        $legendFormatQueryStr,
858
        variable_get('cdm_dataportal_geoservice_map_caption', '')
859
      );
860

    
861
    } else {
862

    
863
      // simple image
864
      $mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
865

    
866
      $query_string .= '&img=true';
867
      $query_string .= '&legend=1&mlp=3' . $mapStaticCaption . '&recalculate=false';
868

    
869
      $map_service_script_name = "areas.php";
870

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

    
886
        $map_service_script_name = "rest_gen.php";
887

    
888
        $bgcolor_areaStyleId= "y";
889
        $baselayer_areaStyleId= "z";
890
        $bgcolor_layer='';
891
        $additional_area_styles = array();
892

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

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

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

    
917
        if($bgcolor_layer){
918
          $query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
919
        }
920

    
921
        if(variable_get('map_base_layer_style', '')){
922
          $additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
923
        }
924

    
925
        foreach ($additional_area_styles as $as) {
926
          $query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
927
        }
928

    
929
      }
930

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

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

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

    
958
  if(!$cdm_ws_pasepath){
959
    drupal_set_message("Type parameter is not valid: ".$type, "error");
960
  }
961

    
962
  $queryParameters  = '';
963
  if(is_numeric($pageSize)){
964
    $queryParameters  = "pageSize=".$pageSize;
965
  } else {
966
    $queryParameters  = "pageSize=0";
967
  }
968

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

    
980
  if(!$pager || $pager->count == 0){
981
      return array();
982
  }
983
  return $pager->records;
984
}
985

    
986
function theme_cdm_IdentificationKey($identificationKey, $doLinkToKeyPage = true, $showIdentificationKeyTitle = true){
987

    
988
   $parentRenderPath = RenderHints::getRenderPath();
989
   RenderHints::pushToRenderStack("IdentificationKey");
990

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

    
1013
function theme_cdm_polytomousKey(&$polytomousKey){
1014

    
1015
  $keyStyle = "linkedStyle"; // TODO settings needed
1016

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

    
1026
function theme_cdm_polytomousKey_linkedStyle_subgraph(&$polytomousKeyNode){
1027

    
1028
  static $statementCountCharacter = '\'';
1029

    
1030
  $out = "";
1031

    
1032
  if(is_array($polytomousKeyNode->children)){
1033

    
1034
    $childCount = 0;
1035

    
1036
    // render edges of the current node
1037
    foreach($polytomousKeyNode->children as &$child){
1038

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

    
1044
      $out .= '<tr class="childCount_' . $childCount . '">';
1045

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

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

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

    
1065
      // --- links to nodes taxa and subkeys
1066
      $out .= '<div class="nodeLink">';
1067

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

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

    
1078
      // link to one or many taxa
1079
      if($islinkToTaxon || $islinkToManyTaxa){
1080

    
1081
        if($islinkToManyTaxa){
1082
          $taxonChildren = $child->children;
1083
        } else {
1084
          $taxonChildren = array($child);
1085
        }
1086

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

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

    
1105
      }
1106

    
1107
      $out .= '</div>'; // end node link
1108
      $out .= '</td>'; // end edge
1109
      $out .= '</tr>';
1110

    
1111
    }
1112

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

    
1118
  }
1119
  return $out;
1120
}
1121

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

    
1131
  $keyList = _list_IdentificationKeys($type, $taxonUuid);
1132
  if(!$keyList || count ($keyList) == 0){
1133
    return;
1134
  }
1135

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

    
1147
  return $out;
1148
}
1149

    
1150
function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize = null){
1151

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