ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
4 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
5 include_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  public 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  $this->initSettingsForm();
50  $this->getSettingsValues();
51  $tpl->setContent($this->form->getHTML());
52  } catch (Exception $e) {
53  ilUtil::sendFailure($e->getMessage());
54  }
55  }
56 
57  public function initSettingsForm()
58  {
59  global $DIC;
60  $ilCtrl = $DIC['ilCtrl'];
61  $lng = $DIC['lng'];
62 
63  $this->form = new ilPropertyFormGUI();
64 
65  // title
66  $ti = new ilTextInputGUI($lng->txt("title"), "title");
67  $ti->setRequired(true);
68  $this->form->addItem($ti);
69 
70  // description
71  $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
72  $this->form->addItem($ta);
73 
74  // online
75  $cb = new ilCheckboxInputGUI($lng->txt("online"), "online");
76  $this->form->addItem($cb);
77 
78  $folder = new ilTextInputGUI($lng->txt("cld_root_folder"), "root_folder");
79  if (!$this->cloud_object->currentUserIsOwner()) {
80  $folder->setDisabled(true);
81  $folder->setInfo($lng->txt("cld_only_owner_has_permission_to_change_root_path"));
82  }
83 
84  $folder->setMaxLength(255);
85  $folder->setSize(50);
86  $this->form->addItem($folder);
87 
88  $this->createPluginSection();
89  $this->initPluginSettings();
90 
91  $this->form->addCommandButton("updateSettings", $lng->txt("save"));
92 
93  $this->form->setTitle($lng->txt("cld_edit_Settings"));
94  $this->form->setFormAction($ilCtrl->getFormActionByClass("ilCloudPluginSettingsGUI"));
95  }
96  protected function createPluginSection()
97  {
98  if (get_class($this) != "ilCloudPluginSettingsGUI" && $this->getMakeOwnPluginSection()) {
99  global $DIC;
100  $lng = $DIC['lng'];
102  $section->setTitle($this->cloud_object->getServiceName() . " " . $lng->txt("cld_service_specific_settings"));
103  $this->form->addItem($section);
104  }
105  }
106 
107  protected function initPluginSettings()
108  {
109  }
110 
111  protected function getMakeOwnPluginSection()
112  {
113  return true;
114  }
115 
119  public function getSettingsValues()
120  {
121  $values["title"] = $this->cloud_object->getTitle();
122  $values["desc"] = $this->cloud_object->getDescription();
123  $values["online"] = $this->cloud_object->getOnline();
124  $values["root_folder"] = $this->cloud_object->getRootFolder();
126  $this->form->setValuesByArray($values);
127  }
128 
129 
130  protected function getPluginSettingsValues(&$values)
131  {
132  }
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  $this->initSettingsForm();
148  if ($this->form->checkInput()) {
149  $this->cloud_object->setTitle($this->form->getInput("title"));
150  $this->cloud_object->setDescription($this->form->getInput("desc"));
151  $this->updatePluginSettings();
152  if (ilCloudUtil::normalizePath($this->form->getInput("root_folder")) != $this->cloud_object->getRootFolder()) {
153  $this->cloud_object->setRootFolder($this->form->getInput("root_folder"));
154  $this->cloud_object->setRootId($this->getService()->getRootId($this->cloud_object->getRootFolder()));
155  }
156 
157  $this->cloud_object->setOnline($this->form->getInput("online"));
158  $this->cloud_object->update();
159  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
160  $ilCtrl->redirect($this, 'editSettings');
161  }
162  } catch (Exception $e) {
163  ilUtil::sendFailure($e->getMessage());
164  }
165 
166  $this->form->setValuesByPost();
167  $tpl->setContent($this->form->getHtml());
168  }
169  protected function updatePluginSettings()
170  {
171  }
172 }
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
This class represents a section header in a property form.
This class represents a checkbox property in a property form.
Class ilCloudPluginSettingsGUI.
global $ilCtrl
Definition: ilias.php:18
$section
Definition: Utf8Test.php:83
$lng
$values
This class represents a text property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
This class represents a text area property in a property form.
Class ilObjCloud.
getSettingsValues()
Get values for edit Settings form.
static normalizePath($path)
setDisabled($a_disabled)
Set Disabled.
setRequired($a_required)
Set Required.
Class ilCloudPluginGUI.