ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
26{
27
31 protected $object;
35 protected $fields = array();
36
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
55
59 public function getObject()
60 {
61 return $this->object;
62 }
63
64
68 public function performCommand($cmd)
69 {
70 include_once("class.ilCloudPluginConfig.php");
71 $this->object = new ilCloudPluginConfig($this->getTableName());
72 $this->fields = $this->getFields();
73 switch ($cmd) {
74 case "configure":
75 case "save":
76 $this->$cmd();
77 break;
78 }
79 }
80
81
85 public function configure()
86 {
87 global $DIC;
88 $tpl = $DIC['tpl'];
89
90 $this->initConfigurationForm();
91 $this->getValues();
92 $tpl->setContent($this->form->getHTML());
93 }
94
95
96 public function getValues()
97 {
98 foreach ($this->fields as $key => $item) {
99 $values[$key] = $this->object->getValue($key);
100 if (is_array($item["subelements"])) {
101 foreach ($item["subelements"] as $subkey => $subitem) {
102 $values[$key . "_" . $subkey] = $this->object->getValue($key . "_" . $subkey);
103 }
104 }
105 }
106
107 $this->form->setValuesByArray($values);
108 }
109
110
114 public function initConfigurationForm()
115 {
116 global $DIC;
117 $lng = $DIC['lng'];
118 $ilCtrl = $DIC['ilCtrl'];
119
120 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
121 $this->form = new ilPropertyFormGUI();
122
123 foreach ($this->fields as $key => $item) {
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 foreach ($item["subelements"] as $subkey => $subitem) {
128 $subfield = new $subitem["type"]($this->plugin_object->txt($key . "_" . $subkey), $key . "_" . $subkey);
129 $subfield->setInfo($this->plugin_object->txt($subitem["info"]));
130 $field->addSubItem($subfield);
131 }
132 }
133
134 $this->form->addItem($field);
135 }
136
137 $this->form->addCommandButton("save", $lng->txt("save"));
138
139 $this->form->setTitle($this->plugin_object->txt("configuration"));
140 $this->form->setFormAction($ilCtrl->getFormAction($this));
141
142 return $this->form;
143 }
144
145
146 public function save()
147 {
148 global $DIC;
149 $tpl = $DIC['tpl'];
150 $ilCtrl = $DIC['ilCtrl'];
151
152 $this->initConfigurationForm();
153 if ($this->form->checkInput()) {
154
155 // Save Checkbox Values
156 foreach ($this->fields as $key => $item) {
157 $this->object->setValue($key, $this->form->getInput($key));
158 if (is_array($item["subelements"])) {
159 foreach ($item["subelements"] as $subkey => $subitem) {
160 $this->object->setValue($key . "_" . $subkey, $this->form->getInput($key . "_" . $subkey));
161 }
162 }
163 }
164
165 $ilCtrl->redirect($this, "configure");
166 } else {
167 $this->form->setValuesByPost();
168 $tpl->setContent($this->form->getHtml());
169 }
170 }
171}
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.
global $ilCtrl
Definition: ilias.php:18
$lng
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$errors fields
Definition: imgupload.php:51
$DIC
Definition: xapitoken.php:46