Skip to content

Commit

Permalink
adapt DublicCoreMetaPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
bozana committed Jan 13, 2025
1 parent 9062f93 commit bfbe18b
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions plugins/generic/dublinCoreMeta/DublinCoreMetaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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++, '<meta name="DC.Creator.PersonalName" content="' . htmlspecialchars($author->getFullName(false, false, $publicationLocale)) . '"/>');
$authorPreferedLocale = $publicationFormatLocale;
if (!$author->getGivenName($authorPreferedLocale)) {
$authorPreferedLocale = $publicationLocale;
}
$templateMgr->addHeader('dublinCoreAuthor' . $i++, '<meta name="DC.Creator.PersonalName" content="' . htmlspecialchars($author->getFullName(false, false, $authorPreferedLocale)) . '"/>');
}

$datePublished = $chapter
Expand Down Expand Up @@ -278,9 +283,13 @@ public function monographFileView($hookName, $args)

$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: '') . '"/>');

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

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', '<meta name="DC.Rights" content="' . htmlspecialchars(__('submission.copyrightStatement', ['copyrightHolder' => $copyrightHolder, 'copyrightYear' => $copyrightYear])) . '"/>');
}
if ($licenseURL = $publication->getData('licenseUrl')) {
Expand Down Expand Up @@ -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', '<meta name="DC.Title" content="' . htmlspecialchars($title) . '"/>');
$titles = $chapter ? $chapter->getFullTitles() : $publication->getFullTitles();
foreach ($titles as $locale => $altTitle) {
if ($title != '' && $locale != $publicationLocale) {
if ($title != '' && $locale != $titlePreferredLocale) {
$templateMgr->addHeader('dublinCoreAltTitle' . $locale, '<meta name="DC.Title.Alternative" xml:lang="' . htmlspecialchars(str_replace(['_', '@'], '-', $locale)) . '" content="' . htmlspecialchars($altTitle) . '"/>');
}
}
Expand Down

0 comments on commit bfbe18b

Please sign in to comment.