363 |
363 |
* @param $element_markup
|
364 |
364 |
* @param $footnote_list_key_suggestion
|
365 |
365 |
*/
|
366 |
|
function cdm_description_element_render_array_add_annotations_and_sources(&$render_array, $element, $feature_block_settings, $element_markup, $footnote_list_key_suggestion)
|
|
366 |
function compose_description_element($element, $feature_block_settings, $element_markup, $footnote_list_key_suggestion)
|
367 |
367 |
{
|
|
368 |
|
|
369 |
$render_array = array(
|
|
370 |
'#type' => 'html_tag',
|
|
371 |
'#tag' => cdm_feature_block_element_tag_name($feature_block_settings),
|
|
372 |
|
|
373 |
'#attributes' => array(
|
|
374 |
'class' => 'DescriptionElement DescriptionElement-' . $element->class . '
|
|
375 |
' . html_class_attribute_ref($element)
|
|
376 |
),
|
|
377 |
|
|
378 |
'#value' => '',
|
|
379 |
'#value_suffix' => NULL
|
|
380 |
|
|
381 |
);
|
|
382 |
|
368 |
383 |
$annotations_and_sources = handle_annotations_and_sources($element, $feature_block_settings, $element_markup, $footnote_list_key_suggestion);
|
369 |
384 |
|
|
385 |
// handle the special case were the TextData is used as container for original source with name
|
|
386 |
// used in source information without any text stored in it.
|
370 |
387 |
$names_used_in_source_markup = '';
|
371 |
388 |
if (!empty($annotations_and_sources['names_used_in_source']) && empty($element_markup)) {
|
372 |
389 |
// $element_text == NULL usually occurs only in the case of CITATIONS!!!
|
... | ... | |
380 |
397 |
|
381 |
398 |
$render_array['#value'] = $names_used_in_source_markup . $element_markup . $source_references_markup;
|
382 |
399 |
$render_array['#value_suffix'] = $annotations_and_sources['foot_note_keys'];
|
|
400 |
|
|
401 |
return $render_array;
|
383 |
402 |
}
|
384 |
403 |
|
385 |
404 |
|
... | ... | |
608 |
627 |
|
609 |
628 |
switch ($element->class) {
|
610 |
629 |
case 'TextData':
|
611 |
|
// FIXME use compose_description_element_textdata()
|
|
630 |
// FIXME use compose_description_element_text_data()
|
612 |
631 |
if(isset($element->multilanguageText_L10n->text)){
|
613 |
632 |
$out_child_elements = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
|
614 |
633 |
}
|
... | ... | |
738 |
757 |
if (isset($descriptionElements['TextData'])) {
|
739 |
758 |
// --- TextData
|
740 |
759 |
foreach ($descriptionElements['TextData'] as $text_data_element) {
|
741 |
|
$asListElement = FALSE;
|
742 |
|
$text_data_render_array = compose_description_element_textdata($text_data_element, $asListElement, $text_data_element->feature->uuid);
|
|
760 |
$text_data_render_array = compose_description_element_text_data($text_data_element, $text_data_element->feature->uuid, $feature_block_settings);
|
743 |
761 |
$repr = drupal_render($text_data_render_array);
|
744 |
762 |
|
745 |
763 |
if (!array_search($repr, $text_data_out_array)) { // de-duplication !!
|
... | ... | |
867 |
885 |
* Composes a drupal render array for single CDM TextData description element.
|
868 |
886 |
*
|
869 |
887 |
* @param $element
|
870 |
|
* The CDN TextData description element.
|
871 |
|
* @param $asListElement
|
872 |
|
* A boolean which determines whether the citations should
|
873 |
|
* be rendered as a list or not.
|
874 |
|
* TODO remove and replace $asListElement by $feature_block_settings['as_list']
|
|
888 |
* The CDM TextData description element.
|
875 |
889 |
* @param $feature_uuid
|
876 |
890 |
*
|
877 |
891 |
* @return array
|
... | ... | |
884 |
898 |
*
|
885 |
899 |
* @ingroup compose
|
886 |
900 |
*/
|
887 |
|
function compose_description_element_textdata($element, $asListElement, $feature_uuid) {
|
|
901 |
function compose_description_element_text_data($element, $feature_uuid, $feature_block_settings) {
|
888 |
902 |
|
889 |
903 |
$footnote_list_key_suggestion = $feature_uuid;
|
890 |
904 |
|
891 |
|
// FIXME $feature_block_settings should be passed as parameter!!!!!
|
892 |
|
$feature_block_settings = get_feature_block_settings($feature_uuid);
|
893 |
|
|
|
905 |
/*
|
894 |
906 |
// FIXME remove this hack ---------------------------
|
895 |
907 |
$default_theme = variable_get('theme_default', NULL);
|
896 |
908 |
if($default_theme == 'garland_cichorieae' || $default_theme == 'cyprus'
|
... | ... | |
898 |
910 |
$asListElement = $feature_block_settings['as_list'] == 'ul';
|
899 |
911 |
}
|
900 |
912 |
// --------------------------------------------------
|
|
913 |
*/
|
901 |
914 |
|
902 |
|
$render_array = array(
|
903 |
|
'#type' => 'html_tag',
|
904 |
|
'#tag' => $asListElement ? 'li' : 'span',
|
905 |
|
'#attributes' => array(
|
906 |
|
'class' => 'DescriptionElement DescriptionElement-' . $element->class . '
|
907 |
|
' . html_class_attribute_ref($element)
|
908 |
|
),
|
909 |
|
'#value' => '',
|
910 |
|
'#value_suffix' => NULL
|
911 |
|
);
|
912 |
|
|
913 |
|
$element_text = '';
|
|
915 |
$element_markup = '';
|
914 |
916 |
if (isset($element->multilanguageText_L10n->text)) {
|
915 |
917 |
// TODO replacement of \n by <br> should be configurable
|
916 |
|
$element_text = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
|
|
918 |
$element_markup = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
|
917 |
919 |
}
|
918 |
920 |
|
919 |
|
cdm_description_element_render_array_add_annotations_and_sources($render_array, $element, $feature_block_settings, $element_text, $footnote_list_key_suggestion);
|
|
921 |
$render_array = compose_description_element($element, $feature_block_settings, $element_markup, $footnote_list_key_suggestion);
|
920 |
922 |
|
921 |
923 |
return $render_array;
|
922 |
924 |
}
|
... | ... | |
1038 |
1040 |
}
|
1039 |
1041 |
}
|
1040 |
1042 |
|
1041 |
|
|
1042 |
1043 |
$out = '<span class="' . html_class_attribute_ref($element) . '">' . implode(', ', $state_data_strings) . '</span>';
|
1043 |
1044 |
|
1044 |
1045 |
$feature_block_settings = get_feature_block_settings($element->feature->uuid);
|
... | ... | |
1197 |
1198 |
{
|
1198 |
1199 |
|
1199 |
1200 |
$feature_block_settings = get_feature_block_settings($feature->uuid);
|
1200 |
|
if($feature_block_settings['as_list']){
|
1201 |
|
$enclosing_tag = $feature_block_settings['as_list'];
|
1202 |
|
} else {
|
1203 |
|
$out = "ERROR</body></html>";
|
1204 |
|
return;
|
1205 |
|
}
|
|
1201 |
$enclosing_tag = $feature_block_settings['as_list'];
|
1206 |
1202 |
|
1207 |
1203 |
$out = '<' . $enclosing_tag . ' class="feature-block-elements" id="' . $feature->representation_L10n . '">';
|
1208 |
1204 |
|
... | ... | |
1335 |
1331 |
$feature_block_settings = get_feature_block_settings($descriptionElement->feature->uuid);
|
1336 |
1332 |
switch ($descriptionElement->class) {
|
1337 |
1333 |
case 'TextData':
|
1338 |
|
$asListElement = $feature_block_settings['as_list'] == 'ul';
|
1339 |
|
$text_data_render_array = compose_description_element_textdata($descriptionElement, $asListElement, $descriptionElement->feature->uuid);
|
|
1334 |
$text_data_render_array = compose_description_element_text_data($descriptionElement, $descriptionElement->feature->uuid, $feature_block_settings);
|
1340 |
1335 |
$feature_block_has_content = $feature_block_has_content || !empty($text_data_render_array['#value']);
|
1341 |
1336 |
$elements_out_array[] = drupal_render($text_data_render_array);
|
1342 |
1337 |
break;
|
... | ... | |
1367 |
1362 |
|
1368 |
1363 |
// If feature = CITATION sort the list of sources.
|
1369 |
1364 |
// This is ONLY for FLORA MALESIANA and FLORE d'AFRIQUE CENTRALE.
|
1370 |
|
if ($descriptionElement->feature->uuid == UUID_CITATION) {
|
|
1365 |
if (isset($descriptionElement) && $descriptionElement->feature->uuid == UUID_CITATION) {
|
1371 |
1366 |
sort($elements_out_array);
|
1372 |
1367 |
}
|
1373 |
1368 |
}
|
... | ... | |
1473 |
1468 |
$text_data_out = array();
|
1474 |
1469 |
|
1475 |
1470 |
foreach ($textData_commonNames as $text_data_element) {
|
1476 |
|
/* footnotes are not handled correctly in compose_description_element_textdata,
|
|
1471 |
/* footnotes are not handled correctly in compose_description_element_text_data,
|
1477 |
1472 |
need to set 'common-names-feature-block' as $footnote_key_suggestion */
|
1478 |
1473 |
RenderHints::setFootnoteListKey($footnote_key_suggestion);
|
1479 |
|
$text_data_render_array = compose_description_element_textdata($text_data_element, TRUE, $text_data_element->feature->uuid);
|
|
1474 |
$text_data_render_array = compose_description_element_text_data($text_data_element, $text_data_element->feature->uuid, $feature_block_settings);
|
1480 |
1475 |
$text_data_out[] = drupal_render($text_data_render_array);
|
1481 |
1476 |
}
|
1482 |
1477 |
|
cleaning up compose_description_element_text_data()