Ignore:
Timestamp:
2013/08/28 13:55:43 (7 years ago)
Author:
m_uehara
Message:

#2348 r23140 をマージ

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13_0/data/module/Calendar/Validator.php

    r23126 r23143  
    11<?php 
    22/* vim: set expandtab tabstop=4 shiftwidth=4: */ 
    3  
     3// 
     4// +----------------------------------------------------------------------+ 
     5// | PHP Version 4                                                        | 
     6// +----------------------------------------------------------------------+ 
     7// | Copyright (c) 1997-2002 The PHP Group                                | 
     8// +----------------------------------------------------------------------+ 
     9// | This source file is subject to version 2.02 of the PHP license,      | 
     10// | that is bundled with this package in the file LICENSE, and is        | 
     11// | available at through the world-wide-web at                           | 
     12// | http://www.php.net/license/3_0.txt.                                  | 
     13// | If you did not receive a copy of the PHP license and are unable to   | 
     14// | obtain it through the world-wide-web, please send a note to          | 
     15// | license@php.net so we can mail you a copy immediately.               | 
     16// +----------------------------------------------------------------------+ 
     17// | Authors: Harry Fuecks <hfuecks@phppatterns.com>                      | 
     18// +----------------------------------------------------------------------+ 
     19// 
     20// $Id: Validator.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ 
     21// 
    422/** 
    5  * Contains the Calendar_Validator class 
    6  * 
    7  * PHP versions 4 and 5 
    8  * 
    9  * LICENSE: Redistribution and use in source and binary forms, with or without 
    10  * modification, are permitted provided that the following conditions are met: 
    11  * 1. Redistributions of source code must retain the above copyright 
    12  *    notice, this list of conditions and the following disclaimer. 
    13  * 2. Redistributions in binary form must reproduce the above copyright 
    14  *    notice, this list of conditions and the following disclaimer in the 
    15  *    documentation and/or other materials provided with the distribution. 
    16  * 3. The name of the author may not be used to endorse or promote products 
    17  *    derived from this software without specific prior written permission. 
    18  * 
    19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 
    20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
    21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
    22  * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY 
    23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
    24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
    25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
    26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    29  * 
    30  * @category  Date and Time 
    31  * @package   Calendar 
    32  * @author    Harry Fuecks <hfuecks@phppatterns.com> 
    33  * @copyright 2003-2007 Harry Fuecks 
    34  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    35  * @version   CVS: $Id: Validator.php 247251 2007-11-28 19:42:33Z quipo $ 
    36  * @link      http://pear.php.net/package/Calendar 
     23 * @package Calendar 
     24 * @version $Id: Validator.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ 
    3725 */ 
    3826 
     
    5038 * Used to validate any given Calendar date object. Instances of this class 
    5139 * can be obtained from any data object using the getValidator method 
    52  * 
    53  * @category  Date and Time 
    54  * @package   Calendar 
    55  * @author    Harry Fuecks <hfuecks@phppatterns.com> 
    56  * @copyright 2003-2007 Harry Fuecks 
    57  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    58  * @link      http://pear.php.net/package/Calendar 
    59  * @see       Calendar::getValidator() 
    60  * @access    public 
     40 * @see Calendar::getValidator() 
     41 * @package Calendar 
     42 * @access public 
    6143 */ 
    6244class Calendar_Validator 
     
    8567    /** 
    8668     * Constructs Calendar_Validator 
    87      * 
    88      * @param object &$calendar subclass of Calendar 
    89      * 
    90      * @access public 
    91      */ 
    92     function Calendar_Validator(&$calendar) 
     69     * @param object subclass of Calendar 
     70     * @access public 
     71     */ 
     72    function Calendar_Validator(& $calendar) 
    9373    { 
    9474        $this->calendar = & $calendar; 
    95         $this->cE       = & $calendar->getEngine(); 
     75        $this->cE = & $calendar->getEngine(); 
    9676    } 
    9777 
    9878    /** 
    9979     * Calls all the other isValidXXX() methods in the validator 
    100      * 
    10180     * @return boolean 
    10281     * @access public 
     
    10685        $checks = array('isValidYear', 'isValidMonth', 'isValidDay', 
    10786            'isValidHour', 'isValidMinute', 'isValidSecond'); 
    108         $valid  = true; 
     87        $valid = true; 
    10988        foreach ($checks as $check) { 
    11089            if (!$this->{$check}()) { 
     
    11796    /** 
    11897     * Check whether this is a valid year 
    119      * 
    12098     * @return boolean 
    12199     * @access public 
     
    123101    function isValidYear() 
    124102    { 
    125         $y   = $this->calendar->thisYear(); 
     103        $y = $this->calendar->thisYear(); 
    126104        $min = $this->cE->getMinYears(); 
    127105        if ($min > $y) { 
    128             $this->errors[] = new Calendar_Validation_Error( 
     106           $this->errors[] = new Calendar_Validation_Error( 
    129107                'Year', $y, CALENDAR_VALUE_TOOSMALL.$min); 
    130108            return false; 
     
    141119    /** 
    142120     * Check whether this is a valid month 
    143      * 
    144121     * @return boolean 
    145122     * @access public 
     
    147124    function isValidMonth() 
    148125    { 
    149         $m   = $this->calendar->thisMonth(); 
     126        $m = $this->calendar->thisMonth(); 
    150127        $min = 1; 
    151128        if ($min > $m) { 
     
    165142    /** 
    166143     * Check whether this is a valid day 
    167      * 
    168144     * @return boolean 
    169145     * @access public 
     
    171147    function isValidDay() 
    172148    { 
    173         $d   = $this->calendar->thisDay(); 
     149        $d = $this->calendar->thisDay(); 
    174150        $min = 1; 
    175151        if ($min > $d) { 
     
    179155        } 
    180156        $max = $this->cE->getDaysInMonth( 
    181             $this->calendar->thisYear(),  
    182             $this->calendar->thisMonth() 
    183         ); 
     157            $this->calendar->thisYear(), $this->calendar->thisMonth()); 
    184158        if ($d > $max) { 
    185159            $this->errors[] = new Calendar_Validation_Error( 
     
    192166    /** 
    193167     * Check whether this is a valid hour 
    194      * 
    195168     * @return boolean 
    196169     * @access public 
     
    198171    function isValidHour() 
    199172    { 
    200         $h   = $this->calendar->thisHour(); 
     173        $h = $this->calendar->thisHour(); 
    201174        $min = 0; 
    202175        if ($min > $h) { 
     
    216189    /** 
    217190     * Check whether this is a valid minute 
    218      * 
    219191     * @return boolean 
    220192     * @access public 
     
    222194    function isValidMinute() 
    223195    { 
    224         $i   = $this->calendar->thisMinute(); 
     196        $i = $this->calendar->thisMinute(); 
    225197        $min = 0; 
    226198        if ($min > $i) { 
     
    240212    /** 
    241213     * Check whether this is a valid second 
    242      * 
    243214     * @return boolean 
    244215     * @access public 
     
    246217    function isValidSecond() 
    247218    { 
    248         $s   = $this->calendar->thisSecond(); 
     219        $s = $this->calendar->thisSecond(); 
    249220        $min = 0; 
    250221        if ($min > $s) { 
     
    264235    /** 
    265236     * Iterates over any validation errors 
    266      * 
    267237     * @return mixed either Calendar_Validation_Error or false 
    268238     * @access public 
     
    270240    function fetch() 
    271241    { 
    272         $error = each($this->errors); 
     242        $error = each ($this->errors); 
    273243        if ($error) { 
    274244            return $error['value']; 
     
    282252/** 
    283253 * For Validation Error messages 
    284  * 
    285  * @category  Date and Time 
    286  * @package   Calendar 
    287  * @author    Harry Fuecks <hfuecks@phppatterns.com> 
    288  * @copyright 2003-2007 Harry Fuecks 
    289  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    290  * @link      http://pear.php.net/package/Calendar 
    291  * @see       Calendar::fetch() 
    292  * @access    public 
     254 * @see Calendar::fetch() 
     255 * @package Calendar 
     256 * @access public 
    293257 */ 
    294258class Calendar_Validation_Error 
     
    317281    /** 
    318282     * Constructs Calendar_Validation_Error 
    319      * 
    320      * @param string $unit    Date unit (e.g. month,hour,second) 
    321      * @param int    $value   Value of unit which failed test 
    322      * @param string $message Validation error message 
    323      * 
     283     * @param string Date unit (e.g. month,hour,second) 
     284     * @param int Value of unit which failed test 
     285     * @param string Validation error message 
    324286     * @access protected 
    325287     */ 
    326     function Calendar_Validation_Error($unit, $value, $message) 
     288    function Calendar_Validation_Error($unit,$value,$message) 
    327289    { 
    328290        $this->unit    = $unit; 
     
    333295    /** 
    334296     * Returns the Date unit 
    335      * 
    336297     * @return string 
    337298     * @access public 
     
    344305    /** 
    345306     * Returns the value of the unit 
    346      * 
    347307     * @return int 
    348308     * @access public 
     
    355315    /** 
    356316     * Returns the validation error message 
    357      * 
    358317     * @return string 
    359318     * @access public 
     
    366325    /** 
    367326     * Returns a string containing the unit, value and error message 
    368      * 
    369327     * @return string 
    370328     * @access public 
Note: See TracChangeset for help on using the changeset viewer.