Open Journal Systems  3.3.0
AnnouncementFeedSettingsForm.inc.php
1 <?php
2 
16 import('lib.pkp.classes.form.Form');
17 
19 
21  protected $_journalId;
22 
24  protected $_plugin;
25 
31  public function __construct($plugin, $journalId) {
32  $this->_journalId = $journalId;
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  public function initData() {
44  $journalId = $this->_journalId;
45  $plugin = $this->_plugin;
46 
47  $this->setData('displayPage', $plugin->getSetting($journalId, 'displayPage'));
48  $this->setData('recentItems', $plugin->getSetting($journalId, 'recentItems'));
49  }
50 
54  public function readInputData() {
55  $this->readUserVars(array('displayPage', 'recentItems'));
56 
57  // check that recent items value is a positive integer
58  if ((int) $this->getData('recentItems') <= 0) $this->setData('recentItems', '');
59  }
60 
65  public function fetch($request) {
66  $templateMgr = TemplateManager::getManager($request);
67  $templateMgr->assign('pluginName', $this->_plugin->getName());
68  return parent::fetch($request);
69  }
70 
74  public function execute(...$functionArgs) {
75  $plugin = $this->_plugin;
76  $journalId = $this->_journalId;
77 
78  $plugin->updateSetting($journalId, 'displayPage', $this->getData('displayPage'));
79  $plugin->updateSetting($journalId, 'recentItems', $this->getData('recentItems'));
80 
81  parent::execute(...$functionArgs);
82  }
83 
84 }
AnnouncementFeedSettingsForm\$_journalId
$_journalId
Definition: AnnouncementFeedSettingsForm.inc.php:24
AnnouncementFeedSettingsForm
Form for journal managers to modify announcement feed plugin settings.
Definition: AnnouncementFeedSettingsForm.inc.php:18
AnnouncementFeedSettingsForm\execute
execute(... $functionArgs)
Definition: AnnouncementFeedSettingsForm.inc.php:80
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
AnnouncementFeedSettingsForm\__construct
__construct($plugin, $journalId)
Definition: AnnouncementFeedSettingsForm.inc.php:37
AnnouncementFeedSettingsForm\initData
initData()
Definition: AnnouncementFeedSettingsForm.inc.php:49
PKPTemplateManager\getManager
static & getManager($request=null)
Definition: PKPTemplateManager.inc.php:1239
AnnouncementFeedSettingsForm\readInputData
readInputData()
Definition: AnnouncementFeedSettingsForm.inc.php:60
AnnouncementFeedSettingsForm\fetch
fetch($request)
Definition: AnnouncementFeedSettingsForm.inc.php:71
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
AnnouncementFeedSettingsForm\$_plugin
$_plugin
Definition: AnnouncementFeedSettingsForm.inc.php:30