ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 

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 23 of file class.ilSettingsTemplateGUI.php.

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

24  {
25  global $ilCtrl;
26 
27  $ilCtrl->saveParameter($this, array("templ_id"));
28 
29  $this->setConfig($a_config);
30 
31  $this->readSettingsTemplate();
32  }
global $ilCtrl
Definition: ilias.php:18
readSettingsTemplate()
Read settings template.
Create styles array
The data for the language used.
setConfig($a_val)
Set config object.
+ Here is the call graph for this function:

Member Function Documentation

◆ addSettingsTemplate()

ilSettingsTemplateGUI::addSettingsTemplate ( )

Add settings template.

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

References $tpl, and initSettingsTemplateForm().

105  {
106  global $tpl;
107 
108  $this->initSettingsTemplateForm("create");
109  $tpl->setContent($this->form->getHTML());
110  }
global $tpl
Definition: ilias.php:8
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 368 of file class.ilSettingsTemplateGUI.php.

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

369  {
370  global $ilCtrl, $tpl, $lng;
371 
372  if (!is_array($_POST["tid"]) || count($_POST["tid"]) == 0)
373  {
374  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
375  $ilCtrl->redirect($this, "listSettingsTemplates");
376  }
377  else
378  {
379  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
380  $cgui = new ilConfirmationGUI();
381  $cgui->setFormAction($ilCtrl->getFormAction($this));
382  $cgui->setHeaderText($lng->txt("adm_sure_delete_settings_template"));
383  $cgui->setCancel($lng->txt("cancel"), "listSettingsTemplates");
384  $cgui->setConfirm($lng->txt("delete"), "deleteSettingsTemplate");
385 
386  foreach ($_POST["tid"] as $i)
387  {
388  $cgui->addItem("tid[]", $i, ilSettingsTemplate::lookupTitle($i));
389  }
390 
391  $tpl->setContent($cgui->getHTML());
392  }
393  }
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static lookupTitle($a_id)
Lookup title.
global $lng
Definition: privfeed.php:17
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ deleteSettingsTemplate()

ilSettingsTemplateGUI::deleteSettingsTemplate ( )

Delete settings template.

Parameters

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

References $_POST, $ilCtrl, $lng, and ilUtil\sendSuccess().

402  {
403  global $ilCtrl, $lng;
404 
405  if (is_array($_POST["tid"]))
406  {
407  foreach ($_POST["tid"] as $i)
408  {
409  $templ = new ilSettingsTemplate($i);
410  $templ->delete();
411  }
412  }
413  ilUtil::sendSuccess("msg_obj_modified");
414  $ilCtrl->redirect($this, "listSettingsTemplates");
415  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
$_POST["username"]
Settings template application class.
+ Here is the call graph for this function:

◆ editSettingsTemplate()

ilSettingsTemplateGUI::editSettingsTemplate ( )

Edit settings template.

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

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

116  {
117  global $tpl;
118 
119  $this->initSettingsTemplateForm("edit");
120  $this->getSettingsTemplateValues();
121  $tpl->setContent($this->form->getHTML());
122  }
global $tpl
Definition: ilias.php:8
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 37 of file class.ilSettingsTemplateGUI.php.

References $cmd, and $ilCtrl.

38  {
39  global $ilCtrl;
40 
41  $cmd = $ilCtrl->getCmd("listSettingsTemplates");
42  $this->$cmd();
43  }
$cmd
Definition: sahs_server.php:35
global $ilCtrl
Definition: ilias.php:18

◆ getConfig()

ilSettingsTemplateGUI::getConfig ( )

Get config object.

Returns
object config object

Definition at line 60 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 246 of file class.ilSettingsTemplateGUI.php.

References $t, array, ilSettingsTemplateConfig\CHECKBOX, and getConfig().

Referenced by editSettingsTemplate().

247  {
248  $values = array();
249 
250  $values["title"] = $this->settings_template->getTitle();
251  $values["description"] = $this->settings_template->getDescription();
252 
253  // save tabs to be hidden
254  $tabs = $this->settings_template->getHiddenTabs();
255  foreach ($tabs as $t)
256  {
257  $values["tab_".$t] = true;
258  }
259 
260  // save settings values
261  $set = $this->settings_template->getSettings();
262  foreach($this->getConfig()->getSettings() as $s)
263  {
264  if (isset($set[$s["id"]]))
265  {
266  $values["set_".$s["id"]] = true;
267 
268  if ($s['type'] == ilSettingsTemplateConfig::CHECKBOX) {
269  if (!is_array($set[$s["id"]]["value"]))
270  $ar = @unserialize($set[$s["id"]]["value"]);
271  else
272  $ar = $set[$s["id"]]["value"];
273  $values["value_".$s["id"]] = is_array($ar) ? $ar : array();
274  }
275  else {
276  $values["value_".$s["id"]] = $set[$s["id"]]["value"];
277  }
278 
279  $values["hide_".$s["id"]] = $set[$s["id"]]["hide"];
280  }
281  }
282  $this->form->setValuesByArray($values);
283  }
Create styles array
The data for the language used.
+ 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 129 of file class.ilSettingsTemplateGUI.php.

References $ilCtrl, $lng, $si, $t, ilCheckboxGroupInputGUI\addOption(), ilSubEnabledFormPropertyGUI\addSubItem(), ilSettingsTemplateConfig\BOOL, ilSettingsTemplateConfig\CHECKBOX, getConfig(), ilSettingsTemplateConfig\SELECT, ilFormPropertyGUI\setDisabled(), ilTextInputGUI\setMaxLength(), and ilSettingsTemplateConfig\TEXT.

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

130  {
131  global $lng, $ilCtrl;
132 
133  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
134  $this->form = new ilPropertyFormGUI();
135 
136  // title
137  $ti = new ilTextInputGUI($lng->txt("title"), "title");
138  $ti->setMaxLength(200);
139  $ti->setRequired(true);
140  // begin-patch lok
141  if($this->settings_template->getAutoGenerated())
142  {
143  $ti->setDisabled(true);
144  }
145  // end-patch lok
146  $this->form->addItem($ti);
147 
148  // description
149  $ti = new ilTextAreaInputGUI($lng->txt("description"), "description");
150  // begin-patch lok
151  if($this->settings_template->getAutoGenerated())
152  {
153  $ti->setDisabled(true);
154  }
155  $this->form->addItem($ti);
156 
157  // hidable tabs
158  $tabs = $this->getConfig()->getHidableTabs();
159  if (is_array($tabs) && count($tabs) > 0)
160  {
161  $sec = new ilFormSectionHeaderGUI();
162  $sec->setTitle($lng->txt("adm_hide_tabs"));
163  $this->form->addItem($sec);
164 
165  foreach($tabs as $t)
166  {
167  // hide tab $t?
168  $cb = new ilCheckboxInputGUI($t["text"], "tab_".$t["id"]);
169  $this->form->addItem($cb);
170  }
171  }
172 
173  // settings
174  $settings = $this->getConfig()->getSettings();
175  if (is_array($settings) && count($settings) > 0)
176  {
177  $sec = new ilFormSectionHeaderGUI();
178  $sec->setTitle($lng->txt("adm_predefined_settings"));
179  $this->form->addItem($sec);
180 
181  foreach($settings as $s)
182  {
183  // setting
184  $cb = new ilCheckboxInputGUI($s["text"], "set_".$s["id"]);
185  $this->form->addItem($cb);
186 
187  switch ($s["type"])
188  {
190 
191  $ti = new ilTextInputGUI($lng->txt("adm_value"), "value_".$s["id"]);
192  //$ti->setMaxLength();
193  //$ti->setSize();
194  $cb->addSubItem($ti);
195  break;
196 
198  $cb2 = new ilCheckboxInputGUI($lng->txt("adm_value"), "value_".$s["id"]);
199  $cb->addSubItem($cb2);
200  break;
201 
203  $si = new ilSelectInputGUI($lng->txt("adm_value"), "value_".$s["id"]);
204  $si->setOptions($s["options"]);
205  $cb->addSubItem($si);
206  break;
207 
209  $chbs = new ilCheckboxGroupInputGUI($lng->txt("adm_value"), "value_".$s["id"]);
210  foreach($s['options'] as $key => $value) {
211  $chbs->addOption($c = new ilCheckboxInputGUI($value, $key));
212  $c->setValue($key);
213  }
214  $cb->addSubItem($chbs);
215  break;
216  }
217 
218  if ($s['hidable']) {
219  // hide setting
220  $cb_hide = new ilCheckboxInputGUI($lng->txt("adm_hide"), "hide_".$s["id"]);
221  $cb->addSubItem($cb_hide);
222  }
223  }
224  }
225 
226  // save and cancel commands
227  if ($a_mode == "create")
228  {
229  $this->form->addCommandButton("saveSettingsTemplate", $lng->txt("save"));
230  $this->form->addCommandButton("listSettingsTemplates", $lng->txt("cancel"));
231  $this->form->setTitle($lng->txt("adm_add_settings_template"));
232  }
233  else
234  {
235  $this->form->addCommandButton("updateSettingsTemplate", $lng->txt("save"));
236  $this->form->addCommandButton("listSettingsTemplates", $lng->txt("cancel"));
237  $this->form->setTitle($lng->txt("adm_edit_settings_template"));
238  }
239 
240  $this->form->setFormAction($ilCtrl->getFormAction($this));
241  }
This class represents a selection list property in a property form.
This class represents a property form user interface.
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 text property in a property form.
setMaxLength($a_maxlength)
Set Max Length.
This class represents a property in a property form.
global $lng
Definition: privfeed.php:17
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 87 of file class.ilSettingsTemplateGUI.php.

References $ilCtrl, $lng, $tpl, and getConfig().

88  {
89  global $tpl, $ilToolbar, $ilCtrl, $lng;
90 
91  $ilToolbar->addButton($lng->txt("adm_add_settings_template"),
92  $ilCtrl->getLinkTarget($this, "addSettingsTemplate"));
93 
94  include_once("./Services/Administration/classes/class.ilSettingsTemplateTableGUI.php");
95  $table = new ilSettingsTemplateTableGUI($this, "listSettingsTemplates",
96  $this->getConfig()->getType());
97 
98  $tpl->setContent($table->getHTML());
99  }
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ readSettingsTemplate()

ilSettingsTemplateGUI::readSettingsTemplate ( )

Read settings template.

Parameters

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

References $_GET, and getConfig().

Referenced by __construct().

72  {
73  if ($this->getConfig()) {
74  $this->settings_template = new ilSettingsTemplate((int) $_GET[templ_id], $this->getConfig());
75  }
76  else {
77  $this->settings_template = new ilSettingsTemplate((int) $_GET[templ_id]);
78  }
79  }
$_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 288 of file class.ilSettingsTemplateGUI.php.

References $ilCtrl, $lng, $tpl, getConfig(), initSettingsTemplateForm(), ilUtil\sendSuccess(), and setValuesFromForm().

289  {
290  global $tpl, $lng, $ilCtrl;
291 
292  $this->initSettingsTemplateForm("create");
293  if ($this->form->checkInput())
294  {
295  $settings_template = new ilSettingsTemplate();
296  $settings_template->setType($this->getConfig()->getType());
297 
298  $this->setValuesFromForm($settings_template);
299  $settings_template->create();
300 
301  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
302  $ilCtrl->redirect($this, "listSettingsTemplates");
303  }
304 
305  $this->form->setValuesByPost();
306  $tpl->setContent($this->form->getHtml());
307  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
setValuesFromForm($a_set_templ)
Set values from form.
initSettingsTemplateForm($a_mode="edit")
Init settings template form.
global $lng
Definition: privfeed.php:17
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 50 of file class.ilSettingsTemplateGUI.php.

Referenced by __construct().

51  {
52  $this->config = $a_val;
53  }
+ Here is the caller graph for this function:

◆ setValuesFromForm()

ilSettingsTemplateGUI::setValuesFromForm (   $a_set_templ)

Set values from form.

Parameters

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

References $_POST, $t, and getConfig().

Referenced by saveSettingsTemplate(), and updateSettingsTemplate().

337  {
338  // perform update
339  $a_set_templ->setTitle($_POST["title"]);
340  $a_set_templ->setDescription($_POST["description"]);
341 
342  // save tabs to be hidden
343  $a_set_templ->removeAllHiddenTabs();
344  foreach ($this->getConfig()->getHidableTabs() as $t)
345  {
346  if ($_POST["tab_".$t["id"]])
347  {
348  $a_set_templ->addHiddenTab($t["id"]);
349  }
350  }
351 
352  // save settings values
353  $a_set_templ->removeAllSettings();
354  foreach($this->getConfig()->getSettings() as $s)
355  {
356  if ($_POST["set_".$s["id"]])
357  {
358  $a_set_templ->setSetting(
359  $s["id"], $_POST["value_".$s["id"]],
360  $_POST["hide_".$s["id"]]);
361  }
362  }
363  }
$_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 312 of file class.ilSettingsTemplateGUI.php.

References $ilCtrl, $lng, $tpl, initSettingsTemplateForm(), ilUtil\sendSuccess(), and setValuesFromForm().

313  {
314  global $lng, $ilCtrl, $tpl;
315 
316  $this->initSettingsTemplateForm("edit");
317  if ($this->form->checkInput())
318  {
319  $this->setValuesFromForm($this->settings_template);
320  $this->settings_template->update();
321 
322  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
323  $ilCtrl->redirect($this, "listSettingsTemplates");
324  }
325 
326  $this->form->setValuesByPost();
327  $tpl->setContent($this->form->getHtml());
328  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
setValuesFromForm($a_set_templ)
Set values from form.
initSettingsTemplateForm($a_mode="edit")
Init settings template form.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

Field Documentation

◆ $config

ilSettingsTemplateGUI::$config
private

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

Referenced by getConfig().


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