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/Factory.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// |          Lorenzo Alberton <l dot alberton at quipo dot it>           | 
     19// +----------------------------------------------------------------------+ 
     20// 
     21// $Id: Factory.php,v 1.3 2005/10/22 10:08:47 quipo Exp $ 
     22// 
    423/** 
    5  * Contains the Calendar_Factory 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  * @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: Factory.php 246404 2007-11-18 21:46:43Z quipo $ 
    37  * @link      http://pear.php.net/package/Calendar 
     24 * @package Calendar 
     25 * @version $Id: Factory.php,v 1.3 2005/10/22 10:08:47 quipo Exp $ 
    3826 */ 
    3927 
     
    6553 * Use the constract CALENDAR_FIRST_DAY_OF_WEEK to control the first day of the week 
    6654 * for Month or Week objects (e.g. 0 = Sunday, 6 = Saturday) 
    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 
     55 * @package Calendar 
    7556 * @access protected 
    7657 */ 
     
    7960    /** 
    8061     * Creates a calendar object given the type and units 
    81      * 
    82      * @param string $type class of calendar object to create 
    83      * @param int    $y    year 
    84      * @param int    $m    month 
    85      * @param int    $d    day 
    86      * @param int    $h    hour 
    87      * @param int    $i    minute 
    88      * @param int    $s    second 
    89      * 
     62     * @param string class of calendar object to create 
     63     * @param int year 
     64     * @param int month 
     65     * @param int day 
     66     * @param int hour 
     67     * @param int minute 
     68     * @param int second 
    9069     * @return object subclass of Calendar 
    9170     * @access public 
     
    9675        $firstDay = defined('CALENDAR_FIRST_DAY_OF_WEEK') ? CALENDAR_FIRST_DAY_OF_WEEK : 1; 
    9776        switch ($type) { 
    98         case 'Day': 
    99             include_once CALENDAR_ROOT.'Day.php'; 
    100             return new Calendar_Day($y, $m, $d); 
    101         case 'Month': 
    102             // Set default state for which month type to build 
    103             if (!defined('CALENDAR_MONTH_STATE')) { 
    104                 define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH); 
    105             } 
    106             switch (CALENDAR_MONTH_STATE) { 
    107             case CALENDAR_USE_MONTH_WEEKDAYS: 
    108                 include_once CALENDAR_ROOT.'Month/Weekdays.php'; 
    109                 $class = 'Calendar_Month_Weekdays'; 
    110                 break; 
    111             case CALENDAR_USE_MONTH_WEEKS: 
    112                 include_once CALENDAR_ROOT.'Month/Weeks.php'; 
    113                 $class = 'Calendar_Month_Weeks'; 
    114                 break; 
    115             case CALENDAR_USE_MONTH: 
     77            case 'Day': 
     78                require_once CALENDAR_ROOT.'Day.php'; 
     79                return new Calendar_Day($y,$m,$d); 
     80            case 'Month': 
     81                // Set default state for which month type to build 
     82                if (!defined('CALENDAR_MONTH_STATE')) { 
     83                    define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH); 
     84                } 
     85                switch (CALENDAR_MONTH_STATE) { 
     86                    case CALENDAR_USE_MONTH_WEEKDAYS: 
     87                        require_once CALENDAR_ROOT.'Month/Weekdays.php'; 
     88                        $class = 'Calendar_Month_Weekdays'; 
     89                        break; 
     90                    case CALENDAR_USE_MONTH_WEEKS: 
     91                        require_once CALENDAR_ROOT.'Month/Weeks.php'; 
     92                        $class = 'Calendar_Month_Weeks'; 
     93                        break; 
     94                    case CALENDAR_USE_MONTH: 
     95                    default: 
     96                        require_once CALENDAR_ROOT.'Month.php'; 
     97                        $class = 'Calendar_Month'; 
     98                        break; 
     99                } 
     100                return new $class($y, $m, $firstDay); 
     101            case 'Week': 
     102                require_once CALENDAR_ROOT.'Week.php'; 
     103                return new Calendar_Week($y, $m, $d, $firstDay); 
     104            case 'Hour': 
     105                require_once CALENDAR_ROOT.'Hour.php'; 
     106                return new Calendar_Hour($y, $m, $d, $h); 
     107            case 'Minute': 
     108                require_once CALENDAR_ROOT.'Minute.php'; 
     109                return new Calendar_Minute($y, $m, $d, $h, $i); 
     110            case 'Second': 
     111                require_once CALENDAR_ROOT.'Second.php'; 
     112                return new Calendar_Second($y,$m,$d,$h,$i,$s); 
     113            case 'Year': 
     114                require_once CALENDAR_ROOT.'Year.php'; 
     115                return new Calendar_Year($y); 
    116116            default: 
    117                 include_once CALENDAR_ROOT.'Month.php'; 
    118                 $class = 'Calendar_Month'; 
    119                 break; 
    120             } 
    121             return new $class($y, $m, $firstDay); 
    122         case 'Week': 
    123             include_once CALENDAR_ROOT.'Week.php'; 
    124             return new Calendar_Week($y, $m, $d, $firstDay); 
    125         case 'Hour': 
    126             include_once CALENDAR_ROOT.'Hour.php'; 
    127             return new Calendar_Hour($y, $m, $d, $h); 
    128         case 'Minute': 
    129             include_once CALENDAR_ROOT.'Minute.php'; 
    130             return new Calendar_Minute($y, $m, $d, $h, $i); 
    131         case 'Second': 
    132             include_once CALENDAR_ROOT.'Second.php'; 
    133             return new Calendar_Second($y, $m, $d, $h, $i, $s); 
    134         case 'Year': 
    135             include_once CALENDAR_ROOT.'Year.php'; 
    136             return new Calendar_Year($y); 
    137         default: 
    138             include_once 'PEAR.php'; 
    139             PEAR::raiseError('Calendar_Factory::create() unrecognised type: '.$type, 
    140                 null, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar_Factory::create()'); 
    141             return false; 
     117                require_once 'PEAR.php'; 
     118                PEAR::raiseError( 
     119                    'Calendar_Factory::create() unrecognised type: '.$type, null, PEAR_ERROR_TRIGGER, 
     120                    E_USER_NOTICE, 'Calendar_Factory::create()'); 
     121                return false; 
    142122        } 
    143123    } 
    144  
    145124    /** 
    146125     * Creates an instance of a calendar object, given a type and timestamp 
    147      * 
    148      * @param string $type  type of object to create 
    149      * @param mixed  $stamp timestamp (depending on Calendar engine being used) 
    150      * 
     126     * @param string type of object to create 
     127     * @param mixed timestamp (depending on Calendar engine being used) 
    151128     * @return object subclass of Calendar 
    152129     * @access public 
     
    155132    function & createByTimestamp($type, $stamp) 
    156133    { 
    157         $cE  = & Calendar_Engine_Factory::getEngine(); 
    158         $y   = $cE->stampToYear($stamp); 
    159         $m   = $cE->stampToMonth($stamp); 
    160         $d   = $cE->stampToDay($stamp); 
    161         $h   = $cE->stampToHour($stamp); 
    162         $i   = $cE->stampToMinute($stamp); 
    163         $s   = $cE->stampToSecond($stamp); 
     134        $cE = & Calendar_Engine_Factory::getEngine(); 
     135        $y = $cE->stampToYear($stamp); 
     136        $m = $cE->stampToMonth($stamp); 
     137        $d = $cE->stampToDay($stamp); 
     138        $h = $cE->stampToHour($stamp); 
     139        $i = $cE->stampToMinute($stamp); 
     140        $s = $cE->stampToSecond($stamp); 
    164141        $cal = Calendar_Factory::create($type, $y, $m, $d, $h, $i, $s); 
    165142        return $cal; 
Note: See TracChangeset for help on using the changeset viewer.