baseline
[omp.pkp.sfu.ca.git] / classes / manager / form / setup / PressSetupForm.inc.php
blob1984b616ef8f95fc390ac5181c57cdb1b47119a2
1 <?php
3 /**
4 * @defgroup manager_form_setup
5 */
7 /**
8 * @file classes/manager/form/setup/PressSetupForm.inc.php
10 * Copyright (c) 2003-2008 John Willinsky
11 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
13 * @class PressSetupForm
14 * @ingroup manager_form_setup
16 * @brief Base class for press setup forms.
19 // $Id: PressSetupForm.inc.php,v 1.3 2009/03/09 22:43:19 tylerl Exp $
21 import('form.Form');
22 import('ui.grid.Grid');
24 class PressSetupForm extends Form {
25 var $step;
26 var $settings;
28 /**
29 * Constructor.
30 * @param $step the step number
31 * @param $settings an associative array with the setting names as keys and associated types as values
33 function PressSetupForm($step, $settings) {
34 parent::Form(sprintf('manager/setup/step%d.tpl', $step));
35 $this->addCheck(new FormValidatorPost($this));
36 $this->step = $step;
37 $this->settings = $settings;
40 /**
41 * Display the form.
43 function display() {
44 $templateMgr =& TemplateManager::getManager();
45 $templateMgr->assign('setupStep', $this->step);
46 $templateMgr->assign('helpTopicId', 'press.managementPages.setup');
47 $templateMgr->setCacheability(CACHEABILITY_MUST_REVALIDATE);
49 // need grid locale
50 Locale::requireComponents(array(LOCALE_COMPONENT_PKP_GRID));
51 parent::display();
54 /**
55 * Initialize data from current settings.
57 function initData() {
58 $press =& Request::getPress();
59 $this->_data = $press->getSettings();
62 /**
63 * Read user input.
65 function readInputData() {
66 $this->readUserVars(array_keys($this->settings));
69 /**
70 * Save modified settings.
72 function execute() {
73 $press =& Request::getPress();
74 $settingsDao =& DAORegistry::getDAO('PressSettingsDAO');
76 foreach ($this->_data as $name => $value) {
77 if (isset($this->settings[$name])) {
78 $isLocalized = in_array($name, $this->getLocaleFieldNames());
79 $settingsDao->updateSetting(
80 $press->getId(),
81 $name,
82 $value,
83 $this->settings[$name],
84 $isLocalized