ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilFormulaInputGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
28 {
29  public function __construct(
30  string $a_title = "",
31  string $a_postvar = ""
32  ) {
33  global $DIC;
34  parent::__construct($a_title, $a_postvar);
35 
36  $this->lng = $DIC->language();
37  }
38 
42  public function setValue($a_value): void
43  {
44  $this->value = str_replace(',', '.', $a_value);
45  }
46 
51  public function checkInput(): bool
52  {
53  $lng = $this->lng;
54 
55  if ($this->getRequired() && $this->getInput() == "") {
56  $this->setAlert($lng->txt("msg_input_is_required"));
57  return false;
58  } else {
59  $eval = new EvalMath();
60  $eval->suppress_errors = true;
61  $result = $eval->e(str_replace(",", ".", $this->getInput()));
62  if ($result === false) {
63  $this->setAlert($lng->txt("form_msg_formula_is_required"));
64  return false;
65  }
66  }
67 
68  return $this->checkSubItemsInput();
69  }
70 
71  public function getInput(): string
72  {
73  $t = $this->refinery->kindlyTo()->string();
74  return ilUtil::stripSlashes(
75  (string) ($this->getRequestParam($this->getPostVar(), $t) ?? ""),
76  false
77  );
78  }
79 }
getRequestParam(string $key, Refinery\Transformation $t)
This class represents a formula text property in a property form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
global $DIC
Definition: shib_login.php:26
checkInput()
Check input, strip slashes etc.
__construct(string $a_title="", string $a_postvar="")
__construct(Container $dic, ilPlugin $plugin)