ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilWidthHeightInputGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 protected $value;
15
22 function __construct($a_title = "", $a_postvar = "")
23 {
24 parent::__construct($a_title, $a_postvar);
25 $this->setType("width_height");
26 $this->dirs = array("width", "height");
27 }
28
34 function setWidth($a_width)
35 {
36 $this->width = $a_width;
37 }
38
44 function getWidth()
45 {
46 return $this->width;
47 }
48
54 function setHeight($a_height)
55 {
56 $this->height = $a_height;
57 }
58
64 function getHeight()
65 {
66 return $this->height;
67 }
68
74 function setConstrainProportions($a_constrainproportions)
75 {
76 $this->constrainproportions = $a_constrainproportions;
77 }
78
85 {
86 return $this->constrainproportions;
87 }
88
94 function checkInput()
95 {
96 global $lng;
97
98 foreach ($this->dirs as $dir)
99 {
100 $pre_value = $_POST[$this->getPostVar()][$dir] =
101 ilUtil::stripSlashes($_POST[$this->getPostVar()][$dir]);
102
103 /*
104 if ($this->getRequired() && trim($num_value) == "")
105 {
106 $this->setAlert($lng->txt("msg_input_is_required"));
107
108 return false;
109 }*/
110
111 $value = $pre_value;
112
113 if (trim($value) != "")
114 {
115 switch ($dir)
116 {
117 case "width": $this->setWidth($value); break;
118 case "height": $this->setHeight($value); break;
119 }
120 }
121
122 }
123
124 return true;
125 }
126
130 function insert($a_tpl)
131 {
132 global $lng;
133
134 $tpl = new ilTemplate("tpl.prop_width_height.html", true, true, "Services/MediaObjects");
135
136 foreach ($this->dirs as $dir)
137 {
138 switch($dir)
139 {
140 case "width": $value = strtolower(trim($this->getWidth())); break;
141 case "height": $value = strtolower(trim($this->getHeight())); break;
142 }
143 $tpl->setVariable("VAL_".strtoupper($dir), $value);
144 }
145 if ($this->getConstrainProportions())
146 {
147 $tpl->setVariable("CHECKED", 'checked="checked"');
148 }
149
150 $tpl->setVariable("POST_VAR", $this->getPostVar());
151 $tpl->setVariable("TXT_CONSTR_PROP", $lng->txt("cont_constrain_proportions"));
152 $wh_ratio = 0;
153 if ((int) $this->getHeight() > 0)
154 {
155 $wh_ratio = (int) $this->getWidth() / (int) $this->getHeight();
156 }
157 $tpl->setVariable("WH_RATIO", str_replace(",", ".", round($wh_ratio, 6)));
158
159 $a_tpl->setCurrentBlock("prop_generic");
160 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
161 $a_tpl->parseCurrentBlock();
162
163 $GLOBALS["tpl"]->addJavascript("./Services/MediaObjects/js/ServiceMediaObjectPropWidthHeight.js");
164 }
165
171 function setValueByArray($a_values)
172 {
173 global $ilUser;
174//var_dump($a_values[$this->getPostVar()]);
175 $this->setWidth($a_values[$this->getPostVar()]["width"]);
176 $this->setHeight($a_values[$this->getPostVar()]["height"]);
177 $this->setConstrainProportions($a_values[$this->getPostVar()]["constr_prop"]);
178 }
179
180}
global $tpl
Definition: ilias.php:8
This class represents a property in a property form.
setType($a_type)
Set Type.
getPostVar()
Get Post Variable.
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
This class represents a width/height item in a property form.
checkInput()
Check input, strip slashes etc.
__construct($a_title="", $a_postvar="")
Constructor.
getConstrainProportions()
Get Constrain Proportions.
setValueByArray($a_values)
Set value by array.
setConstrainProportions($a_constrainproportions)
Set Constrain Proportions.
insert($a_tpl)
Insert property html.
$_POST['username']
Definition: cron.php:12
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15