Ignore:
Timestamp:
2013/08/26 12:42:34 (13 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/Calendar.php

    r20119 r23125  
    11<?php 
    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 // | [email protected] so we can mail you a copy immediately.               | 
    16 // +----------------------------------------------------------------------+ 
    17 // | Authors: Harry Fuecks <[email protected]>                      | 
    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 // 
     2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 
     3 
    234/** 
    24  * @package Calendar 
    25  * @version $Id: Calendar.php,v 1.3 2005/10/22 10:07:11 quipo Exp $ 
     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 <[email protected]> 
     33 * @author    Lorenzo Alberton <[email protected]> 
     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 
    2638 */ 
    2739 
     
    5365 * Calendar_Engines. The engine used can be controlled with the constant 
    5466 * CALENDAR_ENGINE 
    55  * @see Calendar_Engine_Interface 
    56  * @package Calendar 
    57  * @access protected 
     67 * 
     68 * @category  Date and Time 
     69 * @package   Calendar 
     70 * @author    Harry Fuecks <[email protected]> 
     71 * @author    Lorenzo Alberton <[email protected]> 
     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 
    5877 */ 
    5978class Calendar_Engine_Factory 
     
    6180    /** 
    6281     * Returns an instance of the engine 
     82     * 
    6383     * @return object instance of a calendar calculation engine 
    6484     * @access protected 
     
    6888        static $engine = false; 
    6989        switch (CALENDAR_ENGINE) { 
    70             case 'PearDate': 
    71                 $class = 'Calendar_Engine_PearDate'; 
    72                 break; 
    73             case 'UnixTS': 
    74             default: 
    75                 $class = 'Calendar_Engine_UnixTS'; 
     90        case 'PearDate': 
     91            $class = 'Calendar_Engine_PearDate'; 
     92            break; 
     93        case 'UnixTS': 
     94        default: 
     95            $class = 'Calendar_Engine_UnixTS'; 
    7696            break; 
    7797        } 
    7898        if (!$engine) { 
    7999            if (!class_exists($class)) { 
    80                 require_once CALENDAR_ROOT.'Engine'.DIRECTORY_SEPARATOR.CALENDAR_ENGINE.'.php'; 
     100                include_once CALENDAR_ROOT.'Engine'.DIRECTORY_SEPARATOR.CALENDAR_ENGINE.'.php'; 
    81101            } 
    82102            $engine = new $class; 
     
    87107 
    88108/** 
    89  * Base class for Calendar API. This class should not be instantiated 
    90  * directly. 
     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 <[email protected]> 
     114 * @author    Lorenzo Alberton <[email protected]> 
     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 
    91118 * @abstract 
    92  * @package Calendar 
    93119 */ 
    94120class Calendar 
     
    114140     * @var int 
    115141     */ 
    116    var $year; 
     142    var $year; 
    117143 
    118144    /** 
     
    168194    /** 
    169195     * Constructs the Calendar 
    170      * @param int year 
    171      * @param int month 
    172      * @param int day 
    173      * @param int hour 
    174      * @param int minute 
    175      * @param int second 
     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     * 
    176204     * @access protected 
    177205     */ 
     
    182210            $cE = & Calendar_Engine_Factory::getEngine(); 
    183211        } 
    184         $this->cE = & $cE; 
     212        $this->cE     = & $cE; 
    185213        $this->year   = (int)$y; 
    186214        $this->month  = (int)$m; 
     
    194222     * Defines the calendar by a timestamp (Unix or ISO-8601), replacing values 
    195223     * passed to the constructor 
    196      * @param int|string Unix or ISO-8601 timestamp 
     224     * 
     225     * @param int|string $ts Unix or ISO-8601 timestamp 
     226     * 
    197227     * @return void 
    198228     * @access public 
     
    211241     * Returns a timestamp from the current date / time values. Format of 
    212242     * timestamp depends on Calendar_Engine implementation being used 
     243     * 
    213244     * @return int|string timestamp 
    214245     * @access public 
     
    223254    /** 
    224255     * Defines calendar object as selected (e.g. for today) 
    225      * @param boolean state whether Calendar subclass 
     256     * 
     257     * @param boolean $state whether Calendar subclass 
     258     * 
    226259     * @return void 
    227260     * @access public 
     
    234267    /** 
    235268     * True if the calendar subclass object is selected (e.g. today) 
     269     * 
    236270     * @return boolean 
    237271     * @access public 
     
    243277 
    244278    /** 
     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    /** 
    245290     * Adjusts the date (helper method) 
     291     * 
    246292     * @return void 
    247293     * @access public 
     
    249295    function adjust() 
    250296    { 
    251         $stamp = $this->getTimeStamp(); 
     297        $stamp        = $this->getTimeStamp(); 
    252298        $this->year   = $this->cE->stampToYear($stamp); 
    253299        $this->month  = $this->cE->stampToMonth($stamp); 
     
    260306    /** 
    261307     * Returns the date as an associative array (helper method) 
    262      * @param mixed timestamp (leave empty for current timestamp) 
     308     * 
     309     * @param mixed $stamp timestamp (leave empty for current timestamp) 
     310     * 
    263311     * @return array 
    264312     * @access public 
     
    281329    /** 
    282330     * Returns the value as an associative array (helper method) 
    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) 
     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     * 
    287337     * @return mixed 
    288338     * @access private 
     
    291341    { 
    292342        switch (strtolower($format)) { 
    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; 
     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; 
    306356        } 
    307357    } 
     
    310360     * Abstract method for building the children of a calendar object. 
    311361     * Implemented by Calendar subclasses 
    312      * @param array containing Calendar objects to select (optional) 
     362     * 
     363     * @param array $sDates array containing Calendar objects to select (optional) 
     364     * 
    313365     * @return boolean 
    314366     * @access public 
     
    317369    function build($sDates = array()) 
    318370    { 
    319         require_once 'PEAR.php'; 
    320         PEAR::raiseError( 
    321             'Calendar::build is abstract', null, PEAR_ERROR_TRIGGER, 
     371        include_once 'PEAR.php'; 
     372        PEAR::raiseError('Calendar::build is abstract', null, PEAR_ERROR_TRIGGER, 
    322373            E_USER_NOTICE, 'Calendar::build()'); 
    323374        return false; 
     
    326377    /** 
    327378     * Abstract method for selected data objects called from build 
    328      * @param array 
     379     * 
     380     * @param array $sDates array of Calendar objects to select 
     381     * 
    329382     * @return boolean 
    330383     * @access public 
     
    333386    function setSelection($sDates) 
    334387    { 
    335         require_once 'PEAR.php'; 
     388        include_once 'PEAR.php'; 
    336389        PEAR::raiseError( 
    337390            'Calendar::setSelection is abstract', null, PEAR_ERROR_TRIGGER, 
     
    345398     * the collection, returns false and resets the collection for 
    346399     * further iteratations. 
     400     * 
    347401     * @return mixed either an object subclass of Calendar or false 
    348402     * @access public 
     
    361415    /** 
    362416     * Fetches all child from the current collection of children 
     417     * 
    363418     * @return array 
    364419     * @access public 
     
    370425 
    371426    /** 
    372      * Get the number Calendar subclass objects stored in the internal 
    373      * collection. 
     427     * Get the number Calendar subclass objects stored in the internal collection 
     428     * 
    374429     * @return int 
    375430     * @access public 
     
    382437    /** 
    383438     * Determine whether this date is valid, with the bounds determined by 
    384      * the Calendar_Engine. The call is passed on to 
    385      * Calendar_Validator::isValid 
     439     * the Calendar_Engine. The call is passed on to Calendar_Validator::isValid 
     440     * 
    386441     * @return boolean 
    387442     * @access public 
     
    395450    /** 
    396451     * Returns an instance of Calendar_Validator 
     452     * 
    397453     * @return Calendar_Validator 
    398454     * @access public 
     
    401457    { 
    402458        if (!isset($this->validator)) { 
    403             require_once CALENDAR_ROOT.'Validator.php'; 
    404             $this->validator = & new Calendar_Validator($this); 
     459            include_once CALENDAR_ROOT.'Validator.php'; 
     460            $this->validator = new Calendar_Validator($this); 
    405461        } 
    406462        return $this->validator; 
     
    410466     * Returns a reference to the current Calendar_Engine being used. Useful 
    411467     * for Calendar_Table_Helper and Calendar_Validator 
     468     * 
    412469     * @return object implementing Calendar_Engine_Inteface 
    413470     * @access protected 
     
    421478     * Set the CALENDAR_FIRST_DAY_OF_WEEK constant to the $firstDay value 
    422479     * 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 
    423484     * @throws E_USER_WARNING this method throws a WARNING if the 
    424485     *    CALENDAR_FIRST_DAY_OF_WEEK constant is already defined and 
    425486     *    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 
    428487     * @access protected 
    429488     */ 
     
    451510    /** 
    452511     * Returns the value for the previous year 
    453      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     512     * 
     513     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     514     * 
    454515     * @return int e.g. 2002 or timestamp 
    455516     * @access public 
     
    463524    /** 
    464525     * Returns the value for this year 
    465      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     526     * 
     527     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     528     * 
    466529     * @return int e.g. 2003 or timestamp 
    467530     * @access public 
     
    475538    /** 
    476539     * Returns the value for next year 
    477      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     540     * 
     541     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     542     * 
    478543     * @return int e.g. 2004 or timestamp 
    479544     * @access public 
     
    487552    /** 
    488553     * Returns the value for the previous month 
    489      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     554     * 
     555     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     556     * 
    490557     * @return int e.g. 4 or Unix timestamp 
    491558     * @access public 
     
    499566    /** 
    500567     * Returns the value for this month 
    501      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     568     * 
     569     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     570     * 
    502571     * @return int e.g. 5 or timestamp 
    503572     * @access public 
     
    511580    /** 
    512581     * Returns the value for next month 
    513      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     582     * 
     583     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     584     * 
    514585     * @return int e.g. 6 or timestamp 
    515586     * @access public 
     
    523594    /** 
    524595     * Returns the value for the previous day 
    525      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     596     * 
     597     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     598     * 
    526599     * @return int e.g. 10 or timestamp 
    527600     * @access public 
     
    536609    /** 
    537610     * Returns the value for this day 
    538      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     611     * 
     612     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     613     * 
    539614     * @return int e.g. 11 or timestamp 
    540615     * @access public 
     
    549624    /** 
    550625     * Returns the value for the next day 
    551      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     626     * 
     627     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     628     * 
    552629     * @return int e.g. 12 or timestamp 
    553630     * @access public 
     
    562639    /** 
    563640     * Returns the value for the previous hour 
    564      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     641     * 
     642     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     643     * 
    565644     * @return int e.g. 13 or timestamp 
    566645     * @access public 
     
    575654    /** 
    576655     * Returns the value for this hour 
    577      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     656     * 
     657     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     658     * 
    578659     * @return int e.g. 14 or timestamp 
    579660     * @access public 
     
    588669    /** 
    589670     * Returns the value for the next hour 
    590      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     671     * 
     672     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     673     * 
    591674     * @return int e.g. 14 or timestamp 
    592675     * @access public 
     
    601684    /** 
    602685     * Returns the value for the previous minute 
    603      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     686     * 
     687     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     688     * 
    604689     * @return int e.g. 23 or timestamp 
    605690     * @access public 
     
    615700    /** 
    616701     * Returns the value for this minute 
    617      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     702     * 
     703     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     704     * 
    618705     * @return int e.g. 24 or timestamp 
    619706     * @access public 
     
    629716    /** 
    630717    * Returns the value for the next minute 
    631      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     718    * 
     719     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     720     * 
    632721     * @return int e.g. 25 or timestamp 
    633722     * @access public 
     
    643732    /** 
    644733     * Returns the value for the previous second 
    645      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     734     * 
     735     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     736     * 
    646737     * @return int e.g. 43 or timestamp 
    647738     * @access public 
     
    657748    /** 
    658749     * Returns the value for this second 
    659     * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     750     * 
     751    * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     752    * 
    660753     * @return int e.g. 44 or timestamp 
    661754     * @access public 
     
    671764    /** 
    672765     * Returns the value for the next second 
    673      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     766     * 
     767     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     768     * 
    674769     * @return int e.g. 45 or timestamp 
    675770     * @access public 
Note: See TracChangeset for help on using the changeset viewer.