ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilRegExpInputGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2007 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
32{
33 private $pattern;
34
41 public function __construct($a_title = "", $a_postvar = "")
42 {
43 global $DIC;
44
45 $this->lng = $DIC->language();
46 parent::__construct($a_title, $a_postvar);
47 $this->setType("feedurl");
48 }
49
55 public function setNoMatchMessage($a_nomatchmessage)
56 {
57 $this->nomatchmessage = $a_nomatchmessage;
58 }
59
65 public function getNoMatchMessage()
66 {
67 return $this->nomatchmessage;
68 }
69
75 public function setPattern($pattern)
76 {
77 $this->pattern = $pattern;
78 }
79
85 public function getPattern()
86 {
87 return $this->pattern;
88 }
89
95 public function checkInput()
96 {
98
99 // this line is necessary, otherwise it is a security issue (Alex)
101
102 $value = $_POST[$this->getPostVar()];
103
104 if (!$this->getRequired() && strcasecmp($value, "") == 0) {
105 return true;
106 }
107
108 if ($this->getRequired() && trim($value) == "") {
109 $this->setAlert($lng->txt("msg_input_is_required"));
110
111 return false;
112 }
113
114 $result = preg_match($this->pattern, $value);
115 if (!$result) {
116 if ($this->getNoMatchMessage() == "") {
117 $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
118 } else {
119 $this->setAlert($this->getNoMatchMessage());
120 }
121 }
122 return $result;
123 }
124}
$result
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
setType($a_type)
Set Type.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
This class represents a regular expression input property in a property form.
setNoMatchMessage($a_nomatchmessage)
Set Message, if input does not match.
getNoMatchMessage()
Get Message, if input does not match.
__construct($a_title="", $a_postvar="")
Constructor.
getPattern()
return pattern
checkInput()
Check input, strip slashes etc.
setPattern($pattern)
set pattern
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $DIC
Definition: saml.php:7