Alexander O'Neill 6 years ago
parent
commit
a399f6d9c1
  1. 2
      bibcite_footnotes.module
  2. 20
      src/Plugin/Filter/ReferenceFootnotesFilter.php

2
bibcite_footnotes.module

@ -63,7 +63,7 @@ function bibcite_footnotes_help($route_name, RouteMatchInterface $route_match) {
function bibcite_footnotes_preprocess_bibcite_footnote_list(&$variables) { function bibcite_footnotes_preprocess_bibcite_footnote_list(&$variables) {
$config = $variables['config']; $config = $variables['config'];
$footnotes = $variables['notes']; $footnotes = $variables['notes'];
ksm($footnotes);
$notes = [ $notes = [
'#theme' => 'item_list', '#theme' => 'item_list',
'#list_type' => 'ul', '#list_type' => 'ul',

20
src/Plugin/Filter/ReferenceFootnotesFilter.php

@ -10,7 +10,7 @@ use Drupal\footnotes\Plugin\Filter\FootnotesFilter;
* Provides a base filter for Reference Footnotes filter. * Provides a base filter for Reference Footnotes filter.
* *
* @Filter( * @Filter(
* id = "filter_reference_footnotes",footnote_list * id = "filter_reference_footnotes",
* module = "bibcite_footnotes", * module = "bibcite_footnotes",
* title = @Translation("Reference Footnotes filter"), * title = @Translation("Reference Footnotes filter"),
* description = @Translation("You can insert footnotes directly into texts."), * description = @Translation("You can insert footnotes directly into texts."),
@ -141,16 +141,16 @@ class ReferenceFootnotesFilter extends FootnotesFilter {
} }
if ($op == 'output footer') { if ($op == 'output footer') {
if ($this->settings['footnotes_ibid']) {
$this->ibidemify($store_matches);
}
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::ENDNOTE, $store_matches); $notes = $this->extractNotesByType(self::ENDNOTE, $store_matches);
$references = $this->extractNotesByType(self::REFERENCE, $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 // Only if there are stored fn matches, pass the array of fns to be
// themed as a list // themed as a list
$markup = [ $markup = [
@ -330,19 +330,15 @@ class ReferenceFootnotesFilter extends FootnotesFilter {
protected function ibidemify(&$footnotes) { protected function ibidemify(&$footnotes) {
$prev_reference_id = FALSE; $prev_reference_id = FALSE;
foreach ($footnotes as $index => $fn) { foreach ($footnotes as $index => $fn) {
if (!empty($fn['text'])) {
$prev_reference_id = FALSE;
continue;
}
if ($prev_reference_id) { if ($prev_reference_id) {
if ($fn['reference'] == $prev_reference_id) { if ($fn['reference'] == $prev_reference_id) {
unset($footnotes[$index]['reference']); unset($footnotes[$index]['reference']);
$footnotes[$index]['text'] = $this->t('Ibid.'); $footnotes[$index]['text'] = 'Ibid.';
$footnotes[$index]['text_clean'] = 'Ibid.';
continue; continue;
} }
} }
$prev_reference_id = $fn['reference']; // Could be empty, that's OK. $prev_reference_id = $fn['reference'];
} }
} }

Loading…
Cancel
Save