From 336bb8e48bd30559f93e2b25aeeb040414ea6186 Mon Sep 17 00:00:00 2001 From: Gregor Gawol <gawol@ub.uni-leipzig.de> Date: Fri, 19 Mar 2021 12:08:17 +0100 Subject: [PATCH] refs #18674 [master] citation, also display years with square brackets * improve apa template --- module/finc/src/finc/View/Helper/Root/Citation.php | 4 +++- themes/finc/templates/Citation/apa.phtml | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/module/finc/src/finc/View/Helper/Root/Citation.php b/module/finc/src/finc/View/Helper/Root/Citation.php index b855634ccfe..9d98f00cb57 100644 --- a/module/finc/src/finc/View/Helper/Root/Citation.php +++ b/module/finc/src/finc/View/Helper/Root/Citation.php @@ -502,7 +502,9 @@ class Citation extends \VuFind\View\Helper\Root\Citation protected function getYear() { if (isset($this->details['pubDate'])) { - if (strlen($this->details['pubDate']) > 4) { + if ((strlen($this->details['pubDate']) > 4) + && !preg_match("/^\[\d+\]/", $this->details['pubDate']) + ) { try { return $this->dateConverter->convertFromDisplayDate( 'Y', diff --git a/themes/finc/templates/Citation/apa.phtml b/themes/finc/templates/Citation/apa.phtml index 1b40871412d..cdda373c4b6 100644 --- a/themes/finc/templates/Citation/apa.phtml +++ b/themes/finc/templates/Citation/apa.phtml @@ -1,5 +1,11 @@ <?php if (!empty($this->authors)): ?><?=$this->escapeHtml($this->authors)?> - <?php if (!empty($this->year)): ?><?php if (!empty($this->authors)): ?><?php endif; ?>(<?=$this->escapeHtml($this->year)?>). <?php endif; ?> + <?php if (!empty($this->year)): ?> + <?php if (!preg_match("/^\[\d+\]/", $this->year)): ?> + (<?=$this->escapeHtml($this->year)?>). + <?php else: ?> + <?=$this->escapeHtml($this->year)?>. + <?php endif; ?> + <?php endif; ?> <?php endif; ?> <i><?=$this->escapeHtml($this->title)?></i><?php if ($this->periodAfterTitle): ?>. <?php endif ?> <?php if (empty($this->authors)): ?> -- GitLab