ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 function __construct($a_title = "", $a_postvar = "")
42 {
43 parent::__construct($a_title, $a_postvar);
44 $this->setType("feedurl");
45 }
46
52 function setNoMatchMessage($a_nomatchmessage)
53 {
54 $this->nomatchmessage = $a_nomatchmessage;
55 }
56
63 {
64 return $this->nomatchmessage;
65 }
66
73 {
74 $this->pattern = $pattern;
75 }
76
82 function getPattern ()
83 {
84 return $this->pattern;
85 }
86
92 function checkInput()
93 {
94 global $lng;
95
96 // this line is necessary, otherwise it is a security issue (Alex)
98
99 $value = $_POST[$this->getPostVar()];
100
101 if (!$this->getRequired() && strcasecmp($value, "") == 0)
102 {
103 return true;
104 }
105
106 if ($this->getRequired() && trim($value) == "")
107 {
108 $this->setAlert($lng->txt("msg_input_is_required"));
109
110 return false;
111 }
112
113 $result = preg_match ($this->pattern, $value);
114 if (!$result)
115 {
116 if ($this->getNoMatchMessage() == "")
117 {
118 $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
119 }
120 else
121 {
122 $this->setAlert($this->getNoMatchMessage());
123 }
124 }
125 return $result;
126
127 }
128
129}
$result
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
$_POST['username']
Definition: cron.php:12
global $lng
Definition: privfeed.php:40