ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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.
 setSuffix ($a_value)
 Set suffix.
 getSuffix ()
 Get suffix.
 setValue ($a_value)
 Set Value.
 getValue ()
 Get Value.
 setMaxLength ($a_maxlength)
 Set Max Length.
 getMaxLength ()
 Get Max Length.
 setMinvalueShouldBeGreater ($a_bool)
 Set minvalueShouldBeGreater.
 minvalueShouldBeGreater ()
 Get minvalueShouldBeGreater.
 setMaxvalueShouldBeLess ($a_bool)
 Set maxvalueShouldBeLess.
 maxvalueShouldBeLess ()
 Get maxvalueShouldBeLess.
 setSize ($a_size)
 Set Size.
 setValueByArray ($a_values)
 Set value by array.
 getSize ()
 Get Size.
 setMinValue ($a_minvalue, $a_display_always=false)
 Set Minimum Value.
 getMinValue ()
 Get Minimum Value.
 setMaxValue ($a_maxvalue, $a_display_always=false)
 Set Maximum Value.
 getMaxValue ()
 Get Maximum Value.
 setDecimals ($a_decimals)
 Set Decimal Places.
 getDecimals ()
 Get Decimal Places.
 allowDecimals ($a_value)
 Toggle Decimals.
 areDecimalsAllowed ()
 checkInput ()
 Check input, strip slashes etc.
 insert (&$a_tpl)
 Insert property html.
 render ()
 Insert property html.
 getPostValueForComparison ()
 parse post value to make it comparable
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem.
 getSubItems ()
 Get Subitems.
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively
 checkSubItemsInput ()
 Check SubItems.
 getSubForm ()
 Get sub form html.
 getItemByPostVar ($a_post_var)
 Get item by post var.
- Public Member Functions inherited from ilFormPropertyGUI
executeCommand ()
 Execute command.
 getType ()
 Get Type.
 setTitle ($a_title)
 Set Title.
 getTitle ()
 Get Title.
 setPostVar ($a_postvar)
 Set Post Variable.
 getPostVar ()
 Get Post Variable.
 getFieldId ()
 Get Post Variable.
 setInfo ($a_info)
 Set Information Text.
 getInfo ()
 Get Information Text.
 setAlert ($a_alert)
 Set Alert Text.
 getAlert ()
 Get Alert Text.
 setRequired ($a_required)
 Set Required.
 getRequired ()
 Get Required.
 setDisabled ($a_disabled)
 Set Disabled.
 getDisabled ()
 Get Disabled.
 setParentForm ($a_parentform)
 Set Parent Form.
 getParentForm ()
 Get Parent Form.
 setParent ($a_val)
 Set Parent GUI object.
 getParent ()
 Get Parent GUI object.
 hideSubForm ()
 Sub form hidden on init?
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders)
 getHiddenTitle ()
 Get hidden title.
 serializeData ()
 serialize data
 unserializeData ($a_data)
 unserialize data
 writeToSession ()
 Write to session.
 clearFromSession ()
 Clear session value.
 readFromSession ()
 Read from session.
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties)
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi.
 getMulti ()
 Get Multi.
 setMultiValues (array $a_values)
 Set multi values.
 getMultiValues ()
 Get multi values.
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g.

Protected Attributes

 $value
 $maxlength = 200
 $size = 40
 $suffix
 $minvalue = false
 $minvalueShouldBeGreater = false
 $minvalue_visible = false
 $maxvalue = false
 $maxvalueShouldBeLess = false
 $maxvalue_visible = 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.
 getMultiIconsHTML ()
 Get HTML for multiple value icons.

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

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilFormPropertyGUI.

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

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

Member Function Documentation

ilNumberInputGUI::areDecimalsAllowed ( )
Returns
bool

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

References $allow_decimals.

Referenced by render(), and setValue().

{
}

+ Here is the caller graph for this function:

ilNumberInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Reimplemented from ilFormPropertyGUI.

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

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

{
global $lng;
if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
{
$this->setAlert($lng->txt("msg_input_is_required"));
return false;
}
if (trim($_POST[$this->getPostVar()]) != "" &&
! is_numeric(str_replace(',', '.', $_POST[$this->getPostVar()])))
{
$this->minvalue_visible = true;
$this->maxvalue_visible = true;
$this->setAlert($lng->txt("form_msg_numeric_value_required"));
return false;
}
{
if (trim($_POST[$this->getPostVar()]) != "" &&
$this->getMinValue() !== false &&
$_POST[$this->getPostVar()] <= $this->getMinValue())
{
$this->minvalue_visible = true;
$this->setAlert($lng->txt("form_msg_value_too_low"));
return false;
}
}
else
{
if (trim($_POST[$this->getPostVar()]) != "" &&
$this->getMinValue() !== false &&
$_POST[$this->getPostVar()] < $this->getMinValue())
{
$this->minvalue_visible = true;
$this->setAlert($lng->txt("form_msg_value_too_low"));
return false;
}
}
if ($this->maxvalueShouldBeLess())
{
if (trim($_POST[$this->getPostVar()]) != "" &&
$this->getMaxValue() !== false &&
$_POST[$this->getPostVar()] >= $this->getMaxValue())
{
$this->maxvalue_visible = true;
$this->setAlert($lng->txt("form_msg_value_too_high"));
return false;
}
}
else
{
if (trim($_POST[$this->getPostVar()]) != "" &&
$this->getMaxValue() !== false &&
$_POST[$this->getPostVar()] > $this->getMaxValue())
{
$this->maxvalue_visible = true;
$this->setAlert($lng->txt("form_msg_value_too_high"));
return false;
}
}
return $this->checkSubItemsInput();
}

+ Here is the call graph for this function:

ilNumberInputGUI::getDecimals ( )

Get Decimal Places.

Returns
int Decimal Places

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

References $decimals.

Referenced by render(), and setValue().

{
}

+ Here is the caller graph for this function:

ilNumberInputGUI::getMaxLength ( )

Get Max Length.

Returns
int Max Length

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

References $maxlength.

Referenced by render().

{
}

+ Here is the caller graph for this function:

ilNumberInputGUI::getMaxValue ( )

Get Maximum Value.

Returns
float Maximum Value

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

References $maxvalue.

Referenced by checkInput(), and render().

{
}

+ Here is the caller graph for this function:

ilNumberInputGUI::getMinValue ( )

Get Minimum Value.

Returns
float Minimum Value

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

References $minvalue.

Referenced by checkInput(), and render().

{
}

+ Here is the caller graph for this function:

ilNumberInputGUI::getPostValueForComparison ( )

parse post value to make it comparable

used by combination input gui

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

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

{
if($value != "")
{
return (int)$value;
}
}

+ Here is the call graph for this function:

ilNumberInputGUI::getSize ( )

Get Size.

Returns
int Size

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

References $size.

Referenced by render().

{
return $this->size;
}

+ Here is the caller graph for this function:

ilNumberInputGUI::getSuffix ( )

Get suffix.

Returns
string suffix

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

References $suffix.

Referenced by render().

{
return $this->suffix;
}

+ Here is the caller graph for this function:

ilNumberInputGUI::getValue ( )

Get Value.

Returns
string Value

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

References $value.

Referenced by render().

{
return $this->value;
}

+ Here is the caller graph for this function:

ilNumberInputGUI::insert ( $a_tpl)

Insert property html.

Returns
int Size

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

References render().

{
$html = $this->render();
$a_tpl->setCurrentBlock("prop_generic");
$a_tpl->setVariable("PROP_GENERIC", $html);
$a_tpl->parseCurrentBlock();
}

+ Here is the call graph for this function:

ilNumberInputGUI::maxvalueShouldBeLess ( )

Get maxvalueShouldBeLess.

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

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

References $maxvalueShouldBeLess.

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

+ Here is the caller graph for this function:

ilNumberInputGUI::minvalueShouldBeGreater ( )

Get minvalueShouldBeGreater.

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

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

References $minvalueShouldBeGreater.

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

+ Here is the caller graph for this function:

ilNumberInputGUI::render ( )

Insert property html.

Definition at line 368 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().

{
global $lng;
$tpl = new ilTemplate("tpl.prop_number.html", true, true, "Services/Form");
if (strlen($this->getValue()))
{
$tpl->setCurrentBlock("prop_number_propval");
$tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
$tpl->parseCurrentBlock();
}
$tpl->setCurrentBlock("prop_number");
$tpl->setVariable("POST_VAR", $this->getPostVar());
$tpl->setVariable("ID", $this->getFieldId());
$tpl->setVariable("SIZE", $this->getSize());
$tpl->setVariable("MAXLENGTH", $this->getMaxLength());
if (strlen($this->getSuffix())) $tpl->setVariable("INPUT_SUFFIX", $this->getSuffix());
if ($this->getDisabled())
{
$tpl->setVariable("DISABLED",
" disabled=\"disabled\"");
}
/*
$tpl->setVariable("JS_DECIMALS_ALLOWED", (int)$this->areDecimalsAllowed());
*/
// constraints
if ($this->areDecimalsAllowed() && $this->getDecimals() > 0)
{
$constraints = $lng->txt("form_format").": ###.".str_repeat("#", $this->getDecimals());
$delim = ", ";
}
if ($this->getMinValue() !== false && $this->minvalue_visible)
{
$constraints.= $delim.$lng->txt("form_min_value").": ".(($this->minvalueShouldBeGreater()) ? "&gt; " : "").$this->getMinValue();
$delim = ", ";
}
if ($this->getMaxValue() !== false && $this->maxvalue_visible)
{
$constraints.= $delim.$lng->txt("form_max_value").": ".(($this->maxvalueShouldBeLess()) ? "&lt; " : "").$this->getMaxValue();
$delim = ", ";
}
if ($constraints != "")
{
$tpl->setVariable("TXT_NUMBER_CONSTRAINTS", $constraints);
}
$tpl->parseCurrentBlock();
return $tpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilNumberInputGUI::setDecimals (   $a_decimals)

Set Decimal Places.

Parameters
int$a_decimalsDecimal Places

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

References allowDecimals().

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

{
$this->decimals = (int)$a_decimals;
if($this->decimals)
{
$this->allowDecimals(true);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilNumberInputGUI::setMaxLength (   $a_maxlength)
ilNumberInputGUI::setMaxValue (   $a_maxvalue,
  $a_display_always = false 
)

Set Maximum Value.

Parameters
float$a_maxvalueMaximum Value
bool$a_display_always

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

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

{
$this->maxvalue = $a_maxvalue;
$this->maxvalue_visible = (bool)$a_display_always;
}

+ Here is the caller graph for this function:

ilNumberInputGUI::setMaxvalueShouldBeLess (   $a_bool)

Set maxvalueShouldBeLess.

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

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

References maxvalueShouldBeLess().

{
$this->maxvalueShouldBeLess = $a_bool;
}

+ Here is the call graph for this function:

ilNumberInputGUI::setMinValue (   $a_minvalue,
  $a_display_always = false 
)

Set Minimum Value.

Parameters
float$a_minvalueMinimum Value
bool$a_display_always

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

Referenced by ilConsultationHourCron\addCustomSettingsToForm(), ilObjMediaPoolGUI\initEditCustomForm(), ilObjCourseGUI\initEditForm(), ilObjRoleGUI\initFormRoleProperties(), ilObjAdvancedEditingGUI\initGeneralPageSettingsForm(), ilObjStyleSheetGUI\initTagStyleForm(), ilObjSystemFolderGUI\initWebServicesForm(), and assTextSubsetGUI\populateQuestionSpecificFormPart().

{
$this->minvalue = $a_minvalue;
$this->minvalue_visible = (bool)$a_display_always;
}

+ Here is the caller graph for this function:

ilNumberInputGUI::setMinvalueShouldBeGreater (   $a_bool)

Set minvalueShouldBeGreater.

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

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

References minvalueShouldBeGreater().

{
$this->minvalueShouldBeGreater = $a_bool;
}

+ Here is the call graph for this function:

ilNumberInputGUI::setSuffix (   $a_value)

Set suffix.

Parameters
string$a_valuesuffix

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

Referenced by ilObjMediaPoolGUI\initEditCustomForm(), ilObjMailGUI\initForm(), assKprimChoiceGUI\populateQuestionSpecificFormPart(), assSingleChoiceGUI\populateQuestionSpecificFormPart(), and assMultipleChoiceGUI\populateQuestionSpecificFormPart().

{
$this->suffix = $a_value;
}

+ Here is the caller graph for this function:

ilNumberInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

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

References areDecimalsAllowed(), and getDecimals().

Referenced by assClozeTestGUI\addBasicQuestionFormProperties(), assQuestionGUI\addBasicQuestionFormProperties(), ilAdvancedMDFieldDefinitionText\addCustomFieldToDefinitionForm(), ilECSMappingSettingsGUI\dInitFormTreeSettings(), ilObjPersonalDesktopSettingsGUI\editSettings(), ilCourseObjectivesGUI\initFormLimits(), ilCourseObjectivesGUI\initFormRandom(), ilCASSettingsGUI\initFormSettings(), ilObjSystemFolderGUI\initJavaServerIniForm(), ilObjRepositorySettingsGUI\initSettingsForm(), ilObjPaymentSettingsGUI\InvoiceNumberObject(), assFileUploadGUI\populateQuestionSpecificFormPart(), assJavaAppletGUI\populateQuestionSpecificFormPart(), assFlashQuestionGUI\populateQuestionSpecificFormPart(), assErrorTextGUI\populateQuestionSpecificFormPart(), assMatchingQuestionGUI\populateQuestionSpecificFormPart(), assOrderingQuestionGUI\populateQuestionSpecificFormPart(), assClozeTestGUI\populateQuestionSpecificFormPart(), assOrderingHorizontalGUI\populateQuestionSpecificFormPart(), and setValueByArray().

{
$this->value = str_replace(',', '.', $a_value);
// empty strings are allowed
if($this->value != "")
{
// integer
if(!$this->areDecimalsAllowed())
{
$this->value = round($this->value);
}
// float
else if($this->getDecimals() > 0)
{
// get rid of unwanted decimals
$this->value = round($this->value, $this->getDecimals());
// pad value to specified format
$this->value = number_format($this->value, $this->getDecimals(), ".", "");
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilNumberInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

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

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

{
$this->setValue($a_values[$this->getPostVar()]);
}

+ Here is the call graph for this function:

Field Documentation

ilNumberInputGUI::$allow_decimals = false
protected

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

Referenced by areDecimalsAllowed().

ilNumberInputGUI::$decimals
protected

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

Referenced by getDecimals().

ilNumberInputGUI::$maxlength = 200
protected

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

Referenced by getMaxLength().

ilNumberInputGUI::$maxvalue = false
protected

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

Referenced by getMaxValue().

ilNumberInputGUI::$maxvalue_visible = false
protected

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

ilNumberInputGUI::$maxvalueShouldBeLess = false
protected

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

Referenced by maxvalueShouldBeLess().

ilNumberInputGUI::$minvalue = false
protected

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

Referenced by getMinValue().

ilNumberInputGUI::$minvalue_visible = false
protected

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

ilNumberInputGUI::$minvalueShouldBeGreater = false
protected

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

Referenced by minvalueShouldBeGreater().

ilNumberInputGUI::$size = 40
protected

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

Referenced by getSize().

ilNumberInputGUI::$suffix
protected

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

Referenced by getSuffix().

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: