Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
ContextSettingsForm.inc.php
1 <?php
2 
17 // Import the base Form.
18 import('lib.pkp.classes.form.Form');
19 
20 class ContextSettingsForm extends Form {
21 
23  var $_settings;
24 
26  var $_wizardMode;
27 
28 
35  function ContextSettingsForm($settings, $template, $wizardMode) {
36  $this->addCheck(new FormValidatorPost($this));
37  $this->setSettings($settings);
38  $this->setWizardMode($wizardMode);
39  parent::Form($template);
40  }
41 
42 
43  //
44  // Getters and Setters
45  //
50  function getWizardMode() {
51  return $this->_wizardMode;
52  }
53 
58  function setWizardMode($wizardMode) {
59  $this->_wizardMode = $wizardMode;
60  }
61 
66  function getSettings() {
67  return $this->_settings;
68  }
69 
74  function setSettings($settings) {
75  $this->_settings = $settings;
76  }
77 
78 
79  //
80  // Implement template methods from Form.
81  //
86  function initData($request) {
87  $context = $request->getContext();
88  $this->_data = $context->getSettings();
89  }
90 
95  function readInputData($request) {
96  $this->readUserVars(array_keys($this->getSettings()));
97  }
98 
104  function fetch($request, $params = null) {
105  $templateMgr = TemplateManager::getManager($request);
106 
107  // Insert the wizardMode parameter in params array to pass to template.
108  $params = array_merge((array)$params, array('wizardMode' => $this->getWizardMode()));
109 
110  // Pass the parameters to template.
111  foreach($params as $tplVar => $value) {
112  $templateMgr->assign($tplVar, $value);
113  }
114 
115  return parent::fetch($request);
116  }
117 
122  function execute($request) {
123  $context = $request->getContext();
124  $settingsDao = $context->getSettingsDao();
125  $settings = $this->getSettings();
126 
127  foreach ($this->_data as $name => $value) {
128  if (isset($settings[$name])) {
129  $isLocalized = in_array($name, $this->getLocaleFieldNames());
130  $settingsDao->updateSetting(
131  $context->getId(),
132  $name,
133  $value,
134  $settings[$name],
135  $isLocalized
136  );
137  }
138  }
139  }
140 }
141 
142 ?>
ContextSettingsForm($settings, $template, $wizardMode)
addCheck($formValidator)
Definition: Form.inc.php:396
Form validation check to make sure the form is POSTed.
readUserVars($vars)
Definition: Form.inc.php:364
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
initData()
Definition: Form.inc.php:227
fetch($request, $params=null)
getLocaleFieldNames()
Definition: Form.inc.php:317
Base class for forms that manage context settings data.
readInputData()
Definition: Form.inc.php:240