Project

General

Profile

« Previous | Next » 

Revision 28c5c87a

Added by Andreas Kohlbecker over 9 years ago

refactoring the feature node blocks - 1

View differences:

7.x/modules/cdm_dataportal/cdm_api/cdm_api.module
1210 1210
 * @return string
1211 1211
 * 	  the localized representation_L10n of the term,
1212 1212
 *    otherwise the titleCache as fall back,
1213
 *    otherwise an empty string
1213
 *    otherwise the default_representation which defaults to an empty string
1214 1214
 */
1215
function cdm_term_representation($definedTermBase) {
1215
function cdm_term_representation($definedTermBase, $default_representation = '') {
1216 1216
  if ( isset($definedTermBase->representation_L10n) ) {
1217 1217
    return $definedTermBase->representation_L10n;
1218 1218
  } elseif ( isset($definedTermBase->titleCache)) {
1219 1219
    return $definedTermBase->titleCache;
1220 1220
  }
1221
  return '';
1221
  return $default_representation;
1222 1222
}
1223 1223

  
1224 1224
/**
......
1540 1540
 * Merges the given featureNodes structure with the descriptionElements.
1541 1541
 *
1542 1542
 * This method is used in preparation for rendering the descriptionElements.
1543
 * The descriptionElements wich belong to a specific feature node are appended
1543
 * The descriptionElements which belong to a specific feature node are appended
1544 1544
 * to a the feature node by creating a new field:
1545 1545
 *  - descriptionElements: the CDM DescriptionElements which belong to this feature
1546 1546
 * The descriptionElements will be cleared in advance in order to allow reusing the
1547
 * same feature tree without the risk of mixing sets of descrition elemens.
1547
 * same feature tree without the risk of mixing sets of description elements.
1548 1548
 *
1549 1549
 * which originally is not existing in the cdm.
1550 1550
 *
1551 1551
 *
1552 1552
 *
1553 1553
 * @param array $featureNodes
1554
 *    An array of cdm FeatureNodes which may be hierachical since feature nodes
1554
 *    An array of cdm FeatureNodes which may be hierarchical since feature nodes
1555 1555
 *    may have children.
1556 1556
 * @param array $descriptionElements
1557 1557
 *    An flat array of cdm DescriptionElements
1558 1558
 * @return array
1559
 *    The $featureNodes structure enriched with the accoding $descriptionElements
1559
 *    The $featureNodes structure enriched with the according $descriptionElements
1560 1560
 */
1561 1561
function _mergeFeatureTreeDescriptions($featureNodes, $descriptionElements) {
1562 1562

  
1563 1563
  foreach ($featureNodes as &$node) {
1564 1564
    // since the $featureNodes array is reused for each description
1565
    // it is nessecary to clear the custom node fields in advance
1565
    // it is necessary to clear the custom node fields in advance
1566 1566
    if(isset($node->descriptionElements)){
1567 1567
      unset($node->descriptionElements);
1568 1568
    }
7.x/modules/cdm_dataportal/cdm_dataportal.module
1975 1975
 *
1976 1976
 * @param array $cdmBase_list
1977 1977
 *   An array of CdmBase instances or a single instance.
1978
 * @param string $footnote_list_key
1978
 * @param string $footnote_list_key_suggestion
1979 1979
 *
1980 1980
 * @return unknown
1981 1981
 */
1982
function cdm_annotations_as_footnotekeys($cdmBase_list, $footnote_list_key = NULL) {
1982
function cdm_annotations_as_footnotekeys($cdmBase_list, $footnote_list_key_suggestion = NULL) {
1983 1983

  
1984 1984
   static $annotations_types_filter = null;
1985 1985
   if(!$annotations_types_filter) {
......
1998 1998
  }
1999 1999

  
2000 2000
  // Getting the key for the footnotemanager.
2001
  if (isset($footnote_list_key)) {
2002
    $footnoteListKey = $footnote_list_key;
2001
  if (isset($footnote_list_key_suggestion)) {
2002
    $footnote_list_key = $footnote_list_key_suggestion;
2003 2003
  }
2004 2004
  else {
2005
    $footnoteListKey = RenderHints::getFootnoteListKey() . '-annotations';
2005
    $footnote_list_key = RenderHints::getFootnoteListKey() . '-annotations';
2006 2006
  }
2007 2007

  
2008 2008
  // Adding the footnotes keys.
......
2010 2010
    $annotations = cdm_ws_getAnnotationsFor($cdmBase_element, variable_get('annotations_types_as_footnotes', $annotations_types_filter));
2011 2011
    if (is_array($annotations)) {
2012 2012
      foreach ($annotations as $annotation) {
2013
        $footNoteKeys[] = FootnoteManager::addNewFootnote($footnoteListKey, $annotation->text);
2013
        $footNoteKeys[] = FootnoteManager::addNewFootnote($footnote_list_key, $annotation->text);
2014 2014
      }
2015 2015
    }
2016 2016
  }
7.x/modules/cdm_dataportal/classes/footnotemanager.php
31 31
   * key of the  $fnstore map
32 32
   *
33 33
   * The values are associative arrays with the following optional elements:
34
   *  - enclosing_tag: the enclosing tag to be used for rendering of the footnote, @see theme_cdm_footnote()
34
   *  - enclosing_tag: the enclosing tag to be used for rendering of the footnote,
35
   *    @see theme_cdm_footnote()
35 36
   *  - key_format: 'latin', 'ROMAN', 'roman', 'ALPHA', 'alpha'
36 37
   * and one required element:
37
   *  - key_index: the set specific counter, to replace the default $footnote_key_index
38
   *  - key_index: the set specific counter, to replace the
39
   *    default $footnote_key_index
38 40
   */
39 41
  private static $fn_sets = array();
40
  private static $default_set_definition = array('key_index' => 1, 'enclosing_tag' => null, 'key_format' => 'numeric');
42
  private static $default_set_definition = array(
43
    'key_index' => 1,
44
    'enclosing_tag' => null,
45
    'key_format' => 'numeric'
46
  );
41 47

  
42 48
  /**
43 49
   * Private constructor.
......
148 154
   * @param $footnoteListKey
149 155
   * @param $object
150 156
   *
151
   * @return unknown_type
157
   * @return
152 158
   */
153 159
  private static function footnoteExists($footnoteListKey, $object) {
154 160
    foreach (self::$fnstore[$footnoteListKey] as $key => $fn) {
7.x/modules/cdm_dataportal/includes/descriptions.inc
197 197
 *     A CDM DescriptionElement instance
198 198
 * @param $separator
199 199
 *     Optional parameter. The separator string to concatenate the footnode ids, default is ','
200
 * @return the string of foot note keys
200
 * @return String
201
 *     the string of foot note keys
201 202
 */
202
function cdm_create_description_element_footnotes($description_element, $separator = ','){
203
function cdm_create_description_element_footnotes($description_element, $separator = ',', $footnote_list_key_suggestion = null){
203 204

  
204 205

  
205 206
  // Annotations as footnotes.
206
  $footNoteKeys = cdm_annotations_as_footnotekeys($description_element);
207
  $footNoteKeys = cdm_annotations_as_footnotekeys($description_element, $footnote_list_key_suggestion);
207 208

  
208 209
  // Source references as footnotes.
209 210
  $bibliography_settings = get_bibliography_settings();
......
212 213
  foreach ($description_element->sources as $source) {
213 214
    if (_is_original_source_type($source)) {
214 215
      $fn_key = FootnoteManager::addNewFootnote(
215
        original_source_footnote_list_key(),
216
        original_source_footnote_list_key($footnote_list_key_suggestion),
216 217
        theme('cdm_OriginalSource', array(
217 218
          'source' => $source,
218 219
          'doLink' => FALSE,
7.x/modules/cdm_dataportal/includes/occurrences.inc
192 192
//                 continue;
193 193
//               }
194 194
              $elements_by_feature = _mergeFeatureTreeDescriptions($occurrence_featureTree->root->childNodes, $description->elements);
195
              $rendered_description = theme(
196
                 'cdm_feature_nodes',
197
                 array('mergedFeatureNodes' => $elements_by_feature)
198
              );
199
              $description_render_elements = array();
200
//               $description_render_elements[] = array('#markup' => '<h4>'. $description->titleCache . '</h4>');
201
              $description_render_elements[] = array('#markup' => $rendered_description);
195
              $description_render_elements = compose_cdm_feature_nodes($elements_by_feature);
202 196
              $dd_elements[] = $description_render_elements;
203 197
            }
204 198

  
7.x/modules/cdm_dataportal/includes/pages.inc
532 532

  
533 533

  
534 534
  // Render the sections for each feature
535
  $render_array['taxon_description_features'] = markup_to_render_array(
536
      theme(
537
          'cdm_feature_nodes',
538
          array('mergedFeatureNodes' => $merged_tree->root->childNodes, 'taxon' => $taxon)
539
      )
540
  );
535
  $render_array['taxon_description_features'] = compose_cdm_feature_nodes($merged_tree->root->childNodes, $taxon);
541 536

  
542 537
  $toc = array(
543 538
    '#theme' => 'item_list',
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/FeatureBlock.java
30 30
 */
31 31
public class FeatureBlock extends DrupalBlock {
32 32

  
33
	private List<LinkElement> footNoteKeys = new ArrayList<LinkElement>();
34

  
35
	private List<BaseElement> footNotes = new ArrayList<BaseElement>();
36

  
37
	private List<BaseElement> originalSources = new ArrayList<BaseElement>();
33
    private List<LinkElement> footNoteKeys = new ArrayList<LinkElement>();
34

  
35
    private List<BaseElement> footNotes = new ArrayList<BaseElement>();
36

  
37
    private List<BaseElement> originalSources = new ArrayList<BaseElement>();
38 38

  
39
	private List<DescriptionElementRepresentation> descriptionElements = new ArrayList<DescriptionElementRepresentation>();
40

  
41
	private String featureType = null;
42

  
43

  
44
	public List<LinkElement> getFootNoteKeys() {
45
		return footNoteKeys;
46
	}
47

  
48
	public List<BaseElement> getFootNotes() {
49
		return footNotes;
50
	}
51

  
52
	public List<BaseElement> getOriginalSourcesSections() {
53
		return originalSources;
54
	}
55

  
56

  
57
	public List<DescriptionElementRepresentation> getDescriptionElements() {
58
		return descriptionElements;
59
	}
60

  
61
	public String getFeatureType() {
62
		return featureType;
63
	}
64

  
65

  
66
	/**
67
	 * @param element
68
	 */
69
	public FeatureBlock(WebElement element, String enclosingTag, String ... elementTags) {
70
		super(element);
71

  
72
		List<WebElement> fnkList = element.findElements(By.className("footnote-key"));
73
		for(WebElement fnk : fnkList) {
74
			footNoteKeys.add(new LinkElement(fnk.findElement(By.tagName("a"))));
75
		}
76

  
77
		List<WebElement> fnList = element.findElements(By.className("footnote"));
78
		for(WebElement fn : fnList) {
79
			footNotes.add(new BaseElement(fn));
80
		}
81

  
82
		List<WebElement> sourcesList = element.findElements(By.className("sources"));
83
		for(WebElement source : sourcesList) {
84
			originalSources.add(new BaseElement(source));
85
		}
86

  
87
		WebElement descriptionElementsRepresentation =  element.findElement(By.className("description"));
88
		featureType = descriptionElementsRepresentation.getAttribute("id");
89

  
90
		//TODO throw exception instead of making an assetion! selenium should have appropriate exeptions
91
		assertEquals("Unexpected tag enclosing description element representations", enclosingTag, descriptionElementsRepresentation.getTagName());
92

  
93
		if(elementTags.length > 1){
94

  
95
			// handle multipart elements e.g. <dt></dt><dd></dd>
96
			HashMap<String, List<WebElement>> elementsByTag = new HashMap<String, List<WebElement>>();
97
			Integer lastSize = null;
98
			for (String elementTag : elementTags) {
99
				List<WebElement> foundElements = descriptionElementsRepresentation.findElements(By.tagName(elementTag));
100
				if(lastSize != null && foundElements.size() != lastSize){
101
					throw new NoSuchElementException("Mulitpart element lists differ in size");
102
				}
103
				lastSize = foundElements.size();
104
				elementsByTag.put(elementTag, foundElements);
105
			}
106

  
107
			for (int descriptionElementIndex = 0; descriptionElementIndex < lastSize; descriptionElementIndex++){
108
				List<WebElement> elementsByIndex = new ArrayList<WebElement>();
109
				for (String elementTag : elementTags) {
110
					elementsByIndex.add(elementsByTag.get(elementTag).get(descriptionElementIndex));
111
				}
112
				descriptionElements.add(new MultipartDescriptionElementRepresentation(elementsByIndex.toArray(new WebElement[elementsByIndex.size()])));
113

  
114
			}
115
		} else {
116
			// handle single elements
117
			String elementTag = elementTags[0];
118
			for(WebElement el : descriptionElementsRepresentation.findElements(By.tagName( elementTag ))) {
119
				descriptionElements.add(new DescriptionElementRepresentation(el));
120
			}
121
		}
122

  
123
	}
124

  
125
	/**
126
	 * @param indent
127
	 * @param computedFontSize
128
	 * @param expectedCssDisplay
129
	 * @param expectedListStyleType only applies if cssDisplay equals list-item
130
	 * @param expectedListStylePosition only applies if cssDisplay equals list-item
131
	 * @param expectedListStyleImage only applies if cssDisplay equals list-item
132
	 */
133
	public void testDescriptionElementLayout(int descriptionElementId, int indent, int computedFontSize
134
			, String expectedCssDisplay, String expectedListStyleType, String expectedListStylePosition, String expectedListStyleImage) {
135

  
136
		DescriptionElementRepresentation firstDescriptionElement = getDescriptionElements().get(descriptionElementId);
137

  
138
		if(firstDescriptionElement instanceof MultipartDescriptionElementRepresentation){
139
			int multipartElementIndex = 0;
140
			firstDescriptionElement = ((MultipartDescriptionElementRepresentation)firstDescriptionElement).multipartElements.get(multipartElementIndex);
141
		}
142
		int parentX = getElement().getLocation().getX();
143
		int elementX = firstDescriptionElement.getElement().getLocation().getX();
144
		double elementPadLeft = pxSizeToDouble(firstDescriptionElement.getElement().getCssValue("padding-left"));
145

  
146
		assertEquals(indent, elementX - parentX + elementPadLeft, PIXEL_TOLERANCE);
147
		assertEquals(computedFontSize, firstDescriptionElement.getComputedFontSize(), 0.5);
148
		assertEquals(expectedCssDisplay, firstDescriptionElement.getElement().getCssValue("display"));
149

  
150
		if(expectedCssDisplay.equals("list-item")){
151
			assertEquals(expectedListStylePosition, firstDescriptionElement.getElement().getCssValue("list-style-position"));
152
			assertEquals(expectedListStyleImage, firstDescriptionElement.getElement().getCssValue("list-style-image"));
153
			assertEquals(expectedListStyleType, firstDescriptionElement.getElement().getCssValue("list-style-type"));
154
		}
155
	}
39
    private List<DescriptionElementRepresentation> descriptionElements = new ArrayList<DescriptionElementRepresentation>();
40

  
41
    private String featureType = null;
42

  
43

  
44
    public List<LinkElement> getFootNoteKeys() {
45
        return footNoteKeys;
46
    }
47

  
48
    public List<BaseElement> getFootNotes() {
49
        return footNotes;
50
    }
51

  
52
    public List<BaseElement> getOriginalSourcesSections() {
53
        return originalSources;
54
    }
55

  
56

  
57
    public List<DescriptionElementRepresentation> getDescriptionElements() {
58
        return descriptionElements;
59
    }
60

  
61
    public String getFeatureType() {
62
        return featureType;
63
    }
64

  
65

  
66
    /**
67
     * @param element
68
     */
69
    public FeatureBlock(WebElement element, String enclosingTag, String ... elementTags) {
70
        super(element);
71

  
72
        List<WebElement> fnkList = element.findElements(By.className("footnote-key"));
73
        for(WebElement fnk : fnkList) {
74
            footNoteKeys.add(new LinkElement(fnk.findElement(By.tagName("a"))));
75
        }
76

  
77
        List<WebElement> fnList = element.findElements(By.className("footnote"));
78
        for(WebElement fn : fnList) {
79
            footNotes.add(new BaseElement(fn));
80
        }
81

  
82
        List<WebElement> sourcesList = element.findElements(By.className("sources"));
83
        for(WebElement source : sourcesList) {
84
            originalSources.add(new BaseElement(source));
85
        }
86

  
87
        WebElement descriptionElementsRepresentation =  element.findElement(By.className("feature-block-elements"));
88
        featureType = descriptionElementsRepresentation.getAttribute("id");
89

  
90
        //TODO throw exception instead of making an assetion! selenium should have appropriate exeptions
91
        assertEquals("Unexpected tag enclosing description element representations", enclosingTag, descriptionElementsRepresentation.getTagName());
92

  
93
        if(elementTags.length > 1){
94

  
95
            // handle multipart elements e.g. <dt></dt><dd></dd>
96
            HashMap<String, List<WebElement>> elementsByTag = new HashMap<String, List<WebElement>>();
97
            Integer lastSize = null;
98
            for (String elementTag : elementTags) {
99
                List<WebElement> foundElements = descriptionElementsRepresentation.findElements(By.tagName(elementTag));
100
                if(lastSize != null && foundElements.size() != lastSize){
101
                    throw new NoSuchElementException("Mulitpart element lists differ in size");
102
                }
103
                lastSize = foundElements.size();
104
                elementsByTag.put(elementTag, foundElements);
105
            }
106

  
107
            for (int descriptionElementIndex = 0; descriptionElementIndex < lastSize; descriptionElementIndex++){
108
                List<WebElement> elementsByIndex = new ArrayList<WebElement>();
109
                for (String elementTag : elementTags) {
110
                    elementsByIndex.add(elementsByTag.get(elementTag).get(descriptionElementIndex));
111
                }
112
                descriptionElements.add(new MultipartDescriptionElementRepresentation(elementsByIndex.toArray(new WebElement[elementsByIndex.size()])));
113

  
114
            }
115
        } else {
116
            // handle single elements
117
            String elementTag = elementTags[0];
118
            for(WebElement el : descriptionElementsRepresentation.findElements(By.tagName( elementTag ))) {
119
                descriptionElements.add(new DescriptionElementRepresentation(el));
120
            }
121
        }
122

  
123
    }
124

  
125
    /**
126
     * @param indent
127
     * @param computedFontSize
128
     * @param expectedCssDisplay
129
     * @param expectedListStyleType only applies if cssDisplay equals list-item
130
     * @param expectedListStylePosition only applies if cssDisplay equals list-item
131
     * @param expectedListStyleImage only applies if cssDisplay equals list-item
132
     */
133
    public void testDescriptionElementLayout(int descriptionElementId, int indent, int computedFontSize
134
            , String expectedCssDisplay, String expectedListStyleType, String expectedListStylePosition, String expectedListStyleImage) {
135

  
136
        DescriptionElementRepresentation firstDescriptionElement = getDescriptionElements().get(descriptionElementId);
137

  
138
        if(firstDescriptionElement instanceof MultipartDescriptionElementRepresentation){
139
            int multipartElementIndex = 0;
140
            firstDescriptionElement = ((MultipartDescriptionElementRepresentation)firstDescriptionElement).multipartElements.get(multipartElementIndex);
141
        }
142
        int parentX = getElement().getLocation().getX();
143
        int elementX = firstDescriptionElement.getElement().getLocation().getX();
144
        double elementPadLeft = pxSizeToDouble(firstDescriptionElement.getElement().getCssValue("padding-left"));
145

  
146
        assertEquals(indent, elementX - parentX + elementPadLeft, PIXEL_TOLERANCE);
147
        assertEquals(computedFontSize, firstDescriptionElement.getComputedFontSize(), 0.5);
148
        assertEquals(expectedCssDisplay, firstDescriptionElement.getElement().getCssValue("display"));
149

  
150
        if(expectedCssDisplay.equals("list-item")){
151
            assertEquals(expectedListStylePosition, firstDescriptionElement.getElement().getCssValue("list-style-position"));
152
            assertEquals(expectedListStyleImage, firstDescriptionElement.getElement().getCssValue("list-style-image"));
153
            assertEquals(expectedListStyleType, firstDescriptionElement.getElement().getCssValue("list-style-type"));
154
        }
155
    }
156 156

  
157 157
}
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_TechnicalAnnnotationsTest.java
52 52
        assertEquals("Distribution", tocLinks.get(0).getText());
53 53
        assertEquals("Credits", tocLinks.get(1).getText());
54 54

  
55
        // Credits contains an technical annotation but this mus not be displayed
55
        // Credits contains an technical annotation but this must not be displayed
56 56
        FeatureBlock creditsBlock = p.getFeatureBlockAt(1, "credits", "div", "div");
57 57
        //testing this is not possible due to SCHROTT-CODE // assertEquals("expecting 1 DescriptionElements in citation", 1, creditsBlock.getDescriptionElements().size());
58 58
        assertEquals("Credits\nBoufford D. E. 2009: Images (12 added)\nSmalla M. 2009: Images (1 added)\nSun H. 2009: Images (3 added)\nYue J. 2009: Images (1 added)\nZhang J. 2009: Images (1 added).", creditsBlock.getText());
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/Allium_guttatum_subsp_guttatum_TaxonProfileTest.java
97 97
//		featureBlock = p.getFeatureBlockAt(3, "systematics", "div", null);
98 98
//		assertEquals("Systematics\nTaxonomy and nomenclature follow Mathew (1996).\nMathew B. 1996: A review of Allium section Allium . - Kew.", featureBlock.getText());
99 99

  
100
        FeatureBlock bibliography = p.getFeatureBlockAt(5, "bibliography", "div", "div");
101
        List<BaseElement> bibliographyEntries = bibliography.getFootNotes();
102

  
100 103
        featureBlock = p.getFeatureBlockAt(4, "distribution", "div", "span");
104

  
101 105
        assertEquals("Distribution\nDivision 21,2\n1. R. D. Meikle, Flora of Cyprus 2. 1985, 2. R. Hand, Supplementary notes to the flora of Cyprus VI. in Willdenowia 39. 2009", featureBlock.getText());
102 106
        assertEquals("Distribution", featureBlock.getHeader());
103 107
        assertEquals("expecting two footnote keys", 2, featureBlock.getFootNoteKeys().size());
104 108

  
109
        assertEquals("A. R. D. Meikle, Flora of Cyprus 2. 1985", bibliographyEntries.get(1));
110
        assertEquals("B. R. Hand, Supplementary notes to the flora of Cyprus VI. in Willdenowia 39. 2009", bibliographyEntries.get(1));
111

  
105 112
        LinkElement footNoteKey_1 = featureBlock.getFootNoteKeys().get(0);
106 113
        BaseElement footNote_1 = featureBlock.getFootNotes().get(0);
107 114
        assertTrue("expecting one footnote 0 to be the footnote for key 0",footNote_1.getText().startsWith(footNoteKey_1.getText()));
7.x/modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
37 37
}
38 38

  
39 39
/**
40
 * Returns HTML for a taxon profile from the $mergedFeatureNodes of a given $taxon.
40
 * Returns a set of feature blocks for a taxon profile from the $mergedFeatureNodes of a given $taxon.
41 41
 *
42
 * The taxon profile consists of description elements which are ordered by the
43
 * structure defined by specific FeatureTree. The chosen FeatureTree is merged
44
 * with the list of desctiprion elements prior to using this method.
42
 * The taxon profile consists of drupal block elements, one for the description elements
43
 * of a specific feature. The structure is defined by specific FeatureTree.
44
 * The chosen FeatureTree is merged with the list of description elements prior to using this method.
45 45
 *
46 46
 * The merged nodes can be obtained by making use of the
47 47
 * function cdm_ws_descriptions_by_featuretree().
48 48
 *
49 49
 * @see cdm_ws_descriptions_by_featuretree()
50 50
 *
51
 * @param array $variables
52
 *   An associative array containing:
53
 *   - mergedFeatureNodes
54
 *   -taxon
51
 * @param $mergedFeatureNodes
55 52
 *
56
 * @ingroup themeable
53
 * @param $taxon
54
 *
55
 * @return array
56
 *  A Drupal render array
57
 *
58
 * @ingroup compose
57 59
 */
58
function theme_cdm_feature_nodes($variables) {
60
function compose_cdm_feature_nodes($mergedFeatureNodes, $taxon) {
59 61

  
60
  $mergedFeatureNodes = $variables['mergedFeatureNodes'];
61
  $taxon = $variables['taxon'];
62 62
  $out = '';
63 63

  
64 64
  RenderHints::pushToRenderStack('feature_nodes');
65 65

  
66 66
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME);
67 67

  
68
  // Creating an array to place the description elements in.
68
  // Create a drupal block for each feature
69 69
  foreach ($mergedFeatureNodes as $node) {
70 70

  
71
    if ((isset($node->descriptionElements['#type']) || has_feature_node_description_elements($node)) && $node->feature->uuid != UUID_IMAGE) {
71
    if ((isset($node->descriptionElements['#type']) ||
72
        has_feature_node_description_elements($node)) && $node->feature->uuid != UUID_IMAGE) { // skip empty or supressed features
72 73

  
73
      $feature_name = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
74
      $feature_name = cdm_term_representation($node->feature, 'Unnamed Feature');
74 75

  
75 76
      $block = feature_block($feature_name, $node->feature);
76 77

  
77
      $media_list = array();
78

  
79 78
      /*
80 79
       * Content/DISTRIBUTION.
81 80
       */
82
      if ($node->feature->uuid == UUID_DISTRIBUTION) {
83

  
84
        $distributionElements = null;
85
        $distribution_info_dto = null;
86
        $text_data_out_array = array();
87

  
88
        $distribution_sortOutArray = FALSE;
89
        if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') {
90
          $distribution_glue = '';
91
          $distribution_enclosingTag = 'dl';
92
        }
93
        else {
94
          $distribution_glue = '';
95
          $distribution_enclosingTag = 'ul';
96
        }
97

  
98
        if(!isset($node->descriptionElements['#type']) || !$node->descriptionElements['#type']=='DTO') {
99
          // skip the DISTRIBUTION section if there is no DTO type element
100
          continue;
101
        }
102

  
103
        if(isset($node->descriptionElements['TextData'])){
104
          // --- TextData
105
          foreach ($node->descriptionElements['TextData'] as $text_data_element){
106
            $asListElement = FALSE;
107
            $repr = theme('cdm_descriptionElementTextData', array(
108
                'element' => $text_data_element,
109
                'asListElement' => $asListElement,
110
                'feature_uuid' => $text_data_element->feature->uuid,
111
            ));
112

  
113
            if (!array_search($repr, $text_data_out_array)) {
114
              $text_data_out_array[] = $repr;
115
              // TODO HINT: sorting in theme_cdm_descriptionElementArray will
116
              // not work since this array contains html attributes with uuids
117
              // !!!!
118
              $text_data_sortOutArray = TRUE;
119
              $text_data_glue = '<br/> ';
120
              $text_data_enclosingTag = 'p';
121
            }
122
          }
123
        }
124

  
125

  
126
        if ($text_data_out_array && variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
127
          $block->content .= theme('cdm_descriptionElementArray', array(
128
            'elementArray' => $text_data_out_array,
129
            'feature' => $node->feature,
130
            'glue' => $text_data_glue,
131
            'sortArray' => $text_data_sortOutArray,
132
            'enclosingHtml' => $text_data_enclosingTag,
133
          ));
134
        }
135

  
136
        // --- Distribution map
137
        $distribution_map_query_parameters = null;
138
        if(isset($node->descriptionElements['DistributionInfoDTO'])) {
139
          $distribution_map_query_parameters = $node->descriptionElements['DistributionInfoDTO']->mapUriParams;
140
        }
141
        $map_render_element = compose_distribution_map($taxon, $distribution_map_query_parameters);
142
        $block->content .= $map_render_element['#markup'];
143

  
144
          // --- tree or list
145
            $dto_out_array = array();
146
        if(isset($node->descriptionElements['DistributionInfoDTO'])) {
147
          $distribution_info_dto = $node->descriptionElements['DistributionInfoDTO'];
148

  
149
          // --- tree
150
          if (is_object($distribution_info_dto->tree)) {
151
            $dto_out_array[] = theme('cdm_description_ordered_distributions', array('distribution_tree' => $distribution_info_dto->tree));
152
          }
153

  
154
          // --- sorted element list
155
          if( is_array($distribution_info_dto->elements) && count($distribution_info_dto->elements) > 0 ) {
156
            foreach ($distribution_info_dto->elements as $descriptionElement){
157
              if (is_object($descriptionElement->area)) {
158
                $sortKey = $descriptionElement->area->representation_L10n;
159
                $distributionElements[$sortKey] = $descriptionElement;
160
              }
161
            }
162
            ksort($distributionElements);
163
            $dto_out_array[] = theme('cdm_descriptionElement_Distribution', array(
164
                'descriptionElements' => $distributionElements,
165
            ));
166

  
167
          }
168
          //
169
          $block->content .= theme('cdm_descriptionElementArray', array(
170
              'elementArray' => $dto_out_array,
171
              'feature' => $node->feature,
172
              'glue' => $distribution_glue,
173
              'sortArray' => $distribution_sortOutArray,
174
              'enclosingHtml' => $distribution_enclosingTag,
175
          ));
176
        }
177 81

  
178
        // --- TextData at the bottom
179
        if ($text_data_out_array && !variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
180
          $block->content .= theme('cdm_descriptionElementArray', array(
181
              'elementArray' => $text_data_out_array,
182
              'feature' => $node->feature,
183
              'glue' => $text_data_glue,
184
              'sortArray' => $text_data_sortOutArray,
185
              'enclosingHtml' => $text_data_enclosingTag,
186
          ));
187
        }
82
      if ($node->feature->uuid == UUID_DISTRIBUTION) {
83
        $block = compose_feature_block_distribution($taxon, $node->descriptionElements, $node->feature);
188 84

  
189 85
      }
190

  
191 86
      /*
192 87
       * Content/COMMON_NAME.
193 88
       */
194 89
      elseif ($node->feature->uuid == UUID_COMMON_NAME) {
195
        // TODO why is theme_cdm_descriptionElement_CommonTaxonName not
196
        // beeing used???
197
       $block->content .= theme('cdm_common_names', array('elements' => $node->descriptionElements));
198
        /*
199
        }else if($node->feature->uuid == UUID_IMAGE_SOURCES) {
200
        $block->content .= theme('cdm_image_sources',
201
        $node->descriptionElements);
202
        */
90
        $common_names_render_array = compose_cdm_common_names($node->descriptionElements, $node->feature);
91
        $block->content .= drupal_render($common_names_render_array);
203 92
      }
204 93

  
205 94
      /*
206 95
       * Content/ALL OTHER FEATURES.
207 96
       */
208 97
      else {
98

  
99
        $media_list = array();
100
        $out_child_elements = '';
101

  
209 102
        if (isset($node->descriptionElements)) {
210 103
          $taxon_uuid = NULL;
211 104
          if(isset($taxon) ) {
......
218 111
          ));
219 112
        }
220 113

  
221
//           Content/ALL OTHER FEATURES/Subordinate Features
222
//           subordinate features are printed inline in one floating text,
223
//           it is expected hat supordinate features can "contain" TextData,
224
//           Qualitative- and Qualitative- DescriptioneElements
225
        if (isset($node->childNodes[0])) {
114
          // Content/ALL OTHER FEATURES/Subordinate Features
115
          // subordinate features are printed inline in one floating text,
116
          // it is expected hat supordinate features can "contain" TextData,
117
          // Qualitative- and Qualitative- DescriptioneElements
118
          if (isset($node->childNodes[0])) {
226 119

  
227 120
          // TODO support more than one level of children.
228 121
          // can this be solved by resursively calling this very function?
......
261 154
            }
262 155
          }
263 156
          $block->content .= $text;
157
          $block->content .=  compose_feature_media_gallery($node, $media_list, $gallery_settings);
158

  
159

  
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));
264 165
        }
265 166
      }
266 167

  
267
      /*
268
       * Media/ALL FEATURES.
269
       */
270
      if (isset($node->descriptionElements)) {
271
        $media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
272
      }
273
      $captionElements = array('title', 'rights');
274
      $gallery = '';
275
      if (isset($gallery_settings['cdm_dataportal_media_maxextend']) && isset($gallery_settings['cdm_dataportal_media_cols'])) {
276
        $gallery = theme('cdm_media_gallerie', array(
277
          'mediaList' => $media_list,
278
          'galleryName' => CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME . '_' . $node->feature->uuid,
279
          'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
280
          'cols' => $gallery_settings['cdm_dataportal_media_cols'],
281
          'captionElements' => $captionElements,
282
        ));
283
      }
284
      $block->content .= $gallery;
285
      $block->content .= theme('cdm_footnotes', array('footnoteListKey' => $node->feature->uuid));
286
      $block->content .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $node->feature->uuid));
287 168

  
288
      // In D6: $out .= theme('block', $block);
289
      // Comment @WA @TODO check if need to set a region, and which one.
290
      $block->region = FALSE;
291 169
      $out .= theme('block',
292 170
        array(
293 171
          'elements' => array(
......
296 174
          )
297 175
        )
298 176
      );
299
    }
300
  }
177
    } // END: skip empty or supressed features
178
  } // END: creating a block per feature
301 179
  RenderHints::popFromRenderStack();
302
  return $out;
180

  
181
  return markup_to_render_array($out);
303 182
}
304 183

  
184
  /**
185
   * @param $node
186
   * @param $media_list
187
   * @param $gallery_settings
188
   * @return array
189
   */
190
  function compose_feature_media_gallery($node, $media_list, $gallery_settings) {
191
    if (isset($node->descriptionElements)) {
192
      $media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
193
    }
194
    $captionElements = array('title', 'rights');
195
    $gallery = '';
196
    if (isset($gallery_settings['cdm_dataportal_media_maxextend']) && isset($gallery_settings['cdm_dataportal_media_cols'])) {
197
      $gallery = theme('cdm_media_gallerie', array(
198
        'mediaList' => $media_list,
199
        'galleryName' => CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME . '_' . $node->feature->uuid,
200
        'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
201
        'cols' => $gallery_settings['cdm_dataportal_media_cols'],
202
        'captionElements' => $captionElements,
203
      ));
204
      return array($media_list, $gallery);
205
    }
206
    return array($media_list, $gallery);
207
  }
305 208

  
209
  /**
210
   * @param $taxon
211
   * @param $descriptionElements
212
   *   an associative array with two elements:
213
   *   - '#type': must be 'DTO'
214
   *   - 'DistributionInfoDTO': a CDM DistributionInfoDTO object as returned by the DistributionInfo web service
215
   * @param $feature
216
   *
217
   * @ingroup compose
218
   */
219
  function compose_feature_block_distribution($taxon, $descriptionElements, $feature) {
220
    $text_data_glue = '';
221
    $text_data_sortOutArray = FALSE;
222
    $text_data_enclosingTag = 'ul';
223
    $text_data_out_array = array();
224

  
225
    $distributionElements = NULL;
226
    $distribution_info_dto = NULL;
227
    $distribution_sortOutArray = FALSE;
228

  
229
    if (variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT') {
230
      $distribution_glue = '';
231
      $distribution_enclosingTag = 'dl';
232
    } else {
233
      $distribution_glue = '';
234
      $distribution_enclosingTag = 'ul';
235
    }
306 236

  
307
/**
237
    if (!isset($descriptionElements['#type']) || !$descriptionElements['#type'] == 'DTO') {
238
      // skip the DISTRIBUTION section if there is no DTO type element
239
      return array(); // FIXME is it ok to return an empty array?
240
    }
241

  
242
    $block = feature_block(
243
      cdm_term_representation($feature, 'Unnamed Feature'),
244
      $feature
245
    );
246

  
247
    // ======== FIXME is this being used at all? seems to make no sense!!!
248
    if (isset($descriptionElements['TextData'])) {
249
      // --- TextData
250
      foreach ($descriptionElements['TextData'] as $text_data_element) {
251
        $asListElement = FALSE;
252
        $repr = theme('cdm_descriptionElementTextData', array(
253
          'element' => $text_data_element,
254
          'asListElement' => $asListElement,
255
          'feature_uuid' => $text_data_element->feature->uuid,
256
        ));
257

  
258
        if (!array_search($repr, $text_data_out_array)) {
259
          $text_data_out_array[] = $repr;
260
          // TODO HINT: sorting in theme_cdm_feature_block_elements will
261
          // not work since this array contains html attributes with uuids
262
          // !!!!
263
          $text_data_sortOutArray = TRUE;
264
          $text_data_glue = '<br/> ';
265
          $text_data_enclosingTag = 'p';
266
        }
267
      }
268
    }
269

  
270

  
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
      ));
279
    }
280

  
281
    // --- Distribution map
282
    $distribution_map_query_parameters = NULL;
283
    if (isset($descriptionElements['DistributionInfoDTO'])) {
284
      $distribution_map_query_parameters = $descriptionElements['DistributionInfoDTO']->mapUriParams;
285
    }
286
    $map_render_element = compose_distribution_map($taxon, $distribution_map_query_parameters);
287
    $block->content .= $map_render_element['#markup'];
288

  
289
    // --- tree or list
290
    $dto_out_array = array();
291
    if (isset($descriptionElements['DistributionInfoDTO'])) {
292
      $distribution_info_dto = $descriptionElements['DistributionInfoDTO'];
293

  
294
      // --- tree
295
      if (is_object($distribution_info_dto->tree)) {
296
        $dto_out_array[] = theme('cdm_description_ordered_distributions', array('distribution_tree' => $distribution_info_dto->tree));
297
      }
298

  
299
      // --- sorted element list
300
      if (is_array($distribution_info_dto->elements) && count($distribution_info_dto->elements) > 0) {
301
        foreach ($distribution_info_dto->elements as $descriptionElement) {
302
          if (is_object($descriptionElement->area)) {
303
            $sortKey = $descriptionElement->area->representation_L10n;
304
            $distributionElements[$sortKey] = $descriptionElement;
305
          }
306
        }
307
        ksort($distributionElements);
308
        $dto_out_array[] = theme('cdm_descriptionElement_Distribution', array(
309
          'descriptionElements' => $distributionElements,
310
        ));
311

  
312
      }
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
      ));
321
    }
322

  
323
    // --- TextData at the bottom
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
      ));
332
    }
333

  
334
    $block->content .= theme('cdm_footnotes', array('footnoteListKey' => UUID_DISTRIBUTION));
335
    $block->content .= theme('cdm_annotation_footnotes', array('footnoteListKey' => UUID_DISTRIBUTION));
336

  
337
    return $block;
338
  }
339

  
340

  
341
  /**
308 342
 * @todo Please document this function.
309 343
 * @see http://drupal.org/node/1354
310 344
 */
......
365 399
 *
366 400
 * @ingroup themeable
367 401
 */
368
function theme_cdm_descriptionElementArray($variables) {
402
function theme_cdm_feature_block_elements($variables) {
369 403
  $elementArray = $variables['elementArray'];
370

  
371 404
  $feature = $variables['feature'];
372 405
  $glue = $variables['glue'];
373 406
  $sortArray = $variables['sortArray'];
374 407
  $enclosingHtml = $variables['enclosingHtml'];
375
  $out = '<' . $enclosingHtml . ' class="description" id="' . $feature->representation_L10n . '">';
408

  
409
  $out = '<' . $enclosingHtml . ' class="feature-block-elements" id="' . $feature->representation_L10n . '">';
376 410

  
377 411
  if ($sortArray) {
378 412
    sort($elementArray);
379 413
  }
380 414

  
381
  $out .= join($elementArray, $glue);
415
  $out .= '<span class="feature-block-element">' . join($elementArray, '<span class="feature-block-element">' . $glue . '</span>') . '</span>';
382 416

  
383 417
  $out .= '</' . $enclosingHtml . '>';
384 418
  return $out;
385 419
}
386 420

  
387
/**
388
 * Theme function to render CDM DescriptionElements of the type CommonTaxonName.
389
 *
390
 * @param array $variables
391
 *   An associative array containing:
392
 *  - element: the CommonTaxonName element
393
 * @return a html representation of the given CommonTaxonName element
394
 *
395
 * @ingroup themeable
396
 */
397
function theme_cdm_descriptionElement_CommonTaxonName($variables) {
398
  $element = $variables['element'];
399
  $out = '<span class="' . html_class_attribute_ref($element) . '">' . $element->language->representation_L10n . ' (' . $element->area->titleCache . '): ' . $element->name . '</span>';
400
  return $out;
401
}
402 421

  
403 422
/**
404 423
 * Theme function to render CDM DescriptionElements of the type CategoricalData.
......
487 506
  if (isset($element->statisticalValues->modifyingText_L10n)) {
488 507
    $out .=  ' ' . $element->statisticalValues->modifyingText_L10n;
489 508
  }
490
  $modifers_string = cdm_modifers_representations($element->statisticalValues);
491
  $out .= ($modifers_string ? ' ' . cdm_modifers_representations($element->statisticalValues) : '');
509
  $modifiers_strings = cdm_modifers_representations($element->statisticalValues);
510
  $out .= ($modifiers_strings ? ' ' . cdm_modifers_representations($element->statisticalValues) : '');
492 511

  
493 512
  $footnote_key_list_str = cdm_create_description_element_footnotes($element);
494 513

  
......
589 608
    $description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
590 609
  }
591 610
  $sourceRefs = '';
592
  $result = array();
593 611
  $out = '';
594
  $res_author = '';
595
  $res_date = '';
612

  
596 613
  if (isset($element->sources) && is_array($element->sources) && count($element->sources) > 0) {
597 614
    foreach ($element->sources as $source) {
598 615
      $referenceCitation = theme('cdm_OriginalSource', array('source' => $source));
......
631 648
            $out .= $name_used_in_source_link_to_show . ' ';
632 649
          }
633 650
        }
634
        $out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $element, 'footnote_list_key' => $feature_uuid)) . '</li>';
651
        $out .= $description . $sourceRefs . theme(
652
            'cdm_annotations_as_footnotekeys',
653
            array('cdmBase_list' => $element,
654
              'footnote_list_key' => $feature_uuid)) . '</li>';
635 655
      }
636 656
      else {
637 657
        if ($name_used_in_source_link_to_show) {
......
647 667
    $out = $description;
648 668
  }
649 669

  
650
  // FIXME This will create footnotes for annotatios and source, sources are already rendered though
670
  // FIXME This will create footnotes for annotations and sources, sources are already rendered though
651 671
  // FIXME the footnoes are not shown in the page
652 672
  // FIXME RenderHints::getFootnoteListKey() ate not set here
653 673
  // to many problems, so the below line is diabled for now
......
658 678
}
659 679

  
660 680
/**
661
 * @todo Please document this function.
662
 * @see http://drupal.org/node/1354
681
 * Composes block of common names for the given DescriptionElements $elements which must be of the feature CommonName
682
 *
683
 * @parameter $elements
684
 *  an array of CDM DescriptionElements either of type CommonName or TextData
685
 * @parameter $feature
686
 *  the common feature of all $elements, must be CommonName
687
 *
688
 * @return
689
 *   A drupal render array
690
 *
691
 * @ingroup compose
663 692
 */
664
function theme_cdm_common_names($variables) {
665
  $elements = $variables['elements'];
666
  $text_data_out = '';
693
function compose_cdm_common_names($elements, $feature) {
694

  
667 695
  $common_name_out = '';
668
  $separator = ',';
696
  $common_name_feature_elements = array();
669 697
  $textData_commonNames = array();
670 698

  
699
  $footnote_key_suggestion = 'common-names-feature-block';
700

  
671 701
  if (is_array($elements)) {
672 702
    foreach ($elements as $element) {
703

  
673 704
      if ($element->class == 'CommonTaxonName') {
674 705

  
675 706
        // common name without a language or area, should not happen but is possible
......
702 733
    // can give strange results.
703 734
    ksort($common_names);
704 735

  
705
    // Creating the output to be render by Drupal.
706
    foreach ($common_names as $key => $elements) {
736
    // loop over set of elements per language area
737
    foreach ($common_names as $language_area_key => $elements) {
707 738
      ksort($elements); // sort names alphabetically
708
      $rendered_element_list = '';
739
      $per_language_area_out = array();
740
      // loop over set of individual elements
709 741
      foreach ($elements as $element) {
710
        $sourcesFootnoteKeyList = '';
711
        // Adding footnotes sources.
712
        foreach ($element->sources as $source) {
713
          if (_is_original_source_type($source)) {
714
            $_fkey = FootnoteManager::addNewFootnote(original_source_footnote_list_key(UUID_COMMON_NAME), theme('cdm_OriginalSource', array('source' => $source, 'doLink' => FALSE)));
715
            $sourcesFootnoteKeyList .= theme('cdm_footnote_key', array('footnoteKey' => $_fkey, 'separator' => ($sourcesFootnoteKeyList ? $separator : '')));
716
          }
717
        }
718 742
        if ($element->name) {
719
          $rendered_element_list .= '<span class="' . html_class_attribute_ref($element) . '">' . (strlen($rendered_element_list) > 0 ? ', ' : '') . $element->name . $sourcesFootnoteKeyList . '</span>';
743
          $per_language_area_out[] = '<span class="' . html_class_attribute_ref($element) . '">'
744
          . $element->name . cdm_create_description_element_footnotes($element, ',', $footnote_key_suggestion) . '</span>';
720 745
        }
721
      }
722
      if ($key) {
723
        $common_name_out .= (strlen($common_name_out) > 0 ? '; ' : '') . $key . ': ' . $rendered_element_list;
724
      }
725
      else {
726
        $common_name_out .= (strlen($common_name_out) > 0 ? '; ' : '') . $rendered_element_list;
727
      }
728
    }
746
      } // End of loop over set of individual elements
747
      $common_name_feature_elements[] = ($language_area_key ? $language_area_key . ': ' : '' ) . join(',', $per_language_area_out);
748
    } // End of loop over set of elements per language area
749

  
750

  
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
    );
760

  
761

  
729 762
  }
763

  
730 764
  // Handling commons names as text data.
765
  $text_data_out = array();
766

  
731 767
  foreach ($textData_commonNames as $text_data_element) {
732
    $text_data_out .= theme('cdm_descriptionElementTextData', array(
768
    /* footnotes are not handled correctly in theme_cdm_descriptionElementTextData,
769
       need to set 'common-names-feature-block' as $footnote_key_suggestion */
770
    RenderHints::setFootnoteListKey($footnote_key_suggestion);
771
    $text_data_out[] = theme('cdm_descriptionElementTextData', array(
733 772
      'element' => $text_data_element,
734 773
      'asListElement' => TRUE,
735 774
      'feature_uuid' => $text_data_element->feature->uuid,
736 775
    ));
737 776
  }
738 777

  
739
  $common_name_out = "<div class=common_names_as_common_names> $common_name_out </div>";
740
  $out_array[] = $text_data_out;
741
  $common_name_out_text_data = '<div class=common_names_as_text_data>' . theme('cdm_descriptionElementArray', array('elementArray' => $out_array, 'feature' => $element->feature)) . '</div>';
778
  $common_name_out_text_data = theme(
779
        'cdm_feature_block_elements',
780
        array(
781
          'elementArray' => $text_data_out,
782
          'feature' => $feature
783
        )
784
      );
742 785

  
743
  return $common_name_out . $common_name_out_text_data;
744
  /*
745
  return $common_name_out . theme('cdm_descriptionElementArray', $out_array,
746
  $element->feature);
747
  return "<div class=common_names> $common_name_out
748
  $common_name_out_text_data";
749
  */
786

  
787
  $footnotes = theme('cdm_footnotes', array('footnoteListKey' => $footnote_key_suggestion)); // FIXME is this needed at all?
788
  $footnotes .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $footnote_key_suggestion));
789

  
790
  return  markup_to_render_array(
791
    '<div class="common_names_as_common_names">' . $common_name_out . '</div>'
792
    .'<div class="common_names_as_text_data">' . $common_name_out_text_data . '</div>'
793
    .$footnotes
794
  );
750 795
}
751 796

  
752 797
/**
......
760 805
 *     These descriptions elements of a Description must be ordered by the chosen feature tree by
761 806
 *     calling the function _mergeFeatureTreeDescriptions().
762 807
 *     @see _mergeFeatureTreeDescriptions()
763
 *   - featureUuid: currently unused, accoding code disabled
764
 *   - taxon_uuid: only used for ordered dditributions (will be removed!)
808
 *   - featureUuid: currently unused, according code disabled
809
 *   - taxon_uuid: only used for ordered distributions (will be removed!)
765 810
 *
766 811
 * @ingroup themeable
767 812
 */
......
831 876
              'feature_uuid' => $descriptionElement->feature->uuid,
832 877
            ));
833 878
            break;
834
          case 'CommonTaxonName':
835
            $outArray[] = theme('cdm_descriptionElement_CommonTaxonName', array('element' => $descriptionElement));
836
          break;
837 879
          case 'CategoricalData':
838 880
            $outArray[] = theme('cdm_descriptionElement_CategoricalData', array('element' => $descriptionElement));
839 881
            break;
......
867 909
  } // END normal description element arrays
868 910

  
869 911

  
870
  $out = theme('cdm_descriptionElementArray', array(
912
  $out = theme('cdm_feature_block_elements', array(
871 913
    'elementArray' => $outArray,
872 914
    'feature' => $feature,
873 915
    'glue' => $glue,
7.x/modules/cdm_dataportal/theme/theme_registry.inc
75 75

  
76 76
      // Themes in cdm_dataportal.descriptions.theme.
77 77
      'cdm_feature_name' => array('variables' => array('feature_name' => NULL)),
78
      'cdm_feature_nodes' => array('variables' => array('mergedFeatureNodes' => NULL, 'taxon' => NULL)),
79 78
      'FeatureTree_hierarchy' => array('variables' => array('FeatureTreeUuid' => NULL)),
80 79
      'FeatureTree_hierarchy_children' => array('variables' => array('node' => NULL)),
81
      'cdm_descriptionElementArray' => array('variables' => array(
80
      'cdm_feature_block_elements' => array('variables' => array(
82 81
          'elementArray' => array(),
83 82
          'feature' => NULL,
84 83
          'glue' => '',
85 84
          'sortArray' => FALSE,
86 85
          'enclosingHtml' => 'ul',
87 86
      )),
88
      'cdm_descriptionElement_CommonTaxonName' => array('render element' => 'element'),
89 87
      'cdm_descriptionElement_CategoricalData' => array('render element' => 'element'),
90 88
      'cdm_descriptionElement_IndividualsAssociation' => array('render element' => 'element'),
91 89
      'cdm_descriptionElement_TaxonInteraction' => array('render element' => 'element'),
......
95 93
          'asListElement' => NULL,
96 94
          'feature_uuid' => NULL,
97 95
      )),
98
      'cdm_common_names' => array('render element' => 'elements'),
96
      'cdm_common_names' => array('render element' => 'elements', 'variables' => array('feature' => null) ),
99 97
      'cdm_descriptionElements' => array('variables' => array(
100 98
          'descriptionElements' => NULL,
101 99
          'feature' => NULL,
7.x/themes/garland_cichorieae/template.php
216 216
// return $out;
217 217
// }
218 218
/**
219
 * Returns HTML for a cdm_descriptionElementArray.
219
 * Returns HTML for a cdm_feature_block_elements.
220 220
 *
221 221
 * @param array $variables
222 222
 *   An associative array containing:
......
229 229
 *
230 230
 * @ingroup themeable
231 231
 */
232
function garland_cichorieae_cdm_descriptionElementArray($variables) {
232
function garland_cichorieae_cdm_feature_block_elements($variables) {
233 233
  $elementArray = $variables['elementArray'];
234 234
  $feature = $variables['feature'];
235 235
  $glue = $variables['glue'];
......
237 237
  $enclosingHtml = $variables['enclosingHtml'];
238 238

  
239 239
  $enclosingHtml = 'div';
240
  $out = '<' . $enclosingHtml . ' class="description" id="' . $feature->representation_L10n . '">';
240
  $out = '<' . $enclosingHtml . ' class="feature-block-elements" id="' . $feature->representation_L10n . '">';
241 241

  
242 242
  if ($sortArray) {
243 243
    sort($elementArray);
244 244
  }
245 245

  
246
  $out .= join($elementArray, $glue);
246
  $out .= '<span class="feature-block-element">' . join($elementArray, '<span class="feature-block-element">' . $glue . '</span>') . '</span>';
247 247

  
248 248
  $out .= '</' . $enclosingHtml . '>';
249 249
  return $out;
7.x/themes/garland_diptera/template.php
200 200
    }
201 201
  }
202 202

  
203
  return theme('cdm_descriptionElementArray', $outArray, $feature, $glue, $sortOutArray, $enclosingHtml);
203
  return theme('cdm_feature_block_elements', $outArray, $feature, $glue, $sortOutArray, $enclosingHtml);
204 204
}
205 205

  
206 206
/**
7.x/themes/palmweb_2/template.php
164 164

  
165 165
              if (!array_search($repr, $text_data_out_array)) {
166 166
                $text_data_out_array[] = $repr;
167
                // TODO HINT: sorting in theme_cdm_descriptionElementArray will
167
                // TODO HINT: sorting in theme_cdm_feature_block_elements will
168 168
                // not work since this array contains html attributes with uuids
169 169
                // !!!!
170 170
                $text_data_sortOutArray = TRUE;
......
176 176

  
177 177

  
178 178
          if ($text_data_out_array && variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
179
            $block->content .= theme('cdm_descriptionElementArray', array(
179
            $block->content .= theme('cdm_feature_block_elements', array(
180 180
              'elementArray' => $text_data_out_array,
181 181
              'feature' => $node->feature,
182 182
              'glue' => $text_data_glue,
......
218 218

  
219 219
            }
220 220
            //
221
            $block->content .= theme('cdm_descriptionElementArray', array(
221
            $block->content .= theme('cdm_feature_block_elements', array(
222 222
                'elementArray' => $dto_out_array,
223 223
                'feature' => $node->feature,
224 224
                'glue' => $distribution_glue,
......
229 229

  
230 230
          // --- TextData at the bottom
231 231
          if ($text_data_out_array && !variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)) {
232
            $block->content .= theme('cdm_descriptionElementArray', array(
232
            $block->content .= theme('cdm_feature_block_elements', array(
233 233
                'elementArray' => $text_data_out_array,
234 234
                'feature' => $node->feature,
235 235
                'glue' => $text_data_glue,
......
244 244
        Content/COMMON_NAME.
245 245
        */
246 246
        elseif ($node->feature->uuid == UUID_COMMON_NAME) {
247
          // TODO why is theme_cdm_descriptionElement_CommonTaxonName
248
          // not beeing used???
249 247
          $block->content .= theme('cdm_common_names', array('elements' => $node->descriptionElements));
250
        /*
251
        }else if($node->feature->uuid == UUID_IMAGE_SOURCES) {
252
          $block->content .= theme('cdm_image_sources', $node->descriptionElements);
253
        */
254 248
        }
255 249

  
256 250
        /*

Also available in: Unified diff