[ 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/ -> ezdatetimevalidator.php (source)

   1  <?php
   2  //
   3  // Definition of eZDateTimeValidator class
   4  //
   5  //
   6  // SOFTWARE NAME: eZ publish
   7  // SOFTWARE RELEASE: 3.9.0
   8  // BUILD VERSION: 17785
   9  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  10  // SOFTWARE LICENSE: GNU General Public License v2.0
  11  // NOTICE: >
  12  //   This program is free software; you can redistribute it and/or
  13  //   modify it under the terms of version 2.0  of the GNU General
  14  //   Public License as published by the Free Software Foundation.
  15  //
  16  //   This program is distributed in the hope that it will be useful,
  17  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  18  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19  //   GNU General Public License for more details.
  20  //
  21  //   You should have received a copy of version 2.0 of the GNU General
  22  //   Public License along with this program; if not, write to the Free
  23  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  24  //   MA 02110-1301, USA.
  25  //
  26  //
  27  
  28  /*! \file ezdatetimevalidator.php
  29  */
  30  
  31  /*!
  32    \class eZDateTimeValidator ezdatetimevalidator.php
  33    \brief The class eZDateTimeValidator does
  34  
  35  */
  36  
  37  include_once ( 'lib/ezutils/classes/ezinputvalidator.php' );
  38  
  39  class eZDateTimeValidator extends eZInputValidator
  40  {
  41      /*!
  42       Constructor
  43      */
  44      function eZDateTimeValidator()
  45      {
  46      }
  47  
  48      function validateDate( $day, $month, $year )
  49      {
  50          $check = checkdate( $month, $day, $year );
  51          $datetime = mktime( 0, 0, 0, $month, $day, $year );
  52          if ( !$check or
  53               $year < 1970 or
  54               $datetime === false )
  55          {
  56              return EZ_INPUT_VALIDATOR_STATE_INVALID;
  57          }
  58          return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
  59      }
  60  
  61      function validateTime( $hour, $minute )
  62      {
  63          if( preg_match( '/\d+/', trim( $hour )   ) &&
  64              preg_match( '/\d+/', trim( $minute ) ) &&
  65              $hour >= 0 && $minute >= 0 &&
  66              $hour < 24 && $minute < 60 )
  67          {
  68              return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
  69          }
  70          return EZ_INPUT_VALIDATOR_STATE_INVALID;
  71      }
  72  
  73      function validateDateTime( $day, $month, $year, $hour, $minute )
  74      {
  75          $check = checkdate( $month, $day, $year );
  76          $datetime = mktime( $hour, $minute, 0, $month, $day, $year );
  77          if ( !$check or
  78               $year < 1970 or
  79               $datetime === false or
  80               eZDateTimeValidator::validateTime( $hour, $minute ) == EZ_INPUT_VALIDATOR_STATE_INVALID )
  81          {
  82              return EZ_INPUT_VALIDATOR_STATE_INVALID;
  83          }
  84          return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
  85      }
  86  
  87      /// \privatesection
  88  }
  89  
  90  ?>


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