1
|
|
|
<?php |
2
|
|
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Contains the Calendar_Decorator_Wrapper 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$ |
37
|
|
|
* @link http://pear.php.net/package/Calendar |
38
|
|
|
*/ |
39
|
|
|
namespace Pear\Calendar\Decorator; |
40
|
|
|
|
41
|
|
|
use Pear\Calendar\Decorator; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Decorator to help with fetching textual representations of months and |
45
|
|
|
* days of the week. |
46
|
|
|
* <b>Note:</b> for performance you should prefer Calendar_Util_Textual unless you |
47
|
|
|
* have a specific need to use a decorator |
48
|
|
|
* |
49
|
|
|
* @category Date and Time |
50
|
|
|
* @package Calendar |
51
|
|
|
* @author Harry Fuecks <[email protected]> |
52
|
|
|
* @author Lorenzo Alberton <[email protected]> |
53
|
|
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton |
54
|
|
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) |
55
|
|
|
* @link http://pear.php.net/package/Calendar |
56
|
|
|
* @access public |
57
|
|
|
*/ |
58
|
|
|
class Textual extends Decorator |
59
|
|
|
{ |
60
|
|
|
/** |
61
|
|
|
* Constructs Calendar_Decorator_Textual |
62
|
|
|
* |
63
|
|
|
* @param object &$Calendar subclass of Calendar |
64
|
|
|
* |
65
|
|
|
* @access public |
66
|
|
|
*/ |
67
|
|
|
function __construct(&$Calendar) |
|
|
|
|
68
|
|
|
{ |
69
|
|
|
parent::__construct($Calendar); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Returns an array of 12 month names (first index = 1) |
74
|
|
|
* |
75
|
|
|
* @param string $format (optional) format of returned months (one|two|short|long) |
76
|
|
|
* |
77
|
|
|
* @return array |
78
|
|
|
* @access public |
79
|
|
|
* @static |
80
|
|
|
*/ |
81
|
|
|
function monthNames($format = 'long') |
|
|
|
|
82
|
|
|
{ |
83
|
|
|
return \Pear\Calendar\Util\Textual::monthNames($format); |
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Returns an array of 7 week day names (first index = 0) |
88
|
|
|
* |
89
|
|
|
* @param string $format (optional) format of returned days (one|two|short|long) |
90
|
|
|
* |
91
|
|
|
* @return array |
92
|
|
|
* @access public |
93
|
|
|
* @static |
94
|
|
|
*/ |
95
|
|
|
function weekdayNames($format = 'long') |
|
|
|
|
96
|
|
|
{ |
97
|
|
|
return \Pear\Calendar\Util\Textual::weekdayNames($format); |
|
|
|
|
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Returns textual representation of the previous month of the decorated calendar object |
102
|
|
|
* |
103
|
|
|
* @param string $format (optional) format of returned months (one|two|short|long) |
104
|
|
|
* |
105
|
|
|
* @return string |
106
|
|
|
* @access public |
107
|
|
|
*/ |
108
|
|
|
function prevMonthName($format = 'long') |
|
|
|
|
109
|
|
|
{ |
110
|
|
|
return \Pear\Calendar\Util\Textual::prevMonthName($this->calendar, $format); |
|
|
|
|
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Returns textual representation of the month of the decorated calendar object |
115
|
|
|
* |
116
|
|
|
* @param string $format (optional) format of returned months (one|two|short|long) |
117
|
|
|
* |
118
|
|
|
* @return string |
119
|
|
|
* @access public |
120
|
|
|
*/ |
121
|
|
|
function thisMonthName($format = 'long') |
|
|
|
|
122
|
|
|
{ |
123
|
|
|
return \Pear\Calendar\Util\Textual::thisMonthName($this->calendar, $format); |
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Returns textual representation of the next month of the decorated calendar object |
128
|
|
|
* |
129
|
|
|
* @param string $format (optional) format of returned months (one|two|short|long) |
130
|
|
|
* |
131
|
|
|
* @return string |
132
|
|
|
* @access public |
133
|
|
|
*/ |
134
|
|
|
function nextMonthName($format = 'long') |
|
|
|
|
135
|
|
|
{ |
136
|
|
|
return \Pear\Calendar\Util\Textual::nextMonthName($this->calendar, $format); |
|
|
|
|
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Returns textual representation of the previous day of week of the decorated calendar object |
141
|
|
|
* |
142
|
|
|
* @param string $format (optional) format of returned months (one|two|short|long) |
143
|
|
|
* |
144
|
|
|
* @return string |
145
|
|
|
* @access public |
146
|
|
|
*/ |
147
|
|
|
function prevDayName($format = 'long') |
|
|
|
|
148
|
|
|
{ |
149
|
|
|
return \Pear\Calendar\Util\Textual::prevDayName($this->calendar, $format); |
|
|
|
|
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Returns textual representation of the day of week of the decorated calendar object |
154
|
|
|
* |
155
|
|
|
* @param string $format (optional) format of returned months (one|two|short|long) |
156
|
|
|
* |
157
|
|
|
* @return string |
158
|
|
|
* @access public |
159
|
|
|
*/ |
160
|
|
|
function thisDayName($format = 'long') |
|
|
|
|
161
|
|
|
{ |
162
|
|
|
return \Pear\Calendar\Util\Textual::thisDayName($this->calendar, $format); |
|
|
|
|
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Returns textual representation of the next day of week of the decorated calendar object |
167
|
|
|
* |
168
|
|
|
* @param string $format (optional) format of returned months (one|two|short|long) |
169
|
|
|
* |
170
|
|
|
* @return string |
171
|
|
|
* @access public |
172
|
|
|
*/ |
173
|
|
|
function nextDayName($format = 'long') |
|
|
|
|
174
|
|
|
{ |
175
|
|
|
return \Pear\Calendar\Util\Textual::nextDayName($this->calendar, $format); |
|
|
|
|
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Returns the days of the week using the order defined in the decorated |
180
|
|
|
* calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks |
181
|
|
|
* and Calendar_Week. Otherwise the returned array will begin on Sunday |
182
|
|
|
* |
183
|
|
|
* @param string $format (optional) format of returned months (one|two|short|long) |
184
|
|
|
* |
185
|
|
|
* @return array ordered array of week day names |
186
|
|
|
* @access public |
187
|
|
|
*/ |
188
|
|
|
function orderedWeekdays($format = 'long') |
|
|
|
|
189
|
|
|
{ |
190
|
|
|
return \Pear\Calendar\Util\Textual::orderedWeekdays($this->calendar, $format); |
|
|
|
|
191
|
|
|
} |
192
|
|
|
} |
193
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.