• Main Page
  • Modules
  • Classes
  • Files
  • File List

controllers/tab/settings/form/PressSettingsForm.inc.php

00001 <?php
00002 
00016 // Import the base Form.
00017 import('lib.pkp.classes.form.Form');
00018 
00019 class PressSettingsForm extends Form {
00020 
00022    var $_settings;
00023 
00025    var $_wizardMode;
00026 
00027 
00033    function PressSettingsForm($settings, $template, $wizardMode) {
00034       $this->addCheck(new FormValidatorPost($this));
00035       $this->setSettings($settings);
00036       $this->setWizardMode($wizardMode);
00037       parent::Form($template);
00038    }
00039 
00040 
00041    //
00042    // Getters and Setters
00043    //
00048    function getWizardMode() {
00049       return $this->_wizardMode;
00050    }
00051 
00056    function setWizardMode($wizardMode) {
00057       $this->_wizardMode = $wizardMode;
00058    }
00059 
00064    function getSettings() {
00065       return $this->_settings;
00066    }
00067 
00072    function setSettings($settings) {
00073       $this->_settings = $settings;
00074    }
00075 
00076 
00077    //
00078    // Implement template methods from Form.
00079    //
00084    function initData(&$request) {
00085       $press =& $request->getPress();
00086       $this->_data = $press->getSettings();
00087    }
00088 
00092    function readInputData(&$request) {
00093       $this->readUserVars(array_keys($this->getSettings()));
00094    }
00095 
00099    function fetch(&$request, $params = null) {
00100       $templateMgr =& TemplateManager::getManager();
00101 
00102       // Insert the wizardMode parameter in params array to pass to template.
00103       $params = array_merge((array)$params, array('wizardMode' => $this->getWizardMode()));
00104 
00105       // Pass the parameters to template.
00106       foreach($params as $tplVar => $value) {
00107          $templateMgr->assign($tplVar, $value);
00108       }
00109 
00110       return parent::fetch(&$request);
00111    }
00112 
00116    function execute(&$request) {
00117       $press =& $request->getPress();
00118       $settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
00119       $settings = $this->getSettings();
00120 
00121       foreach ($this->_data as $name => $value) {
00122          if (isset($settings[$name])) {
00123             $isLocalized = in_array($name, $this->getLocaleFieldNames());
00124             $settingsDao->updateSetting(
00125                $press->getId(),
00126                $name,
00127                $value,
00128                $settings[$name],
00129                $isLocalized
00130             );
00131          }
00132       }
00133    }
00134 }
00135 
00136 ?>

Generated on Mon Sep 17 2012 13:58:56 for Open Monograph Press by  doxygen 1.7.1