ILIAS  release_4-4 Revision
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, 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.
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  }
initSettingsTemplateForm($a_mode="edit")
Init settings template form.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
+ Here is the call graph for this function:

◆ confirmSettingsTemplateDeletion()

ilSettingsTemplateGUI::confirmSettingsTemplateDeletion ( )

Confirm settings template deletion.

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

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

358  {
359  global $ilCtrl, $tpl, $lng;
360 
361  if (!is_array($_POST["tid"]) || count($_POST["tid"]) == 0)
362  {
363  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
364  $ilCtrl->redirect($this, "listSettingsTemplates");
365  }
366  else
367  {
368  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
369  $cgui = new ilConfirmationGUI();
370  $cgui->setFormAction($ilCtrl->getFormAction($this));
371  $cgui->setHeaderText($lng->txt("adm_sure_delete_settings_template"));
372  $cgui->setCancel($lng->txt("cancel"), "listSettingsTemplates");
373  $cgui->setConfirm($lng->txt("delete"), "deleteSettingsTemplate");
374 
375  foreach ($_POST["tid"] as $i)
376  {
377  $cgui->addItem("tid[]", $i, ilSettingsTemplate::lookupTitle($i));
378  }
379 
380  $tpl->setContent($cgui->getHTML());
381  }
382  }
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
static lookupTitle($a_id)
Lookup title.
global $lng
Definition: privfeed.php:40
Confirmation screen class.
+ Here is the call graph for this function:

◆ deleteSettingsTemplate()

ilSettingsTemplateGUI::deleteSettingsTemplate ( )

Delete settings template.

Parameters

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

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

391  {
392  global $ilCtrl, $lng;
393 
394  if (is_array($_POST["tid"]))
395  {
396  foreach ($_POST["tid"] as $i)
397  {
398  $templ = new ilSettingsTemplate($i);
399  $templ->delete();
400  }
401  }
402  ilUtil::sendSuccess("msg_obj_modified");
403  $ilCtrl->redirect($this, "listSettingsTemplates");
404  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
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  }
getSettingsTemplateValues()
Get current values for settings template from.
initSettingsTemplateForm($a_mode="edit")
Init settings template form.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
+ 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 235 of file class.ilSettingsTemplateGUI.php.

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

Referenced by editSettingsTemplate().

236  {
237  $values = array();
238 
239  $values["title"] = $this->settings_template->getTitle();
240  $values["description"] = $this->settings_template->getDescription();
241 
242  // save tabs to be hidden
243  $tabs = $this->settings_template->getHiddenTabs();
244  foreach ($tabs as $t)
245  {
246  $values["tab_".$t] = true;
247  }
248 
249  // save settings values
250  $set = $this->settings_template->getSettings();
251  foreach($this->getConfig()->getSettings() as $s)
252  {
253  if (isset($set[$s["id"]]))
254  {
255  $values["set_".$s["id"]] = true;
256 
257  if ($s['type'] == ilSettingsTemplateConfig::CHECKBOX) {
258  if (!is_array($set[$s["id"]]["value"]))
259  $ar = @unserialize($set[$s["id"]]["value"]);
260  else
261  $ar = $set[$s["id"]]["value"];
262  $values["value_".$s["id"]] = is_array($ar) ? $ar : array();
263  }
264  else {
265  $values["value_".$s["id"]] = $set[$s["id"]]["value"];
266  }
267 
268  $values["hide_".$s["id"]] = $set[$s["id"]]["hide"];
269  }
270  }
271  $this->form->setValuesByArray($values);
272  }
+ 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, 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  $this->form->addItem($ti);
141 
142  // description
143  $ti = new ilTextAreaInputGUI($lng->txt("description"), "description");
144  $this->form->addItem($ti);
145 
146  // hidable tabs
147  $tabs = $this->getConfig()->getHidableTabs();
148  if (is_array($tabs) && count($tabs) > 0)
149  {
150  $sec = new ilFormSectionHeaderGUI();
151  $sec->setTitle($lng->txt("adm_hide_tabs"));
152  $this->form->addItem($sec);
153 
154  foreach($tabs as $t)
155  {
156  // hide tab $t?
157  $cb = new ilCheckboxInputGUI($t["text"], "tab_".$t["id"]);
158  $this->form->addItem($cb);
159  }
160  }
161 
162  // settings
163  $settings = $this->getConfig()->getSettings();
164  if (is_array($settings) && count($settings) > 0)
165  {
166  $sec = new ilFormSectionHeaderGUI();
167  $sec->setTitle($lng->txt("adm_predefined_settings"));
168  $this->form->addItem($sec);
169 
170  foreach($settings as $s)
171  {
172  // setting
173  $cb = new ilCheckboxInputGUI($s["text"], "set_".$s["id"]);
174  $this->form->addItem($cb);
175 
176  switch ($s["type"])
177  {
179 
180  $ti = new ilTextInputGUI($lng->txt("adm_value"), "value_".$s["id"]);
181  //$ti->setMaxLength();
182  //$ti->setSize();
183  $cb->addSubItem($ti);
184  break;
185 
187  $cb2 = new ilCheckboxInputGUI($lng->txt("adm_value"), "value_".$s["id"]);
188  $cb->addSubItem($cb2);
189  break;
190 
192  $si = new ilSelectInputGUI($lng->txt("adm_value"), "value_".$s["id"]);
193  $si->setOptions($s["options"]);
194  $cb->addSubItem($si);
195  break;
196 
198  $chbs = new ilCheckboxGroupInputGUI($lng->txt("adm_value"), "value_".$s["id"]);
199  foreach($s['options'] as $key => $value) {
200  $chbs->addOption($c = new ilCheckboxInputGUI($value, $key));
201  $c->setValue($key);
202  }
203  $cb->addSubItem($chbs);
204  break;
205  }
206 
207  if ($s['hidable']) {
208  // hide setting
209  $cb_hide = new ilCheckboxInputGUI($lng->txt("adm_hide"), "hide_".$s["id"]);
210  $cb->addSubItem($cb_hide);
211  }
212  }
213  }
214 
215  // save and cancel commands
216  if ($a_mode == "create")
217  {
218  $this->form->addCommandButton("saveSettingsTemplate", $lng->txt("save"));
219  $this->form->addCommandButton("listSettingsTemplates", $lng->txt("cancel"));
220  $this->form->setTitle($lng->txt("adm_add_settings_template"));
221  }
222  else
223  {
224  $this->form->addCommandButton("updateSettingsTemplate", $lng->txt("save"));
225  $this->form->addCommandButton("listSettingsTemplates", $lng->txt("cancel"));
226  $this->form->setTitle($lng->txt("adm_edit_settings_template"));
227  }
228 
229  $this->form->setFormAction($ilCtrl->getFormAction($this));
230  }
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:40
This class represents a text area property in a property form.
+ 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 $ilCtrl
Definition: ilias.php:18
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
+ 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 277 of file class.ilSettingsTemplateGUI.php.

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

278  {
279  global $tpl, $lng, $ilCtrl;
280 
281  $this->initSettingsTemplateForm("create");
282  if ($this->form->checkInput())
283  {
284  $settings_template = new ilSettingsTemplate();
285  $settings_template->setType($this->getConfig()->getType());
286 
287  $this->setValuesFromForm($settings_template);
288  $settings_template->create();
289 
290  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
291  $ilCtrl->redirect($this, "listSettingsTemplates");
292  }
293 
294  $this->form->setValuesByPost();
295  $tpl->setContent($this->form->getHtml());
296  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
setValuesFromForm($a_set_templ)
Set values from form.
initSettingsTemplateForm($a_mode="edit")
Init settings template form.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
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 325 of file class.ilSettingsTemplateGUI.php.

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

Referenced by saveSettingsTemplate(), and updateSettingsTemplate().

326  {
327  // perform update
328  $a_set_templ->setTitle($_POST["title"]);
329  $a_set_templ->setDescription($_POST["description"]);
330 
331  // save tabs to be hidden
332  $a_set_templ->removeAllHiddenTabs();
333  foreach ($this->getConfig()->getHidableTabs() as $t)
334  {
335  if ($_POST["tab_".$t["id"]])
336  {
337  $a_set_templ->addHiddenTab($t["id"]);
338  }
339  }
340 
341  // save settings values
342  $a_set_templ->removeAllSettings();
343  foreach($this->getConfig()->getSettings() as $s)
344  {
345  if ($_POST["set_".$s["id"]])
346  {
347  $a_set_templ->setSetting(
348  $s["id"], $_POST["value_".$s["id"]],
349  $_POST["hide_".$s["id"]]);
350  }
351  }
352  }
$_POST['username']
Definition: cron.php:12
+ 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 301 of file class.ilSettingsTemplateGUI.php.

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

302  {
303  global $lng, $ilCtrl, $tpl;
304 
305  $this->initSettingsTemplateForm("edit");
306  if ($this->form->checkInput())
307  {
308  $this->setValuesFromForm($this->settings_template);
309  $this->settings_template->update();
310 
311  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
312  $ilCtrl->redirect($this, "listSettingsTemplates");
313  }
314 
315  $this->form->setValuesByPost();
316  $tpl->setContent($this->form->getHtml());
317  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
setValuesFromForm($a_set_templ)
Set values from form.
initSettingsTemplateForm($a_mode="edit")
Init settings template form.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
+ 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: