Skip to content

Commit bfbe18b

Browse files
committed
adapt DublicCoreMetaPlugin
1 parent 9062f93 commit bfbe18b

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

plugins/generic/dublinCoreMeta/DublinCoreMetaPlugin.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ public function monographFileView($hookName, $args)
209209
$press = $request->getContext();
210210

211211
$publicationLocale = $publication->getData('locale');
212+
$publicationFormatLocale = $publicationFormat->getData('locale');
212213
$submissionBestId = strlen($urlPath = (string) $publication->getData('urlPath')) ? $urlPath : $monograph->getId();
213214

214215
$templateMgr = TemplateManager::getManager($request);
@@ -235,7 +236,11 @@ public function monographFileView($hookName, $args)
235236

236237
$authors = $chapter ? $chapter->getAuthors()->toArray() : $publication->getData('authors');
237238
foreach ($authors as $i => $author) {
238-
$templateMgr->addHeader('dublinCoreAuthor' . $i++, '<meta name="DC.Creator.PersonalName" content="' . htmlspecialchars($author->getFullName(false, false, $publicationLocale)) . '"/>');
239+
$authorPreferedLocale = $publicationFormatLocale;
240+
if (!$author->getGivenName($authorPreferedLocale)) {
241+
$authorPreferedLocale = $publicationLocale;
242+
}
243+
$templateMgr->addHeader('dublinCoreAuthor' . $i++, '<meta name="DC.Creator.PersonalName" content="' . htmlspecialchars($author->getFullName(false, false, $authorPreferedLocale)) . '"/>');
239244
}
240245

241246
$datePublished = $chapter
@@ -278,9 +283,13 @@ public function monographFileView($hookName, $args)
278283

279284
$templateMgr->addHeader('dublinCoreUri', '<meta name="DC.Identifier.URI" content="' . $request->getDispatcher()->url($request, Application::ROUTE_PAGE, null, 'catalog', 'book', [$submissionBestId, $publicationFormat->getId(), $submissionFile->getId()], urlLocaleForPage: '') . '"/>');
280285

281-
$templateMgr->addHeader('dublinCoreLanguage', '<meta name="DC.Language" scheme="ISO639-1" content="' . str_replace(['_', '@'], '-', $publicationLocale) . '"/>');
286+
$templateMgr->addHeader('dublinCoreLanguage', '<meta name="DC.Language" scheme="ISO639-1" content="' . str_replace(['_', '@'], '-', $publicationFormatLocale) . '"/>');
282287

283-
if (($copyrightHolder = $publication->getData('copyrightHolder', $publicationLocale)) && ($copyrightYear = $publication->getData('copyrightYear'))) {
288+
$copyrightHolderPreferedLocale = $publicationFormatLocale;
289+
if (!$publication->getData('copyrightHolder', $copyrightHolderPreferedLocale)) {
290+
$copyrightHolderPreferedLocale = $publicationLocale;
291+
}
292+
if (($copyrightHolder = $publication->getData('copyrightHolder', $copyrightHolderPreferedLocale)) && ($copyrightYear = $publication->getData('copyrightYear'))) {
284293
$templateMgr->addHeader('dublinCoreCopyright', '<meta name="DC.Rights" content="' . htmlspecialchars(__('submission.copyrightStatement', ['copyrightHolder' => $copyrightHolder, 'copyrightYear' => $copyrightYear])) . '"/>');
285294
}
286295
if ($licenseURL = $publication->getData('licenseUrl')) {
@@ -309,12 +318,16 @@ public function monographFileView($hookName, $args)
309318
}
310319
}
311320

312-
313-
$title = $chapter ? $chapter->getLocalizedFullTitle($publicationLocale) : $publication->getLocalizedFullTitle($publicationLocale);
321+
$titlePreferredLocale = $publicationFormatLocale;
322+
$titleTmp = $chapter ? $chapter->getDate('title', $titlePreferredLocale) : $publication->getData('title', $titlePreferredLocale);
323+
if (!$titleTmp) {
324+
$titlePreferredLocale = $publicationLocale;
325+
}
326+
$title = $chapter ? $chapter->getLocalizedFullTitle($titlePreferredLocale) : $publication->getLocalizedFullTitle($titlePreferredLocale);
314327
$templateMgr->addHeader('dublinCoreTitle', '<meta name="DC.Title" content="' . htmlspecialchars($title) . '"/>');
315328
$titles = $chapter ? $chapter->getFullTitles() : $publication->getFullTitles();
316329
foreach ($titles as $locale => $altTitle) {
317-
if ($title != '' && $locale != $publicationLocale) {
330+
if ($title != '' && $locale != $titlePreferredLocale) {
318331
$templateMgr->addHeader('dublinCoreAltTitle' . $locale, '<meta name="DC.Title.Alternative" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($altTitle) . '"/>');
319332
}
320333
}

0 commit comments

Comments
 (0)