16 import(
'lib.pkp.classes.plugins.GenericPlugin');
22 function register($category, $path, $mainContextId =
null) {
23 if (parent::register($category, $path, $mainContextId)) {
52 if ($applicationName ==
"ojs2"){
54 $submission = $args[2];
55 $submissionPath =
'article';
57 if ($applicationName ==
"ops"){
58 $submission = $args[1];
59 $submissionPath =
'preprint';
61 $requestArgs =
$request->getRequestedArgs();
66 if (count($requestArgs) > 1 && $requestArgs[1] ===
'version') {
71 $templateMgr->addHeader(
'googleScholarRevision',
'<meta name="gs_meta_revision" content="1.1"/>');
74 if ($applicationName ==
"ojs2"){
75 $templateMgr->addHeader(
'googleScholarJournalTitle',
'<meta name="citation_journal_title" content="' . htmlspecialchars($context->getName($context->getPrimaryLocale())) .
'"/>');
76 if (($abbreviation = $context->getData(
'abbreviation', $context->getPrimaryLocale())) || ($abbreviation = $context->getData(
'acronym', $context->getPrimaryLocale()))) {
77 $templateMgr->addHeader(
'googleScholarJournalAbbrev',
'<meta name="citation_journal_abbrev" content="' . htmlspecialchars($abbreviation) .
'"/>');
79 if ( ($issn = $context->getData(
'onlineIssn')) || ($issn = $context->getData(
'printIssn')) || ($issn = $context->getData(
'issn'))) {
80 $templateMgr->addHeader(
'googleScholarIssn',
'<meta name="citation_issn" content="' . htmlspecialchars($issn) .
'"/> ');
83 if ($applicationName ==
"ops"){
84 $templateMgr->addHeader(
'googleScholarPublisher',
'<meta name="citation_publisher" content="' . htmlspecialchars($context->getName($context->getPrimaryLocale())) .
'"/>');
89 foreach ($submission->getAuthors() as $i => $author) {
90 $templateMgr->addHeader(
'googleScholarAuthor' . $i,
'<meta name="citation_author" content="' . htmlspecialchars($author->getFullName(
false)) .
'"/>');
91 if ($affiliation = htmlspecialchars($author->getAffiliation($submission->getLocale()))) {
92 $templateMgr->addHeader(
'googleScholarAuthor' . $i .
'Affiliation',
'<meta name="citation_author_institution" content="' . $affiliation .
'"/>');
97 $templateMgr->addHeader(
'googleScholarTitle',
'<meta name="citation_title" content="' . htmlspecialchars($submission->getFullTitle($submission->getLocale())) .
'"/>');
98 if ($locale = $submission->getLocale()) $templateMgr->addHeader(
'googleScholarLanguage',
'<meta name="citation_language" content="' . htmlspecialchars(substr($locale, 0, 2)) .
'"/>');
101 if ($applicationName ==
"ojs2"){
102 if (is_a($submission,
'Submission') && ($datePublished = $submission->getDatePublished()) && (!$issue->getYear() || $issue->getYear() == strftime(
'%Y', strtotime($datePublished)))) {
103 $templateMgr->addHeader(
'googleScholarDate',
'<meta name="citation_date" content="' . strftime(
'%Y/%m/%d', strtotime($datePublished)) .
'"/>');
104 } elseif ($issue && $issue->getYear()) {
105 $templateMgr->addHeader(
'googleScholarDate',
'<meta name="citation_date" content="' . htmlspecialchars($issue->getYear()) .
'"/>');
106 } elseif ($issue && ($datePublished = $issue->getDatePublished())) {
107 $templateMgr->addHeader(
'googleScholarDate',
'<meta name="citation_date" content="' . strftime(
'%Y/%m/%d', strtotime($datePublished)) .
'"/>');
110 if ($issue->getShowVolume()) $templateMgr->addHeader(
'googleScholarVolume',
'<meta name="citation_volume" content="' . htmlspecialchars($issue->getVolume()) .
'"/>');
111 if ($issue->getShowNumber()) $templateMgr->addHeader(
'googleScholarNumber',
'<meta name="citation_issue" content="' . htmlspecialchars($issue->getNumber()) .
'"/>');
113 if ($submission->getPages()) {
114 if ($startPage = $submission->getStartingPage()) $templateMgr->addHeader(
'googleScholarStartPage',
'<meta name="citation_firstpage" content="' . htmlspecialchars($startPage) .
'"/>');
115 if ($endPage = $submission->getEndingPage()) $templateMgr->addHeader(
'googleScholarEndPage',
'<meta name="citation_lastpage" content="' . htmlspecialchars($endPage) .
'"/>');
118 if ($applicationName ==
"ops"){
119 $templateMgr->addHeader(
'googleScholarDate',
'<meta name="citation_online_date" content="' . strftime(
'%Y/%m/%d', strtotime($submission->getDatePublished())) .
'"/>');
123 foreach((array) $templateMgr->getTemplateVars(
'pubIdPlugins') as $pubIdPlugin) {
124 if ($pubId = $submission->getStoredPubId($pubIdPlugin->getPubIdType())) {
125 $templateMgr->addHeader(
'googleScholarPubId' . $pubIdPlugin->getPubIdDisplayType(),
'<meta name="citation_' . htmlspecialchars(strtolower($pubIdPlugin->getPubIdDisplayType())) .
'" content="' . htmlspecialchars($pubId) .
'"/>');
130 $templateMgr->addHeader(
'googleScholarHtmlUrl',
'<meta name="citation_abstract_html_url" content="' .
$request->url(
null, $submissionPath,
'view', array($submission->getBestId())) .
'"/>');
134 $keywords = $dao->getKeywords($submission->getCurrentPublication()->getId(), array(
AppLocale::getLocale()));
135 foreach ($keywords as $locale => $localeKeywords) {
136 foreach ($localeKeywords as $keyword) {
137 $templateMgr->addHeader(
'googleScholarKeyword' . $i++,
'<meta name="citation_keywords" xml:lang="' . htmlspecialchars(substr($locale, 0, 2)) .
'" content="' . htmlspecialchars($keyword) .
'"/>');
143 if (is_a($submission,
'Submission'))
foreach ($submission->getGalleys() as $galley) {
144 if (is_a($galley->getFile(),
'SupplementaryFile'))
continue;
145 if ($galley->getFileType()==
'application/pdf') {
146 $templateMgr->addHeader(
'googleScholarPdfUrl' . $i++,
'<meta name="citation_pdf_url" content="' .
$request->url(
null, $submissionPath,
'download', array($submission->getBestId(), $galley->getBestGalleyId())) .
'"/>');
147 } elseif ($galley->getFileType()==
'text/html') {
148 $templateMgr->addHeader(
'googleScholarHtmlUrl' . $i++,
'<meta name="citation_fulltext_html_url" content="' .
$request->url(
null, $submissionPath,
'view', array($submission->getBestId(), $galley->getBestGalleyId())) .
'"/>');
153 $outputReferences = array();
155 $parsedCitations = $citationDao->getByPublicationId($submission->getCurrentPublication()->getId());
156 if ($parsedCitations->getCount()){
157 while ($citation = $parsedCitations->next()) {
158 $outputReferences[] = $citation->getRawCitation();
161 HookRegistry::call(
'GoogleScholarPlugin::references', array(&$outputReferences, $submission->getId()));
163 if (!empty($outputReferences)){
165 foreach ($outputReferences as $outputReference) {
166 $templateMgr->addHeader(
'googleScholarReference' . $i++,
'<meta name="citation_reference" content="' . htmlspecialchars($outputReference) .
'"/>');
178 return __(
'plugins.generic.googleScholar.name');
186 return __(
'plugins.generic.googleScholar.description');