ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilCloudPluginSettingsGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
5include_once("class.ilCloudUtil.php");
6
17{
18
22 protected $cloud_object;
26 protected $form;
27
28
34 public function __construct($plugin_service_class)
35 {
36 global $DIC;
37 parent::__construct($plugin_service_class);
38
39 $DIC->language()->loadLanguageModule('content');
40 $DIC->language()->loadLanguageModule('obj');
41 $DIC->language()->loadLanguageModule('cntr');
42 }
43
44
48 public function setCloudObject(ilObjCloud $object)
49 {
50 $this->cloud_object = $object;
51 }
52
53
57 public function editSettings()
58 {
59 global $DIC;
60 $tpl = $DIC['tpl'];
61 $ilTabs = $DIC['ilTabs'];
62
63 $ilTabs->activateTab("settings");
64
65 try {
66 $this->initSettingsForm();
67 $this->getSettingsValues();
68 $tpl->setContent($this->form->getHTML());
69 } catch (Exception $e) {
70 ilUtil::sendFailure($e->getMessage());
71 }
72 }
73
74
78 public function initSettingsForm()
79 {
80 global $DIC;
81 $ilCtrl = $DIC['ilCtrl'];
82 $lng = $DIC['lng'];
83
84 $this->form = new ilPropertyFormGUI();
85
86 // title
87 $ti = new ilTextInputGUI($lng->txt("title"), "title");
88 $ti->setRequired(true);
89 $this->form->addItem($ti);
90
91 // description
92 $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
93 $this->form->addItem($ta);
94
95 // online
96 $cb = new ilCheckboxInputGUI($lng->txt("online"), "online");
97 $this->form->addItem($cb);
98
99 $folder = new ilTextInputGUI($lng->txt("cld_root_folder"), "root_folder");
100 if (!$this->cloud_object->currentUserIsOwner()) {
101 $folder->setDisabled(true);
102 $folder->setInfo($lng->txt("cld_only_owner_has_permission_to_change_root_path"));
103 }
104
105 $folder->setMaxLength(255);
106 $folder->setSize(50);
107 $this->form->addItem($folder);
108
109 $this->createPluginSection();
110 $this->initPluginSettings();
111
113
114 $this->form->addCommandButton("updateSettings", $lng->txt("save"));
115
116 $this->form->setTitle($lng->txt("cld_edit_Settings"));
117 $this->form->setFormAction($ilCtrl->getFormActionByClass("ilCloudPluginSettingsGUI"));
118 }
119
120
124 protected function createPluginSection()
125 {
126 if (get_class($this) != "ilCloudPluginSettingsGUI" && $this->getMakeOwnPluginSection()) {
127 global $DIC;
128 $lng = $DIC['lng'];
130 $section->setTitle($this->cloud_object->getServiceName() . " " . $lng->txt("cld_service_specific_settings"));
131 $this->form->addItem($section);
132 }
133 }
134
135
139 protected function initPluginSettings()
140 {
141 }
142
143
147 protected function initPresentationSection()
148 {
149 global $DIC;
150 $section_appearance = new ilFormSectionHeaderGUI();
151 $section_appearance->setTitle($DIC->language()->txt('cont_presentation'));
152 $this->form->addItem($section_appearance);
153 $DIC->object()->commonSettings()->legacyForm($this->form, $this->cloud_object)->addTileImage();
154 }
155
156
160 protected function getMakeOwnPluginSection()
161 {
162 return true;
163 }
164
165
169 public function getSettingsValues()
170 {
171 $values["title"] = $this->cloud_object->getTitle();
172 $values["desc"] = $this->cloud_object->getDescription();
173 $values["online"] = $this->cloud_object->getOnline();
174 $values["root_folder"] = $this->cloud_object->getRootFolder();
175 $this->getPluginSettingsValues($values);
176 $this->form->setValuesByArray($values, true);
177 }
178
179
183 protected function getPluginSettingsValues(&$values)
184 {
185 }
186
187
191 public function updateSettings()
192 {
193 global $DIC;
194 $tpl = $DIC['tpl'];
195 $lng = $DIC['lng'];
196 $ilCtrl = $DIC['ilCtrl'];
197 $ilTabs = $DIC['ilTabs'];
198
199 $ilTabs->activateTab("settings");
200
201 try {
202 $this->initSettingsForm();
204 if ($this->form->checkInput()) {
205 $this->cloud_object->setTitle($this->form->getInput("title"));
206 $this->cloud_object->setDescription($this->form->getInput("desc"));
207 $this->updatePluginSettings();
208 if (ilCloudUtil::normalizePath($this->form->getInput("root_folder")) != $this->cloud_object->getRootFolder()) {
209 $this->cloud_object->setRootFolder($this->form->getInput("root_folder"));
210 $this->cloud_object->setRootId($this->getService()->getRootId($this->cloud_object->getRootFolder()));
211 }
212
213 $this->cloud_object->setOnline($this->form->getInput("online"));
214 $this->cloud_object->update();
215
216 $DIC->object()->commonSettings()->legacyForm($this->form, $this->cloud_object)->saveTileImage();
217
218 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
219 $ilCtrl->redirect($this, 'editSettings');
220 }
221 } catch (Exception $e) {
222 ilUtil::sendFailure($e->getMessage());
223 }
224
225 $this->form->setValuesByPost();
226 $tpl->setContent($this->form->getHtml());
227 }
228
229
233 protected function updatePluginSettings()
234 {
235 }
236}
$section
Definition: Utf8Test.php:83
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
Class ilCloudPluginGUI.
Class ilCloudPluginSettingsGUI.
getSettingsValues()
Get values for edit Settings form.
__construct($plugin_service_class)
ilCloudPluginSettingsGUI constructor.
static normalizePath($path)
This class represents a section header in a property form.
Class ilObjCloud.
This class represents a property form user interface.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$lng