Project

General

Profile

« Previous | Next » 

Revision 2fc5c836

Added by Andreas Kohlbecker almost 4 years ago

cleaning up and renaming entitiy annotation footnote key methods

View differences:

modules/cdm_dataportal/cdm_dataportal.module
2794 2794
 * @see cdm_fetch_visible_annotations()
2795 2795
 *
2796 2796
 * @param array $cdm_entities
2797
 *   An array of CdmBase instances or a single instance.
2797
 *   An array of CdmBase instances.
2798 2798
 * @param $footnote_list_key_suggestion string
2799 2799
 *    optional parameter. If this parameter is left empty (null, 0, "") the footnote key will be determined be set to
2800 2800
 *    RenderHints::getFootnoteListKey().'-annotations' otherwise the supplied key will be used.
2801 2801
 *
2802 2802
 * @return array of footnote keys
2803 2803
 */
2804
function cdm_annotations_as_footnotekeys(array $cdm_entities, $footnote_list_key_suggestion = NULL) {
2804
function cdm_entities_annotations_as_footnotekeys(array $cdm_entities, $footnote_list_key_suggestion = NULL) {
2805 2805

  
2806
  $foot_note_keys = array();
2807

  
2808
  // Is argument cdmBase an array?
2809
  if (!is_array($cdm_entities)) {
2810
    $enties = array();
2811
    $enties[] = $cdm_entities;
2812
  }
2813
  else {
2814
    $enties = $cdm_entities;
2815
  }
2816

  
2817
  // Getting the key for the footnotemanager.
2818
  if (isset($footnote_list_key_suggestion)) {
2819
    $footnote_list_key = $footnote_list_key_suggestion;
2820
  }
2821
  else {
2822
    $footnote_list_key = RenderHints::getFootnoteListKey() . '-annotations';
2823
  }
2824

  
2825
  // Adding the footnotes keys.
2826
  foreach ($enties as $cdm_entity) {
2827
    $annotations = cdm_fetch_visible_annotations($cdm_entity);
2828
    if (is_array($annotations)) {
2829
      foreach ($annotations as $annotation) {
2830
        $foot_note_keys[] = FootnoteManager::addNewFootnote($footnote_list_key, $annotation->text);
2831
      }
2832
    }
2806
  $foot_note_keys = [];
2807
  foreach ($cdm_entities as $cdm_entity) {
2808
        $foot_note_keys[] = array_merge($foot_note_keys, cdm_entity_annotations_as_footnotekeys($cdm_entity,$footnote_list_key_suggestion));
2833 2809
  }
2834 2810

  
2835 2811
  return $foot_note_keys;
2836 2812
}
2837 2813

  
2838 2814
/**
2839
 * Fetches the list of visible annotations for each of the cdm entities and returns the footnote keys for them.
2815
 * Fetches the list of visible annotations for the cdm entity or for the comparable
2816
 * object and returns the footnote keys.
2840 2817
 *
2841
 * The footnotes are passed to the FootnoteManager in order to store the annotations and to create the footnote keys.
2842
 *
2843
 * @see cdm_fetch_visible_annotations()
2844
 *
2845
 * @param array $cdm_entities
2846
 *   An array of CdmBase instances or a single instance.
2818
 * The footnotes are passed to the FootnoteManager in order to store the
2819
 * annotations and to create the footnote keys.
2820

  
2821
 * @param object $cdm_entity
2822
 *   A single CdmBase instance ore comparable object.
2847 2823
 * @param $footnote_list_key_suggestion string
2848 2824
 *    optional parameter. If this parameter is left empty (null, 0, "") the footnote key will be determined be set to
2849 2825
 *    RenderHints::getFootnoteListKey().'-annotations' otherwise the supplied key will be used.
2850
 *
2851 2826
 * @return array of footnote keys
2827
 *
2828
 * @see cdm_fetch_visible_annotations()
2852 2829
 */
2853
function cdm_entity_annotations_as_footnotekeys($cdm_entity, $footnote_list_key_suggestion = NULL) {
2830
function cdm_entity_annotations_as_footnotekeys(object $cdm_entity, $footnote_list_key_suggestion = NULL) {
2854 2831

  
2855 2832
  $foot_note_keys = array();
2856 2833

  
modules/cdm_dataportal/includes/descriptions.inc
345 345
 * @param $footnote_list_key_suggestion string
346 346
 *    Optional parameter. If this parameter is left empty (null, 0, "") the footnote key will be determined by the nested
347 347
 *    method calls by calling RenderHints::getFootnoteListKey(). NOTE: the footnote key for annotations will be set to
348
 *    RenderHints::getFootnoteListKey().'-annotations'. @see cdm_annotations_as_footnotekeys()
348
 *    RenderHints::getFootnoteListKey().'-annotations'. @return String
349
 *   The foot note keys
350
 *
351
 * @see cdm_entities_annotations_as_footnotekeys()
349 352
 *    For original sources the $footnote_list_key_suggestion will be overwritten by bibliography_footnote_list_key() when
350 353
 *    $is_bibliography_aware is set TRUE.
351 354
 * @$original_source_footnote_tag
352 355
 *    null will cause bibliography_footnote_list_key to use the default
353 356
 *
354
 * @return String
355
 *   The foot note keys
356 357
 */
357 358
function cdm_create_footnotes(
358 359
    $description_element,
......
543 544
   * @param $footnote_list_key_suggestion string
544 545
   *    optional parameter. If this paramter is left empty (null, 0, "") the footnote key will be determined by the nested
545 546
   *    method calls by calling RenderHints::getFootnoteListKey(). NOTE: the footnore key for annotations will be set to
546
   *    RenderHints::getFootnoteListKey().'-annotations'. @see cdm_annotations_as_footnotekeys()
547
   *
548
   * @return array
547
   *    RenderHints::getFootnoteListKey().'-annotations'. @return array
549 548
   *   an associative array with the following elements:
550 549
   *   - foot_note_keys: all footnote keys as markup
551 550
   *   - source_references: an array of the source references citations
552 551
   *   - names used in source: an associative array of the names in source,
553 552
   *        the name in source strings are de-duplicated
554 553
   *        !!!NOTE!!!!: this field will most probably be removed soon (TODO)
554
   *
555
   *@see cdm_entities_annotations_as_footnotekeys()
556
   *
555 557
   */
556 558
  function handle_annotations_and_sources($entity, $config, $inline_text_prefix, $footnote_list_key_suggestion) {
557 559

  
......
595 597
      } // END of loop over sources
596 598

  
597 599
    // annotations footnotes separate.
598
    $annotations_and_sources['foot_note_keys'] = theme('cdm_annotations_as_footnotekeys',
600
    $annotations_and_sources['foot_note_keys'] = theme('cdm_entities_annotations_as_footnotekeys',
599 601
      array(
600 602
        'cdmBase_list' => $entity,
601 603
        'footnote_list_key' => $footnote_list_key_suggestion,
......
1799 1801
    );
1800 1802

  
1801 1803

  
1802
    list($status_label, $status_markup) = distribution_status_label_and_markup($description_element);
1804
    [$status_label, $status_markup] = distribution_status_label_and_markup($description_element);
1803 1805

  
1804 1806
    $out = '';
1805 1807
    $out .= '<' . $enclosingTag . ' class="descriptionElement descriptionElement-' . $description_element->uuid
......
2029 2031
          UUID_DISTRIBUTION
2030 2032
        );
2031 2033

  
2032
        list($status_label, $status_markup) = distribution_status_label_and_markup($distribution, $level_style['status_glue']);
2034
        [$status_label, $status_markup] = distribution_status_label_and_markup($distribution, $level_style['status_glue']);
2033 2035
      }
2034 2036

  
2035 2037
      $per_node_markup[$node_index] .= '<' . $enclosingTag . ' class="descriptionElement'
modules/cdm_dataportal/includes/name.inc
580 580
  }
581 581
  $out .= '</span>';
582 582
  if ($show_annotations) {
583
    // $out .= theme('cdm_annotations_as_footnotekeys', $taxonName);
583
    // $out .= theme('cdm_entities_annotations_as_footnotekeys', $taxonName);
584 584
  }
585 585
  return $out;
586 586
}
modules/cdm_dataportal/includes/pages.inc
722 722
    $special_annotations_array = array();
723 723
    $special_annotations_array[] = $taxon->name;
724 724
    $special_annotations_array[] = $taxon;
725
    $accepted_name .= theme('cdm_annotations_as_footnotekeys', array(
725
    $accepted_name .= theme('cdm_entities_annotations_as_footnotekeys', array(
726 726
        'cdmBase_list' => $special_annotations_array,
727 727
        'footnote_list_key' => $synonymy_render_path . '-annotations')
728 728
    );
modules/cdm_dataportal/includes/taxon.inc
393 393
    $referenceUri = FALSE;
394 394
  }
395 395
  $out_taxon_part = render_taxon_or_name($taxon, $taxonUri, $referenceUri, TRUE, FALSE, $skip_tags, $is_invalid);
396
  $taxon_footnotes = theme('cdm_annotations_as_footnotekeys',
396
  $taxon_footnotes = theme('cdm_entities_annotations_as_footnotekeys',
397 397
    array('cdmBase_list' => array(
398 398
      $taxon->name,
399 399
      $taxon,
......
443 443
      $referenceUri = url(path_to_reference($synonym->name->nomenclaturalReference->uuid));
444 444
    }
445 445
    $out .= render_taxon_or_name($synonym->name, NULL, $referenceUri);
446
    $out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $synonym));
446
    $out .= theme('cdm_entities_annotations_as_footnotekeys', array('cdmBase_list' => $synonym));
447 447
    $out .= '</span>';
448 448
  }
449 449
  RenderHints::popFromRenderStack();
......
574 574
            }
575 575
            $out .= '<span class="classifications"><span class="separator"> : </span>' . implode(', ', $classification_titles) . '</span>';
576 576
          }
577
          $out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
577
          $out .= theme('cdm_entities_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
578 578
          if ($showMedia_synonyms) {
579 579
            $out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $acceptedTaxon));
580 580
          }
......
602 602
        }
603 603
        $out .= '<span class="classifications"><span class="separator"> : </span>' . implode(', ', $classification_titles) . '</span>';
604 604
      }
605
      $out .= theme('cdm_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
605
      $out .= theme('cdm_entities_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
606 606

  
607 607
      if ($showMedia_taxa) {
608 608
        $out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $taxon));
modules/cdm_dataportal/theme/cdm_dataportal.common.theme
163 163
  $out = '';
164 164
  if(is_array($cdm_entities)){
165 165
    // array of entities
166
    $footNoteKeys = cdm_annotations_as_footnotekeys($cdm_entities, $footnote_list_key);
166
    $footNoteKeys = cdm_entities_annotations_as_footnotekeys($cdm_entities, $footnote_list_key);
167 167
  } else {
168 168
    // single entity
169 169
    $footNoteKeys = cdm_entity_annotations_as_footnotekeys($cdm_entities, $footnote_list_key);
modules/cdm_dataportal/theme/theme_registry.inc
37 37
    'radio_options_suffix' => array('render element' => 'element'),
38 38

  
39 39
    // Themes in cdm_dataportal.common.theme.
40
    'cdm_annotations_as_footnotekeys' => array('variables' => array('cdmBase_list' => NULL, 'footnote_list_key' => NULL)),
40
    'cdm_entities_annotations_as_footnotekeys' => array('variables' => array('cdmBase_list' => NULL, 'footnote_list_key' => NULL)),
41 41
    'cdm_annotation_footnotes' => array('variables' => array('footnoteListKey' => NULL, 'enclosingTag' => 'span')),
42 42
    'cdm_annotation_content' => array('variables' => array('AnnotationTO' => NULL)),
43 43
    'cdm_list_of_annotations' => array('variables' => array('annotationElements' => NULL)),

Also available in: Unified diff