ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
66 public 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 case "configure":
73 case "save":
74 $this->$cmd();
75 break;
76
77 }
78 }
79
83 public function configure()
84 {
85 global $DIC;
86 $tpl = $DIC['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 $values[$key] = $this->object->getValue($key);
97 if (is_array($item["subelements"])) {
98 foreach ($item["subelements"] as $subkey => $subitem) {
99 $values[$key . "_" . $subkey] = $this->object->getValue($key . "_" . $subkey);
100 }
101 }
102 }
103
104 $this->form->setValuesByArray($values);
105 }
106
110 public function initConfigurationForm()
111 {
112 global $DIC;
113 $lng = $DIC['lng'];
114 $ilCtrl = $DIC['ilCtrl'];
115
116 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
117 $this->form = new ilPropertyFormGUI();
118
119 foreach ($this->fields as $key => $item) {
120 $field = new $item["type"]($this->plugin_object->txt($key), $key);
121 $field->setInfo($this->plugin_object->txt($item["info"]));
122 if (is_array($item["subelements"])) {
123 foreach ($item["subelements"] as $subkey => $subitem) {
124 $subfield = new $subitem["type"]($this->plugin_object->txt($key . "_" . $subkey), $key . "_" . $subkey);
125 $subfield->setInfo($this->plugin_object->txt($subitem["info"]));
126 $field->addSubItem($subfield);
127 }
128 }
129
130 $this->form->addItem($field);
131 }
132
133 $this->form->addCommandButton("save", $lng->txt("save"));
134
135 $this->form->setTitle($this->plugin_object->txt("configuration"));
136 $this->form->setFormAction($ilCtrl->getFormAction($this));
137
138 return $this->form;
139 }
140
141 public function save()
142 {
143 global $DIC;
144 $tpl = $DIC['tpl'];
145 $ilCtrl = $DIC['ilCtrl'];
146
147 $this->initConfigurationForm();
148 if ($this->form->checkInput()) {
149
150 // Save Checkbox Values
151 foreach ($this->fields as $key => $item) {
152 $this->object->setValue($key, $this->form->getInput($key));
153 if (is_array($item["subelements"])) {
154 foreach ($item["subelements"] as $subkey => $subitem) {
155 $this->object->setValue($key . "_" . $subkey, $this->form->getInput($key . "_" . $subkey));
156 }
157 }
158 }
159
160 $ilCtrl->redirect($this, "configure");
161 } else {
162 $this->form->setValuesByPost();
163 $tpl->setContent($this->form->getHtml());
164 }
165 }
166}
$tpl
Definition: ilias.php:10
An exception for terminatinating execution or to throw for unit testing.
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.
$key
Definition: croninfo.php:18
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$lng
$values
$errors fields
Definition: imgupload.php:51