[17073] | 1 | <?php |
---|
| 2 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
---|
[23143] | 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 | // |
---|
[17073] | 23 | /** |
---|
[23143] | 24 | * @package Calendar |
---|
| 25 | * @version $Id: Uri.php,v 1.3 2004/08/16 09:04:20 hfuecks Exp $ |
---|
[17073] | 26 | */ |
---|
| 27 | |
---|
| 28 | /** |
---|
| 29 | * Allows Calendar include path to be redefined |
---|
| 30 | * @ignore |
---|
| 31 | */ |
---|
| 32 | if (!defined('CALENDAR_ROOT')) { |
---|
| 33 | define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | /** |
---|
| 37 | * Load Calendar decorator base class |
---|
| 38 | */ |
---|
| 39 | require_once CALENDAR_ROOT.'Decorator.php'; |
---|
| 40 | |
---|
| 41 | /** |
---|
| 42 | * Load the Uri utility |
---|
| 43 | */ |
---|
| 44 | require_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); |
---|
[23143] | 52 | * $Uri = & new Calendar_Decorator_Uri($Day); |
---|
[17073] | 53 | * $Uri->setFragments('year', 'month', 'day'); |
---|
| 54 | * echo $Uri->getPrev(); // Displays year=2003&month=10&day=22 |
---|
| 55 | * </code> |
---|
[23143] | 56 | * @see Calendar_Util_Uri |
---|
| 57 | * @package Calendar |
---|
| 58 | * @access public |
---|
[17073] | 59 | */ |
---|
| 60 | class Calendar_Decorator_Uri extends Calendar_Decorator |
---|
| 61 | { |
---|
| 62 | |
---|
| 63 | /** |
---|
[23143] | 64 | * @var Calendar_Util_Uri |
---|
| 65 | * @access private |
---|
| 66 | */ |
---|
[17073] | 67 | var $Uri; |
---|
| 68 | |
---|
| 69 | /** |
---|
| 70 | * Constructs Calendar_Decorator_Uri |
---|
[23143] | 71 | * @param object subclass of Calendar |
---|
[17073] | 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 |
---|
[23143] | 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 |
---|
[17073] | 87 | * @return void |
---|
| 88 | * @access public |
---|
| 89 | */ |
---|
[23143] | 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); |
---|
[17073] | 92 | } |
---|
| 93 | |
---|
| 94 | /** |
---|
| 95 | * Sets the separator string between fragments |
---|
[23143] | 96 | * @param string separator e.g. / |
---|
[17073] | 97 | * @return void |
---|
| 98 | * @access public |
---|
| 99 | */ |
---|
| 100 | function setSeparator($separator) |
---|
| 101 | { |
---|
| 102 | $this->Uri->separator = $separator; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | /** |
---|
[23143] | 106 | * Puts Uri decorator into "scalar mode" - URI variable names are not |
---|
| 107 | * returned |
---|
| 108 | * @param boolean (optional) |
---|
[17073] | 109 | * @return void |
---|
| 110 | * @access public |
---|
| 111 | */ |
---|
[23143] | 112 | function setScalar($state=true) |
---|
[17073] | 113 | { |
---|
| 114 | $this->Uri->scalar = $state; |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | /** |
---|
| 118 | * Gets the URI string for the previous calendar unit |
---|
[23143] | 119 | * @param string calendar unit to fetch uri for (year,month,week or day etc) |
---|
[17073] | 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 |
---|
[23143] | 130 | * @param string calendar unit to fetch uri for (year,month,week or day etc) |
---|
[17073] | 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 |
---|
[23143] | 141 | * @param string calendar unit to fetch uri for (year,month,week or day etc) |
---|
[17073] | 142 | * @return string |
---|
| 143 | * @access public |
---|
| 144 | */ |
---|
| 145 | function next($method) |
---|
| 146 | { |
---|
| 147 | return $this->Uri->next($this, $method); |
---|
| 148 | } |
---|
[23143] | 149 | |
---|
[17073] | 150 | } |
---|
[23143] | 151 | ?> |
---|