Project

General

Profile

« Previous | Next » 

Revision 529c47ff

Added by Andreas Kohlbecker about 8 years ago

turning theme function to compose function for CategoricalData

View differences:

modules/cdm_dataportal/includes/descriptions.inc
539 539
          has_feature_node_description_elements($node)) && $node->feature->uuid != UUID_IMAGE) { // skip empty or supressed features
540 540

  
541 541
        $feature_name = cdm_term_representation($node->feature, 'Unnamed Feature');
542
        $feature_block_settings = get_feature_block_settings($node->feature->uuid);
542 543

  
543 544
        $block = feature_block($feature_name, $node->feature);
544 545
        $block->content = array();
......
577 578
          $out_child_elements = '';
578 579

  
579 580
          if (isset($node->descriptionElements)) {
580
            $taxon_uuid = NULL;
581
            if(isset($taxon) ) {
582
              $taxon_uuid = $taxon->uuid;
583
            }
584
            $elements_render_array = compose_feature_block_items_generic($node->descriptionElements, $node->feature, $taxon_uuid);
581
            $elements_render_array = compose_feature_block_items_generic($node->descriptionElements, $node->feature);
585 582
            $block_content_is_empty = empty($elements_render_array);
586 583
            $block->content[] = $elements_render_array;
587 584
          }
......
619 616
                      break;
620 617
                    case 'CategoricalData':
621 618
                      $out_child_elements  = '<em>' . $child->feature->representation_L10n . '</em> '
622
                        . theme('cdm_descriptionElement_CategoricalData', array('element' => $element));
619
                        . compose_description_element_categorical_data($element, $feature_block_settings);
623 620
                      break;
624 621
                    case 'QuantitativeData':
625 622
                      $out_child_elements = '<em>' . $child->feature->representation_L10n . '</em> '
......
1004 1001

  
1005 1002
}
1006 1003

  
1004
/**
1005
 * Renders a single instance of the type CategoricalData.
1006
 *
1007
 * @param $element
1008
 *  The CDM CategoricalData entity
1009
 *
1010
 * @return string
1011
 *   a html representation of the given CategoricalData element
1012
 *
1013
 * @ingroup compose
1014
 */
1015
function compose_description_element_categorical_data($element, $feature_block_settings) {
1016

  
1017
  $state_data_strings = array();
1018
  if (isset($element->stateData)) {
1019
    foreach ($element->stateData as $state_data) {
1020

  
1021
      $state  = NULL;
1022

  
1023
      if (isset($state_data->state)) {
1024
        $state = cdm_term_representation($state_data->state);
1025
      }
1026

  
1027
      if (isset($state_data->modifyingText_L10n)) {
1028
        $state = ' ' . $state_data->modifyingText_L10n;
1029
      }
1030

  
1031
      $modifiers_strings = cdm_modifers_representations($state_data);
1032

  
1033
      $state_data_strings[] = $state . ($modifiers_strings ? ' ' . $modifiers_strings : '');
1034

  
1035
    }
1036
  }
1037

  
1038

  
1039
  $out = '<span class="' . html_class_attribute_ref($element) . '">' . implode(', ', $state_data_strings) . '</span>';
1040

  
1041
  $feature_block_settings = get_feature_block_settings($element->feature->uuid);
1042
  $annotations_and_sources = handle_annotations_and_sources(
1043
    $element,
1044
    $feature_block_settings,
1045
    $out, // The description element text.
1046
    $element->feature->uuid
1047
  );
1048

  
1049
  if (!empty($annotations_and_sources['source_references'])) {
1050
    $out .= ' ' . implode(' ', $annotations_and_sources['source_references']);
1051
  }
1052
  return $out . $annotations_and_sources['foot_note_keys'];
1053
}
1054

  
1007 1055

  
1008 1056
/**
1009 1057
 * Creates a render array for string representations of description elements for the given feature.
......
1161 1209
           * TODO provide api_hook as extension point for this?
1162 1210
           */
1163 1211
          $feature_block_settings = get_feature_block_settings($descriptionElement->feature->uuid);
1164
          $asListElement  = $feature_block_settings['as_list'] == 'ul';
1165
          switch ($descriptionElement->class) {
1212
        switch ($descriptionElement->class) {
1166 1213
            case 'TextData':
1214
              $asListElement  = $feature_block_settings['as_list'] == 'ul';
1167 1215
              $text_data_render_array = compose_description_element_textdata($descriptionElement, $asListElement, $descriptionElement->feature->uuid);
1168 1216
              $feature_block_has_content = $feature_block_has_content || !empty($text_data_render_array['#value']);
1169 1217
              $elements_out_array[] = drupal_render($text_data_render_array);
1170 1218
              break;
1171 1219
            case 'CategoricalData':
1172 1220
              $feature_block_has_content = true;
1173
              $elements_out_array[] = theme('cdm_descriptionElement_CategoricalData', array('element' => $descriptionElement));
1221
              $elements_out_array[] = compose_description_element_categorical_data($descriptionElement, $feature_block_settings);
1174 1222
              break;
1175 1223
            case 'QuantitativeData':
1176 1224
              $feature_block_has_content = true;
modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
83 83
  return $out;
84 84
}
85 85

  
86

  
87
/**
88
 * Theme function to render CDM DescriptionElements of the type CategoricalData.
89
 *
90
 * @param array $variables
91
 *   An associative array containing:
92
 *  - element: the CategoricalData element
93
 *
94
 * @return string
95
 *   a html representation of the given CategoricalData element
96
 *
97
 * @ingroup themeable
98
 */
99
function theme_cdm_descriptionElement_CategoricalData($variables) {
100
  $element = $variables['element'];
101

  
102
  $state_data_strings = array();
103
  if (isset($element->stateData)) {
104
    foreach ($element->stateData as $state_data) {
105

  
106
      $state  = NULL;
107

  
108
      if (isset($state_data->state)) {
109
        $state = cdm_term_representation($state_data->state);
110
      }
111

  
112
      if (isset($state_data->modifyingText_L10n)) {
113
        $state = ' ' . $state_data->modifyingText_L10n;
114
      }
115

  
116
      $modifiers_strings = cdm_modifers_representations($state_data);
117

  
118
      $state_data_strings[] = $state . ($modifiers_strings ? ' ' . $modifiers_strings : '');
119

  
120
    }
121
  }
122

  
123

  
124
  $out = '<span class="' . html_class_attribute_ref($element) . '">' . implode(', ', $state_data_strings) . '</span>';
125

  
126
  $feature_block_settings = get_feature_block_settings($element->feature->uuid);
127
  $annotations_and_sources = handle_annotations_and_sources(
128
    $element,
129
    $feature_block_settings,
130
    $out, // The description element text.
131
    $element->feature->uuid
132
  );
133

  
134
  if (!empty($annotations_and_sources['source_references'])) {
135
    $out .= ' ' . implode(' ', $annotations_and_sources['source_references']);
136
  }
137
  return $out . $annotations_and_sources['foot_note_keys'];
138
}
139

  
140 86
/**
141 87
 * Theme function to render CDM DescriptionElements of the type QuantitativeData.
142 88
 *
modules/cdm_dataportal/theme/theme_registry.inc
71 71
    'cdm_feature_name' => array('variables' => array('feature_name' => NULL)),
72 72
    'FeatureTree_hierarchy' => array('variables' => array('FeatureTreeUuid' => NULL)),
73 73
    'FeatureTree_hierarchy_children' => array('variables' => array('node' => NULL)),
74
    'cdm_descriptionElement_CategoricalData' => array('render element' => 'element'),
75 74
    'cdm_descriptionElement_QuantitativeData' => array('render element' => 'element'),
76 75
    'cdm_common_names' => array('render element' => 'elements', 'variables' => array('feature' => null) ),
77 76
    'cdm_description_element_image_source' => array('variables' => array(

Also available in: Unified diff