diff --git a/GoogleScholarPlugin.inc.php b/GoogleScholarPlugin.inc.php
index dd29e30..08e09fd 100644
--- a/GoogleScholarPlugin.inc.php
+++ b/GoogleScholarPlugin.inc.php
@@ -15,7 +15,6 @@
use APP\core\Application;
use APP\facades\Repo;
-use APP\submission\Submission;
use APP\template\TemplateManager;
use PKP\db\DAORegistry;
use PKP\plugins\GenericPlugin;
@@ -105,7 +104,8 @@ public function submissionView($hookName, $args)
$submissionBestId = $publication->getData('urlPath') ?? $submission->getId();
// Contributors
- foreach ($publication->getData('authors') as $i => $author) {
+ $authors = $publication->getData('authors');
+ foreach ($authors as $i => $author) {
$templateMgr->addHeader('googleScholarAuthor' . $i, '');
if ($affiliation = htmlspecialchars($author->getLocalizedData('affiliation', $publicationLocale))) {
$templateMgr->addHeader('googleScholarAuthor' . $i . 'Affiliation', '');
@@ -114,11 +114,12 @@ public function submissionView($hookName, $args)
// Submission title
$templateMgr->addHeader('googleScholarTitle', '');
+
$templateMgr->addHeader('googleScholarLanguage', '');
// Submission publish date and issue information
if ($applicationName == 'ojs2') {
- if ($submission instanceof Submission && ($datePublished = $publication->getData('datePublished')) && (!$issue || !$issue->getYear() || $issue->getYear() == date('Y', strtotime($datePublished)))) {
+ if (($datePublished = $publication->getData('datePublished')) && (!$issue || !$issue->getYear() || $issue->getYear() == date('Y', strtotime($datePublished)))) {
$templateMgr->addHeader('googleScholarDate', '');
} elseif ($issue && $issue->getYear()) {
$templateMgr->addHeader('googleScholarDate', '');
@@ -143,7 +144,9 @@ public function submissionView($hookName, $args)
}
}
if ($applicationName == 'ops') {
- $templateMgr->addHeader('googleScholarDate', '');
+ if ($datePublished = $publication->getData('datePublished')) {
+ $templateMgr->addHeader('googleScholarDate', '');
+ }
}
// DOI
@@ -166,34 +169,28 @@ public function submissionView($hookName, $args)
}
// Subjects
- $i = 0;
- $submissionSubjectDao = DAORegistry::getDAO('SubmissionSubjectDAO');
- /** @var SubmissionSubjectDAO $submissionSubjectDao */
- if ($subjects = $submissionSubjectDao->getSubjects($publication->getId(), [$publicationLocale])) {
- foreach ($subjects as $locale => $subjectLocale) {
- foreach ($subjectLocale as $gsKeyword) {
- $templateMgr->addHeader('googleScholarSubject' . $i++, '');
+ if ($subjects = $publication->getData('subjects')) {
+ foreach ($subjects as $locale => $localeSubjects) {
+ foreach ($localeSubjects as $i => $subject) {
+ $templateMgr->addHeader('googleScholarSubject' . $i++, '');
}
}
}
// Keywords
- $i = 0;
- $submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO');
- /** @var SubmissionKeywordDAO $submissionKeywordDao */
- if ($keywords = $submissionKeywordDao->getKeywords($publication->getId(), [$publicationLocale])) {
- foreach ($keywords as $locale => $keywordLocale) {
- foreach ($keywordLocale as $gsKeyword) {
- $templateMgr->addHeader('googleScholarKeyword' . $i++, '');
+ if ($keywords = $publication->getData('keywords')) {
+ foreach ($keywords as $locale => $localeKeywords) {
+ foreach ($localeKeywords as $i => $keyword) {
+ $templateMgr->addHeader('googleScholarKeyword' . $i++, '');
}
}
}
// Galley links
- $i = 0;
- if ($submission instanceof Submission) {
- foreach ($publication->getData('galleys') as $galley) {
- $submissionFile = Repo::submissionFile()->get($galley->getData('submissionFileId'));
+ $galleys = $publication->getData('galleys');
+ foreach ($galleys as $i => $galley) {
+ $submissionFileId = $galley->getData('submissionFileId');
+ if ($submissionFileId && $submissionFile = Repo::submissionFile()->get($submissionFileId)) {
if ($submissionFile->getData('mimetype') == 'application/pdf') {
$templateMgr->addHeader('googleScholarPdfUrl' . $i++, '');
} elseif ($submissionFile->getData('mimetype') == 'text/html') {
@@ -211,11 +208,8 @@ public function submissionView($hookName, $args)
}
Hook::call('GoogleScholarPlugin::references', [&$outputReferences, $submission->getId()]);
- if (!empty($outputReferences)) {
- $i = 0;
- foreach ($outputReferences as $outputReference) {
- $templateMgr->addHeader('googleScholarReference' . $i++, '');
- }
+ foreach ($outputReferences as $i => $outputReference) {
+ $templateMgr->addHeader('googleScholarReference' . $i++, '');
}
return false;