1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* Description theming functions.
|
5
|
*
|
6
|
* @copyright
|
7
|
* (C) 2007-2012 EDIT
|
8
|
* European Distributed Institute of Taxonomy
|
9
|
* http://www.e-taxonomy.eu
|
10
|
*
|
11
|
* The contents of this module are subject to the Mozilla
|
12
|
* Public License Version 1.1.
|
13
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
14
|
*/
|
15
|
|
16
|
/**
|
17
|
* @todo Please document this function.
|
18
|
* @see http://drupal.org/node/1354
|
19
|
*/
|
20
|
function theme_cdm_feature_nodesTOC($variables) {
|
21
|
$featureNodes = $variables['featureNodes'];
|
22
|
$out = '';
|
23
|
$out .= '<ul>';
|
24
|
|
25
|
foreach ($featureNodes as $node) {
|
26
|
|
27
|
if (hasFeatureNodeDescriptionElements($node)) {
|
28
|
|
29
|
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
|
30
|
// HACK to implement images for taxa, should be removed.
|
31
|
if ($node->feature->uuid != UUID_IMAGE) {
|
32
|
$out .= '<li>' . l(t(theme('cdm_feature_name', array('feature_name' => $featureRepresentation))), $_GET['q'], array(
|
33
|
'attributes' => array('class' => array('toc')), 'fragment' => generalizeString($featureRepresentation))) . '</li>';
|
34
|
}
|
35
|
}
|
36
|
}
|
37
|
|
38
|
$out .= '</ul>';
|
39
|
return $out;
|
40
|
}
|
41
|
|
42
|
/**
|
43
|
* Theme function to alter the feature representation.
|
44
|
*
|
45
|
* It is highly qeutionalbe if this function should be completely removed.
|
46
|
* If a feature needs a different representation this should be edited directly
|
47
|
* in the cdm data but it shoud not be tweeked like this in the portal.
|
48
|
*
|
49
|
* Used in:
|
50
|
* - theme_cdm_feature_nodesTOC()
|
51
|
* - theme_cdm_feature_nodes()
|
52
|
* - theme_cdm_media_mime_application()
|
53
|
* - theme_cdm_media_mime_text()
|
54
|
*
|
55
|
* TODO delete this function? (a.kohlbecker feb 2013)
|
56
|
*
|
57
|
*/
|
58
|
function theme_cdm_feature_name($variables) {
|
59
|
$feature_name = $variables['feature_name'];
|
60
|
// TODO replace by using translations ?
|
61
|
return t($feature_name);
|
62
|
}
|
63
|
|
64
|
/**
|
65
|
* Returns HTML for a taxon profile.
|
66
|
*
|
67
|
* The taxon profile consists of description elements which are ordered by the
|
68
|
* structure defined by specific FeatureTree. The chosen FeatureTree is merged
|
69
|
* with the list of desctiprion elements prior to using this method.
|
70
|
*
|
71
|
* @see cdm_ws_descriptions_by_featuretree()
|
72
|
*
|
73
|
* @param array $variables
|
74
|
* An associative array containing:
|
75
|
* - mergedTrees
|
76
|
* - taxon: The taxon whose sprofile to show.
|
77
|
*
|
78
|
* @ingroup themeable
|
79
|
*/
|
80
|
function theme_cdm_featureTrees($variables) {
|
81
|
$mergedTrees = $variables['mergedTrees'];
|
82
|
$taxon = $variables['taxon'];
|
83
|
$out = '';
|
84
|
if (!isset($mergedTrees)) {
|
85
|
return;
|
86
|
}
|
87
|
|
88
|
foreach ($mergedTrees as &$mTree) {
|
89
|
// TODO display title and reference in case of multiple $mergedTrees ->
|
90
|
// theme
|
91
|
$out .= theme('cdm_feature_nodes', array('mergedFeatureNodes' => $mTree->root->children, 'taxon' => $taxon));
|
92
|
}
|
93
|
|
94
|
return $out;
|
95
|
}
|
96
|
|
97
|
/**
|
98
|
* @todo Please document this function.
|
99
|
* @see http://drupal.org/node/1354
|
100
|
*/
|
101
|
function theme_cdm_featureTreeTOCs($variables) {
|
102
|
$mergedTrees = $variables['mergedTrees'];
|
103
|
if (!$mergedTrees) {
|
104
|
return;
|
105
|
}
|
106
|
// FIXME.
|
107
|
$out = '<div id="featureTOC">';
|
108
|
$out .= '<h2>' . t('Content') . '</h2>';
|
109
|
|
110
|
// TODO diplay title and reference in case of multiple $mergedTrees -> theme.
|
111
|
foreach ($mergedTrees as &$mTree) {
|
112
|
$out .= theme('cdm_feature_nodesTOC', array('featureNodes' => $mTree->root->children));
|
113
|
}
|
114
|
|
115
|
$out .= '</div>';
|
116
|
return $out;
|
117
|
}
|
118
|
|
119
|
/**
|
120
|
* Returns HTML for the $mergedFeatureNodes of a given $taxon.
|
121
|
*
|
122
|
* The merged nodes can be obtained by making use of the
|
123
|
* function cdm_ws_descriptions_by_featuretree().
|
124
|
*
|
125
|
* @param array $variables
|
126
|
* An associative array containing:
|
127
|
* - mergedFeatureNodes
|
128
|
* -taxon
|
129
|
*
|
130
|
* @ingroup themeable
|
131
|
*/
|
132
|
function theme_cdm_feature_nodes($variables) {
|
133
|
|
134
|
$mergedFeatureNodes = $variables['mergedFeatureNodes'];
|
135
|
$taxon = $variables['taxon'];
|
136
|
$out = '';
|
137
|
|
138
|
RenderHints::pushToRenderStack('feature_nodes');
|
139
|
|
140
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME);
|
141
|
|
142
|
// Creating an array to place the description elements in.
|
143
|
$block = new stdclass(); // Empty object.
|
144
|
foreach ($mergedFeatureNodes as $node) {
|
145
|
|
146
|
if (hasFeatureNodeDescriptionElements($node)) {
|
147
|
|
148
|
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
|
149
|
$block->module = 'cdm_dataportal';
|
150
|
$media_list = array();
|
151
|
|
152
|
if (true || $node->feature->uuid != UUID_IMAGE) {
|
153
|
|
154
|
$block->delta = generalizeString($featureRepresentation);
|
155
|
$block->subject = '<span class="' . html_class_atttibute_ref($node->feature) . '">' . theme('cdm_feature_name', array('feature_name' => $featureRepresentation)) . '</span>';
|
156
|
$block->module = "cdm_dataportal-feature";
|
157
|
$block->content = '';
|
158
|
|
159
|
/*
|
160
|
* Content/DISTRIBUTION.
|
161
|
*/
|
162
|
if ($node->feature->uuid == UUID_DISTRIBUTION) {
|
163
|
|
164
|
if (variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
|
165
|
$distributionTextDataList = array();
|
166
|
$distributionElementsList = array();
|
167
|
foreach ($node->descriptionElements as $descriptionElement) {
|
168
|
if ($descriptionElement->class == "TextData") {
|
169
|
$distributionTextDataList[] = $descriptionElement;
|
170
|
}
|
171
|
else {
|
172
|
$distributionElementsList[] = $descriptionElement;
|
173
|
}
|
174
|
}
|
175
|
if (count($distributionTextDataList) > 0) {
|
176
|
$node->descriptionElements = $distributionElementsList;
|
177
|
$block->content .= theme('cdm_descriptionElements', array(
|
178
|
'descriptionElements' => $distributionTextDataList,
|
179
|
'featureUuid' => $node->feature->uuid,
|
180
|
'taxon_uuid' => $taxon->uuid,
|
181
|
));
|
182
|
}
|
183
|
}
|
184
|
|
185
|
// Display cdm distribution map TODO this is a HACK to a proper
|
186
|
// generic implementation?
|
187
|
$block->content .= theme('cdm_distribution_map', array('taxon' => $taxon));
|
188
|
$block->content .= theme('cdm_descriptionElements', array(
|
189
|
'descriptionElements' => $node->descriptionElements,
|
190
|
'featureUuid' => $node->feature->uuid,
|
191
|
'taxon_uuid' => $taxon->uuid,
|
192
|
));
|
193
|
}
|
194
|
|
195
|
/*
|
196
|
* Content/COMMON_NAME.
|
197
|
*/
|
198
|
elseif ($node->feature->uuid == UUID_COMMON_NAME) {
|
199
|
// TODO why is theme_cdm_descriptionElement_CommonTaxonName not
|
200
|
// beeing used???
|
201
|
$block->content .= theme('cdm_common_names', array('elements' => $node->descriptionElements));
|
202
|
/*
|
203
|
}else if($node->feature->uuid == UUID_IMAGE_SOURCES) {
|
204
|
$block->content .= theme('cdm_image_sources',
|
205
|
$node->descriptionElements);
|
206
|
*/
|
207
|
}
|
208
|
|
209
|
/*
|
210
|
* Content/ALL OTHER FEATURES.
|
211
|
*/
|
212
|
else {
|
213
|
if (isset($node->descriptionElements)) {
|
214
|
$taxon_uuid = NULL;
|
215
|
if(isset($taxon) ) {
|
216
|
$taxon_uuid = $taxon->uuid;
|
217
|
}
|
218
|
$block->content .= theme('cdm_descriptionElements', array(
|
219
|
'descriptionElements' => $node->descriptionElements,
|
220
|
'featureUuid' => $node->feature->uuid,
|
221
|
'taxon_uuid' => $taxon_uuid,
|
222
|
));
|
223
|
}
|
224
|
|
225
|
// Content/ALL OTHER FEATURES/Subordinate Features
|
226
|
// subordinate features are printed inline in one floating text,
|
227
|
// it is expected hat supordinate features can "contain" TextData,
|
228
|
// Qualitative- and Qualitative- DescriptioneElements
|
229
|
if (count($node->children) > 0) {
|
230
|
|
231
|
// TODO support more than one level of children.
|
232
|
// can this be solved by resursively calling this very function?
|
233
|
// @see http://dev.e-taxonomy.eu/trac/ticket/2393
|
234
|
$text = '';
|
235
|
foreach ($node->children as $child) {
|
236
|
|
237
|
if (isset($child->descriptionElements) && is_array($child->descriptionElements)) {
|
238
|
foreach ($child->descriptionElements as $element) {
|
239
|
|
240
|
if (is_array($element->media)) {
|
241
|
// Append media of supordinate elements to list of main
|
242
|
// feature.
|
243
|
$media_list = array_merge($media_list, $element->media);
|
244
|
}
|
245
|
|
246
|
switch ($element->class) {
|
247
|
case 'TextData':
|
248
|
// TODO use theme_cdm_descriptionElementTextData()
|
249
|
$out_child_elements = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
|
250
|
$out_child_elements = str_replace($child->feature->titleCache, '<em>' . $child->feature->representation_L10n . '</em>', $out_child_elements);
|
251
|
break;
|
252
|
case 'CategoricalData':
|
253
|
$out_child_elements = '<em>' . $child->feature->representation_L10n . '</em> '
|
254
|
. theme('cdm_descriptionElement_CategoricalData', array('element' => $element));
|
255
|
break;
|
256
|
case 'QuantitativeData':
|
257
|
$out_child_elements = '<em>' . $child->feature->representation_L10n . '</em> '
|
258
|
. theme('cdm_descriptionElement_QuantitativeData', array('element' => $element));
|
259
|
|
260
|
}
|
261
|
|
262
|
}
|
263
|
$text .= " " . $out_child_elements;
|
264
|
$out_child_elements = '';
|
265
|
}
|
266
|
}
|
267
|
$block->content .= $text;
|
268
|
}
|
269
|
}
|
270
|
|
271
|
/*
|
272
|
* Media/ALL FEATURES.
|
273
|
*/
|
274
|
if (isset($node->descriptionElements)) {
|
275
|
$media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
|
276
|
}
|
277
|
$captionElements = array('title', 'rights');
|
278
|
$gallery = '';
|
279
|
if (isset($gallery_settings['cdm_dataportal_media_maxextend']) && isset($gallery_settings['cdm_dataportal_media_cols'])) {
|
280
|
$gallery = theme('cdm_media_gallerie', array(
|
281
|
'mediaList' => $media_list,
|
282
|
'galleryName' => CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME . '_' . $node->feature->uuid,
|
283
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
284
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
285
|
'captionElements' => $captionElements,
|
286
|
));
|
287
|
}
|
288
|
$block->content .= $gallery;
|
289
|
$block->content .= theme('cdm_footnotes', array('footnoteListKey' => $node->feature->uuid));
|
290
|
$block->content .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $node->feature->uuid));
|
291
|
|
292
|
// Add anchor to subject.
|
293
|
$block->subject = '<a name="' . $block->delta . '"></a>' . $block->subject;
|
294
|
|
295
|
// In D6: $out .= theme('block', $block);
|
296
|
// Comment @WA @TODO check if need to set a region, and which one.
|
297
|
$block->region = FALSE;
|
298
|
$out .= theme('block', array('elements' => array(
|
299
|
'#block' => $block,
|
300
|
'#children' => $block->content,
|
301
|
)));
|
302
|
}
|
303
|
}
|
304
|
}
|
305
|
RenderHints::popFromRenderStack();
|
306
|
return $out;
|
307
|
}
|
308
|
|
309
|
/**
|
310
|
* @todo Please document this function.
|
311
|
* @see http://drupal.org/node/1354
|
312
|
*/
|
313
|
function theme_FeatureTree_hierarchy($variables) {
|
314
|
|
315
|
$FeatureTreeUuid = $variables['FeatureTreeUuid'];
|
316
|
if (!is_uuid($FeatureTreeUuid)) {
|
317
|
return;
|
318
|
}
|
319
|
|
320
|
$out = '';
|
321
|
$featureTree = cdm_ws_get(CDM_WS_FEATURETREE, array(
|
322
|
$FeatureTreeUuid,
|
323
|
));
|
324
|
|
325
|
if (isset($featureTree) && isset($featureTree->root)) {
|
326
|
$out = '<ul class="' . $featureTree->class . '">';
|
327
|
$out .= theme('FeatureTree_hierarchy_children', array('node' => $featureTree->root));
|
328
|
$out .= '</ul>';
|
329
|
}
|
330
|
return $out;
|
331
|
}
|
332
|
|
333
|
/**
|
334
|
* @todo Please document this function.
|
335
|
* @see http://drupal.org/node/1354
|
336
|
*/
|
337
|
function theme_FeatureTree_hierarchy_children($variables) {
|
338
|
|
339
|
$node = $variables['node'];
|
340
|
$out = '';
|
341
|
if (isset($node->children)) {
|
342
|
|
343
|
foreach ($node->children as $childNode) {
|
344
|
$out .= '<li>' . check_plain($childNode->feature->representation_L10n);
|
345
|
if (isset($childNode->children) && count($childNode->children) > 0) {
|
346
|
$out .= '<ul>' . theme('FeatureTree_hierarchy_children', array('node' => $childNode)) . '</ul>';
|
347
|
}
|
348
|
$out .= '</li>';
|
349
|
}
|
350
|
}
|
351
|
return $out;
|
352
|
}
|
353
|
|
354
|
/**
|
355
|
* Returns HTML for the texts in a description $elementArray.
|
356
|
*
|
357
|
* Joins the texts in $elementArray and encloses with a HTML tag.
|
358
|
*
|
359
|
* @param array $variables
|
360
|
* An associative array containing:
|
361
|
* - elementArray
|
362
|
* - feature: The feature to which the elements given in $elementArray are
|
363
|
* belonging to.
|
364
|
* - glue: Defaults to empty string.
|
365
|
* - sortArray: Whether to sort the $elementArray alphabetically.
|
366
|
* - enclosingHtml
|
367
|
*
|
368
|
* @ingroup themeable
|
369
|
*/
|
370
|
function theme_cdm_descriptionElementArray($variables) {
|
371
|
$elementArray = $variables['elementArray'];
|
372
|
|
373
|
$feature = $variables['feature'];
|
374
|
$glue = $variables['glue'];
|
375
|
$sortArray = $variables['sortArray'];
|
376
|
$enclosingHtml = $variables['enclosingHtml'];
|
377
|
$out = '<' . $enclosingHtml . ' class="description" id="' . $feature->representation_L10n . '">';
|
378
|
|
379
|
if ($sortArray) {
|
380
|
sort($elementArray);
|
381
|
}
|
382
|
|
383
|
$out .= join($elementArray, $glue);
|
384
|
|
385
|
$out .= '</' . $enclosingHtml . '>';
|
386
|
return $out;
|
387
|
}
|
388
|
|
389
|
/**
|
390
|
* @todo Please document this function.
|
391
|
* @see http://drupal.org/node/1354
|
392
|
*/
|
393
|
function theme_cdm_descriptionElement_CommonTaxonName($variables) {
|
394
|
$element = $variables['element'];
|
395
|
$out = '<span class="' . html_class_atttibute_ref($element) . '">' . $element->language->representation_L10n . ' (' . $element->area->titleCache . '): ' . $element->name . '</span>';
|
396
|
return $out;
|
397
|
}
|
398
|
|
399
|
/**
|
400
|
* @todo Please document this function.
|
401
|
* @see http://drupal.org/node/1354
|
402
|
*/
|
403
|
function theme_cdm_descriptionElement_CategoricalData($variables) {
|
404
|
$element = $variables['element'];
|
405
|
|
406
|
$state_data_strings = array();
|
407
|
if (isset($element->states)) {
|
408
|
foreach ($element->states as $stateData) {
|
409
|
|
410
|
$state = NULL;
|
411
|
|
412
|
if(isset($stateData->state)){
|
413
|
$state = cdm_term_representation($stateData->state);
|
414
|
}
|
415
|
|
416
|
if (isset($stateData->modifyingText_L10n)) {
|
417
|
$state = ' ' . $stateData->modifyingText_L10n;
|
418
|
}
|
419
|
|
420
|
$modifiers_strings = cdm_modifers_representations($stateData);
|
421
|
|
422
|
$state_data_strings[] = $state . ($modifiers_strings ? ' ' . $modifiers_strings : '');
|
423
|
|
424
|
// FIXME render sources
|
425
|
|
426
|
}
|
427
|
}
|
428
|
$out = '<span class="' . html_class_atttibute_ref($element) . '">' . implode(', ', $state_data_strings) . '</span>';
|
429
|
return $out;
|
430
|
}
|
431
|
|
432
|
function theme_cdm_descriptionElement_QuantitativeData($variables) {
|
433
|
/*
|
434
|
* - statisticalValues
|
435
|
* - value
|
436
|
* - modifiers
|
437
|
* - type
|
438
|
* - unit->representation_L10n
|
439
|
* - modifyingText
|
440
|
* - modifiers
|
441
|
* - sources
|
442
|
*/
|
443
|
$element = $variables['element'];
|
444
|
|
445
|
$out = '';
|
446
|
|
447
|
$type_representation = NULL;
|
448
|
$modifiers_strings = array();
|
449
|
|
450
|
|
451
|
if (isset($element->statisticalValues)) {
|
452
|
$value_array = array();
|
453
|
foreach ($element->statisticalValues as $val) {
|
454
|
if (isset($val->value)) {
|
455
|
$value_array[] = $val->value;
|
456
|
}
|
457
|
}
|
458
|
|
459
|
$out .= implode($value_array, ', ');
|
460
|
}
|
461
|
|
462
|
if (isset($element->unit)) {
|
463
|
$out .= ' '. cdm_term_representation($element->unit);
|
464
|
}
|
465
|
|
466
|
if (isset($element->statisticalValues->modifyingText_L10n)) {
|
467
|
$out .= ' ' . $element->statisticalValues->modifyingText_L10n;
|
468
|
}
|
469
|
$modifers_string = cdm_modifers_representations($element->statisticalValues);
|
470
|
$out .= ($modifers_string ? ' ' . cdm_modifers_representations($element->statisticalValues) : '');
|
471
|
|
472
|
// FIXME render sources
|
473
|
|
474
|
return $out;
|
475
|
|
476
|
}
|
477
|
|
478
|
/**
|
479
|
* Returns HTML for citations textdata elements.
|
480
|
*
|
481
|
* TODO: assign a new name to the function? Because it is used for the citations
|
482
|
* textdata elements and not for all text data description elements.
|
483
|
*
|
484
|
* @param array $variables
|
485
|
* An associative array containing:
|
486
|
* - element: The description element which contains the text information.
|
487
|
* - asListElement: A boolean which determines whether the citations should
|
488
|
* be rendered as a list or not.
|
489
|
* - feature_uuid
|
490
|
*
|
491
|
* @ingroup themeable
|
492
|
*/
|
493
|
function theme_cdm_descriptionElementTextData($variables) {
|
494
|
|
495
|
$element = $variables['element'];
|
496
|
$asListElement = $variables['asListElement'];
|
497
|
$feature_uuid = $variables['feature_uuid'];
|
498
|
|
499
|
$description = '';
|
500
|
if (isset($element->multilanguageText_L10n->text)) {
|
501
|
$description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
|
502
|
}
|
503
|
$sourceRefs = '';
|
504
|
$result = array();
|
505
|
$out = '';
|
506
|
$res_author = '';
|
507
|
$res_date = '';
|
508
|
if (isset($element->sources) && is_array($element->sources) && count($element->sources) > 0) {
|
509
|
foreach ($element->sources as $source) {
|
510
|
$referenceCitation = theme('cdm_OriginalSource', array('source' => $source));
|
511
|
if ($description && strlen($description) > 0 && $referenceCitation) {
|
512
|
$sourceRefs .= ' (' . $referenceCitation . ')';
|
513
|
}
|
514
|
elseif ($referenceCitation) {
|
515
|
$sourceRefs = $referenceCitation;
|
516
|
}
|
517
|
|
518
|
if (strlen($sourceRefs) > 0) {
|
519
|
$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
|
520
|
}
|
521
|
$name_used_in_source_link_to_show = '';
|
522
|
// Do a link to name page.
|
523
|
if (isset($source->nameUsedInSource->uuid) && isset($source->nameUsedInSource->titleCache)) {
|
524
|
$name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache, path_to_name($source->nameUsedInSource->uuid), array(
|
525
|
'attributes' => array(),
|
526
|
'absolute' => TRUE,
|
527
|
'html' => TRUE,
|
528
|
));
|
529
|
}
|
530
|
// Show a text without link.
|
531
|
elseif (isset($source->nameUsedInSource->originalNameString) && strlen($source->nameUsedInSource->originalNameString) > 0) {
|
532
|
$name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
|
533
|
}
|
534
|
|
535
|
if ($asListElement) {
|
536
|
|
537
|
$out = '<li class="descriptionText DescriptionElement">';
|
538
|
// Adding ":" if necessary.
|
539
|
if (!empty($name_used_in_source_link_to_show)) {
|
540
|
if ( (!empty($description)|| !empty($sourceRefs)) && $feature_uuid != UUID_CHROMOSOMES_NUMBERS) {
|
541
|
$out .= $name_used_in_source_link_to_show . ': ';
|
542
|
} else {
|
543
|
$out .= $name_used_in_source_link_to_show . ' ';
|
544
|
}
|
545
|
}
|
546
|
$out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $element, 'footnote_list_key' => $feature_uuid)) . '</li>';
|
547
|
}
|
548
|
else {
|
549
|
if ($name_used_in_source_link_to_show) {
|
550
|
$name_used_in_source_link_to_show = ' (name in source: ' . $name_used_in_source_link_to_show . ')';
|
551
|
}
|
552
|
|
553
|
$out = '<span class="DescriptionElement DescriptionElement-' . $element->class . '">' . $description . $sourceRefs . $name_used_in_source_link_to_show . '</span>';
|
554
|
}
|
555
|
}
|
556
|
}
|
557
|
else {
|
558
|
// If no sources, print the description.
|
559
|
$out = $description;
|
560
|
}
|
561
|
return $out;
|
562
|
}
|
563
|
|
564
|
/**
|
565
|
* @todo Please document this function.
|
566
|
* @see http://drupal.org/node/1354
|
567
|
*/
|
568
|
function theme_cdm_common_names($variables) {
|
569
|
$elements = $variables['elements'];
|
570
|
$text_data_out = '';
|
571
|
$common_name_out = '';
|
572
|
$separator = ',';
|
573
|
$textData_commonNames = array();
|
574
|
|
575
|
if (is_array($elements)) {
|
576
|
foreach ($elements as $element) {
|
577
|
if ($element->class == 'CommonTaxonName') {
|
578
|
// $key = '<b>' . $element->language->representation_L10n . '</b> (' .
|
579
|
// $element->area->titleCache . ')';
|
580
|
if (isset($element->language->representation_L10n)) {
|
581
|
$key = '<b>' . $element->language->representation_L10n . '</b>';
|
582
|
$key .= (isset($element->area->titleCache) && strlen($element->area->titleCache) > 0) ? ' (' . $element->area->titleCache . ')' : '';
|
583
|
$common_names[$key][] = $element;
|
584
|
}
|
585
|
else {
|
586
|
// @Comment WA: common name without a language, should this happen?
|
587
|
// example: flore_gabon/cdm_dataportal/taxon/24f36d18-a6e8-4edb-93bf-4a30f3394bf5.
|
588
|
// if(!isset($key)) { // Just to mimic same behaviour as in D5.
|
589
|
$key = '';
|
590
|
// }
|
591
|
$common_names[$key][] = $element;
|
592
|
}
|
593
|
}
|
594
|
elseif ($element->class == 'TextData') {
|
595
|
// else if ($element->class == 'TextData' && $element->feature->uuid
|
596
|
// == UUID_COMMON_NAME){
|
597
|
$textData_commonNames[] = $element;
|
598
|
}
|
599
|
}
|
600
|
}
|
601
|
// Handling common names.
|
602
|
if (isset($common_names) && count($common_names) > 0) {
|
603
|
// Sorting the array based on the key (language, + area if set).
|
604
|
// Comment @WA there are common names without a language, so this sorting
|
605
|
// can give strange results.
|
606
|
ksort($common_names);
|
607
|
|
608
|
// Creating the output to be render by Drupal.
|
609
|
foreach ($common_names as $key => $elements) {
|
610
|
$rendered_element_list = '';
|
611
|
foreach ($elements as $element) {
|
612
|
$sourcesFootnoteKeyList = '';
|
613
|
// Adding footnotes sources.
|
614
|
foreach ($element->sources as $source) {
|
615
|
if (_is_original_source_type($source)) {
|
616
|
$_fkey = FootnoteManager::addNewFootnote(UUID_COMMON_NAME, theme('cdm_OriginalSource', array('source' => $source, 'doLink' => FALSE)));
|
617
|
$sourcesFootnoteKeyList .= theme('cdm_footnote_key', array('footnoteKey' => $_fkey, 'separator' => ($sourcesFootnoteKeyList ? $separator : '')));
|
618
|
}
|
619
|
}
|
620
|
if ($element->name) {
|
621
|
$rendered_element_list .= '<span class="' . html_class_atttibute_ref($element) . '">' . (strlen($rendered_element_list) > 0 ? ', ' : '') . $element->name . $sourcesFootnoteKeyList . '</span>';
|
622
|
}
|
623
|
}
|
624
|
if ($key) {
|
625
|
$common_name_out .= (strlen($common_name_out) > 0 ? '; ' : '') . $key . ': ' . $rendered_element_list;
|
626
|
}
|
627
|
else {
|
628
|
$common_name_out .= (strlen($common_name_out) > 0 ? '; ' : '') . $rendered_element_list;
|
629
|
}
|
630
|
}
|
631
|
}
|
632
|
// Handling commons names as text data.
|
633
|
foreach ($textData_commonNames as $text_data_element) {
|
634
|
$text_data_out .= theme('cdm_descriptionElementTextData', array(
|
635
|
'element' => $text_data_element,
|
636
|
'asListElement' => TRUE,
|
637
|
'feature_uuid' => $text_data_element->feature->uuid,
|
638
|
));
|
639
|
}
|
640
|
|
641
|
$common_name_out = "<div class=common_names_as_common_names> $common_name_out </div>";
|
642
|
$out_array[] = $text_data_out;
|
643
|
$common_name_out_text_data = '<div class=common_names_as_text_data>' . theme('cdm_descriptionElementArray', array('elementArray' => $out_array, 'feature' => $element->feature)) . '</div>';
|
644
|
|
645
|
return $common_name_out . $common_name_out_text_data;
|
646
|
/*
|
647
|
return $common_name_out . theme('cdm_descriptionElementArray', $out_array,
|
648
|
$element->feature);
|
649
|
return "<div class=common_names> $common_name_out
|
650
|
$common_name_out_text_data";
|
651
|
*/
|
652
|
}
|
653
|
|
654
|
/**
|
655
|
* Return HTML for a list of description elements.
|
656
|
*
|
657
|
* Usually these are of a specific feature type.
|
658
|
*
|
659
|
* @param array $variables
|
660
|
* An associative array containing:
|
661
|
* - array of descriptionElements which belong to the same feature.
|
662
|
* These descriptions elements of a Description must be ordered by the chosen feature tree by
|
663
|
* calling the function _mergeFeatureTreeDescriptions().
|
664
|
* @see _mergeFeatureTreeDescriptions()
|
665
|
* - featureUuid: currently unused, accoding code disabled
|
666
|
* - taxon_uuid: only used for ordered dditributions (will be removed!)
|
667
|
*
|
668
|
* @ingroup themeable
|
669
|
*/
|
670
|
function theme_cdm_descriptionElements($variables) {
|
671
|
|
672
|
$descriptionElements = $variables['descriptionElements'];
|
673
|
$featureUuid = $variables['featureUuid'];
|
674
|
$taxon_uuid = $variables['taxon_uuid'];
|
675
|
$outArray = array();
|
676
|
|
677
|
/*
|
678
|
$userDefined = mixed_variable_get(LAYOUT_SETTING_PREFIX . $featureUuid, FEATURE_TREE_LAYOUT_DEFAULTS);
|
679
|
if(variable_get('distribution_sort',
|
680
|
'NO_SORT') != 'NO_SORT'){
|
681
|
$glue = '';
|
682
|
$enclosingTag = 'dl';
|
683
|
$entryEnclosingTag = NULL;
|
684
|
} else if($userDefined &&
|
685
|
$userDefined['enabled']){
|
686
|
$glue = $userDefined['glue'];
|
687
|
$enclosingTag = $userDefined['enclosingTag'];
|
688
|
$entryEnclosingTag = $userDefined['entryEnclosingTag'];
|
689
|
} else { // TODO remove once LAYOUT_SETTING_PREFIX-{uuid} setting are configured to work for all portals(selenium test still missing!!!)
|
690
|
$glue = ''; $enclosingTag = 'ul';
|
691
|
$entryEnclosingTag = NULL ;
|
692
|
}
|
693
|
*/
|
694
|
|
695
|
|
696
|
if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') {
|
697
|
$glue = '';
|
698
|
$enclosingTag = 'dl';
|
699
|
}
|
700
|
else {
|
701
|
$glue = '';
|
702
|
$enclosingTag = 'ul';
|
703
|
}
|
704
|
|
705
|
$sortOutArray = FALSE;
|
706
|
$distributionElements = array();
|
707
|
|
708
|
RenderHints::pushToRenderStack('cdm_descriptionElements');
|
709
|
|
710
|
// Avoiding warning box in drupal for flora malesiana.
|
711
|
if (is_array($descriptionElements)) {
|
712
|
foreach ($descriptionElements as $descriptionElement) {
|
713
|
|
714
|
// --- DISTRIBUTION ---- //
|
715
|
if ($descriptionElement->feature->uuid == UUID_DISTRIBUTION) {
|
716
|
if ($descriptionElement->class == 'Distribution') {
|
717
|
$sortKey = $descriptionElement->area->representation_L10n;
|
718
|
$distributionElements[$sortKey] = $descriptionElement;
|
719
|
}
|
720
|
elseif ($descriptionElement->class == 'TextData') {
|
721
|
$asListElement = FALSE;
|
722
|
$repr = theme('cdm_descriptionElementTextData', array(
|
723
|
'element' => $descriptionElement,
|
724
|
'asListElement' => $asListElement,
|
725
|
'feature_uuid' => $descriptionElement->feature->uuid,
|
726
|
));
|
727
|
|
728
|
if (!array_search($repr, $outArray)) {
|
729
|
$outArray[] = $repr;
|
730
|
// TODO HINT: sorting in theme_cdm_descriptionElementArray will
|
731
|
// not work since this array contains html attributes with uuids
|
732
|
// !!!!
|
733
|
$sortOutArray = TRUE;
|
734
|
$glue = '<br/> ';
|
735
|
$enclosingTag = 'p';
|
736
|
}
|
737
|
}
|
738
|
}
|
739
|
|
740
|
// --- IMAGE_SOURCES --- //
|
741
|
elseif ($descriptionElement->feature->uuid == UUID_IMAGE_SOURCES) {
|
742
|
$image_sources[] = $descriptionElement;
|
743
|
}
|
744
|
// --- USE TEXTDATA --- //
|
745
|
elseif ($descriptionElement->feature->uuid == UUID_USE) {
|
746
|
// Do nothing to avoid rendering.
|
747
|
} else {
|
748
|
/* decide based on the description element class
|
749
|
*
|
750
|
* TODO provide api_hook as extension point for this
|
751
|
*/
|
752
|
switch ($descriptionElement->class) {
|
753
|
case 'TextData':
|
754
|
$asListElement = TRUE;
|
755
|
$outArray[] = theme('cdm_descriptionElementTextData', array(
|
756
|
'element' => $descriptionElement,
|
757
|
'asListElement' => $asListElement,
|
758
|
'feature_uuid' => $descriptionElement->feature->uuid,
|
759
|
));
|
760
|
break;
|
761
|
case 'CommonTaxonName':
|
762
|
$outArray[] = theme('cdm_descriptionElement_CommonTaxonName', array('element' => $descriptionElement));
|
763
|
break;
|
764
|
case 'CategoricalData':
|
765
|
$outArray[] = theme('cdm_descriptionElement_CategoricalData', array('element' => $descriptionElement));
|
766
|
break;
|
767
|
case 'QuantitativeData':
|
768
|
$outArray[] = theme('cdm_descriptionElement_QuantitativeData', array('element' => $descriptionElement));
|
769
|
break;
|
770
|
case 'Uses':
|
771
|
/* IGNORE Uses classes, these are handled completely in theme_cdm_UseDescription */
|
772
|
break;
|
773
|
default:
|
774
|
$outArray[] = '<li>No method for rendering unknown description class: ' . $descriptionElement->class . '</li>';
|
775
|
}
|
776
|
}
|
777
|
}
|
778
|
}
|
779
|
|
780
|
// If feature = NAME USAGE sort the list of sources.
|
781
|
// This is ONLY for FLORA MALESIANA and FLORE d'AFRIQUE CENTRALE.
|
782
|
if ($descriptionElement->feature->uuid == UUID_NAME_USAGE) {
|
783
|
sort($outArray);
|
784
|
}
|
785
|
|
786
|
if (isset($image_sources)) {
|
787
|
$outArray[] = theme('cdm_description_element_image_source', array('image_sources' => $image_sources, 'asListElement' => TRUE));
|
788
|
}
|
789
|
|
790
|
if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') {
|
791
|
$outArray[] = theme('cdm_description_ordered_distributions', array('taxon_uuid' => $taxon_uuid, 'descriptionElements' => $distributionElements));
|
792
|
}
|
793
|
else {
|
794
|
ksort($distributionElements);
|
795
|
// TODO , $entryEnclosingTag);
|
796
|
$outArray[] = theme('cdm_descriptionElementDistribution', array(
|
797
|
'descriptionElements' => $distributionElements,
|
798
|
));
|
799
|
}
|
800
|
|
801
|
// Take the feature of the last $descriptionElement.
|
802
|
$feature = $descriptionElement->feature;
|
803
|
|
804
|
$out = theme('cdm_descriptionElementArray', array(
|
805
|
'elementArray' => $outArray,
|
806
|
'feature' => $feature,
|
807
|
'glue' => $glue,
|
808
|
'sortArray' => $sortOutArray,
|
809
|
'enclosingHtml' => $enclosingTag,
|
810
|
));
|
811
|
|
812
|
RenderHints::popFromRenderStack();
|
813
|
return $out;
|
814
|
}
|
815
|
|
816
|
/**
|
817
|
* @todo Please document this function.
|
818
|
* @see http://drupal.org/node/1354
|
819
|
*/
|
820
|
function compare_image_sources($a, $b) {
|
821
|
if ($a->multilanguageText_L10n->text == $b->multilanguageText_L10n->text) {
|
822
|
return 0;
|
823
|
}
|
824
|
return ($a->multilanguageText_L10n->text < $b->multilanguageText_L10n->text) ? -1 : 1;
|
825
|
}
|
826
|
|
827
|
/**
|
828
|
* @todo Please document this function.
|
829
|
* @see http://drupal.org/node/1354
|
830
|
*/
|
831
|
function theme_cdm_description_element_image_source($variables) {
|
832
|
$image_sources = $variables['image_sources'];
|
833
|
$asListElement = $variables['asListElement'];
|
834
|
$out = '';
|
835
|
$separator = ',';
|
836
|
RenderHints::pushToRenderStack('descriptionElementImageSource');
|
837
|
RenderHints::setFootnoteListKey(UUID_IMAGE_SOURCES);
|
838
|
|
839
|
// Sorting the image sources.
|
840
|
usort($image_sources, "compare_image_sources");
|
841
|
// Generate the footnotes.
|
842
|
foreach ($image_sources as $image_source) {
|
843
|
$footNoteKeys = cdm_annotations_as_footnotekeys($image_source);
|
844
|
foreach ($image_source->sources as $source) {
|
845
|
if (_is_original_source_type($source)) {
|
846
|
$fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_OriginalSource', array(
|
847
|
'source' => $source,
|
848
|
'doLink' => FALSE,
|
849
|
)));
|
850
|
// Ensure uniqueness of the footnote keys.
|
851
|
cdm_add_footnote_to_array($footNoteKeys, $fn_key);
|
852
|
}
|
853
|
}
|
854
|
// Sort and render footnote keys.
|
855
|
$footnoteKeyListStr = '';
|
856
|
asort($footNoteKeys);
|
857
|
foreach ($footNoteKeys as $footNoteKey) {
|
858
|
$footnoteKeyListStr .= theme('cdm_footnote_key', array('footnoteKey' => $footNoteKey, 'separator' => ($footnoteKeyListStr ? $separator : '')));
|
859
|
}
|
860
|
// Return value!
|
861
|
$out .= '<span class="descriptionElement descriptionElement-' . $image_source->uuid . '">' . $image_source->multilanguageText_L10n->text . $footnoteKeyListStr . '; </span>';
|
862
|
}
|
863
|
|
864
|
RenderHints::popFromRenderStack();
|
865
|
return $out;
|
866
|
}
|
867
|
|
868
|
/**
|
869
|
* @todo Please document this function.
|
870
|
* @see http://drupal.org/node/1354
|
871
|
*/
|
872
|
function theme_cdm_descriptionElementDistribution($variables) {
|
873
|
$descriptionElements = $variables['descriptionElements'];
|
874
|
$enclosingTag = $variables['enclosingTag'];
|
875
|
if (!$enclosingTag) {
|
876
|
$enclosingTag = "span";
|
877
|
}
|
878
|
|
879
|
$out = '';
|
880
|
$separator = ',';
|
881
|
RenderHints::pushToRenderStack('descriptionElementDistribution');
|
882
|
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
|
883
|
|
884
|
foreach ($descriptionElements as $descriptionElement) {
|
885
|
|
886
|
// Annotations as footnotes.
|
887
|
$footNoteKeys = cdm_annotations_as_footnotekeys($descriptionElement);
|
888
|
// Source references as footnotes.
|
889
|
foreach ($descriptionElement->sources as $source) {
|
890
|
if (_is_original_source_type($source)) {
|
891
|
$fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_OriginalSource', array(
|
892
|
'source' => $source,
|
893
|
'doLink' => FALSE,
|
894
|
)));
|
895
|
// Ensure uniqueness of the footnote keys.
|
896
|
cdm_add_footnote_to_array($footNoteKeys, $fn_key);
|
897
|
}
|
898
|
}
|
899
|
// Sort and render footnote keys.
|
900
|
$footnoteKeyListStr = '';
|
901
|
asort($footNoteKeys);
|
902
|
foreach ($footNoteKeys as $footNoteKey) {
|
903
|
$footnoteKeyListStr .= theme('cdm_footnote_key', array('footnoteKey' => $footNoteKey, 'separator' => ($footnoteKeyListStr ? $separator : '')));
|
904
|
}
|
905
|
|
906
|
$out .= '<' . $enclosingTag . ' class="descriptionElement descriptionElement-' . $descriptionElement->uuid . '">' . $descriptionElement->area->representation_L10n . $footnoteKeyListStr . ' </' . $enclosingTag . '>';
|
907
|
}
|
908
|
|
909
|
RenderHints::popFromRenderStack();
|
910
|
return $out;
|
911
|
}
|
912
|
|
913
|
/**
|
914
|
* Compare two different footnotes objects.
|
915
|
*
|
916
|
* The comparison is based on the footnote key. The one which is
|
917
|
* displayed as footnote number.
|
918
|
*
|
919
|
* @param mixed $a
|
920
|
* Footnote object $a.
|
921
|
* @param mixed $b
|
922
|
* Footnote object $b.
|
923
|
*/
|
924
|
function footnotes_key_compare($a, $b) {
|
925
|
$res = 0;
|
926
|
if (empty($a) || empty($b)) {
|
927
|
return $res;
|
928
|
}
|
929
|
if ($a->keyStr < $b->keyStr) {
|
930
|
$res = -1;
|
931
|
}
|
932
|
elseif ($a->keyStr > $b->keyStr) {
|
933
|
$res = 1;
|
934
|
}
|
935
|
return $res;
|
936
|
}
|
937
|
|
938
|
/**
|
939
|
* @todo Please document this function.
|
940
|
* @see http://drupal.org/node/1354
|
941
|
*/
|
942
|
function theme_cdm_description_ordered_distributions($variables) {
|
943
|
|
944
|
$taxon_uuid = $variables['taxon_uuid'];
|
945
|
$descriptionElements = $variables['descriptionElements'];
|
946
|
|
947
|
// Returning NULL if there are no description elements.
|
948
|
if ($taxon_uuid == null || $descriptionElements == NULL) {
|
949
|
return NULL;
|
950
|
}
|
951
|
|
952
|
// Initialization of some variables.
|
953
|
$out = '';
|
954
|
$separator = ',';
|
955
|
RenderHints::pushToRenderStack('descriptionElementDistribution');
|
956
|
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
|
957
|
|
958
|
// Getting all the taxon description for a given taxon.
|
959
|
$markerTypesEmpty = array();
|
960
|
// $markerTypesEmpty['markerTypes'] = 'af9860ff-08f5-4b4d-863c-49ae96985115';
|
961
|
$markerTypesEmpty['markerTypes'] = '';
|
962
|
$queryString = $markerTypesEmpty['markerTypes'] ? queryString($markerTypesEmpty) : '';
|
963
|
|
964
|
$taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon_uuid, $queryString);
|
965
|
foreach ($taxonDescriptions as $description) {
|
966
|
$descriptions_uuids[] = $description->uuid;
|
967
|
}
|
968
|
|
969
|
// Getting the sortered distributions (omitting level ??).
|
970
|
$request_params = array();
|
971
|
$request_params['omitLevels'] = UUID_NAMEDAREALEVEL_TDWGLEVEL_2;
|
972
|
$ordered_areas = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION_DISTRIBUTION_TREE, join(',', $descriptions_uuids), queryString($request_params));
|
973
|
if (isset($ordered_areas->rootElement->children)) {
|
974
|
$ordered_areas = $ordered_areas->rootElement->children;
|
975
|
}
|
976
|
|
977
|
// Printing the distributions.
|
978
|
if (is_array($ordered_areas) && count($ordered_areas) > 0) {
|
979
|
foreach ($ordered_areas as $element_level1) {
|
980
|
// Level1.
|
981
|
if ($element_level1->data) {
|
982
|
$out .= '<dt>' . $element_level1->data->area->representation_L10n . ':</dt> ';
|
983
|
}
|
984
|
$out .= '<dd>';
|
985
|
|
986
|
// Level3.
|
987
|
foreach ($element_level1->children as $element_level3) {
|
988
|
if ($element_level3->data) {
|
989
|
$text_l3 = $element_level3->data->area->representation_L10n;
|
990
|
}
|
991
|
$fnKeysLevel3Str = '';
|
992
|
$fnKeysLevel3 = cdm_annotations_as_footnotekeys($element_level3->data);
|
993
|
foreach ($element_level3->data->sources as $source) {
|
994
|
if (_is_original_source_type($source)) {
|
995
|
$fn_key3 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_OriginalSource', array('source' => $source, 'doLink' => FALSE)));
|
996
|
cdm_add_footnote_to_array($fnKeysLevel3, $fn_key3);
|
997
|
}
|
998
|
}
|
999
|
// Level4.
|
1000
|
$l4_regions = array();
|
1001
|
foreach ($element_level3->children as $element_level4) {
|
1002
|
if ($element_level4->data) {
|
1003
|
$text_l4 = $element_level4->data->area->representation_L10n;
|
1004
|
$l4_regions[$element_level3->data->area->representation_L10n] = '';
|
1005
|
$fnKeysLevel4Str = '';
|
1006
|
$fnKeysLevel4 = cdm_annotations_as_footnotekeys($element_level4->data);
|
1007
|
foreach ($element_level4->data->sources as $source) {
|
1008
|
if (_is_original_source_type($source)) {
|
1009
|
$fn_key4 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_OriginalSource', array('source' => $source, 'doLink' => FALSE)));
|
1010
|
cdm_add_footnote_to_array($fnKeysLevel4, $fn_key4);
|
1011
|
}
|
1012
|
}
|
1013
|
usort($fnKeysLevel4, "footnotes_key_compare");
|
1014
|
$l4_regions[$text_l4] = $fnKeysLevel4;
|
1015
|
}
|
1016
|
}// Level4.
|
1017
|
// Managing level3 and level4 for generating the right output.
|
1018
|
usort($fnKeysLevel3, "footnotes_key_compare");
|
1019
|
foreach ($fnKeysLevel3 as $key3) {
|
1020
|
foreach ($l4_regions as $key4 => $value4) {
|
1021
|
cdm_add_footnote_to_array($l4_regions[$key4], $key3);
|
1022
|
}
|
1023
|
}
|
1024
|
if ($element_level3->numberOfChildren == 1 && $text_l3 == $element_level3->children[0]->data->area->representation_L10n) {
|
1025
|
// var_dump($element_level3->children[0]->data->area->representation_L10n);
|
1026
|
$fnStr = '';
|
1027
|
$region = array_pop($l4_regions);
|
1028
|
foreach ($region as $key) {
|
1029
|
$fnStr .= theme('cdm_footnote_key', array('footnoteKey' => $key, 'separator' => ($fnStr ? $separator : '')));
|
1030
|
}
|
1031
|
$out .= "$text_l3 $fnStr; ";
|
1032
|
// Removing whitespaces when &fnStr is empty.
|
1033
|
if (substr($out, -3) == ' ; ') {
|
1034
|
$out = substr($out, 0, -3) . '; ';
|
1035
|
}
|
1036
|
}
|
1037
|
else {
|
1038
|
$fnKeysLevel3Str = '';
|
1039
|
foreach ($fnKeysLevel3 as $key) {
|
1040
|
$fnKeysLevel3Str .= theme('cdm_footnote_key', array('footnoteKey' => $key, 'separator' => ($fnKeysLevel3Str ? $separator : '')));
|
1041
|
}
|
1042
|
$text_l4_aux = '';
|
1043
|
foreach ($l4_regions as $key => $value) {
|
1044
|
$fnKeysLevel4Str = '';
|
1045
|
if (is_array($l4_regions[$key])) {
|
1046
|
foreach ($l4_regions[$key] as $fnkey) {// Warning why?
|
1047
|
$fnKeysLevel4Str .= theme('cdm_footnote_key', array('footnoteKey' => $fnkey, 'separator' => ($fnKeysLevel4Str ? $separator : '')));
|
1048
|
}
|
1049
|
}
|
1050
|
// if ($key != $text_l3 || sizeof($l4_regions > 1)){
|
1051
|
if ($key != $text_l3) {
|
1052
|
$text_l4_aux .= "$key $fnKeysLevel4Str, ";
|
1053
|
}
|
1054
|
}
|
1055
|
$text_l4_aux = substr($text_l4_aux, 0, -2);
|
1056
|
|
1057
|
if (strlen($text_l4_aux) > 0) {
|
1058
|
$out .= "$text_l3 $fnKeysLevel3Str ($text_l4_aux); ";
|
1059
|
}
|
1060
|
else {
|
1061
|
$out .= "$text_l3 $fnKeysLevel3Str; ";
|
1062
|
}
|
1063
|
}
|
1064
|
}// Level3.
|
1065
|
$out = substr($out, 0, -2);
|
1066
|
$out .= '.</dd>';
|
1067
|
}// Level1.
|
1068
|
}
|
1069
|
RenderHints::popFromRenderStack();
|
1070
|
return $out;
|
1071
|
}
|
1072
|
|
1073
|
|
1074
|
/*
|
1075
|
function theme_cdm_descriptionElementDistribution($descriptionElements){ $out
|
1076
|
= ''; $separator = ',';
|
1077
|
RenderHints::pushToRenderStack('descriptionElementDistribution');
|
1078
|
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
|
1079
|
foreach($descriptionElements as $descriptionElement){ // annotations as
|
1080
|
footnotes $annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys',
|
1081
|
$descriptionElement); // source references as footnotes
|
1082
|
$sourcesFootnoteKeyList = ''; foreach($descriptionElement->sources as
|
1083
|
$source){ if(_is_original_source_type($source)){ $_fkey =
|
1084
|
FootnoteManager::addNewFootnote(UUID_DISTRIBUTION,
|
1085
|
theme('cdm_OriginalSource', $source, FALSE));
|
1086
|
$sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey,
|
1087
|
UUID_DISTRIBUTION, ($sourcesFootnoteKeyList ? $separator : '')); } }
|
1088
|
if($annotationFootnoteKeys && $sourcesFootnoteKeyList){
|
1089
|
$annotationFootnoteKeys .= $separator; } $out .=
|
1090
|
$descriptionElement->area->representation_L10n . $annotationFootnoteKeys .
|
1091
|
$sourcesFootnoteKeyList . ' '; } $out = substr($out, 0,
|
1092
|
strlen($out)-strlen($separator) ); RenderHints::popFromRenderStack(); return
|
1093
|
$out; }
|
1094
|
*/
|
1095
|
|
1096
|
/**
|
1097
|
* TODO
|
1098
|
* Quick-and-dirty solution to show distribution service to exemplar groups.
|
1099
|
*/
|
1100
|
function theme_cdm_distribution_map($variables) {
|
1101
|
$taxon = $variables['taxon'];
|
1102
|
$out = '';
|
1103
|
$settings = get_edit_map_service_settings();
|
1104
|
|
1105
|
$fontStyles = array(
|
1106
|
0 => "plane",
|
1107
|
1 => "italic",
|
1108
|
);
|
1109
|
|
1110
|
// Query cdm server for map service uri parameters.
|
1111
|
$map_data_parameters = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
|
1112
|
$out .= "<!-- map_data_parameters:" . print_r($map_data_parameters, TRUE) . " -->";
|
1113
|
$query_string = $map_data_parameters->String;
|
1114
|
if (!$query_string) {
|
1115
|
// The $query_string is empty if there are no distribution areas defined.
|
1116
|
return;
|
1117
|
}
|
1118
|
|
1119
|
// Some cleaning of the URI paramters, TODO is this still needed?
|
1120
|
$query_string = str_replace('%3A', ":", $query_string);
|
1121
|
|
1122
|
/* ------ choose the display mode, either openlayers or static image ------ */
|
1123
|
if (variable_get('cdm_dataportal_map_openlayers', 1)) {
|
1124
|
|
1125
|
/* =========== display distributions using the openlayers map viewer =========== */
|
1126
|
$legend_url_font_size = variable_get('cdm_dataportal_geoservice_legend_font_size', 10);
|
1127
|
$legend_url_font_style = variable_get('cdm_dataportal_geoservice_legend_font_style', 1);
|
1128
|
$legend_url_font_style = $fontStyles[$legend_url_font_style];
|
1129
|
$legend_url_icon_width = variable_get('cdm_dataportal_geoservice_legend_icon_width', 35);
|
1130
|
$legend_url_icon_height = variable_get('cdm_dataportal_geoservice_legend_icon_height', 15);
|
1131
|
|
1132
|
$legendFormatQueryStr = "format=image" . urlencode('/') . "png&TRANSPARENT=TRUE";
|
1133
|
$legendFormatQueryStr .= "&WIDTH=" . $legend_url_icon_width . "&HEIGHT=" . $legend_url_icon_height . "&";
|
1134
|
// TODO why is the layer=topp:tdwg_level_4 parameter neede at all here??
|
1135
|
// Comment @WA $sldLegend is not used.
|
1136
|
// $legendFormatQueryStr
|
1137
|
// .="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);
|
1138
|
$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=";
|
1139
|
|
1140
|
$out .= get_openlayers_map(variable_get('cdm_dataportal_geoservice_display_width', 300), variable_get('cdm_dataportal_geoservice_bounding_box', FALSE), NULL, $query_string, $legendFormatQueryStr, variable_get('cdm_dataportal_geoservice_map_caption', ''));
|
1141
|
}
|
1142
|
else {
|
1143
|
$legendFormatQueryStr = '';
|
1144
|
return get_image_map(variable_get('cdm_dataportal_geoservice_display_width', 300), variable_get('cdm_dataportal_geoservice_bounding_box', FALSE), NULL, $query_string, $legendFormatQueryStr, variable_get('cdm_dataportal_geoservice_map_caption', ''));
|
1145
|
|
1146
|
// Simple image.
|
1147
|
$mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
|
1148
|
|
1149
|
$query_string .= '&img=true';
|
1150
|
$query_string .= '&legend=1&mlp=3' . $mapStaticCaption . '&recalculate=FALSE';
|
1151
|
|
1152
|
$map_service_script_name = "areas.php";
|
1153
|
|
1154
|
// Apply Plain Image map settings.
|
1155
|
if (get_edit_map_service_version_number() >= 1.1) {
|
1156
|
/*
|
1157
|
* example : title=a:Naturalized++non-invasive
|
1158
|
* &ad=cyprusdivs:bdcode:a:5&as=a:ff9900,,0.1,&l=tdwg4
|
1159
|
* &ms=500&bbox=32,34,35,36&img=true&legend=1&mlp=3
|
1160
|
* &mc_s=Georgia,15,blue&mc=&recalculate=FALSE
|
1161
|
* http://edit.br.fgov.be/edit_wp5/v1/rest_gen.php?
|
1162
|
* l=background_gis:b,cyprusdivs&ad=cyprusdivs%3Abdcode%3Aa%3A8%2C4
|
1163
|
* &as=a%3A339966%2C%2C0.1%2C|b:0000ff,,
|
1164
|
* &bbox=32%2C34%2C35%2C36&img=true&legend=1&mc=&mc_s=Georgia%2C15%2Cblue
|
1165
|
* &mlp=3&ms=500&recalculate=FALSE&title=a%3Aindigenous
|
1166
|
*/
|
1167
|
|
1168
|
$map_service_script_name = "rest_gen.php";
|
1169
|
|
1170
|
$bgcolor_areaStyleId = "y";
|
1171
|
$baselayer_areaStyleId = "z";
|
1172
|
$bgcolor_layer = '';
|
1173
|
$additional_area_styles = array();
|
1174
|
|
1175
|
// Background color.
|
1176
|
if (variable_get('map_bg_color', '')) {
|
1177
|
$bgcolor_layer = "background_gis:" . $bgcolor_areaStyleId;
|
1178
|
$additional_area_styles[] = $bgcolor_areaStyleId . ":" . variable_get('map_bg_color', '') . ",,";
|
1179
|
}
|
1180
|
|
1181
|
// TODO HACK to replace the default base layer which currently is tdwg4
|
1182
|
// !!!
|
1183
|
if (strpos($query_string, "?l=") !== FALSE) {
|
1184
|
$layer_param_token = "?l=";
|
1185
|
}
|
1186
|
else {
|
1187
|
$layer_param_token = "&l=";
|
1188
|
}
|
1189
|
if (strpos($query_string, "?as=") !== FALSE) {
|
1190
|
$areystyle_param_token = "?as=";
|
1191
|
}
|
1192
|
else {
|
1193
|
$areystyle_param_token = "&as=";
|
1194
|
}
|
1195
|
|
1196
|
if (variable_get('map_base_layer', '')) {
|
1197
|
$query_string = str_replace($layer_param_token . "tdwg4", "$layer_param_token" . variable_get('map_base_layer', '') . ":" . $baselayer_areaStyleId, $query_string);
|
1198
|
}
|
1199
|
else {
|
1200
|
$query_string = str_replace($layer_param_token . "tdwg4", $layer_param_token . "tdwg4:" . $baselayer_areaStyleId . ",", $query_string);
|
1201
|
}
|
1202
|
|
1203
|
if ($bgcolor_layer) {
|
1204
|
$query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
|
1205
|
}
|
1206
|
|
1207
|
if (variable_get('map_base_layer_style', '')) {
|
1208
|
$additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
|
1209
|
}
|
1210
|
|
1211
|
foreach ($additional_area_styles as $as) {
|
1212
|
$query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
|
1213
|
}
|
1214
|
}
|
1215
|
|
1216
|
$mapUri = url(get_edit_map_service_full_uri() . '/' . $map_service_script_name . '? '. $query_string);
|
1217
|
$out .= '<img class="distribution_map" src="' . $mapUri . '" alt="Distribution Map" />';
|
1218
|
}
|
1219
|
return $out;
|
1220
|
}
|
1221
|
|
1222
|
/**
|
1223
|
* Returns a list of a specific type of IdentificationKeys.
|
1224
|
*
|
1225
|
* The list can be restricteded by a taxon.
|
1226
|
*
|
1227
|
* @param string $type
|
1228
|
* The simple name of the cdm class implementing the interface
|
1229
|
* IdentificationKey, valid values are:
|
1230
|
* PolytomousKey, MediaKey, MultiAccessKey.
|
1231
|
* @param string $taxonUuid
|
1232
|
* If given this parameter restrict the listed keys to those which have
|
1233
|
* the taxon identified be this uuid in scope.
|
1234
|
*
|
1235
|
* @return array
|
1236
|
* List with identification keys.
|
1237
|
*/
|
1238
|
function _list_IdentificationKeys($type, $taxonUuid = NULL, $pageSize = NULL, $pageNumber = NULL) {
|
1239
|
if (!$type) {
|
1240
|
drupal_set_message(t('Type parameter is missing'), 'error');
|
1241
|
return;
|
1242
|
}
|
1243
|
$cdm_ws_pasepath = NULL;
|
1244
|
switch ($type) {
|
1245
|
case "PolytomousKey":
|
1246
|
$cdm_ws_pasepath = CDM_WS_POLYTOMOUSKEY;
|
1247
|
break;
|
1248
|
|
1249
|
case "MediaKey":
|
1250
|
$cdm_ws_pasepath = CDM_WS_MEDIAKEY;
|
1251
|
break;
|
1252
|
|
1253
|
case "MultiAccessKey":
|
1254
|
$cdm_ws_pasepath = CDM_WS_MULTIACCESSKEY;
|
1255
|
break;
|
1256
|
|
1257
|
}
|
1258
|
|
1259
|
if (!$cdm_ws_pasepath) {
|
1260
|
drupal_set_message(t('Type parameter is not valid: ') . $type, 'error');
|
1261
|
}
|
1262
|
|
1263
|
$queryParameters = '';
|
1264
|
if (is_numeric($pageSize)) {
|
1265
|
$queryParameters = "pageSize=" . $pageSize;
|
1266
|
}
|
1267
|
else {
|
1268
|
$queryParameters = "pageSize=0";
|
1269
|
}
|
1270
|
|
1271
|
if (is_numeric($pageNumber)) {
|
1272
|
$queryParameters = "pageNumber=" . $pageNumber;
|
1273
|
}
|
1274
|
else {
|
1275
|
$queryParameters = "pageNumber=0";
|
1276
|
}
|
1277
|
$queryParameters = NULL;
|
1278
|
if ($taxonUuid) {
|
1279
|
$queryParameters = "findByTaxonomicScope=$taxonUuid";
|
1280
|
}
|
1281
|
$pager = cdm_ws_get($cdm_ws_pasepath, NULL, $queryParameters);
|
1282
|
|
1283
|
if (!$pager || $pager->count == 0) {
|
1284
|
return array();
|
1285
|
}
|
1286
|
return $pager->records;
|
1287
|
}
|
1288
|
|
1289
|
/**
|
1290
|
* @todo Please document this function.
|
1291
|
* @see http://drupal.org/node/1354
|
1292
|
*/
|
1293
|
function theme_cdm_IdentificationKey($variables) {
|
1294
|
$out = '';
|
1295
|
$identificationKey = $variables['identificationKey'];
|
1296
|
$doLinkToKeyPage = $variables['doLinkToKeyPage'];
|
1297
|
$showIdentificationKeyTitle = $variables['showIdentificationKeyTitle'];
|
1298
|
$parentRenderPath = RenderHints::getRenderPath();
|
1299
|
RenderHints::pushToRenderStack("IdentificationKey");
|
1300
|
|
1301
|
if ($showIdentificationKeyTitle) {
|
1302
|
if ($doLinkToKeyPage) {
|
1303
|
$out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid));
|
1304
|
}
|
1305
|
else {
|
1306
|
$out = $identificationKey->titleCache;
|
1307
|
}
|
1308
|
}
|
1309
|
if (isset($identificationKey->sources) && is_array($identificationKey->sources)) {
|
1310
|
// Display sources.
|
1311
|
$i = 0;
|
1312
|
$out .= '<div>';
|
1313
|
foreach ($identificationKey->sources as $source) {
|
1314
|
$out .= ($i++ > 0 ? ', ' : '') . theme('cdm_OriginalSource', array('source' => $source));
|
1315
|
}
|
1316
|
$out .= '</div>';
|
1317
|
}
|
1318
|
// Display annotations.
|
1319
|
$out .= theme('cdm_annotations', array('annotations' => cdm_ws_getAnnotationsFor($identificationKey), 'enclosingTag' => 'div'));
|
1320
|
RenderHints::popFromRenderStack();
|
1321
|
return $out;
|
1322
|
}
|
1323
|
|
1324
|
/**
|
1325
|
* @todo Please document this function.
|
1326
|
* @see http://drupal.org/node/1354
|
1327
|
*/
|
1328
|
function theme_cdm_polytomousKey($variables) {
|
1329
|
$polytomousKey = $variables['polytomousKey'];
|
1330
|
|
1331
|
// TODO settings needed.
|
1332
|
// @see http://en.wikipedia.org/wiki/Single_access_key#Presentation_styles
|
1333
|
// @see http://dev.e-taxonomy.eu/trac/ticket/2152
|
1334
|
$keyStyle = "linkedStyle";
|
1335
|
|
1336
|
RenderHints::pushToRenderStack("polytomousKey");
|
1337
|
// Key nodes in linked style.
|
1338
|
$out = '<table class="polytomousKey polytomousKey_' . $keyStyle . '">';
|
1339
|
$out .= theme('cdm_polytomousKey_' . $keyStyle . '_subgraph', array('polytomousKeyNode' => $polytomousKey->root));
|
1340
|
$out .= '</table>';
|
1341
|
RenderHints::popFromRenderStack();
|
1342
|
return $out;
|
1343
|
}
|
1344
|
|
1345
|
/**
|
1346
|
* @todo Please document this function.
|
1347
|
* @see http://drupal.org/node/1354
|
1348
|
*/
|
1349
|
function theme_cdm_polytomousKey_linkedStyle_subgraph($variables) {
|
1350
|
$polytomousKeyNode = $variables['polytomousKeyNode'];
|
1351
|
static $statementCountCharacter = '\'';
|
1352
|
$out = "";
|
1353
|
|
1354
|
if (is_array($polytomousKeyNode->children)) {
|
1355
|
$childIndex = 0;
|
1356
|
|
1357
|
// Render edges of the current node.
|
1358
|
foreach ($polytomousKeyNode->children as &$child) {
|
1359
|
|
1360
|
if (!isset($child->statement) && isset($child->taxon->uuid)) {
|
1361
|
// Skip node with empty statements (see below for explanation: "Special
|
1362
|
// case").
|
1363
|
// this skipping here happens always in the next deeper level of iteration
|
1364
|
// the check below is node on the level above
|
1365
|
continue;
|
1366
|
}
|
1367
|
|
1368
|
/*
|
1369
|
* Special case: Child nodes with empty statements but taxa as leaf are to
|
1370
|
* treated as if all those taxa where direct children of the source node.
|
1371
|
*/
|
1372
|
$islinkToManyTaxa = !isset($child->children[0]->statement) && isset($child->children[0]->taxon->uuid);
|
1373
|
$islinkToTaxon = isset($child->taxon->uuid);
|
1374
|
$islinkToSubKey = isset($child->subkey->uuid);
|
1375
|
$islinkToOtherNode = isset($child->otherNode);
|
1376
|
// Either NULL or 0.
|
1377
|
$islinkToNode = $child->nodeNumber && !$islinkToManyTaxa && !$islinkToOtherNode;
|
1378
|
$hasQuestion = isset($polytomousKeyNode->question->label_l10n);
|
1379
|
$hasFeature = isset($polytomousKeyNode->feature);
|
1380
|
|
1381
|
// $indentEdge = $hasQuestion && $childIndex > 0;
|
1382
|
// Question.
|
1383
|
if ($hasQuestion && $childIndex == 0) {
|
1384
|
// Place question, as extra table row.
|
1385
|
$out .= '<tr class="question new_section">';
|
1386
|
$out .= '<td class="nodeNumber">' . uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber) . "</td>";
|
1387
|
$out .= '<td class="question">' . $polytomousKeyNode->question->label_l10n . '</td>';
|
1388
|
$out .= '</tr>';
|
1389
|
}
|
1390
|
|
1391
|
$out .= '<tr class="childCount_' . $childIndex . (!$hasQuestion && $childIndex == 0 ? ' new_section' : '') . '">';
|
1392
|
|
1393
|
if ($hasQuestion) {
|
1394
|
$out .= '<td class="nodeNumber"></td>';
|
1395
|
}
|
1396
|
else {
|
1397
|
$out .= '<td class="nodeNumber">' . uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childIndex, $statementCountCharacter)) . "</td>";
|
1398
|
}
|
1399
|
|
1400
|
$out .= '<td ' . RenderHints::getHtmlElementID($child) . ' class="edge' . ($hasQuestion ? ' edge-indent' : '') . '">';
|
1401
|
|
1402
|
// Feature.
|
1403
|
if ($hasFeature) {
|
1404
|
$out .= $polytomousKeyNode->feature->representation_L10n . ": ";
|
1405
|
}
|
1406
|
|
1407
|
// Statement.
|
1408
|
$out .= $child->statement->label_l10n;
|
1409
|
|
1410
|
// --- Links to nodes taxa and subkeys.
|
1411
|
$out .= '<div class="nodeLink">';
|
1412
|
|
1413
|
// Link to a PolytomousKeyNode.
|
1414
|
if ($islinkToNode) {
|
1415
|
$out .= '<div class="nodeLinkToNode">';
|
1416
|
if (is_object($child->modifyingText)) {
|
1417
|
$out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $child->modifyingText));
|
1418
|
}
|
1419
|
$out .= l($child->nodeNumber, request_path(), array(
|
1420
|
'attributes' => NULL,
|
1421
|
'query' => NULL,
|
1422
|
'fragment' => $child->uuid,
|
1423
|
)) . '</div>';
|
1424
|
}
|
1425
|
|
1426
|
// Link to a PolytomousKeyNode.
|
1427
|
if ($islinkToOtherNode) {
|
1428
|
$out .= '<div class="nodeLinkToOtherNode">';
|
1429
|
if (is_object($child->modifyingText)) {
|
1430
|
$out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $child->modifyingText));
|
1431
|
}
|
1432
|
$out .= l($child->otherNode->nodeNumber, $_REQUEST["q"], array(
|
1433
|
'attributes' => NULL,
|
1434
|
'query' => NULL,
|
1435
|
'fragment' => $child->otherNode->uuid,
|
1436
|
)) . '</div>';
|
1437
|
}
|
1438
|
|
1439
|
// Link to one or many taxa.
|
1440
|
if ($islinkToTaxon || $islinkToManyTaxa) {
|
1441
|
|
1442
|
if ($islinkToManyTaxa) {
|
1443
|
$taxonChildren = $child->children;
|
1444
|
}
|
1445
|
else {
|
1446
|
$taxonChildren = array(
|
1447
|
$child,
|
1448
|
);
|
1449
|
}
|
1450
|
|
1451
|
foreach ($taxonChildren as $taxonChild) {
|
1452
|
// TODO many taxa $child->children->taxon.
|
1453
|
$out .= '<div class="nodeLinkToTaxon">';
|
1454
|
if (is_object($taxonChild->modifyingText)) {
|
1455
|
$out .= theme('cdm_poytomousKeyNode_modifyingText', array('modifyingText' => $taxonChild->modifyingText));
|
1456
|
}
|
1457
|
$out .= theme("cdm_taxonName", array('taxonName' => $taxonChild->taxon->name, 'nameLink' => url(path_to_taxon($taxonChild->taxon->uuid))));
|
1458
|
$out .= '</div>';
|
1459
|
}
|
1460
|
|
1461
|
// Link to a subkey.
|
1462
|
if ($islinkToSubKey) {
|
1463
|
$out .= '<div class="nodeLinkToSubkey">' . theme('cdm_IdentificationKey', array('identificationKey' => $child->subkey)) . '</div>';
|
1464
|
}
|
1465
|
}
|
1466
|
|
1467
|
$out .= '</div>'; // End node link.
|
1468
|
$out .= '</td>'; // End edge.
|
1469
|
$out .= '</tr>';
|
1470
|
|
1471
|
$childIndex++;
|
1472
|
}
|
1473
|
|
1474
|
// Recurse into child nodes.
|
1475
|
foreach ($polytomousKeyNode->children as &$child) {
|
1476
|
$out .= theme('cdm_polytomousKey_linkedStyle_subgraph', array('polytomousKeyNode' => $child));
|
1477
|
}
|
1478
|
}
|
1479
|
|
1480
|
return $out;
|
1481
|
}
|
1482
|
|
1483
|
/**
|
1484
|
* @todo Please document this function.
|
1485
|
* @see http://drupal.org/node/1354
|
1486
|
*/
|
1487
|
function theme_cdm_poytomousKeyNode_modifyingText($variables) {
|
1488
|
$out = '';
|
1489
|
$modifyingText = $variables['modifyingText'];
|
1490
|
if (is_object($modifyingText)) {
|
1491
|
$i = 0;
|
1492
|
foreach (get_object_vars($modifyingText) as $lang => $languageString) {
|
1493
|
$out .= ($i++ > 0 ? ', ' : '') . '<span class="modifyingText">' . $languageString->text . '</span> ';
|
1494
|
}
|
1495
|
}
|
1496
|
return $out;
|
1497
|
}
|
1498
|
|
1499
|
/**
|
1500
|
* Returns HTML for a list of a specific type of IdentificationKeys.
|
1501
|
*
|
1502
|
* The list can be restricteded by a taxon.
|
1503
|
*
|
1504
|
* @param array $variables
|
1505
|
* An associative array containing:
|
1506
|
* - type: The simple name of the cdm class implementing the interface
|
1507
|
* IdentificationKey, valid values are:
|
1508
|
* PolytomousKey, MediaKey, MultiAccessKey
|
1509
|
* - taxonUuid: If given, this parameter restrict the listed keys to those
|
1510
|
* which have the taxon identified be this uuid in scope.
|
1511
|
*
|
1512
|
* @ingroup themeable
|
1513
|
*/
|
1514
|
function theme_cdm_list_IdentificationKeys($variables) {
|
1515
|
$type = $variables['type'];
|
1516
|
$taxonUuid = $variables['taxonUuid'];
|
1517
|
$keyList = _list_IdentificationKeys($type, $taxonUuid);
|
1518
|
if (!$keyList || count($keyList) == 0) {
|
1519
|
return;
|
1520
|
}
|
1521
|
|
1522
|
RenderHints::pushToRenderStack('list_IdentificationKeys');
|
1523
|
$out = '<ul>';
|
1524
|
foreach ($keyList as $key) {
|
1525
|
$out .= '<li>';
|
1526
|
$out .= theme('cdm_IdentificationKey', array('identificationKey' => $key));
|
1527
|
$out .= '</li>';
|
1528
|
}
|
1529
|
$out .= '</ul>';
|
1530
|
$out .= theme("cdm_annotation_footnotes", array('footnoteListKey' => RenderHints::getRenderPath()));
|
1531
|
RenderHints::popFromRenderStack();
|
1532
|
|
1533
|
return $out;
|
1534
|
}
|
1535
|
|
1536
|
// @WA $pageSize is not used..
|
1537
|
// function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize =
|
1538
|
// null){
|
1539
|
/**
|
1540
|
* @todo Please document this function.
|
1541
|
* @see http://drupal.org/node/1354
|
1542
|
*/
|
1543
|
function theme_cdm_block_IdentificationKeys($variables) {
|
1544
|
$taxonUuid = $variables['taxonUuid'];
|
1545
|
static $types = array(
|
1546
|
"PolytomousKey" => "Polytomous",
|
1547
|
"MediaKey" => "Media",
|
1548
|
"MultiAccessKey" => "Multiaccess",
|
1549
|
);
|
1550
|
RenderHints::pushToRenderStack('block_IdentificationKeys');
|
1551
|
$out = '';
|
1552
|
foreach ($types as $type => $label) {
|
1553
|
// @WA $pageNumber is not defined, $pageSize is not used in the theme
|
1554
|
// function
|
1555
|
// $keylist = theme('cdm_list_IdentificationKeys', $type, $taxonUuid,
|
1556
|
// $pageSize, $pageNumber);
|
1557
|
$keylist = theme('cdm_list_IdentificationKeys', array('type' => $type, 'taxonUuid' => $taxonUuid));
|
1558
|
if (!$keylist) {
|
1559
|
continue;
|
1560
|
}
|
1561
|
$out .= '<div class="' . $type . '">';
|
1562
|
$out .= '<h3>' . t($label) . "</h3>";
|
1563
|
$out .= $keylist;
|
1564
|
$out .= '</div>';
|
1565
|
}
|
1566
|
RenderHints::popFromRenderStack();
|
1567
|
return $out;
|
1568
|
}
|
1569
|
|
1570
|
// This theming function formats the use description and use record list for
|
1571
|
// these descriptions.
|
1572
|
// Comment @WA: $pageSize and $pageNumber are not used.
|
1573
|
// function theme_cdm_UseDescription($descriptions = NULL, $taxonUuid = NULL,
|
1574
|
// $pageSize, $pageNumber) {
|
1575
|
/**
|
1576
|
* @todo Please document this function.
|
1577
|
* @see http://drupal.org/node/1354
|
1578
|
*/
|
1579
|
function theme_cdm_UseDescription($variables) {
|
1580
|
$descriptions = $variables['description'];
|
1581
|
$taxonUuid = $variables['taxonUuid'];
|
1582
|
$out = '<div id="content"><ul id="Description" class ="description">';
|
1583
|
if ($descriptions == NULL) {
|
1584
|
return;
|
1585
|
}
|
1586
|
$descriptionSynonyms = '';
|
1587
|
$descriptionOut = '';
|
1588
|
$synonymOut = '';
|
1589
|
$currentTaxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $taxonUuid);
|
1590
|
|
1591
|
foreach ($descriptions as $description) {
|
1592
|
$useSummary = "";
|
1593
|
// Comment @WA: $synonyms is not defined.
|
1594
|
// $serializedSynonyms = serialize($synonyms).
|
1595
|
foreach ($description->elements as $element) {
|
1596
|
|
1597
|
if ($element->feature->uuid == UUID_USE && !(strlen($useSummary) > 0)) {
|
1598
|
$useSummary = $element->multilanguageText_L10n->text;
|
1599
|
}
|
1600
|
}
|
1601
|
// uses will be ordered by source
|
1602
|
foreach ($description->sources as $source) {
|
1603
|
$is_about_current_taxon = FALSE;
|
1604
|
$originalTaxonUsedInSource = NULL;
|
1605
|
$originalTaxonPager = NULL;
|
1606
|
if ($source->originalNameString) {
|
1607
|
$request_params = array();
|
1608
|
$request_params['query'] = $source->originalNameString;
|
1609
|
$request_params['matchMode'] = "EXACT";
|
1610
|
$originalTaxonPager = cdm_ws_get(CDM_WS_PORTAL_NAME_FINDBYNAME, NULL, queryString($request_params));
|
1611
|
if ($originalTaxonPager->count > 0) {
|
1612
|
$originalTaxonUsedInSource = $originalTaxonPager->records[0];
|
1613
|
}
|
1614
|
else {
|
1615
|
$originalTaxonUsedInSource = $currentTaxon->name;
|
1616
|
}
|
1617
|
}
|
1618
|
else {
|
1619
|
$originalTaxonUsedInSource = $currentTaxon->name;
|
1620
|
}
|
1621
|
|
1622
|
$is_about_current_taxon = $currentTaxon->name->uuid == $originalTaxonUsedInSource->uuid;
|
1623
|
|
1624
|
if (!$is_about_current_taxon) {
|
1625
|
$descriptionOut .= '<li class="descriptionText DescriptionElement">';
|
1626
|
$name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
|
1627
|
'absolute' => TRUE,
|
1628
|
'html' => TRUE,
|
1629
|
));
|
1630
|
$descriptionOut .= $name_used_in_source_link_to_show_use . ': ';
|
1631
|
$descriptionOut .= $useSummary;
|
1632
|
foreach ($description->sources as $source) {
|
1633
|
$descriptionOut .= " (" . theme('cdm_OriginalSource', array('source' => $source, 'doLink' => TRUE)) . ")";
|
1634
|
}
|
1635
|
$hasUseRecords = FALSE;
|
1636
|
$descriptionUseRecordOut = '<div id=useRecords><table><th>Use Category</th><th>Use Sub Category</th><th>Plant Part</th><th>Human Group</th><th>Ethnic Group</th><th>Country</th>';
|
1637
|
foreach ($description->elements as $descriptionElement) {
|
1638
|
if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
|
1639
|
$hasUseRecords = TRUE;
|
1640
|
// FIXME localization hardcoded to English
|
1641
|
$useRecordTags = explode(';', $descriptionElement->modifyingText->English->text);
|
1642
|
$descriptionUseRecordOut .= '<tr>';
|
1643
|
$descriptionUseRecordOut .= '<td>' . $useRecordTags[0] . '</td>' . '<td>' . $useRecordTags[1] . '</td>' . '<td>' . $useRecordTags[3] . '</td>' . '<td>' . $useRecordTags[4] . '</td>' . '<td>' . $useRecordTags[5] . '</td>' . '<td>' . $useRecordTags[2] . '</td>';
|
1644
|
$descriptionUseRecordOut .= '</tr>';
|
1645
|
}
|
1646
|
}
|
1647
|
$descriptionUseRecordOut .= '</table></div>';
|
1648
|
if ($hasUseRecords) {
|
1649
|
$descriptionOut .= $descriptionUseRecordOut . '</li>';
|
1650
|
}
|
1651
|
}
|
1652
|
else {
|
1653
|
// TODO +/- duplicate of above, unify this code
|
1654
|
$synonymOut .= '<li class="descriptionText DescriptionElement">';
|
1655
|
$name_used_in_source_link_to_show_use = l($source->originalNameString, path_to_name($originalTaxonUsedInSource->uuid), array(
|
1656
|
'absolute' => TRUE,
|
1657
|
'html' => TRUE,
|
1658
|
));
|
1659
|
|
1660
|
$synonymOut .= $name_used_in_source_link_to_show_use . ': ';
|
1661
|
$synonymOut .= $useSummary;
|
1662
|
foreach ($description->sources as $source) {
|
1663
|
$synonymOut .= " (" . theme('cdm_OriginalSource', array('source' => $source, 'doLink' => TRUE)) . ")";
|
1664
|
}
|
1665
|
|
1666
|
$hasUseRecords = FALSE;
|
1667
|
$useRecordTableOut = '<div id=useRecords><table><th>Use Category</th><th>Use Sub Category</th><th>Plant Part</th><th>Human Group</th><th>Ethnic Group</th><th>Country</th>';
|
1668
|
foreach ($description->elements as $descriptionElement) {
|
1669
|
if ($descriptionElement->feature->uuid == UUID_USE_RECORD) {
|
1670
|
$hasUseRecords = TRUE;
|
1671
|
$useRecordTags = explode(';', $descriptionElement->modifyingText->English->text);
|
1672
|
$useRecordTableOut .= '<tr>';
|
1673
|
$useRecordTableOut .= '<td>' . $useRecordTags[0] . '</td>' . '<td>' . $useRecordTags[1] . '</td>' . '<td>' . $useRecordTags[3] . '</td>' . '<td>' . $useRecordTags[4] . '</td>' . '<td>' . $useRecordTags[5] . '</td>' . '<td>' . $useRecordTags[2] . '</td>';
|
1674
|
$useRecordTableOut .= '</tr>';
|
1675
|
}
|
1676
|
}
|
1677
|
$useRecordTableOut .= '</table></div>';
|
1678
|
if ($hasUseRecords) {
|
1679
|
$synonymOut .= $useRecordTableOut . '</li>';
|
1680
|
}
|
1681
|
}
|
1682
|
|
1683
|
// }
|
1684
|
}
|
1685
|
}
|
1686
|
$out .= $descriptionOut . $synonymOut;
|
1687
|
$out .= "</ul></div>";
|
1688
|
return $out;
|
1689
|
}
|
1690
|
|
1691
|
// The Uses theming function here will handle the display of the
|
1692
|
// Uses Descriptions.
|
1693
|
// Comment @WA: $pageSize is not used.
|
1694
|
// function theme_cdm_block_Uses ($taxonUuid = NULL, $pageSize = NULL {
|
1695
|
/**
|
1696
|
* @todo Please document this function.
|
1697
|
* @see http://drupal.org/node/1354
|
1698
|
*/
|
1699
|
function theme_cdm_block_Uses($variables) {
|
1700
|
$taxonUuid = $variables['taxonUuid'];
|
1701
|
RenderHints::pushToRenderStack('block_Uses');
|
1702
|
|
1703
|
if ($taxonUuid == NULL) {
|
1704
|
return;
|
1705
|
}
|
1706
|
$out = '';
|
1707
|
$markerTypes = array();
|
1708
|
$markerTypes['markerTypes'] = UUID_MARKERTYPE_USE;
|
1709
|
$useDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxonUuid, queryString($markerTypes));
|
1710
|
if (!empty($useDescriptions)) {
|
1711
|
// FIXME use theme_block instaed of hardcoding the block html here !!!!
|
1712
|
$out .= '<div id="block-cdm_dataportal-feature-description" class="clear-block block block-cdm_dataportal-feature"><H2><a name="userecords"> </a> Uses </H2>';
|
1713
|
// @WA $pageNumber is not defined
|
1714
|
// $formatUseDescriptions = theme('cdm_UseDescription', $useDescriptions,
|
1715
|
// $taxonUuid, $pageSize, $pageNumber);
|
1716
|
$formatUseDescriptions = theme('cdm_UseDescription', array('description' => $useDescriptions, 'taxonUuid' => $taxonUuid));
|
1717
|
|
1718
|
$out .= $formatUseDescriptions;
|
1719
|
$out .= "</div>";
|
1720
|
}
|
1721
|
|
1722
|
return $out;
|
1723
|
}
|