ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilFormulaInputGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Form/classes/class.ilTextInputGUI.php");
5include_once("./Services/Math/classes/class.EvalMath.php");
6
15{
16
20 public function __construct($a_title = "", $a_postvar = "")
21 {
22 global $DIC;
23 parent::__construct($a_title, $a_postvar);
24
25 $this->lng = $DIC->language();
26 }
27
33 public function setValue($a_value)
34 {
35 $this->value = str_replace(',', '.', $a_value);
36 }
37
43 public function checkInput()
44 {
46
48 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "") {
49 $this->setAlert($lng->txt("msg_input_is_required"));
50
51 return false;
52 } else {
53 $eval = new EvalMath();
54 $eval->suppress_errors = true;
55 $result = $eval->e(str_replace(",", ".", ilUtil::stripSlashes($_POST[$this->getPostVar()], false)));
56 if ($result === false) {
57 $this->setAlert($lng->txt("form_msg_formula_is_required"));
58 return false;
59 }
60 }
61
62 return $this->checkSubItemsInput();
63 }
64}
$result
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
This class represents a formula text property in a property form.
setValue($a_value)
Set Value.
checkInput()
Check input, strip slashes etc.
__construct($a_title="", $a_postvar="")
Constructor.
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $DIC
Definition: saml.php:7