Project

General

Profile

« Previous | Next » 

Revision 15b7c460

Added by Andreas Kohlbecker about 11 years ago

Foonotes and typedesignations of the accepted taxon will also and only be rendered in the homotypic synonymy group even if the group is empty

View differences:

7.x/modules/cdm_dataportal/theme/cdm_dataportal.name.theme
45 45
    $res .= ($year ? ' ' . $year : '');
46 46
    $res .= ($pages ? ': ' . $pages : '');
47 47
    // $res .= ')';
48
    $fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getRenderPath(), $typeDesignation->citation->titleCache);
48

  
49
    // footnotes should be rendered in the parent element so we
50
    // are relying on the FootnoteListKey set there
51
    $fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $typeDesignation->citation->titleCache);
49 52
    $res .= theme('cdm_footnote_key', array(
50 53
      'footnoteKey' => $fkey_typeDesignation,
51 54
      'separator' => $footnote_separator,
......
57 60
}
58 61

  
59 62
/**
60
 * @todo Please document this function.
61
 * @see http://drupal.org/node/1354
63
 * Searches the $collection for the cdm entitiy given as $element.
64
 *
65
 * The elements are compared by their UUID.
66
 *
67
 * @param $element
68
 *  the CDM entitiy to search for
69
 * @param $collection
70
 *  the list of CDM entities to search in
71
 *
72
 * @return boolean TRUE if the $collection contains the $element, otheriwse FALSE
73
 *
74
 * TODO move into module file
62 75
 */
63
function contains_type_designation($element, $collection) {
76
function contains_cdm_entitiy($element, $collection) {
64 77
  $result = FALSE;
65 78
  foreach ($collection as $a) {
66 79
    if ($a->uuid == $element->uuid) {
......
71 84
}
72 85

  
73 86
/**
74
 * @todo Please document this function.
75
 * @see http://drupal.org/node/1354
87
 * Fiters the array $entity_list of CDM entities by the list
88
 * of $excludes. Any element contained in the $excludes will be removed
89
 * from included int the retuned list.
90
 *
91
 * If the $entity_list is not an array the $excludes will be returned.
76 92
 */
77
function cdm_add_type_designations($source, $extra) {
78
  if (is_array($source)) {
79
    $result = $source;
80
    if ($extra) {
81
      foreach ($extra as $element) {
82
        if (!contains_type_designation($element, $source)) {
83
          $result[] = $element;
93
function filter_cdm_entity_list($entity_list, $excludes) {
94
  if (is_array($entity_list)) {
95
    $result = $entity_list;
96
    if ($excludes) {
97
      foreach ($excludes as $exclude) {
98
        if (!contains_cdm_entitiy($exclude, $entity_list)) {
99
          $result[] = $exclude;
84 100
        }
85 101
      }
86 102
    }
87 103
  }
88 104
  else {
89
    $result = $extra;
105
    $result = $excludes;
90 106
  }
91

  
92 107
  return $result;
93 108
}
94 109

  
......
104 119
  // need to add element to render path since type designations
105 120
  // need other name render template
106 121
  RenderHints::pushToRenderStack('typedesignations');
122

  
107 123
  $out = '<ul class="typeDesignations">';
108 124
  $typeDesignation_footnotes = FALSE;
109 125
  $is_lectotype = FALSE;
......
171 187
        }
172 188
        $typeReference .= ')';
173 189

  
174
        $_fkey2 = FootnoteManager::addNewFootnote(RenderHints::getRenderPath(), $std->citation->titleCache);
190
        // footnotes should be rendered in the parent element so we
191
        // are relying on the FootnoteListKey set there
192
        $_fkey2 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $std->citation->titleCache);
175 193
        $typeReference .= theme('cdm_footnote_key', array(
176 194
          'footnoteKey' => $_fkey2,
177 195
          'separator' => $separator,
......
197 215
      }
198 216

  
199 217
      // Footnotes for collection acronyms.
218
      // footnotes should be rendered in the parent element so we
219
      // are relying on the FootnoteListKey set there
200 220
      $_fkey = FootnoteManager::addNewFootnote(
201
          RenderHints::getRenderPath(),
221
          RenderHints::getFootnoteListKey(),
202 222
          (isset($derivedUnitFacadeInstance->collection->titleCache) ? $derivedUnitFacadeInstance->collection->titleCache : FALSE)
203 223
        );
204 224
      $out .= theme('cdm_footnote_key', array('footnoteKey' => $_fkey, 'separator' => $separator));
......
352 372

  
353 373
  // ------- footnotes ------- //
354 374
  $out .= '<ul class="footnotes">';
355
  $out .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $footnoteListKey, 'enclosingTag' => 'li'));
375
  $out .= theme('cdm_annotation_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'li'));
376
  $out .= theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'li'));
356 377
  $out .= '</ul>';
357 378

  
358 379
  $out .= '</div>';
......
362 383
}
363 384

  
364 385
/**
365
 * @todo Please document this function.
366
 * @see http://drupal.org/node/1354
386
 * Renders the homotypic synonymy group for the accepted taxon in the synonymy.
387
 *
388
 * Foonotes of the accepted taxon will also be rendered here in the
389
 * homotypic synonymy group even if the synonymList or prependedSynonyms are
390
 * empty. Therefore  the homotypic group and accepted taxon share the  same
391
 * footnote key.
392
 *
393
 * @param $variables
394
 *   an associative array:
395
 *   - synonymList: the list of cdm Synonym entities
396
 *   - accepted_taxon_uuid: the uuid of the accepted taxon
397
 *   - prependedSynonyms: further synonyms which should be prepended
398
 *      before the actual list of synonyms
367 399
 */
368 400
function theme_cdm_homotypicSynonymyGroup($variables) {
369 401
  $synonymList = $variables['synonymList'];
370 402
  $accepted_taxon_uuid = $variables['accepted_taxon_uuid'];
371 403
  $prependedSynonyms = $variables['prependedSynonyms'];
404

  
372 405
  RenderHints::pushToRenderStack('homotypicSynonymyGroup');
373 406

  
374
  $footnoteListKey = isset($prependedSynonyms[0]) ? $prependedSynonyms[0]->uuid : (isset($synonymList[0]) ? $synonymList[0]->uuid : 'NULL');
375
  $accepted_taxon_footnoteListKey = RenderHints::getFootnoteListKey();
376
  RenderHints::setFootnoteListKey($footnoteListKey);
407
  $homonym_typeDesignations = NULL;
377 408

  
378
  if (!is_array($synonymList) || count($synonymList) == 0) {
379
    return;
380
  }
409
// no new $footnoteListKey since homotypic group and accepted taxon should share the same key!
410
//   $footnoteListKey = isset($prependedSynonyms[0]) ? $prependedSynonyms[0]->uuid : (isset($synonymList[0]) ? $synonymList[0]->uuid : 'NULL');
411
//   // store the FootnoteListKey from the parent element which is the accepted taxon
412
//   $accepted_taxon_footnoteListKey = RenderHints::getFootnoteListKey();
413
//   // new FootnoteListKey for this homotypicSynonymyGroup
414
//   RenderHints::setFootnoteListKey($footnoteListKey);
381 415

  
382
  $out = '<div class="homotypic-synonymy-group"><ul class="homotypicSynonyms">';
416
  // TODO improve typeDesignations retrieval: wouldn't it be suffcient to retrieve all typeDesignations
417
  // only from the accepted taxon?
418
  $accepted_typeDesignations = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMETYPEDESIGNATIONS, $accepted_taxon_uuid);
383 419

  
384
  if (!empty($prependedSynonyms)) {
385
    foreach ($prependedSynonyms as $taxon) {
386
      $out .= '<li class="synonym">' . cdm_related_taxon($taxon, UUID_HOMOTYPIC_SYNONYM_OF) . '</li>';
387
    }
388
  }
420
  $out = '<div class="homotypic-synonymy-group">';
421

  
422
  if (isset ($accepted_typeDesignations) || is_array($prependedSynonyms) || is_array($synonymList)) {
423
  	$out .= '<ul class="homotypicSynonyms">';
424
	if (!empty($prependedSynonyms)) {
425
	  foreach ($prependedSynonyms as $taxon) {
426
	    $out .= '<li class="synonym">' . cdm_related_taxon($taxon, UUID_HOMOTYPIC_SYNONYM_OF) . '</li>';
427
	  }
428
	}
429

  
430
	$homonym_typeDesignations = NULL;
431
	if (isset($synonymList[0])) {
432
		foreach ($synonymList as $synonym) {
433
			$out .= '<li class="synonym">' . cdm_related_taxon($synonym, UUID_HOMOTYPIC_SYNONYM_OF) . '</li>';
434
		}
435
		$homonym_typeDesignations = cdm_ws_get(CDM_WS_PORTAL_NAME_TYPEDESIGNATIONS, $synonymList[0]->name->uuid);
436
	}
437

  
438
	// type designations
439
	if ($accepted_typeDesignations) {
440
	  $type_designations = filter_cdm_entity_list($homonym_typeDesignations, $accepted_typeDesignations);
441
	}
442
	else {
443
	  $type_designations = $homonym_typeDesignations;
444
	}
445
	if ($type_designations) {
446
	  $out .= theme('cdm_typedesignations', array('typeDesignations' => $type_designations));
447
	}
389 448

  
390
  foreach ($synonymList as $synonym) {
391
    $out .= '<li class="synonym">' . cdm_related_taxon($synonym, UUID_HOMOTYPIC_SYNONYM_OF) . '</li>';
392 449
  }
393 450

  
394
  $homonym_typeDesignations = cdm_ws_get(CDM_WS_PORTAL_NAME_TYPEDESIGNATIONS, $synonymList[0]->name->uuid);
395
  $accepted_typeDesignations = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMETYPEDESIGNATIONS, $accepted_taxon_uuid);
396
  if ($accepted_typeDesignations) {
397
    $typeDesignations = cdm_add_type_designations($homonym_typeDesignations, $accepted_typeDesignations);
398
  }
399
  else {
400
    $typeDesignations = $homonym_typeDesignations;
401
  }
402
  if ($typeDesignations) {
403
    $out .= theme('cdm_typedesignations', array('typeDesignations' => $typeDesignations));
404
  }
405 451
  $out .= '</ul>';
406 452

  
407 453
  // ------- footnotes ------- //
454

  
455
  // all foonotes of the homotypic group and also of the accepted taxon are
456
  // rendered here, both should have the same footnote key
408 457
  $out .= '<ul class="footnotes">';
409
  // To avoiding drupal warnings (#1830).
410
  if ($accepted_taxon_footnoteListKey) {
411
    // Why FALSE???
412
    $out .= theme('cdm_footnotes', array('footnoteListKey' => $accepted_taxon_footnoteListKey, 'enclosingTag' => 'li'));
413
  }
414
  $out .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $footnoteListKey, 'enclosingTag' => 'li'));
415
  $out .= theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getRenderPath(), 'enclosingTag' => 'li'));
458
  $out .= theme('cdm_annotation_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'li'));
459
  $out .= theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey(), 'enclosingTag' => 'li'));
416 460
  $out .= '</ul>';
417 461

  
418 462
  $out .= '</div>';

Also available in: Unified diff