Revision c367b0ab
Added by Andreas Kohlbecker over 9 years ago
7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme | ||
---|---|---|
257 | 257 |
|
258 | 258 |
if (!array_search($repr, $text_data_out_array)) { |
259 | 259 |
$text_data_out_array[] = $repr; |
260 |
// TODO HINT: sorting in theme_cdm_feature_block_elements will
|
|
260 |
// TODO HINT: sorting in compose_cdm_feature_block_elements will
|
|
261 | 261 |
// not work since this array contains html attributes with uuids |
262 | 262 |
// !!!! |
263 | 263 |
$text_data_sortOutArray = TRUE; |
... | ... | |
269 | 269 |
|
270 | 270 |
|
271 | 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 |
));
|
|
272 |
$block->content .= compose_cdm_feature_block_elements(
|
|
273 |
$text_data_out_array, |
|
274 |
$feature, |
|
275 |
$text_data_glue, |
|
276 |
$text_data_sortOutArray, |
|
277 |
$text_data_enclosingTag
|
|
278 |
); |
|
279 | 279 |
} |
280 | 280 |
|
281 | 281 |
// --- Distribution map |
... | ... | |
311 | 311 |
|
312 | 312 |
} |
313 | 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 |
));
|
|
314 |
$block->content .= compose_cdm_feature_block_elements(
|
|
315 |
$dto_out_array, |
|
316 |
$feature, |
|
317 |
$distribution_glue, |
|
318 |
$distribution_sortOutArray, |
|
319 |
$distribution_enclosingTag
|
|
320 |
); |
|
321 | 321 |
} |
322 | 322 |
|
323 | 323 |
// --- TextData at the bottom |
324 | 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 |
));
|
|
325 |
$block->content .= compose_cdm_feature_block_elements(
|
|
326 |
$text_data_out_array, |
|
327 |
$feature, |
|
328 |
$text_data_glue, |
|
329 |
$text_data_sortOutArray, |
|
330 |
$text_data_enclosingTag
|
|
331 |
); |
|
332 | 332 |
} |
333 | 333 |
|
334 | 334 |
$block->content .= theme('cdm_footnotes', array('footnoteListKey' => UUID_DISTRIBUTION)); |
... | ... | |
384 | 384 |
} |
385 | 385 |
|
386 | 386 |
/** |
387 |
* Returns HTML for the texts in a description $elementArray.
|
|
387 |
* Returns HTML for the texts in a description $elements.
|
|
388 | 388 |
* |
389 |
* Joins the texts in $elementArray and encloses with a HTML tag.
|
|
389 |
* Joins the texts in $elements and encloses with a HTML tag.
|
|
390 | 390 |
* |
391 |
* @param array $variables
|
|
392 |
* An associative array containing:
|
|
393 |
* - elementArray
|
|
394 |
* - feature: The feature to which the elements given in $elementArray are
|
|
395 |
* belonging to.
|
|
396 |
* - glue: Defaults to empty string.
|
|
397 |
* - sortArray: Whether to sort the $elementArray alphabetically.
|
|
398 |
* - enclosingHtml
|
|
391 |
* @param $elements
|
|
392 |
* @param feature:
|
|
393 |
* The feature to which the elements given in $elements are belonging to.
|
|
394 |
* @param glue:
|
|
395 |
* Defaults to empty string.
|
|
396 |
* @param $sort
|
|
397 |
* Boolean Whether to sort the $elements alphabetically, default is FALSE
|
|
398 |
* @param $enclosing_tag
|
|
399 | 399 |
* |
400 |
* @ingroup themeable
|
|
400 |
* @ingroup compose
|
|
401 | 401 |
*/ |
402 |
function theme_cdm_feature_block_elements($variables) {
|
|
403 |
$elementArray = $variables['elementArray']; |
|
404 |
$feature = $variables['feature'];
|
|
405 |
$glue = $variables['glue'];
|
|
406 |
$sortArray = $variables['sortArray'];
|
|
407 |
$enclosingHtml = $variables['enclosingHtml'];
|
|
402 |
function compose_cdm_feature_block_elements($elements, $feature, $glue = '', $sort = FALSE, $enclosing_tag = 'ul') {
|
|
403 |
|
|
404 |
$feature_block_settings = get_feature_block_settings();
|
|
405 |
if($feature_block_settings['as_list']){
|
|
406 |
$enclosing_tag = $feature_block_settings['as_list'];
|
|
407 |
}
|
|
408 | 408 |
|
409 |
$out = '<' . $enclosingHtml . ' class="feature-block-elements" id="' . $feature->representation_L10n . '">';
|
|
409 |
$out = '<' . $enclosing_tag . ' class="feature-block-elements" id="' . $feature->representation_L10n . '">';
|
|
410 | 410 |
|
411 |
if ($sortArray) {
|
|
412 |
sort($elementArray);
|
|
411 |
if ($sort) { |
|
412 |
sort($elements);
|
|
413 | 413 |
} |
414 | 414 |
|
415 |
$out .= '<span class="feature-block-element">' . join($elementArray, '<span class="feature-block-element">' . $glue . '</span>') . '</span>'; |
|
415 |
//TODO it would be nice if any element would get "feature-block-element" as additional class attribute |
|
416 |
// this will become possible once all $elemets are real Drupal render arrays |
|
417 |
$out .= join($elements, $glue) ; |
|
416 | 418 |
|
417 |
$out .= '</' . $enclosingHtml . '>';
|
|
419 |
$out .= '</' . $enclosing_tag . '>';
|
|
418 | 420 |
return $out; |
419 | 421 |
} |
420 | 422 |
|
... | ... | |
626 | 628 |
$name_used_in_source_link_to_show = ''; |
627 | 629 |
// Do a link to name page. |
628 | 630 |
if (isset($source->nameUsedInSource->uuid) && isset($source->nameUsedInSource->titleCache)) { |
631 |
// it is a DescriptionElementSource |
|
629 | 632 |
$name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache, path_to_name($source->nameUsedInSource->uuid), array( |
630 | 633 |
'attributes' => array(), |
631 | 634 |
'absolute' => TRUE, |
632 | 635 |
'html' => TRUE, |
633 | 636 |
)); |
634 | 637 |
} |
635 |
// Show a text without link. |
|
636 |
elseif (isset($source->nameUsedInSource->originalNameString) && strlen($source->nameUsedInSource->originalNameString) > 0) { |
|
638 |
else if (isset($source->nameUsedInSource->originalNameString) && strlen($source->nameUsedInSource->originalNameString) > 0) { |
|
639 |
// it is NOT a DescriptionElementSource |
|
640 |
// Show a text without link. |
|
637 | 641 |
$name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString; |
638 | 642 |
} |
639 | 643 |
|
... | ... | |
744 | 748 |
. $element->name . cdm_create_description_element_footnotes($element, ',', $footnote_key_suggestion) . '</span>'; |
745 | 749 |
} |
746 | 750 |
} // End of loop over set of individual elements |
747 |
$common_name_feature_elements[] = ($language_area_key ? $language_area_key . ': ' : '' ) . join(',', $per_language_area_out); |
|
751 |
$common_name_feature_elements[] = ($language_area_key ? $language_area_key . ': ' : '' ) . join(', ', $per_language_area_out);
|
|
748 | 752 |
} // End of loop over set of elements per language area |
749 | 753 |
|
750 | 754 |
|
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 |
); |
|
755 |
$common_name_out .= compose_cdm_feature_block_elements( |
|
756 |
$common_name_feature_elements, |
|
757 |
$feature, |
|
758 |
'; ', |
|
759 |
FALSE, |
|
760 |
'div' |
|
761 |
); |
|
760 | 762 |
|
761 | 763 |
|
762 | 764 |
} |
... | ... | |
775 | 777 |
)); |
776 | 778 |
} |
777 | 779 |
|
778 |
$common_name_out_text_data = theme( |
|
779 |
'cdm_feature_block_elements', |
|
780 |
array( |
|
781 |
'elementArray' => $text_data_out, |
|
782 |
'feature' => $feature |
|
783 |
) |
|
780 |
$common_name_out_text_data = compose_cdm_feature_block_elements( |
|
781 |
$text_data_out, |
|
782 |
$feature |
|
784 | 783 |
); |
785 | 784 |
|
786 | 785 |
|
... | ... | |
897 | 896 |
} |
898 | 897 |
} // --- END loop over normal description element arrays |
899 | 898 |
|
900 |
// If feature = NAME USAGE sort the list of sources.
|
|
899 |
// If feature = CITATION sort the list of sources.
|
|
901 | 900 |
// This is ONLY for FLORA MALESIANA and FLORE d'AFRIQUE CENTRALE. |
902 |
if ($descriptionElement->feature->uuid == UUID_NAME_USAGE) {
|
|
901 |
if ($descriptionElement->feature->uuid == UUID_CITATION) {
|
|
903 | 902 |
sort($outArray); |
904 | 903 |
} |
905 | 904 |
|
... | ... | |
909 | 908 |
} // END normal description element arrays |
910 | 909 |
|
911 | 910 |
|
912 |
$out = theme('cdm_feature_block_elements', array(
|
|
913 |
'elementArray' => $outArray,
|
|
914 |
'feature' => $feature,
|
|
915 |
'glue' => $glue,
|
|
916 |
'sortArray' => $sortOutArray,
|
|
917 |
'enclosingHtml' => $enclosingTag,
|
|
918 |
));
|
|
911 |
$out = compose_cdm_feature_block_elements(
|
|
912 |
$outArray, |
|
913 |
$feature, |
|
914 |
$glue, |
|
915 |
$sortOutArray, |
|
916 |
$enclosingTag
|
|
917 |
); |
|
919 | 918 |
|
920 | 919 |
RenderHints::popFromRenderStack(); |
921 | 920 |
return $out; |
Also available in: Unified diff
refactoring the feature node blocks - 2 + adapting test suite