getEnabled($mainContextId)) { // Register callback for Smarty filters; add CSS HookRegistry::register('TemplateManager::display', array($this, 'handleTemplateDisplay')); // Insert ORCID callback HookRegistry::register('LoadHandler', array($this, 'setupCallbackHandler')); // Handle ORCID on user registration HookRegistry::register('registrationform::execute', array($this, 'collectUserOrcidId')); // Send emails to authors without ORCID id upon submission HookRegistry::register('Author::Form::Submit::AuthorSubmitStep3Form::Execute', array($this, 'collectAuthorOrcidId')); // Add ORCiD hash to author DAO HookRegistry::register('authordao::getAdditionalFieldNames', array($this, 'authorSubmitGetFieldNames')); $this->_registerTemplateResource(); } return $success; } /** * Get page handler path for this plugin. * @return string Path to plugin's page handler */ function getHandlerPath() { return $this->getPluginPath() . DIRECTORY_SEPARATOR . 'pages'; } /** * Hook callback: register pages for each sushi-lite method * This URL is of the form: orcidapi/{$orcidrequest} * @see PKPPageRouter::route() */ function setupCallbackHandler($hookName, $params) { $page = $params[0]; if ($this->getEnabled() && $page == 'orcidapi') { $this->import('pages/OrcidHandler'); define('HANDLER_CLASS', 'OrcidHandler'); return true; } return false; } /** * Hook callback: register output filter to add data citation to submission * summaries; add data citation to reading tools' suppfiles and metadata views. * @see TemplateManager::display() */ function handleTemplateDisplay($hookName, $args) { $templateMgr =& $args[0]; $template =& $args[1]; $request = PKPApplication::getRequest(); // Assign our private stylesheet, for front and back ends. $templateMgr->addStyleSheet( 'orcidProfile', $request->getBaseUrl() . '/' . $this->getStyleSheet(), array( 'contexts' => array('frontend', 'backend') ) ); switch ($template) { case 'frontend/pages/userRegister.tpl': $templateMgr->register_outputfilter(array($this, 'registrationFilter')); break; case 'frontend/pages/article.tpl': $templateMgr->assign('orcidIcon', $this->getIcon()); break; case 'user/publicProfileForm.tpl': $templateMgr->register_outputfilter(array($this, 'profileFilter')); break; } return false; } /** * Return the OAUTH path (prod or sandbox) based on the current API configuration * @return $string */ function getOauthPath() { $context = Request::getContext(); $contextId = ($context == null) ? 0 : $context->getId(); $apiPath = $this->getSetting($contextId, 'orcidProfileAPIPath'); if ($apiPath == ORCID_API_URL_PUBLIC || $apiPath == ORCID_API_URL_MEMBER) { return ORCID_OAUTH_URL; } else { return ORCID_OAUTH_URL_SANDBOX; } } /** * Output filter adds ORCiD interaction to registration form. * @param $output string * @param $templateMgr TemplateManager * @return $string */ function registrationFilter($output, &$templateMgr) { if (preg_match('/