1 |
bd56cbc1
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Taxon Node functions.
|
6 |
|
|
*
|
7 |
|
|
* @copyright
|
8 |
|
|
* (C) 2007-2020 EDIT
|
9 |
|
|
* European Distributed Institute of Taxonomy
|
10 |
|
|
* http://www.e-taxonomy.eu
|
11 |
|
|
*
|
12 |
|
|
* The contents of this module are subject to the Mozilla
|
13 |
|
|
* Public License Version 1.1.
|
14 |
|
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
15 |
|
|
*
|
16 |
|
|
* @author
|
17 |
|
|
* - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
|
18 |
|
|
*/
|
19 |
|
|
|
20 |
|
|
/**
|
21 |
|
|
* Created a render array with taxon node information like states.
|
22 |
|
|
*
|
23 |
|
|
* @param array $taxon_nodes
|
24 |
|
|
*
|
25 |
|
|
* @gropup compose
|
26 |
|
|
*/
|
27 |
|
|
function compose_taxon_node_status(array $taxon_nodes){
|
28 |
|
|
|
29 |
|
|
$render_array = [];
|
30 |
95e00758
|
Andreas Kohlbecker
|
RenderHints::pushToRenderStack("taxon_nodes");
|
31 |
|
|
RenderHints::setFootnoteListKey('taxon_nodes');
|
32 |
bd56cbc1
|
Andreas Kohlbecker
|
if($taxon_nodes && count($taxon_nodes) > 0){
|
33 |
|
|
$label_plural = false;
|
34 |
95e00758
|
Andreas Kohlbecker
|
$status_markup_tokens = [];
|
35 |
bd56cbc1
|
Andreas Kohlbecker
|
foreach ($taxon_nodes as $taxon_node){
|
36 |
95e00758
|
Andreas Kohlbecker
|
|
37 |
|
|
$annotations_and_sources = handle_annotations_and_sources($taxon_node,
|
38 |
|
|
array(
|
39 |
|
|
'sources_as_content' => false,
|
40 |
|
|
'link_to_name_used_in_source' => false,
|
41 |
|
|
'link_to_reference' => true,
|
42 |
178d1ae6
|
Andreas Kohlbecker
|
'add_footnote_keys' => true,
|
43 |
95e00758
|
Andreas Kohlbecker
|
'bibliography_aware' => false),
|
44 |
|
|
'',
|
45 |
|
|
null);
|
46 |
|
|
|
47 |
64cfdac1
|
Andreas Kohlbecker
|
if(isset($taxon_node->nodeStatus)){
|
48 |
|
|
$state_label = strtolower($taxon_node->nodeStatus->message_L10n);
|
49 |
95e00758
|
Andreas Kohlbecker
|
if(isset($taxon_node->statusNote_L10n->text)){
|
50 |
|
|
$state_label .= ' <span class="status-note">(' . $taxon_node->statusNote_L10n->text . ')</span>';
|
51 |
|
|
}
|
52 |
64cfdac1
|
Andreas Kohlbecker
|
$classification = cdm_ws_get(CDM_WS_CLASSIFICATION, array($taxon_node->classificationUUID));
|
53 |
95e00758
|
Andreas Kohlbecker
|
$status_markup_tokens[] = [
|
54 |
|
|
'status' => '<span class="' . html_class_attribute_ref($taxon_node) .'">' . $state_label . $annotations_and_sources['foot_note_keys'] . '%s</span>', // %s will be replaced by the $classification_markup or by '',
|
55 |
64cfdac1
|
Andreas Kohlbecker
|
'classification' => ' <span class="' . html_class_attribute_ref($classification) .'">[' . $classification->titleCache . ']</span>'
|
56 |
bd56cbc1
|
Andreas Kohlbecker
|
];
|
57 |
|
|
}
|
58 |
95e00758
|
Andreas Kohlbecker
|
|
59 |
bd56cbc1
|
Andreas Kohlbecker
|
}
|
60 |
95e00758
|
Andreas Kohlbecker
|
if(count($status_markup_tokens) > 0){
|
61 |
|
|
$status_markup = [];
|
62 |
|
|
$label_plural |= count($status_markup_tokens) > 1;
|
63 |
31bb0452
|
Andreas Kohlbecker
|
$label = $label_plural ? t('Placement status') : t('Placement status');
|
64 |
95e00758
|
Andreas Kohlbecker
|
if(count($status_markup_tokens) > 1){
|
65 |
|
|
foreach ($status_markup_tokens as $tokes){
|
66 |
|
|
$status_markup[] = sprintf($tokes['status'], $tokes['classification']);
|
67 |
bd56cbc1
|
Andreas Kohlbecker
|
}
|
68 |
|
|
} else {
|
69 |
95e00758
|
Andreas Kohlbecker
|
foreach ($status_markup_tokens as $tokes){
|
70 |
|
|
$status_markup[] = sprintf($tokes['status'], '');
|
71 |
bd56cbc1
|
Andreas Kohlbecker
|
}
|
72 |
|
|
}
|
73 |
95e00758
|
Andreas Kohlbecker
|
$render_array['taxon-node-status'] = markup_to_render_array($label . ': ' . join('; ', $status_markup) . theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey())));
|
74 |
bd56cbc1
|
Andreas Kohlbecker
|
$render_array['taxon-node-status']['#prefix'] = '<div class="taxon-node-status">';
|
75 |
|
|
$render_array['taxon-node-status']['#suffix'] = '</div>';
|
76 |
|
|
}
|
77 |
|
|
}
|
78 |
178d1ae6
|
Andreas Kohlbecker
|
RenderHints::setFootnoteListKey(null);
|
79 |
95e00758
|
Andreas Kohlbecker
|
RenderHints::popFromRenderStack();
|
80 |
bd56cbc1
|
Andreas Kohlbecker
|
return $render_array;
|
81 |
|
|
}
|