ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 global $lng;
31 $this->object = $object;
32 $this->lng = $lng;
33 $this->is_new = ($this->object->getId() == 0);
34 $this->initForm();
35 }
36
37
38 protected function initForm() {
39 $this->setTarget('_top');
40 $this->setFormAction('setup.php?cmd=gateway&mcsid=' . $_GET['mcsid']);
41 $this->initButtons();
42
43 $te = new ilCheckboxInputGUI($this->txt(self::F_STATUS), self::F_STATUS);
44 $this->addItem($te);
45
46 $te = new ilTextInputGUI($this->txt(self::F_HOST), self::F_HOST);
47 $te->setRequired(true);
48 $this->addItem($te);
49
50 $te = new ilTextInputGUI($this->txt(self::F_PORT), self::F_PORT);
51 $te->setRequired(true);
52 $this->addItem($te);
53
54 $se = new ilSelectInputGUI($this->txt(self::F_WEIGHT), self::F_WEIGHT);
55 $se->setOptions(array( 10 => 10, 20 => 20, 30 => 30, 40 => 40, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90, 100 => 100 ));
56 $this->addItem($se);
57 }
58
59
60 public function fillForm() {
61 $array = array(
62 self::F_STATUS => $this->object->getStatus() == ilMemcacheServer::STATUS_ACTIVE,
63 self::F_HOST => $this->object->getHost(),
64 self::F_PORT => $this->object->getPort(),
65 self::F_WEIGHT => $this->object->getWeight(),
66 );
67
68 $this->setValuesByArray($array);
69 }
70
71
75 public function fillObject() {
76 if (! $this->checkInput()) {
77 return false;
78 }
79 $this->object->setStatus(($this->getInput(self::F_STATUS) == 1 ? ilMemcacheServer::STATUS_ACTIVE : ilMemcacheServer::STATUS_INACTIVE));
80 $this->object->setHost($this->getInput(self::F_HOST));
81 $this->object->setPort($this->getInput(self::F_PORT));
82 $this->object->setWeight($this->getInput(self::F_WEIGHT));
83
84 return true;
85 }
86
87
93 protected function txt($key) {
94 return $this->lng->txt('memcache_' . $key);
95 }
96
97
101 public function saveObject() {
102 if (! $this->fillObject()) {
103 return false;
104 }
105
106 if ($this->object->getId()) {
107 $this->object->update();
108 } else {
109 $this->object->create();
110 }
111
112 return $this->object->getId();
113 }
114
115
116 protected function initButtons() {
117 switch (true) {
118 case $this->is_new:
119 $this->setTitle($this->txt('add'));
120 $this->addCommandButton('createMemcacheServer', $this->txt('add'));
121 $this->addCommandButton('cache', $this->txt('cancel'));
122 break;
123 case ! $this->is_new:
124 $this->setTitle($this->txt('update'));
125 $this->addCommandButton('updateMemcacheServer', $this->txt('update'));
126 $this->addCommandButton('cache', $this->txt('cancel'));
127 break;
128 }
129 }
130}
131
132
$_GET["client_id"]
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).
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 selection list property in a property form.
This class represents a text property in a property form.
global $lng
Definition: privfeed.php:40