Skip to content

Commit

Permalink
Check for bibliography node in style XML and only add to list if it e…
Browse files Browse the repository at this point in the history
…xists.
  • Loading branch information
aksm committed Nov 7, 2022
1 parent ee110da commit 4dbcfdf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Plugin/Field/FieldFormatter/StrawberryCitationFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,16 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
$citation_style_directory = $this->cslStylesPath;
// Get the list of style files.
$style_list = $this->fileSystem->scanDirectory($citation_style_directory, '/\.(csl)$/i', ['recurse' => FALSE, 'key' => 'name']);
# Generate a list of select options and push in the styles.
// Generate a list of select options and push in the styles.
foreach($style_list as $style) {
$style_name = $style->name;
$style_xml = simplexml_load_file($style->uri);
$style_title = $style_xml->info->title->__toString();
$style_options[$style_name] = $this->t($style_title);
// Check if the bibliography node exists and only add to the list if it does.
$style_bibliography_exists = isset($style_xml->bibliography);
if($style_bibliography_exists) {
$style_title = $style_xml->info->title->__toString();
$style_options[$style_name] = $this->t($style_title);
}
}
// Alphabetize them.
asort($style_options);
Expand Down

0 comments on commit 4dbcfdf

Please sign in to comment.