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/Util/Textual.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 // | [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: Textual.php,v 1.2 2004/08/16 13:13:09 hfuecks Exp $ 
    22 // 
     3 
     4/** 
     5 * Contains the Calendar_Util_Textual 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 <[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: Textual.php 247250 2007-11-28 19:42:01Z quipo $ 
     37 * @link      http://pear.php.net/package/Calendar 
     38 */ 
     39 
    2340/** 
    2441 * @package Calendar 
    25  * @version $Id: Textual.php,v 1.2 2004/08/16 13:13:09 hfuecks Exp $ 
     42 * @version $Id: Textual.php 247250 2007-11-28 19:42:01Z quipo $ 
    2643 */ 
    2744 
     
    4259 * Static utlities to help with fetching textual representations of months and 
    4360 * days of the week. 
    44  * @package Calendar 
    45  * @access public 
     61 * 
     62 * @category  Date and Time 
     63 * @package   Calendar 
     64 * @author    Harry Fuecks <[email protected]> 
     65 * @author    Lorenzo Alberton <[email protected]> 
     66 * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton 
     67 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause) 
     68 * @link      http://pear.php.net/package/Calendar 
     69 * @access    public 
    4670 */ 
    4771class Calendar_Util_Textual 
     
    5074    /** 
    5175     * Returns an array of 12 month names (first index = 1) 
    52      * @param string (optional) format of returned months (one,two,short or long) 
     76     * 
     77     * @param string $format (optional) format of returned months (one|two|short|long) 
     78     * 
    5379     * @return array 
    5480     * @access public 
    5581     * @static 
    5682     */ 
    57     function monthNames($format='long') 
    58     { 
    59         $formats = array('one'=>'%b', 'two'=>'%b', 'short'=>'%b', 'long'=>'%B'); 
    60         if (!array_key_exists($format,$formats)) { 
     83    function monthNames($format = 'long') 
     84    { 
     85        $formats = array( 
     86            'one'   => '%b',  
     87            'two'   => '%b',  
     88            'short' => '%b',  
     89            'long'  => '%B', 
     90        ); 
     91        if (!array_key_exists($format, $formats)) { 
    6192            $format = 'long'; 
    6293        } 
     
    6697            $month = strftime($formats[$format], $stamp); 
    6798            switch($format) { 
    68                 case 'one': 
    69                     $month = substr($month, 0, 1); 
     99            case 'one': 
     100                $month = substr($month, 0, 1); 
    70101                break; 
    71                 case 'two': 
    72                     $month = substr($month, 0, 2); 
     102            case 'two': 
     103                $month = substr($month, 0, 2); 
    73104                break; 
    74105            } 
     
    80111    /** 
    81112     * Returns an array of 7 week day names (first index = 0) 
    82      * @param string (optional) format of returned days (one,two,short or long) 
     113     * 
     114     * @param string $format (optional) format of returned days (one,two,short or long) 
     115     * 
    83116     * @return array 
    84117     * @access public 
    85118     * @static 
    86119     */ 
    87     function weekdayNames($format='long') 
    88     { 
    89         $formats = array('one'=>'%a', 'two'=>'%a', 'short'=>'%a', 'long'=>'%A'); 
    90         if (!array_key_exists($format,$formats)) { 
     120    function weekdayNames($format = 'long') 
     121    { 
     122        $formats = array( 
     123            'one'   => '%a',  
     124            'two'   => '%a',  
     125            'short' => '%a',  
     126            'long'  => '%A', 
     127        ); 
     128        if (!array_key_exists($format, $formats)) { 
    91129            $format = 'long'; 
    92130        } 
     
    96134            $day = strftime($formats[$format], $stamp); 
    97135            switch($format) { 
    98                 case 'one': 
    99                     $day = substr($day, 0, 1); 
     136            case 'one': 
     137                $day = substr($day, 0, 1); 
    100138                break; 
    101                 case 'two': 
    102                     $day = substr($day, 0, 2); 
     139            case 'two': 
     140                $day = substr($day, 0, 2); 
    103141                break; 
    104142            } 
     
    110148    /** 
    111149     * Returns textual representation of the previous month of the decorated calendar object 
    112      * @param object subclass of Calendar e.g. Calendar_Month 
    113      * @param string (optional) format of returned months (one,two,short or long) 
    114      * @return string 
    115      * @access public 
    116      * @static 
    117      */ 
    118     function prevMonthName($Calendar, $format='long') 
     150     * 
     151     * @param object $Calendar subclass of Calendar e.g. Calendar_Month 
     152     * @param string $format   (optional) format of returned months (one,two,short or long) 
     153     * 
     154     * @return string 
     155     * @access public 
     156     * @static 
     157     */ 
     158    function prevMonthName($Calendar, $format = 'long') 
    119159    { 
    120160        $months = Calendar_Util_Textual::monthNames($format); 
     
    124164    /** 
    125165     * Returns textual representation of the month of the decorated calendar object 
    126      * @param object subclass of Calendar e.g. Calendar_Month 
    127      * @param string (optional) format of returned months (one,two,short or long) 
    128      * @return string 
    129      * @access public 
    130      * @static 
    131      */ 
    132     function thisMonthName($Calendar, $format='long') 
     166     * 
     167     * @param object $Calendar subclass of Calendar e.g. Calendar_Month 
     168     * @param string $format   (optional) format of returned months (one,two,short or long) 
     169     * 
     170     * @return string 
     171     * @access public 
     172     * @static 
     173     */ 
     174    function thisMonthName($Calendar, $format = 'long') 
    133175    { 
    134176        $months = Calendar_Util_Textual::monthNames($format); 
     
    138180    /** 
    139181     * Returns textual representation of the next month of the decorated calendar object 
    140      * @param object subclass of Calendar e.g. Calendar_Month 
    141      * @param string (optional) format of returned months (one,two,short or long) 
    142      * @return string 
    143      * @access public 
    144      * @static 
    145      */ 
    146     function nextMonthName($Calendar, $format='long') 
     182     * 
     183     * @param object $Calendar subclass of Calendar e.g. Calendar_Month 
     184     * @param string $format   (optional) format of returned months (one,two,short or long) 
     185     * 
     186     * @return string 
     187     * @access public 
     188     * @static 
     189     */ 
     190    function nextMonthName($Calendar, $format = 'long') 
    147191    { 
    148192        $months = Calendar_Util_Textual::monthNames($format); 
     
    153197     * Returns textual representation of the previous day of week of the decorated calendar object 
    154198     * <b>Note:</b> Requires PEAR::Date 
    155      * @param object subclass of Calendar e.g. Calendar_Month 
    156      * @param string (optional) format of returned months (one,two,short or long) 
    157      * @return string 
    158      * @access public 
    159      * @static 
    160      */ 
    161     function prevDayName($Calendar, $format='long') 
     199     * 
     200     * @param object $Calendar subclass of Calendar e.g. Calendar_Month 
     201     * @param string $format   (optional) format of returned months (one,two,short or long) 
     202     * 
     203     * @return string 
     204     * @access public 
     205     * @static 
     206     */ 
     207    function prevDayName($Calendar, $format = 'long') 
    162208    { 
    163209        $days = Calendar_Util_Textual::weekdayNames($format); 
    164210        $stamp = $Calendar->prevDay('timestamp'); 
    165211        $cE = $Calendar->getEngine(); 
    166         require_once 'Date/Calc.php'; 
     212        include_once 'Date/Calc.php'; 
    167213        $day = Date_Calc::dayOfWeek($cE->stampToDay($stamp), 
    168214            $cE->stampToMonth($stamp), $cE->stampToYear($stamp)); 
     
    173219     * Returns textual representation of the day of week of the decorated calendar object 
    174220     * <b>Note:</b> Requires PEAR::Date 
    175      * @param object subclass of Calendar e.g. Calendar_Month 
    176      * @param string (optional) format of returned months (one,two,short or long) 
     221     * 
     222     * @param object $Calendar subclass of Calendar e.g. Calendar_Month 
     223     * @param string $format   (optional) format of returned months (one,two,short or long) 
     224     * 
    177225     * @return string 
    178226     * @access public 
     
    182230    { 
    183231        $days = Calendar_Util_Textual::weekdayNames($format); 
    184         require_once 'Date/Calc.php'; 
     232        include_once 'Date/Calc.php'; 
    185233        $day = Date_Calc::dayOfWeek($Calendar->thisDay(), $Calendar->thisMonth(), $Calendar->thisYear()); 
    186234        return $days[$day]; 
     
    189237    /** 
    190238     * Returns textual representation of the next day of week of the decorated calendar object 
    191      * @param object subclass of Calendar e.g. Calendar_Month 
    192      * @param string (optional) format of returned months (one,two,short or long) 
     239     * 
     240     * @param object $Calendar subclass of Calendar e.g. Calendar_Month 
     241     * @param string $format   (optional) format of returned months (one,two,short or long) 
     242     * 
    193243     * @return string 
    194244     * @access public 
     
    200250        $stamp = $Calendar->nextDay('timestamp'); 
    201251        $cE = $Calendar->getEngine(); 
    202         require_once 'Date/Calc.php'; 
     252        include_once 'Date/Calc.php'; 
    203253        $day = Date_Calc::dayOfWeek($cE->stampToDay($stamp), 
    204254            $cE->stampToMonth($stamp), $cE->stampToYear($stamp)); 
     
    210260     * calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks 
    211261     * and Calendar_Week. Otherwise the returned array will begin on Sunday 
    212      * @param object subclass of Calendar e.g. Calendar_Month 
    213      * @param string (optional) format of returned months (one,two,short or long) 
     262     * 
     263     * @param object $Calendar subclass of Calendar e.g. Calendar_Month 
     264     * @param string $format   (optional) format of returned months (one,two,short or long) 
     265     * 
    214266     * @return array ordered array of week day names 
    215267     * @access public 
    216268     * @static 
    217269     */ 
    218     function orderedWeekdays($Calendar, $format='long') 
     270    function orderedWeekdays($Calendar, $format = 'long') 
    219271    { 
    220272        $days = Calendar_Util_Textual::weekdayNames($format); 
    221273         
    222         // Not so good - need methods to access this information perhaps... 
    223274        if (isset($Calendar->tableHelper)) { 
    224             $ordereddays = $Calendar->tableHelper->daysOfWeek; 
     275            $ordereddays = $Calendar->tableHelper->getDaysOfWeek(); 
    225276        } else { 
    226             $ordereddays = array(0, 1, 2, 3, 4, 5, 6); 
     277            //default: start from Sunday 
     278            $firstDay = 0; 
     279            //check if defined / set 
     280            if (defined('CALENDAR_FIRST_DAY_OF_WEEK')) { 
     281                $firstDay = CALENDAR_FIRST_DAY_OF_WEEK; 
     282            } elseif(isset($Calendar->firstDay)) { 
     283                $firstDay = $Calendar->firstDay; 
     284            } 
     285            $ordereddays = array(); 
     286            for ($i = $firstDay; $i < 7; $i++) { 
     287                $ordereddays[] = $i; 
     288            } 
     289            for ($i = 0; $i < $firstDay; $i++) { 
     290                $ordereddays[] = $i; 
     291            } 
    227292        } 
    228293         
Note: See TracChangeset for help on using the changeset viewer.