Browse Source

Drupal 10 compatibility

8.x-1.x
Paul Pound 9 months ago
parent
commit
235afbfa7a
  1. 2
      bibcite_footnotes.info.yml
  2. 17
      bibcite_footnotes.module
  3. 2
      bibcite_footnotes_article_with_citations/bibcite_footnotes_article_with_citations.info.yml
  4. 5
      src/Plugin/CKEditorPlugin/ReferenceFootnotes.php

2
bibcite_footnotes.info.yml

@ -1,7 +1,7 @@
name: 'BibCite Footnotes'
type: module
description: 'Inline footnote links for BibCite References'
core_version_requirement: ^8.0 || ^9
core_version_requirement: ^8.0 || ^9 || 10
package: 'Bibliography & Citation'
dependencies:
- bibcite:bibcite

17
bibcite_footnotes.module

@ -25,7 +25,7 @@ function bibcite_footnotes_theme() {
],
'bibcite_footnote_list' => [
'render element' => 'footnotes',
'path' => drupal_get_path('module', 'bibcite_footnotes') . '/templates',
'path' => \Drupal::service('extension.list.module')->getPath('bibcite_footnotes') . '/templates',
'template' => 'bibcite-footnote-list',
'variables' => [
'notes' => [],
@ -145,8 +145,9 @@ function bibcite_footnotes_preprocess_bibcite_footnote_list(&$variables) {
$build[] = $citation_build;
}
$render = render($build);
$item['sort'] = trim(strip_tags(render($citation_build)));
//$render = render($build);
$citation_build_render = \Drupal::service('renderer')->render($citation_build);
$item['sort'] = trim(strip_tags($citation_build_render));
}
// $item['#markup'] = $render;
@ -197,8 +198,8 @@ function bibcite_footnotes_preprocess_bibcite_footnote_link(&$variables) {
$citation_data['#data']['page'] = $fn['page'];
$class .= '-inline';
}
$title = trim(strip_tags(render($citation_data)));
$citation_data_render = \Drupal::service('renderer')->render($citation_data);
$title = trim(strip_tags($citation_data_render));
$url = Url::fromUserInput('#' . $fn['fn_id'], ['attributes' => ['id' => $fn['ref_id'], 'class' => $class, 'title' => $title]]);
@ -307,7 +308,8 @@ function bibcite_footnotes_get_ckeditor_select_item($entity): array {
$data = $serializer->normalize($entity, 'csl');
$build = ['#theme' => 'bibcite_citation', '#data' => $data];
$citation_text = trim(strip_tags(render($build)));
$build_render = \Drupal::service('renderer')->render($build);
$citation_text = trim(strip_tags($build_render));
// Attempt to match up pre-saved entities with the eventual saved ones.
$citation_key = $entity->id->first()->getValue()['value'];
return [$citation_text, $citation_key];
@ -327,10 +329,11 @@ function bibcite_footnotes_preprocess_field(&$variables, $hook) {
foreach($variables['element'] as $index => $element) {
if (is_numeric($index)) {
$renderable = $citation_tools->getRenderableReference($element['#bibcite_reference']);
$renderable = \Drupal::service('renderer')->render($renderable);
$items[] = [
'orig_index' => $index,
'orig_element' => $element,
'rendered' => trim(strip_tags(render($renderable))),
'rendered' => trim(strip_tags($renderable)),
];
}
}

2
bibcite_footnotes_article_with_citations/bibcite_footnotes_article_with_citations.info.yml

@ -1,7 +1,7 @@
name: 'BibCite Footnotes Article with Citations'
type: module
description: 'Example module to show a fully-configured content type and text format with Reference Footnotes.'
core_version_requirement: ^8 || ^9
core_version_requirement: ^8 || ^9 || ^10
package: 'Bibliography & Citation'
dependencies:
- bibcite_footnotees:bibcite_footnotes

5
src/Plugin/CKEditorPlugin/ReferenceFootnotes.php

@ -33,7 +33,8 @@ class ReferenceFootnotes extends CKEditorPluginBase {
return [
'reference_footnotes' => [
'label' => t('Reference Footnotes'),
'image' => drupal_get_path('module', 'bibcite_footnotes') . '/js/plugins/reference_footnotes/images/icon.png',
'image' => \Drupal::service('extension.list.module')->getPath('bibcite_footnotes') .
'/js/plugins/reference_footnotes/images/icon.png',
],
];
}
@ -44,7 +45,7 @@ class ReferenceFootnotes extends CKEditorPluginBase {
public function getFile() {
// Make sure that the path to the plugin.js matches the file structure of
// the CKEditor plugin you are implementing.
return drupal_get_path('module', 'bibcite_footnotes') . '/js/plugins/reference_footnotes/plugin.js';
return \Drupal::service('extension.list.module')->getPath('bibcite_footnotes') . '/js/plugins/reference_footnotes/plugin.js';
}
/**

Loading…
Cancel
Save