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
|
}
|
809
|
|
810
|
|
811
|
$fontStyles = array(0 => "plane", 1 => "italic");
|
812
|
|
813
|
// query cdm server for map service uri parameters
|
814
|
$map_data_parameters = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
|
815
|
$out .= "<!-- map_data_parameters:". print_r($map_data_parameters, true) . " -->";
|
816
|
$query_string = $map_data_parameters->String;
|
817
|
if(!$query_string){
|
818
|
// the $query_string is empty if there are no distribution areas defined
|
819
|
return ;
|
820
|
}
|
821
|
|
822
|
// some cleaning of the URI paramters, TODO is this still needed?
|
823
|
$query_string = str_replace('%3A', ":", $query_string);
|
824
|
|
825
|
|
826
|
/* ------ choose the display mode, either openlayers or static image ------ */
|
827
|
|
828
|
if(variable_get('cdm_dataportal_map_openlayers', 1)){
|
829
|
|
830
|
/* =========== display distributions using the openlayers map viewer =========== */
|
831
|
|
832
|
$legend_url_font_size = variable_get('cdm_dataportal_geoservice_legend_font_size', 10);
|
833
|
$legend_url_font_style = variable_get('cdm_dataportal_geoservice_legend_font_style', 1);
|
834
|
$legend_url_font_style = $fontStyles[$legend_url_font_style];
|
835
|
$legend_url_icon_width = variable_get('cdm_dataportal_geoservice_legend_icon_width', 35);
|
836
|
$legend_url_icon_height = variable_get('cdm_dataportal_geoservice_legend_icon_height', 15);
|
837
|
|
838
|
$legendFormatQueryStr = "format=image".urlencode('/')."png&TRANSPARENT=TRUE";
|
839
|
$legendFormatQueryStr .= "&WIDTH=".$legend_url_icon_width."&HEIGHT=".$legend_url_icon_height."&";
|
840
|
//TODO why is the layer=topp:tdwg_level_4 parameter neede at all here??
|
841
|
$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);
|
842
|
|
843
|
$out .= get_openlayers_map(
|
844
|
variable_get('cdm_dataportal_geoservice_display_width', 300),
|
845
|
variable_get('cdm_dataportal_geoservice_bounding_box', false),
|
846
|
null,
|
847
|
$query_string,
|
848
|
$legendFormatQueryStr,
|
849
|
variable_get('cdm_dataportal_geoservice_map_caption', '')
|
850
|
);
|
851
|
|
852
|
} else {
|
853
|
|
854
|
return get_image_map(
|
855
|
variable_get('cdm_dataportal_geoservice_display_width', 300),
|
856
|
variable_get('cdm_dataportal_geoservice_bounding_box', false),
|
857
|
null,
|
858
|
$query_string,
|
859
|
$legendFormatQueryStr,
|
860
|
variable_get('cdm_dataportal_geoservice_map_caption', '')
|
861
|
);
|
862
|
|
863
|
|
864
|
// simple image
|
865
|
$mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
|
866
|
|
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 (getEDITMapServiceVersionNumber() >= 1.1){
|
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
|
$childIndex = 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
|
/*
|
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
|
$hasQuestion = isset($polytomousKeyNode->question->label_l10n);
|
1057
|
$hasFeature = isset($polytomousKeyNode->feature);
|
1058
|
|
1059
|
//$indentEdge = $hasQuestion && $childIndex > 0;
|
1060
|
|
1061
|
// Question
|
1062
|
if($hasQuestion && $childIndex == 0){
|
1063
|
// place question, as extra table row
|
1064
|
$out .= '<tr class="question new_section">';
|
1065
|
$out .= '<td class="nodeNumber">'. uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber) . "</td>";
|
1066
|
$out .= '<td class="question">' . $polytomousKeyNode->question->label_l10n . '</td>';
|
1067
|
$out .= '</tr>';
|
1068
|
}
|
1069
|
|
1070
|
$out .= '<tr class="childCount_' . $childIndex . (!$hasQuestion && $childIndex == 0 ? ' new_section':''). '">';
|
1071
|
|
1072
|
if($hasQuestion){
|
1073
|
$out .= '<td class="nodeNumber"></td>';
|
1074
|
} else {
|
1075
|
$out .= '<td class="nodeNumber">'. uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childIndex , $statementCountCharacter)) . "</td>";
|
1076
|
}
|
1077
|
|
1078
|
$out .= '<td ' . RenderHints::getHtmlElementID($child) . ' class="edge'.($hasQuestion? ' edge-indent': '').'">';
|
1079
|
|
1080
|
// Feature
|
1081
|
if($hasFeature){
|
1082
|
$out .= $polytomousKeyNode->feature->representation_L10n . ": ";
|
1083
|
}
|
1084
|
|
1085
|
// Statement
|
1086
|
$out .= $child->statement->label_l10n;
|
1087
|
|
1088
|
// --- links to nodes taxa and subkeys
|
1089
|
$out .= '<div class="nodeLink">';
|
1090
|
|
1091
|
// link to a PolytomousKeyNode
|
1092
|
if($islinkToNode){
|
1093
|
$out .= '<div class="nodeLinkToNode">';
|
1094
|
if(is_object($child->modifyingText)){
|
1095
|
$out .= theme('cdm_poytomousKeyNode_modifyingText', $child->modifyingText);
|
1096
|
}
|
1097
|
$out .= l($child->nodeNumber, $_REQUEST["q"], null, null, $child->uuid) . '</div>';
|
1098
|
}
|
1099
|
|
1100
|
// link to a PolytomousKeyNode
|
1101
|
if($islinkToOtherNode){
|
1102
|
$out .= '<div class="nodeLinkToOtherNode">';
|
1103
|
if(is_object($child->modifyingText)){
|
1104
|
$out .= theme('cdm_poytomousKeyNode_modifyingText', $child->modifyingText);
|
1105
|
}
|
1106
|
$out .= l($child->otherNode->nodeNumber, $_REQUEST["q"], null, null, $child->otherNode->uuid) . '</div>';
|
1107
|
}
|
1108
|
|
1109
|
// link to one or many taxa
|
1110
|
if($islinkToTaxon || $islinkToManyTaxa){
|
1111
|
|
1112
|
if($islinkToManyTaxa){
|
1113
|
$taxonChildren = $child->children;
|
1114
|
} else {
|
1115
|
$taxonChildren = array($child);
|
1116
|
}
|
1117
|
|
1118
|
foreach($taxonChildren as $taxonChild){
|
1119
|
// TODO many taxa $child->children->taxon
|
1120
|
$out .= '<div class="nodeLinkToTaxon">';
|
1121
|
if(is_object($taxonChild->modifyingText)){
|
1122
|
$out .= theme('cdm_poytomousKeyNode_modifyingText', $taxonChild->modifyingText);
|
1123
|
}
|
1124
|
$out .= theme("cdm_taxonName", $taxonChild->taxon->name, url(path_to_taxon($taxonChild->taxon->uuid)));
|
1125
|
$out .= '</div>';
|
1126
|
}
|
1127
|
|
1128
|
// link to a subkey
|
1129
|
if($islinkToSubKey){
|
1130
|
$out .= '<div class="nodeLinkToSubkey">' . theme('cdm_IdentificationKey', $child->subkey) . '</div>';
|
1131
|
}
|
1132
|
|
1133
|
}
|
1134
|
|
1135
|
$out .= '</div>'; // end node link
|
1136
|
$out .= '</td>'; // end edge
|
1137
|
$out .= '</tr>';
|
1138
|
|
1139
|
$childIndex++;
|
1140
|
}
|
1141
|
|
1142
|
// recurse into child nodes
|
1143
|
foreach($polytomousKeyNode->children as &$child){
|
1144
|
$out .= theme('cdm_polytomousKey_linkedStyle_subgraph', $child);
|
1145
|
}
|
1146
|
|
1147
|
}
|
1148
|
|
1149
|
return $out;
|
1150
|
}
|
1151
|
|
1152
|
function theme_cdm_poytomousKeyNode_modifyingText($modifyingText){
|
1153
|
if(is_object($modifyingText)){
|
1154
|
$i = 0;
|
1155
|
foreach(get_object_vars($modifyingText) as $language=>$languageString){
|
1156
|
$out .= ($i++ > 0 ? ', ' : '') . '<span class="modifyingText">'. $languageString->text . '</span> ';
|
1157
|
}
|
1158
|
}
|
1159
|
return $out;
|
1160
|
}
|
1161
|
|
1162
|
/**
|
1163
|
* Renders a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
|
1164
|
* @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
|
1165
|
* valid values are : PolytomousKey, MediaKey, MultiAccessKey
|
1166
|
* @param $taxonUuid if given this parameter restrict the listed keys to
|
1167
|
* those which have the taxon identified be this uuid in scope.
|
1168
|
*/
|
1169
|
function theme_cdm_list_IdentificationKeys($type, $taxonUuid = null, $pageSize, $pageNumber){
|
1170
|
|
1171
|
$keyList = _list_IdentificationKeys($type, $taxonUuid);
|
1172
|
if(!$keyList || count ($keyList) == 0){
|
1173
|
return;
|
1174
|
}
|
1175
|
|
1176
|
RenderHints::pushToRenderStack('list_IdentificationKeys');
|
1177
|
$out = '<ul>';
|
1178
|
foreach ($keyList as $key){
|
1179
|
$out .= '<li>';
|
1180
|
$out .= theme('cdm_IdentificationKey', $key);
|
1181
|
$out .= '</li>';
|
1182
|
}
|
1183
|
$out .= '</ul>';
|
1184
|
$out .= theme("cdm_annotation_footnotes", RenderHints::getRenderPath());
|
1185
|
RenderHints::popFromRenderStack();
|
1186
|
|
1187
|
return $out;
|
1188
|
}
|
1189
|
|
1190
|
function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize = null){
|
1191
|
|
1192
|
static $types = array("PolytomousKey"=>"Polytomous", "MediaKey"=>"Media", "MultiAccessKey"=>"Multiaccess");
|
1193
|
RenderHints::pushToRenderStack('block_IdentificationKeys');
|
1194
|
$out = '';
|
1195
|
foreach($types as $type=>$label){
|
1196
|
$keylist = theme('cdm_list_IdentificationKeys', $type, $taxonUuid, $pageSize, $pageNumber);
|
1197
|
if(!$keylist){
|
1198
|
continue;
|
1199
|
}
|
1200
|
$out .= '<div class="'.$type.'">';
|
1201
|
$out .= '<h3>'.t($label)."</h3>";
|
1202
|
$out .= $keylist;
|
1203
|
$out .= '</div>';
|
1204
|
}
|
1205
|
RenderHints::popFromRenderStack();
|
1206
|
return $out;
|
1207
|
}
|