ILIAS  release_8 Revision v8.24
class.ilRegExpInputGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27{
28 private string $pattern = "";
29 protected string $nomatchmessage = "";
30
31 public function __construct(
32 string $a_title = "",
33 string $a_postvar = ""
34 ) {
35 global $DIC;
36
37 $this->lng = $DIC->language();
38 parent::__construct($a_title, $a_postvar);
39 $this->setType("feedurl");
40 }
41
42 public function setNoMatchMessage(string $a_nomatchmessage): void
43 {
44 $this->nomatchmessage = $a_nomatchmessage;
45 }
46
47 public function getNoMatchMessage(): string
48 {
50 }
51
52 public function setPattern(string $pattern): void
53 {
54 $this->pattern = $pattern;
55 }
56
57 public function getPattern(): string
58 {
59 return $this->pattern;
60 }
61
62 public function checkInput(): bool
63 {
65
66 $value = $this->getInput();
67
68 if (!$this->getRequired() && strcasecmp($value, "") == 0) {
69 return true;
70 }
71
72 if ($this->getRequired() && trim($value) == "") {
73 $this->setAlert($lng->txt("msg_input_is_required"));
74 return false;
75 }
76
77 $result = (bool) preg_match($this->pattern, $value);
78 if (!$result) {
79 if ($this->getNoMatchMessage() == "") {
80 $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
81 } else {
82 $this->setAlert($this->getNoMatchMessage());
83 }
84 }
85 return $result;
86 }
87
88 public function getInput(): string
89 {
90 return $this->str($this->getPostVar());
91 }
92}
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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc