Project

General

Profile

« Previous | Next » 

Revision 95e00758

Added by Andreas Kohlbecker almost 4 years ago

ref #9010 showing status notes, source and annotations

View differences:

modules/cdm_dataportal/includes/taxon-node.inc
27 27
function compose_taxon_node_status(array $taxon_nodes){
28 28

  
29 29
  $render_array = [];
30
  RenderHints::pushToRenderStack("taxon_nodes");
31
  RenderHints::setFootnoteListKey('taxon_nodes');
30 32
  if($taxon_nodes && count($taxon_nodes) > 0){
31 33
    $label_plural = false;
32
    $state_markup_tokens = [];
34
    $status_markup_tokens = [];
33 35
    foreach ($taxon_nodes as $taxon_node){
36

  
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
        'add_footnote_keys' => false,
43
        'bibliography_aware' => false),
44
        '',
45
        null);
46

  
34 47
      if(isset($taxon_node->status)){
35 48
        $state_label = strtolower($taxon_node->status);
36
        $classification_markup = ' <span class="' . html_class_attribute_ref($taxon_node->classification) .'">[' . $taxon_node->classification->titleCache . ']</span>';
37
        $state_markup = '<span class="' . html_class_attribute_ref($taxon_node) .'">' . $state_label . '%s</span>'; // %s will be replaced by the $classification_markup or by ''
38
        $state_markup_tokens[] = [
39
          'states' => $state_markup,
40
          'classification' => $classification_markup,
41
          'closing_tag' => '</span>'
49
        if(isset($taxon_node->statusNote_L10n->text)){
50
          $state_label .= ' <span class="status-note">(' . $taxon_node->statusNote_L10n->text . ')</span>';
51
        }
52
        $status_markup_tokens[]  = [
53
          '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 '',
54
          'classification' => ' <span class="' . html_class_attribute_ref($taxon_node->classification) .'">[' . $taxon_node->classification->titleCache . ']</span>'
42 55
        ];
43 56
      }
57

  
44 58
    }
45
    if(count($state_markup_tokens) > 0){
46
      $state_markup = [];
47
      $label_plural |= count($state_markup_tokens) > 1;
59
    if(count($status_markup_tokens) > 0){
60
      $status_markup = [];
61
      $label_plural |= count($status_markup_tokens) > 1;
48 62
      $label = $label_plural ? t('Placement status') : t('Placement status');
49
      if(count($state_markup_tokens) > 1){
50
        foreach ($state_markup_tokens as $tokes){
51
          $state_markup[] = sprintf($tokes['states'], $tokes['classification']);
63
      if(count($status_markup_tokens) > 1){
64
        foreach ($status_markup_tokens as $tokes){
65
          $status_markup[] = sprintf($tokes['status'], $tokes['classification']);
52 66
        }
53 67
      } else {
54
        foreach ($state_markup_tokens as $tokes){
55
          $state_markup[] = sprintf($tokes['states'], '');
68
        foreach ($status_markup_tokens as $tokes){
69
          $status_markup[] = sprintf($tokes['status'], '');
56 70
        }
57 71
      }
58
      $render_array['taxon-node-status'] = markup_to_render_array($label . ': ' . join('; ', $state_markup));
72
      $render_array['taxon-node-status'] = markup_to_render_array($label . ': ' . join('; ', $status_markup) . theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey())));
59 73
      $render_array['taxon-node-status']['#prefix'] = '<div class="taxon-node-status">';
60 74
      $render_array['taxon-node-status']['#suffix'] = '</div>';
61 75
    }
62 76
  }
77
  RenderHints::getFootnoteListKey();
78
  RenderHints::popFromRenderStack();
63 79
  return $render_array;
64 80
}

Also available in: Unified diff