/**
  * @see Filter::process()
  */
 function &process(&$input)
 {
     // Initialize view
     $locale = AppLocale::getLocale();
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     $templateMgr = TemplateManager::getManager($request);
     // Add the filter's directory as additional template dir so that
     // templates can include sub-templates in the same folder.
     array_unshift($templateMgr->template_dir, $this->getBasePath());
     // Give sub-filters a chance to add their variables
     // to the template.
     $this->addTemplateVars($templateMgr, $input, $request, $locale);
     // Use a base path hash as compile id to make sure that we don't
     // get namespace problems if several filters use the same
     // template names.
     $previousCompileId = $templateMgr->compile_id;
     $templateMgr->compile_id = md5($this->getBasePath());
     // Let the template engine render the citation.
     $output = $templateMgr->fetch($this->getTemplateName());
     // Remove the additional template dir
     array_shift($templateMgr->template_dir);
     // Restore the compile id.
     $templateMgr->compile_id = $previousCompileId;
     return $output;
 }
 /**
  * Constructor.
  * @param $handler Handler the associated form
  * @param $roles array of role id's
  * @param $all bool flag for whether all roles must exist or just 1
  */
 function HandlerValidatorRoles(&$handler, $redirectLogin = true, $message = null, $additionalArgs = array(), $roles, $all = false)
 {
     $application =& PKPApplication::getApplication();
     $request =& $application->getRequest();
     $policy = new RoleBasedHandlerOperationPolicy($request, $roles, array(), $message, $all, true);
     parent::HandlerValidatorPolicy($policy, $handler, $redirectLogin, $message, $additionalArgs);
 }
Exemple #3
0
 function isTinyMCEInstalled()
 {
     // If the thesis plugin isn't enabled, don't do anything.
     $application =& PKPApplication::getApplication();
     $products =& $application->getEnabledProducts('plugins.generic');
     return isset($products['tinymce']);
 }
Exemple #4
0
 /**
  * Constructor
  * @param $plugin MedraExportPlugin
  * @param $contextId integer
  */
 function MedraSettingsForm($plugin, $contextId)
 {
     $this->_contextId = $contextId;
     $this->_plugin = $plugin;
     parent::Form($plugin->getTemplatePath() . 'settingsForm.tpl');
     // DOI plugin settings action link
     $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true);
     if (isset($pubIdPlugins['doipubidplugin'])) {
         $application = PKPApplication::getApplication();
         $request = $application->getRequest();
         $dispatcher = $application->getDispatcher();
         import('lib.pkp.classes.linkAction.request.AjaxModal');
         $doiPluginSettingsLinkAction = new LinkAction('settings', new AjaxModal($dispatcher->url($request, ROUTE_COMPONENT, null, 'grid.settings.plugins.SettingsPluginGridHandler', 'manage', null, array('plugin' => 'doipubidplugin', 'category' => 'pubIds')), __('plugins.importexport.common.settings.DOIPluginSettings')), __('plugins.importexport.common.settings.DOIPluginSettings'), null);
         $this->setData('doiPluginSettingsLinkAction', $doiPluginSettingsLinkAction);
     }
     // Add form validation checks.
     $this->addCheck(new FormValidator($this, 'registrantName', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.registrantNameRequired'));
     $this->addCheck(new FormValidator($this, 'fromCompany', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.fromCompanyRequired'));
     $this->addCheck(new FormValidator($this, 'fromName', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.fromNameRequired'));
     $this->addCheck(new FormValidatorEmail($this, 'fromEmail', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.fromEmailRequired'));
     $this->addCheck(new FormValidatorInSet($this, 'exportIssuesAs', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.exportIssuesAs', array(O4DOI_ISSUE_AS_WORK, O4DOI_ISSUE_AS_MANIFESTATION)));
     $this->addCheck(new FormValidatorInSet($this, 'publicationCountry', FORM_VALIDATOR_REQUIRED_VALUE, 'plugins.importexport.medra.settings.form.publicationCountry', array_keys($this->_getCountries())));
     // The username is used in HTTP basic authentication and according to RFC2617 it therefore may not contain a colon.
     $this->addCheck(new FormValidatorRegExp($this, 'username', FORM_VALIDATOR_OPTIONAL_VALUE, 'plugins.importexport.medra.settings.form.usernameRequired', '/^[^:]+$/'));
     $this->addCheck(new FormValidatorPost($this));
 }
Exemple #5
0
 /**
  * @copydoc SiteSetupForm::fetch()
  */
 function fetch($request, $params = null)
 {
     $application = PKPApplication::getApplication();
     $templateMgr = TemplateManager::getManager();
     $templateMgr->assign('availableMetricTypes', $application->getMetricTypes(true));
     return parent::fetch($request, $params = null);
 }
 /**
  * Assign parameters to template
  * @param $paramArray array
  */
 function assignParams($paramArray = array())
 {
     $submission = $this->submission;
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     parent::assignParams(array_merge(array('submissionTitle' => strip_tags($submission->getLocalizedTitle()), 'submissionId' => $submission->getId(), 'submissionAbstract' => PKPString::html2text($submission->getLocalizedAbstract()), 'authorString' => strip_tags($submission->getAuthorString())), $paramArray));
 }
 /**
  * Constructor.
  * @see HandlerValidator::HandlerValidator()
  */
 function HandlerValidatorPress(&$handler, $redirectToLogin = false, $message = null, $additionalArgs = array())
 {
     $application =& PKPApplication::getApplication();
     $request =& $application->getRequest();
     $policy = new ContextRequiredPolicy($request, $message);
     parent::HandlerValidatorPolicy($policy, $handler, $redirectToLogin, $message, $additionalArgs);
 }
 /**
  * @covers HandlerValidatorRoles
  */
 public function testHandlerValidatorRoles()
 {
     $contextDepth = PKPApplication::getApplication()->getContextDepth();
     // tests: userId, role type, user has role in context?, match all roles?, expected result of isValid()
     $tests = array(array(7, array(HANDLER_VALIDATOR_ROLES_FULL_CONTEXT_ROLE), true, false, true), array(7, array(HANDLER_VALIDATOR_ROLES_MANAGER_ROLE), true, true, true), array(7, array(HANDLER_VALIDATOR_ROLES_SITE_ADMIN_ROLE), true, false, true), array(null, array(HANDLER_VALIDATOR_ROLES_FULL_CONTEXT_ROLE), true, false, false), array(7, array(HANDLER_VALIDATOR_ROLES_FULL_CONTEXT_ROLE), false, false, false), array(7, array(HANDLER_VALIDATOR_ROLES_FULL_CONTEXT_ROLE, HANDLER_VALIDATOR_ROLES_MANAGER_ROLE), array(true, false), false, true), array(7, array(HANDLER_VALIDATOR_ROLES_FULL_CONTEXT_ROLE, HANDLER_VALIDATOR_ROLES_MANAGER_ROLE), array(true, true), false, true), array(7, array(HANDLER_VALIDATOR_ROLES_FULL_CONTEXT_ROLE, HANDLER_VALIDATOR_ROLES_MANAGER_ROLE), array(true, false), true, false), array(7, array(HANDLER_VALIDATOR_ROLES_FULL_CONTEXT_ROLE, HANDLER_VALIDATOR_ROLES_MANAGER_ROLE), array(true, true), true, true));
     foreach ($tests as $testNumber => $test) {
         $this->executeHandlerValidatorRolesTest($test, $testNumber);
     }
 }
 /**
  * @copydoc PKPTestCase::setUp()
  */
 protected function setUp()
 {
     $application = PKPApplication::getApplication();
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $request = $application->getRequest();
     if (is_null($request->getRouter())) {
         $router = new PKPRouter();
         $request->setRouter($router);
     }
 }
 /**
  * @see WebTestCase::setUp()
  */
 protected function setUp()
 {
     parent::setUp();
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     if (is_null($request->getRouter())) {
         $router = new PKPRouter();
         $request->setRouter($router);
     }
 }
 /**
  * @see OAI#OAI
  */
 function PressOAI($config)
 {
     parent::OAI($config);
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     $this->site = $request->getSite();
     $this->press = $request->getPress();
     $this->pressId = isset($this->press) ? $this->press->getId() : null;
     $this->dao = DAORegistry::getDAO('OAIDAO');
     $this->dao->setOAI($this);
 }
Exemple #12
0
 /**
  * Get an instance of the Help object.
  */
 function &getHelp()
 {
     $instance =& Registry::get('help');
     if ($instance == null) {
         unset($instance);
         $application =& PKPApplication::getApplication();
         $instance =& $application->instantiateHelp();
         Registry::set('help', $instance);
     }
     return $instance;
 }
 function assignParams($paramArray = array())
 {
     $submission = $this->submission;
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     $paramArray['submissionTitle'] = strip_tags($submission->getLocalizedTitle());
     $paramArray['submissionId'] = $submission->getId();
     $paramArray['submissionAbstract'] = String::html2text($submission->getLocalizedAbstract());
     $paramArray['authorString'] = strip_tags($submission->getAuthorString());
     parent::assignParams($paramArray);
 }
Exemple #14
0
 /**
  * Static method to return a new version from a version string of the form "W.X.Y.Z".
  * @param $versionString string
  * @param $productType string
  * @param $product string
  * @param $productClass string
  * @param $lazyLoad integer
  * @param $sitewide integer
  * @return Version
  */
 function &fromString($versionString, $productType = null, $product = null, $productClass = '', $lazyLoad = 0, $sitewide = 1)
 {
     $versionArray = explode('.', $versionString);
     if (!$product && !$productType) {
         $application = PKPApplication::getApplication();
         $product = $application->getName();
         $productType = 'core';
     }
     $version = new Version(isset($versionArray[0]) ? (int) $versionArray[0] : 0, isset($versionArray[1]) ? (int) $versionArray[1] : 0, isset($versionArray[2]) ? (int) $versionArray[2] : 0, isset($versionArray[3]) ? (int) $versionArray[3] : 0, Core::getCurrentDate(), 1, $productType, $product, $productClass, $lazyLoad, $sitewide);
     return $version;
 }
 /**
  * Return information about the latest available version.
  * @return array
  */
 function getLatestVersion()
 {
     $application = PKPApplication::getApplication();
     $includeId = Config::getVar('general', 'installed') && !defined('RUNNING_UPGRADE') && Config::getVar('general', 'enable_beacon', true);
     if ($includeId) {
         $pluginSettingsDao =& DAORegistry::getDAO('PluginSettingsDAO');
         $uniqueSiteId = $pluginSettingsDao->getSetting(CONTEXT_SITE, 'UsageEventPlugin', 'uniqueSiteId');
     } else {
         $uniqueSiteId = null;
     }
     $request = $application->getRequest();
     return VersionCheck::parseVersionXML($application->getVersionDescriptorUrl() . ($includeId ? '?id=' . urlencode($uniqueSiteId) . '&oai=' . urlencode($request->url('index', 'oai')) : ''));
 }
 protected function setUp()
 {
     $application =& PKPApplication::getApplication();
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $request =& $application->getRequest();
     if (is_null($request->getRouter())) {
         $router = new PKPRouter();
         $request->setRouter($router);
     }
     // Instantiate the citation DAO and make sure we have no left-overs
     // from previous unsuccessful tests.
     $this->citationDao = DAORegistry::getDAO('CitationDAO');
     $this->citationDao->deleteObjectsByAssocId($this->assocType, $this->assocId);
 }
 /**
  * Retrieve the complete version history, ordered by date (most recent first).
  * @param $product string
  * @return array Versions
  */
 function &getVersionHistory($product = null)
 {
     $versions = array();
     if (!$product) {
         $application = PKPApplication::getApplication();
         $product = $application->getName();
     }
     $result =& $this->retrieve('SELECT * FROM versions WHERE product = ? ORDER BY date_installed DESC', array($product));
     while (!$result->EOF) {
         $versions[] = $this->_returnVersionFromRow($result->GetRowAssoc(false));
         $result->MoveNext();
     }
     $result->Close();
     unset($result);
     return $versions;
 }
 /**
  * Retrieve Notes by assoc id/type
  * @param $assocId int
  * @param $assocType int
  * @param $userId int
  * @return object DAOResultFactory containing matching Note objects
  */
 function &getByAssoc($assocType, $assocId, $userId = null)
 {
     $application =& PKPApplication::getApplication();
     $productName = $application->getName();
     $params = array((int) $assocId, (int) $assocType);
     if (isset($userId)) {
         $params[] = (int) $userId;
     }
     $sql = 'SELECT * FROM notes WHERE assoc_id = ? AND assoc_type = ?';
     if (isset($userId)) {
         $sql .= ' AND user_id = ?';
     }
     $sql .= ' ORDER BY date_created DESC';
     $result =& $this->retrieveRange($sql, $params);
     $returner = new DAOResultFactory($result, $this, '_returnNoteFromRow');
     return $returner;
 }
 /**
  * Constructor
  * @param $plugin DOIPubIdPlugin
  * @param $pressId integer
  */
 function DOISettingsForm(&$plugin, $pressId)
 {
     $this->_pressId = $pressId;
     $this->_plugin =& $plugin;
     parent::Form($plugin->getTemplatePath() . 'settingsForm.tpl');
     $this->addCheck(new FormValidatorRegExp($this, 'doiPrefix', 'required', 'plugins.pubIds.doi.manager.settings.doiPrefixPattern', '/^10\\.[0-9][0-9][0-9][0-9][0-9]?$/'));
     $this->addCheck(new FormValidatorCustom($this, 'doiPublicationFormatSuffixPattern', 'required', 'plugins.pubIds.doi.manager.settings.doiPublicationFormatSuffixPatternRequired', create_function('$doiPublicationFormatSuffixPattern,$form', 'if ($form->getData(\'doiSuffix\') == \'pattern\') return $doiPublicationFormatSuffixPattern != \'\';return true;'), array(&$this)));
     $this->addCheck(new FormValidator($this, 'doiSuffix', 'required', 'plugins.pubIds.doi.manager.settings.doiSuffixRequired'));
     $this->addCheck(new FormValidatorPost($this));
     // for DOI reset requests
     import('lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     $clearPubIdsLinkAction = new LinkAction('reassignDOIs', new RemoteActionConfirmationModal(__('plugins.pubIds.doi.manager.settings.doiReassign.confirm'), __('common.delete'), $request->url(null, null, 'plugin', null, array('verb' => 'settings', 'clearPubIds' => true, 'plugin' => $plugin->getName(), 'category' => 'pubIds')), 'modal_delete'), __('plugins.pubIds.doi.manager.settings.doiReassign'), 'delete');
     $this->setData('clearPubIdsLinkAction', $clearPubIdsLinkAction);
     $this->setData('pluginName', $plugin->getName());
 }
 /**
  * @see LazyLoadPlugin::register()
  */
 function register($category, $path)
 {
     $success = parent::register($category, $path);
     if ($this->getEnabled() && $success) {
         // Register callbacks.
         $app = PKPApplication::getApplication();
         $version = $app->getCurrentVersion();
         HookRegistry::register('AcronPlugin::parseCronTab', array($this, 'callbackParseCronTab'));
         HookRegistry::register('PluginRegistry::loadCategory', array($this, 'callbackLoadCategory'));
         // If the plugin will provide the access logs,
         // register to the usage event hook provider.
         if ($this->getSetting(CONTEXT_ID_NONE, 'createLogFiles')) {
             HookRegistry::register('UsageEventPlugin::getUsageEvent', array(&$this, 'logUsageEvent'));
         }
     }
     return $success;
 }
 /**
  * Associate a category with a submission.
  * @copydoc ListbuilderHandler::insertEntry
  */
 function insertEntry($request, $newRowId)
 {
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     $categoryId = $newRowId['name'];
     $categoryDao = DAORegistry::getDAO('CategoryDAO');
     $submissionDao = DAORegistry::getDAO('MonographDAO');
     $context = $request->getContext();
     $submission = $this->submission;
     $category = $categoryDao->getById($categoryId, $context->getId());
     if (!$category) {
         return true;
     }
     // Associate the category with the submission
     $submissionDao->addCategory($submission->getId(), $categoryId);
     return true;
 }
Exemple #22
0
 /**
  * Retrieve a reference to the specified DAO.
  * @param $name string the class name of the requested DAO
  * @param $dbconn ADONewConnection optional
  * @return DAO
  */
 function &getDAO($name, $dbconn = null)
 {
     $daos =& DAORegistry::getDAOs();
     if (!isset($daos[$name])) {
         // Import the required DAO class.
         $application =& PKPApplication::getApplication();
         $className = $application->getQualifiedDAOName($name);
         if (!$className) {
             fatalError('Unrecognized DAO ' . $name . '!');
         }
         // Only instantiate each class of DAO a single time
         $daos[$name] =& instantiate($className, array('DAO', 'XMLDAO'));
         if ($dbconn != null) {
             $daos[$name]->setDataSource($dbconn);
         }
     }
     return $daos[$name];
 }
Exemple #23
0
 /**
  * Static method to return a new version from a version string of the form "W.X.Y.Z".
  * @param $versionString string
  * @param $product string
  * @param $productType string
  * @return Version
  */
 function &fromString($versionString, $product = null, $productType = null)
 {
     $version = new Version();
     if (!$product && !$productType) {
         $application = PKPApplication::getApplication();
         $product = $application->getName();
         $productType = 'core';
     }
     $versionArray = explode('.', $versionString);
     $version->setMajor(isset($versionArray[0]) ? (int) $versionArray[0] : 0);
     $version->setMinor(isset($versionArray[1]) ? (int) $versionArray[1] : 0);
     $version->setRevision(isset($versionArray[2]) ? (int) $versionArray[2] : 0);
     $version->setBuild(isset($versionArray[3]) ? (int) $versionArray[3] : 0);
     $version->setDateInstalled(null);
     $version->setProduct($product);
     $version->setProductType($productType);
     return $version;
 }
Exemple #24
0
 /**
  * Constructor
  * @param $plugin URNPubIdPlugin
  * @param $contextId integer
  */
 function URNSettingsForm($plugin, $contextId)
 {
     $this->_contextId = $contextId;
     $this->_plugin = $plugin;
     parent::Form($plugin->getTemplatePath() . 'settingsForm.tpl');
     $this->addCheck(new FormValidatorCustom($this, 'urnObjects', 'required', 'plugins.pubIds.urn.manager.settings.urnObjectsRequired', create_function('$enableIssueURN,$form', 'return $form->getData(\'enableIssueURN\') || $form->getData(\'enableArticleURN\') || $form->getData(\'enableRepresentationURN\');'), array($this)));
     $this->addCheck(new FormValidatorRegExp($this, 'urnPrefix', 'required', 'plugins.pubIds.urn.manager.settings.form.urnPrefixPattern', '/^urn:[a-zA-Z0-9-]*:.*/'));
     $this->addCheck(new FormValidatorCustom($this, 'urnIssueSuffixPattern', 'required', 'plugins.pubIds.urn.manager.settings.form.urnIssueSuffixPatternRequired', create_function('$urnIssueSuffixPattern,$form', 'if ($form->getData(\'urnSuffix\') == \'pattern\' && $form->getData(\'enableIssueURN\')) return $urnIssueSuffixPattern != \'\';return true;'), array($this)));
     $this->addCheck(new FormValidatorCustom($this, 'urnArticleSuffixPattern', 'required', 'plugins.pubIds.urn.manager.settings.form.urnArticleSuffixPatternRequired', create_function('$urnArticleSuffixPattern,$form', 'if ($form->getData(\'urnSuffix\') == \'pattern\' && $form->getData(\'enableArticleURN\')) return $urnArticleSuffixPattern != \'\';return true;'), array($this)));
     $this->addCheck(new FormValidatorCustom($this, 'urnRepresentationSuffixPattern', 'required', 'plugins.pubIds.urn.manager.settings.form.urnRepresentationSuffixPatternRequired', create_function('$urnRepresentationSuffixPattern,$form', 'if ($form->getData(\'urnSuffix\') == \'pattern\' && $form->getData(\'enableRepresentationURN\')) return $urnRepresentationSuffixPattern != \'\';return true;'), array($this)));
     $this->addCheck(new FormValidatorUrl($this, 'urnResolver', 'required', 'plugins.pubIds.urn.manager.settings.form.urnResolverRequired'));
     $this->addCheck(new FormValidatorPost($this));
     // for URN reset requests
     import('lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     $this->setData('clearPubIdsLinkAction', new LinkAction('reassignURNs', new RemoteActionConfirmationModal(__('plugins.pubIds.urn.manager.settings.urnReassign.confirm'), __('common.delete'), $request->url(null, null, 'manage', null, array('verb' => 'clearPubIds', 'plugin' => $plugin->getName(), 'category' => 'pubIds')), 'modal_delete'), __('plugins.pubIds.urn.manager.settings.urnReassign'), 'delete'));
     $this->setData('pluginName', $plugin->getName());
 }
 /**
  * Constructor
  * @param $plugin URNDNBPubIdPlugin
  * @param $pressId integer
  */
 function URNDNBSettingsForm(&$plugin, $pressId)
 {
     $this->_pressId = $pressId;
     $this->_plugin =& $plugin;
     parent::Form($plugin->getTemplatePath() . 'settingsForm.tpl');
     $this->addCheck(new FormValidatorRegExp($this, 'urnDNBPrefix', 'required', 'plugins.pubIds.urnDNB.manager.settings.urnDNBPrefixPattern', '/^urn:nbn(:[a-z0-9.-]+)+$/'));
     $this->addCheck(new FormValidatorCustom($this, 'urnDNBSuffixPattern', 'required', 'plugins.pubIds.urnDNB.manager.settings.urnDNBSuffixPatternRequired', create_function('$urnDNBSuffixPattern,$form', 'if ($form->getData(\'urnDNBSuffix\') == \'pattern\') return $urnDNBSuffixPattern != \'\';return true;'), array(&$this)));
     $this->addCheck(new FormValidatorRegExp($this, 'urnDNBSuffixPattern', 'optional', 'plugins.pubIds.urnDNB.manager.settings.urnDNBSuffixPatternFormat', '/^-[a-z0-9\\.\\-]*%[mp][a-z0-9\\.\\-]*%[mp][a-z0-9\\.\\-]*$/'));
     $this->addCheck(new FormValidatorRegExp($this, 'urnDNBSuffixPattern', 'optional', 'plugins.pubIds.urnDNB.manager.settings.urnDNBSuffixPatternFormat', '/%m/'));
     $this->addCheck(new FormValidator($this, 'urnDNBSuffix', 'required', 'plugins.pubIds.urnDNB.manager.settings.urnDNBSuffixRequired'));
     $this->addCheck(new FormValidatorPost($this));
     // for URNDNB reset requests
     import('lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     $clearPubIdsLinkAction = new LinkAction('reassignURNDNBs', new RemoteActionConfirmationModal(__('plugins.pubIds.urnDNB.manager.settings.urnDNBReassign.confirm'), __('common.delete'), $request->url(null, null, 'manage', null, array('verb' => 'settings', 'clearPubIds' => true, 'plugin' => $plugin->getName(), 'category' => 'pubIds')), 'modal_delete'), __('plugins.pubIds.urnDNB.manager.settings.urnDNBReassign'), 'delete');
     $this->setData('clearPubIdsLinkAction', $clearPubIdsLinkAction);
     $this->setData('pluginName', $plugin->getName());
 }
Exemple #26
0
 /**
  * Constructor
  * @param $plugin DOIPubIdPlugin
  * @param $contextId integer
  */
 function __construct($plugin, $contextId)
 {
     $this->_contextId = $contextId;
     $this->_plugin = $plugin;
     parent::__construct($plugin->getTemplatePath() . 'settingsForm.tpl');
     $this->addCheck(new FormValidatorCustom($this, 'doiObjects', 'required', 'plugins.pubIds.doi.manager.settings.doiObjectsRequired', create_function('$enableIssueDoi,$form', 'return $form->getData(\'enableIssueDoi\') || $form->getData(\'enableSubmissionDoi\') || $form->getData(\'enableRepresentationDoi\');'), array($this)));
     $this->addCheck(new FormValidatorRegExp($this, 'doiPrefix', 'required', 'plugins.pubIds.doi.manager.settings.doiPrefixPattern', '/^10\\.[0-9]{4,7}$/'));
     $this->addCheck(new FormValidatorCustom($this, 'doiIssueSuffixPattern', 'required', 'plugins.pubIds.doi.manager.settings.doiIssueSuffixPatternRequired', create_function('$doiIssueSuffixPattern,$form', 'if ($form->getData(\'doiSuffix\') == \'pattern\' && $form->getData(\'enableIssueDoi\')) return $doiIssueSuffixPattern != \'\';return true;'), array($this)));
     $this->addCheck(new FormValidatorCustom($this, 'doiSubmissionSuffixPattern', 'required', 'plugins.pubIds.doi.manager.settings.doiSubmissionSuffixPatternRequired', create_function('$doiSubmissionSuffixPattern,$form', 'if ($form->getData(\'doiSuffix\') == \'pattern\' && $form->getData(\'enableSubmissionDoi\')) return $doiSubmissionSuffixPattern != \'\';return true;'), array($this)));
     $this->addCheck(new FormValidatorCustom($this, 'doiRepresentationSuffixPattern', 'required', 'plugins.pubIds.doi.manager.settings.doiRepresentationSuffixPatternRequired', create_function('$doiRepresentationSuffixPattern,$form', 'if ($form->getData(\'doiSuffix\') == \'pattern\' && $form->getData(\'enableRepresentationDoi\')) return $doiRepresentationSuffixPattern != \'\';return true;'), array($this)));
     $this->addCheck(new FormValidatorPost($this));
     $this->addCheck(new FormValidatorCSRF($this));
     // for DOI reset requests
     import('lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     $this->setData('clearPubIdsLinkAction', new LinkAction('reassignDOIs', new RemoteActionConfirmationModal($request->getSession(), __('plugins.pubIds.doi.manager.settings.doiReassign.confirm'), __('common.delete'), $request->url(null, null, 'manage', null, array('verb' => 'clearPubIds', 'plugin' => $plugin->getName(), 'category' => 'pubIds')), 'modal_delete'), __('plugins.pubIds.doi.manager.settings.doiReassign'), 'delete'));
     $this->setData('pluginName', $plugin->getName());
 }
Exemple #27
0
 /**
  * @see LazyLoadPlugin::register()
  */
 function register($category, $path)
 {
     $success = parent::register($category, $path);
     if ($this->getEnabled() && $success) {
         // Register callbacks.
         $app =& PKPApplication::getApplication();
         $version = $app->getCurrentVersion();
         HookRegistry::register('PluginRegistry::loadCategory', array($this, 'callbackLoadCategory'));
         if ($version->getMajor() < 3) {
             HookRegistry::register('LoadHandler', array(&$this, 'callbackLoadHandler'));
         }
         // If the plugin will provide the access logs,
         // register to the usage event hook provider.
         if ($this->getSetting(0, 'createLogFiles')) {
             HookRegistry::register('UsageEventPlugin::getUsageEvent', array(&$this, 'logUsageEvent'));
         }
     }
     return $success;
 }
 /**
  * Retrieve a reference to the specified DAO.
  * @param $name string the class name of the requested DAO
  * @param $dbconn ADONewConnection optional
  * @return DAO
  */
 function &getDAO($name, $dbconn = null)
 {
     $daos =& DAORegistry::getDAOs();
     if (!isset($daos[$name])) {
         // Import the required DAO class.
         $application =& PKPApplication::getApplication();
         $className = $application->getQualifiedDAOName($name);
         if (!$className) {
             fatalError('Unrecognized DAO ' . $name . '!');
         }
         // Only instantiate each class of DAO a single time
         $daos[$name] =& instantiate($className, array('DAO', 'XMLDAO'));
         if ($dbconn != null) {
             // FIXME Needed by installer but shouldn't access member variable directly
             $daos[$name]->_dataSource = $dbconn;
         }
     }
     return $daos[$name];
 }
 /**
  * Display the form.
  */
 function display()
 {
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     $journals =& $journalDao->getJournalTitles();
     $templateMgr =& TemplateManager::getManager();
     $allThemes =& PluginRegistry::loadCategory('themes');
     $themes = array();
     foreach ($allThemes as $key => $junk) {
         $plugin =& $allThemes[$key];
         // by ref
         $themes[basename($plugin->getPluginPath())] =& $plugin;
         unset($plugin);
     }
     $templateMgr->assign('themes', $themes);
     $templateMgr->assign('redirectOptions', $journals);
     $application =& PKPApplication::getApplication();
     $templateMgr->assign('availableMetricTypes', $application->getMetricTypes(true));
     return parent::display();
 }
Exemple #30
0
 /**
  * Constructor
  * @param $plugin DataciteExportPlugin
  * @param $contextId integer
  */
 function __construct($plugin, $contextId)
 {
     $this->_contextId = $contextId;
     $this->_plugin = $plugin;
     parent::__construct($plugin->getTemplatePath() . 'settingsForm.tpl');
     // DOI plugin settings action link
     $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true);
     if (isset($pubIdPlugins['doipubidplugin'])) {
         $application = PKPApplication::getApplication();
         $request = $application->getRequest();
         $dispatcher = $application->getDispatcher();
         import('lib.pkp.classes.linkAction.request.AjaxModal');
         $doiPluginSettingsLinkAction = new LinkAction('settings', new AjaxModal($dispatcher->url($request, ROUTE_COMPONENT, null, 'grid.settings.plugins.SettingsPluginGridHandler', 'manage', null, array('plugin' => 'doipubidplugin', 'category' => 'pubIds')), __('plugins.importexport.common.settings.DOIPluginSettings')), __('plugins.importexport.common.settings.DOIPluginSettings'), null);
         $this->setData('doiPluginSettingsLinkAction', $doiPluginSettingsLinkAction);
     }
     // Add form validation checks.
     // The username is used in HTTP basic authentication and according to RFC2617 it therefore may not contain a colon.
     $this->addCheck(new FormValidatorRegExp($this, 'username', FORM_VALIDATOR_OPTIONAL_VALUE, 'plugins.importexport.datacite.settings.form.usernameRequired', '/^[^:]+$/'));
     $this->addCheck(new FormValidatorPost($this));
 }