Open Journal Systems  3.3.0
WebFeedSettingsForm.inc.php
1 <?php
2 
16 import('lib.pkp.classes.form.Form');
17 
18 class WebFeedSettingsForm extends Form {
19 
21  private $_contextId;
22 
24  private $_plugin;
25 
31  function __construct($plugin, $contextId) {
32  $this->_contextId = $contextId;
33  $this->_plugin = $plugin;
34 
35  parent::__construct($plugin->getTemplateResource('settingsForm.tpl'));
36  $this->addCheck(new FormValidatorPost($this));
37  $this->addCheck(new FormValidatorCSRF($this));
38  }
39 
43  function initData() {
44  $contextId = $this->_contextId;
45  $plugin = $this->_plugin;
46 
47  $this->setData('displayPage', $plugin->getSetting($contextId, 'displayPage'));
48  $this->setData('displayItems', $plugin->getSetting($contextId, 'displayItems'));
49  $this->setData('recentItems', $plugin->getSetting($contextId, 'recentItems'));
50  }
51 
55  function readInputData() {
56  $this->readUserVars(array('displayPage','displayItems','recentItems'));
57 
58  // check that recent items value is a positive integer
59  if ((int) $this->getData('recentItems') <= 0) $this->setData('recentItems', '');
60 
61  // if recent items is selected, check that we have a value
62  if ($this->getData('displayItems') == 'recent') {
63  $this->addCheck(new FormValidator($this, 'recentItems', 'required', 'plugins.generic.webfeed.settings.recentItemsRequired'));
64  }
65 
66  }
67 
72  function fetch($request) {
73  $templateMgr = TemplateManager::getManager($request);
74  $templateMgr->assign('pluginName', $this->_plugin->getName());
75  return parent::fetch($request);
76  }
77 
81  function execute(...$functionArgs) {
82  $plugin = $this->_plugin;
83  $contextId = $this->_contextId;
84 
85  $plugin->updateSetting($contextId, 'displayPage', $this->getData('displayPage'));
86  $plugin->updateSetting($contextId, 'displayItems', $this->getData('displayItems'));
87  $plugin->updateSetting($contextId, 'recentItems', $this->getData('recentItems'));
88 
89  parent::execute(...$functionArgs);
90  }
91 }
WebFeedSettingsForm\readInputData
readInputData()
Definition: WebFeedSettingsForm.inc.php:61
WebFeedSettingsForm\fetch
fetch($request)
Definition: WebFeedSettingsForm.inc.php:78
Form\setData
setData($key, $value=null)
Definition: Form.inc.php:229
Form\readUserVars
readUserVars($vars)
Definition: Form.inc.php:378
Form\getData
getData($key)
Definition: Form.inc.php:220
FormValidatorPost
Form validation check to make sure the form is POSTed.
Definition: FormValidatorPost.inc.php:18
WebFeedSettingsForm\initData
initData()
Definition: WebFeedSettingsForm.inc.php:49
WebFeedSettingsForm\execute
execute(... $functionArgs)
Definition: WebFeedSettingsForm.inc.php:87
PKPTemplateManager\getManager
static & getManager($request=null)
Definition: PKPTemplateManager.inc.php:1239
FormValidator
Class to represent a form validation check.
Definition: FormValidator.inc.php:23
Form\addCheck
addCheck($formValidator)
Definition: Form.inc.php:395
FormValidatorCSRF
Form validation check to make sure the CSRF token is correct.
Definition: FormValidatorCSRF.inc.php:18
Form
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
WebFeedSettingsForm
Form for managers to modify web feeds plugin settings.
Definition: WebFeedSettingsForm.inc.php:18
WebFeedSettingsForm\__construct
__construct($plugin, $contextId)
Definition: WebFeedSettingsForm.inc.php:37