ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
17 protected $parent_gui;
21 protected $ctrl;
22
23
27 public function __construct($parent_gui) {
28 global $ilCtrl, $lng;
29 $this->parent_gui = $parent_gui;
30 $this->ctrl = $ilCtrl;
31 $this->lng = $lng;
32 $this->ctrl->saveParameter($parent_gui, 'clip_ext_id');
33 $this->setFormAction($this->ctrl->getFormAction($parent_gui));
34 $this->initForm();
35 }
36
37
38 protected function initForm() {
39 $this->setTitle($this->lng->txt('admin_form_title'));
40
41 $te = new ilTextInputGUI($this->lng->txt('admin_origins_path'), 'path');
42 $te->setInfo($this->lng->txt('admin_origins_path_info'));
43 $this->addItem($te);
44
45 $this->addCommandButtons();
46 }
47
48
49 public function fillForm() {
50 $array = array();
51 foreach ($this->getItems() as $item) {
52 $this->getValuesForItem($item, $array);
53 }
54 $this->setValuesByArray($array);
55 }
56
57
64 private function getValuesForItem($item, &$array) {
65 if (self::checkItem($item)) {
66 $key = $item->getPostVar();
67 $array[$key] = json_decode(arConfig::get($key));
68 if (self::checkForSubItem($item)) {
69 foreach ($item->getSubItems() as $subitem) {
70 $this->getValuesForItem($subitem, $array);
71 }
72 }
73 }
74 }
75
76
82 public function fillObject() {
83 if (!$this->checkInput()) {
84 return false;
85 }
86
87 return true;
88 }
89
90
94 public function saveObject() {
95 if (!$this->fillObject()) {
96 return false;
97 }
98 foreach ($this->getItems() as $item) {
99 $this->saveValueForItem($item);
100 }
101
102 return true;
103 }
104
105
109 private function saveValueForItem($item) {
110 if (self::checkItem($item)) {
111 $key = $item->getPostVar();
112 arConfig::set($key, json_encode($this->getInput($key)));
113 if (self::checkForSubItem($item)) {
114 foreach ($item->getSubItems() as $subitem) {
115 $this->saveValueForItem($subitem);
116 }
117 }
118 }
119 }
120
121
127 public static function checkItem(ilPropertyFormGUI $item) {
128 return !$item instanceof ilFormSectionHeaderGUI AND !$item instanceof ilMultiSelectInputGUI;
129 }
130
131
137 public static function checkForSubItem(ilPropertyFormGUI $item) {
138 return !$item instanceof ilMultiSelectInputGUI;
139 }
140
141
142 protected function addCommandButtons() {
143 $this->addCommandButton('save', $this->lng->txt('admin_form_button_save'));
144 $this->addCommandButton('cancel', $this->lng->txt('admin_form_button_cancel'));
145 }
146}
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).
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.
addCommandButton($a_cmd, $a_text)
Add Command button.
setTitle($a_title)
Set Title.
This class represents a text property in a property form.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40