ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4include_once("./Services/Component/classes/class.ilPluginConfigGUI.php");
5include_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
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 $tpl;
87
88 $this->initConfigurationForm();
89 $this->getValues();
90 $tpl->setContent($this->form->getHTML());
91 }
92
93 public function getValues()
94 {
95 foreach ($this->fields as $key => $item)
96 {
97
98 $values[$key] = $this->object->getValue($key);
99 if (is_array($item["subelements"]))
100 {
101 foreach ($item["subelements"] as $subkey => $subitem)
102 {
103 $values[$key . "_" . $subkey] = $this->object->getValue($key . "_" . $subkey);
104 }
105 }
106
107 }
108
109 $this->form->setValuesByArray($values);
110 }
111
115 public function initConfigurationForm()
116 {
117 global $lng, $ilCtrl;
118
119 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
120 $this->form = new ilPropertyFormGUI();
121
122 foreach ($this->fields as $key => $item)
123 {
124 $field = new $item["type"]($this->plugin_object->txt($key), $key);
125 $field->setInfo($this->plugin_object->txt($item["info"]));
126 if (is_array($item["subelements"]))
127 {
128 foreach ($item["subelements"] as $subkey => $subitem)
129 {
130 $subfield = new $subitem["type"]($this->plugin_object->txt($key . "_" . $subkey), $key . "_" . $subkey);
131 $subfield->setInfo($this->plugin_object->txt($subitem["info"]));
132 $field->addSubItem($subfield);
133 }
134 }
135
136 $this->form->addItem($field);
137 }
138
139 $this->form->addCommandButton("save", $lng->txt("save"));
140
141 $this->form->setTitle($this->plugin_object->txt("configuration"));
142 $this->form->setFormAction($ilCtrl->getFormAction($this));
143
144 return $this->form;
145 }
146
147 public function save()
148 {
149 global $tpl, $ilCtrl;
150
151 $this->initConfigurationForm();
152 if ($this->form->checkInput())
153 {
154
155 // Save Checkbox Values
156 foreach ($this->fields as $key => $item)
157 {
158
159 $this->object->setValue($key, $this->form->getInput($key));
160 if (is_array($item["subelements"]))
161 {
162 foreach ($item["subelements"] as $subkey => $subitem)
163 {
164 $this->object->setValue($key . "_" . $subkey, $this->form->getInput($key . "_" . $subkey));
165 }
166 }
167
168 }
169
170 $ilCtrl->redirect($this, "configure");
171 } else
172 {
173 $this->form->setValuesByPost();
174 $tpl->setContent($this->form->getHtml());
175 }
176 }
177}
178?>
global $tpl
Definition: ilias.php:8
Class ilCloudPluginConfigGUI.
performCommand($cmd)
Handles all commmands, default is "configure".
Class ilCloudPluginConfig.
Parent class for all plugin config gui classes.
getPluginObject()
Get plugin object.
This class represents a property form user interface.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
$errors fields
Definition: imgupload.php:48