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/cdm_dataportal.module
1721 1721
  if (!$taxon_in_current_classification) {
1722 1722
    $classifications = get_classifications_for_taxon($taxon);
1723 1723
    RenderHints::pushToRenderStack('not_in_current_classification');
1724
    RenderHints::setFootnoteListKey('not_in_current_classification');
1725
    FootnoteManager::blockFootnotesFor('not_in_current_classification');
1724 1726
    $taxon_name_markup = render_taxon_or_name($taxon);
1727
    FootnoteManager::unblockFootnotesFor('not_in_current_classification');
1728
    RenderHints::clearFootnoteListKey();
1725 1729

  
1726 1730
    if (count($classifications) == 0) {
1727 1731
      drupal_set_message(t('This concept of the taxon !taxonname is not contained as an accepted taxon in the currently chosen classification.',
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
   */
modules/cdm_dataportal/includes/footnotes.inc
273 273

  
274 274

  
275 275
/**
276
 * Creates markup for the name relationship and creates a footnote in the
277
 * {@link \FootnoteManager}. The resulting foonote key is returned as markup.
276
 * Creates footnote markup for the name relationship and
277
 * registers it in the {@link \FootnoteManager}. The resulting foonote
278
 * key is returned as markup.
278 279
 *
279 280
 * @param $name_rel
280 281
 *   The cdm name relationship
281 282
 * @return string
282
 *  The makrup for the footnote key
283
 *  The markup for the footnote key
283 284
 */
284 285
function handle_name_relationship_as_footnote($name_rel)
285 286
{
......
302 303
}
303 304

  
304 305
/**
306
 * Creates footnote markup for nomenclatural status and
307
 * registers it in the {@link \FootnoteManager}. The resulting foonote
308
 * key is returned as markup.
309
 *
305 310
 * @param $nom_status
306 311
 * @return string
312
 *  The markup for the footnote key
307 313
 */
308
function nomenclatural_status_footnote_markup($nom_status)
314
function handle_nomenclatural_status_as_footnote($nom_status)
309 315
{
310 316
  // NomenclaturalStatus is a subclass of ReferencedEntityBase
311 317
  // and has the same structure as TaxonNameRelationship
......
313 319
}
314 320

  
315 321
/**
322
 * Creates footnote markup for nomenclatural reference of the name and
323
 * registers it in the {@link \FootnoteManager}. The resulting foonote
324
 * key is returned as markup.
325
 *
316 326
 * @param $name
327
 * The name whose nomenclatural reference is to be shown as footnote
317 328
 * @return string
329
 *  The markup for the footnote key
318 330
 */
319
function nomenclatural_reference_footnote_key_markup($name)
331
function handle_nomenclatural_reference_as_footnote($name)
320 332
{
321 333
  $footnote_markup = '';
322 334
  $footnote_key_markup = '';
modules/cdm_dataportal/includes/name.inc
474 474
        foreach ($nom_status_tagged_text as &$tt){
475 475
         if($tt->type == 'nomStatus'&& isset($tt->entityReference)) {
476 476
           $nom_status = cdm_ws_get(CDM_WS_NOMENCLATURALSTATUS, array($tt->entityReference->uuid));
477
           $nom_status_fkey = nomenclatural_status_footnote_markup($nom_status);
477
           $nom_status_fkey = handle_nomenclatural_status_as_footnote($nom_status);
478 478
           $tt->text .= $nom_status_fkey;
479 479
           $tt_to_markup_options['html'] = true;
480 480
         }
......
1551 1551
        $is_inverse_relation = $current_name_uuid == $name_rel->toName->uuid;
1552 1552
        $rel_footnote_key_markup = handle_name_relationship_as_footnote($name_rel);
1553 1553
        $relationship_markup = name_relationship_markup($name_rel, $current_name_uuid, $current_taxon_uuid, TRUE);
1554
        $nomref_footnote_key_markup = nomenclatural_reference_footnote_key_markup($name_rel->toName);
1554
        $nomref_footnote_key_markup = handle_nomenclatural_reference_as_footnote($name_rel->toName);
1555 1555
        $label = cdm_relationship_type_term_abbreviated_label($name_rel->type, $is_inverse_relation);
1556 1556
        $symbol = cdm_relationship_type_term_symbol($name_rel->type, $is_inverse_relation);
1557 1557
        $symbol_markup = '<span class="symbol" title="' . $label . '">' . $symbol . '</span>' . $rel_footnote_key_markup .  ' ';

Also available in: Unified diff