Project

General

Profile

Download (42.8 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
    // process $descriptionElements with content only
20
    if(is_array($node->descriptionElements) && count($node->descriptionElements) > 0 || count($node->children) > 0){
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

    
99
    // process $descriptionElements with content only
100
    if(is_array($node->descriptionElements) && count($node->descriptionElements) > 0 || count($node->children) > 0){
101

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

    
105
      $media_list = array();
106

    
107
      if($node->feature->uuid != UUID_IMAGE) {
108

    
109
        $block->delta = generalizeString($featureRepresentation);
110
        $block->subject = theme('cdm_feature_name', $featureRepresentation);
111
        $block->module = "cdm_dataportal-feature";
112
        $block->content = '';
113

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

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

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

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

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

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

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

    
170
             if (is_array($child->descriptionElements)){
171
               foreach ($child->descriptionElements as $element) {
172

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

    
178
                 $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
179
                //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)
180
                 $description = str_replace($element->feature->titleCache, '<em>' . $element->feature->titleCache . '</em>', $description);
181
               }
182
               $text .= " " . $description;
183
               $description = '';
184
             }
185

    
186
            }
187
            $block->content .= $text;
188
          }
189

    
190
        }
191

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

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

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

    
209
        // set anchor; FIXME put anchor in $block->subject
210
        $out .= '<a name="'.$block->delta.'"></a>';
211
        $out .= theme('block', $block);
212

    
213
      }
214
    }
215

    
216
  }
217
  RenderHints::popFromRenderStack();
218
  return $out;
219
}
220

    
221
function theme_FeatureTree_hierarchy($FeatureTreeUuid){
222

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

    
236
function theme_FeatureTree_hierarchy_children($node){
237

    
238
  $out = '';
239
  if($node->children){
240

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

    
252

    
253

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

    
266
  if($sortArray) sort($elementArray);
267

    
268
  $out .= join($elementArray, $glue);
269

    
270
  $out .= '</'.$enclosingHtml.'>';
271
  return $out;
272
}
273

    
274

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

    
280

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

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

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

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

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

    
319
      if ($asListElement){
320
        $out = '<li class="descriptionText">' . $name_used_in_source_link_to_show;
321
        //adding ":" if necesary
322
        if ($name_used_in_source_link_to_show && ($description || $sourceRefs)){
323
          $out .= ': ';
324
        }
325
        $out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', $element) . '</li>';
326
      }else{
327
        if ($name_used_in_source_link_to_show){
328
          $name_used_in_source_link_to_show = ' (name in source: '. $name_used_in_source_link_to_show . ')';
329
        }
330
        $out = $description . $sourceRefs . $name_used_in_source_link_to_show;
331
      }
332
    }
333
  }
334
  //if no sources, print the description
335
  if(!isset($out)) {
336
    $out = $description;
337
  }
338
  //printing annotations footnotes
339
  //$out .= theme('cdm_annotations_as_footnotekeys', $element);
340
  // add annotations as footnote key
341
  //$out .= theme('cdm_annotations_as_footnotekeys', $element); move above
342
  return $out;
343
}
344

    
345

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

    
352

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

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

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

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

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

    
417
  $outArray = array();
418

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

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

    
445
  $sortOutArray = false;
446
  $distributionElements = array();
447

    
448
  RenderHints::pushToRenderStack('cdm_descriptionElements');
449

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

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

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

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

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

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

    
495

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

    
499
  }
500

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

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

    
512
  RenderHints::popFromRenderStack();
513
  return $out;
514
}
515

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

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

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

    
558
    }
559

    
560
    RenderHints::popFromRenderStack();
561
    return $out;
562
}
563

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

    
571

    
572
	if(!$enclosingTag){
573
		$enclosingTag = "span";
574
	}
575

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

    
581
  foreach($descriptionElements as $descriptionElement){
582

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

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

    
603
  RenderHints::popFromRenderStack();
604
  return $out;
605
}
606

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

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

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

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

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

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

    
737
  RenderHints::popFromRenderStack();
738
  return $out;
739
}
740

    
741
function theme_cdm_DescriptionElementSource($descriptionElementSource, $doLink = TRUE){
742

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

    
749
function theme_cdm_IdentifieableSource($source, $doLink = TRUE){
750

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

    
757

    
758

    
759

    
760

    
761
/*
762
 function theme_cdm_descriptionElementDistribution($descriptionElements){
763

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

    
785
 $out = substr($out, 0, strlen($out)-strlen($separator) );
786

    
787
 RenderHints::popFromRenderStack();
788
 return $out;
789

    
790
 }
791
 */
792

    
793

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

    
803
  $server = getEDITMapServiceURI();
804

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

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

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

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

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

    
836
    /* ------ choose the display mode, either openlayers or static image ------ */
837

    
838
    if(variable_get('cdm_dataportal_map_openlayers', 1)){
839

    
840
      $query_string .= '&img=false';
841

    
842
      /* =========== display distributions using the openlayers map viewer =========== */
843

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

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

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

    
863
    } else {
864

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

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

    
871
      $map_service_script_name = "areas.php";
872

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

    
888
        $map_service_script_name = "rest_gen.php";
889

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

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

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

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

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

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

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

    
931
      }
932

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

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

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

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

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

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

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

    
988
function theme_cdm_IdentificationKey($identificationKey, $doLinkToKeyPage = true, $showIdentificationKeyTitle = true){
989

    
990
   $parentRenderPath = RenderHints::getRenderPath();
991
   RenderHints::pushToRenderStack("IdentificationKey");
992

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

    
1015
function theme_cdm_polytomousKey(&$polytomousKey){
1016

    
1017
  $keyStyle = "linkedStyle"; // TODO settings needed
1018

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

    
1028
function theme_cdm_polytomousKey_linkedStyle_subgraph(&$polytomousKeyNode){
1029

    
1030
  static $statementCountCharacter = '\'';
1031

    
1032
  $out = "";
1033

    
1034
  if(is_array($polytomousKeyNode->children)){
1035

    
1036
    $childCount = 0;
1037

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

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

    
1046
      $out .= '<tr class="childCount_' . $childCount . '">';
1047

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

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

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

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

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

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

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

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

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

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

    
1107
      }
1108

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

    
1113
    }
1114

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

    
1120
  }
1121
  return $out;
1122
}
1123

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

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

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

    
1149
  return $out;
1150
}
1151

    
1152
function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize = null){
1153

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