| Server IP : 195.134.90.114 / Your IP : 216.73.216.86 Web Server : Apache/2.4.58 System : Linux nepub 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/public_html/plugins/importexport/doaj/classes/form/ |
Upload File : |
<?php
/**
* @file plugins/importexport/doaj/classes/form/DOAJSettingsForm.inc.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class DOAJSettingsForm
* @ingroup plugins_importexport_doaj
*
* @brief Form for journal managers to setup DOAJ plugin
*/
import('lib.pkp.classes.form.Form');
class DOAJSettingsForm extends Form {
//
// Private properties
//
/** @var integer */
var $_contextId;
/**
* Get the context ID.
* @return integer
*/
function _getContextId() {
return $this->_contextId;
}
/** @var CrossRefExportPlugin */
var $_plugin;
/**
* Get the plugin.
* @return CrossRefExportPlugin
*/
function _getPlugin() {
return $this->_plugin;
}
//
// Constructor
//
/**
* Constructor
* @param $plugin DOAJExportPlugin
* @param $contextId integer
*/
function __construct($plugin, $contextId) {
$this->_contextId = $contextId;
$this->_plugin = $plugin;
parent::__construct($plugin->getTemplateResource('settingsForm.tpl'));
// Add form validation checks.
$this->addCheck(new FormValidatorPost($this));
$this->addCheck(new FormValidatorCSRF($this));
}
//
// Implement template methods from Form
//
/**
* @copydoc Form::initData()
*/
function initData() {
$contextId = $this->_getContextId();
$plugin = $this->_getPlugin();
foreach($this->getFormFields() as $fieldName => $fieldType) {
$this->setData($fieldName, $plugin->getSetting($contextId, $fieldName));
}
}
/**
* @copydoc Form::readInputData()
*/
function readInputData() {
$this->readUserVars(array_keys($this->getFormFields()));
}
/**
* @copydoc Form::execute()
*/
function execute(...$functionArgs) {
$plugin = $this->_getPlugin();
$contextId = $this->_getContextId();
parent::execute(...$functionArgs);
foreach($this->getFormFields() as $fieldName => $fieldType) {
$plugin->updateSetting($contextId, $fieldName, $this->getData($fieldName), $fieldType);
}
}
//
// Public helper methods
//
/**
* Get form fields
* @return array (field name => field type)
*/
function getFormFields() {
return array(
'apiKey' => 'string',
'automaticRegistration' => 'bool',
'testMode' => 'bool'
);
}
/**
* Is the form field optional
* @param $settingName string
* @return boolean
*/
function isOptional($settingName) {
return in_array($settingName, array('apiKey', 'automaticRegistration', 'testMode'));
}
}