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