ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilCloudPluginConfigGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Component/classes/class.ilPluginConfigGUI.php");
5 include_once("class.ilCloudPluginConfig.php");
6 
7 
27 {
31  protected $object;
32 
36  protected $fields = array();
37 
41  public function getFields()
42  {
43  return null;
44  }
45 
46 
50  public function getTableName()
51  {
52  return $this->getPluginObject()->getPrefix() . "_config";
53  }
54 
58  public function getObject()
59  {
60  return $this->object;
61  }
62 
66  function performCommand($cmd)
67  {
68  include_once("class.ilCloudPluginConfig.php");
69  $this->object = new ilCloudPluginConfig($this->getTableName());
70  $this->fields = $this->getFields();
71  switch ($cmd)
72  {
73  case "configure":
74  case "save":
75  $this->$cmd();
76  break;
77 
78  }
79  }
80 
84  function configure()
85  {
86  global $DIC;
87  $tpl = $DIC['tpl'];
88 
89  $this->initConfigurationForm();
90  $this->getValues();
91  $tpl->setContent($this->form->getHTML());
92  }
93 
94  public function getValues()
95  {
96  foreach ($this->fields as $key => $item)
97  {
98 
99  $values[$key] = $this->object->getValue($key);
100  if (is_array($item["subelements"]))
101  {
102  foreach ($item["subelements"] as $subkey => $subitem)
103  {
104  $values[$key . "_" . $subkey] = $this->object->getValue($key . "_" . $subkey);
105  }
106  }
107 
108  }
109 
110  $this->form->setValuesByArray($values);
111  }
112 
116  public function initConfigurationForm()
117  {
118  global $DIC;
119  $lng = $DIC['lng'];
120  $ilCtrl = $DIC['ilCtrl'];
121 
122  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
123  $this->form = new ilPropertyFormGUI();
124 
125  foreach ($this->fields as $key => $item)
126  {
127  $field = new $item["type"]($this->plugin_object->txt($key), $key);
128  $field->setInfo($this->plugin_object->txt($item["info"]));
129  if (is_array($item["subelements"]))
130  {
131  foreach ($item["subelements"] as $subkey => $subitem)
132  {
133  $subfield = new $subitem["type"]($this->plugin_object->txt($key . "_" . $subkey), $key . "_" . $subkey);
134  $subfield->setInfo($this->plugin_object->txt($subitem["info"]));
135  $field->addSubItem($subfield);
136  }
137  }
138 
139  $this->form->addItem($field);
140  }
141 
142  $this->form->addCommandButton("save", $lng->txt("save"));
143 
144  $this->form->setTitle($this->plugin_object->txt("configuration"));
145  $this->form->setFormAction($ilCtrl->getFormAction($this));
146 
147  return $this->form;
148  }
149 
150  public function save()
151  {
152  global $DIC;
153  $tpl = $DIC['tpl'];
154  $ilCtrl = $DIC['ilCtrl'];
155 
156  $this->initConfigurationForm();
157  if ($this->form->checkInput())
158  {
159 
160  // Save Checkbox Values
161  foreach ($this->fields as $key => $item)
162  {
163 
164  $this->object->setValue($key, $this->form->getInput($key));
165  if (is_array($item["subelements"]))
166  {
167  foreach ($item["subelements"] as $subkey => $subitem)
168  {
169  $this->object->setValue($key . "_" . $subkey, $this->form->getInput($key . "_" . $subkey));
170  }
171  }
172 
173  }
174 
175  $ilCtrl->redirect($this, "configure");
176  } else
177  {
178  $this->form->setValuesByPost();
179  $tpl->setContent($this->form->getHtml());
180  }
181  }
182 }
183 ?>
This class represents a property form user interface.
$cmd
Definition: sahs_server.php:35
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
$errors fields
Definition: imgupload.php:52
performCommand($cmd)
Handles all commmands, default is "configure".
Parent class for all plugin config gui classes.
Class ilCloudPluginConfig.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
getPluginObject()
Get plugin object.
global $DIC
Class ilCloudPluginConfigGUI.