Skip to content

Commit

Permalink
Refactor bibliography check to use citeproc-php methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
aksm committed Nov 7, 2022
1 parent 6ff281d commit f7aa7a6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/CiteProc/Render.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ public function bibliography(string $locale, array $styleNames, array $jsonData)
$style_xml = simplexml_load_string($style);
$style_bibliography_exists = isset($style_xml->bibliography);

if($style_bibliography_exists) {
if ($available_locale) {
$citeProc = new CiteProc($style, $available_locale);
}
else {
$citeProc = new CiteProc($style);
}
if ($available_locale) {
$citeProc = new CiteProc($style, $available_locale);
}
else {
$citeProc = new CiteProc($style);
}
$citeProc->init();
$citeProcBibliography = $citeProc->getContext()->getBibliography();
if($citeProcBibliography !== null) {
$bibliography = $citeProc->render($jsonData, "bibliography");
$cssStyles = $citeProc->renderCssStyles();
$parsedStyle = $this->parseCSS($cssStyles);
Expand Down Expand Up @@ -126,7 +128,8 @@ public function bibliography(string $locale, array $styleNames, array $jsonData)
$style_title = $style_xml->info->title->__toString();
$select .= '<option value="' . $selected_style . '">' . $style_title . '</option>';
++$style_iterator;
} else {
}
else {
$message = 'The ' . $selected_style . ' CSL style wasn\'t rendered because it doesn\'t contain a bibliography node.' ;
\Drupal::logger('format_strawberryfield')->info($message);
}
Expand Down

0 comments on commit f7aa7a6

Please sign in to comment.