Skip to content
Snippets Groups Projects
Select Git revision
  • cambouis-3_3_0
  • stable-3_3_0
  • master default protected
  • jc/zimage-with-subfile-ids
  • jc/3.4.0-4
5 results

XML2HTMLSettingsForm.inc.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    XML2HTMLSettingsForm.inc.php 1.93 KiB
    <?php
    
    
    import('lib.pkp.classes.form.Form');
    
    class XML2HTMLSettingsForm extends Form {
    
        private static $FORMAT_SETTING = "format";
        private $_contextId;
    
        private $_plugin;
    
        /**
         * Constructor
         * @param $plugin  xml2html plugin
         * @param $contextId int Context ID
         */
        function __construct($plugin, $contextId) {
            $this->_contextId = $contextId;
            $this->_plugin = $plugin;
    
            parent::__construct($plugin->getTemplateResource('settingsForm.tpl'));
            $this->addCheck(new FormValidatorPost($this));
            $this->addCheck(new FormValidatorCSRF($this));
        }
    
        /**
         * Initialize form data.
         */
        function initData() {
            $contextId = $this->_contextId;
            $plugin = $this->_plugin;
            $this->setData('format', $plugin->getSetting($contextId, XML2HTMLSettingsForm::$FORMAT));
    
        }
    
        /**
         * Assign form data to user-submitted data.
         */
        function readInputData() {
            $this->readUserVars(array(XML2HTMLSettingsForm::$FORMAT));
    
    //
    //        // if recent items is selected, check that we have a value
    //        if ($this->getData('displayItems') == 'recent') {
    //            $this->addCheck(new FormValidator($this, 'recentItems', 'required', 'plugins.generic.webfeed.settings.recentItemsRequired'));
    //        }
    
        }
    
        /**
         * Fetch the form.
         * @copydoc Form::fetch()
         */
        function fetch($request, $template = null, $display = false) {
            $templateMgr = TemplateManager::getManager($request);
            $templateMgr->assign('pluginName', $this->_plugin->getName());
            return parent::fetch($request);
        }
    
        /**
         * @copydoc Form::execute()
         */
        function execute(...$functionArgs) {
            $plugin = $this->_plugin;
            $contextId = $this->_contextId;
    
            $plugin->updateSetting($contextId, XML2HTMLSettingsForm::$FORMAT, $this->getData(XML2HTMLSettingsForm::$FORMAT));
    
    
            parent::execute(...$functionArgs);
        }
    }