getTemplateResource('settingsForm.tpl')); $this->addCheck(new FormValidatorPost($this)); $this->addCheck(new FormValidatorCSRF($this)); } /** * @copydoc Form::initData() */ public function initData(): void { $contextId = $this->contextId; $plugin = $this->plugin; $this->setData('displayPage', $plugin->getSetting($contextId, 'displayPage')); $this->setData('displayItems', $plugin->getSetting($contextId, 'displayItems')); $this->setData('recentItems', $plugin->getSetting($contextId, 'recentItems')); $this->setData('includeIdentifiers', $plugin->getSetting($contextId, 'includeIdentifiers')); parent::initData(); } /** * @copydoc Form::readInputData() */ public function readInputData(): void { $this->readUserVars(['displayPage', 'displayItems', 'recentItems', 'includeIdentifiers']); // Check that recent items value is a positive integer if ((int) $this->getData('recentItems') <= 0) { $this->setData('recentItems', ''); } // If recent items is selected or if the application doesn't support issues (there's no displayItems option to select), check that we have a value if (!WebFeedPlugin::hasIssues() || $this->getData('displayItems') === 'recent') { $this->addCheck(new FormValidator($this, 'recentItems', 'required', 'plugins.generic.webfeed.settings.recentItemsRequired')); } } /** * @copydoc Form::fetch() * * @param null|mixed $template */ public function fetch($request, $template = null, $display = false): string { $templateMgr = TemplateManager::getManager($request); $templateMgr->assign([ 'pluginName' => $this->plugin->getName(), 'hasIssues' => WebFeedPlugin::hasIssues() ]); return parent::fetch($request, $template, $display); } /** * @copydoc Form::execute() */ public function execute(...$functionArgs) { $plugin = $this->plugin; $contextId = $this->contextId; $plugin->updateSetting($contextId, 'displayPage', $this->getData('displayPage'), 'string'); $plugin->updateSetting($contextId, 'displayItems', $this->getData('displayItems'), 'string'); $plugin->updateSetting($contextId, 'recentItems', $this->getData('recentItems'), 'int'); $plugin->updateSetting($contextId, 'includeIdentifiers', $this->getData('includeIdentifiers'), 'bool'); parent::execute(...$functionArgs); } }