Project

General

Profile

« Previous | Next » 

Revision 8202a2c0

Added by Andreas Kohlbecker almost 4 years ago

ref #8543 option to block footnote list key to avoid foonote keys in odd places like warnings

View differences:

modules/cdm_dataportal/classes/footnotemanager.php
21 21
 * the RenderHints class by calling @see RenderHints::setFootnoteListKey($footnoteListKey)
22 22
 */
23 23
class FootnoteManager {
24
  private static $fnstore = array();
25
  //private static $footnote_key_index = 1;
24
  private static $fnstore = [];
25
  private static $blockedFootnoteLitsKeys = [];
26 26
  /*
27 27
   * An associative array holding information on
28 28
   * special footnote sets which are to be handle separately
......
84 84
   * @param string $separator
85 85
   *
86 86
   * @return string
87
   *   The rendered footnotelist.
87
   *   The rendered footnotelist or an empty string if the $footnoteListKey is
88
   *   blocked
88 89
   */
89 90
  public static function renderFootnoteList($footnoteListKey, $separator = ', ') {
91

  
92
    if(self::isBlockedFootnoteListKey($footnoteListKey)){
93
      // the footnote key is blocked, don't render it!
94
      return '';
95
    }
90 96
    $out = '';
91 97
    if (array_key_exists($footnoteListKey, self::$fnstore)) {
92 98
      foreach (self::$fnstore[$footnoteListKey] as $fn) {
......
102 108
   *
103 109
   * @param $footnoteListKey
104 110
   * @param $object
105
   * @param $theme
106
   * @param $themeArguments
107 111
   *
108 112
   * @return FootnoteKey
109 113
   */
110
  public static function addNewFootnote($footnoteListKey, $object = NULL, $enclosing_tag = null) {
111
    if (!$object || !$footnoteListKey) {
114
  public static function addNewFootnote($footnoteListKey, $object = NULL) {
115
    if (!$object || !$footnoteListKey || self::isBlockedFootnoteListKey($footnoteListKey)) {
112 116
      return null;
113 117
    }
114 118
    if (!array_key_exists($footnoteListKey, self::$fnstore)) {
......
214 218
    return self::$default_set_definition;
215 219
  }
216 220

  
221
  public static function blockFootnotesFor($footnoteListKey) {
222
    if(array_search($footnoteListKey, self::$blockedFootnoteLitsKeys) === false){
223
      self::$blockedFootnoteLitsKeys[] = $footnoteListKey;
224
    }
225
  }
226
  public static function unblockFootnotesFor($footnoteListKey) {
227
    $index = array_search($footnoteListKey, self::$blockedFootnoteLitsKeys);
228
    if($index !== false){
229
      unset(self::$blockedFootnoteLitsKeys[$index]);
230
    }
231
  }
232

  
233
  /**
234
   * @param $footnoteListKey
235
   *
236
   * @return bool
237
   */
238
  public static function isBlockedFootnoteListKey($footnoteListKey) {
239
    return array_search($footnoteListKey, self::$blockedFootnoteLitsKeys) !== false;
240
  }
241

  
217 242
  /**
218 243
   * Stop users from cloning.
219 244
   */

Also available in: Unified diff