source: branches/version-2_13_0/data/module/Calendar/Decorator/Uri.php @ 23143

Revision 23143, 4.5 KB checked in by m_uehara, 7 years ago (diff)

#2348 r23140 をマージ

  • Property svn:eol-style set to LF
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?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// | 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: Uri.php,v 1.3 2004/08/16 09:04:20 hfuecks Exp $
22//
23/**
24 * @package Calendar
25 * @version $Id: Uri.php,v 1.3 2004/08/16 09:04:20 hfuecks Exp $
26 */
27
28/**
29 * Allows Calendar include path to be redefined
30 * @ignore
31 */
32if (!defined('CALENDAR_ROOT')) {
33    define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
34}
35
36/**
37 * Load Calendar decorator base class
38 */
39require_once CALENDAR_ROOT.'Decorator.php';
40
41/**
42 * Load the Uri utility
43 */
44require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Uri.php';
45
46/**
47 * Decorator to help with building HTML links for navigating the calendar<br />
48 * <b>Note:</b> for performance you should prefer Calendar_Util_Uri unless you
49 * have a specific need to use a decorator
50 * <code>
51 * $Day = new Calendar_Day(2003, 10, 23);
52 * $Uri = & new Calendar_Decorator_Uri($Day);
53 * $Uri->setFragments('year', 'month', 'day');
54 * echo $Uri->getPrev(); // Displays year=2003&month=10&day=22
55 * </code>
56 * @see Calendar_Util_Uri
57 * @package Calendar
58 * @access public
59 */
60class Calendar_Decorator_Uri extends Calendar_Decorator
61{
62
63    /**
64    * @var Calendar_Util_Uri
65    * @access private
66    */
67    var $Uri;
68
69    /**
70     * Constructs Calendar_Decorator_Uri
71     * @param object subclass of Calendar
72     * @access public
73     */
74    function Calendar_Decorator_Uri(&$Calendar)
75    {
76        parent::Calendar_Decorator($Calendar);
77    }
78
79    /**
80     * Sets the URI fragment names
81     * @param string URI fragment for year
82     * @param string (optional) URI fragment for month
83     * @param string (optional) URI fragment for day
84     * @param string (optional) URI fragment for hour
85     * @param string (optional) URI fragment for minute
86     * @param string (optional) URI fragment for second
87     * @return void
88     * @access public
89     */
90    function setFragments($y, $m=null, $d=null, $h=null, $i=null, $s=null) {
91        $this->Uri = & new Calendar_Util_Uri($y, $m, $d, $h, $i, $s);
92    }
93
94    /**
95     * Sets the separator string between fragments
96     * @param string separator e.g. /
97     * @return void
98     * @access public
99     */
100    function setSeparator($separator)
101    {
102        $this->Uri->separator = $separator;
103    }
104
105    /**
106     * Puts Uri decorator into "scalar mode" - URI variable names are not
107     * returned
108     * @param boolean (optional)
109     * @return void
110     * @access public
111     */
112    function setScalar($state=true)
113    {
114        $this->Uri->scalar = $state;
115    }
116
117    /**
118     * Gets the URI string for the previous calendar unit
119     * @param string calendar unit to fetch uri for (year,month,week or day etc)
120     * @return string
121     * @access public
122     */
123    function prev($method)
124    {
125        return $this->Uri->prev($this, $method);
126    }
127
128    /**
129     * Gets the URI string for the current calendar unit
130     * @param string calendar unit to fetch uri for (year,month,week or day etc)
131     * @return string
132     * @access public
133     */
134    function this($method)
135    {
136        return $this->Uri->this($this, $method);
137    }
138
139    /**
140     * Gets the URI string for the next calendar unit
141     * @param string calendar unit to fetch uri for (year,month,week or day etc)
142     * @return string
143     * @access public
144     */
145    function next($method)
146    {
147        return $this->Uri->next($this, $method);
148    }
149
150}
151?>
Note: See TracBrowser for help on using the repository browser.