Skip to content

Commit

Permalink
Merge pull request #19 from jyhein/f699
Browse files Browse the repository at this point in the history
pkp/pkp-lib#699 Show locale in url in multilingual contexts
  • Loading branch information
bozana authored Apr 25, 2024
2 parents d80e646 + 69d72dd commit 283aca0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions GoogleScholarPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use APP\submission\Submission;
use APP\template\TemplateManager;
use PKP\citation\CitationDAO;
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\plugins\GenericPlugin;
use PKP\plugins\Hook;
Expand Down Expand Up @@ -114,7 +115,7 @@ public function submissionView($hookName, $args)
$authors = $publication->getData('authors');
foreach ($authors as $i => $author) {
$templateMgr->addHeader('googleScholarAuthor' . $i, '<meta name="citation_author" content="' . htmlspecialchars($author->getFullName(false, false, $publicationLocale)) . '"/>');
if ($affiliation = htmlspecialchars($author->getLocalizedData('affiliation', $publicationLocale))) {
if ($affiliation = htmlspecialchars($author->getLocalizedData('affiliation', $publicationLocale) ?? "")) {
$templateMgr->addHeader('googleScholarAuthor' . $i . 'Affiliation', '<meta name="citation_author_institution" content="' . $affiliation . '"/>');
}
}
Expand Down Expand Up @@ -168,7 +169,7 @@ public function submissionView($hookName, $args)
}

// Abstract URL
$templateMgr->addHeader('googleScholarHtmlUrl', '<meta name="citation_abstract_html_url" content="' . $request->url(null, $submissionPath, 'view', [$submissionBestId]) . '"/>');
$templateMgr->addHeader('googleScholarHtmlUrl', '<meta name="citation_abstract_html_url" content="' . $request->getDispatcher()->url($request, PKPApplication::ROUTE_PAGE, null, $submissionPath, 'view', [$submissionBestId], urlLocaleForPage: '') . '"/>');

// Abstract
if ($abstract = $publication->getLocalizedData('abstract', $publicationLocale)) {
Expand Down Expand Up @@ -199,9 +200,9 @@ public function submissionView($hookName, $args)
$submissionFileId = $galley->getData('submissionFileId');
if ($submissionFileId && $submissionFile = Repo::submissionFile()->get($submissionFileId)) {
if ($submissionFile->getData('mimetype') == 'application/pdf') {
$templateMgr->addHeader('googleScholarPdfUrl' . $i++, '<meta name="citation_pdf_url" content="' . $request->url(null, $submissionPath, 'download', [$submissionBestId, $galley->getBestGalleyId()]) . '"/>');
$templateMgr->addHeader('googleScholarPdfUrl' . $i++, '<meta name="citation_pdf_url" content="' . $request->getDispatcher()->url($request, PKPApplication::ROUTE_PAGE, null, $submissionPath, 'download', [$submissionBestId, $galley->getBestGalleyId()], urlLocaleForPage: '') . '"/>');
} elseif ($submissionFile->getData('mimetype') == 'text/html') {
$templateMgr->addHeader('googleScholarHtmlUrl' . $i++, '<meta name="citation_fulltext_html_url" content="' . $request->url(null, $submissionPath, 'view', [$submissionBestId, $galley->getBestGalleyId()]) . '"/>');
$templateMgr->addHeader('googleScholarHtmlUrl' . $i++, '<meta name="citation_fulltext_html_url" content="' . $request->getDispatcher()->url($request, PKPApplication::ROUTE_PAGE, null, $submissionPath, 'view', [$submissionBestId, $galley->getBestGalleyId()], urlLocaleForPage: '') . '"/>');
}
}
}
Expand Down

0 comments on commit 283aca0

Please sign in to comment.