Ignore:
Timestamp:
2013/08/28 13:26:44 (11 years ago)
Author:
m_uehara
Message:

#2275
影響が大きいため、2.13.0では対応を行わない r23125 r23128 r23133 を差し戻します。

File:
1 edited

Legend:

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

    r23125 r23141  
    11<?php 
    2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 
    3  
     2/* 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// |          Lorenzo Alberton <l dot alberton at quipo dot it>           | 
     19// +----------------------------------------------------------------------+ 
     20// 
     21// $Id: Calendar.php,v 1.3 2005/10/22 10:07:11 quipo Exp $ 
     22// 
    423/** 
    5  * Contains the Calendar and Calendar_Engine_Factory classes 
    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  * @author    Lorenzo Alberton <l.alberton@quipo.it> 
    34  * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton 
    35  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    36  * @version   CVS: $Id: Calendar.php 300729 2010-06-24 12:05:53Z quipo $ 
    37  * @link      http://pear.php.net/package/Calendar 
     24 * @package Calendar 
     25 * @version $Id: Calendar.php,v 1.3 2005/10/22 10:07:11 quipo Exp $ 
    3826 */ 
    3927 
     
    6553 * Calendar_Engines. The engine used can be controlled with the constant 
    6654 * CALENDAR_ENGINE 
    67  * 
    68  * @category  Date and Time 
    69  * @package   Calendar 
    70  * @author    Harry Fuecks <hfuecks@phppatterns.com> 
    71  * @author    Lorenzo Alberton <l.alberton@quipo.it> 
    72  * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton 
    73  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    74  * @link      http://pear.php.net/package/Calendar 
    75  * @see       Calendar_Engine_Interface 
    76  * @access    protected 
     55 * @see Calendar_Engine_Interface 
     56 * @package Calendar 
     57 * @access protected 
    7758 */ 
    7859class Calendar_Engine_Factory 
     
    8061    /** 
    8162     * Returns an instance of the engine 
    82      * 
    8363     * @return object instance of a calendar calculation engine 
    8464     * @access protected 
     
    8868        static $engine = false; 
    8969        switch (CALENDAR_ENGINE) { 
    90         case 'PearDate': 
    91             $class = 'Calendar_Engine_PearDate'; 
    92             break; 
    93         case 'UnixTS': 
    94         default: 
    95             $class = 'Calendar_Engine_UnixTS'; 
     70            case 'PearDate': 
     71                $class = 'Calendar_Engine_PearDate'; 
     72                break; 
     73            case 'UnixTS': 
     74            default: 
     75                $class = 'Calendar_Engine_UnixTS'; 
    9676            break; 
    9777        } 
    9878        if (!$engine) { 
    9979            if (!class_exists($class)) { 
    100                 include_once CALENDAR_ROOT.'Engine'.DIRECTORY_SEPARATOR.CALENDAR_ENGINE.'.php'; 
     80                require_once CALENDAR_ROOT.'Engine'.DIRECTORY_SEPARATOR.CALENDAR_ENGINE.'.php'; 
    10181            } 
    10282            $engine = new $class; 
     
    10787 
    10888/** 
    109  * Base class for Calendar API. This class should not be instantiated directly. 
    110  * 
    111  * @category  Date and Time 
    112  * @package   Calendar 
    113  * @author    Harry Fuecks <hfuecks@phppatterns.com> 
    114  * @author    Lorenzo Alberton <l.alberton@quipo.it> 
    115  * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton 
    116  * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
    117  * @link      http://pear.php.net/package/Calendar 
     89 * Base class for Calendar API. This class should not be instantiated 
     90 * directly. 
    11891 * @abstract 
     92 * @package Calendar 
    11993 */ 
    12094class Calendar 
     
    140114     * @var int 
    141115     */ 
    142     var $year; 
     116   var $year; 
    143117 
    144118    /** 
     
    194168    /** 
    195169     * Constructs the Calendar 
    196      * 
    197      * @param int $y year 
    198      * @param int $m month 
    199      * @param int $d day 
    200      * @param int $h hour 
    201      * @param int $i minute 
    202      * @param int $s second 
    203      * 
     170     * @param int year 
     171     * @param int month 
     172     * @param int day 
     173     * @param int hour 
     174     * @param int minute 
     175     * @param int second 
    204176     * @access protected 
    205177     */ 
     
    210182            $cE = & Calendar_Engine_Factory::getEngine(); 
    211183        } 
    212         $this->cE     = & $cE; 
     184        $this->cE = & $cE; 
    213185        $this->year   = (int)$y; 
    214186        $this->month  = (int)$m; 
     
    222194     * Defines the calendar by a timestamp (Unix or ISO-8601), replacing values 
    223195     * passed to the constructor 
    224      * 
    225      * @param int|string $ts Unix or ISO-8601 timestamp 
    226      * 
     196     * @param int|string Unix or ISO-8601 timestamp 
    227197     * @return void 
    228198     * @access public 
     
    241211     * Returns a timestamp from the current date / time values. Format of 
    242212     * timestamp depends on Calendar_Engine implementation being used 
    243      * 
    244213     * @return int|string timestamp 
    245214     * @access public 
     
    254223    /** 
    255224     * Defines calendar object as selected (e.g. for today) 
    256      * 
    257      * @param boolean $state whether Calendar subclass 
    258      * 
     225     * @param boolean state whether Calendar subclass 
    259226     * @return void 
    260227     * @access public 
     
    267234    /** 
    268235     * True if the calendar subclass object is selected (e.g. today) 
    269      * 
    270236     * @return boolean 
    271237     * @access public 
     
    277243 
    278244    /** 
    279      * Checks if the current Calendar object is today's date 
    280      * 
    281      * @return boolean 
    282      * @access public 
    283      */ 
    284     function isToday() 
    285     { 
    286         return $this->cE->isToday($this->getTimeStamp()); 
    287     } 
    288  
    289     /** 
    290245     * Adjusts the date (helper method) 
    291      * 
    292246     * @return void 
    293247     * @access public 
     
    295249    function adjust() 
    296250    { 
    297         $stamp        = $this->getTimeStamp(); 
     251        $stamp = $this->getTimeStamp(); 
    298252        $this->year   = $this->cE->stampToYear($stamp); 
    299253        $this->month  = $this->cE->stampToMonth($stamp); 
     
    306260    /** 
    307261     * Returns the date as an associative array (helper method) 
    308      * 
    309      * @param mixed $stamp timestamp (leave empty for current timestamp) 
    310      * 
     262     * @param mixed timestamp (leave empty for current timestamp) 
    311263     * @return array 
    312264     * @access public 
     
    329281    /** 
    330282     * Returns the value as an associative array (helper method) 
    331      * 
    332      * @param string $returnType type of date object that return value represents 
    333      * @param string $format     ['int' | 'array' | 'timestamp' | 'object'] 
    334      * @param mixed  $stamp      timestamp (depending on Calendar engine being used) 
    335      * @param int    $default    default value (i.e. give me the answer quick) 
    336      * 
     283     * @param string type of date object that return value represents 
     284     * @param string $format ['int' | 'array' | 'timestamp' | 'object'] 
     285     * @param mixed timestamp (depending on Calendar engine being used) 
     286     * @param int integer default value (i.e. give me the answer quick) 
    337287     * @return mixed 
    338288     * @access private 
     
    341291    { 
    342292        switch (strtolower($format)) { 
    343         case 'int': 
    344             return $default; 
    345         case 'array': 
    346             return $this->toArray($stamp); 
    347             break; 
    348         case 'object': 
    349             include_once CALENDAR_ROOT.'Factory.php'; 
    350             return Calendar_Factory::createByTimestamp($returnType, $stamp); 
    351             break; 
    352         case 'timestamp': 
    353         default: 
    354             return $stamp; 
    355             break; 
     293            case 'int': 
     294                return $default; 
     295            case 'array': 
     296                return $this->toArray($stamp); 
     297                break; 
     298            case 'object': 
     299                require_once CALENDAR_ROOT.'Factory.php'; 
     300                return Calendar_Factory::createByTimestamp($returnType,$stamp); 
     301                break; 
     302            case 'timestamp': 
     303            default: 
     304                return $stamp; 
     305                break; 
    356306        } 
    357307    } 
     
    360310     * Abstract method for building the children of a calendar object. 
    361311     * Implemented by Calendar subclasses 
    362      * 
    363      * @param array $sDates array containing Calendar objects to select (optional) 
    364      * 
     312     * @param array containing Calendar objects to select (optional) 
    365313     * @return boolean 
    366314     * @access public 
     
    369317    function build($sDates = array()) 
    370318    { 
    371         include_once 'PEAR.php'; 
    372         PEAR::raiseError('Calendar::build is abstract', null, PEAR_ERROR_TRIGGER, 
     319        require_once 'PEAR.php'; 
     320        PEAR::raiseError( 
     321            'Calendar::build is abstract', null, PEAR_ERROR_TRIGGER, 
    373322            E_USER_NOTICE, 'Calendar::build()'); 
    374323        return false; 
     
    377326    /** 
    378327     * Abstract method for selected data objects called from build 
    379      * 
    380      * @param array $sDates array of Calendar objects to select 
    381      * 
     328     * @param array 
    382329     * @return boolean 
    383330     * @access public 
     
    386333    function setSelection($sDates) 
    387334    { 
    388         include_once 'PEAR.php'; 
     335        require_once 'PEAR.php'; 
    389336        PEAR::raiseError( 
    390337            'Calendar::setSelection is abstract', null, PEAR_ERROR_TRIGGER, 
     
    398345     * the collection, returns false and resets the collection for 
    399346     * further iteratations. 
    400      * 
    401347     * @return mixed either an object subclass of Calendar or false 
    402348     * @access public 
     
    415361    /** 
    416362     * Fetches all child from the current collection of children 
    417      * 
    418363     * @return array 
    419364     * @access public 
     
    425370 
    426371    /** 
    427      * Get the number Calendar subclass objects stored in the internal collection 
    428      * 
     372     * Get the number Calendar subclass objects stored in the internal 
     373     * collection. 
    429374     * @return int 
    430375     * @access public 
     
    437382    /** 
    438383     * Determine whether this date is valid, with the bounds determined by 
    439      * the Calendar_Engine. The call is passed on to Calendar_Validator::isValid 
    440      * 
     384     * the Calendar_Engine. The call is passed on to 
     385     * Calendar_Validator::isValid 
    441386     * @return boolean 
    442387     * @access public 
     
    450395    /** 
    451396     * Returns an instance of Calendar_Validator 
    452      * 
    453397     * @return Calendar_Validator 
    454398     * @access public 
     
    457401    { 
    458402        if (!isset($this->validator)) { 
    459             include_once CALENDAR_ROOT.'Validator.php'; 
    460             $this->validator = new Calendar_Validator($this); 
     403            require_once CALENDAR_ROOT.'Validator.php'; 
     404            $this->validator = & new Calendar_Validator($this); 
    461405        } 
    462406        return $this->validator; 
     
    466410     * Returns a reference to the current Calendar_Engine being used. Useful 
    467411     * for Calendar_Table_Helper and Calendar_Validator 
    468      * 
    469412     * @return object implementing Calendar_Engine_Inteface 
    470413     * @access protected 
     
    478421     * Set the CALENDAR_FIRST_DAY_OF_WEEK constant to the $firstDay value 
    479422     * if the constant is not set yet. 
    480      * 
    481      * @param integer $firstDay first day of the week (0=sunday, 1=monday, ...) 
    482      * 
    483      * @return integer 
    484423     * @throws E_USER_WARNING this method throws a WARNING if the 
    485424     *    CALENDAR_FIRST_DAY_OF_WEEK constant is already defined and 
    486425     *    the $firstDay parameter is set to a different value 
     426     * @param integer $firstDay first day of the week (0=sunday, 1=monday, ...) 
     427     * @return integer 
    487428     * @access protected 
    488429     */ 
     
    510451    /** 
    511452     * Returns the value for the previous year 
    512      * 
    513      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    514      * 
     453     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    515454     * @return int e.g. 2002 or timestamp 
    516455     * @access public 
     
    524463    /** 
    525464     * Returns the value for this year 
    526      * 
    527      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    528      * 
     465     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    529466     * @return int e.g. 2003 or timestamp 
    530467     * @access public 
     
    538475    /** 
    539476     * Returns the value for next year 
    540      * 
    541      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    542      * 
     477     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    543478     * @return int e.g. 2004 or timestamp 
    544479     * @access public 
     
    552487    /** 
    553488     * Returns the value for the previous month 
    554      * 
    555      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    556      * 
     489     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    557490     * @return int e.g. 4 or Unix timestamp 
    558491     * @access public 
     
    566499    /** 
    567500     * Returns the value for this month 
    568      * 
    569      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    570      * 
     501     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    571502     * @return int e.g. 5 or timestamp 
    572503     * @access public 
     
    580511    /** 
    581512     * Returns the value for next month 
    582      * 
    583      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    584      * 
     513     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    585514     * @return int e.g. 6 or timestamp 
    586515     * @access public 
     
    594523    /** 
    595524     * Returns the value for the previous day 
    596      * 
    597      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    598      * 
     525     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    599526     * @return int e.g. 10 or timestamp 
    600527     * @access public 
     
    609536    /** 
    610537     * Returns the value for this day 
    611      * 
    612      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    613      * 
     538     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    614539     * @return int e.g. 11 or timestamp 
    615540     * @access public 
     
    624549    /** 
    625550     * Returns the value for the next day 
    626      * 
    627      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    628      * 
     551     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    629552     * @return int e.g. 12 or timestamp 
    630553     * @access public 
     
    639562    /** 
    640563     * Returns the value for the previous hour 
    641      * 
    642      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    643      * 
     564     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    644565     * @return int e.g. 13 or timestamp 
    645566     * @access public 
     
    654575    /** 
    655576     * Returns the value for this hour 
    656      * 
    657      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    658      * 
     577     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    659578     * @return int e.g. 14 or timestamp 
    660579     * @access public 
     
    669588    /** 
    670589     * Returns the value for the next hour 
    671      * 
    672      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    673      * 
     590     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    674591     * @return int e.g. 14 or timestamp 
    675592     * @access public 
     
    684601    /** 
    685602     * Returns the value for the previous minute 
    686      * 
    687      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    688      * 
     603     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    689604     * @return int e.g. 23 or timestamp 
    690605     * @access public 
     
    700615    /** 
    701616     * Returns the value for this minute 
    702      * 
    703      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    704      * 
     617     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    705618     * @return int e.g. 24 or timestamp 
    706619     * @access public 
     
    716629    /** 
    717630    * Returns the value for the next minute 
    718     * 
    719      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    720      * 
     631     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    721632     * @return int e.g. 25 or timestamp 
    722633     * @access public 
     
    732643    /** 
    733644     * Returns the value for the previous second 
    734      * 
    735      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    736      * 
     645     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    737646     * @return int e.g. 43 or timestamp 
    738647     * @access public 
     
    748657    /** 
    749658     * Returns the value for this second 
    750      * 
    751     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    752     * 
     659    * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    753660     * @return int e.g. 44 or timestamp 
    754661     * @access public 
     
    764671    /** 
    765672     * Returns the value for the next second 
    766      * 
    767      * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
    768      * 
     673     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
    769674     * @return int e.g. 45 or timestamp 
    770675     * @access public 
Note: See TracChangeset for help on using the changeset viewer.