diff --git a/bibcite_footnotes.module b/bibcite_footnotes.module index 274c79f..bec0ebd 100644 --- a/bibcite_footnotes.module +++ b/bibcite_footnotes.module @@ -76,7 +76,7 @@ function bibcite_footnotes_preprocess_bibcite_footnote_list(&$variables) { $notes['#attached']['library'][] = 'bibcite_footnotes/reference_footnote'; $dont_show_backlink_text = $config['reference_dont_show_backlink_text']; - $sort_references_by = $config['reference_sort_by']; + $citation_tools = new CitationTools(); if (empty($footnotes)) { return; @@ -200,7 +200,7 @@ function bibcite_footnotes_preprocess_bibcite_footnote_link(&$variables) { $title = trim(strip_tags(render($citation_data))); $url = Url::fromUserInput('#' . $fn['fn_id'], ['attributes' => ['id' => $fn['ref_id'], 'class' => $class, 'title' => $title]]); - + $link = Link::fromTextAndUrl($fn['value'], $url)->toRenderable(); unset($variables['fn']['fn']); @@ -241,21 +241,22 @@ function bibcite_footnotes_form_node_form_alter(&$form, FormStateInterface &$for /** * @var FieldConfig $field_config */ - $field_config = $ief_instance['instance']; - - // Check if this is a bibcite_reference field type. - if ($field_config->getSetting('handler') == 'default:bibcite_reference') { - $field_name = $field_config->get('field_name'); - if (!empty($ief_instance['entities'])) { - - foreach ($ief_instance['entities'] as $entity_wrapper) { - /** - * @var \Drupal\core\Entity\EntityInterface $entity - */ - $entity = $entity_wrapper['entity']; - if ($entity->getEntityTypeId() == 'bibcite_reference') { - list($citation_text, $citation_key) = bibcite_footnotes_get_ckeditor_select_item($entity); - $bibcite_references[] = [$citation_text, $citation_key]; + if ($field_config = $ief_instance['instance']) { + + // Check if this is a bibcite_reference field type. + if ($field_config->getSetting('handler') == 'default:bibcite_reference') { + $field_name = $field_config->get('field_name'); + if (!empty($ief_instance['entities'])) { + + foreach ($ief_instance['entities'] as $entity_wrapper) { + /** + * @var \Drupal\core\Entity\EntityInterface $entity + */ + $entity = $entity_wrapper['entity']; + if ($entity->getEntityTypeId() == 'bibcite_reference') { + list($citation_text, $citation_key) = bibcite_footnotes_get_ckeditor_select_item($entity); + $bibcite_references[] = [$citation_text, $citation_key]; + } } } } @@ -359,4 +360,4 @@ function _bibcite_footnotes_sort_rendered_references($a, $b) { return 0; } return strtolower($a['rendered']) < strtolower($b['rendered']) ? -1 : 1; -} \ No newline at end of file +}