|
|
@ -69,16 +69,13 @@ function bibcite_footnotes_preprocess_footnote_list(&$variables) { |
|
|
|
], |
|
|
|
], |
|
|
|
]; |
|
|
|
]; |
|
|
|
$build = []; |
|
|
|
$build = []; |
|
|
|
$reference_entity_id = _bibcite_footnotes_get_reference_entity_id_from_bibcite_footnote($fn['text']); |
|
|
|
$reference_entity_id = _bibcite_footnotes_get_reference_entity_id_from_bibcite_footnote($fn['reference']); |
|
|
|
|
|
|
|
|
|
|
|
$footnote_link_text = $dont_show_backlink_text && $reference_entity_id ? '^' : $fn['value']; |
|
|
|
$footnote_link_text = ($dont_show_backlink_text && $reference_entity_id) ? '^' : $fn['value']; |
|
|
|
if (!is_array($fn['ref_id'])) { |
|
|
|
if (!is_array($fn['ref_id'])) { |
|
|
|
// Output normal footnote. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$url = Url::fromUserInput('#' . $fn['ref_id'], ['attributes' => ['id' => $fn['fn_id'], 'class' => 'footnote-link']]); |
|
|
|
$url = Url::fromUserInput('#' . $fn['ref_id'], ['attributes' => ['id' => $fn['fn_id'], 'class' => 'footnote-link']]); |
|
|
|
$link = Link::fromTextAndUrl(($footnote_link_text), $url)->toRenderable(); |
|
|
|
$link = Link::fromTextAndUrl(($footnote_link_text), $url)->toRenderable(); |
|
|
|
$build[] = $link; |
|
|
|
$build['footnote-link'] = $link; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
// Output footnote that has more than one reference to it in the body. |
|
|
|
// Output footnote that has more than one reference to it in the body. |
|
|
@ -88,7 +85,7 @@ function bibcite_footnotes_preprocess_footnote_list(&$variables) { |
|
|
|
$i = 0; |
|
|
|
$i = 0; |
|
|
|
|
|
|
|
|
|
|
|
$url = Url::fromUserInput('#' . $fn['ref_id'][0], ['attributes' => ['id' => $fn['fn_id'], 'class' => 'footnote-link']]); |
|
|
|
$url = Url::fromUserInput('#' . $fn['ref_id'][0], ['attributes' => ['id' => $fn['fn_id'], 'class' => 'footnote-link']]); |
|
|
|
$build[] = Link::fromTextAndUrl($footnote_link_text, $url)->toRenderable(); |
|
|
|
$build['footnote-link'] = Link::fromTextAndUrl($footnote_link_text, $url)->toRenderable(); |
|
|
|
|
|
|
|
|
|
|
|
foreach ($fn['ref_id'] as $ref) { |
|
|
|
foreach ($fn['ref_id'] as $ref) { |
|
|
|
$url = Url::fromUserInput( '#' . $ref, ['attributes' => ['id' => $fn['fn_id'], 'class' => 'footnote-multi']]); |
|
|
|
$url = Url::fromUserInput( '#' . $ref, ['attributes' => ['id' => $fn['fn_id'], 'class' => 'footnote-multi']]); |
|
|
@ -96,11 +93,28 @@ function bibcite_footnotes_preprocess_footnote_list(&$variables) { |
|
|
|
|
|
|
|
|
|
|
|
$i++; |
|
|
|
$i++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($fn['text'])) { |
|
|
|
|
|
|
|
// Handle the case where an endnote contains text and a reference. |
|
|
|
|
|
|
|
// It will appear in both lists. But the link text for the endnote should |
|
|
|
|
|
|
|
// always be the title of the note. So make a copy of the biuld arrray |
|
|
|
|
|
|
|
// and change the link text. |
|
|
|
|
|
|
|
$note_build = $build + ['#type' => 'markup', '#markup' => ' <span class="endnote-text">' . $fn['text'] . '</span>']; |
|
|
|
|
|
|
|
$note_build['footnote-link'] = Link::fromTextAndUrl($fn['value'], $url)->toRenderable(); |
|
|
|
|
|
|
|
if (!empty($reference_entity_id)) { |
|
|
|
|
|
|
|
$citation_build = $citation_tools->getRenderableReference($reference_entity_id); |
|
|
|
|
|
|
|
$note_build[] = $citation_build; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$note_item = [] + $item; |
|
|
|
|
|
|
|
$note_item['#markup'] = render($note_build); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$notes['#items'][] = $note_item; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($reference_entity_id)) { |
|
|
|
if (!empty($reference_entity_id)) { |
|
|
|
$citation_build = $citation_tools->getRenderableReference($reference_entity_id); |
|
|
|
$citation_build = $citation_tools->getRenderableReference($reference_entity_id); |
|
|
|
|
|
|
|
|
|
|
|
$build[] = $citation_build; |
|
|
|
$build[] = $citation_build; |
|
|
|
$render = render($build); |
|
|
|
$render = render($build); |
|
|
|
$item['#markup'] = $render; |
|
|
|
$item['#markup'] = $render; |
|
|
@ -108,13 +122,7 @@ function bibcite_footnotes_preprocess_footnote_list(&$variables) { |
|
|
|
$references['#items'][] = $item; |
|
|
|
$references['#items'][] = $item; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
|
$build[] = ['#type' => 'markup', '#markup' => ' ' . $fn['text']]; |
|
|
|
|
|
|
|
$render = render($build); |
|
|
|
|
|
|
|
$item['#markup'] = $render; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$notes['#items'][] = $item; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$variables['notes'] = $notes; |
|
|
|
$variables['notes'] = $notes; |
|
|
@ -125,15 +133,6 @@ function bibcite_footnotes_preprocess_footnote_list(&$variables) { |
|
|
|
$variables['references'] = $references; |
|
|
|
$variables['references'] = $references; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param $text The text of the bibcite reference placeholder. |
|
|
|
|
|
|
|
* @return Entity id of the Reference. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
function _bibcite_footnotes_get_reference_entity_id_from_bibcite_footnote($text){ |
|
|
|
|
|
|
|
preg_match('/\[bibcite_reference:(\d*)\]/', $text, $matches); |
|
|
|
|
|
|
|
return $matches[1]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _bibcite_footnotes_reference_array_cmp($a, $b) { |
|
|
|
function _bibcite_footnotes_reference_array_cmp($a, $b) { |
|
|
|
$a1 = (!empty($a['sort']) ? strtolower($a['sort']) : ''); |
|
|
|
$a1 = (!empty($a['sort']) ? strtolower($a['sort']) : ''); |
|
|
|
$b1 = (!empty($b['sort']) ? strtolower($b['sort']) : ''); |
|
|
|
$b1 = (!empty($b['sort']) ? strtolower($b['sort']) : ''); |
|
|
@ -149,7 +148,7 @@ function bibcite_footnotes_preprocess_footnote_link(&$variables) { |
|
|
|
$class = 'see-footnote'; |
|
|
|
$class = 'see-footnote'; |
|
|
|
// Generate the hover text |
|
|
|
// Generate the hover text |
|
|
|
$citation_tools = new CitationTools(); |
|
|
|
$citation_tools = new CitationTools(); |
|
|
|
$citation_entity_id = _bibcite_footnotes_get_reference_entity_id_from_bibcite_footnote($fn['text']); |
|
|
|
$citation_entity_id = $fn['reference']; |
|
|
|
$citation_data = $citation_tools->getRenderableReference($citation_entity_id); |
|
|
|
$citation_data = $citation_tools->getRenderableReference($citation_entity_id); |
|
|
|
|
|
|
|
|
|
|
|
// Citation contains a page reference, so construct parenthetical footnote. |
|
|
|
// Citation contains a page reference, so construct parenthetical footnote. |
|
|
|