ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSettingsTemplateGUI Class Reference

Settings template. More...

+ Collaboration diagram for ilSettingsTemplateGUI:

Public Member Functions

 __construct ($a_config)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 setConfig ($a_val)
 Set config object. More...
 
 getConfig ()
 Get config object. More...
 
 readSettingsTemplate ()
 Read settings template. More...
 
 listSettingsTemplates ()
 List all settings template. More...
 
 addSettingsTemplate ()
 Add settings template. More...
 
 editSettingsTemplate ()
 Edit settings template. More...
 
 initSettingsTemplateForm ($a_mode="edit")
 Init settings template form. More...
 
 getSettingsTemplateValues ()
 Get current values for settings template from. More...
 
 saveSettingsTemplate ()
 Save settings template form. More...
 
 updateSettingsTemplate ()
 Update settings template. More...
 
 setValuesFromForm ($a_set_templ)
 Set values from form. More...
 
 confirmSettingsTemplateDeletion ()
 Confirm settings template deletion. More...
 
 deleteSettingsTemplate ()
 Delete settings template. More...
 

Protected Attributes

 $ctrl
 
 $tpl
 
 $toolbar
 
 $lng
 
 $dic
 
 $rbacsystem
 

Private Attributes

 $config
 

Detailed Description

Settings template.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilSettingsTemplateGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSettingsTemplateGUI::__construct (   $a_config)

Constructor.

Parameters

Definition at line 51 of file class.ilSettingsTemplateGUI.php.

References $DIC, $ilCtrl, readSettingsTemplate(), and setConfig().

52  {
53  global $DIC;
54  $this->dic = $DIC;
55  $this->rbacsystem = $this->dic->rbac()->system();
56  $this->ctrl = $this->dic->ctrl();
57  $this->tpl = $this->dic["tpl"];
58  $this->toolbar = $this->dic->toolbar();
59  $this->lng = $this->dic->language();
60  $ilCtrl = $this->dic->ctrl();
61 
62  $ilCtrl->saveParameter($this, array("templ_id"));
63 
64  $this->setConfig($a_config);
65 
66  $this->readSettingsTemplate();
67  }
global $ilCtrl
Definition: ilias.php:18
readSettingsTemplate()
Read settings template.
setConfig($a_val)
Set config object.
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ addSettingsTemplate()

ilSettingsTemplateGUI::addSettingsTemplate ( )

Add settings template.

Definition at line 148 of file class.ilSettingsTemplateGUI.php.

References $tpl, and initSettingsTemplateForm().

149  {
150  $tpl = $this->tpl;
151 
152  $this->initSettingsTemplateForm("create");
153  $tpl->setContent($this->form->getHTML());
154  }
initSettingsTemplateForm($a_mode="edit")
Init settings template form.
+ Here is the call graph for this function:

◆ confirmSettingsTemplateDeletion()

ilSettingsTemplateGUI::confirmSettingsTemplateDeletion ( )

Confirm settings template deletion.

Definition at line 402 of file class.ilSettingsTemplateGUI.php.

References $_POST, $ctrl, $i, $ilCtrl, $lng, $tpl, ilSettingsTemplate\lookupTitle(), and ilUtil\sendInfo().

403  {
405  $tpl = $this->tpl;
406  $lng = $this->lng;
407 
408  if (!is_array($_POST["tid"]) || count($_POST["tid"]) == 0) {
409  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
410  $ilCtrl->redirect($this, "listSettingsTemplates");
411  } else {
412  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
413  $cgui = new ilConfirmationGUI();
414  $cgui->setFormAction($ilCtrl->getFormAction($this));
415  $cgui->setHeaderText($lng->txt("adm_sure_delete_settings_template"));
416  $cgui->setCancel($lng->txt("cancel"), "listSettingsTemplates");
417  $cgui->setConfirm($lng->txt("delete"), "deleteSettingsTemplate");
418 
419  foreach ($_POST["tid"] as $i) {
420  $cgui->addItem("tid[]", $i, ilSettingsTemplate::lookupTitle($i));
421  }
422 
423  $tpl->setContent($cgui->getHTML());
424  }
425  }
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static lookupTitle($a_id)
Lookup title.
$_POST["username"]
$i
Definition: metadata.php:24
Confirmation screen class.
+ Here is the call graph for this function:

◆ deleteSettingsTemplate()

ilSettingsTemplateGUI::deleteSettingsTemplate ( )

Delete settings template.

Parameters

Definition at line 433 of file class.ilSettingsTemplateGUI.php.

References $_POST, $ctrl, $i, $ilCtrl, and $lng.

434  {
436  $lng = $this->lng;
437 
438  if (is_array($_POST["tid"])) {
439  foreach ($_POST["tid"] as $i) {
440  $templ = new ilSettingsTemplate($i);
441  $templ->delete();
442  }
443  }
444  ilUtil::sendSuccess("msg_obj_modified");
445  $ilCtrl->redirect($this, "listSettingsTemplates");
446  }
global $ilCtrl
Definition: ilias.php:18
$_POST["username"]
Settings template application class.
$i
Definition: metadata.php:24

◆ editSettingsTemplate()

ilSettingsTemplateGUI::editSettingsTemplate ( )

Edit settings template.

Definition at line 159 of file class.ilSettingsTemplateGUI.php.

References $tpl, getSettingsTemplateValues(), and initSettingsTemplateForm().

160  {
161  $tpl = $this->tpl;
162 
163  $this->initSettingsTemplateForm("edit");
164  $this->getSettingsTemplateValues();
165  $tpl->setContent($this->form->getHTML());
166  }
getSettingsTemplateValues()
Get current values for settings template from.
initSettingsTemplateForm($a_mode="edit")
Init settings template form.
+ Here is the call graph for this function:

◆ executeCommand()

ilSettingsTemplateGUI::executeCommand ( )

Execute command.

Definition at line 72 of file class.ilSettingsTemplateGUI.php.

References $ctrl, and $ilCtrl.

73  {
75 
76  $cmd = $ilCtrl->getCmd("listSettingsTemplates");
77  $this->$cmd();
78  }
global $ilCtrl
Definition: ilias.php:18

◆ getConfig()

ilSettingsTemplateGUI::getConfig ( )

Get config object.

Returns
object config object

Definition at line 95 of file class.ilSettingsTemplateGUI.php.

References $config.

Referenced by getSettingsTemplateValues(), initSettingsTemplateForm(), listSettingsTemplates(), readSettingsTemplate(), saveSettingsTemplate(), and setValuesFromForm().

+ Here is the caller graph for this function:

◆ getSettingsTemplateValues()

ilSettingsTemplateGUI::getSettingsTemplateValues ( )

Get current values for settings template from.

Definition at line 283 of file class.ilSettingsTemplateGUI.php.

References ilSettingsTemplateConfig\CHECKBOX, and getConfig().

Referenced by editSettingsTemplate().

284  {
285  $values = array();
286 
287  $values["title"] = $this->settings_template->getTitle();
288  $values["description"] = $this->settings_template->getDescription();
289 
290  // save tabs to be hidden
291  $tabs = $this->settings_template->getHiddenTabs();
292  foreach ($tabs as $t) {
293  $values["tab_" . $t] = true;
294  }
295 
296  // save settings values
297  $set = $this->settings_template->getSettings();
298  foreach ($this->getConfig()->getSettings() as $s) {
299  if (isset($set[$s["id"]])) {
300  $values["set_" . $s["id"]] = true;
301 
302  if ($s['type'] == ilSettingsTemplateConfig::CHECKBOX) {
303  if (!is_array($set[$s["id"]]["value"])) {
304  $ar = @unserialize($set[$s["id"]]["value"]);
305  } else {
306  $ar = $set[$s["id"]]["value"];
307  }
308  $values["value_" . $s["id"]] = is_array($ar) ? $ar : array();
309  } else {
310  $values["value_" . $s["id"]] = $set[$s["id"]]["value"];
311  }
312 
313  $values["hide_" . $s["id"]] = $set[$s["id"]]["hide"];
314  }
315  }
316  $this->form->setValuesByArray($values);
317  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSettingsTemplateForm()

ilSettingsTemplateGUI::initSettingsTemplateForm (   $a_mode = "edit")

Init settings template form.

Parameters
int$a_modeEdit Mode

Definition at line 173 of file class.ilSettingsTemplateGUI.php.

References $_GET, Vendor\Package\$c, $ctrl, $ilCtrl, $lng, $si, ilCheckboxGroupInputGUI\addOption(), ilSubEnabledFormPropertyGUI\addSubItem(), ilSettingsTemplateConfig\BOOL, ilSettingsTemplateConfig\CHECKBOX, getConfig(), ilSettingsTemplateConfig\SELECT, ilFormPropertyGUI\setDisabled(), and ilSettingsTemplateConfig\TEXT.

Referenced by addSettingsTemplate(), editSettingsTemplate(), saveSettingsTemplate(), and updateSettingsTemplate().

174  {
175  $lng = $this->lng;
177 
178  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
179  $this->form = new ilPropertyFormGUI();
180 
181  // title
182  $ti = new ilTextInputGUI($lng->txt("title"), "title");
183  $ti->setMaxLength(200);
184  $ti->setRequired(true);
185  // begin-patch lok
186  if ($this->settings_template->getAutoGenerated()) {
187  $ti->setDisabled(true);
188  }
189  // end-patch lok
190  $this->form->addItem($ti);
191 
192  // description
193  $ti = new ilTextAreaInputGUI($lng->txt("description"), "description");
194  // begin-patch lok
195  if ($this->settings_template->getAutoGenerated()) {
196  $ti->setDisabled(true);
197  }
198  $this->form->addItem($ti);
199 
200  // hidable tabs
201  $tabs = $this->getConfig()->getHidableTabs();
202  if (is_array($tabs) && count($tabs) > 0) {
203  $sec = new ilFormSectionHeaderGUI();
204  $sec->setTitle($lng->txt("adm_hide_tabs"));
205  $this->form->addItem($sec);
206 
207  foreach ($tabs as $t) {
208  // hide tab $t?
209  $cb = new ilCheckboxInputGUI($t["text"], "tab_" . $t["id"]);
210  $this->form->addItem($cb);
211  }
212  }
213 
214  // settings
215  $settings = $this->getConfig()->getSettings();
216  if (is_array($settings) && count($settings) > 0) {
217  $sec = new ilFormSectionHeaderGUI();
218  $sec->setTitle($lng->txt("adm_predefined_settings"));
219  $this->form->addItem($sec);
220 
221  foreach ($settings as $s) {
222  // setting
223  $cb = new ilCheckboxInputGUI($s["text"], "set_" . $s["id"]);
224  $this->form->addItem($cb);
225 
226  switch ($s["type"]) {
228 
229  $ti = new ilTextInputGUI($lng->txt("adm_value"), "value_" . $s["id"]);
230  //$ti->setMaxLength();
231  //$ti->setSize();
232  $cb->addSubItem($ti);
233  break;
234 
236  $cb2 = new ilCheckboxInputGUI($lng->txt("adm_value"), "value_" . $s["id"]);
237  $cb->addSubItem($cb2);
238  break;
239 
241  $si = new ilSelectInputGUI($lng->txt("adm_value"), "value_" . $s["id"]);
242  $si->setOptions($s["options"]);
243  $cb->addSubItem($si);
244  break;
245 
247  $chbs = new ilCheckboxGroupInputGUI($lng->txt("adm_value"), "value_" . $s["id"]);
248  foreach ($s['options'] as $key => $value) {
249  $chbs->addOption($c = new ilCheckboxInputGUI($value, $key));
250  $c->setValue($key);
251  }
252  $cb->addSubItem($chbs);
253  break;
254  }
255 
256  if ($s['hidable']) {
257  // hide setting
258  $cb_hide = new ilCheckboxInputGUI($lng->txt("adm_hide"), "hide_" . $s["id"]);
259  $cb->addSubItem($cb_hide);
260  }
261  }
262  }
263 
264  if ($this->rbacsystem->checkAccess('write', $_GET['ref_id'])) {
265  // save and cancel commands
266  if ($a_mode == "create") {
267  $this->form->addCommandButton("saveSettingsTemplate", $lng->txt("save"));
268  $this->form->addCommandButton("listSettingsTemplates", $lng->txt("cancel"));
269  $this->form->setTitle($lng->txt("adm_add_settings_template"));
270  } else {
271  $this->form->addCommandButton("updateSettingsTemplate", $lng->txt("save"));
272  $this->form->addCommandButton("listSettingsTemplates", $lng->txt("cancel"));
273  $this->form->setTitle($lng->txt("adm_edit_settings_template"));
274  }
275  }
276 
277  $this->form->setFormAction($ilCtrl->getFormAction($this));
278  }
This class represents a property form user interface.
$_GET["client_id"]
This class represents a section header in a property form.
This class represents a checkbox property in a property form.
global $ilCtrl
Definition: ilias.php:18
This class represents a property in a property form.
This class represents a text area property in a property form.
setDisabled($a_disabled)
Set Disabled.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listSettingsTemplates()

ilSettingsTemplateGUI::listSettingsTemplates ( )

List all settings template.

Parameters

Definition at line 121 of file class.ilSettingsTemplateGUI.php.

References $_GET, $ctrl, $ilCtrl, $lng, $toolbar, $tpl, and getConfig().

122  {
123  $tpl = $this->tpl;
124  $ilToolbar = $this->toolbar;
126  $lng = $this->lng;
127 
128  if ($this->rbacsystem->checkAccess('write', $_GET['ref_id'])) {
129  $ilToolbar->addButton(
130  $lng->txt("adm_add_settings_template"),
131  $ilCtrl->getLinkTarget($this, "addSettingsTemplate")
132  );
133  }
134 
135  include_once("./Services/Administration/classes/class.ilSettingsTemplateTableGUI.php");
136  $table = new ilSettingsTemplateTableGUI(
137  $this,
138  "listSettingsTemplates",
139  $this->getConfig()->getType()
140  );
141 
142  $tpl->setContent($table->getHTML());
143  }
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

◆ readSettingsTemplate()

ilSettingsTemplateGUI::readSettingsTemplate ( )

Read settings template.

Parameters

Definition at line 106 of file class.ilSettingsTemplateGUI.php.

References $_GET, and getConfig().

Referenced by __construct().

107  {
108  if ($this->getConfig()) {
109  $this->settings_template = new ilSettingsTemplate((int) $_GET["templ_id"], $this->getConfig());
110  } else {
111  $this->settings_template = new ilSettingsTemplate((int) $_GET["templ_id"]);
112  }
113  }
$_GET["client_id"]
Settings template application class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveSettingsTemplate()

ilSettingsTemplateGUI::saveSettingsTemplate ( )

Save settings template form.

Definition at line 322 of file class.ilSettingsTemplateGUI.php.

References $ctrl, $ilCtrl, $lng, $tpl, getConfig(), initSettingsTemplateForm(), and setValuesFromForm().

323  {
324  $tpl = $this->tpl;
325  $lng = $this->lng;
327 
328  $this->initSettingsTemplateForm("create");
329  if ($this->form->checkInput()) {
330  $settings_template = new ilSettingsTemplate();
331  $settings_template->setType($this->getConfig()->getType());
332 
333  $this->setValuesFromForm($settings_template);
334  $settings_template->create();
335 
336  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
337  $ilCtrl->redirect($this, "listSettingsTemplates");
338  }
339 
340  $this->form->setValuesByPost();
341  $tpl->setContent($this->form->getHtml());
342  }
global $ilCtrl
Definition: ilias.php:18
setValuesFromForm($a_set_templ)
Set values from form.
initSettingsTemplateForm($a_mode="edit")
Init settings template form.
Settings template application class.
+ Here is the call graph for this function:

◆ setConfig()

ilSettingsTemplateGUI::setConfig (   $a_val)

Set config object.

Parameters
object$a_valconfig object

Definition at line 85 of file class.ilSettingsTemplateGUI.php.

Referenced by __construct().

86  {
87  $this->config = $a_val;
88  }
+ Here is the caller graph for this function:

◆ setValuesFromForm()

ilSettingsTemplateGUI::setValuesFromForm (   $a_set_templ)

Set values from form.

Parameters

Definition at line 372 of file class.ilSettingsTemplateGUI.php.

References $_POST, and getConfig().

Referenced by saveSettingsTemplate(), and updateSettingsTemplate().

373  {
374  // perform update
375  $a_set_templ->setTitle($_POST["title"]);
376  $a_set_templ->setDescription($_POST["description"]);
377 
378  // save tabs to be hidden
379  $a_set_templ->removeAllHiddenTabs();
380  foreach ($this->getConfig()->getHidableTabs() as $t) {
381  if ($_POST["tab_" . $t["id"]]) {
382  $a_set_templ->addHiddenTab($t["id"]);
383  }
384  }
385 
386  // save settings values
387  $a_set_templ->removeAllSettings();
388  foreach ($this->getConfig()->getSettings() as $s) {
389  if ($_POST["set_" . $s["id"]]) {
390  $a_set_templ->setSetting(
391  $s["id"],
392  $_POST["value_" . $s["id"]],
393  $_POST["hide_" . $s["id"]]
394  );
395  }
396  }
397  }
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateSettingsTemplate()

ilSettingsTemplateGUI::updateSettingsTemplate ( )

Update settings template.

Definition at line 347 of file class.ilSettingsTemplateGUI.php.

References $ctrl, $ilCtrl, $lng, $tpl, initSettingsTemplateForm(), and setValuesFromForm().

348  {
349  $lng = $this->lng;
351  $tpl = $this->tpl;
352 
353  $this->initSettingsTemplateForm("edit");
354  if ($this->form->checkInput()) {
355  $this->setValuesFromForm($this->settings_template);
356  $this->settings_template->update();
357 
358  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
359  $ilCtrl->redirect($this, "listSettingsTemplates");
360  }
361 
362  $this->form->setValuesByPost();
363  $tpl->setContent($this->form->getHtml());
364  }
global $ilCtrl
Definition: ilias.php:18
setValuesFromForm($a_set_templ)
Set values from form.
initSettingsTemplateForm($a_mode="edit")
Init settings template form.
+ Here is the call graph for this function:

Field Documentation

◆ $config

ilSettingsTemplateGUI::$config
private

Definition at line 35 of file class.ilSettingsTemplateGUI.php.

Referenced by getConfig().

◆ $ctrl

◆ $dic

ilSettingsTemplateGUI::$dic
protected

Definition at line 39 of file class.ilSettingsTemplateGUI.php.

◆ $lng

◆ $rbacsystem

ilSettingsTemplateGUI::$rbacsystem
protected

Definition at line 43 of file class.ilSettingsTemplateGUI.php.

◆ $toolbar

ilSettingsTemplateGUI::$toolbar
protected

Definition at line 28 of file class.ilSettingsTemplateGUI.php.

Referenced by listSettingsTemplates().

◆ $tpl


The documentation for this class was generated from the following file: