Revision 6f5c7f2a
Added by Andreas Kohlbecker over 9 years ago
7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme | ||
---|---|---|
74 | 74 |
$feature_name = cdm_term_representation($node->feature, 'Unnamed Feature'); |
75 | 75 |
|
76 | 76 |
$block = feature_block($feature_name, $node->feature); |
77 |
$block->content = array(); |
|
78 |
$block_content_weight = 0; |
|
77 | 79 |
|
78 | 80 |
/* |
79 | 81 |
* Content/DISTRIBUTION. |
... | ... | |
81 | 83 |
|
82 | 84 |
if ($node->feature->uuid == UUID_DISTRIBUTION) { |
83 | 85 |
$block = compose_feature_block_distribution($taxon, $node->descriptionElements, $node->feature); |
84 |
|
|
85 | 86 |
} |
86 | 87 |
/* |
87 | 88 |
* Content/COMMON_NAME. |
88 | 89 |
*/ |
89 |
elseif ($node->feature->uuid == UUID_COMMON_NAME) { |
|
90 |
else if ($node->feature->uuid == UUID_COMMON_NAME) {
|
|
90 | 91 |
$common_names_render_array = compose_cdm_common_names($node->descriptionElements, $node->feature); |
91 |
$block->content .= drupal_render($common_names_render_array);
|
|
92 |
$block->content[] = $common_names_render_array;
|
|
92 | 93 |
} |
93 | 94 |
|
94 | 95 |
/* |
... | ... | |
104 | 105 |
if(isset($taxon) ) { |
105 | 106 |
$taxon_uuid = $taxon->uuid; |
106 | 107 |
} |
107 |
$block->content .= theme('cdm_descriptionElements', array( |
|
108 |
'descriptionElements' => $node->descriptionElements, |
|
109 |
'feature' => $node->feature, |
|
110 |
'taxon_uuid' => $taxon_uuid, |
|
111 |
)); |
|
108 |
$block->content[] = compose_cdm_descriptionElements($node->descriptionElements, $node->feature, $taxon_uuid); |
|
112 | 109 |
} |
113 | 110 |
|
114 | 111 |
// Content/ALL OTHER FEATURES/Subordinate Features |
115 | 112 |
// subordinate features are printed inline in one floating text, |
116 |
// it is expected hat supordinate features can "contain" TextData,
|
|
113 |
// it is expected hat subordinate features can "contain" TextData,
|
|
117 | 114 |
// Qualitative- and Qualitative- DescriptioneElements |
118 | 115 |
if (isset($node->childNodes[0])) { |
119 | 116 |
|
120 | 117 |
// TODO support more than one level of children. |
121 |
// can this be solved by resursively calling this very function?
|
|
118 |
// can this be solved by recursively calling this function?
|
|
122 | 119 |
// @see http://dev.e-taxonomy.eu/trac/ticket/2393 |
123 | 120 |
$text = ''; |
124 | 121 |
foreach ($node->childNodes as $child) { |
... | ... | |
126 | 123 |
if (isset($child->descriptionElements) && is_array($child->descriptionElements)) { |
127 | 124 |
foreach ($child->descriptionElements as $element) { |
128 | 125 |
|
126 |
//TODO it woud be better if we could use compose_cdm_descriptionElements() directly instead of the below stuff |
|
127 |
|
|
129 | 128 |
if (is_array($element->media)) { |
130 | 129 |
// Append media of supordinate elements to list of main |
131 | 130 |
// feature. |
... | ... | |
134 | 133 |
|
135 | 134 |
switch ($element->class) { |
136 | 135 |
case 'TextData': |
137 |
// TODO use theme_cdm_descriptionElementTextData()
|
|
136 |
// FIXME use theme_cdm_descriptionElementTextData()
|
|
138 | 137 |
$out_child_elements = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text); |
139 | 138 |
$out_child_elements = str_replace($child->feature->titleCache, '<em>' . $child->feature->representation_L10n . '</em>', $out_child_elements); |
140 | 139 |
break; |
... | ... | |
153 | 152 |
$out_child_elements = ''; |
154 | 153 |
} |
155 | 154 |
} |
156 |
$block->content .= $text;
|
|
157 |
$block->content .= compose_feature_media_gallery($node, $media_list, $gallery_settings);
|
|
155 |
$block->content[] = markup_to_render_array($text);
|
|
156 |
$block->content[] = compose_feature_media_gallery($node, $media_list, $gallery_settings);
|
|
158 | 157 |
|
159 | 158 |
|
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));
|
|
165 |
}
|
|
159 |
}
|
|
160 |
/*
|
|
161 |
* Footnotes for the feature block
|
|
162 |
*/
|
|
163 |
$block->content[] = markup_to_render_array(theme('cdm_footnotes', array('footnoteListKey' => $node->feature->uuid)));
|
|
164 |
$block->content[] = markup_to_render_array(theme('cdm_annotation_footnotes', array('footnoteListKey' => $node->feature->uuid)));
|
|
166 | 165 |
} |
167 | 166 |
|
168 | 167 |
|
... | ... | |
170 | 169 |
array( |
171 | 170 |
'elements' => array( |
172 | 171 |
'#block' => $block, |
173 |
'#children' => $block->content,
|
|
172 |
'#children' => drupal_render($block->content),
|
|
174 | 173 |
), |
175 | 174 |
) |
176 | 175 |
); |
... | ... | |
269 | 268 |
|
270 | 269 |
|
271 | 270 |
if ($text_data_out_array && variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) { |
272 |
$block->content .= compose_cdm_feature_block_elements(
|
|
271 |
$block->content[] = compose_cdm_feature_block_elements(
|
|
273 | 272 |
$text_data_out_array, |
274 | 273 |
$feature, |
275 | 274 |
$text_data_glue, |
... | ... | |
284 | 283 |
$distribution_map_query_parameters = $descriptionElements['DistributionInfoDTO']->mapUriParams; |
285 | 284 |
} |
286 | 285 |
$map_render_element = compose_distribution_map($taxon, $distribution_map_query_parameters); |
287 |
$block->content .= $map_render_element['#markup'];
|
|
286 |
$block->content[] = $map_render_element;
|
|
288 | 287 |
|
289 | 288 |
// --- tree or list |
290 | 289 |
$dto_out_array = array(); |
... | ... | |
311 | 310 |
|
312 | 311 |
} |
313 | 312 |
// |
314 |
$block->content .= compose_cdm_feature_block_elements(
|
|
313 |
$block->content[] = compose_cdm_feature_block_elements(
|
|
315 | 314 |
$dto_out_array, |
316 | 315 |
$feature, |
317 | 316 |
$distribution_glue, |
... | ... | |
322 | 321 |
|
323 | 322 |
// --- TextData at the bottom |
324 | 323 |
if ($text_data_out_array && !variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) { |
325 |
$block->content .= compose_cdm_feature_block_elements(
|
|
324 |
$block->content[] = compose_cdm_feature_block_elements(
|
|
326 | 325 |
$text_data_out_array, |
327 | 326 |
$feature, |
328 | 327 |
$text_data_glue, |
... | ... | |
331 | 330 |
); |
332 | 331 |
} |
333 | 332 |
|
334 |
$block->content .= theme('cdm_footnotes', array('footnoteListKey' => UUID_DISTRIBUTION));
|
|
335 |
$block->content .= theme('cdm_annotation_footnotes', array('footnoteListKey' => UUID_DISTRIBUTION));
|
|
333 |
$block->content[] = markup_to_render_array(theme('cdm_footnotes', array('footnoteListKey' => UUID_DISTRIBUTION)));
|
|
334 |
$block->content[] = markup_to_render_array(theme('cdm_annotation_footnotes', array('footnoteListKey' => UUID_DISTRIBUTION)));
|
|
336 | 335 |
|
337 | 336 |
return $block; |
338 | 337 |
} |
... | ... | |
417 | 416 |
$out .= join($elements, $glue) ; |
418 | 417 |
|
419 | 418 |
$out .= '</' . $enclosing_tag . '>'; |
420 |
return $out;
|
|
419 |
return markup_to_render_array($out);
|
|
421 | 420 |
} |
422 | 421 |
|
423 | 422 |
|
... | ... | |
604 | 603 |
$element = $variables['element']; |
605 | 604 |
$feature_uuid = $variables['feature_uuid']; |
606 | 605 |
$asListElement = $variables['asListElement']; // TODo remove and replace by $feature_block_settings['as_list'] |
606 |
$footnote_list_key_suggestion = $feature_uuid; |
|
607 | 607 |
|
608 | 608 |
$sourceRefs = ''; |
609 | 609 |
$out = ''; |
610 |
$name_used_in_source = ''; |
|
610 | 611 |
|
611 | 612 |
// FIXME $feature_block_settings should be passed as parameter!!!!! |
612 | 613 |
$feature_block_settings = get_feature_block_settings($feature_uuid); |
614 |
$bibliography_settings = get_bibliography_settings(); |
|
615 |
$do_references_inline = $feature_block_settings['references_inline'] && $bibliography_settings['enabled'] !== 1; |
|
613 | 616 |
|
614 | 617 |
// FIXME remove this hack --------------------------- |
615 | 618 |
$default_theme = variable_get('theme_default', NULL); |
... | ... | |
617 | 620 |
|| $default_theme == 'flore_afrique_centrale' || $default_theme == 'flora_malesiana' || $default_theme == 'flore_gabon' ){ |
618 | 621 |
$asListElement = $feature_block_settings['as_list'] == 'ul'; |
619 | 622 |
} |
620 |
|
|
621 | 623 |
// -------------------------------------------------- |
622 | 624 |
|
623 | 625 |
$description = ''; |
... | ... | |
625 | 627 |
$description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text); |
626 | 628 |
} |
627 | 629 |
|
628 |
// annotations footnotes. |
|
629 |
$annotation_fkeys = theme('cdm_annotations_as_footnotekeys', |
|
630 |
array( |
|
631 |
'cdmBase_list' => $element, |
|
632 |
'footnote_list_key' => $feature_uuid, |
|
633 |
) |
|
634 |
); |
|
635 |
|
|
636 | 630 |
// original sources |
637 |
if (isset($element->sources) && is_array($element->sources) && count($element->sources) > 0) {
|
|
631 |
if($do_references_inline) {
|
|
638 | 632 |
foreach ($element->sources as $source) { |
639 |
|
|
640 | 633 |
// --------------------------------------------------------------------------- |
641 | 634 |
// CUSTOM CODE (2) from cichorieae theme, |
642 | 635 |
// use nomref web service to combine reference with microreference, other way to combine these? |
... | ... | |
649 | 642 |
)); |
650 | 643 |
$referenceCitation = $referenceCitation->String; |
651 | 644 |
|
652 |
// END CUSTOM CODE (2) |
|
653 |
// --------------------------------------------------------------------------- |
|
645 |
// END CUSTOM CODE (2)
|
|
646 |
// ---------------------------------------------------------------------------
|
|
654 | 647 |
} else { |
655 | 648 |
$referenceCitation = theme('cdm_OriginalSource', array('source' => $source)); |
656 | 649 |
} |
... | ... | |
667 | 660 |
} |
668 | 661 |
|
669 | 662 |
// link the nameUsedInSource to the according name page |
670 |
$name_used_in_source_link_to_show = ''; |
|
671 | 663 |
// Do a link to name page. |
672 | 664 |
if (isset($source->nameUsedInSource->uuid) && isset($source->nameUsedInSource->titleCache)) { |
673 | 665 |
// it is a DescriptionElementSource |
674 | 666 |
if($feature_block_settings['link_to_name_used_in_source']){ |
675 |
$name_used_in_source_link_to_show = l(
|
|
667 |
$name_used_in_source = l( |
|
676 | 668 |
$source->nameUsedInSource->titleCache, |
677 | 669 |
path_to_name($source->nameUsedInSource->uuid), |
678 | 670 |
array( |
679 |
'attributes' => array(), |
|
680 |
'absolute' => TRUE, |
|
681 |
'html' => TRUE, |
|
682 |
)); |
|
671 |
'attributes' => array(),
|
|
672 |
'absolute' => TRUE,
|
|
673 |
'html' => TRUE,
|
|
674 |
));
|
|
683 | 675 |
|
684 | 676 |
} else { |
685 |
$name_used_in_source_link_to_show = $source->nameUsedInSource->titleCache;
|
|
677 |
$name_used_in_source = $source->nameUsedInSource->titleCache; |
|
686 | 678 |
} |
687 | 679 |
} |
688 | 680 |
else if (isset($source->nameUsedInSource->originalNameString) && strlen($source->nameUsedInSource->originalNameString) > 0) { |
689 | 681 |
// TODO does this make sense? is $source->nameUsedInSource->originalNameString different from $source->nameUsedInSource->titleCache ? |
690 | 682 |
// it is NOT a DescriptionElementSource |
691 | 683 |
// Show a text without link. |
692 |
$name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
|
|
684 |
$name_used_in_source = $source->nameUsedInSource->originalNameString; |
|
693 | 685 |
} |
686 |
} // END of loop over sources |
|
687 |
|
|
688 |
// annotations footnotes separate. |
|
689 |
$foot_note_keys = theme('cdm_annotations_as_footnotekeys', |
|
690 |
array( |
|
691 |
'cdmBase_list' => $element, |
|
692 |
'footnote_list_key' => $footnote_list_key_suggestion, |
|
693 |
) |
|
694 |
); |
|
694 | 695 |
|
695 |
// final composition of the TextData element |
|
696 |
// FIXME this should move below after the end if (isset($element->sources) {...} and will replace the else |
|
697 |
if ($asListElement) { |
|
698 |
|
|
699 |
$out = '<li class="descriptionText DescriptionElement">'; |
|
700 |
// Adding ":" if necessary. |
|
701 |
if (!empty($name_used_in_source_link_to_show)) { |
|
702 |
if ( (!empty($description)|| !empty($sourceRefs)) && $feature_uuid != UUID_CHROMOSOMES_NUMBERS) { |
|
703 |
$out .= $name_used_in_source_link_to_show . ': '; |
|
704 |
} else { |
|
705 |
$out .= $name_used_in_source_link_to_show . ' '; |
|
706 |
} |
|
707 |
} |
|
708 |
$out .= $description . $sourceRefs . $annotation_fkeys . '</li>'; |
|
709 |
} |
|
710 |
else { |
|
711 |
if ($name_used_in_source_link_to_show) { |
|
712 |
$name_used_in_source_link_to_show = ' (name in source: ' . $name_used_in_source_link_to_show . ')'; |
|
713 |
} |
|
696 |
} // END of references inline |
|
697 |
else { |
|
698 |
$foot_note_keys = cdm_create_description_element_footnotes($element, ',', $footnote_list_key_suggestion); |
|
699 |
} |
|
714 | 700 |
|
715 |
$out = '<span class="DescriptionElement DescriptionElement-'. $element->class . ' |
|
716 |
' . html_class_attribute_ref($element) . '">' |
|
717 |
. $description . $sourceRefs . $name_used_in_source_link_to_show . $annotation_fkeys . '</span>'; |
|
701 |
if ($asListElement) { |
|
702 |
|
|
703 |
$out = '<li class="DescriptionElement DescriptionElement-' . $element->class . ' |
|
704 |
' . html_class_attribute_ref($element) . '">'; |
|
705 |
// Adding ":" if necessary. |
|
706 |
if (!empty($name_used_in_source)) { |
|
707 |
if ( (!empty($description)|| !empty($sourceRefs)) && $feature_uuid != UUID_CHROMOSOMES_NUMBERS) { |
|
708 |
$out .= $name_used_in_source . ': '; |
|
709 |
} else { |
|
710 |
$out .= $name_used_in_source . ' '; |
|
718 | 711 |
} |
719 | 712 |
} |
720 |
} // END of if (isset($element->sources)
|
|
721 |
|
|
713 |
$out .= $description . $sourceRefs . $foot_note_keys . '</li>';
|
|
714 |
} |
|
722 | 715 |
else { |
723 |
// If no sources, print the description. |
|
724 |
$out = '<span class="' . html_class_attribute_ref($element) . '"> ' |
|
725 |
. $description . $annotation_fkeys . '</span>'; |
|
716 |
if ($name_used_in_source) { |
|
717 |
$name_used_in_source = ' (name in source: ' . $name_used_in_source . ')'; |
|
718 |
} |
|
719 |
|
|
720 |
$out = '<span class="DescriptionElement DescriptionElement-' . $element->class . ' |
|
721 |
' . html_class_attribute_ref($element) . '">' |
|
722 |
. $description . $sourceRefs . $name_used_in_source . $foot_note_keys . '</span>'; |
|
726 | 723 |
} |
727 | 724 |
|
728 | 725 |
return $out; |
... | ... | |
741 | 738 |
* |
742 | 739 |
* @ingroup compose |
743 | 740 |
*/ |
744 |
function compose_cdm_common_names($elements, $feature) { |
|
741 |
function compose_cdm_common_names($elements, $feature, $weight = FALSE) {
|
|
745 | 742 |
|
746 | 743 |
$common_name_out = ''; |
747 | 744 |
$common_name_feature_elements = array(); |
... | ... | |
799 | 796 |
} // End of loop over set of elements per language area |
800 | 797 |
|
801 | 798 |
|
802 |
$common_name_out .= compose_cdm_feature_block_elements(
|
|
803 |
$common_name_feature_elements,
|
|
804 |
$feature,
|
|
805 |
'; ',
|
|
806 |
FALSE,
|
|
807 |
'div'
|
|
799 |
$common_name_feature_elements_render_array = compose_cdm_feature_block_elements(
|
|
800 |
$common_name_feature_elements, |
|
801 |
$feature, |
|
802 |
'; ', |
|
803 |
FALSE, |
|
804 |
'div' |
|
808 | 805 |
); |
809 |
|
|
806 |
$common_name_out .= $common_name_feature_elements_render_array['#markup']; |
|
810 | 807 |
|
811 | 808 |
} |
812 | 809 |
|
... | ... | |
835 | 832 |
|
836 | 833 |
return markup_to_render_array( |
837 | 834 |
'<div class="common_names_as_common_names">' . $common_name_out . '</div>' |
838 |
.'<div class="common_names_as_text_data">' . $common_name_out_text_data . '</div>' |
|
839 |
.$footnotes |
|
835 |
.'<div class="common_names_as_text_data">' . $common_name_out_text_data['#markup'] . '</div>' |
|
836 |
.$footnotes, |
|
837 |
$weight |
|
840 | 838 |
); |
841 | 839 |
} |
842 | 840 |
|
... | ... | |
845 | 843 |
* |
846 | 844 |
* Usually these are of a specific feature type. |
847 | 845 |
* |
848 |
* @param array $variables |
|
849 |
* An associative array containing: |
|
850 |
* - array of descriptionElements which belong to the same feature. |
|
851 |
* These descriptions elements of a Description must be ordered by the chosen feature tree by |
|
852 |
* calling the function _mergeFeatureTreeDescriptions(). |
|
853 |
* @see _mergeFeatureTreeDescriptions() |
|
854 |
* - featureUuid: currently unused, according code disabled |
|
855 |
* - taxon_uuid: only used for ordered distributions (will be removed!) |
|
846 |
* @param $descriptionElements |
|
847 |
* array of descriptionElements which belong to the same feature. |
|
848 |
* These descriptions elements of a Description must be ordered by the chosen feature tree by |
|
849 |
* calling the function _mergeFeatureTreeDescriptions(). |
|
850 |
* @see _mergeFeatureTreeDescriptions() |
|
851 |
* @param $feature_uuid |
|
856 | 852 |
* |
857 |
* @ingroup themeable
|
|
853 |
* @ingroup compose
|
|
858 | 854 |
*/ |
859 |
function theme_cdm_descriptionElements($variables) { |
|
855 |
function compose_cdm_descriptionElements($descriptionElements, $feature, $weight = FALSE) { |
|
856 |
|
|
860 | 857 |
|
861 |
$descriptionElements = $variables['descriptionElements']; |
|
862 |
$feature = $variables['feature']; |
|
863 |
$taxon_uuid = $variables['taxon_uuid']; |
|
864 | 858 |
$outArray = array(); |
859 |
$sortOutArray = FALSE; |
|
860 |
$distributionElements = array(); |
|
861 |
$distribution_tree = null; |
|
865 | 862 |
|
866 | 863 |
/* |
867 | 864 |
$userDefined = mixed_variable_get(LAYOUT_SETTING_PREFIX . $feature_uuid, FEATURE_TREE_LAYOUT_DEFAULTS); |
... | ... | |
881 | 878 |
} |
882 | 879 |
*/ |
883 | 880 |
|
884 |
$sortOutArray = FALSE; |
|
885 |
$distributionElements = array(); |
|
886 |
$distribution_tree = null; |
|
881 |
|
|
887 | 882 |
|
888 | 883 |
RenderHints::pushToRenderStack('cdm_descriptionElements'); |
889 | 884 |
|
... | ... | |
948 | 943 |
} |
949 | 944 |
} // END normal description element arrays |
950 | 945 |
|
951 |
$out = compose_cdm_feature_block_elements(
|
|
946 |
$render_array = compose_cdm_feature_block_elements(
|
|
952 | 947 |
$outArray, |
953 | 948 |
$feature |
954 | 949 |
); |
955 | 950 |
|
956 | 951 |
RenderHints::popFromRenderStack(); |
957 |
return $out;
|
|
952 |
return $render_array;
|
|
958 | 953 |
} |
959 | 954 |
|
960 | 955 |
/** |
Also available in: Unified diff
fixing #1933 (DescriptionElementBases do not show annotation footnotes in flora malesiana portal)