ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
36 protected $lng;
37
38 protected $top;
39 protected $left;
40 protected $right;
41 protected $bottom;
42 protected $size;
43 protected $useUnits;
44
51 public function __construct($a_title = "", $a_postvar = "")
52 {
53 global $DIC;
54
55 $this->lng = $DIC->language();
56 parent::__construct($a_title, $a_postvar);
57 $this->size = 6;
58 $this->useUnits = true;
59 }
60
66 public function setUseUnits($a_value)
67 {
68 $this->useUnits = $a_value;
69 }
70
76 public function useUnits()
77 {
78 return $this->useUnits;
79 }
80
86 public function setTop($a_value)
87 {
88 $this->top = $a_value;
89 }
90
96 public function getTop()
97 {
98 return $this->top;
99 }
100
106 public function setBottom($a_value)
107 {
108 $this->bottom = $a_value;
109 }
110
116 public function getBottom()
117 {
118 return $this->bottom;
119 }
120
126 public function setLeft($a_value)
127 {
128 $this->left = $a_value;
129 }
130
136 public function getLeft()
137 {
138 return $this->left;
139 }
140
146 public function setRight($a_value)
147 {
148 $this->right = $a_value;
149 }
150
156 public function getRight()
157 {
158 return $this->right;
159 }
160
166 public function setSize($a_size)
167 {
168 $this->size = $a_size;
169 }
170
176 public function setValueByArray($a_values)
177 {
178 $this->setValue($a_values[$this->getPostVar()]);
179 }
180
186 public function getSize()
187 {
188 return $this->size;
189 }
190
196 public function checkInput()
197 {
199
200 $_POST[$this->getPostVar()]["top"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["top"]);
201 $_POST[$this->getPostVar()]["right"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["right"]);
202 $_POST[$this->getPostVar()]["bottom"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["bottom"]);
203 $_POST[$this->getPostVar()]["left"] = ilUtil::stripSlashes($_POST[$this->getPostVar()]["left"]);
204 if ($this->getRequired() && ((trim($_POST[$this->getPostVar()]["top"]) == "") || (trim($_POST[$this->getPostVar()]["bottom"]) == "") || (trim($_POST[$this->getPostVar()]["left"]) == "") || (trim($_POST[$this->getPostVar()]["right"]) == ""))) {
205 $this->setAlert($lng->txt("msg_input_is_required"));
206 return false;
207 }
208 if ($this->useUnits()) {
209 if ((!preg_match('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*))|0)(cm|mm|in|pt|pc|px|em)$/is', $_POST[$this->getPostVar()]["left"])) ||
210 (!preg_match('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*))|0)(cm|mm|in|pt|pc|px|em)$/is', $_POST[$this->getPostVar()]["right"])) ||
211 (!preg_match('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*))|0)(cm|mm|in|pt|pc|px|em)$/is', $_POST[$this->getPostVar()]["bottom"])) ||
212 (!preg_match('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*))|0)(cm|mm|in|pt|pc|px|em)$/is', $_POST[$this->getPostVar()]["top"]))) {
213 $this->setAlert($lng->txt("msg_unit_is_required"));
214 return false;
215 }
216 }
217 return $this->checkSubItemsInput();
218 }
219
225 public function insert($a_tpl)
226 {
228
229 if (strlen($this->getTop())) {
230 $a_tpl->setCurrentBlock("cssrect_value_top");
231 $a_tpl->setVariable("CSSRECT_VALUE", ilUtil::prepareFormOutput($this->getTop()));
232 $a_tpl->parseCurrentBlock();
233 }
234 if (strlen($this->getBottom())) {
235 $a_tpl->setCurrentBlock("cssrect_value_bottom");
236 $a_tpl->setVariable("CSSRECT_VALUE", ilUtil::prepareFormOutput($this->getBottom()));
237 $a_tpl->parseCurrentBlock();
238 }
239 if (strlen($this->getLeft())) {
240 $a_tpl->setCurrentBlock("cssrect_value_left");
241 $a_tpl->setVariable("CSSRECT_VALUE", ilUtil::prepareFormOutput($this->getLeft()));
242 $a_tpl->parseCurrentBlock();
243 }
244 if (strlen($this->getRight())) {
245 $a_tpl->setCurrentBlock("cssrect_value_right");
246 $a_tpl->setVariable("CSSRECT_VALUE", ilUtil::prepareFormOutput($this->getRight()));
247 $a_tpl->parseCurrentBlock();
248 }
249 $a_tpl->setCurrentBlock("cssrect");
250 $a_tpl->setVariable("ID", $this->getFieldId());
251 $a_tpl->setVariable("SIZE", $this->getSize());
252 $a_tpl->setVariable("POST_VAR", $this->getPostVar());
253 $a_tpl->setVariable("TEXT_TOP", $lng->txt("pos_top"));
254 $a_tpl->setVariable("TEXT_RIGHT", $lng->txt("pos_right"));
255 $a_tpl->setVariable("TEXT_BOTTOM", $lng->txt("pos_bottom"));
256 $a_tpl->setVariable("TEXT_LEFT", $lng->txt("pos_left"));
257 if ($this->getDisabled()) {
258 $a_tpl->setVariable(
259 "DISABLED",
260 " disabled=\"disabled\""
261 );
262 }
263 $a_tpl->parseCurrentBlock();
264 }
265}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a text property in a property form.
setTop($a_value)
Set Top.
__construct($a_title="", $a_postvar="")
Constructor.
insert($a_tpl)
Insert property html.
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
global $DIC
Definition: saml.php:7