getEnabled($mainContextId)) { HookRegistry::register('TemplateManager::display',array($this, 'callbackAddLinks')); $this->import('WebFeedBlockPlugin'); $blockPlugin = new WebFeedBlockPlugin($this); PluginRegistry::register('blocks', $blockPlugin, $this->getPluginPath()); $this->import('WebFeedGatewayPlugin'); $gatewayPlugin = new WebFeedGatewayPlugin($this); PluginRegistry::register('gateways', $gatewayPlugin, $this->getPluginPath()); $this->_registerTemplateResource(); } return true; } return false; } /** * Get the name of the settings file to be installed on new context * creation. * @return string */ public function getContextSpecificPluginSettingsFile() { return $this->getPluginPath() . '/settings.xml'; } /** * @copydoc PKPPlugin::getTemplatePath */ public function getTemplatePath($inCore = false) { return $this->getTemplateResourceName() . ':templates/'; } /** * Add feed links to page
on select/all pages. */ public function callbackAddLinks($hookName, $args) { // Only page requests will be handled $request = $this->getRequest(); if (!is_a($request->getRouter(), 'PKPPageRouter')) return false; $templateManager =& $args[0]; $currentJournal = $templateManager->get_template_vars('currentJournal'); if (is_null($currentJournal)) { return; } $issueDao = DAORegistry::getDAO('IssueDAO'); $currentIssue = $issueDao->getCurrent($currentJournal->getId(), true); if (!$currentIssue) { return; } $displayPage = $this->getSetting($currentJournal->getId(), 'displayPage'); // Define when the elements should appear $contexts = 'frontend'; if ($displayPage == 'homepage') { $contexts = array('frontend-index', 'frontend-issue'); } elseif ($displayPage == 'issue') { $contexts = 'frontend-issue'; } $templateManager->addHeader( 'webFeedAtom+xml', '', array( 'contexts' => $contexts, ) ); $templateManager->addHeader( 'webFeedRdf+xml', '', array( 'contexts' => $contexts, ) ); $templateManager->addHeader( 'webFeedRss+xml', '', array( 'contexts' => $contexts, ) ); return false; } /** * @copydoc Plugin::getActions() */ public function getActions($request, $verb) { $router = $request->getRouter(); import('lib.pkp.classes.linkAction.request.AjaxModal'); return array_merge( $this->getEnabled()?array( new LinkAction( 'settings', new AjaxModal( $router->url($request, null, null, 'manage', null, array('verb' => 'settings', 'plugin' => $this->getName(), 'category' => 'generic')), $this->getDisplayName() ), __('manager.plugins.settings'), null ), ):array(), parent::getActions($request, $verb) ); } /** * @copydoc Plugin::manage() */ public function manage($args, $request) { switch ($request->getUserVar('verb')) { case 'settings': AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON, LOCALE_COMPONENT_PKP_MANAGER); $this->import('WebFeedSettingsForm'); $form = new WebFeedSettingsForm($this, $request->getContext()->getId()); if ($request->getUserVar('save')) { $form->readInputData(); if ($form->validate()) { $form->execute(); $notificationManager = new NotificationManager(); $notificationManager->createTrivialNotification($request->getUser()->getId()); return new JSONMessage(true); } } else { $form->initData(); } return new JSONMessage(true, $form->fetch($request)); } return parent::manage($args, $request); } }