Project

General

Profile

« Previous | Next » 

Revision 9f9fe101

Added by Andreas Kohlbecker over 3 years ago

ref #8543 refactoring: renaming variables & moving functions to other files

View differences:

modules/cdm_dataportal/includes/footnotes.inc
20 20
 * Creates the footnotes for the given CDM instance.
21 21
 *
22 22
 * Footnotes are created for annotations and original sources whereas the resulting footnote keys depend on the
23
 * parameters $footnote_list_key_suggestion and $is_bibliography_aware, see parameter $footnote_list_key_suggestion
23
 * parameters $footnote_list_key and $is_bibliography_aware, see parameter $footnote_list_key
24 24
 * for more details.
25 25
 *
26 26
 * possible keys for annotation and source footnotes:
27
 *       - $footnote_list_key_suggestion
27
 *       - $footnote_list_key
28 28
 *       - RenderHints::getFootnoteListKey()
29 29
 *     - original source footnotes
30 30
 *       - "BIBLIOGRAPHY" (when !$is_bibliography_aware && bibliography_settings['enabled'] == 1 )
31
 *       - "BIBLIOGRAPHY-$footnote_list_key_suggestion" (when !$is_bibliography_aware && bibliography_settings['enabled'] == 0 )
32
 *       - $footnote_list_key_suggestion (when $is_bibliography_aware)
31
 *       - "BIBLIOGRAPHY-$footnote_list_key" (when !$is_bibliography_aware && bibliography_settings['enabled'] == 0 )
32
 *       - $footnote_list_key (when $is_bibliography_aware)
33 33
 *
34 34
 * @param $cdm_entity
35 35
 *   A CDM entity
36 36
 * @param string $separator
37 37
 *   Optional parameter. The separator string to concatenate the footnote ids, default is ','
38
 * @param $footnote_list_key_suggestion string
38
 * @param $footnote_list_key string
39 39
 *    Optional parameter. If this parameter is left empty (null, 0, "") the footnote key will be determined by the nested
40 40
 *    method calls by calling RenderHints::getFootnoteListKey().
41
 *    For original sources the $footnote_list_key_suggestion will be overwritten by bibliography_footnote_list_key() when
41
 *    For original sources the $footnote_list_key will be overwritten by bibliography_footnote_list_key() when
42 42
 *    $is_bibliography_aware is set TRUE.
43 43
 * @param bool $do_link_to_reference
44 44
 *    Create a link to the reference pages for sources when TRUE.
......
46 46
 *    Create a link to the name pages for name in source when TRUE.
47 47
 * @param bool $is_bibliography_aware
48 48
 *    Put source references into the bibliography when this param is TRUE.
49
 *    For original sources the $footnote_list_key_suggestion will be overwritten
49
 *    For original sources the $footnote_list_key will be overwritten
50 50
 *    by bibliography_footnote_list_key() when
51 51
 *    $is_bibliography_aware is set TRUE.
52 52
 * @return String
......
57 57
function render_entity_footnotes(
58 58
  $cdm_entity,
59 59
  $separator = ',',
60
  $footnote_list_key_suggestion = null,
60
  $footnote_list_key = null,
61 61
  $do_link_to_reference = FALSE,
62 62
  $do_link_to_name_used_in_source = FALSE,
63 63
  $is_bibliography_aware = FALSE
......
65 65

  
66 66
  $sources = cdm_entity_sources_sorted($cdm_entity);
67 67

  
68
  if (!isset($footnote_list_key_suggestion) || !$footnote_list_key_suggestion) {
69
    $footnote_list_key_suggestion = RenderHints::getFootnoteListKey();
68
  if (!isset($footnote_list_key) || !$footnote_list_key) {
69
    $footnote_list_key = RenderHints::getFootnoteListKey();
70 70
  }
71 71

  
72 72
  // Annotations as footnotes.
73
  $footnote_keys = cdm_entity_annotations_as_footnote_keys($cdm_entity, $footnote_list_key_suggestion);
73
  $footnote_keys = cdm_entity_annotations_as_footnote_keys($cdm_entity, $footnote_list_key);
74 74

  
75 75
  // Source references as footnotes.
76 76
  if($is_bibliography_aware){
77 77
    $bibliography_settings = get_bibliography_settings();
78
    $sources_footnote_list_key = bibliography_footnote_list_key($footnote_list_key_suggestion);
78
    $sources_footnote_list_key = bibliography_footnote_list_key($footnote_list_key);
79 79
    $original_source_footnote_tag = $bibliography_settings['enabled'] == 1 ? 'div' : null; // null will cause bibliography_footnote_list_key to use the default
80 80
  } else {
81
    $sources_footnote_list_key = $footnote_list_key_suggestion;
81
    $sources_footnote_list_key = $footnote_list_key;
82 82
    $original_source_footnote_tag = NULL;
83 83
  }
84 84

  
......
238 238
  return $out;
239 239
}
240 240

  
241
/**
242
 * This method determines the footnote key for original sources to be shown in the bibliography block
243
 *
244
 * The footnote key depends on the value of the 'enabled' value of the bibliography_settings
245
 *    - enabled == 1 -> "BIBLIOGRAPHY"
246
 *    - enabled == 0 -> "BIBLIOGRAPHY-$key_suggestion"
247
 *
248
 * @see get_bibliography_settings() and @see constant BIBLIOGRAPHY_FOOTNOTE_KEY
249
 *
250
 * @param $key_suggestion string
251
 *    optional parameter. If this parameter is left empty (null, 0, "") the footnote key will be retrieved by
252
 *    calling RenderHints::getFootnoteListKey().
253

  
254
 *
255
 * @return string
256
 *  the footnote_list_key
257
 */
258
function bibliography_footnote_list_key($key_suggestion = null) {
259
  if(!$key_suggestion){
260
    $key_suggestion = RenderHints::getFootnoteListKey();
261
  }
262
  $bibliography_settings = get_bibliography_settings();
263
  $footnote_list_key = $bibliography_settings['enabled'] == 1 ? BIBLIOGRAPHY_FOOTNOTE_KEY : BIBLIOGRAPHY_FOOTNOTE_KEY . '-' . $key_suggestion;
264
  return $footnote_list_key;
265
}
266

  
267

  

Also available in: Unified diff