Project

General

Profile

« Previous | Next » 

Revision 28c5c87a

Added by Andreas Kohlbecker over 9 years ago

refactoring the feature node blocks - 1

View differences:

7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
37 37
}
38 38

  
39 39
/**
40
 * Returns HTML for a taxon profile from the $mergedFeatureNodes of a given $taxon.
40
 * Returns a set of feature blocks for a taxon profile from the $mergedFeatureNodes of a given $taxon.
41 41
 *
42
 * The taxon profile consists of description elements which are ordered by the
43
 * structure defined by specific FeatureTree. The chosen FeatureTree is merged
44
 * with the list of desctiprion elements prior to using this method.
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 45
 *
46 46
 * The merged nodes can be obtained by making use of the
47 47
 * function cdm_ws_descriptions_by_featuretree().
48 48
 *
49 49
 * @see cdm_ws_descriptions_by_featuretree()
50 50
 *
51
 * @param array $variables
52
 *   An associative array containing:
53
 *   - mergedFeatureNodes
54
 *   -taxon
51
 * @param $mergedFeatureNodes
55 52
 *
56
 * @ingroup themeable
53
 * @param $taxon
54
 *
55
 * @return array
56
 *  A Drupal render array
57
 *
58
 * @ingroup compose
57 59
 */
58
function theme_cdm_feature_nodes($variables) {
60
function compose_cdm_feature_nodes($mergedFeatureNodes, $taxon) {
59 61

  
60
  $mergedFeatureNodes = $variables['mergedFeatureNodes'];
61
  $taxon = $variables['taxon'];
62 62
  $out = '';
63 63

  
64 64
  RenderHints::pushToRenderStack('feature_nodes');
65 65

  
66 66
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME);
67 67

  
68
  // Creating an array to place the description elements in.
68
  // Create a drupal block for each feature
69 69
  foreach ($mergedFeatureNodes as $node) {
70 70

  
71
    if ((isset($node->descriptionElements['#type']) || has_feature_node_description_elements($node)) && $node->feature->uuid != UUID_IMAGE) {
71
    if ((isset($node->descriptionElements['#type']) ||
72
        has_feature_node_description_elements($node)) && $node->feature->uuid != UUID_IMAGE) { // skip empty or supressed features
72 73

  
73
      $feature_name = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
74
      $feature_name = cdm_term_representation($node->feature, 'Unnamed Feature');
74 75

  
75 76
      $block = feature_block($feature_name, $node->feature);
76 77

  
77
      $media_list = array();
78

  
79 78
      /*
80 79
       * Content/DISTRIBUTION.
81 80
       */
82
      if ($node->feature->uuid == UUID_DISTRIBUTION) {
83

  
84
        $distributionElements = null;
85
        $distribution_info_dto = null;
86
        $text_data_out_array = array();
87

  
88
        $distribution_sortOutArray = FALSE;
89
        if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') {
90
          $distribution_glue = '';
91
          $distribution_enclosingTag = 'dl';
92
        }
93
        else {
94
          $distribution_glue = '';
95
          $distribution_enclosingTag = 'ul';
96
        }
97

  
98
        if(!isset($node->descriptionElements['#type']) || !$node->descriptionElements['#type']=='DTO') {
99
          // skip the DISTRIBUTION section if there is no DTO type element
100
          continue;
101
        }
102

  
103
        if(isset($node->descriptionElements['TextData'])){
104
          // --- TextData
105
          foreach ($node->descriptionElements['TextData'] as $text_data_element){
106
            $asListElement = FALSE;
107
            $repr = theme('cdm_descriptionElementTextData', array(
108
                'element' => $text_data_element,
109
                'asListElement' => $asListElement,
110
                'feature_uuid' => $text_data_element->feature->uuid,
111
            ));
112

  
113
            if (!array_search($repr, $text_data_out_array)) {
114
              $text_data_out_array[] = $repr;
115
              // TODO HINT: sorting in theme_cdm_descriptionElementArray will
116
              // not work since this array contains html attributes with uuids
117
              // !!!!
118
              $text_data_sortOutArray = TRUE;
119
              $text_data_glue = '<br/> ';
120
              $text_data_enclosingTag = 'p';
121
            }
122
          }
123
        }
124

  
125

  
126
        if ($text_data_out_array && variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
127
          $block->content .= theme('cdm_descriptionElementArray', array(
128
            'elementArray' => $text_data_out_array,
129
            'feature' => $node->feature,
130
            'glue' => $text_data_glue,
131
            'sortArray' => $text_data_sortOutArray,
132
            'enclosingHtml' => $text_data_enclosingTag,
133
          ));
134
        }
135

  
136
        // --- Distribution map
137
        $distribution_map_query_parameters = null;
138
        if(isset($node->descriptionElements['DistributionInfoDTO'])) {
139
          $distribution_map_query_parameters = $node->descriptionElements['DistributionInfoDTO']->mapUriParams;
140
        }
141
        $map_render_element = compose_distribution_map($taxon, $distribution_map_query_parameters);
142
        $block->content .= $map_render_element['#markup'];
143

  
144
          // --- tree or list
145
            $dto_out_array = array();
146
        if(isset($node->descriptionElements['DistributionInfoDTO'])) {
147
          $distribution_info_dto = $node->descriptionElements['DistributionInfoDTO'];
148

  
149
          // --- tree
150
          if (is_object($distribution_info_dto->tree)) {
151
            $dto_out_array[] = theme('cdm_description_ordered_distributions', array('distribution_tree' => $distribution_info_dto->tree));
152
          }
153

  
154
          // --- sorted element list
155
          if( is_array($distribution_info_dto->elements) && count($distribution_info_dto->elements) > 0 ) {
156
            foreach ($distribution_info_dto->elements as $descriptionElement){
157
              if (is_object($descriptionElement->area)) {
158
                $sortKey = $descriptionElement->area->representation_L10n;
159
                $distributionElements[$sortKey] = $descriptionElement;
160
              }
161
            }
162
            ksort($distributionElements);
163
            $dto_out_array[] = theme('cdm_descriptionElement_Distribution', array(
164
                'descriptionElements' => $distributionElements,
165
            ));
166

  
167
          }
168
          //
169
          $block->content .= theme('cdm_descriptionElementArray', array(
170
              'elementArray' => $dto_out_array,
171
              'feature' => $node->feature,
172
              'glue' => $distribution_glue,
173
              'sortArray' => $distribution_sortOutArray,
174
              'enclosingHtml' => $distribution_enclosingTag,
175
          ));
176
        }
177 81

  
178
        // --- TextData at the bottom
179
        if ($text_data_out_array && !variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
180
          $block->content .= theme('cdm_descriptionElementArray', array(
181
              'elementArray' => $text_data_out_array,
182
              'feature' => $node->feature,
183
              'glue' => $text_data_glue,
184
              'sortArray' => $text_data_sortOutArray,
185
              'enclosingHtml' => $text_data_enclosingTag,
186
          ));
187
        }
82
      if ($node->feature->uuid == UUID_DISTRIBUTION) {
83
        $block = compose_feature_block_distribution($taxon, $node->descriptionElements, $node->feature);
188 84

  
189 85
      }
190

  
191 86
      /*
192 87
       * Content/COMMON_NAME.
193 88
       */
194 89
      elseif ($node->feature->uuid == UUID_COMMON_NAME) {
195
        // TODO why is theme_cdm_descriptionElement_CommonTaxonName not
196
        // beeing used???
197
       $block->content .= theme('cdm_common_names', array('elements' => $node->descriptionElements));
198
        /*
199
        }else if($node->feature->uuid == UUID_IMAGE_SOURCES) {
200
        $block->content .= theme('cdm_image_sources',
201
        $node->descriptionElements);
202
        */
90
        $common_names_render_array = compose_cdm_common_names($node->descriptionElements, $node->feature);
91
        $block->content .= drupal_render($common_names_render_array);
203 92
      }
204 93

  
205 94
      /*
206 95
       * Content/ALL OTHER FEATURES.
207 96
       */
208 97
      else {
98

  
99
        $media_list = array();
100
        $out_child_elements = '';
101

  
209 102
        if (isset($node->descriptionElements)) {
210 103
          $taxon_uuid = NULL;
211 104
          if(isset($taxon) ) {
......
218 111
          ));
219 112
        }
220 113

  
221
//           Content/ALL OTHER FEATURES/Subordinate Features
222
//           subordinate features are printed inline in one floating text,
223
//           it is expected hat supordinate features can "contain" TextData,
224
//           Qualitative- and Qualitative- DescriptioneElements
225
        if (isset($node->childNodes[0])) {
114
          // Content/ALL OTHER FEATURES/Subordinate Features
115
          // subordinate features are printed inline in one floating text,
116
          // it is expected hat supordinate features can "contain" TextData,
117
          // Qualitative- and Qualitative- DescriptioneElements
118
          if (isset($node->childNodes[0])) {
226 119

  
227 120
          // TODO support more than one level of children.
228 121
          // can this be solved by resursively calling this very function?
......
261 154
            }
262 155
          }
263 156
          $block->content .= $text;
157
          $block->content .=  compose_feature_media_gallery($node, $media_list, $gallery_settings);
158

  
159

  
160
          /*
161
           * Footnotes for the feature block
162
           */
163
          $block->content .= theme('cdm_footnotes', array('footnoteListKey' => $node->feature->uuid));
164
          $block->content .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $node->feature->uuid));
264 165
        }
265 166
      }
266 167

  
267
      /*
268
       * Media/ALL FEATURES.
269
       */
270
      if (isset($node->descriptionElements)) {
271
        $media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
272
      }
273
      $captionElements = array('title', 'rights');
274
      $gallery = '';
275
      if (isset($gallery_settings['cdm_dataportal_media_maxextend']) && isset($gallery_settings['cdm_dataportal_media_cols'])) {
276
        $gallery = theme('cdm_media_gallerie', array(
277
          'mediaList' => $media_list,
278
          'galleryName' => CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME . '_' . $node->feature->uuid,
279
          'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
280
          'cols' => $gallery_settings['cdm_dataportal_media_cols'],
281
          'captionElements' => $captionElements,
282
        ));
283
      }
284
      $block->content .= $gallery;
285
      $block->content .= theme('cdm_footnotes', array('footnoteListKey' => $node->feature->uuid));
286
      $block->content .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $node->feature->uuid));
287 168

  
288
      // In D6: $out .= theme('block', $block);
289
      // Comment @WA @TODO check if need to set a region, and which one.
290
      $block->region = FALSE;
291 169
      $out .= theme('block',
292 170
        array(
293 171
          'elements' => array(
......
296 174
          )
297 175
        )
298 176
      );
299
    }
300
  }
177
    } // END: skip empty or supressed features
178
  } // END: creating a block per feature
301 179
  RenderHints::popFromRenderStack();
302
  return $out;
180

  
181
  return markup_to_render_array($out);
303 182
}
304 183

  
184
  /**
185
   * @param $node
186
   * @param $media_list
187
   * @param $gallery_settings
188
   * @return array
189
   */
190
  function compose_feature_media_gallery($node, $media_list, $gallery_settings) {
191
    if (isset($node->descriptionElements)) {
192
      $media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
193
    }
194
    $captionElements = array('title', 'rights');
195
    $gallery = '';
196
    if (isset($gallery_settings['cdm_dataportal_media_maxextend']) && isset($gallery_settings['cdm_dataportal_media_cols'])) {
197
      $gallery = theme('cdm_media_gallerie', array(
198
        'mediaList' => $media_list,
199
        'galleryName' => CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME . '_' . $node->feature->uuid,
200
        'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
201
        'cols' => $gallery_settings['cdm_dataportal_media_cols'],
202
        'captionElements' => $captionElements,
203
      ));
204
      return array($media_list, $gallery);
205
    }
206
    return array($media_list, $gallery);
207
  }
305 208

  
209
  /**
210
   * @param $taxon
211
   * @param $descriptionElements
212
   *   an associative array with two elements:
213
   *   - '#type': must be 'DTO'
214
   *   - 'DistributionInfoDTO': a CDM DistributionInfoDTO object as returned by the DistributionInfo web service
215
   * @param $feature
216
   *
217
   * @ingroup compose
218
   */
219
  function compose_feature_block_distribution($taxon, $descriptionElements, $feature) {
220
    $text_data_glue = '';
221
    $text_data_sortOutArray = FALSE;
222
    $text_data_enclosingTag = 'ul';
223
    $text_data_out_array = array();
224

  
225
    $distributionElements = NULL;
226
    $distribution_info_dto = NULL;
227
    $distribution_sortOutArray = FALSE;
228

  
229
    if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') {
230
      $distribution_glue = '';
231
      $distribution_enclosingTag = 'dl';
232
    } else {
233
      $distribution_glue = '';
234
      $distribution_enclosingTag = 'ul';
235
    }
306 236

  
307
/**
237
    if (!isset($descriptionElements['#type']) || !$descriptionElements['#type'] == 'DTO') {
238
      // skip the DISTRIBUTION section if there is no DTO type element
239
      return array(); // FIXME is it ok to return an empty array?
240
    }
241

  
242
    $block = feature_block(
243
      cdm_term_representation($feature, 'Unnamed Feature'),
244
      $feature
245
    );
246

  
247
    // ======== FIXME is this being used at all? seems to make no sense!!!
248
    if (isset($descriptionElements['TextData'])) {
249
      // --- TextData
250
      foreach ($descriptionElements['TextData'] as $text_data_element) {
251
        $asListElement = FALSE;
252
        $repr = theme('cdm_descriptionElementTextData', array(
253
          'element' => $text_data_element,
254
          'asListElement' => $asListElement,
255
          'feature_uuid' => $text_data_element->feature->uuid,
256
        ));
257

  
258
        if (!array_search($repr, $text_data_out_array)) {
259
          $text_data_out_array[] = $repr;
260
          // TODO HINT: sorting in theme_cdm_feature_block_elements will
261
          // not work since this array contains html attributes with uuids
262
          // !!!!
263
          $text_data_sortOutArray = TRUE;
264
          $text_data_glue = '<br/> ';
265
          $text_data_enclosingTag = 'p';
266
        }
267
      }
268
    }
269

  
270

  
271
    if ($text_data_out_array && variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
272
      $block->content .= theme('cdm_feature_block_elements', array(
273
        'elementArray' => $text_data_out_array,
274
        'feature' => $feature,
275
        'glue' => $text_data_glue,
276
        'sortArray' => $text_data_sortOutArray,
277
        'enclosingHtml' => $text_data_enclosingTag,
278
      ));
279
    }
280

  
281
    // --- Distribution map
282
    $distribution_map_query_parameters = NULL;
283
    if (isset($descriptionElements['DistributionInfoDTO'])) {
284
      $distribution_map_query_parameters = $descriptionElements['DistributionInfoDTO']->mapUriParams;
285
    }
286
    $map_render_element = compose_distribution_map($taxon, $distribution_map_query_parameters);
287
    $block->content .= $map_render_element['#markup'];
288

  
289
    // --- tree or list
290
    $dto_out_array = array();
291
    if (isset($descriptionElements['DistributionInfoDTO'])) {
292
      $distribution_info_dto = $descriptionElements['DistributionInfoDTO'];
293

  
294
      // --- tree
295
      if (is_object($distribution_info_dto->tree)) {
296
        $dto_out_array[] = theme('cdm_description_ordered_distributions', array('distribution_tree' => $distribution_info_dto->tree));
297
      }
298

  
299
      // --- sorted element list
300
      if (is_array($distribution_info_dto->elements) && count($distribution_info_dto->elements) > 0) {
301
        foreach ($distribution_info_dto->elements as $descriptionElement) {
302
          if (is_object($descriptionElement->area)) {
303
            $sortKey = $descriptionElement->area->representation_L10n;
304
            $distributionElements[$sortKey] = $descriptionElement;
305
          }
306
        }
307
        ksort($distributionElements);
308
        $dto_out_array[] = theme('cdm_descriptionElement_Distribution', array(
309
          'descriptionElements' => $distributionElements,
310
        ));
311

  
312
      }
313
      //
314
      $block->content .= theme('cdm_feature_block_elements', array(
315
        'elementArray' => $dto_out_array,
316
        'feature' => $feature,
317
        'glue' => $distribution_glue,
318
        'sortArray' => $distribution_sortOutArray,
319
        'enclosingHtml' => $distribution_enclosingTag,
320
      ));
321
    }
322

  
323
    // --- TextData at the bottom
324
    if ($text_data_out_array && !variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
325
      $block->content .= theme('cdm_feature_block_elements', array(
326
        'elementArray' => $text_data_out_array,
327
        'feature' => $feature,
328
        'glue' => $text_data_glue,
329
        'sortArray' => $text_data_sortOutArray,
330
        'enclosingHtml' => $text_data_enclosingTag,
331
      ));
332
    }
333

  
334
    $block->content .= theme('cdm_footnotes', array('footnoteListKey' => UUID_DISTRIBUTION));
335
    $block->content .= theme('cdm_annotation_footnotes', array('footnoteListKey' => UUID_DISTRIBUTION));
336

  
337
    return $block;
338
  }
339

  
340

  
341
  /**
308 342
 * @todo Please document this function.
309 343
 * @see http://drupal.org/node/1354
310 344
 */
......
365 399
 *
366 400
 * @ingroup themeable
367 401
 */
368
function theme_cdm_descriptionElementArray($variables) {
402
function theme_cdm_feature_block_elements($variables) {
369 403
  $elementArray = $variables['elementArray'];
370

  
371 404
  $feature = $variables['feature'];
372 405
  $glue = $variables['glue'];
373 406
  $sortArray = $variables['sortArray'];
374 407
  $enclosingHtml = $variables['enclosingHtml'];
375
  $out = '<' . $enclosingHtml . ' class="description" id="' . $feature->representation_L10n . '">';
408

  
409
  $out = '<' . $enclosingHtml . ' class="feature-block-elements" id="' . $feature->representation_L10n . '">';
376 410

  
377 411
  if ($sortArray) {
378 412
    sort($elementArray);
379 413
  }
380 414

  
381
  $out .= join($elementArray, $glue);
415
  $out .= '<span class="feature-block-element">' . join($elementArray, '<span class="feature-block-element">' . $glue . '</span>') . '</span>';
382 416

  
383 417
  $out .= '</' . $enclosingHtml . '>';
384 418
  return $out;
385 419
}
386 420

  
387
/**
388
 * Theme function to render CDM DescriptionElements of the type CommonTaxonName.
389
 *
390
 * @param array $variables
391
 *   An associative array containing:
392
 *  - element: the CommonTaxonName element
393
 * @return a html representation of the given CommonTaxonName element
394
 *
395
 * @ingroup themeable
396
 */
397
function theme_cdm_descriptionElement_CommonTaxonName($variables) {
398
  $element = $variables['element'];
399
  $out = '<span class="' . html_class_attribute_ref($element) . '">' . $element->language->representation_L10n . ' (' . $element->area->titleCache . '): ' . $element->name . '</span>';
400
  return $out;
401
}
402 421

  
403 422
/**
404 423
 * Theme function to render CDM DescriptionElements of the type CategoricalData.
......
487 506
  if (isset($element->statisticalValues->modifyingText_L10n)) {
488 507
    $out .=  ' ' . $element->statisticalValues->modifyingText_L10n;
489 508
  }
490
  $modifers_string = cdm_modifers_representations($element->statisticalValues);
491
  $out .= ($modifers_string ? ' ' . cdm_modifers_representations($element->statisticalValues) : '');
509
  $modifiers_strings = cdm_modifers_representations($element->statisticalValues);
510
  $out .= ($modifiers_strings ? ' ' . cdm_modifers_representations($element->statisticalValues) : '');
492 511

  
493 512
  $footnote_key_list_str = cdm_create_description_element_footnotes($element);
494 513

  
......
589 608
    $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
590 609
  }
591 610
  $sourceRefs = '';
592
  $result = array();
593 611
  $out = '';
594
  $res_author = '';
595
  $res_date = '';
612

  
596 613
  if (isset($element->sources) && is_array($element->sources) && count($element->sources) > 0) {
597 614
    foreach ($element->sources as $source) {
598 615
      $referenceCitation = theme('cdm_OriginalSource', array('source' => $source));
......
631 648
            $out .= $name_used_in_source_link_to_show . ' ';
632 649
          }
633 650
        }
634
        $out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $element, 'footnote_list_key' => $feature_uuid)) . '</li>';
651
        $out .= $description . $sourceRefs . theme(
652
            'cdm_annotations_as_footnotekeys',
653
            array('cdmBase_list' => $element,
654
              'footnote_list_key' => $feature_uuid)) . '</li>';
635 655
      }
636 656
      else {
637 657
        if ($name_used_in_source_link_to_show) {
......
647 667
    $out = $description;
648 668
  }
649 669

  
650
  // FIXME This will create footnotes for annotatios and source, sources are already rendered though
670
  // FIXME This will create footnotes for annotations and sources, sources are already rendered though
651 671
  // FIXME the footnoes are not shown in the page
652 672
  // FIXME RenderHints::getFootnoteListKey() ate not set here
653 673
  // to many problems, so the below line is diabled for now
......
658 678
}
659 679

  
660 680
/**
661
 * @todo Please document this function.
662
 * @see http://drupal.org/node/1354
681
 * Composes block of common names for the given DescriptionElements $elements which must be of the feature CommonName
682
 *
683
 * @parameter $elements
684
 *  an array of CDM DescriptionElements either of type CommonName or TextData
685
 * @parameter $feature
686
 *  the common feature of all $elements, must be CommonName
687
 *
688
 * @return
689
 *   A drupal render array
690
 *
691
 * @ingroup compose
663 692
 */
664
function theme_cdm_common_names($variables) {
665
  $elements = $variables['elements'];
666
  $text_data_out = '';
693
function compose_cdm_common_names($elements, $feature) {
694

  
667 695
  $common_name_out = '';
668
  $separator = ',';
696
  $common_name_feature_elements = array();
669 697
  $textData_commonNames = array();
670 698

  
699
  $footnote_key_suggestion = 'common-names-feature-block';
700

  
671 701
  if (is_array($elements)) {
672 702
    foreach ($elements as $element) {
703

  
673 704
      if ($element->class == 'CommonTaxonName') {
674 705

  
675 706
        // common name without a language or area, should not happen but is possible
......
702 733
    // can give strange results.
703 734
    ksort($common_names);
704 735

  
705
    // Creating the output to be render by Drupal.
706
    foreach ($common_names as $key => $elements) {
736
    // loop over set of elements per language area
737
    foreach ($common_names as $language_area_key => $elements) {
707 738
      ksort($elements); // sort names alphabetically
708
      $rendered_element_list = '';
739
      $per_language_area_out = array();
740
      // loop over set of individual elements
709 741
      foreach ($elements as $element) {
710
        $sourcesFootnoteKeyList = '';
711
        // Adding footnotes sources.
712
        foreach ($element->sources as $source) {
713
          if (_is_original_source_type($source)) {
714
            $_fkey = FootnoteManager::addNewFootnote(original_source_footnote_list_key(UUID_COMMON_NAME), theme('cdm_OriginalSource', array('source' => $source, 'doLink' => FALSE)));
715
            $sourcesFootnoteKeyList .= theme('cdm_footnote_key', array('footnoteKey' => $_fkey, 'separator' => ($sourcesFootnoteKeyList ? $separator : '')));
716
          }
717
        }
718 742
        if ($element->name) {
719
          $rendered_element_list .= '<span class="' . html_class_attribute_ref($element) . '">' . (strlen($rendered_element_list) > 0 ? ', ' : '') . $element->name . $sourcesFootnoteKeyList . '</span>';
743
          $per_language_area_out[] = '<span class="' . html_class_attribute_ref($element) . '">'
744
          . $element->name . cdm_create_description_element_footnotes($element, ',', $footnote_key_suggestion) . '</span>';
720 745
        }
721
      }
722
      if ($key) {
723
        $common_name_out .= (strlen($common_name_out) > 0 ? '; ' : '') . $key . ': ' . $rendered_element_list;
724
      }
725
      else {
726
        $common_name_out .= (strlen($common_name_out) > 0 ? '; ' : '') . $rendered_element_list;
727
      }
728
    }
746
      } // End of loop over set of individual elements
747
      $common_name_feature_elements[] = ($language_area_key ? $language_area_key . ': ' : '' ) . join(',', $per_language_area_out);
748
    } // End of loop over set of elements per language area
749

  
750

  
751
    $common_name_out .= theme('cdm_feature_block_elements',
752
      array(
753
        'elementArray' => $common_name_feature_elements,
754
        'feature' => $feature,
755
        'glue' => ';',
756
        'sortArray' => FALSE,
757
        'enclosingHtml' => 'div',
758
      )
759
    );
760

  
761

  
729 762
  }
763

  
730 764
  // Handling commons names as text data.
765
  $text_data_out = array();
766

  
731 767
  foreach ($textData_commonNames as $text_data_element) {
732
    $text_data_out .= theme('cdm_descriptionElementTextData', array(
768
    /* footnotes are not handled correctly in theme_cdm_descriptionElementTextData,
769
       need to set 'common-names-feature-block' as $footnote_key_suggestion */
770
    RenderHints::setFootnoteListKey($footnote_key_suggestion);
771
    $text_data_out[] = theme('cdm_descriptionElementTextData', array(
733 772
      'element' => $text_data_element,
734 773
      'asListElement' => TRUE,
735 774
      'feature_uuid' => $text_data_element->feature->uuid,
736 775
    ));
737 776
  }
738 777

  
739
  $common_name_out = "<div class=common_names_as_common_names> $common_name_out </div>";
740
  $out_array[] = $text_data_out;
741
  $common_name_out_text_data = '<div class=common_names_as_text_data>' . theme('cdm_descriptionElementArray', array('elementArray' => $out_array, 'feature' => $element->feature)) . '</div>';
778
  $common_name_out_text_data = theme(
779
        'cdm_feature_block_elements',
780
        array(
781
          'elementArray' => $text_data_out,
782
          'feature' => $feature
783
        )
784
      );
742 785

  
743
  return $common_name_out . $common_name_out_text_data;
744
  /*
745
  return $common_name_out . theme('cdm_descriptionElementArray', $out_array,
746
  $element->feature);
747
  return "<div class=common_names> $common_name_out
748
  $common_name_out_text_data";
749
  */
786

  
787
  $footnotes = theme('cdm_footnotes', array('footnoteListKey' => $footnote_key_suggestion)); // FIXME is this needed at all?
788
  $footnotes .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $footnote_key_suggestion));
789

  
790
  return  markup_to_render_array(
791
    '<div class="common_names_as_common_names">' . $common_name_out . '</div>'
792
    .'<div class="common_names_as_text_data">' . $common_name_out_text_data . '</div>'
793
    .$footnotes
794
  );
750 795
}
751 796

  
752 797
/**
......
760 805
 *     These descriptions elements of a Description must be ordered by the chosen feature tree by
761 806
 *     calling the function _mergeFeatureTreeDescriptions().
762 807
 *     @see _mergeFeatureTreeDescriptions()
763
 *   - featureUuid: currently unused, accoding code disabled
764
 *   - taxon_uuid: only used for ordered dditributions (will be removed!)
808
 *   - featureUuid: currently unused, according code disabled
809
 *   - taxon_uuid: only used for ordered distributions (will be removed!)
765 810
 *
766 811
 * @ingroup themeable
767 812
 */
......
831 876
              'feature_uuid' => $descriptionElement->feature->uuid,
832 877
            ));
833 878
            break;
834
          case 'CommonTaxonName':
835
            $outArray[] = theme('cdm_descriptionElement_CommonTaxonName', array('element' => $descriptionElement));
836
          break;
837 879
          case 'CategoricalData':
838 880
            $outArray[] = theme('cdm_descriptionElement_CategoricalData', array('element' => $descriptionElement));
839 881
            break;
......
867 909
  } // END normal description element arrays
868 910

  
869 911

  
870
  $out = theme('cdm_descriptionElementArray', array(
912
  $out = theme('cdm_feature_block_elements', array(
871 913
    'elementArray' => $outArray,
872 914
    'feature' => $feature,
873 915
    'glue' => $glue,

Also available in: Unified diff