Project

General

Profile

« Previous | Next » 

Revision dd0767b6

Added by Andreas Kohlbecker over 3 years ago

ref #8543 moving footnote functions to separate inc file

View differences:

modules/cdm_dataportal/cdm_dataportal.module
23 23
  module_load_include('php', 'cdm_dataportal', 'cdm_dataportal.search');
24 24

  
25 25
  module_load_include('inc', 'cdm_dataportal', 'includes/common');
26
  module_load_include('inc', 'cdm_dataportal', 'includes/footnotes');
26 27
  module_load_include('inc', 'cdm_dataportal', 'includes/agent');
27 28
  module_load_include('inc', 'cdm_dataportal', 'includes/name');
28 29
  module_load_include('inc', 'cdm_dataportal', 'includes/taxon');
......
2786 2787
  return $outArrayOfMedia;
2787 2788
}
2788 2789

  
2789
/**
2790
 * Fetches the list of visible annotations for each of the cdm entities and returns the footnote keys for them.
2791
 *
2792
 * The footnotes are passed to the FootnoteManager in order to store the annotations and to create the footnote keys.
2793
 *
2794
 * @see cdm_fetch_visible_annotations()
2795
 *
2796
 * @param array $cdm_entities
2797
 *   An array of CdmBase instances.
2798
 * @param $footnote_list_key_suggestion string
2799
 *    optional parameter. If this parameter is left empty (null, 0, "") the footnote key will be determined be set to
2800
 *    RenderHints::getFootnoteListKey().'-annotations' otherwise the supplied key will be used.
2801
 *
2802
 * @return array of footnote keys
2803
 */
2804
function cdm_entities_annotations_footnotekeys(array $cdm_entities, $footnote_list_key_suggestion = NULL) {
2805

  
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));
2809
  }
2810

  
2811
  return $foot_note_keys;
2812
}
2813

  
2814
/**
2815
 * Fetches the list of visible annotations for the cdm entity or for the comparable
2816
 * object and returns the footnote keys.
2817
 *
2818
 * The footnotes are passed to the FootnoteManager in order to store the
2819
 * annotations and to create the footnote keys.
2820

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

  
2832
  $foot_note_keys = [];
2833

  
2834
  // Getting the key for the footnotemanager.
2835
  if (isset($footnote_list_key_suggestion)) {
2836
    $footnote_list_key = $footnote_list_key_suggestion;
2837
  } else {
2838
    $footnote_list_key = RenderHints::getFootnoteListKey() . '-annotations';
2839
  }
2840

  
2841
  // Adding the footnotes keys.
2842
  $annotations = cdm_fetch_visible_annotations($cdm_entity);
2843
  if (is_array($annotations)) {
2844
    foreach ($annotations as $annotation) {
2845
      $foot_note_keys[] = FootnoteManager::addNewFootnote($footnote_list_key, $annotation->text);
2846
    }
2847
  }
2848 2790

  
2849
  return $foot_note_keys;
2850
}
2851 2791

  
2852 2792

  
2853 2793
/**

Also available in: Unified diff