Revision 159cd9bb
Added by Andreas Kohlbecker over 9 years ago
7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme | ||
---|---|---|
75 | 75 |
|
76 | 76 |
$block = feature_block($feature_name, $node->feature); |
77 | 77 |
$block->content = array(); |
78 |
$block_content_is_empty = TRUE; |
|
78 | 79 |
$block_content_weight = 0; |
79 | 80 |
|
80 | 81 |
/* |
... | ... | |
83 | 84 |
|
84 | 85 |
if ($node->feature->uuid == UUID_DISTRIBUTION) { |
85 | 86 |
$block = compose_feature_block_distribution($taxon, $node->descriptionElements, $node->feature); |
87 |
$block_content_is_empty = FALSE; |
|
86 | 88 |
} |
87 | 89 |
/* |
88 | 90 |
* Content/COMMON_NAME. |
... | ... | |
105 | 107 |
if(isset($taxon) ) { |
106 | 108 |
$taxon_uuid = $taxon->uuid; |
107 | 109 |
} |
108 |
$block->content[] = compose_cdm_descriptionElements($node->descriptionElements, $node->feature, $taxon_uuid); |
|
110 |
$elements_render_array = compose_cdm_descriptionElements($node->descriptionElements, $node->feature, $taxon_uuid); |
|
111 |
$block_content_is_empty = empty($elements_render_array); |
|
112 |
$block->content[] = $elements_render_array; |
|
109 | 113 |
} |
110 | 114 |
|
111 | 115 |
// Content/ALL OTHER FEATURES/Subordinate Features |
... | ... | |
152 | 156 |
$out_child_elements = ''; |
153 | 157 |
} |
154 | 158 |
} |
159 |
$block_content_is_empty = $block_content_is_empty && empty($text); |
|
155 | 160 |
$block->content[] = markup_to_render_array($text); |
161 |
$block_content_is_empty = $block_content_is_empty && empty($media_list); |
|
156 | 162 |
$block->content[] = compose_feature_media_gallery($node, $media_list, $gallery_settings); |
157 | 163 |
|
158 | 164 |
|
... | ... | |
162 | 168 |
*/ |
163 | 169 |
$block->content[] = markup_to_render_array(theme('cdm_footnotes', array('footnoteListKey' => $node->feature->uuid))); |
164 | 170 |
$block->content[] = markup_to_render_array(theme('cdm_annotation_footnotes', array('footnoteListKey' => $node->feature->uuid))); |
165 |
} |
|
166 |
|
|
171 |
} // END all other features |
|
167 | 172 |
|
168 |
$out .= theme('block', |
|
169 |
array( |
|
170 |
'elements' => array( |
|
171 |
'#block' => $block, |
|
172 |
'#children' => drupal_render($block->content), |
|
173 |
), |
|
174 |
) |
|
175 |
); |
|
173 |
if(!$block_content_is_empty){ // skip empty block content |
|
174 |
$out .= theme('block', |
|
175 |
array( |
|
176 |
'elements' => array( |
|
177 |
'#block' => $block, |
|
178 |
'#children' => drupal_render($block->content), |
|
179 |
), |
|
180 |
) |
|
181 |
); |
|
182 |
} // END: skip empty block content |
|
176 | 183 |
} // END: skip empty or supressed features |
177 | 184 |
} // END: creating a block per feature |
178 | 185 |
RenderHints::popFromRenderStack(); |
... | ... | |
248 | 255 |
// --- TextData |
249 | 256 |
foreach ($descriptionElements['TextData'] as $text_data_element) { |
250 | 257 |
$asListElement = FALSE; |
251 |
$repr = theme('cdm_descriptionElementTextData', array( |
|
252 |
'element' => $text_data_element, |
|
253 |
'asListElement' => $asListElement, |
|
254 |
'feature_uuid' => $text_data_element->feature->uuid, |
|
255 |
)); |
|
258 |
$text_data_render_array = compose_cdm_descriptionElementTextData($text_data_element, $asListElement, $text_data_element->feature->uuid); |
|
259 |
$repr = drupal_render($text_data_render_array); |
|
256 | 260 |
|
257 |
if (!array_search($repr, $text_data_out_array)) { |
|
261 |
if (!array_search($repr, $text_data_out_array)) { // de-duplication !!
|
|
258 | 262 |
$text_data_out_array[] = $repr; |
259 | 263 |
// TODO HINT: sorting in compose_cdm_feature_block_elements will |
260 | 264 |
// not work since this array contains html attributes with uuids |
261 |
// !!!! |
|
265 |
// and what is about cases like the bibliography where |
|
266 |
// any content can be prefixed with some foot-note anchors? |
|
262 | 267 |
$text_data_sortOutArray = TRUE; |
263 | 268 |
$text_data_glue = '<br/> '; |
264 | 269 |
$text_data_enclosingTag = 'p'; |
... | ... | |
587 | 592 |
* Returns HTML for citations textdata elements. |
588 | 593 |
* |
589 | 594 |
* TODO: assign a new name to the function? Because it is used for the citations |
590 |
* textdata elements and not for all text data description elements.
|
|
595 |
* Textdata elements and not for all text data description elements.
|
|
591 | 596 |
* |
592 |
* @param array $variables
|
|
593 |
* An associative array containing:
|
|
594 |
* - element: The description element which contains the text information.
|
|
595 |
* - asListElement: A boolean which determines whether the citations should
|
|
597 |
* @param $element
|
|
598 |
* The CDM TextData description element which contains the textual information.
|
|
599 |
* @param $asListElement
|
|
600 |
* A boolean which determines whether the citations should |
|
596 | 601 |
* be rendered as a list or not. |
597 |
* - feature_uuid |
|
602 |
* TODO remove and replace $asListElement by $feature_block_settings['as_list'] |
|
603 |
* @param $feature_uuid |
|
598 | 604 |
* |
599 |
* @ingroup themeable |
|
605 |
* @return array |
|
606 |
* A drupal render array with the following elements being used: |
|
607 |
* - #tag: either 'div', 'li', ... |
|
608 |
* ⁻ #attributes: class attributes |
|
609 |
* - #value_prefix: (optionally) contains footnote anchors |
|
610 |
* - #value: contains the textual content |
|
611 |
* - #value_suffix: (optionally) contains footnote keys |
|
612 |
* |
|
613 |
* @ingroup compose |
|
600 | 614 |
*/ |
601 |
function theme_cdm_descriptionElementTextData($variables) {
|
|
615 |
function compose_cdm_descriptionElementTextData($element, $asListElement, $feature_uuid) {
|
|
602 | 616 |
|
603 |
$element = $variables['element']; |
|
604 |
$feature_uuid = $variables['feature_uuid']; |
|
605 |
$asListElement = $variables['asListElement']; // TODo remove and replace by $feature_block_settings['as_list'] |
|
606 | 617 |
$footnote_list_key_suggestion = $feature_uuid; |
607 | 618 |
|
608 | 619 |
$sourceRefs = ''; |
609 |
$out = ''; |
|
610 | 620 |
$name_used_in_source = ''; |
611 | 621 |
|
612 | 622 |
// FIXME $feature_block_settings should be passed as parameter!!!!! |
... | ... | |
621 | 631 |
} |
622 | 632 |
// -------------------------------------------------- |
623 | 633 |
|
634 |
$render_array = array( |
|
635 |
'#type' => 'html_tag', |
|
636 |
'#tag' => $asListElement ? 'li' : 'span', |
|
637 |
'#attributes' => array( |
|
638 |
'class' => 'DescriptionElement DescriptionElement-' . $element->class . ' |
|
639 |
' . html_class_attribute_ref($element) |
|
640 |
), |
|
641 |
'#value' => '', |
|
642 |
'#value_suffix' => NULL |
|
643 |
); |
|
644 |
|
|
645 |
// TODO this should be configurable |
|
624 | 646 |
$description = ''; |
625 | 647 |
if (isset($element->multilanguageText_L10n->text)) { |
626 | 648 |
$description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text); |
... | ... | |
633 | 655 |
// CUSTOM CODE (2) from cichorieae theme, |
634 | 656 |
// use nomref web service to combine reference with microreference, other way to combine these? |
635 | 657 |
// is this a general case for all features? |
636 |
// compare with theme_cdm_reference() where it is onyl appended |
|
637 |
// >>> DISCUSS with Andreas M. FIXME |
|
658 |
// compare with theme_cdm_reference() where it is only appended |
|
659 |
// FIXME the CDM_WS_NOMENCLATURAL_REFERENCE_CITATION service should onyl be used for nomenclatural references |
|
660 |
// needs however further discussion with the users!!! |
|
638 | 661 |
// SKIPPING THIS FOR NOW: |
639 | 662 |
if (FALSE && $feature_uuid == UUID_CITATION) { |
640 | 663 |
|
... | ... | |
694 | 717 |
} // END of loop over sources |
695 | 718 |
|
696 | 719 |
// annotations footnotes separate. |
697 |
$foot_note_keys = theme('cdm_annotations_as_footnotekeys',
|
|
720 |
$render_array['#value-suffix'] = theme('cdm_annotations_as_footnotekeys',
|
|
698 | 721 |
array( |
699 | 722 |
'cdmBase_list' => $element, |
700 | 723 |
'footnote_list_key' => $footnote_list_key_suggestion, |
... | ... | |
704 | 727 |
} // END of references inline |
705 | 728 |
|
706 | 729 |
if(!$do_references_inline || $feature_block_settings['sources_as_content_to_bibliography']) { |
707 |
$foot_note_keys = cdm_create_description_element_footnotes($element, ',', $footnote_list_key_suggestion);
|
|
730 |
$render_array['#value-suffix'] = cdm_create_description_element_footnotes($element, ',', $footnote_list_key_suggestion);
|
|
708 | 731 |
} |
709 | 732 |
|
710 |
if ($asListElement) { |
|
711 | 733 |
|
712 |
$out = '<li class="DescriptionElement DescriptionElement-' . $element->class . ' |
|
713 |
' . html_class_attribute_ref($element) . '">'; |
|
734 |
// FIXME the only distinction between $asListElement = TRUE and FLASE is the different display of the |
|
735 |
// nameInSource which is prepended with "name in source:" in case of the 'not as list' case: |
|
736 |
if ($asListElement) { |
|
714 | 737 |
// Adding ":" if necessary. |
715 | 738 |
if (!empty($name_used_in_source)) { |
716 | 739 |
if ( (!empty($description)|| !empty($sourceRefs)) && $feature_uuid != UUID_CHROMOSOMES_NUMBERS) { |
717 |
$out .= $name_used_in_source . ': ';
|
|
740 |
$render_array['#value'] = $name_used_in_source . ': ';
|
|
718 | 741 |
} else { |
719 |
$out .= $name_used_in_source . ' ';
|
|
742 |
$render_array['#value'] .= $name_used_in_source . ' ';
|
|
720 | 743 |
} |
721 | 744 |
} |
722 |
$out .= $description . $sourceRefs . $foot_note_keys . '</li>';
|
|
745 |
$render_array['#value'] .= $description . $sourceRefs;
|
|
723 | 746 |
} |
724 | 747 |
else { |
725 | 748 |
if ($name_used_in_source) { |
726 | 749 |
$name_used_in_source = ' (name in source: ' . $name_used_in_source . ')'; |
727 | 750 |
} |
728 |
|
|
729 |
$out = '<span class="DescriptionElement DescriptionElement-' . $element->class . ' |
|
730 |
' . html_class_attribute_ref($element) . '">' |
|
731 |
. $description . $sourceRefs . $name_used_in_source . $foot_note_keys . '</span>'; |
|
751 |
$render_array['#value'] = $description . $sourceRefs . $name_used_in_source; |
|
732 | 752 |
} |
733 | 753 |
|
734 |
return $out;
|
|
754 |
return $render_array;
|
|
735 | 755 |
} |
736 | 756 |
|
737 | 757 |
/** |
... | ... | |
823 | 843 |
/* footnotes are not handled correctly in theme_cdm_descriptionElementTextData, |
824 | 844 |
need to set 'common-names-feature-block' as $footnote_key_suggestion */ |
825 | 845 |
RenderHints::setFootnoteListKey($footnote_key_suggestion); |
826 |
$text_data_out[] = theme('cdm_descriptionElementTextData', array( |
|
827 |
'element' => $text_data_element, |
|
828 |
'asListElement' => TRUE, |
|
829 |
'feature_uuid' => $text_data_element->feature->uuid, |
|
830 |
)); |
|
846 |
$text_data_render_array = compose_cdm_descriptionElementTextData($text_data_element, TRUE, $text_data_element->feature->uuid); |
|
847 |
$text_data_out[] = drupal_render($text_data_render_array); |
|
831 | 848 |
} |
832 | 849 |
|
833 | 850 |
$common_name_out_text_data = compose_cdm_feature_block_elements( |
... | ... | |
857 | 874 |
* These descriptions elements of a Description must be ordered by the chosen feature tree by |
858 | 875 |
* calling the function _mergeFeatureTreeDescriptions(). |
859 | 876 |
* @see _mergeFeatureTreeDescriptions() |
860 |
* @param $feature_uuid |
|
877 |
* |
|
878 |
* @param $feature_uuid |
|
879 |
* |
|
880 |
* @return |
|
881 |
* A drupal render array for the $descriptionElements, may be an empty array if the textual content was empty. |
|
882 |
* Footnote key or anchors are not considered to be textual content. |
|
861 | 883 |
* |
862 | 884 |
* @ingroup compose |
863 | 885 |
*/ |
864 | 886 |
function compose_cdm_descriptionElements($descriptionElements, $feature) { |
865 | 887 |
|
866 |
$outArray = array(); |
|
888 |
$render_array = array(); |
|
889 |
$elements_out_array = array(); |
|
867 | 890 |
$distribution_tree = null; |
868 | 891 |
|
892 |
/* |
|
893 |
* $feature_block_has_content will be set true if at least one of the |
|
894 |
* $descriptionElements contains some text which makes up some content |
|
895 |
* for the feature block. Footnote keys are not considered |
|
896 |
* to be content in this sense. |
|
897 |
*/ |
|
898 |
$feature_block_has_content = false; |
|
899 |
|
|
869 | 900 |
/* |
870 | 901 |
$userDefined = mixed_variable_get(LAYOUT_SETTING_PREFIX . $feature_uuid, FEATURE_TREE_LAYOUT_DEFAULTS); |
871 | 902 |
if(variable_get('distribution_sort', |
... | ... | |
884 | 915 |
} |
885 | 916 |
*/ |
886 | 917 |
|
887 |
|
|
888 |
|
|
889 | 918 |
RenderHints::pushToRenderStack('cdm_descriptionElements'); |
890 | 919 |
|
891 | 920 |
if (is_array($descriptionElements)) { |
... | ... | |
912 | 941 |
$asListElement = $feature_block_settings['as_list'] == 'ul'; |
913 | 942 |
switch ($descriptionElement->class) { |
914 | 943 |
case 'TextData': |
915 |
$outArray[] = theme('cdm_descriptionElementTextData', array( |
|
916 |
'element' => $descriptionElement, |
|
917 |
'asListElement' => $asListElement, |
|
918 |
'feature_uuid' => $descriptionElement->feature->uuid, |
|
919 |
)); |
|
944 |
$text_data_render_array = compose_cdm_descriptionElementTextData($descriptionElement, $asListElement, $descriptionElement->feature->uuid); |
|
945 |
$feature_block_has_content = $feature_block_has_content || !empty($text_data_render_array['#value']); |
|
946 |
$elements_out_array[] = drupal_render($text_data_render_array); |
|
920 | 947 |
break; |
921 | 948 |
case 'CategoricalData': |
922 |
$outArray[] = theme('cdm_descriptionElement_CategoricalData', array('element' => $descriptionElement)); |
|
949 |
$feature_block_has_content = true; |
|
950 |
$elements_out_array[] = theme('cdm_descriptionElement_CategoricalData', array('element' => $descriptionElement)); |
|
923 | 951 |
break; |
924 | 952 |
case 'QuantitativeData': |
925 |
$outArray[] = theme('cdm_descriptionElement_QuantitativeData', array('element' => $descriptionElement)); |
|
953 |
$feature_block_has_content = true; |
|
954 |
$elements_out_array[] = theme('cdm_descriptionElement_QuantitativeData', array('element' => $descriptionElement)); |
|
926 | 955 |
break; |
927 | 956 |
case 'IndividualsAssociation': |
928 |
$outArray[] = theme('cdm_descriptionElement_IndividualsAssociation', array('element' => $descriptionElement)); |
|
957 |
$feature_block_has_content = true; |
|
958 |
$elements_out_array[] = theme('cdm_descriptionElement_IndividualsAssociation', array('element' => $descriptionElement)); |
|
929 | 959 |
break; |
930 | 960 |
case 'TaxonInteraction': |
931 |
$outArray[] = theme('cdm_descriptionElement_TaxonInteraction', array('element' => $descriptionElement)); |
|
961 |
$feature_block_has_content = true; |
|
962 |
$elements_out_array[] = theme('cdm_descriptionElement_TaxonInteraction', array('element' => $descriptionElement)); |
|
932 | 963 |
break; |
933 | 964 |
case 'Uses': |
934 | 965 |
/* IGNORE Uses classes, these are handled completely in theme_cdm_UseDescription */ |
935 | 966 |
break; |
936 | 967 |
default: |
937 |
$outArray[] = '<li>No method for rendering unknown description class: ' . $descriptionElement->class . '</li>'; |
|
968 |
$feature_block_has_content = true; |
|
969 |
$elements_out_array[] = '<li>No method for rendering unknown description class: ' . $descriptionElement->class . '</li>'; |
|
938 | 970 |
} |
939 | 971 |
} |
940 | 972 |
} // --- END loop over normal description element arrays |
... | ... | |
942 | 974 |
// If feature = CITATION sort the list of sources. |
943 | 975 |
// This is ONLY for FLORA MALESIANA and FLORE d'AFRIQUE CENTRALE. |
944 | 976 |
if ($descriptionElement->feature->uuid == UUID_CITATION) { |
945 |
sort($outArray);
|
|
977 |
sort($elements_out_array);
|
|
946 | 978 |
} |
947 | 979 |
|
948 | 980 |
if (isset($image_sources)) { |
949 |
$outArray[] = theme('cdm_description_element_image_source', array('image_sources' => $image_sources, 'asListElement' => TRUE));
|
|
981 |
$elements_out_array[] = theme('cdm_description_element_image_source', array('image_sources' => $image_sources, 'asListElement' => TRUE));
|
|
950 | 982 |
} |
951 | 983 |
} // END normal description element arrays |
952 | 984 |
|
953 |
$render_array = compose_cdm_feature_block_elements( |
|
954 |
$outArray, |
|
955 |
$feature |
|
956 |
); |
|
985 |
if($feature_block_has_content){ |
|
986 |
$render_array = compose_cdm_feature_block_elements( |
|
987 |
$elements_out_array, |
|
988 |
$feature |
|
989 |
); |
|
990 |
} |
|
957 | 991 |
|
958 | 992 |
RenderHints::popFromRenderStack(); |
959 | 993 |
return $render_array; |
Also available in: Unified diff
hiding empty feature blocks