ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilBackgroundPositionInputGUI Class Reference

This class represents a background position in a property form. More...

+ Inheritance diagram for ilBackgroundPositionInputGUI:
+ Collaboration diagram for ilBackgroundPositionInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setHorizontalValue ($a_horizontalvalue)
 Set Horizontal Value. More...
 
 getHorizontalValue ()
 Get Horizontal Value. More...
 
 setVerticalValue ($a_verticalvalue)
 Set Vertical Value. More...
 
 getVerticalValue ()
 Get Vertical Value. More...
 
 getValue ()
 Get value. More...
 
 setValue ($a_val)
 Set value. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 insert (&$a_tpl)
 Insert property html. More...
 
 setValueByArray ($a_values)
 Set value by array. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setPostVar ($a_postvar)
 Set Post Variable. More...
 
 getPostVar ()
 Get Post Variable. More...
 
 getFieldId ()
 Get Post Variable. More...
 
 setInfo ($a_info)
 Set Information Text. More...
 
 getInfo ()
 Get Information Text. More...
 
 setAlert ($a_alert)
 Set Alert Text. More...
 
 getAlert ()
 Get Alert Text. More...
 
 setRequired ($a_required)
 Set Required. More...
 
 getRequired ()
 Get Required. More...
 
 setDisabled ($a_disabled)
 Set Disabled. More...
 
 getDisabled ()
 Get Disabled. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm ($a_parentform)
 Set Parent Form. More...
 
 getParentForm ()
 Get Parent Form. More...
 
 setParent ($a_val)
 Set Parent GUI object. More...
 
 getParent ()
 Get Parent GUI object. More...
 
 getSubForm ()
 Get sub form html. More...
 
 hideSubForm ()
 Sub form hidden on init? More...
 
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders) More...
 
 getHiddenTitle ()
 Get hidden title. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
 serializeData ()
 serialize data More...
 
 unserializeData ($a_data)
 unserialize data More...
 
 writeToSession ()
 Write to session. More...
 
 clearFromSession ()
 Clear session value. More...
 
 readFromSession ()
 Read from session. More...
 
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties) More...
 
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi. More...
 
 getMulti ()
 Get Multi. More...
 
 setMultiValues (array $a_values)
 Set multi values. More...
 
 getMultiValues ()
 Get multi values. More...
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback ($a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 

Protected Attributes

 $user
 
 $value
 
- Protected Attributes inherited from ilFormPropertyGUI
 $ctrl
 
 $lng
 
 $type
 
 $title
 
 $postvar
 
 $info
 
 $alert
 
 $required = false
 
 $parentgui
 
 $parentform
 
 $hidden_title = ""
 
 $multi = false
 
 $multi_sortable = false
 
 $multi_addremove = true
 
 $multi_values
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters ($a_text)
 Remove prohibited characters see #19159. More...
 
- Protected Member Functions inherited from ilFormPropertyGUI
 setType ($a_type)
 Set Type. More...
 
 getMultiIconsHTML ()
 Get HTML for multiple value icons. More...
 

Detailed Description

This class represents a background position in a property form.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 31 of file class.ilBackgroundPositionInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilBackgroundPositionInputGUI::__construct (   $a_title = "",
  $a_postvar = "" 
)

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Definition at line 46 of file class.ilBackgroundPositionInputGUI.php.

References $DIC, array, ilFormPropertyGUI\setType(), and user().

47  {
48  global $DIC;
49 
50  $this->lng = $DIC->language();
51  $this->user = $DIC->user();
52  parent::__construct($a_title, $a_postvar);
53  $this->setType("border_width");
54  $this->dirs = array("horizontal", "vertical");
55  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
setType($a_type)
Set Type.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilBackgroundPositionInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Definition at line 137 of file class.ilBackgroundPositionInputGUI.php.

References $_POST, ilFormPropertyGUI\$lng, ilFormPropertyGUI\$type, $value, ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\setAlert(), setHorizontalValue(), setVerticalValue(), and ilUtil\stripSlashes().

138  {
139  $lng = $this->lng;
140 
141  foreach ($this->dirs as $dir) {
142  $type = $_POST[$this->getPostVar()][$dir]["type"] =
143  ilUtil::stripSlashes($_POST[$this->getPostVar()][$dir]["type"]);
144  $num_value = $_POST[$this->getPostVar()][$dir]["num_value"] =
145  trim(ilUtil::stripSlashes($_POST[$this->getPostVar()][$dir]["num_value"]));
146  $num_unit = $_POST[$this->getPostVar()][$dir]["num_unit"] =
147  trim(ilUtil::stripSlashes($_POST[$this->getPostVar()][$dir]["num_unit"]));
148  $pre_value = $_POST[$this->getPostVar()][$dir]["pre_calue"] =
149  ilUtil::stripSlashes($_POST[$this->getPostVar()][$dir]["pre_value"]);
150 
151  /*
152  if ($this->getRequired() && trim($num_value) == "")
153  {
154  $this->setAlert($lng->txt("msg_input_is_required"));
155 
156  return false;
157  }*/
158 
159  if (!is_numeric($num_value) && trim($num_value) != "") {
160  $this->setAlert($lng->txt("sty_msg_input_must_be_numeric"));
161  return false;
162  }
163 
164  $value = "";
165  if ($type == "numeric") {
166  if ($num_value != "") {
167  $value = $num_value . $num_unit;
168  }
169  } else {
170  $value = $pre_value;
171  }
172 
173  if (trim($value) != "") {
174  switch ($dir) {
175  case "horizontal": $this->setHorizontalValue($value); break;
176  case "vertical": $this->setVerticalValue($value); break;
177  }
178  }
179  }
180 
181  return true;
182  }
getPostVar()
Get Post Variable.
setVerticalValue($a_verticalvalue)
Set Vertical Value.
setAlert($a_alert)
Set Alert Text.
setHorizontalValue($a_horizontalvalue)
Set Horizontal Value.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$_POST["username"]
+ Here is the call graph for this function:

◆ getHorizontalValue()

ilBackgroundPositionInputGUI::getHorizontalValue ( )

Get Horizontal Value.

Returns
string Horizontal Value

Definition at line 72 of file class.ilBackgroundPositionInputGUI.php.

Referenced by getValue(), and insert().

73  {
74  return $this->horizontalvalue;
75  }
+ Here is the caller graph for this function:

◆ getValue()

ilBackgroundPositionInputGUI::getValue ( )

Get value.

Definition at line 100 of file class.ilBackgroundPositionInputGUI.php.

References getHorizontalValue(), and getVerticalValue().

101  {
102  if ($this->getHorizontalValue() != "") {
103  if ($this->getVerticalValue() != "") {
104  return $this->getHorizontalValue() . " " . $this->getVerticalValue();
105  } else {
106  return $this->getHorizontalValue();
107  }
108  } else {
109  if ($this->getVerticalValue() != "") {
110  return "left " . $this->getVerticalValue();
111  }
112  }
113  return "";
114  }
+ Here is the call graph for this function:

◆ getVerticalValue()

ilBackgroundPositionInputGUI::getVerticalValue ( )

Get Vertical Value.

Returns
string Vertical Value

Definition at line 92 of file class.ilBackgroundPositionInputGUI.php.

Referenced by getValue(), and insert().

93  {
94  return $this->verticalvalue;
95  }
+ Here is the caller graph for this function:

◆ insert()

ilBackgroundPositionInputGUI::insert ( $a_tpl)

Insert property html.

Definition at line 187 of file class.ilBackgroundPositionInputGUI.php.

References ilFormPropertyGUI\$lng, $tpl, $value, ilObjStyleSheet\_getStyleParameterNumericUnits(), ilObjStyleSheet\_getStyleParameterValues(), getHorizontalValue(), ilFormPropertyGUI\getPostVar(), and getVerticalValue().

188  {
189  $lng = $this->lng;
190 
191  $layout_tpl = new ilTemplate("tpl.prop_hv_layout.html", true, true, "Services/Style/Content");
192 
193  foreach ($this->dirs as $dir) {
194  $tpl = new ilTemplate("tpl.prop_background_position.html", true, true, "Services/Style/Content");
196  $pre_options = ilObjStyleSheet::_getStyleParameterValues("background-position");
197  $pre_options = $pre_options[$dir];
198  switch ($dir) {
199  case "horizontal": $value = strtolower(trim($this->getHorizontalValue())); break;
200  case "vertical": $value = strtolower(trim($this->getVerticalValue())); break;
201  }
202 
203  if (in_array($value, $pre_options)) {
204  $current_type = "pre";
205  $tpl->setVariable("PREDEFINED_SELECTED", 'checked="checked"');
206  } else {
207  $current_type = "unit";
208  $tpl->setVariable("NUMERIC_SELECTED", 'checked="checked"');
209 
210  $current_unit = "";
211  foreach ($unit_options as $u) {
212  if (substr($value, strlen($value) - strlen($u)) == $u) {
213  $current_unit = $u;
214  }
215  }
216  $disp_val = substr($value, 0, strlen($value) - strlen($current_unit));
217  if ($current_unit == "") {
218  $current_unit = "px";
219  }
220  $tpl->setVariable("VAL_NUM", $disp_val);
221  }
222 
223  foreach ($unit_options as $option) {
224  $tpl->setCurrentBlock("unit_option");
225  $tpl->setVariable("VAL_UNIT", $option);
226  $tpl->setVariable("TXT_UNIT", $option);
227  if ($current_type == "unit" && $current_unit == $option) {
228  $tpl->setVariable("UNIT_SELECTED", 'selected="selected"');
229  }
230  $tpl->parseCurrentBlock();
231  }
232 
233  foreach ($pre_options as $option) {
234  $tpl->setCurrentBlock("pre_option");
235  $tpl->setVariable("VAL_PRE", $option);
236  $tpl->setVariable("TXT_PRE", $option);
237  if ($current_type == "pre" && $value == $option) {
238  $tpl->setVariable("PRE_SELECTED", 'selected="selected"');
239  }
240  $tpl->parseCurrentBlock();
241  }
242 
243  $tpl->setVariable("POSTVAR", $this->getPostVar());
244  $tpl->setVariable("TXT_DIR", $lng->txt("sty_$dir"));
245  $tpl->setVariable("DIR", $dir);
246 
247  $layout_tpl->setVariable(strtoupper($dir), $tpl->get());
248  }
249  $layout_tpl->setVariable("COLSPAN", "2");
250 
251  $a_tpl->setCurrentBlock("prop_generic");
252  $a_tpl->setVariable("PROP_GENERIC", $layout_tpl->get());
253  $a_tpl->parseCurrentBlock();
254  }
$tpl
Definition: ilias.php:10
getPostVar()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
static _getStyleParameterValues($par)
static _getStyleParameterNumericUnits($a_no_percentage=false)
+ Here is the call graph for this function:

◆ setHorizontalValue()

ilBackgroundPositionInputGUI::setHorizontalValue (   $a_horizontalvalue)

Set Horizontal Value.

Parameters
string$a_horizontalvalueHorizontal Value

Definition at line 62 of file class.ilBackgroundPositionInputGUI.php.

Referenced by checkInput(), setValue(), and setValueByArray().

63  {
64  $this->horizontalvalue = $a_horizontalvalue;
65  }
+ Here is the caller graph for this function:

◆ setValue()

ilBackgroundPositionInputGUI::setValue (   $a_val)

Set value.

Definition at line 119 of file class.ilBackgroundPositionInputGUI.php.

References setHorizontalValue(), and setVerticalValue().

120  {
121  $a_val = trim($a_val);
122  $a_val_arr = explode(" ", $a_val);
123  $hor = trim($a_val_arr[0]);
124  $ver = trim($a_val_arr[1]);
125  if ($hor == "center" && $ver == "") {
126  $ver = "center";
127  }
128  $this->setHorizontalValue($hor);
129  $this->setVerticalValue($ver);
130  }
setVerticalValue($a_verticalvalue)
Set Vertical Value.
setHorizontalValue($a_horizontalvalue)
Set Horizontal Value.
+ Here is the call graph for this function:

◆ setValueByArray()

ilBackgroundPositionInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

Definition at line 261 of file class.ilBackgroundPositionInputGUI.php.

References $ilUser, $user, ilFormPropertyGUI\getPostVar(), setHorizontalValue(), and setVerticalValue().

262  {
264 
265  if ($a_values[$this->getPostVar()]["horizontal"]["type"] == "predefined") {
266  $this->setHorizontalValue($a_values[$this->getPostVar()]["horizontal"]["pre_value"]);
267  } else {
268  $this->setHorizontalValue($a_values[$this->getPostVar()]["horizontal"]["num_value"] .
269  $a_values[$this->getPostVar()]["horizontal"]["num_unit"]);
270  }
271  if ($a_values[$this->getPostVar()]["vertical"]["type"] == "predefined") {
272  $this->setVerticalValue($a_values[$this->getPostVar()]["vertical"]["pre_value"]);
273  } else {
274  $this->setVerticalValue($a_values[$this->getPostVar()]["vertical"]["num_value"] .
275  $a_values[$this->getPostVar()]["vertical"]["num_unit"]);
276  }
277  }
getPostVar()
Get Post Variable.
setVerticalValue($a_verticalvalue)
Set Vertical Value.
setHorizontalValue($a_horizontalvalue)
Set Horizontal Value.
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:

◆ setVerticalValue()

ilBackgroundPositionInputGUI::setVerticalValue (   $a_verticalvalue)

Set Vertical Value.

Parameters
string$a_verticalvalueVertical Value

Definition at line 82 of file class.ilBackgroundPositionInputGUI.php.

Referenced by checkInput(), setValue(), and setValueByArray().

83  {
84  $this->verticalvalue = $a_verticalvalue;
85  }
+ Here is the caller graph for this function:

Field Documentation

◆ $user

ilBackgroundPositionInputGUI::$user
protected

Definition at line 36 of file class.ilBackgroundPositionInputGUI.php.

Referenced by setValueByArray().

◆ $value

ilBackgroundPositionInputGUI::$value
protected

Definition at line 38 of file class.ilBackgroundPositionInputGUI.php.

Referenced by checkInput(), and insert().


The documentation for this class was generated from the following file: