getEnabled($mainContextId)) { HookRegistry::register('ArticleHandler::view',array(&$this, 'articleView')); } return true; } return false; } /** * Get the name of the settings file to be installed on new context * creation. * @return string */ function getContextSpecificPluginSettingsFile() { return $this->getPluginPath() . '/settings.xml'; } /** * Inject Google Scholar metadata into article view * @param $hookName string * @param $args array * @return boolean */ function articleView($hookName, $args) { $request = $args[0]; $issue = $args[1]; $article = $args[2]; $journal = $request->getContext(); $templateMgr = TemplateManager::getManager($request); $templateMgr->addHeader('googleScholarRevision', ''); $templateMgr->addHeader('googleScholarJournalTitle', ''); if ($abbreviation = $journal->getSetting('abbreviation', $journal->getPrimaryLocale()) || $abbreviation = $journal->getSetting('acronym', $journal->getPrimaryLocale())) { $templateMgr->addHeader('googleScholarJournalAbbrev', ''); } if (($issn = $journal->getSetting('onlineIssn')) || ($issn = $journal->getSetting('printIssn')) || ($issn = $journal->getSetting('issn'))) { $templateMgr->addHeader('googleScholarIssn', ' '); } foreach ($article->getAuthors() as $i => $author) { $templateMgr->addHeader('googleScholarAuthor' . $i, 'getLastName()) . '"/>'); if ($affiliation = htmlspecialchars($author->getAffiliation($article->getLocale()))) { $templateMgr->addHeader('googleScholarAuthor' . $i . 'Affiliation', ''); } } $templateMgr->addHeader('googleScholarTitle', ''); if (is_a($article, 'PublishedArticle') && ($datePublished = $article->getDatePublished()) && (!$issue->getYear() || $issue->getYear() == strftime('%Y', strtotime($datePublished)))) { $templateMgr->addHeader('googleScholarDate', ''); } elseif ($issue && $issue->getYear()) { $templateMgr->addHeader('googleScholarDate', ''); } elseif ($issue && ($datePublished = $issue->getDatePublished())) { $templateMgr->addHeader('googleScholarDate', ''); } if ($issue) { if ($issue->getShowVolume()) $templateMgr->addHeader('googleScholarVolume', ''); if ($issue->getShowNumber()) $templateMgr->addHeader('googleScholarNumber', ''); } if ($article->getPages()) { if ($startPage = $article->getStartingPage()) $templateMgr->addHeader('googleScholarStartPage', ''); if ($endPage = $article->getEndingPage()) $templateMgr->addHeader('googleScholarEndPage', ''); } foreach((array) $templateMgr->get_template_vars('pubIdPlugins') as $pubIdPlugin) { if ($pubId = $article->getStoredPubId($pubIdPlugin->getPubIdType())) { $templateMgr->addHeader('googleScholarPubId' . $pubIdPlugin->getPubIdDisplayType(), ''); } } $templateMgr->addHeader('googleScholarHtmlUrl', ''); if ($language = $article->getLanguage()) $templateMgr->addHeader('googleScholarLanguage', ''); $i=0; $dao = DAORegistry::getDAO('SubmissionKeywordDAO'); $keywords = $dao->getKeywords($article->getId(), array(AppLocale::getLocale())); foreach ($keywords as $locale => $localeKeywords) { foreach ($localeKeywords as $keyword) { $templateMgr->addHeader('googleScholarKeyword' . $i++, ''); } } $i=$j=0; if (is_a($article, 'PublishedArticle')) foreach ($article->getGalleys() as $galley) { if (is_a($galley->getFile(), 'SupplementaryFile')) continue; if ($galley->getFileType()=='application/pdf') { $templateMgr->addHeader('googleScholarPdfUrl' . $i++, ''); } elseif ($galley->getFileType()=='text/html') { $templateMgr->addHeader('googleScholarHtmlUrl' . $i++, ''); } } return false; } /** * Get the display name of this plugin * @return string */ function getDisplayName() { return __('plugins.generic.googleScholar.name'); } /** * Get the description of this plugin * @return string */ function getDescription() { return __('plugins.generic.googleScholar.description'); } } ?>