From bfbe18b8b18784f87c3080e0389eed7cf1738907 Mon Sep 17 00:00:00 2001 From: Bozana Bokan Date: Mon, 13 Jan 2025 14:49:13 +0100 Subject: [PATCH] adapt DublicCoreMetaPlugin --- .../dublinCoreMeta/DublinCoreMetaPlugin.php | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/plugins/generic/dublinCoreMeta/DublinCoreMetaPlugin.php b/plugins/generic/dublinCoreMeta/DublinCoreMetaPlugin.php index 0dd68da310..1e1088c976 100644 --- a/plugins/generic/dublinCoreMeta/DublinCoreMetaPlugin.php +++ b/plugins/generic/dublinCoreMeta/DublinCoreMetaPlugin.php @@ -209,6 +209,7 @@ public function monographFileView($hookName, $args) $press = $request->getContext(); $publicationLocale = $publication->getData('locale'); + $publicationFormatLocale = $publicationFormat->getData('locale'); $submissionBestId = strlen($urlPath = (string) $publication->getData('urlPath')) ? $urlPath : $monograph->getId(); $templateMgr = TemplateManager::getManager($request); @@ -235,7 +236,11 @@ public function monographFileView($hookName, $args) $authors = $chapter ? $chapter->getAuthors()->toArray() : $publication->getData('authors'); foreach ($authors as $i => $author) { - $templateMgr->addHeader('dublinCoreAuthor' . $i++, ''); + $authorPreferedLocale = $publicationFormatLocale; + if (!$author->getGivenName($authorPreferedLocale)) { + $authorPreferedLocale = $publicationLocale; + } + $templateMgr->addHeader('dublinCoreAuthor' . $i++, ''); } $datePublished = $chapter @@ -278,9 +283,13 @@ public function monographFileView($hookName, $args) $templateMgr->addHeader('dublinCoreUri', ''); - $templateMgr->addHeader('dublinCoreLanguage', ''); + $templateMgr->addHeader('dublinCoreLanguage', ''); - if (($copyrightHolder = $publication->getData('copyrightHolder', $publicationLocale)) && ($copyrightYear = $publication->getData('copyrightYear'))) { + $copyrightHolderPreferedLocale = $publicationFormatLocale; + if (!$publication->getData('copyrightHolder', $copyrightHolderPreferedLocale)) { + $copyrightHolderPreferedLocale = $publicationLocale; + } + if (($copyrightHolder = $publication->getData('copyrightHolder', $copyrightHolderPreferedLocale)) && ($copyrightYear = $publication->getData('copyrightYear'))) { $templateMgr->addHeader('dublinCoreCopyright', ''); } if ($licenseURL = $publication->getData('licenseUrl')) { @@ -309,12 +318,16 @@ public function monographFileView($hookName, $args) } } - - $title = $chapter ? $chapter->getLocalizedFullTitle($publicationLocale) : $publication->getLocalizedFullTitle($publicationLocale); + $titlePreferredLocale = $publicationFormatLocale; + $titleTmp = $chapter ? $chapter->getDate('title', $titlePreferredLocale) : $publication->getData('title', $titlePreferredLocale); + if (!$titleTmp) { + $titlePreferredLocale = $publicationLocale; + } + $title = $chapter ? $chapter->getLocalizedFullTitle($titlePreferredLocale) : $publication->getLocalizedFullTitle($titlePreferredLocale); $templateMgr->addHeader('dublinCoreTitle', ''); $titles = $chapter ? $chapter->getFullTitles() : $publication->getFullTitles(); foreach ($titles as $locale => $altTitle) { - if ($title != '' && $locale != $publicationLocale) { + if ($title != '' && $locale != $titlePreferredLocale) { $templateMgr->addHeader('dublinCoreAltTitle' . $locale, ''); } }