Project

General

Profile

« Previous | Next » 

Revision d8069342

Added by Andreas Kohlbecker over 3 years ago

ref #8543 further harmonizing footnote functions

View differences:

modules/cdm_dataportal/classes/footnote.php
38 38
      $enclosing_tag = $this->enclosing_tag;
39 39
    }
40 40

  
41
    return footnote_markup($this->key, $this->object, $enclosing_tag);
41
    return render_footnote($this->key, $this->object, $enclosing_tag);
42 42
  }
43 43
}
modules/cdm_dataportal/includes/descriptions.inc
527 527
      } // END of loop over sources
528 528

  
529 529
      // annotations footnotes separate from sources
530
      $annotations_and_sources['foot_note_keys'] = footnote_keys_to_markup(
530
      $annotations_and_sources['foot_note_keys'] = render_footnote_keys(
531 531
        cdm_entity_annotations_as_footnote_keys($entity, $footnote_list_key_suggestion), ', '
532 532
      );
533 533

  
......
535 535

  
536 536
    // footnotes for sources and annotations or put into into bibliography if requested ...
537 537
    if ($config['add_footnote_keys'] == 1) {
538
        $annotations_and_sources['foot_note_keys'] = cdm_entity_footnotes(
538
        $annotations_and_sources['foot_note_keys'] = render_entity_footnotes(
539 539
          $entity, ',',
540 540
          $footnote_list_key_suggestion,
541 541
          $config['link_to_reference'] == 1,
......
736 736
            /*
737 737
             * Footnotes for the feature block
738 738
             */
739
            $block->content[] = markup_to_render_array(cdm_footnotes(PSEUDO_FEATURE_BIBLIOGRAPHY . '-' . $feature_node->term->uuid));
740
            $block->content[] = markup_to_render_array(cdm_footnotes($feature_node->term->uuid));
741
            $block->content[] = markup_to_render_array(cdm_annotation_footnotes($feature_node->term->uuid));
739
            $block->content[] = markup_to_render_array(render_footnotes(PSEUDO_FEATURE_BIBLIOGRAPHY . '-' . $feature_node->term->uuid));
740
            $block->content[] = markup_to_render_array(render_footnotes($feature_node->term->uuid));
741
            $block->content[] = markup_to_render_array(render_annotation_footnotes($feature_node->term->uuid));
742 742
          }
743 743
        } // END all other features
744 744

  
......
1035 1035
      );
1036 1036
    }
1037 1037

  
1038
    $block->content[] = markup_to_render_array(cdm_footnotes('BIBLIOGRAPHY-' . UUID_DISTRIBUTION));
1039
    $block->content[] = markup_to_render_array(cdm_footnotes(UUID_DISTRIBUTION));
1040
    $block->content[] = markup_to_render_array(cdm_annotation_footnotes(UUID_DISTRIBUTION));
1038
    $block->content[] = markup_to_render_array(render_footnotes('BIBLIOGRAPHY-' . UUID_DISTRIBUTION));
1039
    $block->content[] = markup_to_render_array(render_footnotes(UUID_DISTRIBUTION));
1040
    $block->content[] = markup_to_render_array(render_annotation_footnotes(UUID_DISTRIBUTION));
1041 1041

  
1042 1042
    return $block;
1043 1043
  }
......
1659 1659
    $text_data_out, $feature
1660 1660
  );
1661 1661

  
1662
  $footnotes = cdm_footnotes('BIBLIOGRAPHY-' . $footnote_key_suggestion);
1663
  $footnotes .= cdm_footnotes($footnote_key_suggestion); // FIXME is this needed at all?
1664
  $footnotes .= cdm_annotation_footnotes($footnote_key_suggestion);
1662
  $footnotes = render_footnotes('BIBLIOGRAPHY-' . $footnote_key_suggestion);
1663
  $footnotes .= render_footnotes($footnote_key_suggestion); // FIXME is this needed at all?
1664
  $footnotes .= render_annotation_footnotes($footnote_key_suggestion);
1665 1665

  
1666 1666
  return  markup_to_render_array(  // FIXME markup_to_render_array should no longer be needed
1667 1667
    '<div class="common-taxon-name">' . $common_name_out . '</div>'
modules/cdm_dataportal/includes/footnotes.inc
49 49
 *    Put source references into the bibliography when this param is TRUE.
50 50
 *
51 51
 * @return String
52
 *   The foot note keys
52
 *   The foot note keys as markup
53 53
 *
54 54
 * @throws \Exception re-throw exception from theme()
55 55
 * @see cdm_entities_annotations_footnote_keys()
......
58 58
 * @$original_source_footnote_tag
59 59
 *    null will cause bibliography_footnote_list_key to use the default
60 60
 */
61
function cdm_entity_footnotes(
61
function render_entity_footnotes(
62 62
  $cdm_entity,
63 63
  $separator = ',',
64 64
  $footnote_list_key_suggestion = null,
......
104 104
  }
105 105
  // Sort and render footnote keys.
106 106
  asort($footnote_keys);
107
  return footnote_keys_to_markup($footnote_keys, $separator);
107
  return render_footnote_keys($footnote_keys, $separator);
108 108
}
109 109

  
110 110
/**
......
152 152

  
153 153
  $foot_note_keys = [];
154 154

  
155
  // Getting the key for the footnotemanager.
155
  // Getting the key for the FootnoteManager.
156 156
  if (isset($footnote_list_key_suggestion)) {
157 157
    $footnote_list_key = $footnote_list_key_suggestion;
158 158
  } else {
......
170 170
  return $foot_note_keys;
171 171
}
172 172

  
173
/**
174
 * Created and registers footnotes in the FootnoteManager and returns the
175
 * footnote keys as markup.
176
 *
177
 * The following cdm cdm classes are annotatable:
178
 *
179
 * - DescriptionElementBase
180
 * - EventBase
181
 * - HomotypicalGroup
182
 * - IdentifiableEntity
183
 * - DescriptionBase
184
 * - IdentifiableMediaEntity
185
 * - Media
186
 * - Sequence
187
 * - TaxonBase
188
 * - TaxonName
189
 * - TaxonomicTree
190
 * - TermBase
191
 * - LanguageStringBase
192
 * - ReferencedEntityBase
193
 * - NomenclaturalStatus
194
 * - OriginalSourceBase
195
 * - RelationshipBase
196
 * - TypeDesignationBase
197
 * - TaxonNode
198
 * - WorkingSet
199
 *
200
 * @param array $cdm_entities
201
 *   An array of CdmBase instances.
202
 * @param $footnote_list_key_suggestion string
203
 *    optional parameter. If this parameter is left empty (null, 0, "") the
204
 *   footnote key will be determined be set to
205
 *   RenderHints::getFootnoteListKey().FOOTNOTE_KEY_SUFFIX_ANNOTATIONS otherwise the supplied
206
 *   key will be used.
207
 *
208
 * @return string
209
 *   The markup.
210
 */
211
function render_entities_annotations_as_footnote_keys(array $cdm_entities, $footnote_list_key =null){
212

  
213
  // check if footnotes for annotations are disabled completely
214
  if (variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
215
    return '';
216
  }
217
  $markup = '';
218
  $footNoteKeys = cdm_entities_annotations_footnote_keys($cdm_entities, $footnote_list_key);
219
  foreach ($footNoteKeys as $a) {
220
    $markup .= render_footnote_key($a, ($markup ? ',' : ''));
221
  }
222
  return $markup;
223
}
224

  
173 225
/**
174 226
 * Creates markup for an array of foot note keys
175 227
 *
......
178 230
 *
179 231
 * @return string
180 232
 */
181
function footnote_keys_to_markup(array $footnote_keys, $separator) {
233
function render_footnote_keys(array $footnote_keys, $separator) {
182 234

  
183 235
  $footnotes_markup = '';
184 236
  foreach ($footnote_keys as $foot_note_key) {
185 237
    try {
186
      $footnotes_markup .= cdm_footnote_key($foot_note_key, ($footnotes_markup ? $separator : ''));
238
      $footnotes_markup .= render_footnote_key($foot_note_key, ($footnotes_markup ? $separator : ''));
187 239
    } catch (Exception $e) {
188 240
      drupal_set_message("Exception: " . $e->getMessage(), 'error');
189 241
    }
......
202 254
 * @return string
203 255
 * @throws \Exception
204 256
 */
205
function cdm_annotation_footnotes($footnote_list_key = null, $element_tag = 'span') {
257
function render_annotation_footnotes($footnote_list_key = null, $element_tag = 'span') {
206 258
  if (variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
207 259
    return '';
208 260
  }
209
  return cdm_footnotes($footnote_list_key . FOOTNOTE_KEY_SUFFIX_ANNOTATIONS, $element_tag);
261
  return render_footnotes($footnote_list_key . FOOTNOTE_KEY_SUFFIX_ANNOTATIONS, $element_tag);
210 262
}
211 263

  
212 264
/**
......
219 271
 * @return string
220 272
 *   The footnote key markup
221 273
 */
222
function cdm_footnote_key($footnoteKey = null, $separator = '', $separator_off = false) {
274
function render_footnote_key($footnoteKey = null, $separator = '', $separator_off = false) {
223 275

  
224 276
  if (!is_object($footnoteKey) or !isset($footnoteKey->footnoteListKey)) {
225 277
    return '';
......
244 296
 *
245 297
 * @return string
246 298
 */
247
function footnote_markup($footnoteKey = null, $footnoteText = null, $enclosing_tag = 'span') {
299
function render_footnote($footnoteKey = null, $footnoteText = null, $enclosing_tag = 'span') {
248 300
  _add_js_footnotes();
249 301
  if($enclosing_tag == null){
250 302
    $enclosing_tag = 'span';
......
267 319
 *
268 320
 * @return string
269 321
 */
270
function cdm_footnotes($footnote_list_key = null, $element_tag = 'span') {
322
function render_footnotes($footnote_list_key = null, $element_tag = 'span') {
271 323

  
272 324
  if (variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
273 325
    return '';
modules/cdm_dataportal/includes/name.inc
580 580
  }
581 581
  $out .= '</span>';
582 582
  if ($show_annotations) {
583
    // $out .= theme('cdm_entities_annotations_as_footnotekeys', $taxonName);
583
    // $out .= render_entities_annotations_as_footnote_keys([$taxonName]);
584 584
  }
585 585
  return $out;
586 586
}
......
984 984
          // footnotes should be rendered in the parent element so we
985 985
          // are relying on the FootnoteListKey set there
986 986
          $_fkey2 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $citation_footnote_str);
987
          $footnote_key_markup = cdm_footnote_key($_fkey2, $separator, TRUE);
987
          $footnote_key_markup = render_footnote_key($_fkey2, $separator, TRUE);
988 988
        }
989 989

  
990 990
        $type_citation_markup .= '&nbsp;(' . t('designated by') . '&nbsp;<span class="typeReference">' . $authorteam_str . '</span>';
......
1064 1064
    RenderHints::getFootnoteListKey(),
1065 1065
    (isset($derivedUnitFacadeInstance->collection->titleCache) ? $derivedUnitFacadeInstance->collection->titleCache : FALSE)
1066 1066
  );
1067
  $out .= cdm_footnote_key($_fkey, $separator);
1067
  $out .= render_footnote_key($_fkey, $separator);
1068 1068
  $out .= '</' . $enclosing_tag .'>';
1069 1069

  
1070 1070
  RenderHints::popFromRenderStack();
......
1435 1435

  
1436 1436
  RenderHints::popFromRenderStack();
1437 1437
  if(RenderHints::getFootnoteListKey() == $key) {
1438
    $render_array['footnotes'] = markup_to_render_array(cdm_footnotes(RenderHints::getFootnoteListKey()));
1438
    $render_array['footnotes'] = markup_to_render_array(render_footnotes(RenderHints::getFootnoteListKey()));
1439 1439
    RenderHints::clearFootnoteListKey();
1440 1440
  }
1441 1441
  return $render_array;
......
1590 1590
  }
1591 1591
  if ($footnote_markup) {
1592 1592
    $fnkey = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $footnote_markup);
1593
    $footnote_key_markup = cdm_footnote_key($fnkey,',',TRUE);
1593
    $footnote_key_markup = render_footnote_key($fnkey,',',TRUE);
1594 1594
  }
1595 1595
  return $footnote_key_markup;
1596 1596
}
......
1622 1622
  }
1623 1623
  if ($footnote_markup) {
1624 1624
    $fnkey = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $footnote_markup);
1625
    $footnote_key_markup = cdm_footnote_key($fnkey, ',',TRUE);
1625
    $footnote_key_markup = render_footnote_key($fnkey, ',',TRUE);
1626 1626
  }
1627 1627
  return $footnote_key_markup;
1628 1628
}
......
1990 1990
    // footnotes should be rendered in the parent element so we
1991 1991
    // are relying on the FootnoteListKey set there
1992 1992
    $fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $typeDesignation->citation->titleCache);
1993
    $res .= cdm_footnote_key($fkey_typeDesignation, $footnote_separator,TRUE) . ')';
1993
    $res .= render_footnote_key($fkey_typeDesignation, $footnote_separator,TRUE) . ')';
1994 1994
  }
1995 1995
  return $res;
1996 1996
}
modules/cdm_dataportal/includes/occurrences.inc
761 761

  
762 762
        $derivatives[] = $occurrence_elements;
763 763
        // all footnotes which has been assembled so far (e.g. from typeDesignations) to here
764
//       $foonote_li_elements = cdm_footnotes(RenderHints::getFootnoteListKey(), 'span');
764
//       $foonote_li_elements = render_footnotes(RenderHints::getFootnoteListKey(), 'span');
765 765
//        if (!empty($foonote_li_elements)) {
766 766
//            $derivatives[] =  array(
767 767
//                '#markup' =>  '<div class="footnotes">' . $foonote_li_elements . '</div>',
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 .= cdm_entities_annotations_as_footnotekeys($special_annotations_array,  $synonymy_render_path . FOOTNOTE_KEY_SUFFIX_ANNOTATIONS);
725
    $accepted_name .= render_entities_annotations_as_footnote_keys($special_annotations_array,  $synonymy_render_path . FOOTNOTE_KEY_SUFFIX_ANNOTATIONS);
726 726
    $accepted_name .= '</div>';
727 727
    RenderHints::popFromRenderStack();
728 728
  }
modules/cdm_dataportal/includes/taxon-node.inc
72 72
          $status_markup[] = sprintf($tokes['status'], '');
73 73
        }
74 74
      }
75
      $render_array['taxon-node-status'] = markup_to_render_array($label . ': ' . join('; ', $status_markup) . cdm_footnotes(RenderHints::getFootnoteListKey()));
75
      $render_array['taxon-node-status'] = markup_to_render_array($label . ': ' . join('; ', $status_markup) . render_footnotes(RenderHints::getFootnoteListKey()));
76 76
      $render_array['taxon-node-status']['#prefix'] = '<div class="taxon-node-status">';
77 77
      $render_array['taxon-node-status']['#suffix'] = '</div>';
78 78
    }
modules/cdm_dataportal/includes/taxon.inc
145 145
      if($sensu_strings['order_by_key'] != $sensu_reference->titleCache){
146 146
        $sensu_reference_markup = cdm_reference_markup($sensu_reference);
147 147
        $footnote_key = FootnoteManager::addNewFootnote($footnote_list_key, $sensu_reference_markup);
148
        $footnote_key = cdm_footnote_key($footnote_key);
148
        $footnote_key = render_footnote_key($footnote_key);
149 149
        $joined_refs[$ref_key]['markup'] = '<span class="sensu">' . $sensu_strings['markup'] . $footnote_key . '</span>';
150 150
      }
151 151
    }
......
209 209
    $out .= '</ul>';
210 210
  }
211 211

  
212
  $footnotes = cdm_footnotes($footnote_list_key, 'li');
213
  $footnotes .= cdm_annotation_footnotes($footnote_list_key,'li');
212
  $footnotes = render_footnotes($footnote_list_key, 'li');
213
  $footnotes .= render_annotation_footnotes($footnote_list_key,'li');
214 214

  
215 215
  $out .= '<ul class="footnotes">' . $footnotes . '</ul>';
216 216
  $out .= '</div>';
......
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 = cdm_entities_annotations_as_footnotekeys([$taxon->name,$taxon], $footnoteListKey);
396
  $taxon_footnotes = render_entities_annotations_as_footnote_keys([$taxon->name,$taxon], $footnoteListKey);
397 397
  $name_relations = cdm_name_relationships_for_taxon($taxon);
398 398
  $name_relations_render_array = compose_name_relationships_inline($name_relations, $taxon->name->uuid, $taxon->uuid);
399 399

  
......
435 435
      $referenceUri = url(path_to_reference($synonym->name->nomenclaturalReference->uuid));
436 436
    }
437 437
    $out .= render_taxon_or_name($synonym->name, NULL, $referenceUri);
438
    $out .= cdm_entities_annotations_as_footnotekeys($synonym);
438
    $out .= render_entities_annotations_as_footnote_keys([$synonym]);
439 439
    $out .= '</span>';
440 440
  }
441 441
  RenderHints::popFromRenderStack();
......
566 566
            }
567 567
            $out .= '<span class="classifications"><span class="separator"> : </span>' . implode(', ', $classification_titles) . '</span>';
568 568
          }
569
          $out .= cdm_entities_annotations_as_footnotekeys($taxon);
569
          $out .= render_entities_annotations_as_footnote_keys([$taxon]);
570 570
          if ($showMedia_synonyms) {
571 571
            $out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $acceptedTaxon));
572 572
          }
......
594 594
        }
595 595
        $out .= '<span class="classifications"><span class="separator"> : </span>' . implode(', ', $classification_titles) . '</span>';
596 596
      }
597
      $out .= cdm_entities_annotations_as_footnotekeys($taxon);
597
      $out .= render_entities_annotations_as_footnote_keys([$taxon]);
598 598

  
599 599
      if ($showMedia_taxa) {
600 600
        $out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $taxon));
modules/cdm_dataportal/theme/cdm_dataportal.common.theme
119 119

  
120 120
/* ============================ annotations ============================= */
121 121

  
122
/**
123
 * Returns HTML for annotations to cdm objects.
124
 *
125
 * Almost any cdmObject may be annotated. Therefore we provide a generic way to
126
 * display as well as create or update annotations. The following cdm classes
127
 * are annotatable:
128
 *
129
 * - DescriptionElementBase
130
 * - EventBase
131
 * - HomotypicalGroup
132
 * - IdentifiableEntity
133
 * - DescriptionBase
134
 * - IdentifiableMediaEntity
135
 * - Media
136
 * - Sequence
137
 * - TaxonBase
138
 * - TaxonName
139
 * - TaxonomicTree
140
 * - TermBase
141
 * - LanguageStringBase
142
 * - ReferencedEntityBase
143
 * - NomenclaturalStatus
144
 * - OriginalSourceBase
145
 * - RelationshipBase
146
 * - TypeDesignationBase
147
 * - TaxonNode
148
 * - WorkingSet
149
 *
150
 * @param array $cdm_entities
151
 *   An array of CdmBase instances.
152
 * @param $footnote_list_key_suggestion string
153
 *    optional parameter. If this parameter is left empty (null, 0, "") the
154
 *   footnote key will be determined be set to
155
 *   RenderHints::getFootnoteListKey().FOOTNOTE_KEY_SUFFIX_ANNOTATIONS otherwise the supplied
156
 *   key will be used.
157
 *
158
 * @return string
159
 *   The markup.
160
 */
161
function cdm_entities_annotations_as_footnotekeys($cdm_entities, $footnote_list_key =null){
162

  
163
  // check if footnotes for annotations are disabled completely
164
  if (variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES)) {
165
    return '';
166
  }
167
  $out = '';
168
  if(is_array($cdm_entities)){
169
    // array of entities
170
    $footNoteKeys = cdm_entities_annotations_footnote_keys($cdm_entities, $footnote_list_key);
171
  } else {
172
    // single entity
173
    $footNoteKeys = cdm_entity_annotations_as_footnote_keys($cdm_entities, $footnote_list_key);
174
  }
175
  foreach ($footNoteKeys as $a) {
176
    $out .= cdm_footnote_key($a, ($out ? ',' : ''));
177
  }
178
  return $out;
179
}
180

  
181 122
/**
182 123
 * Created markup for the annotations
183 124
 * @param null $annotations
modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
330 330
    $out .= '</li>';
331 331
  }
332 332
  $out .= '</ul>';
333
  $out .= cdm_annotation_footnotes(RenderHints::getRenderPath());
333
  $out .= render_annotation_footnotes(RenderHints::getRenderPath());
334 334
  RenderHints::popFromRenderStack();
335 335

  
336 336
  return $out;
modules/cdm_dataportal/theme/cdm_dataportal.media.theme
308 308
  );
309 309
  $out .= drupal_render($description_list_item);
310 310

  
311
  $out .= cdm_footnotes($footnote_list_key);
311
  $out .= render_footnotes($footnote_list_key);
312 312

  
313 313
  return $out;
314 314
}
modules/cdm_dataportal/theme/cdm_dataportal.name.theme
59 59

  
60 60
  // ------- footnotes ------- //
61 61
  $out .= '<ul class="footnotes">';
62
  $out .= cdm_annotation_footnotes(RenderHints::getFootnoteListKey(), 'li');
63
  $out .= cdm_footnotes(RenderHints::getFootnoteListKey(), 'li');
62
  $out .= render_annotation_footnotes(RenderHints::getFootnoteListKey(), 'li');
63
  $out .= render_footnotes(RenderHints::getFootnoteListKey(), 'li');
64 64
  $out .= '</ul>';
65 65

  
66 66
  $out .= '</div>';
......
124 124
  // all foonotes of the homotypic group and also of the accepted taxon are
125 125
  // rendered here, both should have the same footnote key
126 126
  $out .= '<ul class="footnotes">';
127
  $out .= cdm_annotation_footnotes(RenderHints::getFootnoteListKey(), 'li');
128
  $out .= cdm_footnotes(RenderHints::getFootnoteListKey(), 'li');
127
  $out .= render_annotation_footnotes(RenderHints::getFootnoteListKey(), 'li');
128
  $out .= render_footnotes(RenderHints::getFootnoteListKey(), 'li');
129 129
  $out .= '</ul>';
130 130

  
131 131
  $out .= '</div>';

Also available in: Unified diff