[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/ezutils/classes/ -> ezregexpvalidator.php (source)

   1  <?php
   2  //
   3  // Definition of eZRegExpValidator class
   4  //
   5  // Created on: <08-Jul-2002 16:17:15 amos>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*! \file ezregexpvalidator.php
  30  */
  31  
  32  /*!
  33    \class eZRegExpValidator ezregexpvalidator.php
  34    \brief Input validation using regexps
  35  
  36  */
  37  
  38  include_once ( "lib/ezutils/classes/ezinputvalidator.php" );
  39  
  40  class eZRegExpValidator extends eZInputValidator
  41  {
  42      /*!
  43      */
  44      function eZRegExpValidator( $rule = null )
  45      {
  46          $this->eZInputValidator();
  47          $this->RegExpRule = $rule;
  48      }
  49  
  50      function setRegExpRule( $rule )
  51      {
  52          $this->RegExpRule = $rule;
  53      }
  54  
  55      function validate( $text )
  56      {
  57          if ( !is_array( $this->RegExpRule ) )
  58              return EZ_INPUT_VALIDATOR_STATE_INVALID;
  59          $accepted =& $this->RegExpRule["accepted"];
  60          if ( preg_match( $accepted, $text ) )
  61              return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
  62          $intermediate =& $this->RegExpRule["intermediate"];
  63          if ( preg_match( $intermediate, $text ) )
  64              return EZ_INPUT_VALIDATOR_STATE_INTERMEDIATE;
  65          return EZ_INPUT_VALIDATOR_STATE_INVALID;
  66      }
  67  
  68      function &fixup( $text )
  69      {
  70          if ( !is_array( $this->RegExpRule ) )
  71              return $text;
  72          $intermediate =& $this->RegExpRule["intermediate"];
  73          $fixup =& $this->RegExpRule["fixup"];
  74          if ( is_array( $fixup ) )
  75          {
  76              $intermediate =& $fixup["match"];
  77              $fixup =& $fixup["replace"];
  78          }
  79          $text = preg_replace( $intermediate, $fixup, $text );
  80          return $text;
  81      }
  82  
  83      /// \privatesection
  84      var $RegExpRule;
  85  }
  86  
  87  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7