Ignore:
Timestamp:
2013/08/26 15:52:37 (11 years ago)
Author:
m_uehara
Message:

#2348 r23116 - r23125 をマージ

File:
1 edited

Legend:

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

    r20119 r23126  
    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: Decorator.php,v 1.3 2005/10/22 10:29:46 quipo Exp $ 
    21 // 
     3 
    224/** 
    23  * @package Calendar 
    24  * @version $Id: Decorator.php,v 1.3 2005/10/22 10:29:46 quipo Exp $ 
     5 * Contains the Calendar_Decorator 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: Decorator.php 300729 2010-06-24 12:05:53Z quipo $ 
     36 * @link      http://pear.php.net/package/Calendar 
    2537 */ 
     38 
    2639/** 
    2740 * Decorates any calendar class. 
     
    3750 *     } 
    3851 * } 
    39  * $Day = & new Calendar_Day(2003, 10, 25); 
    40  * $DayDecorator = & new DayDecorator($Day); 
     52 * $Day = new Calendar_Day(2003, 10, 25); 
     53 * $DayDecorator = new DayDecorator($Day); 
    4154 * echo $DayDecorator->thisDay(); // Outputs "Sat" 
    4255 * </code> 
     56 * 
     57 * @category  Date and Time 
     58 * @package   Calendar 
     59 * @author    Harry Fuecks <hfuecks@phppatterns.com> 
     60 * @copyright 2003-2007 Harry Fuecks 
     61 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
     62 * @link      http://pear.php.net/package/Calendar 
    4363 * @abstract 
    44  * @package Calendar 
    4564 */ 
    4665class Calendar_Decorator 
     
    5574    /** 
    5675     * Constructs the Calendar_Decorator 
    57      * @param object subclass to Calendar to decorate 
    58      */ 
    59     function Calendar_Decorator(& $calendar) 
     76     * 
     77     * @param object &$calendar subclass to Calendar to decorate 
     78     */ 
     79    function Calendar_Decorator(&$calendar) 
    6080    { 
    6181        $this->calendar = & $calendar; 
     
    6585     * Defines the calendar by a Unix timestamp, replacing values 
    6686     * passed to the constructor 
    67      * @param int Unix timestamp 
     87     * 
     88     * @param int $ts Unix timestamp 
     89     * 
    6890     * @return void 
    6991     * @access public 
     
    7799     * Returns a timestamp from the current date / time values. Format of 
    78100     * timestamp depends on Calendar_Engine implementation being used 
    79      * @return int timestamp 
     101     * 
     102     * @return int $ts timestamp 
    80103     * @access public 
    81104     */ 
     
    87110    /** 
    88111     * Defines calendar object as selected (e.g. for today) 
    89      * @param boolean state whether Calendar subclass 
     112     * 
     113     * @param boolean $state whether Calendar subclass must be selected 
     114     * 
    90115     * @return void 
    91116     * @access public 
     
    98123    /** 
    99124     * True if the calendar subclass object is selected (e.g. today) 
     125     * 
    100126     * @return boolean 
    101127     * @access public 
     
    108134    /** 
    109135     * Adjusts the date (helper method) 
     136     * 
    110137     * @return void 
    111138     * @access public 
     
    118145    /** 
    119146     * Returns the date as an associative array (helper method) 
    120      * @param mixed timestamp (leave empty for current timestamp) 
     147     * 
     148     * @param mixed $stamp timestamp (leave empty for current timestamp) 
     149     * 
    121150     * @return array 
    122151     * @access public 
    123152     */ 
    124     function toArray($stamp=null) 
     153    function toArray($stamp = null) 
    125154    { 
    126155        return $this->calendar->toArray($stamp); 
     
    129158    /** 
    130159     * Returns the value as an associative array (helper method) 
    131      * @param string type of date object that return value represents 
    132      * @param string $format ['int' | 'array' | 'timestamp' | 'object'] 
    133      * @param mixed timestamp (depending on Calendar engine being used) 
    134      * @param int integer default value (i.e. give me the answer quick) 
     160     * 
     161     * @param string  $returnType type of date object that return value represents 
     162     * @param string  $format     ['int'|'timestamp'|'object'|'array'] 
     163     * @param mixed   $stamp      timestamp (depending on Calendar engine being used) 
     164     * @param integer $default    default value (i.e. give me the answer quick) 
     165     * 
    135166     * @return mixed 
    136167     * @access private 
     
    144175     * Defines Day object as first in a week 
    145176     * Only used by Calendar_Month_Weekdays::build() 
    146      * @param boolean state 
     177     * 
     178     * @param boolean $state whether it's first or not 
     179     * 
    147180     * @return void 
    148181     * @access private 
    149182     */ 
    150     function setFirst ($state = true) 
    151     { 
    152         if ( method_exists($this->calendar,'setFirst') ) { 
     183    function setFirst($state = true) 
     184    { 
     185        if (method_exists($this->calendar, 'setFirst')) { 
    153186            $this->calendar->setFirst($state); 
    154187        } 
     
    158191     * Defines Day object as last in a week 
    159192     * Used only following Calendar_Month_Weekdays::build() 
    160      * @param boolean state 
     193     * 
     194     * @param boolean $state whether it's last or not 
     195     * 
    161196     * @return void 
    162197     * @access private 
     
    164199    function setLast($state = true) 
    165200    { 
    166         if ( method_exists($this->calendar,'setLast') ) { 
     201        if (method_exists($this->calendar, 'setLast')) { 
    167202            $this->calendar->setLast($state); 
    168203        } 
     
    172207     * Returns true if Day object is first in a Week 
    173208     * Only relevant when Day is created by Calendar_Month_Weekdays::build() 
     209     * 
    174210     * @return boolean 
    175211     * @access public 
    176212     */ 
    177     function isFirst() { 
    178         if ( method_exists($this->calendar,'isFirst') ) { 
     213    function isFirst() 
     214    { 
     215        if (method_exists($this->calendar, 'isFirst')) { 
    179216            return $this->calendar->isFirst(); 
    180217        } 
     
    184221     * Returns true if Day object is last in a Week 
    185222     * Only relevant when Day is created by Calendar_Month_Weekdays::build() 
     223     * 
    186224     * @return boolean 
    187225     * @access public 
     
    189227    function isLast() 
    190228    { 
    191         if ( method_exists($this->calendar,'isLast') ) { 
     229        if (method_exists($this->calendar, 'isLast')) { 
    192230            return $this->calendar->isLast(); 
    193231        } 
     
    197235     * Defines Day object as empty 
    198236     * Only used by Calendar_Month_Weekdays::build() 
    199      * @param boolean state 
     237     * 
     238     * @param boolean $state whether it's empty or not 
     239     * 
    200240     * @return void 
    201241     * @access private 
     
    203243    function setEmpty ($state = true) 
    204244    { 
    205         if ( method_exists($this->calendar,'setEmpty') ) { 
     245        if (method_exists($this->calendar, 'setEmpty')) { 
    206246            $this->calendar->setEmpty($state); 
    207247        } 
     
    209249 
    210250    /** 
     251     * Check if the current object is empty 
     252     * 
    211253     * @return boolean 
    212254     * @access public 
     
    214256    function isEmpty() 
    215257    { 
    216         if ( method_exists($this->calendar,'isEmpty') ) { 
     258        if (method_exists($this->calendar, 'isEmpty')) { 
    217259            return $this->calendar->isEmpty(); 
    218260        } 
     
    221263    /** 
    222264     * Build the children 
    223      * @param array containing Calendar objects to select (optional) 
     265     * 
     266     * @param array $sDates array containing Calendar objects to select (optional) 
     267     * 
    224268     * @return boolean 
    225269     * @access public 
     
    236280     * the collection, returns false and resets the collection for 
    237281     * further iteratations. 
     282     * 
    238283     * @return mixed either an object subclass of Calendar or false 
    239284     * @access public 
     
    246291    /** 
    247292     * Fetches all child from the current collection of children 
     293     * 
    248294     * @return array 
    249295     * @access public 
     
    255301 
    256302    /** 
    257      * Get the number Calendar subclass objects stored in the internal 
    258      * collection. 
     303     * Get the number Calendar subclass objects stored in the internal collection 
     304     * 
    259305     * @return int 
    260306     * @access public 
     
    267313    /** 
    268314     * Determine whether this date is valid, with the bounds determined by 
    269      * the Calendar_Engine. The call is passed on to 
    270      * Calendar_Validator::isValid 
     315     * the Calendar_Engine. The call is passed on to Calendar_Validator::isValid 
     316     * 
    271317     * @return boolean 
    272318     * @access public 
     
    279325    /** 
    280326     * Returns an instance of Calendar_Validator 
     327     * 
    281328     * @return Calendar_Validator 
    282329     * @access public 
     
    291338     * Returns a reference to the current Calendar_Engine being used. Useful 
    292339     * for Calendar_Table_Helper and Calendar_Validator 
     340     * 
    293341     * @return object implementing Calendar_Engine_Inteface 
    294342     * @access private 
     
    296344    function & getEngine() 
    297345    { 
    298         return $this->calendar->getEngine(); 
     346        $engine = $this->calendar->getEngine(); 
     347        return $engine; 
    299348    } 
    300349 
    301350    /** 
    302351     * Returns the value for the previous year 
    303      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     352     * 
     353     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     354     * 
    304355     * @return int e.g. 2002 or timestamp 
    305356     * @access public 
     
    312363    /** 
    313364     * Returns the value for this year 
    314      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     365     * 
     366     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     367     * 
    315368     * @return int e.g. 2003 or timestamp 
    316369     * @access public 
     
    323376    /** 
    324377     * Returns the value for next year 
    325      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     378     * 
     379     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     380     * 
    326381     * @return int e.g. 2004 or timestamp 
    327382     * @access public 
     
    334389    /** 
    335390     * Returns the value for the previous month 
    336      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     391     * 
     392     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     393     * 
    337394     * @return int e.g. 4 or Unix timestamp 
    338395     * @access public 
     
    345402    /** 
    346403     * Returns the value for this month 
    347      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     404     * 
     405     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     406     * 
    348407     * @return int e.g. 5 or timestamp 
    349408     * @access public 
     
    356415    /** 
    357416     * Returns the value for next month 
    358      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     417     * 
     418     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     419     * 
    359420     * @return int e.g. 6 or timestamp 
    360421     * @access public 
     
    367428    /** 
    368429     * Returns the value for the previous week 
    369      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     430     * 
     431     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     432     * 
    370433     * @return int e.g. 4 or Unix timestamp 
    371434     * @access public 
     
    373436    function prevWeek($format = 'n_in_month') 
    374437    { 
    375         if ( method_exists($this->calendar,'prevWeek') ) { 
     438        if ( method_exists($this->calendar, 'prevWeek')) { 
    376439            return $this->calendar->prevWeek($format); 
    377440        } else { 
    378             require_once 'PEAR.php'; 
     441            include_once 'PEAR.php'; 
    379442            PEAR::raiseError( 
    380443                'Cannot call prevWeek on Calendar object of type: '. 
     
    387450    /** 
    388451     * Returns the value for this week 
    389      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     452     * 
     453     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     454     * 
    390455     * @return int e.g. 5 or timestamp 
    391456     * @access public 
     
    393458    function thisWeek($format = 'n_in_month') 
    394459    { 
    395         if ( method_exists($this->calendar,'thisWeek') ) { 
     460        if ( method_exists($this->calendar, 'thisWeek')) { 
    396461            return $this->calendar->thisWeek($format); 
    397462        } else { 
    398             require_once 'PEAR.php'; 
     463            include_once 'PEAR.php'; 
    399464            PEAR::raiseError( 
    400465                'Cannot call thisWeek on Calendar object of type: '. 
     
    407472    /** 
    408473     * Returns the value for next week 
    409      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     474     * 
     475     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     476     * 
    410477     * @return int e.g. 6 or timestamp 
    411478     * @access public 
     
    413480    function nextWeek($format = 'n_in_month') 
    414481    { 
    415         if ( method_exists($this->calendar,'nextWeek') ) { 
     482        if ( method_exists($this->calendar, 'nextWeek')) { 
    416483            return $this->calendar->nextWeek($format); 
    417484        } else { 
    418             require_once 'PEAR.php'; 
     485            include_once 'PEAR.php'; 
    419486            PEAR::raiseError( 
    420487                'Cannot call thisWeek on Calendar object of type: '. 
     
    427494    /** 
    428495     * Returns the value for the previous day 
    429      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     496     * 
     497     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     498     * 
    430499     * @return int e.g. 10 or timestamp 
    431500     * @access public 
    432501     */ 
    433     function prevDay($format = 'int') { 
     502    function prevDay($format = 'int') 
     503    { 
    434504        return $this->calendar->prevDay($format); 
    435505    } 
     
    437507    /** 
    438508     * Returns the value for this day 
    439      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     509     * 
     510     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     511     * 
    440512     * @return int e.g. 11 or timestamp 
    441513     * @access public 
     
    448520    /** 
    449521     * Returns the value for the next day 
    450      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     522     * 
     523     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     524     * 
    451525     * @return int e.g. 12 or timestamp 
    452526     * @access public 
     
    459533    /** 
    460534     * Returns the value for the previous hour 
    461      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     535     * 
     536     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     537     * 
    462538     * @return int e.g. 13 or timestamp 
    463539     * @access public 
     
    470546    /** 
    471547     * Returns the value for this hour 
    472      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     548     * 
     549     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     550     * 
    473551     * @return int e.g. 14 or timestamp 
    474552     * @access public 
     
    481559    /** 
    482560     * Returns the value for the next hour 
    483      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     561     * 
     562     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     563     * 
    484564     * @return int e.g. 14 or timestamp 
    485565     * @access public 
     
    492572    /** 
    493573     * Returns the value for the previous minute 
    494      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     574     * 
     575     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     576     * 
    495577     * @return int e.g. 23 or timestamp 
    496578     * @access public 
     
    503585    /** 
    504586     * Returns the value for this minute 
    505      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     587     * 
     588     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     589     * 
    506590     * @return int e.g. 24 or timestamp 
    507591     * @access public 
     
    514598    /** 
    515599     * Returns the value for the next minute 
    516      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     600     * 
     601     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     602     * 
    517603     * @return int e.g. 25 or timestamp 
    518604     * @access public 
    519605     */ 
    520    function nextMinute($format = 'int') 
     606    function nextMinute($format = 'int') 
    521607    { 
    522608        return $this->calendar->nextMinute($format); 
     
    525611    /** 
    526612     * Returns the value for the previous second 
    527      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     613     * 
     614     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     615     * 
    528616     * @return int e.g. 43 or timestamp 
    529617     * @access public 
     
    536624    /** 
    537625     * Returns the value for this second 
    538      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     626     * 
     627     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     628     * 
    539629     * @return int e.g. 44 or timestamp 
    540630     * @access public 
     
    547637    /** 
    548638     * Returns the value for the next second 
    549      * @param string return value format ['int' | 'timestamp' | 'object' | 'array'] 
     639     * 
     640     * @param string $format return value format ['int'|'timestamp'|'object'|'array'] 
     641     * 
    550642     * @return int e.g. 45 or timestamp 
    551643     * @access public 
Note: See TracChangeset for help on using the changeset viewer.