ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
19{
23 protected $cloud_object;
24
28 protected $form;
29
30
31 public function setCloudObject(ilObjCloud $object)
32 {
33 $this->cloud_object = $object;
34 }
35
39 function editSettings()
40 {
41 global $DIC;
42 $tpl = $DIC['tpl'];
43 $ilTabs = $DIC['ilTabs'];
44 $lng = $DIC['lng'];
45
46 $ilTabs->activateTab("settings");
47
48 try
49 {
50 $this->initSettingsForm();
51 $this->getSettingsValues();
52 $tpl->setContent($this->form->getHTML());
53 } catch (Exception $e)
54 {
55 ilUtil::sendFailure($e->getMessage());
56 }
57 }
58
59 public function initSettingsForm()
60 {
61 global $DIC;
62 $ilCtrl = $DIC['ilCtrl'];
63 $lng = $DIC['lng'];
64
65 $this->form = new ilPropertyFormGUI();
66
67 // title
68 $ti = new ilTextInputGUI($lng->txt("title"), "title");
69 $ti->setRequired(true);
70 $this->form->addItem($ti);
71
72 // description
73 $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
74 $this->form->addItem($ta);
75
76 // online
77 $cb = new ilCheckboxInputGUI($lng->txt("online"), "online");
78 $this->form->addItem($cb);
79
80 $folder = new ilTextInputGUI($lng->txt("cld_root_folder"), "root_folder");
81 if(!$this->cloud_object->currentUserIsOwner())
82 {
83 $folder->setDisabled(true);
84 $folder->setInfo($lng->txt("cld_only_owner_has_permission_to_change_root_path"));
85 }
86
87 $folder->setMaxLength(255);
88 $folder->setSize(50);
89 $this->form->addItem($folder);
90
91 $this->createPluginSection();
92 $this->initPluginSettings();
93
94 $this->form->addCommandButton("updateSettings", $lng->txt("save"));
95
96 $this->form->setTitle($lng->txt("cld_edit_Settings"));
97 $this->form->setFormAction($ilCtrl->getFormActionByClass("ilCloudPluginSettingsGUI"));
98 }
99 protected function createPluginSection()
100 {
101 if(get_class($this) != "ilCloudPluginSettingsGUI" && $this->getMakeOwnPluginSection())
102 {
103 global $DIC;
104 $lng = $DIC['lng'];
106 $section->setTitle($this->cloud_object->getServiceName()." ".$lng->txt("cld_service_specific_settings"));
107 $this->form->addItem($section);
108 }
109 }
110
111 protected function initPluginSettings(){}
112
113 protected function getMakeOwnPluginSection()
114 {
115 return true;
116 }
117
122 {
123 $values["title"] = $this->cloud_object->getTitle();
124 $values["desc"] = $this->cloud_object->getDescription();
125 $values["online"] = $this->cloud_object->getOnline();
126 $values["root_folder"] = $this->cloud_object->getRootFolder();
127 $this->getPluginSettingsValues($values);
128 $this->form->setValuesByArray($values);
129 }
130
131
132 protected function getPluginSettingsValues(&$values){}
136 public function updateSettings()
137 {
138 global $DIC;
139 $tpl = $DIC['tpl'];
140 $lng = $DIC['lng'];
141 $ilCtrl = $DIC['ilCtrl'];
142 $ilTabs = $DIC['ilTabs'];
143
144 $ilTabs->activateTab("settings");
145
146 try
147 {
148 $this->initSettingsForm();
149 if ($this->form->checkInput())
150 {
151 $this->cloud_object->setTitle($this->form->getInput("title"));
152 $this->cloud_object->setDescription($this->form->getInput("desc"));
153 $this->updatePluginSettings();
154 if (ilCloudUtil::normalizePath($this->form->getInput("root_folder")) != $this->cloud_object->getRootFolder())
155 {
156 $this->cloud_object->setRootFolder($this->form->getInput("root_folder"));
157 $this->cloud_object->setRootId($this->getService()->getRootId($this->cloud_object->getRootFolder()));
158 }
159
160 $this->cloud_object->setOnline($this->form->getInput("online"));
161 $this->cloud_object->update();
162 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
163 $ilCtrl->redirect($this, 'editSettings');
164 }
165 } catch (Exception $e)
166 {
167 ilUtil::sendFailure($e->getMessage());
168 }
169
170 $this->form->setValuesByPost();
171 $tpl->setContent($this->form->getHtml());
172 }
173 protected function updatePluginSettings(){}
174
175}
176
177?>
global $tpl
Definition: ilias.php:8
$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.
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
global $DIC