Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#699 Show locale in url in multilingual contexts #19

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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