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
|
|
59
|
return $out;
|
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
|
//Creating an array to place the description elements in
|
96
|
|
97
|
foreach($mergedFeatureNodes as $node){
|
98
|
|
99
|
if(hasFeatureNodeDescriptionElements($node)) {
|
100
|
|
101
|
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
|
102
|
$block->module = 'cdm_dataportal';
|
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
|
|
209
|
|
210
|
// add anchor to subject
|
211
|
$block->subject = '<a name="'.$block->delta.'"></a>'. $block->subject;
|
212
|
|
213
|
|
214
|
$out .= theme('block', $block);
|
215
|
|
216
|
}
|
217
|
|
218
|
|
219
|
|
220
|
|
221
|
}
|
222
|
|
223
|
}
|
224
|
RenderHints::popFromRenderStack();
|
225
|
return $out;
|
226
|
}
|
227
|
|
228
|
function theme_FeatureTree_hierarchy($FeatureTreeUuid){
|
229
|
|
230
|
if(!is_uuid($FeatureTreeUuid)){
|
231
|
return;
|
232
|
}
|
233
|
$out = '';
|
234
|
$featureTree = cdm_ws_get(CDM_WS_FEATURETREE, array($FeatureTreeUuid));
|
235
|
if($featureTree && $featureTree->root){
|
236
|
$out = '<ul class="'.$featureTree->class.'">';
|
237
|
$out .= theme('FeatureTree_hierarchy_children', $featureTree->root);
|
238
|
$out .= '</ul>';
|
239
|
}
|
240
|
return $out;
|
241
|
}
|
242
|
|
243
|
function theme_FeatureTree_hierarchy_children($node){
|
244
|
|
245
|
$out = '';
|
246
|
if($node->children){
|
247
|
|
248
|
foreach($node->children as $childNode){
|
249
|
$out .= '<li>'.check_plain($childNode->feature->representation_L10n);
|
250
|
if($childNode->children && count($childNode->children) > 0){
|
251
|
$out .= '<ul>'.theme('FeatureTree_hierarchy_children', $childNode).'</ul>';
|
252
|
}
|
253
|
$out .= '</li>';
|
254
|
}
|
255
|
}
|
256
|
return $out;
|
257
|
}
|
258
|
|
259
|
|
260
|
|
261
|
/**
|
262
|
*
|
263
|
* Join the texts in $elementArray and enclose with a HTML tag
|
264
|
* @param unknown_type $elementArray
|
265
|
* @param unknown_type $feature the feature to which the elements given in $elementArray are belonging to
|
266
|
* @param unknown_type $glue defaults to empty string
|
267
|
* @param unknown_type $sortArray whether to sort the $elementArray alphabetically
|
268
|
* @param unknown_type $enclosingHtml
|
269
|
*/
|
270
|
function theme_cdm_descriptionElementArray($elementArray, $feature, $glue = '', $sortArray = false, $enclosingHtml = 'ul'){
|
271
|
$out = '<'.$enclosingHtml.' class="description" id="'.$feature->representation_L10n.'">';
|
272
|
|
273
|
if($sortArray) sort($elementArray);
|
274
|
|
275
|
$out .= join($elementArray, $glue);
|
276
|
|
277
|
$out .= '</'.$enclosingHtml.'>';
|
278
|
return $out;
|
279
|
}
|
280
|
|
281
|
|
282
|
function theme_cdm_descriptionElement_CommonTaxonName($element){
|
283
|
$out = '<span class="' . html_class_atttibute_ref($element). '">' . $element->language->representation_L10n . ' (' . $element->area->titleCache . '): ' . $element->name .'</span>';
|
284
|
return $out;
|
285
|
}
|
286
|
|
287
|
|
288
|
/**
|
289
|
* TODO: assign a new name to the function? because it is used for the citations
|
290
|
* textdata elements and not for all text data description elements
|
291
|
* @param $element The description element which contains the text information
|
292
|
* @param $asListElement A boolean which determines whether the citations should
|
293
|
* be renderer as a list or not
|
294
|
* @return unknown_type Html to be renderized in drupal
|
295
|
*/
|
296
|
function theme_cdm_descriptionElementTextData($element, $asListElement, $feature_uuid = null){
|
297
|
|
298
|
$description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
|
299
|
$sourceRefs = '';
|
300
|
$result = array();
|
301
|
$out;
|
302
|
$res_author;
|
303
|
$res_date;
|
304
|
|
305
|
if(is_array($element->sources)){
|
306
|
foreach($element->sources as $source){
|
307
|
$referenceCitation = theme('cdm_DescriptionElementSource', $source);
|
308
|
if($description && strlen($description) > 0 && $referenceCitation ){
|
309
|
$sourceRefs .= ' ('.$referenceCitation.')' ;
|
310
|
}else if ($referenceCitation){
|
311
|
$sourceRefs = $referenceCitation;
|
312
|
}
|
313
|
|
314
|
if(strlen($sourceRefs) > 0){
|
315
|
$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
|
316
|
}
|
317
|
|
318
|
if ($source->nameUsedInSource->uuid){ //do a link to name page
|
319
|
$name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache,
|
320
|
path_to_name($source->nameUsedInSource->uuid),
|
321
|
array(), NULL, NULL, FALSE ,TRUE);
|
322
|
}else if (strlen($source->nameUsedInSource->originalNameString) > 0){ //show a text without link
|
323
|
$name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
|
324
|
}
|
325
|
|
326
|
if ($asListElement){
|
327
|
$out = '<li class="descriptionText DescriptionElement">' . $name_used_in_source_link_to_show;
|
328
|
//adding ":" if necesary
|
329
|
if ($name_used_in_source_link_to_show && ($description || $sourceRefs)){
|
330
|
$out .= ': ';
|
331
|
}
|
332
|
$out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', $element, $feature_uuid) . '</li>';
|
333
|
}else{
|
334
|
if ($name_used_in_source_link_to_show){
|
335
|
$name_used_in_source_link_to_show = ' (name in source: '. $name_used_in_source_link_to_show . ')';
|
336
|
}
|
337
|
$out = '<span class="DescriptionElement DescriptionElement-' . $element->class .'">' . $description . $sourceRefs . $name_used_in_source_link_to_show . '</span>';
|
338
|
}
|
339
|
}
|
340
|
}
|
341
|
//if no sources, print the description
|
342
|
if(!isset($out)) {
|
343
|
$out = $description;
|
344
|
}
|
345
|
|
346
|
return $out;
|
347
|
}
|
348
|
|
349
|
|
350
|
function theme_cdm_common_names($elements){
|
351
|
$text_data_out = '';
|
352
|
$common_name_out = '';
|
353
|
$separator = ',';
|
354
|
$textData_commonNames = array();
|
355
|
|
356
|
|
357
|
if (is_array($elements)){
|
358
|
foreach ($elements as $element){
|
359
|
if ($element->class == 'CommonTaxonName'){
|
360
|
//$key = '<b>' . $element->language->representation_L10n . '</b> (' . $element->area->titleCache . ')';
|
361
|
if ($element->language->representation_L10n){
|
362
|
$key = '<b>' . $element->language->representation_L10n . '</b>';
|
363
|
$key .= (strlen($element->area->titleCache)>0) ? ' (' . $element->area->titleCache . ')' : '';
|
364
|
}
|
365
|
$common_names[$key][] = $element;
|
366
|
}else if ($element->class == 'TextData'){
|
367
|
//else if ($element->class == 'TextData' && $element->feature->uuid == UUID_COMMON_NAME){
|
368
|
$textData_commonNames[] = $element;
|
369
|
}
|
370
|
}
|
371
|
}
|
372
|
//handling common names
|
373
|
|
374
|
if (count($common_names) > 0){
|
375
|
//sorting the a-array based on the area (key)
|
376
|
ksort($common_names);
|
377
|
//creating the output to be render by drupal
|
378
|
foreach ($common_names as $key => $elements){
|
379
|
$rendered_element_list = '';
|
380
|
foreach($elements as $element){
|
381
|
$sourcesFootnoteKeyList = '';
|
382
|
// adding footnotes sources
|
383
|
foreach($element->sources as $source){
|
384
|
if(_is_original_source_type($source)){
|
385
|
$_fkey = FootnoteManager::addNewFootnote(UUID_COMMON_NAME, theme('cdm_DescriptionElementSource', $source, false));
|
386
|
$sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, ($sourcesFootnoteKeyList ? $separator : ''));
|
387
|
}
|
388
|
}
|
389
|
if($element->name){
|
390
|
$rendered_element_list .= '<span class="' . html_class_atttibute_ref($element). '">' . (strlen($rendered_element_list) > 0 ? ', ': '') . $element->name . $sourcesFootnoteKeyList . '</span>';
|
391
|
}
|
392
|
}
|
393
|
if ($key){
|
394
|
$common_name_out .= (strlen($common_name_out) > 0 ? '; ': '') . $key . ': ' . $rendered_element_list;
|
395
|
}else{
|
396
|
$common_name_out .= (strlen($common_name_out) > 0 ? '; ': '') . $rendered_element_list;
|
397
|
}
|
398
|
}
|
399
|
}
|
400
|
//handling commons names as text data
|
401
|
foreach($textData_commonNames as $text_data_element){
|
402
|
$text_data_out .= theme('cdm_descriptionElementTextData', $text_data_element, true, $text_data_element->feature->uuid);
|
403
|
}
|
404
|
|
405
|
$common_name_out = "<div class=common_names_as_common_names> $common_name_out </div>";
|
406
|
$out_array[] = $text_data_out;
|
407
|
$common_name_out_text_data = '<div class=common_names_as_text_data>' . theme('cdm_descriptionElementArray', $out_array, $element->feature) . '</div>';
|
408
|
|
409
|
return $common_name_out . $common_name_out_text_data;
|
410
|
//return $common_name_out . theme('cdm_descriptionElementArray', $out_array, $element->feature);
|
411
|
//return "<div class=common_names> $common_name_out $common_name_out_text_data";
|
412
|
}
|
413
|
|
414
|
/**
|
415
|
* Theme a list of description elements, usually of a specific feature type
|
416
|
* @param $descriptionElements
|
417
|
* @return unknown_type
|
418
|
*/
|
419
|
function theme_cdm_descriptionElements($descriptionElements, $featureUuid, $taxon_uuid){
|
420
|
|
421
|
$outArray = array();
|
422
|
|
423
|
/*
|
424
|
$userDefined = mixed_variable_get(LAYOUT_SETTING_PREFIX . $featureUuid, FEATURE_TREE_LAYOUT_DEFAULTS);
|
425
|
if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){
|
426
|
$glue = '';
|
427
|
$enclosingTag = 'dl';
|
428
|
$entryEnclosingTag = null;
|
429
|
} else if($userDefined && $userDefined['enabled']){
|
430
|
$glue = $userDefined['glue'];
|
431
|
$enclosingTag = $userDefined['enclosingTag'];
|
432
|
$entryEnclosingTag = $userDefined['entryEnclosingTag'];
|
433
|
} else {
|
434
|
// TODO remove once LAYOUT_SETTING_PREFIX-{uuid} seeting are confired to work for all portals (selenium test still missing!!!)
|
435
|
$glue = '';
|
436
|
$enclosingTag = 'ul';
|
437
|
$entryEnclosingTag = null ;
|
438
|
}
|
439
|
*/
|
440
|
|
441
|
if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){
|
442
|
$glue = '';
|
443
|
$enclosingTag = 'dl';
|
444
|
} else {
|
445
|
$glue = '';
|
446
|
$enclosingTag = 'ul';
|
447
|
}
|
448
|
|
449
|
$sortOutArray = false;
|
450
|
$distributionElements = array();
|
451
|
|
452
|
RenderHints::pushToRenderStack('cdm_descriptionElements');
|
453
|
|
454
|
if(is_array($descriptionElements)){//avoiding warning box in drupal for flora malesiana
|
455
|
foreach($descriptionElements as $descriptionElement) {
|
456
|
|
457
|
// --- DISTRIBUTION ---- //
|
458
|
if($descriptionElement->feature->uuid == UUID_DISTRIBUTION){
|
459
|
if($descriptionElement->class == 'Distribution'){
|
460
|
$sortKey = $descriptionElement->area->representation_L10n;
|
461
|
$distributionElements[$sortKey]= $descriptionElement;
|
462
|
} else if($descriptionElement->class == 'TextData'){
|
463
|
$asListElement = false;
|
464
|
$repr = theme ('cdm_descriptionElementTextData', $descriptionElement, $asListElement, $descriptionElement->feature->uuid);
|
465
|
|
466
|
if( !array_search($repr, $outArray)){
|
467
|
$outArray[] = $repr;
|
468
|
//TODO HINT: sorting in theme_cdm_descriptionElementArray will not work since this array contains html attributes with uuids !!!!
|
469
|
$sortOutArray = true;
|
470
|
$glue = '<br/> ';
|
471
|
$enclosingTag = 'p';
|
472
|
}
|
473
|
}
|
474
|
}
|
475
|
|
476
|
// --- IMAGE_SOURCES --- //
|
477
|
else if($descriptionElement->feature->uuid == UUID_IMAGE_SOURCES){
|
478
|
$image_sources[] = $descriptionElement;
|
479
|
}
|
480
|
|
481
|
// ---- class == TextData ---- //
|
482
|
else if($descriptionElement->class == 'TextData'){
|
483
|
$asListElement = true;
|
484
|
$outArray[] = theme('cdm_descriptionElementTextData', $descriptionElement, $asListElement, $descriptionElement->feature->uuid);
|
485
|
}else if ($descriptionElement->class == 'CommonTaxonName') {
|
486
|
$outArray[] = theme('cdm_descriptionElement_CommonTaxonName', $descriptionElement);
|
487
|
}else {
|
488
|
$outArray[] = '<li>No method for rendering unknown description class: '.$descriptionElement->classType.'</li>';
|
489
|
}
|
490
|
}
|
491
|
}
|
492
|
|
493
|
//if feature = NAME USAGE sort the list of sources
|
494
|
//this is ONLY for FLORA MALESIANA and FLORE d'AFRIQUE CENTRALE
|
495
|
if($descriptionElement->feature->uuid == UUID_NAME_USAGE){
|
496
|
sort($outArray);
|
497
|
}
|
498
|
|
499
|
|
500
|
if($image_sources){
|
501
|
$outArray[] = theme('cdm_description_element_image_source', $image_sources, true);
|
502
|
|
503
|
}
|
504
|
|
505
|
if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){
|
506
|
$outArray[] = theme('cdm_description_ordered_distributions', $taxon_uuid, $distributionElements);
|
507
|
}else{
|
508
|
ksort($distributionElements);
|
509
|
$outArray[] = theme('cdm_descriptionElementDistribution', $distributionElements); // TODO , $entryEnclosingTag);
|
510
|
}
|
511
|
|
512
|
// take the feature of the last $descriptionElement
|
513
|
$feature = $descriptionElement->feature;
|
514
|
$out = theme('cdm_descriptionElementArray', $outArray, $feature, $glue, $sortOutArray, $enclosingTag);
|
515
|
|
516
|
RenderHints::popFromRenderStack();
|
517
|
return $out;
|
518
|
}
|
519
|
|
520
|
|
521
|
|
522
|
/**
|
523
|
*
|
524
|
* Enter description here ...
|
525
|
* @param unknown_type $a
|
526
|
* @param unknown_type $b
|
527
|
*/
|
528
|
function compare_image_sources($a, $b){
|
529
|
if($a->multilanguageText_L10n->text == $b->multilanguageText_L10n->text){
|
530
|
return 0;
|
531
|
}
|
532
|
return ($a->multilanguageText_L10n->text < $b->multilanguageText_L10n->text) ? -1 : 1;
|
533
|
}
|
534
|
|
535
|
/**
|
536
|
*
|
537
|
*/
|
538
|
function theme_cdm_description_element_image_source($image_sources, $asListElement) {
|
539
|
$out = '';
|
540
|
$separator = ',';
|
541
|
RenderHints::pushToRenderStack('descriptionElementImageSource');
|
542
|
RenderHints::setFootnoteListKey(UUID_IMAGE_SOURCES);
|
543
|
|
544
|
//sorting the image sources
|
545
|
usort($image_sources, "compare_image_sources");
|
546
|
//generate the footnotes
|
547
|
foreach($image_sources as $image_source){
|
548
|
$footNoteKeys = cdm_annotations_as_footnotekeys($image_source);
|
549
|
foreach($image_source->sources as $source){
|
550
|
if(_is_original_source_type($source)){
|
551
|
$fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
|
552
|
cdm_add_footnote_to_array($footNoteKeys, $fn_key);// ensure uniqueness of the footnote keys
|
553
|
}
|
554
|
}
|
555
|
//sort and render footnote keys
|
556
|
$footnoteKeyListStr = '';
|
557
|
asort($footNoteKeys);
|
558
|
foreach($footNoteKeys as $footNoteKey){
|
559
|
$footnoteKeyListStr .= theme('cdm_footnote_key', $footNoteKey, ($footnoteKeyListStr ? $separator : ''));
|
560
|
}
|
561
|
//return value!
|
562
|
$out .= '<span class="descriptionElement descriptionElement-'.$image_source->uuid.'">'.$image_source->multilanguageText_L10n->text . $footnoteKeyListStr . '; </span>';
|
563
|
|
564
|
}
|
565
|
|
566
|
RenderHints::popFromRenderStack();
|
567
|
return $out;
|
568
|
}
|
569
|
|
570
|
/**
|
571
|
*
|
572
|
* @param unknown_type $descriptionElements
|
573
|
* @param String $enclosingTag
|
574
|
*/
|
575
|
function theme_cdm_descriptionElementDistribution($descriptionElements, $enclosingTag = "span"){
|
576
|
|
577
|
|
578
|
if(!$enclosingTag){
|
579
|
$enclosingTag = "span";
|
580
|
}
|
581
|
|
582
|
$out = '';
|
583
|
$separator = ',';
|
584
|
RenderHints::pushToRenderStack('descriptionElementDistribution');
|
585
|
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
|
586
|
|
587
|
foreach($descriptionElements as $descriptionElement){
|
588
|
|
589
|
// annotations as footnotes
|
590
|
$footNoteKeys = cdm_annotations_as_footnotekeys($descriptionElement);
|
591
|
// source references as footnotes
|
592
|
foreach($descriptionElement->sources as $source){
|
593
|
if(_is_original_source_type($source)){
|
594
|
$fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
|
595
|
cdm_add_footnote_to_array($footNoteKeys, $fn_key);// ensure uniqueness of the footnote keys
|
596
|
}
|
597
|
}
|
598
|
// sort and render footnote keys
|
599
|
$footnoteKeyListStr = '';
|
600
|
asort($footNoteKeys);
|
601
|
foreach($footNoteKeys as $footNoteKey){
|
602
|
$footnoteKeyListStr .= theme('cdm_footnote_key', $footNoteKey, ($footnoteKeyListStr ? $separator : ''));
|
603
|
}
|
604
|
|
605
|
$out .= '<'. $enclosingTag .' class="descriptionElement descriptionElement-'.$descriptionElement->uuid.'">'
|
606
|
. $descriptionElement->area->representation_L10n . $footnoteKeyListStr . ' </'. $enclosingTag .'>';
|
607
|
}
|
608
|
|
609
|
RenderHints::popFromRenderStack();
|
610
|
return $out;
|
611
|
}
|
612
|
|
613
|
/**
|
614
|
* Function target is to compare two different foootnotes objects.
|
615
|
* The comparation is based on the footnote key. The one which is
|
616
|
* displayed as footnote number.
|
617
|
*
|
618
|
* @param footnote object $a
|
619
|
* @param footnote object $b
|
620
|
*/
|
621
|
function footnotes_key_compare($a, $b){
|
622
|
$res = 0;
|
623
|
if ($a->keyStr < $b->keyStr){
|
624
|
$res = -1;
|
625
|
}elseif ($a->keyStr > $b->keyStr){
|
626
|
$res = 1;
|
627
|
}
|
628
|
return $res;
|
629
|
}
|
630
|
|
631
|
function theme_cdm_description_ordered_distributions($taxon_uuid, $descriptionElements){
|
632
|
//returning null if no description elements
|
633
|
if ($descriptionElements == null){
|
634
|
return '';
|
635
|
}
|
636
|
//initialization some variables
|
637
|
$out = '';
|
638
|
$separator = ',';
|
639
|
RenderHints::pushToRenderStack('descriptionElementDistribution');
|
640
|
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
|
641
|
//getting all the taxon description for a given taxon
|
642
|
$markerTypesEmpty = array();
|
643
|
//$markerTypesEmpty['markerTypes'] = 'af9860ff-08f5-4b4d-863c-49ae96985115';
|
644
|
$markerTypesEmpty['markerTypes'] = '';
|
645
|
$taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon_uuid, queryString($markerTypesEmpty));
|
646
|
foreach ($taxonDescriptions as $description){
|
647
|
$descriptions_uuids[] = $description->uuid;
|
648
|
}
|
649
|
//getting the sortered distributions (omiting level ??)
|
650
|
$request_params = array();
|
651
|
$request_params['omitLevels'] = UUID_NAMEDAREALEVEL_TDWGLEVEL_2;
|
652
|
$ordered_areas = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION_DISTRIBUTION_TREE, join(',',$descriptions_uuids), queryString($request_params));
|
653
|
$ordered_areas = $ordered_areas->rootElement->children;
|
654
|
|
655
|
//printing the distributions
|
656
|
foreach ($ordered_areas as $element_level1){
|
657
|
//level1
|
658
|
if ($element_level1->data){
|
659
|
$out .= '<dt>' . $element_level1->data->area->representation_L10n . ':</dt> ';
|
660
|
}
|
661
|
$out .= '<dd>';
|
662
|
|
663
|
//level3
|
664
|
foreach ($element_level1->children as $element_level3){
|
665
|
if ($element_level3->data){
|
666
|
$text_l3 = $element_level3->data->area->representation_L10n;
|
667
|
}
|
668
|
$fnKeysLevel3Str = '';
|
669
|
$fnKeysLevel3 = cdm_annotations_as_footnotekeys($element_level3->data);
|
670
|
foreach($element_level3->data->sources as $source){
|
671
|
if(_is_original_source_type($source)){
|
672
|
$fn_key3 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
|
673
|
cdm_add_footnote_to_array($fnKeysLevel3, $fn_key3);
|
674
|
}
|
675
|
}
|
676
|
//level4
|
677
|
$l4_regions = array();
|
678
|
foreach ($element_level3->children as $element_level4){
|
679
|
if ($element_level4->data){
|
680
|
$text_l4 = $element_level4->data->area->representation_L10n;
|
681
|
$l4_regions[$element_level3->data->area->representation_L10n] = '';
|
682
|
$fnKeysLevel4Str = '';
|
683
|
$fnKeysLevel4 = cdm_annotations_as_footnotekeys($element_level4->data);
|
684
|
foreach($element_level4->data->sources as $source){
|
685
|
if(_is_original_source_type($source)){
|
686
|
$fn_key4 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
|
687
|
cdm_add_footnote_to_array($fnKeysLevel4, $fn_key4);
|
688
|
}
|
689
|
}
|
690
|
usort($fnKeysLevel4, "footnotes_key_compare");
|
691
|
$l4_regions[$text_l4] = $fnKeysLevel4;
|
692
|
}
|
693
|
}//level4
|
694
|
//managing level3 and level4 for generating the right output
|
695
|
usort($fnKeysLevel3, "footnotes_key_compare");
|
696
|
foreach ($fnKeysLevel3 as $key3){
|
697
|
foreach ($l4_regions as $key4 => $value4){
|
698
|
cdm_add_footnote_to_array($l4_regions[$key4], $key3);
|
699
|
}
|
700
|
}
|
701
|
if ($element_level3->numberOfChildren == 1 &&
|
702
|
$text_l3 == $element_level3->children[0]->data->area->representation_L10n){
|
703
|
//var_dump($element_level3->children[0]->data->area->representation_L10n);
|
704
|
$fnStr = '';
|
705
|
$region = array_pop($l4_regions);
|
706
|
foreach($region as $key){
|
707
|
$fnStr .= theme('cdm_footnote_key', $key, ($fnStr ? $separator : ''));
|
708
|
}
|
709
|
$out .= "$text_l3 $fnStr; ";
|
710
|
//removing whitespaces when &fnStr is empty
|
711
|
if(substr($out, -3) == ' ; '){
|
712
|
$out = substr($out, 0, -3) . '; ';
|
713
|
}
|
714
|
}else{
|
715
|
$fnKeysLevel3Str = '';
|
716
|
foreach($fnKeysLevel3 as $key){
|
717
|
$fnKeysLevel3Str .= theme('cdm_footnote_key', $key, ($fnKeysLevel3Str ? $separator : ''));
|
718
|
}
|
719
|
$text_l4_aux = '';
|
720
|
foreach ($l4_regions as $key => $value){
|
721
|
$fnKeysLevel4Str = '';
|
722
|
if (is_array($l4_regions[$key])) {
|
723
|
foreach ($l4_regions[$key] as $fnkey){//warning why?
|
724
|
$fnKeysLevel4Str .= theme('cdm_footnote_key', $fnkey, ($fnKeysLevel4Str ? $separator : ''));
|
725
|
}
|
726
|
}
|
727
|
//if ($key != $text_l3 || sizeof($l4_regions > 1)){
|
728
|
if ($key != $text_l3){
|
729
|
$text_l4_aux .= "$key $fnKeysLevel4Str, ";
|
730
|
}
|
731
|
}
|
732
|
$text_l4_aux = substr($text_l4_aux, 0, -2);
|
733
|
|
734
|
if (strlen($text_l4_aux) > 0){
|
735
|
$out .= "$text_l3 $fnKeysLevel3Str ($text_l4_aux); ";
|
736
|
}else{
|
737
|
$out .= "$text_l3 $fnKeysLevel3Str; ";
|
738
|
}
|
739
|
|
740
|
}
|
741
|
}//level3
|
742
|
$out = substr($out, 0, -2);
|
743
|
$out .= '.</dd>';
|
744
|
}//level1
|
745
|
|
746
|
RenderHints::popFromRenderStack();
|
747
|
return $out;
|
748
|
}
|
749
|
|
750
|
function theme_cdm_DescriptionElementSource($descriptionElementSource, $doLink = TRUE){
|
751
|
|
752
|
if(isset($descriptionElementSource->citation)){
|
753
|
$out = theme('cdm_reference', $descriptionElementSource->citation, $descriptionElementSource->citationMicroReference, $doLink);
|
754
|
}
|
755
|
return $out;
|
756
|
}
|
757
|
|
758
|
function theme_cdm_IdentifieableSource($source, $doLink = TRUE){
|
759
|
|
760
|
if(isset($source->citation)){
|
761
|
$out = theme('cdm_reference', $source->citation, $source->citationMicroReference, $doLink);
|
762
|
}
|
763
|
return $out;
|
764
|
}
|
765
|
|
766
|
|
767
|
|
768
|
|
769
|
|
770
|
/*
|
771
|
function theme_cdm_descriptionElementDistribution($descriptionElements){
|
772
|
|
773
|
$out = '';
|
774
|
$separator = ',';
|
775
|
RenderHints::pushToRenderStack('descriptionElementDistribution');
|
776
|
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
|
777
|
foreach($descriptionElements as $descriptionElement){
|
778
|
// annotations as footnotes
|
779
|
$annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys', $descriptionElement);
|
780
|
// source references as footnotes
|
781
|
$sourcesFootnoteKeyList = '';
|
782
|
foreach($descriptionElement->sources as $source){
|
783
|
if(_is_original_source_type($source)){
|
784
|
$_fkey = FootnoteManager::addNewFootnote(UUID_DISTRIBUTION, theme('cdm_DescriptionElementSource', $source, false));
|
785
|
$sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, UUID_DISTRIBUTION, ($sourcesFootnoteKeyList ? $separator : ''));
|
786
|
}
|
787
|
}
|
788
|
if($annotationFootnoteKeys && $sourcesFootnoteKeyList){
|
789
|
$annotationFootnoteKeys .= $separator;
|
790
|
}
|
791
|
$out .= $descriptionElement->area->representation_L10n . $annotationFootnoteKeys . $sourcesFootnoteKeyList . ' ';
|
792
|
}
|
793
|
|
794
|
$out = substr($out, 0, strlen($out)-strlen($separator) );
|
795
|
|
796
|
RenderHints::popFromRenderStack();
|
797
|
return $out;
|
798
|
|
799
|
}
|
800
|
*/
|
801
|
|
802
|
|
803
|
/**
|
804
|
* TODO
|
805
|
* Quick-and-dirty solution to show distribution service to exemplar groups
|
806
|
*
|
807
|
* @param unknown_type $featureTo
|
808
|
* @return unknown
|
809
|
*/
|
810
|
function theme_cdm_distribution_map($taxon){
|
811
|
|
812
|
$server = getEDITMapServiceURI();
|
813
|
|
814
|
if(!$server){
|
815
|
//warning message
|
816
|
drupal_set_message('No \'Geoservice Access Point\' has been set so far. '
|
817
|
. 'Please configure the variable \'Geoservice Access Point\' here '
|
818
|
. l('CDM Dataportal Settings', 'admin/settings/cdm_dataportal/geo'), 'warning');
|
819
|
//message to render
|
820
|
return "<p>No geoservice specified</p>";
|
821
|
}
|
822
|
|
823
|
|
824
|
$fontStyles = array(0 => "plane", 1 => "italic");
|
825
|
|
826
|
// query cdm server for map service uri parameters
|
827
|
$map_data_parameters = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
|
828
|
$out .= "<!-- map_data_parameters:". print_r($map_data_parameters, true) . " -->";
|
829
|
$query_string = $map_data_parameters->String;
|
830
|
if(!$query_string){
|
831
|
// the $query_string is empty if there are no distribution areas defined
|
832
|
return ;
|
833
|
}
|
834
|
|
835
|
// some cleaning of the URI paramters, TODO is this still needed?
|
836
|
$query_string = str_replace('%3A', ":", $query_string);
|
837
|
|
838
|
|
839
|
/* ------ choose the display mode, either openlayers or static image ------ */
|
840
|
|
841
|
if(variable_get('cdm_dataportal_map_openlayers', 1)){
|
842
|
|
843
|
/* =========== display distributions using the openlayers map viewer =========== */
|
844
|
|
845
|
$legend_url_font_size = variable_get('cdm_dataportal_geoservice_legend_font_size', 10);
|
846
|
$legend_url_font_style = variable_get('cdm_dataportal_geoservice_legend_font_style', 1);
|
847
|
$legend_url_font_style = $fontStyles[$legend_url_font_style];
|
848
|
$legend_url_icon_width = variable_get('cdm_dataportal_geoservice_legend_icon_width', 35);
|
849
|
$legend_url_icon_height = variable_get('cdm_dataportal_geoservice_legend_icon_height', 15);
|
850
|
|
851
|
$legendFormatQueryStr = "format=image".urlencode('/')."png&TRANSPARENT=TRUE";
|
852
|
$legendFormatQueryStr .= "&WIDTH=".$legend_url_icon_width."&HEIGHT=".$legend_url_icon_height."&";
|
853
|
//TODO why is the layer=topp:tdwg_level_4 parameter neede at all here??
|
854
|
$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);
|
855
|
|
856
|
$out .= get_openlayers_map(
|
857
|
variable_get('cdm_dataportal_geoservice_display_width', 300),
|
858
|
variable_get('cdm_dataportal_geoservice_bounding_box', false),
|
859
|
null,
|
860
|
$query_string,
|
861
|
$legendFormatQueryStr,
|
862
|
variable_get('cdm_dataportal_geoservice_map_caption', '')
|
863
|
);
|
864
|
|
865
|
} else {
|
866
|
|
867
|
return get_image_map(
|
868
|
variable_get('cdm_dataportal_geoservice_display_width', 300),
|
869
|
variable_get('cdm_dataportal_geoservice_bounding_box', false),
|
870
|
null,
|
871
|
$query_string,
|
872
|
$legendFormatQueryStr,
|
873
|
variable_get('cdm_dataportal_geoservice_map_caption', '')
|
874
|
);
|
875
|
|
876
|
|
877
|
// simple image
|
878
|
$mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
|
879
|
|
880
|
|
881
|
$query_string .= '&img=true';
|
882
|
$query_string .= '&legend=1&mlp=3' . $mapStaticCaption . '&recalculate=false';
|
883
|
|
884
|
$map_service_script_name = "areas.php";
|
885
|
|
886
|
// apply Plain Image map settings
|
887
|
if (getEDITMapServiceVersionNumber() >= 1.1){
|
888
|
/*
|
889
|
* example : title=a:Naturalized++non-invasive
|
890
|
* &ad=cyprusdivs:bdcode:a:5&as=a:ff9900,,0.1,&l=tdwg4
|
891
|
* &ms=500&bbox=32,34,35,36&img=true&legend=1&mlp=3
|
892
|
* &mc_s=Georgia,15,blue&mc=&recalculate=false
|
893
|
*
|
894
|
* http://edit.br.fgov.be/edit_wp5/v1/rest_gen.php?
|
895
|
* l=background_gis:b,cyprusdivs&ad=cyprusdivs%3Abdcode%3Aa%3A8%2C4
|
896
|
* &as=a%3A339966%2C%2C0.1%2C|b:0000ff,,
|
897
|
* &bbox=32%2C34%2C35%2C36&img=true&legend=1&mc=&mc_s=Georgia%2C15%2Cblue
|
898
|
* &mlp=3&ms=500&recalculate=false&title=a%3Aindigenous
|
899
|
*/
|
900
|
|
901
|
$map_service_script_name = "rest_gen.php";
|
902
|
|
903
|
$bgcolor_areaStyleId= "y";
|
904
|
$baselayer_areaStyleId= "z";
|
905
|
$bgcolor_layer='';
|
906
|
$additional_area_styles = array();
|
907
|
|
908
|
// background color:
|
909
|
if(variable_get('map_bg_color', '')){
|
910
|
$bgcolor_layer = "background_gis:".$bgcolor_areaStyleId;
|
911
|
$additional_area_styles[] = $bgcolor_areaStyleId . ":" . variable_get('map_bg_color', '') . ",,";
|
912
|
}
|
913
|
|
914
|
//TODO HACK to replace the default base layer which currently is tdwg4 !!!
|
915
|
if(strpos($query_string, "?l=") !== FALSE){
|
916
|
$layer_param_token = "?l=";
|
917
|
} else {
|
918
|
$layer_param_token = "&l=";
|
919
|
}
|
920
|
if(strpos($query_string, "?as=") !== FALSE){
|
921
|
$areystyle_param_token = "?as=";
|
922
|
} else {
|
923
|
$areystyle_param_token = "&as=";
|
924
|
}
|
925
|
|
926
|
if(variable_get('map_base_layer', '')){
|
927
|
$query_string = str_replace($layer_param_token."tdwg4", "$layer_param_token".variable_get('map_base_layer', ''). ":" . $baselayer_areaStyleId, $query_string);
|
928
|
} else {
|
929
|
$query_string = str_replace($layer_param_token."tdwg4", $layer_param_token."tdwg4:".$baselayer_areaStyleId . ",", $query_string);
|
930
|
}
|
931
|
|
932
|
if($bgcolor_layer){
|
933
|
$query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
|
934
|
}
|
935
|
|
936
|
if(variable_get('map_base_layer_style', '')){
|
937
|
$additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
|
938
|
}
|
939
|
|
940
|
foreach ($additional_area_styles as $as) {
|
941
|
$query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
|
942
|
}
|
943
|
|
944
|
}
|
945
|
|
946
|
$mapUri = url("$server/$map_service_script_name?$query_string");
|
947
|
$out .= '<img class="distribution_map" src="' . $mapUri . '" alt="Distribution Map" />';
|
948
|
}
|
949
|
return $out;
|
950
|
|
951
|
}
|
952
|
|
953
|
/**
|
954
|
* Returns a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
|
955
|
* @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
|
956
|
* valid values are : PolytomousKey, MediaKey, MultiAccessKey
|
957
|
* @param $taxonUuid if given this parameter restrict the listed keys to
|
958
|
* those which have the taxon identified be this uuid in scope.
|
959
|
*/
|
960
|
function _list_IdentificationKeys($type, $taxonUuid = null, $pageSize = null, $pageNumber = null){
|
961
|
|
962
|
if(!$type){
|
963
|
drupal_set_message("Type parameter is missing", "error");
|
964
|
return;
|
965
|
}
|
966
|
$cdm_ws_pasepath = null;
|
967
|
switch($type){
|
968
|
case "PolytomousKey" : $cdm_ws_pasepath = CDM_WS_POLYTOMOUSKEY; break;
|
969
|
case "MediaKey" : $cdm_ws_pasepath = CDM_WS_MEDIAKEY; break;
|
970
|
case "MultiAccessKey" : $cdm_ws_pasepath = CDM_WS_MULTIACCESSKEY; break;
|
971
|
}
|
972
|
|
973
|
if(!$cdm_ws_pasepath){
|
974
|
drupal_set_message("Type parameter is not valid: ".$type, "error");
|
975
|
}
|
976
|
|
977
|
$queryParameters = '';
|
978
|
if(is_numeric($pageSize)){
|
979
|
$queryParameters = "pageSize=".$pageSize;
|
980
|
} else {
|
981
|
$queryParameters = "pageSize=0";
|
982
|
}
|
983
|
|
984
|
if(is_numeric($pageNumber)){
|
985
|
$queryParameters = "pageNumber=".$pageNumber;
|
986
|
} else {
|
987
|
$queryParameters = "pageNumber=0";
|
988
|
}
|
989
|
$queryParameters = null;
|
990
|
if($taxonUuid){
|
991
|
$queryParameters = "findByTaxonomicScope=$taxonUuid";
|
992
|
}
|
993
|
$pager = cdm_ws_get($cdm_ws_pasepath, null, $queryParameters);
|
994
|
|
995
|
if(!$pager || $pager->count == 0){
|
996
|
return array();
|
997
|
}
|
998
|
return $pager->records;
|
999
|
}
|
1000
|
|
1001
|
function theme_cdm_IdentificationKey($identificationKey, $doLinkToKeyPage = true, $showIdentificationKeyTitle = true){
|
1002
|
|
1003
|
$parentRenderPath = RenderHints::getRenderPath();
|
1004
|
RenderHints::pushToRenderStack("IdentificationKey");
|
1005
|
|
1006
|
if($showIdentificationKeyTitle){
|
1007
|
if($doLinkToKeyPage) {
|
1008
|
$out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid));
|
1009
|
} else {
|
1010
|
$out = $identificationKey->titleCache;
|
1011
|
}
|
1012
|
}
|
1013
|
if(is_array($identificationKey->sources)){
|
1014
|
// display sources
|
1015
|
$i = 0;
|
1016
|
$out .= '<div>';
|
1017
|
foreach($identificationKey->sources as $source){
|
1018
|
$out .= ($i++ > 0 ? ', ' : '' ) . theme("cdm_IdentifieableSource", $source);
|
1019
|
}
|
1020
|
$out .= '</div>';
|
1021
|
}
|
1022
|
// display annotations
|
1023
|
$out .= theme('cdm_annotations', cdm_ws_getAnnotationsFor($identificationKey), 'div');
|
1024
|
RenderHints::popFromRenderStack();
|
1025
|
return $out;
|
1026
|
}
|
1027
|
|
1028
|
function theme_cdm_polytomousKey(&$polytomousKey){
|
1029
|
|
1030
|
$keyStyle = "linkedStyle"; // TODO settings needed
|
1031
|
|
1032
|
RenderHints::pushToRenderStack("polytomousKey");
|
1033
|
// key nodes in linked style
|
1034
|
$out = '<table class="polytomousKey polytomousKey_'.$keyStyle.'">';
|
1035
|
$out .= theme('cdm_polytomousKey_'.$keyStyle.'_subgraph', $polytomousKey->root);
|
1036
|
$out .= '</table>';
|
1037
|
RenderHints::popFromRenderStack();
|
1038
|
return $out;
|
1039
|
}
|
1040
|
|
1041
|
function theme_cdm_polytomousKey_linkedStyle_subgraph(&$polytomousKeyNode){
|
1042
|
|
1043
|
static $statementCountCharacter = '\'';
|
1044
|
|
1045
|
$out = "";
|
1046
|
|
1047
|
if(is_array($polytomousKeyNode->children)){
|
1048
|
|
1049
|
$childIndex = 0;
|
1050
|
|
1051
|
// render edges of the current node
|
1052
|
foreach($polytomousKeyNode->children as &$child){
|
1053
|
|
1054
|
if(!isset($child->statement)){
|
1055
|
// skip node with empty statements (see below for explanation: "Special case")
|
1056
|
continue;
|
1057
|
}
|
1058
|
|
1059
|
/*
|
1060
|
* Special case:
|
1061
|
* Child nodes with empty statements but taxa as leaf are to
|
1062
|
* treated as if all those taxa where direct children of the source node.
|
1063
|
*/
|
1064
|
$islinkToManyTaxa = !isset($child->children[0]->statement) && isset($child->children[0]->taxon->uuid);
|
1065
|
$islinkToTaxon = isset($child->taxon->uuid);
|
1066
|
$islinkToSubKey = isset($child->subkey->uuid);
|
1067
|
$islinkToOtherNode = isset($child->otherNode);
|
1068
|
$islinkToNode = $child->nodeNumber && !$islinkToManyTaxa && !$islinkToOtherNode; // either null or 0
|
1069
|
$hasQuestion = isset($polytomousKeyNode->question->label_l10n);
|
1070
|
$hasFeature = isset($polytomousKeyNode->feature);
|
1071
|
|
1072
|
//$indentEdge = $hasQuestion && $childIndex > 0;
|
1073
|
|
1074
|
// Question
|
1075
|
if($hasQuestion && $childIndex == 0){
|
1076
|
// place question, as extra table row
|
1077
|
$out .= '<tr class="question new_section">';
|
1078
|
$out .= '<td class="nodeNumber">'. uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber) . "</td>";
|
1079
|
$out .= '<td class="question">' . $polytomousKeyNode->question->label_l10n . '</td>';
|
1080
|
$out .= '</tr>';
|
1081
|
}
|
1082
|
|
1083
|
$out .= '<tr class="childCount_' . $childIndex . (!$hasQuestion && $childIndex == 0 ? ' new_section':''). '">';
|
1084
|
|
1085
|
if($hasQuestion){
|
1086
|
$out .= '<td class="nodeNumber"></td>';
|
1087
|
} else {
|
1088
|
$out .= '<td class="nodeNumber">'. uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childIndex , $statementCountCharacter)) . "</td>";
|
1089
|
}
|
1090
|
|
1091
|
$out .= '<td ' . RenderHints::getHtmlElementID($child) . ' class="edge'.($hasQuestion? ' edge-indent': '').'">';
|
1092
|
|
1093
|
// Feature
|
1094
|
if($hasFeature){
|
1095
|
$out .= $polytomousKeyNode->feature->representation_L10n . ": ";
|
1096
|
}
|
1097
|
|
1098
|
// Statement
|
1099
|
$out .= $child->statement->label_l10n;
|
1100
|
|
1101
|
// --- links to nodes taxa and subkeys
|
1102
|
$out .= '<div class="nodeLink">';
|
1103
|
|
1104
|
// link to a PolytomousKeyNode
|
1105
|
if($islinkToNode){
|
1106
|
$out .= '<div class="nodeLinkToNode">';
|
1107
|
if(is_object($child->modifyingText)){
|
1108
|
$out .= theme('cdm_poytomousKeyNode_modifyingText', $child->modifyingText);
|
1109
|
}
|
1110
|
$out .= l($child->nodeNumber, $_REQUEST["q"], null, null, $child->uuid) . '</div>';
|
1111
|
}
|
1112
|
|
1113
|
// link to a PolytomousKeyNode
|
1114
|
if($islinkToOtherNode){
|
1115
|
$out .= '<div class="nodeLinkToOtherNode">';
|
1116
|
if(is_object($child->modifyingText)){
|
1117
|
$out .= theme('cdm_poytomousKeyNode_modifyingText', $child->modifyingText);
|
1118
|
}
|
1119
|
$out .= l($child->otherNode->nodeNumber, $_REQUEST["q"], null, null, $child->otherNode->uuid) . '</div>';
|
1120
|
}
|
1121
|
|
1122
|
// link to one or many taxa
|
1123
|
if($islinkToTaxon || $islinkToManyTaxa){
|
1124
|
|
1125
|
if($islinkToManyTaxa){
|
1126
|
$taxonChildren = $child->children;
|
1127
|
} else {
|
1128
|
$taxonChildren = array($child);
|
1129
|
}
|
1130
|
|
1131
|
foreach($taxonChildren as $taxonChild){
|
1132
|
// TODO many taxa $child->children->taxon
|
1133
|
$out .= '<div class="nodeLinkToTaxon">';
|
1134
|
if(is_object($taxonChild->modifyingText)){
|
1135
|
$out .= theme('cdm_poytomousKeyNode_modifyingText', $taxonChild->modifyingText);
|
1136
|
}
|
1137
|
$out .= theme("cdm_taxonName", $taxonChild->taxon->name, url(path_to_taxon($taxonChild->taxon->uuid)));
|
1138
|
$out .= '</div>';
|
1139
|
}
|
1140
|
|
1141
|
// link to a subkey
|
1142
|
if($islinkToSubKey){
|
1143
|
$out .= '<div class="nodeLinkToSubkey">' . theme('cdm_IdentificationKey', $child->subkey) . '</div>';
|
1144
|
}
|
1145
|
|
1146
|
}
|
1147
|
|
1148
|
$out .= '</div>'; // end node link
|
1149
|
$out .= '</td>'; // end edge
|
1150
|
$out .= '</tr>';
|
1151
|
|
1152
|
$childIndex++;
|
1153
|
}
|
1154
|
|
1155
|
// recurse into child nodes
|
1156
|
foreach($polytomousKeyNode->children as &$child){
|
1157
|
$out .= theme('cdm_polytomousKey_linkedStyle_subgraph', $child);
|
1158
|
}
|
1159
|
|
1160
|
}
|
1161
|
|
1162
|
return $out;
|
1163
|
}
|
1164
|
|
1165
|
function theme_cdm_poytomousKeyNode_modifyingText($modifyingText){
|
1166
|
if(is_object($modifyingText)){
|
1167
|
$i = 0;
|
1168
|
foreach(get_object_vars($modifyingText) as $language=>$languageString){
|
1169
|
$out .= ($i++ > 0 ? ', ' : '') . '<span class="modifyingText">'. $languageString->text . '</span> ';
|
1170
|
}
|
1171
|
}
|
1172
|
return $out;
|
1173
|
}
|
1174
|
|
1175
|
/**
|
1176
|
* Renders a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
|
1177
|
* @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
|
1178
|
* valid values are : PolytomousKey, MediaKey, MultiAccessKey
|
1179
|
* @param $taxonUuid if given this parameter restrict the listed keys to
|
1180
|
* those which have the taxon identified be this uuid in scope.
|
1181
|
*/
|
1182
|
function theme_cdm_list_IdentificationKeys($type, $taxonUuid = null, $pageSize, $pageNumber){
|
1183
|
|
1184
|
$keyList = _list_IdentificationKeys($type, $taxonUuid);
|
1185
|
if(!$keyList || count ($keyList) == 0){
|
1186
|
return;
|
1187
|
}
|
1188
|
|
1189
|
RenderHints::pushToRenderStack('list_IdentificationKeys');
|
1190
|
$out = '<ul>';
|
1191
|
foreach ($keyList as $key){
|
1192
|
$out .= '<li>';
|
1193
|
$out .= theme('cdm_IdentificationKey', $key);
|
1194
|
$out .= '</li>';
|
1195
|
}
|
1196
|
$out .= '</ul>';
|
1197
|
$out .= theme("cdm_annotation_footnotes", RenderHints::getRenderPath());
|
1198
|
RenderHints::popFromRenderStack();
|
1199
|
|
1200
|
return $out;
|
1201
|
}
|
1202
|
|
1203
|
function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize = null){
|
1204
|
|
1205
|
static $types = array("PolytomousKey"=>"Polytomous", "MediaKey"=>"Media", "MultiAccessKey"=>"Multiaccess");
|
1206
|
RenderHints::pushToRenderStack('block_IdentificationKeys');
|
1207
|
$out = '';
|
1208
|
foreach($types as $type=>$label){
|
1209
|
$keylist = theme('cdm_list_IdentificationKeys', $type, $taxonUuid, $pageSize, $pageNumber);
|
1210
|
if(!$keylist){
|
1211
|
continue;
|
1212
|
}
|
1213
|
$out .= '<div class="'.$type.'">';
|
1214
|
$out .= '<h3>'.t($label)."</h3>";
|
1215
|
$out .= $keylist;
|
1216
|
$out .= '</div>';
|
1217
|
}
|
1218
|
RenderHints::popFromRenderStack();
|
1219
|
return $out;
|
1220
|
}
|
1221
|
|
1222
|
//this theming function formats the use description and use record list for these descriptions
|
1223
|
function theme_cdm_format_Uses ($descriptions = null, $pageSize, $pageNumber) {
|
1224
|
$out = '<div id="content"><ul id="Description" class ="description">';
|
1225
|
if ($descriptions == null) {
|
1226
|
return;
|
1227
|
}
|
1228
|
|
1229
|
foreach($descriptions as $description) {
|
1230
|
//$out .= print_r($description);
|
1231
|
//$taxonName = cdm_ws_get(CDM_WS_NAME_NAMECAHE, $description->taxon->uuid);
|
1232
|
//$out .= print_r($taxonName);
|
1233
|
//$taxonnameName = cdm_ws_get(CDM_WS_PORTAL_NAME_NAMESBYNAME, $taxonName . ".");
|
1234
|
$synonyms = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY,$description->taxon->uuid);
|
1235
|
$out .= print_r($synonyms);
|
1236
|
//$out .= print_r($taxonnameName);
|
1237
|
$out .= '<li class="descriptionText DescriptionElement">';
|
1238
|
foreach ($description->sources as $source) {
|
1239
|
if($source->originalNameString) {
|
1240
|
$originalTaxonUsedInSource = cdm_ws_get(CDM_WS_PORTAL_NAME_NAMESBYNAME, $source->originalNameString . ".");
|
1241
|
$out .=print_r($originalTaxonUsedInSource);
|
1242
|
$name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid),array(), NULL, NULL, FALSE ,TRUE);
|
1243
|
|
1244
|
//$out .= $source->originalNameString . ': ';
|
1245
|
$out .= $name_used_in_source_link_to_show_use . ': ';
|
1246
|
}
|
1247
|
}
|
1248
|
$out .= $description->titleCache;
|
1249
|
foreach ($description->sources as $source) {
|
1250
|
if($source->originalNameString) {
|
1251
|
//$out = $source->originalNameString . ':' . $out;
|
1252
|
}
|
1253
|
$out .= " (" . theme('cdm_DescriptionElementSource', $source, true) . ")";
|
1254
|
}
|
1255
|
$out .= '<ul>';
|
1256
|
foreach ($description->elements as $descriptionElement) {
|
1257
|
$useRecordTags = explode(';', $descriptionElement->modifyingText->English->text);
|
1258
|
$out .= '<li class="use_record_list">- ' . $useRecordTags[0] . '[' . $useRecordTags[1] . ']' . ' - ' . $useRecordTags[2] . ' - ' . $useRecordTags[3]. '[' .$useRecordTags[4]. ']' . ' - ' . $useRecordTags[5] . '</li>';
|
1259
|
}
|
1260
|
$out .= '</ul>';
|
1261
|
|
1262
|
$out .= "</li>";
|
1263
|
|
1264
|
}
|
1265
|
$out .= "</ul></div>";
|
1266
|
return $out;
|
1267
|
}
|
1268
|
|
1269
|
//The Use theming function here will handle the display of the Use Descriptions
|
1270
|
function theme_cdm_block_Uses ($taxonUuid = null, $pageSize = null) {
|
1271
|
RenderHints::pushToRenderStack('block_Uses');
|
1272
|
|
1273
|
if ($taxonUuid == null) {
|
1274
|
return;
|
1275
|
}
|
1276
|
$out = '';
|
1277
|
$markerTypes = array();
|
1278
|
$markerTypes['markerTypes'] = UUID_MARKERTYPE_USE;
|
1279
|
$useDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxonUuid, queryString($markerTypes));
|
1280
|
if(!empty($useDescriptions)) {
|
1281
|
//$out .= print_r($useDescriptions);
|
1282
|
//$out .= print_r($useDescriptions);
|
1283
|
$out .= '<div id="block-cdm_dataportal-feature-description" class="clear-block block block-cdm_dataportal-feature"><a name="userecords"> </a><H2> Uses </H2>';
|
1284
|
$formatUseDescriptions = theme('cdm_format_Uses', $useDescriptions, $pageSize, $pageNumber);
|
1285
|
$out .= $formatUseDescriptions;
|
1286
|
$out .="</div>";
|
1287
|
}
|
1288
|
|
1289
|
return $out;
|
1290
|
}
|