Revision b011743c
Added by Andreas Kohlbecker over 5 years ago
modules/cdm_dataportal/includes/descriptions.inc | ||
---|---|---|
694 | 694 |
|
695 | 695 |
RenderHints::pushToRenderStack('feature_block'); |
696 | 696 |
// Create a drupal block for each feature |
697 |
foreach ($mergedFeatureNodes as $node) { |
|
697 |
foreach ($mergedFeatureNodes as $feature_node) {
|
|
698 | 698 |
|
699 |
if ((isset($node->descriptionElements['#type']) || |
|
700 |
has_feature_node_description_elements($node)) && $node->feature->uuid != UUID_IMAGE) { // skip empty or suppressed features
|
|
699 |
if ((isset($feature_node->descriptionElements['#type']) ||
|
|
700 |
has_feature_node_description_elements($feature_node)) && $feature_node->term->uuid != UUID_IMAGE) { // skip empty or suppressed features
|
|
701 | 701 |
|
702 |
RenderHints::pushToRenderStack($node->feature->uuid);
|
|
702 |
RenderHints::pushToRenderStack($feature_node->term->uuid);
|
|
703 | 703 |
|
704 |
$feature_name = cdm_term_representation($node->feature, 'Unnamed Feature');
|
|
705 |
$feature_block_settings = get_feature_block_settings($node->feature->uuid);
|
|
704 |
$feature_name = cdm_term_representation($feature_node->term, 'Unnamed Feature');
|
|
705 |
$feature_block_settings = get_feature_block_settings($feature_node->term->uuid);
|
|
706 | 706 |
|
707 | 707 |
|
708 |
$block = feature_block($feature_name, $node->feature);
|
|
708 |
$block = feature_block($feature_name, $feature_node->term);
|
|
709 | 709 |
$block->content = array(); |
710 | 710 |
$block_content_is_empty = TRUE; |
711 | 711 |
|
712 |
if(array_search($node->feature->uuid, $use_description_features) !== false) {
|
|
712 |
if(array_search($feature_node->term->uuid, $use_description_features) !== false) {
|
|
713 | 713 |
// do not show features which belong to the UseDescriptions, these are |
714 | 714 |
// handled by compose_feature_block_items_use_records() where the according descriptions are |
715 | 715 |
// fetched again separately. |
... | ... | |
720 | 720 |
/* |
721 | 721 |
* Content/DISTRIBUTION. |
722 | 722 |
*/ |
723 |
if ($node->feature->uuid == UUID_DISTRIBUTION) {
|
|
724 |
$block = compose_feature_block_distribution($taxon, $node->descriptionElements, $node->feature);
|
|
723 |
if ($feature_node->term->uuid == UUID_DISTRIBUTION) {
|
|
724 |
$block = compose_feature_block_distribution($taxon, $feature_node->descriptionElements, $feature_node->term);
|
|
725 | 725 |
$block_content_is_empty = FALSE; |
726 | 726 |
} |
727 | 727 |
|
728 | 728 |
/* |
729 | 729 |
* Content/COMMON_NAME. |
730 | 730 |
*/ |
731 |
else if ($node->feature->uuid == UUID_COMMON_NAME) {
|
|
732 |
$common_names_render_array = compose_feature_block_items_feature_common_name($node->descriptionElements, $node->feature);
|
|
731 |
else if ($feature_node->term->uuid == UUID_COMMON_NAME) {
|
|
732 |
$common_names_render_array = compose_feature_block_items_feature_common_name($feature_node->descriptionElements, $feature_node->term);
|
|
733 | 733 |
$block->content[] = $common_names_render_array; |
734 | 734 |
$block_content_is_empty = FALSE; |
735 | 735 |
} |
... | ... | |
737 | 737 |
/* |
738 | 738 |
* Content/Use Description (Use + UseRecord) |
739 | 739 |
*/ |
740 |
else if ($node->feature->uuid == UUID_USE_RECORD) {
|
|
741 |
$block->content[] = cdm_block_use_description_content($taxon->uuid, $node->feature);
|
|
740 |
else if ($feature_node->term->uuid == UUID_USE_RECORD) {
|
|
741 |
$block->content[] = cdm_block_use_description_content($taxon->uuid, $feature_node->term);
|
|
742 | 742 |
$block_content_is_empty = FALSE; |
743 | 743 |
} |
744 | 744 |
|
... | ... | |
751 | 751 |
$elements_render_array = array(); |
752 | 752 |
$child_elements_render_array = null; |
753 | 753 |
|
754 |
if (isset($node->descriptionElements[0])) { |
|
755 |
$elements_render_array = compose_feature_block_items_generic($node->descriptionElements, $node->feature);
|
|
754 |
if (isset($feature_node->descriptionElements[0])) {
|
|
755 |
$elements_render_array = compose_feature_block_items_generic($feature_node->descriptionElements, $feature_node->term);
|
|
756 | 756 |
} |
757 | 757 |
|
758 | 758 |
// Content/ALL OTHER FEATURES/Subordinate Features |
759 | 759 |
// subordinate features are printed inline in one floating text, |
760 | 760 |
// it is expected hat subordinate features can "contain" TextData, |
761 | 761 |
// Qualitative- and Qualitative- DescriptionElements |
762 |
if (isset($node->childNodes[0])) { |
|
763 |
$child_elements_render_array = compose_feature_block_items_nested($node, $media_list, $feature_block_settings); |
|
762 |
if (isset($feature_node->childNodes[0])) {
|
|
763 |
$child_elements_render_array = compose_feature_block_items_nested($feature_node, $media_list, $feature_block_settings);
|
|
764 | 764 |
$elements_render_array = array_merge($elements_render_array, $child_elements_render_array); |
765 | 765 |
} |
766 | 766 |
$block_content_is_empty = $block_content_is_empty && empty($media_list) && empty($elements_render_array); |
767 | 767 |
if(!$block_content_is_empty){ |
768 |
$block->content[] = compose_feature_block_wrap_elements($elements_render_array, $node->feature, $feature_block_settings['glue']);
|
|
769 |
$block->content[] = compose_feature_media_gallery($node, $media_list, $gallery_settings); |
|
768 |
$block->content[] = compose_feature_block_wrap_elements($elements_render_array, $feature_node->term, $feature_block_settings['glue']);
|
|
769 |
$block->content[] = compose_feature_media_gallery($feature_node, $media_list, $gallery_settings);
|
|
770 | 770 |
/* |
771 | 771 |
* Footnotes for the feature block |
772 | 772 |
*/ |
773 |
$block->content[] = markup_to_render_array(theme('cdm_footnotes', array('footnoteListKey' => 'BIBLIOGRAPHY-' . $node->feature->uuid)));
|
|
774 |
$block->content[] = markup_to_render_array(theme('cdm_footnotes', array('footnoteListKey' => $node->feature->uuid)));
|
|
775 |
$block->content[] = markup_to_render_array(theme('cdm_annotation_footnotes', array('footnoteListKey' => $node->feature->uuid)));
|
|
773 |
$block->content[] = markup_to_render_array(theme('cdm_footnotes', array('footnoteListKey' => 'BIBLIOGRAPHY-' . $feature_node->term->uuid)));
|
|
774 |
$block->content[] = markup_to_render_array(theme('cdm_footnotes', array('footnoteListKey' => $feature_node->term->uuid)));
|
|
775 |
$block->content[] = markup_to_render_array(theme('cdm_annotation_footnotes', array('footnoteListKey' => $feature_node->term->uuid)));
|
|
776 | 776 |
} |
777 | 777 |
} // END all other features |
778 | 778 |
|
779 | 779 |
// allows modifying the block contents via a the hook_cdm_feature_node_block_content_alter |
780 |
drupal_alter('cdm_feature_node_block_content', $block->content, $node->feature, $node->descriptionElements);
|
|
780 |
drupal_alter('cdm_feature_node_block_content', $block->content, $feature_node->term, $feature_node->descriptionElements);
|
|
781 | 781 |
|
782 | 782 |
if(!$block_content_is_empty){ // skip empty block content |
783 | 783 |
$block_list[] = $block; |
784 |
cdm_toc_list_add_item(cdm_term_representation($node->feature), $node->feature->uuid);
|
|
784 |
cdm_toc_list_add_item(cdm_term_representation($feature_node->term), $feature_node->term->uuid);
|
|
785 | 785 |
} // END: skip empty block content |
786 | 786 |
} // END: skip empty or suppressed features |
787 | 787 |
RenderHints::popFromRenderStack(); |
... | ... | |
799 | 799 |
* |
800 | 800 |
* This function is called recursively! |
801 | 801 |
* |
802 |
* @param $node |
|
802 |
* @param $feature_node
|
|
803 | 803 |
* The feature node. |
804 | 804 |
* @param array $media_list |
805 | 805 |
* List of CDM Media entities. All media of subordinate elements should be passed to the main feature.รค |
... | ... | |
813 | 813 |
* |
814 | 814 |
* @ingroup compose |
815 | 815 |
*/ |
816 |
function compose_feature_block_items_nested($node, &$media_list, $feature_block_settings, $main_feature = NULL) |
|
816 |
function compose_feature_block_items_nested($feature_node, &$media_list, $feature_block_settings, $main_feature = NULL)
|
|
817 | 817 |
{ |
818 | 818 |
|
819 | 819 |
if(!$main_feature){ |
820 |
$main_feature = $node->feature;
|
|
820 |
$main_feature = $feature_node->term;
|
|
821 | 821 |
} |
822 | 822 |
/* |
823 | 823 |
* TODO should be configurable, options; YES, NO, AUTOMATIC |
... | ... | |
826 | 826 |
$prepend_feature_label = false; |
827 | 827 |
|
828 | 828 |
$render_arrays = array(); |
829 |
foreach ($node->childNodes as $child_node) { |
|
829 |
foreach ($feature_node->childNodes as $child_node) {
|
|
830 | 830 |
if (isset($child_node->descriptionElements[0])) { |
831 | 831 |
foreach ($child_node->descriptionElements as $element) { |
832 | 832 |
|
... | ... | |
864 | 864 |
|
865 | 865 |
/** |
866 | 866 |
* |
867 |
* @param $node |
|
867 |
* @param $feature_node
|
|
868 | 868 |
* The merged feature three node which potentially contains media in its description elements. |
869 | 869 |
* @param $media_list |
870 | 870 |
* Additional media to be merged witht the media contained in the nodes description elements |
... | ... | |
873 | 873 |
* |
874 | 874 |
* @ingroup compose |
875 | 875 |
*/ |
876 |
function compose_feature_media_gallery($node, $media_list, $gallery_settings) { |
|
876 |
function compose_feature_media_gallery($feature_node, $media_list, $gallery_settings) {
|
|
877 | 877 |
|
878 |
if (isset($node->descriptionElements)) { |
|
879 |
$media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements)); |
|
878 |
if (isset($feature_node->descriptionElements)) {
|
|
879 |
$media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($feature_node->descriptionElements));
|
|
880 | 880 |
} |
881 | 881 |
|
882 | 882 |
$captionElements = array('title', 'rights'); |
... | ... | |
884 | 884 |
if (isset($media_list[0]) && isset($gallery_settings['cdm_dataportal_media_maxextend']) && isset($gallery_settings['cdm_dataportal_media_cols'])) { |
885 | 885 |
$gallery = compose_cdm_media_gallerie(array( |
886 | 886 |
'mediaList' => $media_list, |
887 |
'galleryName' => CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME . '_' . $node->feature->uuid,
|
|
887 |
'galleryName' => CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME . '_' . $feature_node->term->uuid,
|
|
888 | 888 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
889 | 889 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
890 | 890 |
'captionElements' => $captionElements, |
Also available in: Unified diff
ref #8166 adapting to change in FeatureNode property 'feature' becomes 'term'