ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMemcacheServerFormGUI.php
Go to the documentation of this file.
1 <?php
2 require_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
3 require_once('class.ilMemcacheServer.php');
4 
11 
12  const F_HOST = 'host';
13  const F_PORT = 'port';
14  const F_STATUS = 'status';
15  const F_WEIGHT = 'weight';
19  protected $object;
23  protected $is_new = true;
24 
25 
30  global $DIC;
31  $lng = $DIC['lng'];
32  $this->object = $object;
33  $this->lng = $lng;
34  $this->is_new = ($this->object->getId() == 0);
35  $this->initForm();
36  }
37 
38 
39  protected function initForm() {
40  $this->setTarget('_top');
41  $this->setFormAction('setup.php?cmd=gateway&mcsid=' . $_GET['mcsid']);
42  $this->initButtons();
43 
44  $te = new ilCheckboxInputGUI($this->txt(self::F_STATUS), self::F_STATUS);
45  $this->addItem($te);
46 
47  $te = new ilTextInputGUI($this->txt(self::F_HOST), self::F_HOST);
48  $te->setRequired(true);
49  $this->addItem($te);
50 
51  $te = new ilTextInputGUI($this->txt(self::F_PORT), self::F_PORT);
52  $te->setRequired(true);
53  $this->addItem($te);
54 
55  $se = new ilSelectInputGUI($this->txt(self::F_WEIGHT), self::F_WEIGHT);
56  $se->setOptions(array( 10 => 10, 20 => 20, 30 => 30, 40 => 40, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90, 100 => 100 ));
57  $this->addItem($se);
58  }
59 
60 
61  public function fillForm() {
62  $array = array(
63  self::F_STATUS => $this->object->getStatus() == ilMemcacheServer::STATUS_ACTIVE,
64  self::F_HOST => $this->object->getHost(),
65  self::F_PORT => $this->object->getPort(),
66  self::F_WEIGHT => $this->object->getWeight(),
67  );
68 
69  $this->setValuesByArray($array);
70  }
71 
72 
76  public function fillObject() {
77  if (!$this->checkInput()) {
78  return false;
79  }
80  $this->object->setStatus(($this->getInput(self::F_STATUS) == 1 ? ilMemcacheServer::STATUS_ACTIVE : ilMemcacheServer::STATUS_INACTIVE));
81  $this->object->setHost($this->getInput(self::F_HOST));
82  $this->object->setPort($this->getInput(self::F_PORT));
83  $this->object->setWeight($this->getInput(self::F_WEIGHT));
84 
85  return true;
86  }
87 
88 
94  protected function txt($key) {
95  return $this->lng->txt('memcache_' . $key);
96  }
97 
98 
102  public function saveObject() {
103  if (!$this->fillObject()) {
104  return false;
105  }
106 
107  if ($this->object->getId()) {
108  $this->object->update();
109  } else {
110  $this->object->create();
111  }
112 
113  return $this->object->getId();
114  }
115 
116 
117  protected function initButtons() {
118  switch (true) {
119  case $this->is_new:
120  $this->setTitle($this->txt('add'));
121  $this->addCommandButton('createMemcacheServer', $this->txt('add'));
122  $this->addCommandButton('cache', $this->txt('cancel'));
123  break;
124  case !$this->is_new:
125  $this->setTitle($this->txt('update'));
126  $this->addCommandButton('updateMemcacheServer', $this->txt('update'));
127  $this->addCommandButton('cache', $this->txt('cancel'));
128  break;
129  }
130  }
131 }
132 
133 
This class represents a selection list property in a property form.
This class represents a property form user interface.
$_GET["client_id"]
This class represents a checkbox property in a property form.
setFormAction($a_formaction)
Set FormAction.
addItem($a_item)
Add Item (Property, SectionHeader).
setTarget($a_target)
Set Target.
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.
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
global $lng
Definition: privfeed.php:17
__construct(ilMemcacheServer $object)
global $DIC
Class ilMemcacheServer.
Class ilMemcacheServerFormGUI.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.