ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.arConfigFormGUI.php
Go to the documentation of this file.
1 <?php
2 require_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
3 require_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 }
GUI-Class arConfigFormGUI.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
This class represents a section header in a property form.
setFormAction($a_formaction)
Set FormAction.
addItem($a_item)
Add Item (Property, SectionHeader).
fillObject()
returns whether checkinput was successful or not.
static set($name, $value)
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
This class represents a multi selection list property in a property form.
setTitle($a_title)
Set Title.
This class represents a text property in a property form.
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
checkInput()
Check Post Input.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
static checkItem(ilPropertyFormGUI $item)
$key
Definition: croninfo.php:18
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
static checkForSubItem(ilPropertyFormGUI $item)
getValuesForItem($item, &$array)