2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
5 * Contains the Calendar_Decorator_Uri class
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.
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.
30 * @category Date and Time
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: Uri.php 4940 2012-06-06 02:20:28Z fishbone $
37 * @link http://pear.php.net/package/Calendar
41 * Allows Calendar include path to be redefined
44 if (!defined('CALENDAR_ROOT')) {
45 define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
49 * Load Calendar decorator base class
51 require_once CALENDAR_ROOT.'Decorator.php';
54 * Load the Uri utility
56 require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Uri.php';
59 * Decorator to help with building HTML links for navigating the calendar<br />
60 * <b>Note:</b> for performance you should prefer Calendar_Util_Uri unless you
61 * have a specific need to use a decorator
63 * $Day = new Calendar_Day(2003, 10, 23);
64 * $Uri = new Calendar_Decorator_Uri($Day);
65 * $Uri->setFragments('year', 'month', 'day');
66 * echo $Uri->getPrev(); // Displays year=2003&month=10&day=22
69 * @category Date and Time
71 * @author Harry Fuecks <hfuecks@phppatterns.com>
72 * @author Lorenzo Alberton <l.alberton@quipo.it>
73 * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
74 * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
75 * @link http://pear.php.net/package/Calendar
76 * @see Calendar_Util_Uri
79 class Calendar_Decorator_Uri extends Calendar_Decorator
83 * @var Calendar_Util_Uri
89 * Constructs Calendar_Decorator_Uri
91 * @param object &$Calendar subclass of Calendar
95 function Calendar_Decorator_Uri(&$Calendar)
97 parent::Calendar_Decorator($Calendar);
101 * Sets the URI fragment names
103 * @param string $y URI fragment for year
104 * @param string $m (optional) URI fragment for month
105 * @param string $d (optional) URI fragment for day
106 * @param string $h (optional) URI fragment for hour
107 * @param string $i (optional) URI fragment for minute
108 * @param string $s (optional) URI fragment for second
113 function setFragments($y, $m = null, $d = null, $h = null, $i = null, $s = null)
115 $this->Uri = new Calendar_Util_Uri($y, $m, $d, $h, $i, $s);
119 * Sets the separator string between fragments
121 * @param string $separator url fragment separator e.g. /
126 function setSeparator($separator)
128 $this->Uri->separator = $separator;
132 * Puts Uri decorator into "scalar mode" - URI variable names are not returned
134 * @param boolean $state (optional)
139 function setScalar($state = true)
141 $this->Uri->scalar = $state;
145 * Gets the URI string for the previous calendar unit
147 * @param string $method calendar unit to fetch uri for (year, month, week or day etc)
152 function prev($method)
154 return $this->Uri->prev($this, $method);
158 * Gets the URI string for the current calendar unit
160 * @param string $method calendar unit to fetch uri for (year,month,week or day etc)
165 function this($method)
167 return $this->Uri->this($this, $method);
171 * Gets the URI string for the next calendar unit
173 * @param string $method calendar unit to fetch uri for (year,month,week or day etc)
178 function next($method)
180 return $this->Uri->next($this, $method);