ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilNumberInputGUI Class Reference

This class represents a number property in a property form. More...

+ Inheritance diagram for ilNumberInputGUI:
+ Collaboration diagram for ilNumberInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setSuffix ($a_value)
 Set suffix. More...
 
 getSuffix ()
 Get suffix. More...
 
 setValue ($a_value)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setMaxLength ($a_maxlength)
 Set Max Length. More...
 
 getMaxLength ()
 Get Max Length. More...
 
 setMinvalueShouldBeGreater ($a_bool)
 Set minvalueShouldBeGreater. More...
 
 minvalueShouldBeGreater ()
 Get minvalueShouldBeGreater. More...
 
 setMaxvalueShouldBeLess ($a_bool)
 Set maxvalueShouldBeLess. More...
 
 maxvalueShouldBeLess ()
 Get maxvalueShouldBeLess. More...
 
 setSize ($a_size)
 Set Size. More...
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 getSize ()
 Get Size. More...
 
 setMinValue ($a_minvalue)
 Set Minimum Value. More...
 
 getMinValue ()
 Get Minimum Value. More...
 
 setMaxValue ($a_maxvalue)
 Set Maximum Value. More...
 
 getMaxValue ()
 Get Maximum Value. More...
 
 setDecimals ($a_decimals)
 Set Decimal Places. More...
 
 getDecimals ()
 Get Decimal Places. More...
 
 allowDecimals ($a_value)
 Toggle Decimals. More...
 
 areDecimalsAllowed ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 insert (&$a_tpl)
 Insert property html. More...
 
 render ()
 Insert property html. More...
 
 getPostValueForComparison ()
 parse post value to make it comparable More...
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem. More...
 
 getSubItems ()
 Get Subitems. More...
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 Get sub form html. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. 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...
 

Protected Attributes

 $value
 
 $maxlength = 200
 
 $size = 40
 
 $suffix
 
 $minvalue = false
 
 $minvalueShouldBeGreater = false
 
 $maxvalue = false
 
 $maxvalueShouldBeLess = false
 
 $decimals
 
 $allow_decimals = false
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
 $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
 $type
 
 $title
 
 $postvar
 
 $info
 
 $alert
 
 $required = false
 
 $parentgui
 
 $parentform
 
 $hidden_title = ""
 
 $multi = false
 
 $multi_sortable = false
 
 $multi_addremove = true
 
 $multi_values
 

Additional Inherited Members

- 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 number property 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 14 of file class.ilNumberInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Definition at line 33 of file class.ilNumberInputGUI.php.

34  {
35  parent::__construct($a_title, $a_postvar);
36  }

Member Function Documentation

◆ allowDecimals()

◆ areDecimalsAllowed()

ilNumberInputGUI::areDecimalsAllowed ( )
Returns
bool

Definition at line 266 of file class.ilNumberInputGUI.php.

References $allow_decimals.

Referenced by render(), and setValue().

267  {
268  return $this->allow_decimals;
269  }
+ Here is the caller graph for this function:

◆ checkInput()

ilNumberInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Definition at line 276 of file class.ilNumberInputGUI.php.

References $_POST, $lng, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), getMaxValue(), getMinValue(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), maxvalueShouldBeLess(), minvalueShouldBeGreater(), ilFormPropertyGUI\setAlert(), and ilUtil\stripSlashes().

277  {
278  global $lng;
279 
280  $_POST[$this->getPostVar()] = ilUtil::stripSlashes($_POST[$this->getPostVar()]);
281  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
282  {
283  $this->setAlert($lng->txt("msg_input_is_required"));
284 
285  return false;
286  }
287 
288  if (trim($_POST[$this->getPostVar()]) != "" &&
289  ! is_numeric(str_replace(',', '.', $_POST[$this->getPostVar()])))
290  {
291  $this->setAlert($lng->txt("form_msg_numeric_value_required"));
292 
293  return false;
294  }
295 
296  if ($this->minvalueShouldBeGreater())
297  {
298  if (trim($_POST[$this->getPostVar()]) != "" &&
299  $this->getMinValue() !== false &&
300  $_POST[$this->getPostVar()] <= $this->getMinValue())
301  {
302  $this->setAlert($lng->txt("form_msg_value_too_low"));
303 
304  return false;
305  }
306  }
307  else
308  {
309  if (trim($_POST[$this->getPostVar()]) != "" &&
310  $this->getMinValue() !== false &&
311  $_POST[$this->getPostVar()] < $this->getMinValue())
312  {
313  $this->setAlert($lng->txt("form_msg_value_too_low"));
314 
315  return false;
316  }
317  }
318 
319  if ($this->maxvalueShouldBeLess())
320  {
321  if (trim($_POST[$this->getPostVar()]) != "" &&
322  $this->getMaxValue() !== false &&
323  $_POST[$this->getPostVar()] >= $this->getMaxValue())
324  {
325  $this->setAlert($lng->txt("form_msg_value_too_high"));
326 
327  return false;
328  }
329  }
330  else
331  {
332  if (trim($_POST[$this->getPostVar()]) != "" &&
333  $this->getMaxValue() !== false &&
334  $_POST[$this->getPostVar()] > $this->getMaxValue())
335  {
336  $this->setAlert($lng->txt("form_msg_value_too_high"));
337 
338  return false;
339  }
340  }
341 
342  return $this->checkSubItemsInput();
343  }
$_POST['username']
Definition: cron.php:12
getMinValue()
Get Minimum Value.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
minvalueShouldBeGreater()
Get minvalueShouldBeGreater.
getMaxValue()
Get Maximum Value.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $lng
Definition: privfeed.php:40
maxvalueShouldBeLess()
Get maxvalueShouldBeLess.
+ Here is the call graph for this function:

◆ getDecimals()

ilNumberInputGUI::getDecimals ( )

Get Decimal Places.

Returns
int Decimal Places

Definition at line 246 of file class.ilNumberInputGUI.php.

References $decimals.

Referenced by render(), and setValue().

247  {
248  return $this->decimals;
249  }
+ Here is the caller graph for this function:

◆ getMaxLength()

ilNumberInputGUI::getMaxLength ( )

Get Max Length.

Returns
int Max Length

Definition at line 112 of file class.ilNumberInputGUI.php.

References $maxlength.

Referenced by render().

113  {
114  return $this->maxlength;
115  }
+ Here is the caller graph for this function:

◆ getMaxValue()

ilNumberInputGUI::getMaxValue ( )

Get Maximum Value.

Returns
float Maximum Value

Definition at line 222 of file class.ilNumberInputGUI.php.

References $maxvalue.

Referenced by checkInput(), and render().

223  {
224  return $this->maxvalue;
225  }
+ Here is the caller graph for this function:

◆ getMinValue()

ilNumberInputGUI::getMinValue ( )

Get Minimum Value.

Returns
float Minimum Value

Definition at line 202 of file class.ilNumberInputGUI.php.

References $minvalue.

Referenced by checkInput(), and render().

203  {
204  return $this->minvalue;
205  }
+ Here is the caller graph for this function:

◆ getPostValueForComparison()

ilNumberInputGUI::getPostValueForComparison ( )

parse post value to make it comparable

used by combination input gui

Definition at line 422 of file class.ilNumberInputGUI.php.

References $_POST, $value, ilFormPropertyGUI\getPostVar(), and ilUtil\stripSlashes().

423  {
425  if($value != "")
426  {
427  return (int)$value;
428  }
429  }
$_POST['username']
Definition: cron.php:12
getPostVar()
Get Post Variable.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
+ Here is the call graph for this function:

◆ getSize()

ilNumberInputGUI::getSize ( )

Get Size.

Returns
int Size

Definition at line 182 of file class.ilNumberInputGUI.php.

References $size.

Referenced by render().

183  {
184  return $this->size;
185  }
+ Here is the caller graph for this function:

◆ getSuffix()

ilNumberInputGUI::getSuffix ( )

Get suffix.

Returns
string suffix

Definition at line 53 of file class.ilNumberInputGUI.php.

References $suffix.

Referenced by render().

54  {
55  return $this->suffix;
56  }
+ Here is the caller graph for this function:

◆ getValue()

ilNumberInputGUI::getValue ( )

Get Value.

Returns
string Value

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

References $value.

Referenced by render().

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

◆ insert()

ilNumberInputGUI::insert ( $a_tpl)

Insert property html.

Returns
int Size

Definition at line 350 of file class.ilNumberInputGUI.php.

References render().

351  {
352  $html = $this->render();
353 
354  $a_tpl->setCurrentBlock("prop_generic");
355  $a_tpl->setVariable("PROP_GENERIC", $html);
356  $a_tpl->parseCurrentBlock();
357  }
render()
Insert property html.
+ Here is the call graph for this function:

◆ maxvalueShouldBeLess()

ilNumberInputGUI::maxvalueShouldBeLess ( )

Get maxvalueShouldBeLess.

Returns
boolean true if the maximum value should be less than maxvalue

Definition at line 152 of file class.ilNumberInputGUI.php.

References $maxvalueShouldBeLess.

Referenced by checkInput(), render(), and setMaxvalueShouldBeLess().

153  {
155  }
+ Here is the caller graph for this function:

◆ minvalueShouldBeGreater()

ilNumberInputGUI::minvalueShouldBeGreater ( )

Get minvalueShouldBeGreater.

Returns
boolean true if the minimum value should be greater than minvalue

Definition at line 132 of file class.ilNumberInputGUI.php.

References $minvalueShouldBeGreater.

Referenced by checkInput(), render(), and setMinvalueShouldBeGreater().

133  {
135  }
+ Here is the caller graph for this function:

◆ render()

ilNumberInputGUI::render ( )

Insert property html.

Definition at line 362 of file class.ilNumberInputGUI.php.

References $lng, $tpl, areDecimalsAllowed(), getDecimals(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), getMaxLength(), getMaxValue(), getMinValue(), ilFormPropertyGUI\getPostVar(), getSize(), getSuffix(), getValue(), maxvalueShouldBeLess(), minvalueShouldBeGreater(), and ilUtil\prepareFormOutput().

Referenced by insert().

363  {
364  global $lng;
365 
366  $tpl = new ilTemplate("tpl.prop_number.html", true, true, "Services/Form");
367 
368  if (strlen($this->getValue()))
369  {
370  $tpl->setCurrentBlock("prop_number_propval");
371  $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
372  $tpl->parseCurrentBlock();
373  }
374  $tpl->setCurrentBlock("prop_number");
375 
376  $tpl->setVariable("POST_VAR", $this->getPostVar());
377  $tpl->setVariable("ID", $this->getFieldId());
378  $tpl->setVariable("SIZE", $this->getSize());
379  $tpl->setVariable("MAXLENGTH", $this->getMaxLength());
380  if (strlen($this->getSuffix())) $tpl->setVariable("INPUT_SUFFIX", $this->getSuffix());
381  if ($this->getDisabled())
382  {
383  $tpl->setVariable("DISABLED",
384  " disabled=\"disabled\"");
385  }
386 
387  /*
388  $tpl->setVariable("JS_DECIMALS_ALLOWED", (int)$this->areDecimalsAllowed());
389  */
390 
391  // constraints
392  if ($this->areDecimalsAllowed() && $this->getDecimals() > 0)
393  {
394  $constraints = $lng->txt("form_format").": ###.".str_repeat("#", $this->getDecimals());
395  $delim = ", ";
396  }
397  if ($this->getMinValue() !== false)
398  {
399  $constraints.= $delim.$lng->txt("form_min_value").": ".(($this->minvalueShouldBeGreater()) ? "&gt; " : "").$this->getMinValue();
400  $delim = ", ";
401  }
402  if ($this->getMaxValue() !== false)
403  {
404  $constraints.= $delim.$lng->txt("form_max_value").": ".(($this->maxvalueShouldBeLess()) ? "&lt; " : "").$this->getMaxValue();
405  $delim = ", ";
406  }
407  if ($constraints != "")
408  {
409  $tpl->setVariable("TXT_NUMBER_CONSTRAINTS", $constraints);
410  }
411 
412  $tpl->parseCurrentBlock();
413 
414  return $tpl->get();
415  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getMinValue()
Get Minimum Value.
getPostVar()
Get Post Variable.
getMaxLength()
Get Max Length.
minvalueShouldBeGreater()
Get minvalueShouldBeGreater.
getMaxValue()
Get Maximum Value.
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
getDecimals()
Get Decimal Places.
maxvalueShouldBeLess()
Get maxvalueShouldBeLess.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDecimals()

ilNumberInputGUI::setDecimals (   $a_decimals)

Set Decimal Places.

Parameters
int$a_decimalsDecimal Places

Definition at line 232 of file class.ilNumberInputGUI.php.

References allowDecimals().

Referenced by SurveyMetricQuestionGUI\addFieldsToEditForm(), ilObjFileAccessSettingsGUI\initPreviewSettingsForm(), ilObjFileAccessSettingsGUI\initUploadSettingsForm(), and assJavaAppletGUI\populateQuestionSpecificFormPart().

233  {
234  $this->decimals = (int)$a_decimals;
235  if($this->decimals)
236  {
237  $this->allowDecimals(true);
238  }
239  }
allowDecimals($a_value)
Toggle Decimals.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMaxLength()

◆ setMaxValue()

ilNumberInputGUI::setMaxValue (   $a_maxvalue)

Set Maximum Value.

Parameters
float$a_maxvalueMaximum Value

Definition at line 212 of file class.ilNumberInputGUI.php.

Referenced by ilObjMediaCastGUI\initSettingsForm(), and ilObjStyleSheetGUI\initTemplateGenerationForm().

213  {
214  $this->maxvalue = $a_maxvalue;
215  }
+ Here is the caller graph for this function:

◆ setMaxvalueShouldBeLess()

ilNumberInputGUI::setMaxvalueShouldBeLess (   $a_bool)

Set maxvalueShouldBeLess.

Parameters
boolean$a_booltrue if the maximum value should be less than maxvalue

Definition at line 142 of file class.ilNumberInputGUI.php.

References maxvalueShouldBeLess().

143  {
144  $this->maxvalueShouldBeLess = $a_bool;
145  }
maxvalueShouldBeLess()
Get maxvalueShouldBeLess.
+ Here is the call graph for this function:

◆ setMinValue()

ilNumberInputGUI::setMinValue (   $a_minvalue)

◆ setMinvalueShouldBeGreater()

ilNumberInputGUI::setMinvalueShouldBeGreater (   $a_bool)

Set minvalueShouldBeGreater.

Parameters
boolean$a_booltrue if the minimum value should be greater than minvalue

Definition at line 122 of file class.ilNumberInputGUI.php.

References minvalueShouldBeGreater().

123  {
124  $this->minvalueShouldBeGreater = $a_bool;
125  }
minvalueShouldBeGreater()
Get minvalueShouldBeGreater.
+ Here is the call graph for this function:

◆ setSize()

◆ setSuffix()

ilNumberInputGUI::setSuffix (   $a_value)

Set suffix.

Parameters
string$a_valuesuffix

Definition at line 43 of file class.ilNumberInputGUI.php.

Referenced by assSingleChoiceGUI\populateQuestionSpecificFormPart(), and assMultipleChoiceGUI\populateQuestionSpecificFormPart().

44  {
45  $this->suffix = $a_value;
46  }
+ Here is the caller graph for this function:

◆ setValue()

ilNumberInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

Definition at line 63 of file class.ilNumberInputGUI.php.

References areDecimalsAllowed(), and getDecimals().

Referenced by assClozeTestGUI\addBasicQuestionFormProperties(), assQuestionGUI\addBasicQuestionFormProperties(), ilECSMappingSettingsGUI\dInitFormTreeSettings(), ilCASSettingsGUI\initFormSettings(), ilObjSystemFolderGUI\initJavaServerIniForm(), ilObjPaymentSettingsGUI\InvoiceNumberObject(), assTextQuestionGUI\populateAnswerSpecificFormPart(), assFileUploadGUI\populateQuestionSpecificFormPart(), assJavaAppletGUI\populateQuestionSpecificFormPart(), assFlashQuestionGUI\populateQuestionSpecificFormPart(), assErrorTextGUI\populateQuestionSpecificFormPart(), assMatchingQuestionGUI\populateQuestionSpecificFormPart(), assOrderingQuestionGUI\populateQuestionSpecificFormPart(), assClozeTestGUI\populateQuestionSpecificFormPart(), assOrderingHorizontalGUI\populateQuestionSpecificFormPart(), and setValueByArray().

64  {
65  $this->value = str_replace(',', '.', $a_value);
66 
67  // empty strings are allowed
68  if($this->value != "")
69  {
70  // integer
71  if(!$this->areDecimalsAllowed())
72  {
73  $this->value = round($this->value);
74  }
75  // float
76  else if($this->getDecimals() > 0)
77  {
78  // get rid of unwanted decimals
79  $this->value = round($this->value, $this->getDecimals());
80 
81  // pad value to specified format
82  $this->value = number_format($this->value, $this->getDecimals(), ".", "");
83  }
84  }
85  }
getDecimals()
Get Decimal Places.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValueByArray()

ilNumberInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

Definition at line 172 of file class.ilNumberInputGUI.php.

References ilFormPropertyGUI\getPostVar(), and setValue().

173  {
174  $this->setValue($a_values[$this->getPostVar()]);
175  }
setValue($a_value)
Set Value.
getPostVar()
Get Post Variable.
+ Here is the call graph for this function:

Field Documentation

◆ $allow_decimals

ilNumberInputGUI::$allow_decimals = false
protected

Definition at line 25 of file class.ilNumberInputGUI.php.

Referenced by areDecimalsAllowed().

◆ $decimals

ilNumberInputGUI::$decimals
protected

Definition at line 24 of file class.ilNumberInputGUI.php.

Referenced by getDecimals().

◆ $maxlength

ilNumberInputGUI::$maxlength = 200
protected

Definition at line 17 of file class.ilNumberInputGUI.php.

Referenced by getMaxLength().

◆ $maxvalue

ilNumberInputGUI::$maxvalue = false
protected

Definition at line 22 of file class.ilNumberInputGUI.php.

Referenced by getMaxValue().

◆ $maxvalueShouldBeLess

ilNumberInputGUI::$maxvalueShouldBeLess = false
protected

Definition at line 23 of file class.ilNumberInputGUI.php.

Referenced by maxvalueShouldBeLess().

◆ $minvalue

ilNumberInputGUI::$minvalue = false
protected

Definition at line 20 of file class.ilNumberInputGUI.php.

Referenced by getMinValue().

◆ $minvalueShouldBeGreater

ilNumberInputGUI::$minvalueShouldBeGreater = false
protected

Definition at line 21 of file class.ilNumberInputGUI.php.

Referenced by minvalueShouldBeGreater().

◆ $size

ilNumberInputGUI::$size = 40
protected

Definition at line 18 of file class.ilNumberInputGUI.php.

Referenced by getSize().

◆ $suffix

ilNumberInputGUI::$suffix
protected

Definition at line 19 of file class.ilNumberInputGUI.php.

Referenced by getSuffix().

◆ $value

ilNumberInputGUI::$value
protected

Definition at line 16 of file class.ilNumberInputGUI.php.

Referenced by getPostValueForComparison(), and getValue().


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