ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.arConfigFormGUI.php
Go to the documentation of this file.
1<?php
2require_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
3require_once('class.arConfig.php');
4
13{
14
18 protected $parent_gui;
22 protected $ctrl;
23
24
28 public function __construct($parent_gui)
29 {
30 global $DIC;
31 $ilCtrl = $DIC['ilCtrl'];
32 $lng = $DIC['lng'];
33 $this->parent_gui = $parent_gui;
34 $this->ctrl = $ilCtrl;
35 $this->lng = $lng;
36 $this->ctrl->saveParameter($parent_gui, 'clip_ext_id');
37 $this->setFormAction($this->ctrl->getFormAction($parent_gui));
38 $this->initForm();
39 }
40
41
42 protected function initForm()
43 {
44 $this->setTitle($this->lng->txt('admin_form_title'));
45
46 $te = new ilTextInputGUI($this->lng->txt('admin_origins_path'), 'path');
47 $te->setInfo($this->lng->txt('admin_origins_path_info'));
48 $this->addItem($te);
49
50 $this->addCommandButtons();
51 }
52
53
54 public function fillForm()
55 {
56 $array = array();
57 foreach ($this->getItems() as $item) {
58 $this->getValuesForItem($item, $array);
59 }
60 $this->setValuesByArray($array);
61 }
62
63
70 private function getValuesForItem($item, &$array)
71 {
72 if (self::checkItem($item)) {
73 $key = $item->getPostVar();
74 $array[$key] = json_decode(arConfig::get($key));
75 if (self::checkForSubItem($item)) {
76 foreach ($item->getSubItems() as $subitem) {
77 $this->getValuesForItem($subitem, $array);
78 }
79 }
80 }
81 }
82
83
89 public function fillObject()
90 {
91 if (!$this->checkInput()) {
92 return false;
93 }
94
95 return true;
96 }
97
98
102 public function saveObject()
103 {
104 if (!$this->fillObject()) {
105 return false;
106 }
107 foreach ($this->getItems() as $item) {
108 $this->saveValueForItem($item);
109 }
110
111 return true;
112 }
113
114
118 private function saveValueForItem($item)
119 {
120 if (self::checkItem($item)) {
121 $key = $item->getPostVar();
122 arConfig::set($key, json_encode($this->getInput($key)));
123 if (self::checkForSubItem($item)) {
124 foreach ($item->getSubItems() as $subitem) {
125 $this->saveValueForItem($subitem);
126 }
127 }
128 }
129 }
130
131
137 public static function checkItem(ilPropertyFormGUI $item)
138 {
139 return !$item instanceof ilFormSectionHeaderGUI and !$item instanceof ilMultiSelectInputGUI;
140 }
141
142
148 public static function checkForSubItem(ilPropertyFormGUI $item)
149 {
150 return !$item instanceof ilMultiSelectInputGUI;
151 }
152
153
154 protected function addCommandButtons()
155 {
156 $this->addCommandButton('save', $this->lng->txt('admin_form_button_save'));
157 $this->addCommandButton('cancel', $this->lng->txt('admin_form_button_cancel'));
158 }
159}
An exception for terminatinating execution or to throw for unit testing.
GUI-Class arConfigFormGUI.
getValuesForItem($item, &$array)
fillObject()
returns whether checkinput was successful or not.
static checkForSubItem(ilPropertyFormGUI $item)
static checkItem(ilPropertyFormGUI $item)
static set($name, $value)
setFormAction($a_formaction)
Set FormAction.
This class represents a section header in a property form.
This class represents a multi selection list property in a property form.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
checkInput()
Check Post Input.
setTitle($a_title)
Set Title.
This class represents a text property in a property form.
$key
Definition: croninfo.php:18
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7