ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDclTextInputGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 public function setValueByArray(array $a_values): void
24 {
25 parent::setValueByArray($a_values);
26 foreach ($this->getSubItems() as $item) {
27 $item->setValueByArray($a_values);
28 }
29 }
30
31 public function checkInput(): bool
32 {
33 // validate regex
34 $has_postvar = $this->http->wrapper()->post()->has($this->getPostVar());
35 if ($this->getPostVar() == 'prop_' . ilDclBaseFieldModel::PROP_REGEX && $has_postvar) {
36 $regex = $this->http->wrapper()->post()->retrieve(
37 $this->getPostVar(),
38 $this->refinery->kindlyTo()->string()
39 );
40 if (substr($regex, 0, 1) != "/") {
41 $regex = "/" . $regex;
42 }
43 if (substr($regex, -1) != "/" || $regex == "/") {
44 $regex .= "/";
45 }
46
47 try {
48 preg_match($regex, '');
49 } catch (Exception) {
50 global $DIC;
51 $lng = $DIC['lng'];
52 $this->setAlert($lng->txt('msg_input_does_not_match_regexp'));
53
54 return false;
55 }
56 }
57
58 return parent::checkInput();
59 }
60}
setValueByArray(array $a_values)
checkInput()
Check input, strip slashes etc.
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 http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26