Alexander O'Neill 6 years ago
parent
commit
068d75e7df
  1. 3
      bibcite_footnotes.module
  2. 28
      src/Plugin/Filter/ReferenceFootnotesFilter.php

3
bibcite_footnotes.module

@ -27,6 +27,7 @@ function bibcite_footnotes_theme() {
'variables' => [ 'variables' => [
'notes' => [], 'notes' => [],
'note_type' => [], 'note_type' => [],
'config' => [],
], ],
], ],
]; ];
@ -70,7 +71,7 @@ function bibcite_footnotes_preprocess_footnote_list(&$variables) {
'#wrapper_attributes' => ['class' => 'container'], '#wrapper_attributes' => ['class' => 'container'],
]; ];
$references['#attached']['library'][] = 'bibcite_footnotes/reference_footnote'; $notes['#attached']['library'][] = 'bibcite_footnotes/reference_footnote';
$dont_show_backlink_text = $config->get('filters.filter_reference_footnotes.settings.reference_dont_show_backlink_text'); $dont_show_backlink_text = $config->get('filters.filter_reference_footnotes.settings.reference_dont_show_backlink_text');
$sort_references_by = $config->get('filters.filter_reference_footnotes.settings.reference_sort_by'); $sort_references_by = $config->get('filters.filter_reference_footnotes.settings.reference_sort_by');
$citation_tools = new CitationTools(); $citation_tools = new CitationTools();

28
src/Plugin/Filter/ReferenceFootnotesFilter.php

@ -147,15 +147,17 @@ class ReferenceFootnotesFilter extends FootnotesFilter {
if (count($store_matches) > 0) { if (count($store_matches) > 0) {
// Separate out endontes and reference notes. // Separate out endontes and reference notes.
$notes = $this->extractNotesByType(self::NOTES, $store_matches); $notes = $this->extractNotesByType(self::ENDNOTE, $store_matches);
$references = $this->extractNotesByType(self::REFERENCES, $store_matches); $references = $this->extractNotesByType(self::REFERENCE, $store_matches);
// Only if there are stored fn matches, pass the array of fns to be // Only if there are stored fn matches, pass the array of fns to be
// themed as a list // themed as a list
$markup = [ $markup = [
'#theme' => 'footnote_list', '#theme' => 'bibcite_footnote_list',
'#footnotes' => $store_matches, '#footnotes' => $notes,,
'#note_type' => self::ENDNOTE,
'#config' => $this->settings,
]; ];
$str = \Drupal::service('renderer')->render($markup, FALSE); $str = \Drupal::service('renderer')->render($markup, FALSE);
} }
@ -256,7 +258,7 @@ class ReferenceFootnotesFilter extends FootnotesFilter {
// Drupal 7 requires we use "render element" which just introduces a wrapper // Drupal 7 requires we use "render element" which just introduces a wrapper
// around the old array. // around the old array.
$fn = [ $fn = [
'#theme' => 'footnote_link', '#theme' => 'bibcite_footnote_link',
'fn' => $fn, 'fn' => $fn,
]; ];
@ -338,8 +340,22 @@ class ReferenceFootnotesFilter extends FootnotesFilter {
} }
protected function extractNotesByType($type, $footnotes) { protected function extractNotesByType($type, $footnotes) {
$notes = [];
foreach ($footnotes as $fn) { foreach ($footnotes as $fn) {
switch ($type) {
case self::ENDNOTE:
if (!empty(fn['text'])) {
$notes[] = $fn;
}
break;
case self::REFERENCE:
if (!empty($fn['reference'])) {
$notes[] = $fn;
}
break;
}
ksm($fn);
} }
return $notes;
} }
} }

Loading…
Cancel
Save