ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilMemcacheServerFormGUI.php
Go to the documentation of this file.
1<?php
2require_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
3require_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 {
31 global $DIC;
32 $lng = $DIC['lng'];
33 $this->object = $object;
34 $this->lng = $lng;
35 $this->is_new = ($this->object->getId() == 0);
36 $this->initForm();
37 }
38
39
40 protected function initForm()
41 {
42 $this->setTarget('_top');
43 $this->setFormAction('setup.php?cmd=gateway&mcsid=' . $_GET['mcsid']);
44 $this->initButtons();
45
46 $te = new ilCheckboxInputGUI($this->txt(self::F_STATUS), self::F_STATUS);
47 $this->addItem($te);
48
49 $te = new ilTextInputGUI($this->txt(self::F_HOST), self::F_HOST);
50 $te->setRequired(true);
51 $this->addItem($te);
52
53 $te = new ilTextInputGUI($this->txt(self::F_PORT), self::F_PORT);
54 $te->setRequired(true);
55 $this->addItem($te);
56
57 $se = new ilSelectInputGUI($this->txt(self::F_WEIGHT), self::F_WEIGHT);
58 $se->setOptions(array( 10 => 10, 20 => 20, 30 => 30, 40 => 40, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90, 100 => 100 ));
59 $this->addItem($se);
60 }
61
62
63 public function fillForm()
64 {
65 $array = array(
66 self::F_STATUS => $this->object->getStatus() == ilMemcacheServer::STATUS_ACTIVE,
67 self::F_HOST => $this->object->getHost(),
68 self::F_PORT => $this->object->getPort(),
69 self::F_WEIGHT => $this->object->getWeight(),
70 );
71
72 $this->setValuesByArray($array);
73 }
74
75
79 public function fillObject()
80 {
81 if (!$this->checkInput()) {
82 return false;
83 }
84 $this->object->setStatus(($this->getInput(self::F_STATUS) == 1 ? ilMemcacheServer::STATUS_ACTIVE : ilMemcacheServer::STATUS_INACTIVE));
85 $this->object->setHost($this->getInput(self::F_HOST));
86 $this->object->setPort($this->getInput(self::F_PORT));
87 $this->object->setWeight($this->getInput(self::F_WEIGHT));
88
89 return true;
90 }
91
92
98 protected function txt($key)
99 {
100 return $this->lng->txt('memcache_' . $key);
101 }
102
103
107 public function saveObject()
108 {
109 if (!$this->fillObject()) {
110 return false;
111 }
112
113 if ($this->object->getId()) {
114 $this->object->update();
115 } else {
116 $this->object->create();
117 }
118
119 return $this->object->getId();
120 }
121
122
123 protected function initButtons()
124 {
125 switch (true) {
126 case $this->is_new:
127 $this->setTitle($this->txt('add'));
128 $this->addCommandButton('createMemcacheServer', $this->txt('add'));
129 $this->addCommandButton('cache', $this->txt('cancel'));
130 break;
131 case !$this->is_new:
132 $this->setTitle($this->txt('update'));
133 $this->addCommandButton('updateMemcacheServer', $this->txt('update'));
134 $this->addCommandButton('cache', $this->txt('cancel'));
135 break;
136 }
137 }
138}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
setTarget($a_target)
Set Target.
setFormAction($a_formaction)
Set FormAction.
Class ilMemcacheServerFormGUI.
__construct(ilMemcacheServer $object)
Class ilMemcacheServer.
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 selection list property in a property form.
This class represents a text property in a property form.
global $DIC
Definition: goto.php:24