|
|
@ -20,14 +20,11 @@ use Drupal\footnotes\Plugin\Filter\FootnotesFilter; |
|
|
|
* "footnotes_footnotefootnote_linkcollapse" = FALSE, |
|
|
|
* "footnotes_footnotefootnote_linkcollapse" = FALSE, |
|
|
|
* "footnotes_ibid" = FALSE, |
|
|
|
* "footnotes_ibid" = FALSE, |
|
|
|
* "notes_section_label" = "Notes", |
|
|
|
* "notes_section_label" = "Notes", |
|
|
|
* "references_section_label" = "References" |
|
|
|
|
|
|
|
* }, |
|
|
|
* }, |
|
|
|
* weight = 0 |
|
|
|
* weight = 0 |
|
|
|
* ) |
|
|
|
* ) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class ReferenceFootnotesFilter extends FootnotesFilter { |
|
|
|
class ReferenceFootnotesFilter extends FootnotesFilter { |
|
|
|
const ENDNOTE = 0; |
|
|
|
|
|
|
|
const REFERENCE = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Object with configuration for reference footnotes. |
|
|
|
* Object with configuration for reference footnotes. |
|
|
@ -80,34 +77,27 @@ class ReferenceFootnotesFilter extends FootnotesFilter { |
|
|
|
]; |
|
|
|
]; |
|
|
|
$settings['notes_section_label'] = [ |
|
|
|
$settings['notes_section_label'] = [ |
|
|
|
'#type' => 'textfield', |
|
|
|
'#type' => 'textfield', |
|
|
|
'#title' => t('Notes section label'), |
|
|
|
'#title' => t('Notes section heading label'), |
|
|
|
'#default_value' => $this->settings['notes_section_label'], |
|
|
|
'#default_value' => $this->settings['notes_section_label'], |
|
|
|
]; |
|
|
|
]; |
|
|
|
$settings['references_section_label'] = [ |
|
|
|
|
|
|
|
'#type' => 'textfield', |
|
|
|
|
|
|
|
'#title' => $this->t('References section label'), |
|
|
|
|
|
|
|
'#description' => $this->t('E.g., "Works Cited" for MLA style.'), |
|
|
|
|
|
|
|
'#default_value' => $this->settings['references_section_label'], |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
$settings['reference_dont_show_backlink_text'] = [ |
|
|
|
$settings['reference_dont_show_backlink_text'] = [ |
|
|
|
'#type' => 'checkbox', |
|
|
|
'#type' => 'checkbox', |
|
|
|
'#title' => $this->t("Don't show note 'value' text in reference list."), |
|
|
|
'#title' => $this->t("Don't show note 'value' text in reference list."), |
|
|
|
'#description' => $this->t("Suitable for MLA-style citations, like (Smith, 33-22)"), |
|
|
|
'#description' => $this->t("Suitable for MLA-style citations, like (Smith, 33-22)"), |
|
|
|
'#default_value' => $this->settings['reference_dont_show_backlink_text'], |
|
|
|
'#default_value' => $this->settings['reference_dont_show_backlink_text'], |
|
|
|
]; |
|
|
|
]; |
|
|
|
$settings['reference_sort_by'] = [ |
|
|
|
$settings['works_cited_sort_by'] = [ |
|
|
|
'#type' => 'select', |
|
|
|
'#type' => 'select', |
|
|
|
'#title' => $this->t("Sort references list by"), |
|
|
|
'#title' => $this->t("Sort Workd Cited list by"), |
|
|
|
'#options' => [ |
|
|
|
'#options' => [ |
|
|
|
'order' => $this->t("Order in text"), |
|
|
|
'weight' => $this->t("Manually"), |
|
|
|
'alphabetical' => $this->t("Alphabetical"), |
|
|
|
'alphabetical' => $this->t("Alphabetically"), |
|
|
|
], |
|
|
|
], |
|
|
|
'#default_value' => $this->settings['reference_sort_by'], |
|
|
|
'#default_value' => $this->settings['works_cited_sort_by'], |
|
|
|
]; |
|
|
|
]; |
|
|
|
return $settings; |
|
|
|
return $settings; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Helper function called from preg_replace_callback() above. |
|
|
|
* Helper function called from preg_replace_callback() above. |
|
|
|
* |
|
|
|
* |
|
|
@ -320,23 +310,4 @@ class ReferenceFootnotesFilter extends FootnotesFilter { |
|
|
|
$prev_reference_id = $fn['reference']; |
|
|
|
$prev_reference_id = $fn['reference']; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function extractNotesByType($type, $footnotes) { |
|
|
|
|
|
|
|
$notes = []; |
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $notes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|