Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / theme / cdm_dataportal.descriptions.theme @ dc69d2dc

History | View | Annotate | Download (42.8 KB)

1
<?php
2
// $Id$
3

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

    
13

    
14
function theme_cdm_feature_nodesTOC($featureNodes){
15

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

    
18
  foreach($featureNodes as $node){
19

    
20
    if(hasFeatureNodeDescriptionElements($node)){
21

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

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

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

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

    
61

    
62

    
63
function theme_cdm_featureTreeTOCs($mergedTrees){
64

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

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

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

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

    
82

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

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

    
96
  foreach($mergedFeatureNodes as $node){
97

    
98
    if(hasFeatureNodeDescriptionElements($node)) {
99

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

    
103
      $media_list = array();
104

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

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

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

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

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

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

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

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

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

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

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

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

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

    
189
        }
190

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

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

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

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

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

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

    
220
function theme_FeatureTree_hierarchy($FeatureTreeUuid){
221

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

    
235
function theme_FeatureTree_hierarchy_children($node){
236

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

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

    
251

    
252

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

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

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

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

    
273

    
274
function theme_cdm_descriptionElement_CommonTaxonName($element){
275
  $out = '<span class="' .  html_class_atttibute_ref($element). '">' . $element->language->representation_L10n . ' (' . $element->area->titleCache . '): ' . $element->name .'</span>';
276
  return $out;
277
}
278

    
279

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

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

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

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

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

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

    
338
  return $out;
339
}
340

    
341

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

    
348

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

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

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

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

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

    
413
  $outArray = array();
414

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

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

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

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

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

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

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

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

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

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

    
491

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

    
495
  }
496

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

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

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

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

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

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

    
554
    }
555

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

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

    
567

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

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

    
577
  foreach($descriptionElements as $descriptionElement){
578

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
753

    
754

    
755

    
756

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

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

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

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

    
786
 }
787
 */
788

    
789

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

    
799
  $server = getEDITMapServiceURI();
800

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

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

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

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

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

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

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

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

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

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

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

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

    
859
    } else {
860

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

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

    
867
      $map_service_script_name = "areas.php";
868

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

    
884
        $map_service_script_name = "rest_gen.php";
885

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

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

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

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

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

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

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

    
927
      }
928

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

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

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

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

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

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

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

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

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

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

    
1011
function theme_cdm_polytomousKey(&$polytomousKey){
1012

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

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

    
1024
function theme_cdm_polytomousKey_linkedStyle_subgraph(&$polytomousKeyNode){
1025

    
1026
  static $statementCountCharacter = '\'';
1027

    
1028
  $out = "";
1029

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

    
1032
    $childCount = 0;
1033

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1103
      }
1104

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

    
1109
    }
1110

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

    
1116
  }
1117
  return $out;
1118
}
1119

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

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

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

    
1145
  return $out;
1146
}
1147

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

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