ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilFormulaInputGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27{
28 public function __construct(
29 string $a_title = "",
30 string $a_postvar = ""
31 ) {
32 global $DIC;
33 parent::__construct($a_title, $a_postvar);
34
35 $this->lng = $DIC->language();
36 }
37
41 public function setValue($a_value): void
42 {
43 $this->value = str_replace(',', '.', $a_value);
44 }
45
50 public function checkInput(): bool
51 {
53
54 if ($this->getRequired() && $this->getInput() == "") {
55 $this->setAlert($lng->txt("msg_input_is_required"));
56 return false;
57 } else {
58 $eval = new EvalMath();
59 $eval->suppress_errors = true;
60 $result = $eval->e(str_replace(",", ".", $this->getInput()));
61 if ($result === false) {
62 $this->setAlert($lng->txt("form_msg_formula_is_required"));
63 return false;
64 }
65 }
66
67 return $this->checkSubItemsInput();
68 }
69
70 public function getInput(): string
71 {
72 $t = $this->refinery->kindlyTo()->string();
74 (string) ($this->getRequestParam($this->getPostVar(), $t) ?? ""),
75 false
76 );
77 }
78}
getRequestParam(string $key, Refinery\Transformation $t)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkInput()
Check input, strip slashes etc.
__construct(string $a_title="", string $a_postvar="")
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...
This class represents a text property in a property form.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc