ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
5 include_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  {
45  $lng = $this->lng;
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 }
This class represents a formula text property in a property form.
$result
setValue($a_value)
Set Value.
global $DIC
Definition: saml.php:7
getPostVar()
Get Post Variable.
__construct($a_title="", $a_postvar="")
Constructor.
setAlert($a_alert)
Set Alert Text.
This class represents a text property in a property form.
checkInput()
Check input, strip slashes etc.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$_POST["username"]