Ignore:
Timestamp:
2013/08/26 12:42:34 (11 years ago)
Author:
kimoto
Message:

#2275 PEAR更新
不要なrequire_onceの削除
レガシーなPEARモジュールは使わない
SearchReplace?.phpのパスが間違っているので修正

File:
1 edited

Legend:

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

    r20119 r23125  
    11<?php 
    22/* vim: set expandtab tabstop=4 shiftwidth=4: */ 
    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 // 
     3 
    224/** 
    23  * @package Calendar 
    24  * @version $Id: Validator.php,v 1.1 2004/05/24 22:25:42 quipo Exp $ 
     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 
    2537 */ 
    2638 
     
    3850 * Used to validate any given Calendar date object. Instances of this class 
    3951 * can be obtained from any data object using the getValidator method 
    40  * @see Calendar::getValidator() 
    41  * @package Calendar 
    42  * @access public 
     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 
    4361 */ 
    4462class Calendar_Validator 
     
    6785    /** 
    6886     * Constructs Calendar_Validator 
    69      * @param object subclass of Calendar 
    70      * @access public 
    71      */ 
    72     function Calendar_Validator(& $calendar) 
     87     * 
     88     * @param object &$calendar subclass of Calendar 
     89     * 
     90     * @access public 
     91     */ 
     92    function Calendar_Validator(&$calendar) 
    7393    { 
    7494        $this->calendar = & $calendar; 
    75         $this->cE = & $calendar->getEngine(); 
     95        $this->cE       = & $calendar->getEngine(); 
    7696    } 
    7797 
    7898    /** 
    7999     * Calls all the other isValidXXX() methods in the validator 
     100     * 
    80101     * @return boolean 
    81102     * @access public 
     
    85106        $checks = array('isValidYear', 'isValidMonth', 'isValidDay', 
    86107            'isValidHour', 'isValidMinute', 'isValidSecond'); 
    87         $valid = true; 
     108        $valid  = true; 
    88109        foreach ($checks as $check) { 
    89110            if (!$this->{$check}()) { 
     
    96117    /** 
    97118     * Check whether this is a valid year 
     119     * 
    98120     * @return boolean 
    99121     * @access public 
     
    101123    function isValidYear() 
    102124    { 
    103         $y = $this->calendar->thisYear(); 
     125        $y   = $this->calendar->thisYear(); 
    104126        $min = $this->cE->getMinYears(); 
    105127        if ($min > $y) { 
    106            $this->errors[] = new Calendar_Validation_Error( 
     128            $this->errors[] = new Calendar_Validation_Error( 
    107129                'Year', $y, CALENDAR_VALUE_TOOSMALL.$min); 
    108130            return false; 
     
    119141    /** 
    120142     * Check whether this is a valid month 
     143     * 
    121144     * @return boolean 
    122145     * @access public 
     
    124147    function isValidMonth() 
    125148    { 
    126         $m = $this->calendar->thisMonth(); 
     149        $m   = $this->calendar->thisMonth(); 
    127150        $min = 1; 
    128151        if ($min > $m) { 
     
    142165    /** 
    143166     * Check whether this is a valid day 
     167     * 
    144168     * @return boolean 
    145169     * @access public 
     
    147171    function isValidDay() 
    148172    { 
    149         $d = $this->calendar->thisDay(); 
     173        $d   = $this->calendar->thisDay(); 
    150174        $min = 1; 
    151175        if ($min > $d) { 
     
    155179        } 
    156180        $max = $this->cE->getDaysInMonth( 
    157             $this->calendar->thisYear(), $this->calendar->thisMonth()); 
     181            $this->calendar->thisYear(),  
     182            $this->calendar->thisMonth() 
     183        ); 
    158184        if ($d > $max) { 
    159185            $this->errors[] = new Calendar_Validation_Error( 
     
    166192    /** 
    167193     * Check whether this is a valid hour 
     194     * 
    168195     * @return boolean 
    169196     * @access public 
     
    171198    function isValidHour() 
    172199    { 
    173         $h = $this->calendar->thisHour(); 
     200        $h   = $this->calendar->thisHour(); 
    174201        $min = 0; 
    175202        if ($min > $h) { 
     
    189216    /** 
    190217     * Check whether this is a valid minute 
     218     * 
    191219     * @return boolean 
    192220     * @access public 
     
    194222    function isValidMinute() 
    195223    { 
    196         $i = $this->calendar->thisMinute(); 
     224        $i   = $this->calendar->thisMinute(); 
    197225        $min = 0; 
    198226        if ($min > $i) { 
     
    212240    /** 
    213241     * Check whether this is a valid second 
     242     * 
    214243     * @return boolean 
    215244     * @access public 
     
    217246    function isValidSecond() 
    218247    { 
    219         $s = $this->calendar->thisSecond(); 
     248        $s   = $this->calendar->thisSecond(); 
    220249        $min = 0; 
    221250        if ($min > $s) { 
     
    235264    /** 
    236265     * Iterates over any validation errors 
     266     * 
    237267     * @return mixed either Calendar_Validation_Error or false 
    238268     * @access public 
     
    240270    function fetch() 
    241271    { 
    242         $error = each ($this->errors); 
     272        $error = each($this->errors); 
    243273        if ($error) { 
    244274            return $error['value']; 
     
    252282/** 
    253283 * For Validation Error messages 
    254  * @see Calendar::fetch() 
    255  * @package Calendar 
    256  * @access public 
     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 
    257293 */ 
    258294class Calendar_Validation_Error 
     
    281317    /** 
    282318     * Constructs Calendar_Validation_Error 
    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 
     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     * 
    286324     * @access protected 
    287325     */ 
    288     function Calendar_Validation_Error($unit,$value,$message) 
     326    function Calendar_Validation_Error($unit, $value, $message) 
    289327    { 
    290328        $this->unit    = $unit; 
     
    295333    /** 
    296334     * Returns the Date unit 
     335     * 
    297336     * @return string 
    298337     * @access public 
     
    305344    /** 
    306345     * Returns the value of the unit 
     346     * 
    307347     * @return int 
    308348     * @access public 
     
    315355    /** 
    316356     * Returns the validation error message 
     357     * 
    317358     * @return string 
    318359     * @access public 
     
    325366    /** 
    326367     * Returns a string containing the unit, value and error message 
     368     * 
    327369     * @return string 
    328370     * @access public 
Note: See TracChangeset for help on using the changeset viewer.