ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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{
17 protected $user;
18
19 protected $value;
20
27 public function __construct($a_title = "", $a_postvar = "")
28 {
29 global $DIC;
30
31 $this->lng = $DIC->language();
32 $this->user = $DIC->user();
33 parent::__construct($a_title, $a_postvar);
34 $this->setType("width_height");
35 $this->dirs = array("width", "height");
36 }
37
43 public function setWidth($a_width)
44 {
45 $this->width = $a_width;
46 }
47
53 public function getWidth()
54 {
55 return $this->width;
56 }
57
63 public function setHeight($a_height)
64 {
65 $this->height = $a_height;
66 }
67
73 public function getHeight()
74 {
75 return $this->height;
76 }
77
83 public function setConstrainProportions($a_constrainproportions)
84 {
85 $this->constrainproportions = $a_constrainproportions;
86 }
87
93 public function getConstrainProportions()
94 {
95 return $this->constrainproportions;
96 }
97
103 public function checkInput()
104 {
106
107 foreach ($this->dirs as $dir) {
108 $pre_value = $_POST[$this->getPostVar()][$dir] =
109 ilUtil::stripSlashes($_POST[$this->getPostVar()][$dir]);
110
111 /*
112 if ($this->getRequired() && trim($num_value) == "")
113 {
114 $this->setAlert($lng->txt("msg_input_is_required"));
115
116 return false;
117 }*/
118
119 $value = $pre_value;
120
121 if (trim($value) != "") {
122 switch ($dir) {
123 case "width": $this->setWidth($value); break;
124 case "height": $this->setHeight($value); break;
125 }
126 }
127 }
128
129 return true;
130 }
131
135 public function insert($a_tpl)
136 {
138
139 $tpl = new ilTemplate("tpl.prop_width_height.html", true, true, "Services/MediaObjects");
140
141 foreach ($this->dirs as $dir) {
142 switch ($dir) {
143 case "width": $value = strtolower(trim($this->getWidth())); break;
144 case "height": $value = strtolower(trim($this->getHeight())); break;
145 }
146 $tpl->setVariable("VAL_" . strtoupper($dir), $value);
147 }
148 if ($this->getConstrainProportions()) {
149 $tpl->setVariable("CHECKED", 'checked="checked"');
150 }
151
152 $tpl->setVariable("POST_VAR", $this->getPostVar());
153 $tpl->setVariable("TXT_CONSTR_PROP", $lng->txt("cont_constrain_proportions"));
154 $wh_ratio = 0;
155 if ((int) $this->getHeight() > 0) {
156 $wh_ratio = (int) $this->getWidth() / (int) $this->getHeight();
157 }
158 $tpl->setVariable("WH_RATIO", str_replace(",", ".", round($wh_ratio, 6)));
159
160 $a_tpl->setCurrentBlock("prop_generic");
161 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
162 $a_tpl->parseCurrentBlock();
163
164 $GLOBALS["tpl"]->addJavascript("./Services/MediaObjects/js/ServiceMediaObjectPropWidthHeight.js");
165 }
166
172 public function setValueByArray($a_values)
173 {
175 //var_dump($a_values[$this->getPostVar()]);
176 $this->setWidth($a_values[$this->getPostVar()]["width"]);
177 $this->setHeight($a_values[$this->getPostVar()]["height"]);
178 $this->setConstrainProportions($a_values[$this->getPostVar()]["constr_prop"]);
179 }
180}
user()
Definition: user.php:4
$tpl
Definition: ilias.php:10
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
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.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18