ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilRegExpInputGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 private string $pattern = "";
30 protected string $nomatchmessage = "";
31
32 public function __construct(
33 string $a_title = "",
34 string $a_postvar = ""
35 ) {
36 global $DIC;
37
38 $this->lng = $DIC->language();
39 parent::__construct($a_title, $a_postvar);
40 $this->setType("feedurl");
41 }
42
43 public function setNoMatchMessage(string $a_nomatchmessage): void
44 {
45 $this->nomatchmessage = $a_nomatchmessage;
46 }
47
48 public function getNoMatchMessage(): string
49 {
51 }
52
53 public function setPattern(string $pattern): void
54 {
55 $this->pattern = $pattern;
56 }
57
58 public function getPattern(): string
59 {
60 return $this->pattern;
61 }
62
63 public function checkInput(): bool
64 {
66
67 $value = $this->getInput();
68
69 if (!$this->getRequired() && strcasecmp($value, "") == 0) {
70 return true;
71 }
72
73 if ($this->getRequired() && trim($value) == "") {
74 $this->setAlert($lng->txt("msg_input_is_required"));
75 return false;
76 }
77
78 $result = (bool) preg_match($this->pattern, $value);
79 if (!$result) {
80 if ($this->getNoMatchMessage() == "") {
81 $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
82 } else {
83 $this->setAlert($this->getNoMatchMessage());
84 }
85 }
86 return $result;
87 }
88
89 public function getInput(): string
90 {
91 return $this->str($this->getPostVar());
92 }
93}
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 regular expression input property in a property form.
setPattern(string $pattern)
setNoMatchMessage(string $a_nomatchmessage)
__construct(string $a_title="", string $a_postvar="")
checkInput()
Check input, strip slashes etc.
This class represents a text property in a property form.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26