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 Dublin Core 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('dublinCoreSchema', '');
$i=0;
if ($sponsors = $article->getSponsor(null)) foreach ($sponsors as $locale => $sponsor) {
$templateMgr->addHeader('dublinCoreSponsor' . $i++, '');
}
$i=0;
if ($coverages = $article->getCoverage(null)) foreach($coverages as $locale => $coverage) {
$templateMgr->addHeader('dublinCoreCoverage' . $i++, '');
}
$i=0;
foreach (explode(', ', $article->getAuthorString()) as $author) {
$templateMgr->addHeader('dublinCoreAuthor' . $i++, '');
}
if (is_a($article, 'PublishedArticle') && ($datePublished = $article->getDatePublished())) {
$templateMgr->addHeader('dublinCoreDateCreated', '');
}
$templateMgr->addHeader('dublinCoreDateSubmitted', '');
if ($issue && ($datePublished = $issue->getDatePublished())) {
$templateMgr->addHeader('dublinCoreDateIssued', '');
}
if ($dateModified = $article->getDateStatusModified()) $templateMgr->addHeader('dublinCoreDateModified', '');
$i=0;
if ($abstracts = $article->getAbstract(null)) foreach($abstracts as $locale => $abstract) {
$templateMgr->addHeader('dublinCoreAbstract' . $i++, '');
}
$i=0;
if (is_a($article, 'PublishedArticle')) foreach($article->getGalleys() as $galley) {
if (is_a($galley, 'SupplementaryFile')) continue;
$templateMgr->addHeader('dublinCoreFormat' . $i++, '');
}
$templateMgr->addHeader('dublinCoreIdentifier', '');
if ($pages = $article->getPages()) {
$templateMgr->addHeader('dublinCorePages', '');
}
foreach((array) $templateMgr->get_template_vars('pubIdPlugins') as $pubIdPlugin) {
if ($pubId = $article->getStoredPubId($pubIdPlugin->getPubIdType())) {
$templateMgr->addHeader('dublinCorePubId' . $pubIdPlugin->getPubIdDisplayType(), '');
}
}
$templateMgr->addHeader('dublinCoreUri', '');
$templateMgr->addHeader('dublinCoreLanguage', '');
$templateMgr->addHeader('dublinCoreCopyright', '');
$templateMgr->addHeader('dublinCorePagesLicenseUrl', '');
$templateMgr->addHeader('dublinCoreSource', '');
if (($issn = $journal->getSetting('onlineIssn')) || ($issn = $journal->getSetting('printIssn')) || ($issn = $journal->getSetting('issn'))) {
$templateMgr->addHeader('dublinCoreIssn', '');
}
if ($issue) {
if ($issue->getShowNumber()) $templateMgr->addHeader('dublinCoreIssue', '');
if ($issue->getShowVolume()) $templateMgr->addHeader('dublinCoreVolume', '');
}
$templateMgr->addHeader('dublinCoreSourceUri', '');
$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('dublinCoreSubject' . $i++, '');
}
}
$templateMgr->addHeader('dublinCoreTitle', '');
$i=0;
foreach ($article->getTitle(null) as $locale => $title) {
if ($locale == $article->getLocale()) continue;
$templateMgr->addHeader('dublinCoreAltTitle' . $i++, '');
}
$templateMgr->addHeader('dublinCoreType', '');
$i=0;
if ($types = $article->getType(null)) foreach($types as $locale => $type) {
$templateMgr->addHeader('dublinCoreType' . $i++, '');
}
$sectionDao = DAORegistry::getDAO('SectionDAO');
$section = $sectionDao->getById($article->getSectionId());
$templateMgr->addHeader('dublinCoreArticleType', '');
return false;
}
/**
* Get the display name of this plugin
* @return string
*/
function getDisplayName() {
return __('plugins.generic.dublinCoreMeta.name');
}
/**
* Get the description of this plugin
* @return string
*/
function getDescription() {
return __('plugins.generic.dublinCoreMeta.description');
}
}
?>