addLocaleData(); return $success; } /** * Get the name of this plugin. The name must be unique within * its category. * @return String name of plugin */ function getName() { return 'AbntCitationPlugin'; } /** * @see Plugin::getDisplayName */ function getDisplayName() { return __('plugins.citationFormats.abnt.displayName'); } /** * @see CitationFormatPlugin::getCitationFormatName */ function getCitationFormatName() { return __('plugins.citationFormats.abnt.citationFormatName'); } /** * @see Plugin::getDescription */ function getDescription() { return __('plugins.citationFormats.abnt.description'); } /** * Get the localized location for citations in this journal * @param $journal Journal * @return string */ function getLocalizedLocation($journal) { $settings = $this->getSetting($journal->getId(), 'location'); if ($settings === null) { return null; } $location = $settings[AppLocale::getLocale()]; if (empty($location)) { $location = $settings[AppLocale::getPrimaryLocale()]; } return $location; } /** * Display verbs for the management interface. * @return array */ function getManagementVerbs() { return array( array( 'settings', __('plugins.citationFormats.abnt.manager.settings') ) ); } /** * Display an HTML-formatted citation. We register String::strtoupper modifier * in order to convert author names to uppercase. * @param $article Article * @param $issue Issue * @param $journal Journal */ function displayCitation(&$article, &$issue, &$journal) { $templateMgr =& TemplateManager::getManager(); $templateMgr->register_modifier('mb_upper', array('String', 'strtoupper')); return parent::displayCitation($article, $issue, $journal); } /** * Execute a management verb on this plugin * @param $verb string * @param $args array * @param $message string If a message is returned from this by-ref * argument then it will be displayed as a notification if (and only * if) the method returns false. * @return boolean will redirect to the plugin category page if false, * otherwise will remain on the same page */ function manage($verb, $args, &$message) { switch ($verb) { case 'settings': $templateMgr =& TemplateManager::getManager(); $templateMgr->register_function('plugin_url', array(&$this, 'smartyPluginUrl')); $journal =& Request::getJournal(); $this->import('AbntSettingsForm'); $form = new AbntSettingsForm($this, $journal->getId()); if (Request::getUserVar('save')) { $form->readInputData(); if ($form->validate()) { $form->execute(); Request::redirect(null, 'manager', 'plugin'); return false; } else { $this->setBreadCrumbs(true); $form->display(); } } else { $this->setBreadCrumbs(true); if ($form->isLocaleResubmit()) { $form->readInputData(); } else { $form->initData(); } $form->display(); } return true; default: // Unknown management verb, delegate to parent return parent::manage($verb, $args, $message); } } /** * Set the page's breadcrumbs, given the plugin's tree of items * to append. * @param $subclass boolean */ function setBreadcrumbs($isSubclass = false) { $templateMgr =& TemplateManager::getManager(); $pageCrumbs = array( array( Request::url(null, 'manager'), 'user.role.manager' ) ); if ($isSubclass) { $pageCrumbs[] = array( Request::url(null, 'manager', 'plugins'), 'manager.plugins' ); } $templateMgr->assign('pageHierarchy', $pageCrumbs); } /** * Extend the {url ...} smarty to support this plugin. */ function smartyPluginUrl($params, &$smarty) { $path = array($this->getCategory(), $this->getName()); if (is_array($params['path'])) { $params['path'] = array_merge($path, $params['path']); } elseif (!empty($params['path'])) { $params['path'] = array_merge($path, array($params['path'])); } else { $params['path'] = $path; } return $smarty->smartyUrl($params, $smarty); } } ?>