ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilTRBLBorderWidthInputGUI.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 $value;
34
41 function __construct($a_title = "", $a_postvar = "")
42 {
43 parent::__construct($a_title, $a_postvar);
44 $this->setType("border_width");
45 $this->dirs = array("all", "top", "bottom", "left", "right");
46 }
47
53 function setAllValue($a_allvalue)
54 {
55 $this->allvalue = $a_allvalue;
56 }
57
63 function getAllValue()
64 {
65 return $this->allvalue;
66 }
67
73 function setTopValue($a_topvalue)
74 {
75 $this->topvalue = $a_topvalue;
76 }
77
83 function getTopValue()
84 {
85 return $this->topvalue;
86 }
87
93 function setBottomValue($a_bottomvalue)
94 {
95 $this->bottomvalue = $a_bottomvalue;
96 }
97
103 function getBottomValue()
104 {
105 return $this->bottomvalue;
106 }
107
113 function setLeftValue($a_leftvalue)
114 {
115 $this->leftvalue = $a_leftvalue;
116 }
117
123 function getLeftValue()
124 {
125 return $this->leftvalue;
126 }
127
133 function setRightValue($a_rightvalue)
134 {
135 $this->rightvalue = $a_rightvalue;
136 }
137
143 function getRightValue()
144 {
145 return $this->rightvalue;
146 }
147
153 function checkInput()
154 {
155 global $lng;
156
157 foreach ($this->dirs as $dir)
158 {
159 $type = $_POST[$this->getPostVar()][$dir]["type"] =
160 ilUtil::stripSlashes($_POST[$this->getPostVar()][$dir]["type"]);
161 $num_value = $_POST[$this->getPostVar()][$dir]["num_value"] =
162 trim(ilUtil::stripSlashes($_POST[$this->getPostVar()][$dir]["num_value"]));
163 $num_unit = $_POST[$this->getPostVar()][$dir]["num_unit"] =
164 trim(ilUtil::stripSlashes($_POST[$this->getPostVar()][$dir]["num_unit"]));
165 $pre_value = $_POST[$this->getPostVar()][$dir]["pre_calue"] =
166 ilUtil::stripSlashes($_POST[$this->getPostVar()][$dir]["pre_value"]);
167
168 /*
169 if ($this->getRequired() && trim($num_value) == "")
170 {
171 $this->setAlert($lng->txt("msg_input_is_required"));
172
173 return false;
174 }*/
175
176 if (!is_numeric($num_value) && $num_value != "")
177 {
178 $this->setAlert($lng->txt("sty_msg_input_must_be_numeric"));
179 return false;
180 }
181
182 $value = "";
183 if ($type == "numeric")
184 {
185 if ($num_value != "")
186 {
187 $value = $num_value.$num_unit;
188 }
189 }
190 else
191 {
192 $value = $pre_value;
193 }
194
195 if (trim($value) != "")
196 {
197 switch ($dir)
198 {
199 case "all": $this->setAllValue($value); break;
200 case "top": $this->setTopValue($value); break;
201 case "bottom": $this->setBottomValue($value); break;
202 case "left": $this->setLeftValue($value); break;
203 case "right": $this->setRightValue($value); break;
204 }
205 }
206
207 }
208
209 return true;
210 }
211
215 function insert(&$a_tpl)
216 {
217 global $lng;
218
219 $layout_tpl = new ilTemplate("tpl.prop_trbl_layout.html", true, true, "Services/Style");
220
221 foreach ($this->dirs as $dir)
222 {
223 $tpl = new ilTemplate("tpl.prop_trbl_border_width.html", true, true, "Services/Style");
225 $pre_options = ilObjStyleSheet::_getStyleParameterValues("border-width");
226
227 switch($dir)
228 {
229 case "all": $value = strtolower(trim($this->getAllValue())); break;
230 case "top": $value = strtolower(trim($this->getTopValue())); break;
231 case "bottom": $value = strtolower(trim($this->getBottomValue())); break;
232 case "left": $value = strtolower(trim($this->getLeftValue())); break;
233 case "right": $value = strtolower(trim($this->getRightValue())); break;
234 }
235
236 if (in_array($value, $pre_options))
237 {
238 $current_type = "pre";
239 $tpl->setVariable("PREDEFINED_SELECTED", 'checked="checked"');
240 }
241 else
242 {
243 $current_type = "unit";
244 $tpl->setVariable("NUMERIC_SELECTED", 'checked="checked"');
245
246 $current_unit = "";
247 foreach ($unit_options as $u)
248 {
249 if (substr($value, strlen($value) - strlen($u)) == $u)
250 {
251 $current_unit = $u;
252 }
253 }
254 $disp_val = substr($value, 0, strlen($value) - strlen($current_unit));
255 if ($current_unit == "")
256 {
257 $current_unit = "px";
258 }
259 $tpl->setVariable("VAL_NUM", $disp_val);
260 }
261
262 foreach ($unit_options as $option)
263 {
264 $tpl->setCurrentBlock("unit_option");
265 $tpl->setVariable("VAL_UNIT", $option);
266 $tpl->setVariable("TXT_UNIT", $option);
267 if ($current_type == "unit" && $current_unit == $option)
268 {
269 $tpl->setVariable("UNIT_SELECTED", 'selected="selected"');
270 }
271 $tpl->parseCurrentBlock();
272 }
273
274 foreach ($pre_options as $option)
275 {
276 $tpl->setCurrentBlock("pre_option");
277 $tpl->setVariable("VAL_PRE", $option);
278 $tpl->setVariable("TXT_PRE", $option);
279 if ($current_type == "pre" && $value == $option)
280 {
281 $tpl->setVariable("PRE_SELECTED", 'selected="selected"');
282 }
283 $tpl->parseCurrentBlock();
284 }
285
286 $tpl->setVariable("POSTVAR", $this->getPostVar());
287 $tpl->setVariable("TXT_DIR", $lng->txt("sty_$dir"));
288 $tpl->setVariable("DIR", $dir);
289
290 $layout_tpl->setVariable(strtoupper($dir), $tpl->get());
291 }
292 $layout_tpl->setVariable("COLSPAN", "2");
293
294 $a_tpl->setCurrentBlock("prop_generic");
295 $a_tpl->setVariable("PROP_GENERIC", $layout_tpl->get());
296 $a_tpl->parseCurrentBlock();
297 }
298
304 function setValueByArray($a_values)
305 {
306 global $ilUser;
307
308 if ($a_values[$this->getPostVar()]["all"]["type"] == "predefined")
309 {
310 $this->setAllValue($a_values[$this->getPostVar()]["all"]["pre_value"]);
311 }
312 else
313 {
314 $this->setAllValue($a_values[$this->getPostVar()]["all"]["num_value"].
315 $a_values[$this->getPostVar()]["all"]["num_unit"]);
316 }
317 if ($a_values[$this->getPostVar()]["bottom"]["type"] == "predefined")
318 {
319 $this->setBottomValue($a_values[$this->getPostVar()]["bottom"]["pre_value"]);
320 }
321 else
322 {
323 $this->setBottomValue($a_values[$this->getPostVar()]["bottom"]["num_value"].
324 $a_values[$this->getPostVar()]["bottom"]["num_unit"]);
325 }
326 if ($a_values[$this->getPostVar()]["top"]["type"] == "predefined")
327 {
328 $this->setTopValue($a_values[$this->getPostVar()]["top"]["pre_value"]);
329 }
330 else
331 {
332 $this->setTopValue($a_values[$this->getPostVar()]["top"]["num_value"].
333 $a_values[$this->getPostVar()]["top"]["num_unit"]);
334 }
335 if ($a_values[$this->getPostVar()]["left"]["type"] == "predefined")
336 {
337 $this->setLeftValue($a_values[$this->getPostVar()]["left"]["pre_value"]);
338 }
339 else
340 {
341 $this->setLeftValue($a_values[$this->getPostVar()]["left"]["num_value"].
342 $a_values[$this->getPostVar()]["left"]["num_unit"]);
343 }
344 if ($a_values[$this->getPostVar()]["right"]["type"] == "predefined")
345 {
346 $this->setRightValue($a_values[$this->getPostVar()]["right"]["pre_value"]);
347 }
348 else
349 {
350 $this->setRightValue($a_values[$this->getPostVar()]["right"]["num_value"].
351 $a_values[$this->getPostVar()]["right"]["num_unit"]);
352 }
353 }
354
355}
global $tpl
Definition: ilias.php:8
This class represents a property in a property form.
setType($a_type)
Set Type.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
static _getStyleParameterNumericUnits($a_no_percentage=false)
static _getStyleParameterValues($par)
This class represents a border width with all/top/right/bottom/left in a property form.
checkInput()
Check input, strip slashes etc.
setLeftValue($a_leftvalue)
Set Left Value.
setTopValue($a_topvalue)
Set Top Value.
insert(&$a_tpl)
Insert property html.
setBottomValue($a_bottomvalue)
Set Bottom Value.
setRightValue($a_rightvalue)
Set Right Value.
setAllValue($a_allvalue)
Set All Value.
__construct($a_title="", $a_postvar="")
Constructor.
setValueByArray($a_values)
Set value by array.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$_POST['username']
Definition: cron.php:12
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15