From a399f6d9c118636f8e17cd8d1e034a6b7520392c Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Tue, 6 Nov 2018 16:32:20 -0400 Subject: [PATCH] WIP --- bibcite_footnotes.module | 2 +- .../Filter/ReferenceFootnotesFilter.php | 20 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/bibcite_footnotes.module b/bibcite_footnotes.module index a2d2a6f..b590dd4 100644 --- a/bibcite_footnotes.module +++ b/bibcite_footnotes.module @@ -63,7 +63,7 @@ function bibcite_footnotes_help($route_name, RouteMatchInterface $route_match) { function bibcite_footnotes_preprocess_bibcite_footnote_list(&$variables) { $config = $variables['config']; $footnotes = $variables['notes']; - +ksm($footnotes); $notes = [ '#theme' => 'item_list', '#list_type' => 'ul', diff --git a/src/Plugin/Filter/ReferenceFootnotesFilter.php b/src/Plugin/Filter/ReferenceFootnotesFilter.php index ac1cea6..e5dcfc3 100644 --- a/src/Plugin/Filter/ReferenceFootnotesFilter.php +++ b/src/Plugin/Filter/ReferenceFootnotesFilter.php @@ -10,7 +10,7 @@ use Drupal\footnotes\Plugin\Filter\FootnotesFilter; * Provides a base filter for Reference Footnotes filter. * * @Filter( - * id = "filter_reference_footnotes",footnote_list + * id = "filter_reference_footnotes", * module = "bibcite_footnotes", * title = @Translation("Reference Footnotes filter"), * description = @Translation("You can insert footnotes directly into texts."), @@ -141,16 +141,16 @@ class ReferenceFootnotesFilter extends FootnotesFilter { } if ($op == 'output footer') { - if ($this->settings['footnotes_ibid']) { - $this->ibidemify($store_matches); - } + if (count($store_matches) > 0) { // Separate out endontes and reference notes. $notes = $this->extractNotesByType(self::ENDNOTE, $store_matches); $references = $this->extractNotesByType(self::REFERENCE, $store_matches); - + if ($this->settings['footnotes_ibid']) { + $this->ibidemify($references); + } // Only if there are stored fn matches, pass the array of fns to be // themed as a list $markup = [ @@ -330,19 +330,15 @@ class ReferenceFootnotesFilter extends FootnotesFilter { protected function ibidemify(&$footnotes) { $prev_reference_id = FALSE; foreach ($footnotes as $index => $fn) { - if (!empty($fn['text'])) { - $prev_reference_id = FALSE; - continue; - } if ($prev_reference_id) { if ($fn['reference'] == $prev_reference_id) { unset($footnotes[$index]['reference']); - $footnotes[$index]['text'] = $this->t('Ibid.'); + $footnotes[$index]['text'] = 'Ibid.'; + $footnotes[$index]['text_clean'] = 'Ibid.'; continue; } } - $prev_reference_id = $fn['reference']; // Could be empty, that's OK. - + $prev_reference_id = $fn['reference']; } }