Project

General

Profile

Download (3.07 KB) Statistics
| Branch: | Tag: | Revision:
1
<?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
  RenderHints::pushToRenderStack("taxon_nodes");
31
  RenderHints::setFootnoteListKey('taxon_nodes');
32
  if($taxon_nodes && count($taxon_nodes) > 0){
33
    $label_plural = false;
34
    $status_markup_tokens = [];
35
    $bibliography_settings = get_bibliography_settings();
36
    foreach ($taxon_nodes as $taxon_node){
37

    
38
      $annotations_and_sources = handle_annotations_and_sources($taxon_node,
39
        array(
40
        'sources_as_content' => false,
41
        'link_to_name_used_in_source' => false,
42
        'link_to_reference' => true,
43
        'add_footnote_keys' => true,
44
        'bibliography_aware' => $bibliography_settings['enabled'] == 1),
45
        '',
46
        null);
47

    
48
      if(isset($taxon_node->nodeStatus)){
49
        $state_label = strtolower($taxon_node->nodeStatus->message_L10n);
50
        if(isset($taxon_node->statusNote_L10n->text)){
51
          $state_label .= ' <span class="status-note">(' . $taxon_node->statusNote_L10n->text . ')</span>';
52
        }
53
        $classification = cdm_ws_get(CDM_WS_CLASSIFICATION, array($taxon_node->classificationUUID));
54
        $status_markup_tokens[$state_label . '-' . $taxon_node->uuid]  = [
55
          '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 '',
56
          'classification' => ' <span class="' . html_class_attribute_ref($classification) .'">[' . $classification->titleCache . ']</span>'
57
        ];
58
      }
59

    
60
    }
61
    if(count($status_markup_tokens) > 0){
62
      ksort($status_markup_tokens);
63
      $status_markup = [];
64
      $label_plural |= count($status_markup_tokens) > 1;
65
      $label = $label_plural ? t('Placement status') : t('Placement status');
66
      if(count($status_markup_tokens) > 1){
67
        foreach ($status_markup_tokens as $tokes){
68
          $status_markup[] = sprintf($tokes['status'], $tokes['classification']);
69
        }
70
      } else {
71
        foreach ($status_markup_tokens as $tokes){
72
          $status_markup[] = sprintf($tokes['status'], '');
73
        }
74
      }
75
      $render_array['taxon-node-status'] = markup_to_render_array($label . ': ' . join('; ', $status_markup) . theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey())));
76
      $render_array['taxon-node-status']['#prefix'] = '<div class="taxon-node-status">';
77
      $render_array['taxon-node-status']['#suffix'] = '</div>';
78
    }
79
  }
80
  RenderHints::setFootnoteListKey(null);
81
  RenderHints::popFromRenderStack();
82
  return $render_array;
83
}
(11-11/13)