Project

General

Profile

« Previous | Next » 

Revision 294bea51

Added by Andreas Kohlbecker over 12 years ago

fixing #2521 (Remove empty descriptions)

View differences:

modules/cdm_dataportal/cdm_api/cdm_api.module
689 689
  foreach($featureNodes as &$node){
690 690

  
691 691
    // append corresponding elements to an additional node field: $node->descriptionElements
692
    foreach($descriptionElements as $element){
693
      if($element->feature->uuid == $node->feature->uuid){
694
        if(!isset($node->descriptionElements)){
692
    foreach($descriptionElements as $element) {
693
      if($element->feature->uuid == $node->feature->uuid) {
694
        if(!isset($node->descriptionElements)) {
695 695
          $node->descriptionElements = array();
696 696
        }
697 697
        $node->descriptionElements[] = $element;
modules/cdm_dataportal/cdm_dataportal.module
1476 1476
  return $out;
1477 1477
}
1478 1478

  
1479
/**
1480
 * returns true if the given $featureNode or any of its subordinate nodes contains at least one
1481
 * DescriptionElement
1482
 * @param unknown_type $featureNode A heature node as produced by the function _mergeFeatureTreeDescriptions()
1483
 */
1484
function hasFeatureNodeDescriptionElements($featureNode) {
1485

  
1486
  if(is_array($featureNode->descriptionElements) && count($featureNode->descriptionElements) > 0) {
1487
    return true;
1488
  } else if(is_array($featureNode->children)) {
1489
    foreach ($featureNode->children as $child) {
1490
      if(hasFeatureNodeDescriptionElements($child)){
1491
        return true;
1492
      }
1493
  }
1494
  return false;
1495
}
1496

  
1497
}
modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
16 16
  $out .= '<ul>';
17 17

  
18 18
  foreach($featureNodes as $node){
19
    // process $descriptionElements with content only
20
    if(is_array($node->descriptionElements) && count($node->descriptionElements) > 0 || count($node->children) > 0){
19

  
20
    if(hasFeatureNodeDescriptionElements($node)){
21 21

  
22 22
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
23 23
      // HACK to implement images for taxa, should be removed
......
95 95

  
96 96
  foreach($mergedFeatureNodes as $node){
97 97

  
98

  
99
    // process $descriptionElements with content only
100
    if(is_array($node->descriptionElements) && count($node->descriptionElements) > 0 || count($node->children) > 0){
98
    if(hasFeatureNodeDescriptionElements($node)) {
101 99

  
102 100
      $featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
103 101
      $block->module = 'cdm_dataportal';
......
206 204
        $block->content .= theme('cdm_footnotes', $node->feature->uuid);
207 205
        $block->content .= theme('cdm_annotation_footnotes', $node->feature->uuid);
208 206

  
209
        // set anchor; FIXME put anchor in $block->subject
210
        $out .= '<a name="'.$block->delta.'"></a>';
211
        $out .= theme('block', $block);
207
        // add anchor to subject
208
        $block->subject = '<a name="'.$block->delta.'"></a>'.  $block->subject;
212 209

  
210
        $out .= theme('block', $block);
213 211
      }
214 212
    }
215 213

  

Also available in: Unified diff