Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezregexpvalidator.php
Go to the documentation of this file.
1 <?php
17 class eZRegExpValidator extends eZInputValidator
18 {
24 public function __construct( $rule = null )
25 {
26 $this->RegExpRule = $rule;
27 }
28
29 function setRegExpRule( $rule )
30 {
31 $this->RegExpRule = $rule;
32 }
33
34 function validate( $text )
35 {
36 if ( !is_array( $this->RegExpRule ) )
37 return eZInputValidator::STATE_INVALID;
38 $accepted =& $this->RegExpRule["accepted"];
39 if ( preg_match( $accepted, $text ) )
40 return eZInputValidator::STATE_ACCEPTED;
41 $intermediate =& $this->RegExpRule["intermediate"];
42 if ( preg_match( $intermediate, $text ) )
43 return eZInputValidator::STATE_INTERMEDIATE;
44 return eZInputValidator::STATE_INVALID;
45 }
46
47 function fixup( $text )
48 {
49 if ( !is_array( $this->RegExpRule ) )
50 return $text;
51 $intermediate =& $this->RegExpRule["intermediate"];
52 $fixup =& $this->RegExpRule["fixup"];
53 if ( is_array( $fixup ) )
54 {
55 $intermediate = $fixup["match"];
56 $fixup = $fixup["replace"];
57 }
58 $text = preg_replace( $intermediate, $fixup, $text );
59 return $text;
60 }
61
63 public $RegExpRule;
64 }
65
66 ?>
eZInputValidator
Input text validation and correction.
Definition: ezinputvalidator.php:78
eZInputValidator\STATE_INTERMEDIATE
const STATE_INTERMEDIATE
Definition: ezinputvalidator.php:80
eZInputValidator\STATE_ACCEPTED
const STATE_ACCEPTED
Definition: ezinputvalidator.php:79
eZInputValidator\STATE_INVALID
const STATE_INVALID
Definition: ezinputvalidator.php:81
eZRegExpValidator
Input validation using regexps.
Definition: ezregexpvalidator.php:18
eZRegExpValidator\__construct
__construct( $rule=null)
Definition: ezregexpvalidator.php:24
eZRegExpValidator\fixup
fixup( $text)
Definition: ezregexpvalidator.php:47
eZRegExpValidator\setRegExpRule
setRegExpRule( $rule)
Definition: ezregexpvalidator.php:29
eZRegExpValidator\validate
validate( $text)
Definition: ezregexpvalidator.php:34
eZRegExpValidator\$RegExpRule
$RegExpRule
Definition: ezregexpvalidator.php:63
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.