ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilCSSRectInputGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2007 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
32{
33 protected $top;
34 protected $left;
35 protected $right;
36 protected $bottom;
37 protected $size;
38 protected $useUnits;
39
46 function __construct($a_title = "", $a_postvar = "")
47 {
48 parent::__construct($a_title, $a_postvar);
49 $this->size = 6;
50 $this->useUnits = TRUE;
51 }
52
58 function setUseUnits($a_value)
59 {
60 $this->useUnits = $a_value;
61 }
62
68 function useUnits()
69 {
70 return $this->useUnits;
71 }
72
78 function setTop($a_value)
79 {
80 $this->top = $a_value;
81 }
82
88 function getTop()
89 {
90 return $this->top;
91 }
92
98 function setBottom($a_value)
99 {
100 $this->bottom = $a_value;
101 }
102
108 function getBottom()
109 {
110 return $this->bottom;
111 }
112
118 function setLeft($a_value)
119 {
120 $this->left = $a_value;
121 }
122
128 function getLeft()
129 {
130 return $this->left;
131 }
132
138 function setRight($a_value)
139 {
140 $this->right = $a_value;
141 }
142
148 function getRight()
149 {
150 return $this->right;
151 }
152
158 function setSize($a_size)
159 {
160 $this->size = $a_size;
161 }
162
168 function setValueByArray($a_values)
169 {
170 $this->setValue($a_values[$this->getPostVar()]);
171 }
172
178 function getSize()
179 {
180 return $this->size;
181 }
182
188 function checkInput()
189 {
190 global $lng;
191
192 $_POST[$this->getPostVar()]["top"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["top"]);
193 $_POST[$this->getPostVar()]["right"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["right"]);
194 $_POST[$this->getPostVar()]["bottom"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["bottom"]);
195 $_POST[$this->getPostVar()]["left"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["left"]);
196 if ($this->getRequired() && ((trim($_POST[$this->getPostVar()]["top"]) == "") || (trim($_POST[$this->getPostVar()]["bottom"]) == "") || (trim($_POST[$this->getPostVar()]["left"]) == "") || (trim($_POST[$this->getPostVar()]["right"]) == "")))
197 {
198 $this->setAlert($lng->txt("msg_input_is_required"));
199 return false;
200 }
201 if ($this->useUnits())
202 {
203 if ((!preg_match("/\\d+(cm|mm|in|pt|pc|px|em)/", $_POST[$this->getPostVar()]["left"])) ||
204 (!preg_match("/\\d+(cm|mm|in|pt|pc|px|em)/", $_POST[$this->getPostVar()]["right"])) ||
205 (!preg_match("/\\d+(cm|mm|in|pt|pc|px|em)/", $_POST[$this->getPostVar()]["bottom"])) ||
206 (!preg_match("/\\d+(cm|mm|in|pt|pc|px|em)/", $_POST[$this->getPostVar()]["top"])))
207 {
208 $this->setAlert($lng->txt("msg_unit_is_required"));
209 return false;
210 }
211 }
212 return $this->checkSubItemsInput();
213 }
214
220 function insert(&$a_tpl)
221 {
222 global $lng;
223
224 if (strlen($this->getTop()))
225 {
226 $a_tpl->setCurrentBlock("cssrect_value_top");
227 $a_tpl->setVariable("CSSRECT_VALUE", ilUtil::prepareFormOutput($this->getTop()));
228 $a_tpl->parseCurrentBlock();
229 }
230 if (strlen($this->getBottom()))
231 {
232 $a_tpl->setCurrentBlock("cssrect_value_bottom");
233 $a_tpl->setVariable("CSSRECT_VALUE", ilUtil::prepareFormOutput($this->getBottom()));
234 $a_tpl->parseCurrentBlock();
235 }
236 if (strlen($this->getLeft()))
237 {
238 $a_tpl->setCurrentBlock("cssrect_value_left");
239 $a_tpl->setVariable("CSSRECT_VALUE", ilUtil::prepareFormOutput($this->getLeft()));
240 $a_tpl->parseCurrentBlock();
241 }
242 if (strlen($this->getRight()))
243 {
244 $a_tpl->setCurrentBlock("cssrect_value_right");
245 $a_tpl->setVariable("CSSRECT_VALUE", ilUtil::prepareFormOutput($this->getRight()));
246 $a_tpl->parseCurrentBlock();
247 }
248 $a_tpl->setCurrentBlock("cssrect");
249 $a_tpl->setVariable("ID", $this->getFieldId());
250 $a_tpl->setVariable("SIZE", $this->getSize());
251 $a_tpl->setVariable("POST_VAR", $this->getPostVar());
252 $a_tpl->setVariable("TEXT_TOP", $lng->txt("pos_top"));
253 $a_tpl->setVariable("TEXT_RIGHT", $lng->txt("pos_right"));
254 $a_tpl->setVariable("TEXT_BOTTOM", $lng->txt("pos_bottom"));
255 $a_tpl->setVariable("TEXT_LEFT", $lng->txt("pos_left"));
256 if ($this->getDisabled())
257 {
258 $a_tpl->setVariable("DISABLED",
259 " disabled=\"disabled\"");
260 }
261 $a_tpl->parseCurrentBlock();
262 }
263}
This class represents a text property in a property form.
insert(&$a_tpl)
Insert property html.
setTop($a_value)
Set Top.
__construct($a_title="", $a_postvar="")
Constructor.
setUseUnits($a_value)
Set use units.
setBottom($a_value)
Set Bottom.
setLeft($a_value)
Set Left.
setValueByArray($a_values)
Set value by array.
setRight($a_value)
Set Right.
checkInput()
Check input, strip slashes etc.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
getFieldId()
Get Post Variable.
This class represents a property that may include a sub form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$_POST['username']
Definition: cron.php:12
global $lng
Definition: privfeed.php:40