@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | require_once 'simple_include.php'; |
5 | 5 | require_once 'calendar_include.php'; |
6 | 6 | |
7 | -Mock::generate('Calendar_Engine_Interface','Mock_Calendar_Engine'); |
|
8 | -Mock::generate('Calendar_Second','Mock_Calendar_Second'); |
|
7 | +Mock::generate('Calendar_Engine_Interface', 'Mock_Calendar_Engine'); |
|
8 | +Mock::generate('Calendar_Second', 'Mock_Calendar_Second'); |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Class TestOfValidator |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | function setUp() |
22 | 22 | { |
23 | 23 | $this->mockengine = new Mock_Calendar_Engine($this); |
24 | - $this->mockengine->setReturnValue('getMinYears',1970); |
|
25 | - $this->mockengine->setReturnValue('getMaxYears',2037); |
|
26 | - $this->mockengine->setReturnValue('getMonthsInYear',12); |
|
27 | - $this->mockengine->setReturnValue('getDaysInMonth',30); |
|
28 | - $this->mockengine->setReturnValue('getHoursInDay',24); |
|
29 | - $this->mockengine->setReturnValue('getMinutesInHour',_EXTCAL_TS_MINUTE); |
|
30 | - $this->mockengine->setReturnValue('getSecondsInMinute',_EXTCAL_TS_MINUTE); |
|
24 | + $this->mockengine->setReturnValue('getMinYears', 1970); |
|
25 | + $this->mockengine->setReturnValue('getMaxYears', 2037); |
|
26 | + $this->mockengine->setReturnValue('getMonthsInYear', 12); |
|
27 | + $this->mockengine->setReturnValue('getDaysInMonth', 30); |
|
28 | + $this->mockengine->setReturnValue('getHoursInDay', 24); |
|
29 | + $this->mockengine->setReturnValue('getMinutesInHour', _EXTCAL_TS_MINUTE); |
|
30 | + $this->mockengine->setReturnValue('getSecondsInMinute', _EXTCAL_TS_MINUTE); |
|
31 | 31 | $this->mockcal = new Mock_Calendar_Second($this); |
32 | - $this->mockcal->setReturnValue('getEngine',$this->mockengine); |
|
32 | + $this->mockcal->setReturnValue('getEngine', $this->mockengine); |
|
33 | 33 | } |
34 | 34 | function tearDown() |
35 | 35 | { |
@@ -38,139 +38,139 @@ discard block |
||
38 | 38 | } |
39 | 39 | function testIsValidYear() |
40 | 40 | { |
41 | - $this->mockcal->setReturnValue('thisYear',2000); |
|
41 | + $this->mockcal->setReturnValue('thisYear', 2000); |
|
42 | 42 | $Validator = new Calendar_Validator($this->mockcal); |
43 | 43 | $this->assertTrue($Validator->isValidYear()); |
44 | 44 | } |
45 | 45 | function testIsValidYearTooSmall() |
46 | 46 | { |
47 | - $this->mockcal->setReturnValue('thisYear',1969); |
|
47 | + $this->mockcal->setReturnValue('thisYear', 1969); |
|
48 | 48 | $Validator = new Calendar_Validator($this->mockcal); |
49 | 49 | $this->assertFalse($Validator->isValidYear()); |
50 | 50 | } |
51 | 51 | function testIsValidYearTooLarge() |
52 | 52 | { |
53 | - $this->mockcal->setReturnValue('thisYear',2038); |
|
53 | + $this->mockcal->setReturnValue('thisYear', 2038); |
|
54 | 54 | $Validator = new Calendar_Validator($this->mockcal); |
55 | 55 | $this->assertFalse($Validator->isValidYear()); |
56 | 56 | } |
57 | 57 | function testIsValidMonth() |
58 | 58 | { |
59 | - $this->mockcal->setReturnValue('thisMonth',10); |
|
59 | + $this->mockcal->setReturnValue('thisMonth', 10); |
|
60 | 60 | $Validator = new Calendar_Validator($this->mockcal); |
61 | 61 | $this->assertTrue($Validator->isValidMonth()); |
62 | 62 | } |
63 | 63 | function testIsValidMonthTooSmall() |
64 | 64 | { |
65 | - $this->mockcal->setReturnValue('thisMonth',0); |
|
65 | + $this->mockcal->setReturnValue('thisMonth', 0); |
|
66 | 66 | $Validator = new Calendar_Validator($this->mockcal); |
67 | 67 | $this->assertFalse($Validator->isValidMonth()); |
68 | 68 | } |
69 | 69 | function testIsValidMonthTooLarge() |
70 | 70 | { |
71 | - $this->mockcal->setReturnValue('thisMonth',13); |
|
71 | + $this->mockcal->setReturnValue('thisMonth', 13); |
|
72 | 72 | $Validator = new Calendar_Validator($this->mockcal); |
73 | 73 | $this->assertFalse($Validator->isValidMonth()); |
74 | 74 | } |
75 | 75 | function testIsValidDay() |
76 | 76 | { |
77 | - $this->mockcal->setReturnValue('thisDay',10); |
|
77 | + $this->mockcal->setReturnValue('thisDay', 10); |
|
78 | 78 | $Validator = new Calendar_Validator($this->mockcal); |
79 | 79 | $this->assertTrue($Validator->isValidDay()); |
80 | 80 | } |
81 | 81 | function testIsValidDayTooSmall() |
82 | 82 | { |
83 | - $this->mockcal->setReturnValue('thisDay',0); |
|
83 | + $this->mockcal->setReturnValue('thisDay', 0); |
|
84 | 84 | $Validator = new Calendar_Validator($this->mockcal); |
85 | 85 | $this->assertFalse($Validator->isValidDay()); |
86 | 86 | } |
87 | 87 | function testIsValidDayTooLarge() |
88 | 88 | { |
89 | - $this->mockcal->setReturnValue('thisDay',31); |
|
89 | + $this->mockcal->setReturnValue('thisDay', 31); |
|
90 | 90 | $Validator = new Calendar_Validator($this->mockcal); |
91 | 91 | $this->assertFalse($Validator->isValidDay()); |
92 | 92 | } |
93 | 93 | function testIsValidHour() |
94 | 94 | { |
95 | - $this->mockcal->setReturnValue('thisHour',10); |
|
95 | + $this->mockcal->setReturnValue('thisHour', 10); |
|
96 | 96 | $Validator = new Calendar_Validator($this->mockcal); |
97 | 97 | $this->assertTrue($Validator->isValidHour()); |
98 | 98 | } |
99 | 99 | function testIsValidHourTooSmall() |
100 | 100 | { |
101 | - $this->mockcal->setReturnValue('thisHour',-1); |
|
101 | + $this->mockcal->setReturnValue('thisHour', -1); |
|
102 | 102 | $Validator = new Calendar_Validator($this->mockcal); |
103 | 103 | $this->assertFalse($Validator->isValidHour()); |
104 | 104 | } |
105 | 105 | function testIsValidHourTooLarge() |
106 | 106 | { |
107 | - $this->mockcal->setReturnValue('thisHour',24); |
|
107 | + $this->mockcal->setReturnValue('thisHour', 24); |
|
108 | 108 | $Validator = new Calendar_Validator($this->mockcal); |
109 | 109 | $this->assertFalse($Validator->isValidHour()); |
110 | 110 | } |
111 | 111 | function testIsValidMinute() |
112 | 112 | { |
113 | - $this->mockcal->setReturnValue('thisMinute',30); |
|
113 | + $this->mockcal->setReturnValue('thisMinute', 30); |
|
114 | 114 | $Validator = new Calendar_Validator($this->mockcal); |
115 | 115 | $this->assertTrue($Validator->isValidMinute()); |
116 | 116 | } |
117 | 117 | function testIsValidMinuteTooSmall() |
118 | 118 | { |
119 | - $this->mockcal->setReturnValue('thisMinute',-1); |
|
119 | + $this->mockcal->setReturnValue('thisMinute', -1); |
|
120 | 120 | $Validator = new Calendar_Validator($this->mockcal); |
121 | 121 | $this->assertFalse($Validator->isValidMinute()); |
122 | 122 | } |
123 | 123 | function testIsValidMinuteTooLarge() |
124 | 124 | { |
125 | - $this->mockcal->setReturnValue('thisMinute',_EXTCAL_TS_MINUTE); |
|
125 | + $this->mockcal->setReturnValue('thisMinute', _EXTCAL_TS_MINUTE); |
|
126 | 126 | $Validator = new Calendar_Validator($this->mockcal); |
127 | 127 | $this->assertFalse($Validator->isValidMinute()); |
128 | 128 | } |
129 | 129 | function testIsValidSecond() |
130 | 130 | { |
131 | - $this->mockcal->setReturnValue('thisSecond',30); |
|
131 | + $this->mockcal->setReturnValue('thisSecond', 30); |
|
132 | 132 | $Validator = new Calendar_Validator($this->mockcal); |
133 | 133 | $this->assertTrue($Validator->isValidSecond()); |
134 | 134 | } |
135 | 135 | function testIsValidSecondTooSmall() |
136 | 136 | { |
137 | - $this->mockcal->setReturnValue('thisSecond',-1); |
|
137 | + $this->mockcal->setReturnValue('thisSecond', -1); |
|
138 | 138 | $Validator = new Calendar_Validator($this->mockcal); |
139 | 139 | $this->assertFalse($Validator->isValidSecond()); |
140 | 140 | } |
141 | 141 | function testIsValidSecondTooLarge() |
142 | 142 | { |
143 | - $this->mockcal->setReturnValue('thisSecond',_EXTCAL_TS_MINUTE); |
|
143 | + $this->mockcal->setReturnValue('thisSecond', _EXTCAL_TS_MINUTE); |
|
144 | 144 | $Validator = new Calendar_Validator($this->mockcal); |
145 | 145 | $this->assertFalse($Validator->isValidSecond()); |
146 | 146 | } |
147 | 147 | function testIsValid() |
148 | 148 | { |
149 | - $this->mockcal->setReturnValue('thisYear',2000); |
|
150 | - $this->mockcal->setReturnValue('thisMonth',5); |
|
151 | - $this->mockcal->setReturnValue('thisDay',15); |
|
152 | - $this->mockcal->setReturnValue('thisHour',13); |
|
153 | - $this->mockcal->setReturnValue('thisMinute',30); |
|
154 | - $this->mockcal->setReturnValue('thisSecond',40); |
|
149 | + $this->mockcal->setReturnValue('thisYear', 2000); |
|
150 | + $this->mockcal->setReturnValue('thisMonth', 5); |
|
151 | + $this->mockcal->setReturnValue('thisDay', 15); |
|
152 | + $this->mockcal->setReturnValue('thisHour', 13); |
|
153 | + $this->mockcal->setReturnValue('thisMinute', 30); |
|
154 | + $this->mockcal->setReturnValue('thisSecond', 40); |
|
155 | 155 | $Validator = new Calendar_Validator($this->mockcal); |
156 | 156 | $this->assertTrue($Validator->isValid()); |
157 | 157 | } |
158 | 158 | function testIsValidAllWrong() |
159 | 159 | { |
160 | - $this->mockcal->setReturnValue('thisYear',2038); |
|
161 | - $this->mockcal->setReturnValue('thisMonth',13); |
|
162 | - $this->mockcal->setReturnValue('thisDay',31); |
|
160 | + $this->mockcal->setReturnValue('thisYear', 2038); |
|
161 | + $this->mockcal->setReturnValue('thisMonth', 13); |
|
162 | + $this->mockcal->setReturnValue('thisDay', 31); |
|
163 | 163 | $this->mockcal->day = 31; |
164 | - $this->mockcal->setReturnValue('thisHour',24); |
|
165 | - $this->mockcal->setReturnValue('thisMinute',_EXTCAL_TS_MINUTE); |
|
166 | - $this->mockcal->setReturnValue('thisSecond',_EXTCAL_TS_MINUTE); |
|
164 | + $this->mockcal->setReturnValue('thisHour', 24); |
|
165 | + $this->mockcal->setReturnValue('thisMinute', _EXTCAL_TS_MINUTE); |
|
166 | + $this->mockcal->setReturnValue('thisSecond', _EXTCAL_TS_MINUTE); |
|
167 | 167 | $Validator = new Calendar_Validator($this->mockcal); |
168 | 168 | $this->assertFalse($Validator->isValid()); |
169 | 169 | $i = 0; |
170 | - while ( $Validator->fetch() ) { |
|
170 | + while ($Validator->fetch()) { |
|
171 | 171 | ++$i; |
172 | 172 | } |
173 | - $this->assertEqual($i,6); |
|
173 | + $this->assertEqual($i, 6); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | } |
192 | 192 | function testMonth() |
193 | 193 | { |
194 | - $Unit = new Calendar_Month(2000,13); |
|
194 | + $Unit = new Calendar_Month(2000, 13); |
|
195 | 195 | $Validator = & $Unit->getValidator(); |
196 | 196 | $this->assertFalse($Validator->isValidMonth()); |
197 | 197 | } |
@@ -205,38 +205,38 @@ discard block |
||
205 | 205 | */ |
206 | 206 | function testDay() |
207 | 207 | { |
208 | - $Unit = new Calendar_Day(2000,12,32); |
|
208 | + $Unit = new Calendar_Day(2000, 12, 32); |
|
209 | 209 | $Validator = & $Unit->getValidator(); |
210 | 210 | $this->assertFalse($Validator->isValidDay()); |
211 | 211 | } |
212 | 212 | function testHour() |
213 | 213 | { |
214 | - $Unit = new Calendar_Hour(2000,12,20,24); |
|
214 | + $Unit = new Calendar_Hour(2000, 12, 20, 24); |
|
215 | 215 | $Validator = & $Unit->getValidator(); |
216 | 216 | $this->assertFalse($Validator->isValidHour()); |
217 | 217 | } |
218 | 218 | function testMinute() |
219 | 219 | { |
220 | - $Unit = new Calendar_Minute(2000,12,20,23,_EXTCAL_TS_MINUTE); |
|
220 | + $Unit = new Calendar_Minute(2000, 12, 20, 23, _EXTCAL_TS_MINUTE); |
|
221 | 221 | $Validator = & $Unit->getValidator(); |
222 | 222 | $this->assertFalse($Validator->isValidMinute()); |
223 | 223 | } |
224 | 224 | function testSecond() |
225 | 225 | { |
226 | - $Unit = new Calendar_Second(2000,12,20,23,59,_EXTCAL_TS_MINUTE); |
|
226 | + $Unit = new Calendar_Second(2000, 12, 20, 23, 59, _EXTCAL_TS_MINUTE); |
|
227 | 227 | $Validator = & $Unit->getValidator(); |
228 | 228 | $this->assertFalse($Validator->isValidSecond()); |
229 | 229 | } |
230 | 230 | function testAllBad() |
231 | 231 | { |
232 | - $Unit = new Calendar_Second(2000,13,32,24,_EXTCAL_TS_MINUTE,_EXTCAL_TS_MINUTE); |
|
232 | + $Unit = new Calendar_Second(2000, 13, 32, 24, _EXTCAL_TS_MINUTE, _EXTCAL_TS_MINUTE); |
|
233 | 233 | $this->assertFalse($Unit->isValid()); |
234 | 234 | $Validator = & $Unit->getValidator(); |
235 | 235 | $i = 0; |
236 | - while ( $Validator->fetch() ) { |
|
236 | + while ($Validator->fetch()) { |
|
237 | 237 | ++$i; |
238 | 238 | } |
239 | - $this->assertEqual($i,5); |
|
239 | + $this->assertEqual($i, 5); |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 |
@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | if (!@include 'Calendar/Calendar.php') { |
6 | 6 | define('CALENDAR_ROOT', '../../'); |
7 | 7 | } |
8 | -require_once CALENDAR_ROOT.'Month/Weekdays.php'; |
|
9 | -require_once CALENDAR_ROOT.'Decorator/Uri.php'; |
|
8 | +require_once CALENDAR_ROOT . 'Month/Weekdays.php'; |
|
9 | +require_once CALENDAR_ROOT . 'Decorator/Uri.php'; |
|
10 | 10 | |
11 | 11 | if (!isset($_GET['jahr'])) $_GET['jahr'] = date('Y'); |
12 | 12 | if (!isset($_GET['monat'])) $_GET['monat'] = date('m'); |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | // Build the month |
15 | 15 | $Calendar = new Calendar_Month_Weekdays($_GET['jahr'], $_GET['monat']); |
16 | 16 | |
17 | -echo ( '<p>The current month is ' |
|
18 | - .$Calendar->thisMonth().' of year '.$Calendar->thisYear().'</p>'); |
|
17 | +echo ('<p>The current month is ' |
|
18 | + .$Calendar->thisMonth() . ' of year ' . $Calendar->thisYear() . '</p>'); |
|
19 | 19 | |
20 | 20 | $Uri = new Calendar_Decorator_Uri($Calendar); |
21 | -$Uri->setFragments('jahr','monat'); |
|
21 | +$Uri->setFragments('jahr', 'monat'); |
|
22 | 22 | // $Uri->setSeperator('/'); // Default is & |
23 | 23 | // $Uri->setScalar(); // Omit variable names |
24 | -echo ( "<pre>Previous Uri:\t".$Uri->prev('month')."\n" ); |
|
25 | -echo ( "This Uri:\t".$Uri->this('month')."\n" ); |
|
26 | -echo ( "Next Uri:\t".$Uri->next('month')."\n</pre>" ); |
|
24 | +echo ("<pre>Previous Uri:\t" . $Uri->prev('month') . "\n"); |
|
25 | +echo ("This Uri:\t" . $Uri->this('month') . "\n"); |
|
26 | +echo ("Next Uri:\t" . $Uri->next('month') . "\n</pre>"); |
|
27 | 27 | ?> |
28 | 28 | <p> |
29 | -<a href="<?php echo($_SERVER['PHP_SELF'].'?'.$Uri->prev('month'));?>">Prev</a> : |
|
30 | -<a href="<?php echo($_SERVER['PHP_SELF'].'?'.$Uri->next('month'));?>">Next</a> |
|
29 | +<a href="<?php echo($_SERVER['PHP_SELF'] . '?' . $Uri->prev('month')); ?>">Prev</a> : |
|
30 | +<a href="<?php echo($_SERVER['PHP_SELF'] . '?' . $Uri->next('month')); ?>">Next</a> |
|
31 | 31 | </p> |
@@ -8,8 +8,12 @@ |
||
8 | 8 | require_once CALENDAR_ROOT.'Month/Weekdays.php'; |
9 | 9 | require_once CALENDAR_ROOT.'Decorator/Uri.php'; |
10 | 10 | |
11 | -if (!isset($_GET['jahr'])) $_GET['jahr'] = date('Y'); |
|
12 | -if (!isset($_GET['monat'])) $_GET['monat'] = date('m'); |
|
11 | +if (!isset($_GET['jahr'])) { |
|
12 | + $_GET['jahr'] = date('Y'); |
|
13 | +} |
|
14 | +if (!isset($_GET['monat'])) { |
|
15 | + $_GET['monat'] = date('m'); |
|
16 | +} |
|
13 | 17 | |
14 | 18 | // Build the month |
15 | 19 | $Calendar = new Calendar_Month_Weekdays($_GET['jahr'], $_GET['monat']); |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | */ |
8 | 8 | function getmicrotime() |
9 | 9 | { |
10 | - list($usec, $sec) = explode(" ",microtime()); |
|
10 | + list($usec, $sec) = explode(" ", microtime()); |
|
11 | 11 | |
12 | 12 | return ((float) $usec + (float) $sec); |
13 | 13 | } |
14 | 14 | |
15 | 15 | if (!@include 'Calendar/Calendar.php') { |
16 | - define('CALENDAR_ROOT','../../'); |
|
16 | + define('CALENDAR_ROOT', '../../'); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | if (!isset($_GET['y'])) $_GET['y'] = 2003; |
@@ -27,67 +27,67 @@ discard block |
||
27 | 27 | default: |
28 | 28 | $_GET['view'] = 'calendar_year'; |
29 | 29 | case 'calendar_year': |
30 | - require_once CALENDAR_ROOT.'Year.php'; |
|
30 | + require_once CALENDAR_ROOT . 'Year.php'; |
|
31 | 31 | $c = new Calendar_Year($_GET['y']); |
32 | 32 | break; |
33 | 33 | case 'calendar_month': |
34 | - require_once CALENDAR_ROOT.'Month.php'; |
|
35 | - $c = new Calendar_Month($_GET['y'],$_GET['m']); |
|
34 | + require_once CALENDAR_ROOT . 'Month.php'; |
|
35 | + $c = new Calendar_Month($_GET['y'], $_GET['m']); |
|
36 | 36 | break; |
37 | 37 | case 'calendar_day': |
38 | - require_once CALENDAR_ROOT.'Day.php'; |
|
39 | - $c = new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']); |
|
38 | + require_once CALENDAR_ROOT . 'Day.php'; |
|
39 | + $c = new Calendar_Day($_GET['y'], $_GET['m'], $_GET['d']); |
|
40 | 40 | break; |
41 | 41 | case 'calendar_hour': |
42 | - require_once CALENDAR_ROOT.'Hour.php'; |
|
43 | - $c = new Calendar_Hour($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h']); |
|
42 | + require_once CALENDAR_ROOT . 'Hour.php'; |
|
43 | + $c = new Calendar_Hour($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h']); |
|
44 | 44 | break; |
45 | 45 | case 'calendar_minute': |
46 | - require_once CALENDAR_ROOT.'Minute.php'; |
|
47 | - $c = new Calendar_Minute($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i']); |
|
46 | + require_once CALENDAR_ROOT . 'Minute.php'; |
|
47 | + $c = new Calendar_Minute($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i']); |
|
48 | 48 | break; |
49 | 49 | case 'calendar_second': |
50 | - require_once CALENDAR_ROOT.'Second.php'; |
|
51 | - $c = new Calendar_Second($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i'],$_GET['s']); |
|
50 | + require_once CALENDAR_ROOT . 'Second.php'; |
|
51 | + $c = new Calendar_Second($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i'], $_GET['s']); |
|
52 | 52 | break; |
53 | 53 | } |
54 | 54 | |
55 | -echo ( 'Viewing: '.@$_GET['view'].'<br />' ); |
|
56 | -echo ( 'The time is now: '.date('Y M d H:i:s',$c->getTimestamp()).'<br >' ); |
|
55 | +echo ('Viewing: ' . @$_GET['view'] . '<br />'); |
|
56 | +echo ('The time is now: ' . date('Y M d H:i:s', $c->getTimestamp()) . '<br >'); |
|
57 | 57 | |
58 | 58 | $i = 1; |
59 | -echo ( '<h1>First Iteration</h1>' ); |
|
60 | -echo ( '<p>The first iteration is more "expensive", the calendar data |
|
59 | +echo ('<h1>First Iteration</h1>'); |
|
60 | +echo ('<p>The first iteration is more "expensive", the calendar data |
|
61 | 61 | structures having to be built.</p>' ); |
62 | 62 | $start = getmicrotime(); |
63 | 63 | $c->build(); |
64 | -while ( $e = $c->fetch() ) { |
|
64 | +while ($e = $c->fetch()) { |
|
65 | 65 | $class = strtolower(get_class($e)); |
66 | - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). |
|
67 | - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); |
|
68 | - $method = 'this'.str_replace('calendar_','',$class); |
|
69 | - echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " ); |
|
70 | - if ( ($i % 10) == 0 ) { |
|
71 | - echo ( '<br>' ); |
|
66 | + $link = "&y=" . $e->thisYear() . "&m=" . $e->thisMonth() . "&d=" . $e->thisDay() . |
|
67 | + "&h=" . $e->thisHour() . "&i=" . $e->thisMinute() . "&s=" . $e->thisSecond(); |
|
68 | + $method = 'this' . str_replace('calendar_', '', $class); |
|
69 | + echo ("<a href=\"" . $_SERVER['PHP_SELF'] . "?view=" . $class . $link . "\">" . $e->{$method}() . "</a> : "); |
|
70 | + if (($i % 10) == 0) { |
|
71 | + echo ('<br>'); |
|
72 | 72 | } |
73 | 73 | ++$i; |
74 | 74 | } |
75 | -echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' ); |
|
75 | +echo ('<p><b>Took: ' . (getmicrotime() - $start) . ' seconds</b></p>'); |
|
76 | 76 | |
77 | 77 | $i = 1; |
78 | -echo ( '<h1>Second Iteration</h1>' ); |
|
79 | -echo ( '<p>This second iteration is faster, the data structures |
|
78 | +echo ('<h1>Second Iteration</h1>'); |
|
79 | +echo ('<p>This second iteration is faster, the data structures |
|
80 | 80 | being re-used</p>' ); |
81 | 81 | $start = getmicrotime(); |
82 | -while ( $e = $c->fetch() ) { |
|
82 | +while ($e = $c->fetch()) { |
|
83 | 83 | $class = strtolower(get_class($e)); |
84 | - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). |
|
85 | - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); |
|
86 | - $method = 'this'.str_replace('calendar_','',$class); |
|
87 | - echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " ); |
|
88 | - if ( ($i % 10) == 0 ) { |
|
89 | - echo ( '<br>' ); |
|
84 | + $link = "&y=" . $e->thisYear() . "&m=" . $e->thisMonth() . "&d=" . $e->thisDay() . |
|
85 | + "&h=" . $e->thisHour() . "&i=" . $e->thisMinute() . "&s=" . $e->thisSecond(); |
|
86 | + $method = 'this' . str_replace('calendar_', '', $class); |
|
87 | + echo ("<a href=\"" . $_SERVER['PHP_SELF'] . "?view=" . $class . $link . "\">" . $e->{$method}() . "</a> : "); |
|
88 | + if (($i % 10) == 0) { |
|
89 | + echo ('<br>'); |
|
90 | 90 | } |
91 | 91 | ++$i; |
92 | 92 | } |
93 | -echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' ); |
|
93 | +echo ('<p><b>Took: ' . (getmicrotime() - $start) . ' seconds</b></p>'); |
@@ -16,12 +16,24 @@ |
||
16 | 16 | define('CALENDAR_ROOT','../../'); |
17 | 17 | } |
18 | 18 | |
19 | -if (!isset($_GET['y'])) $_GET['y'] = 2003; |
|
20 | -if (!isset($_GET['m'])) $_GET['m'] = 8; |
|
21 | -if (!isset($_GET['d'])) $_GET['d'] = 9; |
|
22 | -if (!isset($_GET['h'])) $_GET['h'] = 12; |
|
23 | -if (!isset($_GET['i'])) $_GET['i'] = 34; |
|
24 | -if (!isset($_GET['s'])) $_GET['s'] = 46; |
|
19 | +if (!isset($_GET['y'])) { |
|
20 | + $_GET['y'] = 2003; |
|
21 | +} |
|
22 | +if (!isset($_GET['m'])) { |
|
23 | + $_GET['m'] = 8; |
|
24 | +} |
|
25 | +if (!isset($_GET['d'])) { |
|
26 | + $_GET['d'] = 9; |
|
27 | +} |
|
28 | +if (!isset($_GET['h'])) { |
|
29 | + $_GET['h'] = 12; |
|
30 | +} |
|
31 | +if (!isset($_GET['i'])) { |
|
32 | + $_GET['i'] = 34; |
|
33 | +} |
|
34 | +if (!isset($_GET['s'])) { |
|
35 | + $_GET['s'] = 46; |
|
36 | +} |
|
25 | 37 | |
26 | 38 | switch (@$_GET['view']) { |
27 | 39 | default: |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Description: client for the SOAP Calendar Server |
|
4 | - */ |
|
3 | + * Description: client for the SOAP Calendar Server |
|
4 | + */ |
|
5 | 5 | if ( version_compare(phpversion(), "5.0.0", ">") ) { |
6 | 6 | die('PHP 5 has problems with PEAR::SOAP Client (8.0RC3) |
7 | 7 | - remove @ before include below to see why'); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Description: client for the SOAP Calendar Server |
4 | 4 | */ |
5 | -if ( version_compare(phpversion(), "5.0.0", ">") ) { |
|
5 | +if (version_compare(phpversion(), "5.0.0", ">")) { |
|
6 | 6 | die('PHP 5 has problems with PEAR::SOAP Client (8.0RC3) |
7 | 7 | - remove @ before include below to see why'); |
8 | 8 | } |
@@ -15,21 +15,21 @@ discard block |
||
15 | 15 | $basePath = explode('/', $_SERVER['SCRIPT_NAME']); |
16 | 16 | array_pop($basePath); |
17 | 17 | $basePath = implode('/', $basePath); |
18 | -$url = 'http://'.$_SERVER['SERVER_NAME'].$basePath.'/7.php?wsdl'; |
|
18 | +$url = 'http://' . $_SERVER['SERVER_NAME'] . $basePath . '/7.php?wsdl'; |
|
19 | 19 | |
20 | 20 | if (!isset($_GET['y'])) $_GET['y'] = date('Y'); |
21 | 21 | if (!isset($_GET['m'])) $_GET['m'] = date('n'); |
22 | 22 | |
23 | -$wsdl = new SOAP_WSDL ($url); |
|
23 | +$wsdl = new SOAP_WSDL($url); |
|
24 | 24 | |
25 | -echo ( '<pre>'.$wsdl->generateProxyCode().'</pre>' ); |
|
25 | +echo ('<pre>' . $wsdl->generateProxyCode() . '</pre>'); |
|
26 | 26 | |
27 | 27 | $calendarClient = $wsdl->getProxy(); |
28 | 28 | |
29 | -$month = $calendarClient->getMonth((int) $_GET['y'],(int) $_GET['m']); |
|
29 | +$month = $calendarClient->getMonth((int) $_GET['y'], (int) $_GET['m']); |
|
30 | 30 | |
31 | -if ( PEAR::isError($month) ) { |
|
32 | - die ( $month->toString() ); |
|
31 | +if (PEAR::isError($month)) { |
|
32 | + die ($month->toString()); |
|
33 | 33 | } |
34 | 34 | ?> |
35 | 35 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
@@ -40,30 +40,30 @@ discard block |
||
40 | 40 | <body> |
41 | 41 | <h1>Calendar Over the Wire (featuring PEAR::SOAP)</h1> |
42 | 42 | <table> |
43 | -<caption><b><?php echo ( $month->monthname );?></b></caption> |
|
43 | +<caption><b><?php echo ($month->monthname); ?></b></caption> |
|
44 | 44 | <tr> |
45 | 45 | <th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th><th>S</th> |
46 | 46 | </tr> |
47 | 47 | <?php |
48 | 48 | foreach ($month->days as $day) { |
49 | 49 | |
50 | - if ( $day->isFirst === 1 ) |
|
51 | - echo ( "<tr>\n" ); |
|
50 | + if ($day->isFirst === 1) |
|
51 | + echo ("<tr>\n"); |
|
52 | 52 | if ($day->isEmpty === 1) { |
53 | - echo ( "<td></td>" ); |
|
53 | + echo ("<td></td>"); |
|
54 | 54 | } else { |
55 | - echo ( "<td>".$day->day."</td>" ); |
|
55 | + echo ("<td>" . $day->day . "</td>"); |
|
56 | 56 | } |
57 | - if ( $day->isLast === 1 ) |
|
58 | - echo ( "</tr>\n" ); |
|
57 | + if ($day->isLast === 1) |
|
58 | + echo ("</tr>\n"); |
|
59 | 59 | } |
60 | 60 | ?> |
61 | 61 | <tr> |
62 | 62 | </table> |
63 | 63 | <p>Enter Year and Month to View:</p> |
64 | -<form action="<?php echo ( $_SERVER['PHP_SELF'] ); ?>" method="get"> |
|
65 | -Year: <input type="text" size="4" name="y" value="<?php echo ( $_GET['y'] ); ?>"> |
|
66 | -Month: <input type="text" size="2" name="m" value="<?php echo ( $_GET['m'] ); ?>"> |
|
64 | +<form action="<?php echo ($_SERVER['PHP_SELF']); ?>" method="get"> |
|
65 | +Year: <input type="text" size="4" name="y" value="<?php echo ($_GET['y']); ?>"> |
|
66 | +Month: <input type="text" size="2" name="m" value="<?php echo ($_GET['m']); ?>"> |
|
67 | 67 | <input type="submit" value="Fetch Calendar"> |
68 | 68 | </form> |
69 | 69 | </body> |
@@ -17,8 +17,12 @@ discard block |
||
17 | 17 | $basePath = implode('/', $basePath); |
18 | 18 | $url = 'http://'.$_SERVER['SERVER_NAME'].$basePath.'/7.php?wsdl'; |
19 | 19 | |
20 | -if (!isset($_GET['y'])) $_GET['y'] = date('Y'); |
|
21 | -if (!isset($_GET['m'])) $_GET['m'] = date('n'); |
|
20 | +if (!isset($_GET['y'])) { |
|
21 | + $_GET['y'] = date('Y'); |
|
22 | +} |
|
23 | +if (!isset($_GET['m'])) { |
|
24 | + $_GET['m'] = date('n'); |
|
25 | +} |
|
22 | 26 | |
23 | 27 | $wsdl = new SOAP_WSDL ($url); |
24 | 28 | |
@@ -47,16 +51,18 @@ discard block |
||
47 | 51 | <?php |
48 | 52 | foreach ($month->days as $day) { |
49 | 53 | |
50 | - if ( $day->isFirst === 1 ) |
|
51 | - echo ( "<tr>\n" ); |
|
54 | + if ( $day->isFirst === 1 ) { |
|
55 | + echo ( "<tr>\n" ); |
|
56 | + } |
|
52 | 57 | if ($day->isEmpty === 1) { |
53 | 58 | echo ( "<td></td>" ); |
54 | 59 | } else { |
55 | 60 | echo ( "<td>".$day->day."</td>" ); |
56 | 61 | } |
57 | - if ( $day->isLast === 1 ) |
|
58 | - echo ( "</tr>\n" ); |
|
59 | -} |
|
62 | + if ( $day->isLast === 1 ) { |
|
63 | + echo ( "</tr>\n" ); |
|
64 | + } |
|
65 | + } |
|
60 | 66 | ?> |
61 | 67 | <tr> |
62 | 68 | </table> |
@@ -7,16 +7,16 @@ discard block |
||
7 | 7 | */ |
8 | 8 | function getmicrotime() |
9 | 9 | { |
10 | - list($usec, $sec) = explode(" ",microtime()); |
|
10 | + list($usec, $sec) = explode(" ", microtime()); |
|
11 | 11 | |
12 | 12 | return ((float) $usec + (float) $sec); |
13 | 13 | } |
14 | 14 | |
15 | 15 | // Switch to PEAR::Date engine |
16 | -define('CALENDAR_ENGINE','PearDate'); |
|
16 | +define('CALENDAR_ENGINE', 'PearDate'); |
|
17 | 17 | |
18 | 18 | if (!@include 'Calendar/Calendar.php') { |
19 | - define('CALENDAR_ROOT','../../'); |
|
19 | + define('CALENDAR_ROOT', '../../'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (!isset($_GET['y'])) $_GET['y'] = 2003; |
@@ -30,71 +30,71 @@ discard block |
||
30 | 30 | default: |
31 | 31 | $_GET['view'] = 'calendar_year'; |
32 | 32 | case 'calendar_year': |
33 | - require_once CALENDAR_ROOT.'Year.php'; |
|
33 | + require_once CALENDAR_ROOT . 'Year.php'; |
|
34 | 34 | $c = new Calendar_Year($_GET['y']); |
35 | 35 | break; |
36 | 36 | case 'calendar_month': |
37 | - require_once CALENDAR_ROOT.'Month.php'; |
|
38 | - $c = new Calendar_Month($_GET['y'],$_GET['m']); |
|
37 | + require_once CALENDAR_ROOT . 'Month.php'; |
|
38 | + $c = new Calendar_Month($_GET['y'], $_GET['m']); |
|
39 | 39 | break; |
40 | 40 | case 'calendar_day': |
41 | - require_once CALENDAR_ROOT.'Day.php'; |
|
42 | - $c = new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']); |
|
41 | + require_once CALENDAR_ROOT . 'Day.php'; |
|
42 | + $c = new Calendar_Day($_GET['y'], $_GET['m'], $_GET['d']); |
|
43 | 43 | break; |
44 | 44 | case 'calendar_hour': |
45 | - require_once CALENDAR_ROOT.'Hour.php'; |
|
46 | - $c = new Calendar_Hour($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h']); |
|
45 | + require_once CALENDAR_ROOT . 'Hour.php'; |
|
46 | + $c = new Calendar_Hour($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h']); |
|
47 | 47 | break; |
48 | 48 | case 'calendar_minute': |
49 | - require_once CALENDAR_ROOT.'Minute.php'; |
|
50 | - $c = new Calendar_Minute($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i']); |
|
49 | + require_once CALENDAR_ROOT . 'Minute.php'; |
|
50 | + $c = new Calendar_Minute($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i']); |
|
51 | 51 | break; |
52 | 52 | case 'calendar_second': |
53 | - require_once CALENDAR_ROOT.'Second.php'; |
|
54 | - $c = new Calendar_Second($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i'],$_GET['s']); |
|
53 | + require_once CALENDAR_ROOT . 'Second.php'; |
|
54 | + $c = new Calendar_Second($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i'], $_GET['s']); |
|
55 | 55 | break; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Convert timestamp to human readable date |
59 | 59 | $date = new Date($c->getTimestamp()); |
60 | 60 | |
61 | -echo ( '<h1>Using PEAR::Date engine</h1>' ); |
|
62 | -echo ( 'Viewing: '.@$_GET['view'].'<br />' ); |
|
63 | -echo ( 'The time is now: '.$date->format('%Y %a %e %T').'<br >' ); |
|
61 | +echo ('<h1>Using PEAR::Date engine</h1>'); |
|
62 | +echo ('Viewing: ' . @$_GET['view'] . '<br />'); |
|
63 | +echo ('The time is now: ' . $date->format('%Y %a %e %T') . '<br >'); |
|
64 | 64 | |
65 | 65 | $i = 1; |
66 | -echo ( '<h1>First Iteration</h1>' ); |
|
67 | -echo ( '<p>The first iteration is more "expensive", the calendar data |
|
66 | +echo ('<h1>First Iteration</h1>'); |
|
67 | +echo ('<p>The first iteration is more "expensive", the calendar data |
|
68 | 68 | structures having to be built.</p>' ); |
69 | 69 | $start = getmicrotime(); |
70 | 70 | $c->build(); |
71 | -while ( $e = $c->fetch() ) { |
|
71 | +while ($e = $c->fetch()) { |
|
72 | 72 | $class = strtolower(get_class($e)); |
73 | - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). |
|
74 | - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); |
|
75 | - $method = 'this'.str_replace('calendar_','',$class); |
|
76 | - echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " ); |
|
77 | - if ( ($i % 10) == 0 ) { |
|
78 | - echo ( '<br>' ); |
|
73 | + $link = "&y=" . $e->thisYear() . "&m=" . $e->thisMonth() . "&d=" . $e->thisDay() . |
|
74 | + "&h=" . $e->thisHour() . "&i=" . $e->thisMinute() . "&s=" . $e->thisSecond(); |
|
75 | + $method = 'this' . str_replace('calendar_', '', $class); |
|
76 | + echo ("<a href=\"" . $_SERVER['PHP_SELF'] . "?view=" . $class . $link . "\">" . $e->{$method}() . "</a> : "); |
|
77 | + if (($i % 10) == 0) { |
|
78 | + echo ('<br>'); |
|
79 | 79 | } |
80 | 80 | ++$i; |
81 | 81 | } |
82 | -echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' ); |
|
82 | +echo ('<p><b>Took: ' . (getmicrotime() - $start) . ' seconds</b></p>'); |
|
83 | 83 | |
84 | 84 | $i = 1; |
85 | -echo ( '<h1>Second Iteration</h1>' ); |
|
86 | -echo ( '<p>This second iteration is faster, the data structures |
|
85 | +echo ('<h1>Second Iteration</h1>'); |
|
86 | +echo ('<p>This second iteration is faster, the data structures |
|
87 | 87 | being re-used</p>' ); |
88 | 88 | $start = getmicrotime(); |
89 | -while ( $e = $c->fetch() ) { |
|
89 | +while ($e = $c->fetch()) { |
|
90 | 90 | $class = strtolower(get_class($e)); |
91 | - $link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay(). |
|
92 | - "&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond(); |
|
93 | - $method = 'this'.str_replace('calendar_','',$class); |
|
94 | - echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " ); |
|
95 | - if ( ($i % 10) == 0 ) { |
|
96 | - echo ( '<br>' ); |
|
91 | + $link = "&y=" . $e->thisYear() . "&m=" . $e->thisMonth() . "&d=" . $e->thisDay() . |
|
92 | + "&h=" . $e->thisHour() . "&i=" . $e->thisMinute() . "&s=" . $e->thisSecond(); |
|
93 | + $method = 'this' . str_replace('calendar_', '', $class); |
|
94 | + echo ("<a href=\"" . $_SERVER['PHP_SELF'] . "?view=" . $class . $link . "\">" . $e->{$method}() . "</a> : "); |
|
95 | + if (($i % 10) == 0) { |
|
96 | + echo ('<br>'); |
|
97 | 97 | } |
98 | 98 | ++$i; |
99 | 99 | } |
100 | -echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' ); |
|
100 | +echo ('<p><b>Took: ' . (getmicrotime() - $start) . ' seconds</b></p>'); |
@@ -19,12 +19,24 @@ |
||
19 | 19 | define('CALENDAR_ROOT','../../'); |
20 | 20 | } |
21 | 21 | |
22 | -if (!isset($_GET['y'])) $_GET['y'] = 2003; |
|
23 | -if (!isset($_GET['m'])) $_GET['m'] = 8; |
|
24 | -if (!isset($_GET['d'])) $_GET['d'] = 9; |
|
25 | -if (!isset($_GET['h'])) $_GET['h'] = 12; |
|
26 | -if (!isset($_GET['i'])) $_GET['i'] = 34; |
|
27 | -if (!isset($_GET['s'])) $_GET['s'] = 46; |
|
22 | +if (!isset($_GET['y'])) { |
|
23 | + $_GET['y'] = 2003; |
|
24 | +} |
|
25 | +if (!isset($_GET['m'])) { |
|
26 | + $_GET['m'] = 8; |
|
27 | +} |
|
28 | +if (!isset($_GET['d'])) { |
|
29 | + $_GET['d'] = 9; |
|
30 | +} |
|
31 | +if (!isset($_GET['h'])) { |
|
32 | + $_GET['h'] = 12; |
|
33 | +} |
|
34 | +if (!isset($_GET['i'])) { |
|
35 | + $_GET['i'] = 34; |
|
36 | +} |
|
37 | +if (!isset($_GET['s'])) { |
|
38 | + $_GET['s'] = 46; |
|
39 | +} |
|
28 | 40 | |
29 | 41 | switch (@$_GET['view']) { |
30 | 42 | default: |
@@ -6,9 +6,9 @@ discard block |
||
6 | 6 | if (!@include 'Calendar/Calendar.php') { |
7 | 7 | define('CALENDAR_ROOT', '../../'); |
8 | 8 | } |
9 | -require_once CALENDAR_ROOT.'Day.php'; |
|
10 | -require_once CALENDAR_ROOT.'Month/Weekdays.php'; |
|
11 | -require_once CALENDAR_ROOT.'Decorator/Textual.php'; |
|
9 | +require_once CALENDAR_ROOT . 'Day.php'; |
|
10 | +require_once CALENDAR_ROOT . 'Month/Weekdays.php'; |
|
11 | +require_once CALENDAR_ROOT . 'Decorator/Textual.php'; |
|
12 | 12 | |
13 | 13 | // Could change language like this |
14 | 14 | // setlocale (LC_TIME, "de_DE"); // Unix based (probably) |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | // Decorate |
29 | 29 | $Textual = new Calendar_Decorator_Textual($Calendar); |
30 | 30 | |
31 | -echo '<hr>Previous month is: '.$Textual->prevMonthName('two').'<br />'; |
|
32 | -echo 'This month is: '.$Textual->thisMonthName('short').'<br />'; |
|
33 | -echo 'Next month is: '.$Textual->nextMonthName().'<br /><hr />'; |
|
34 | -echo 'Previous day is: '.$Textual->prevDayName().'<br />'; |
|
35 | -echo 'This day is: '.$Textual->thisDayName('short').'<br />'; |
|
36 | -echo 'Next day is: '.$Textual->nextDayName('one').'<br /><hr />'; |
|
31 | +echo '<hr>Previous month is: ' . $Textual->prevMonthName('two') . '<br />'; |
|
32 | +echo 'This month is: ' . $Textual->thisMonthName('short') . '<br />'; |
|
33 | +echo 'Next month is: ' . $Textual->nextMonthName() . '<br /><hr />'; |
|
34 | +echo 'Previous day is: ' . $Textual->prevDayName() . '<br />'; |
|
35 | +echo 'This day is: ' . $Textual->thisDayName('short') . '<br />'; |
|
36 | +echo 'Next day is: ' . $Textual->nextDayName('one') . '<br /><hr />'; |
|
37 | 37 | |
38 | 38 | echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week<br />"; |
39 | 39 | $Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6); |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | ?> |
44 | 44 | <p>Rendering calendar....</p> |
45 | 45 | <table> |
46 | -<caption><?php echo $Textual->thisMonthName().' '.$Textual->thisYear(); ?></caption> |
|
46 | +<caption><?php echo $Textual->thisMonthName() . ' ' . $Textual->thisYear(); ?></caption> |
|
47 | 47 | <tr> |
48 | 48 | <?php |
49 | 49 | $dayheaders = $Textual->orderedWeekdays('short'); |
50 | 50 | foreach ($dayheaders as $dayheader) { |
51 | - echo '<th>'.$dayheader.'</th>'; |
|
51 | + echo '<th>' . $dayheader . '</th>'; |
|
52 | 52 | } |
53 | 53 | ?> |
54 | 54 | </tr> |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | if ($Day->isEmpty()) { |
62 | 62 | echo '<td> </td>'; |
63 | 63 | } else { |
64 | - echo '<td>'.$Day->thisDay().'</td>'; |
|
64 | + echo '<td>' . $Day->thisDay() . '</td>'; |
|
65 | 65 | } |
66 | 66 | if ($Day->isLast()) { |
67 | 67 | echo "</tr>\n"; |
@@ -3,13 +3,13 @@ |
||
3 | 3 | * Description: simple example on i18N |
4 | 4 | */ |
5 | 5 | if (!@include 'Calendar/Calendar.php') { |
6 | - define('CALENDAR_ROOT','../../'); |
|
6 | + define('CALENDAR_ROOT', '../../'); |
|
7 | 7 | } |
8 | -require_once CALENDAR_ROOT.'Day.php'; |
|
8 | +require_once CALENDAR_ROOT . 'Day.php'; |
|
9 | 9 | |
10 | -$Day = new Calendar_Day(2003,10,23); |
|
10 | +$Day = new Calendar_Day(2003, 10, 23); |
|
11 | 11 | |
12 | -setlocale (LC_TIME, "de_DE"); // Unix based (probably) |
|
12 | +setlocale(LC_TIME, "de_DE"); // Unix based (probably) |
|
13 | 13 | // setlocale (LC_TIME, "ge"); // Windows |
14 | 14 | |
15 | -echo ( strftime('%A %d %B %Y',$Day->getTimeStamp())); |
|
15 | +echo (strftime('%A %d %B %Y', $Day->getTimeStamp())); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | if (!@include 'Calendar/Calendar.php') { |
14 | 14 | define('CALENDAR_ROOT', '../../'); |
15 | 15 | } |
16 | -require_once CALENDAR_ROOT.'Second.php'; |
|
16 | +require_once CALENDAR_ROOT . 'Second.php'; |
|
17 | 17 | |
18 | 18 | if (!isset($_GET['y'])) $_GET['y'] = date('Y'); |
19 | 19 | if (!isset($_GET['m'])) $_GET['m'] = date('n'); |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | |
25 | 25 | $Unit = new Calendar_Second($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i'], $_GET['s']); |
26 | 26 | |
27 | -echo '<p><b>Result:</b> '.$Unit->thisYear().'-'.$Unit->thisMonth().'-'.$Unit->thisDay(). |
|
28 | - ' '.$Unit->thisHour().':'.$Unit->thisMinute().':'.$Unit->thisSecond(); |
|
27 | +echo '<p><b>Result:</b> ' . $Unit->thisYear() . '-' . $Unit->thisMonth() . '-' . $Unit->thisDay() . |
|
28 | + ' ' . $Unit->thisHour() . ':' . $Unit->thisMinute() . ':' . $Unit->thisSecond(); |
|
29 | 29 | if ($Unit->isValid()) { |
30 | 30 | echo ' is valid!</p>'; |
31 | 31 | } else { |
32 | - $V= & $Unit->getValidator(); |
|
32 | + $V = & $Unit->getValidator(); |
|
33 | 33 | echo ' is invalid:</p>'; |
34 | 34 | while ($error = $V->fetch()) { |
35 | - echo $error->toString() .'<br />'; |
|
35 | + echo $error->toString() . '<br />'; |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | ?> |
@@ -48,4 +48,4 @@ discard block |
||
48 | 48 | </form> |
49 | 49 | <p><b>Note:</b> Error messages can be controlled with the constants <code>CALENDAR_VALUE_TOOSMALL</code> and <code>CALENDAR_VALUE_TOOLARGE</code> - see <code>Calendar_Validator.php</code></p> |
50 | 50 | |
51 | -<?php echo '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>'; |
|
51 | +<?php echo '<p><b>Took: ' . (getmicrotime() - $start) . ' seconds</b></p>'; |
@@ -15,12 +15,24 @@ |
||
15 | 15 | } |
16 | 16 | require_once CALENDAR_ROOT.'Second.php'; |
17 | 17 | |
18 | -if (!isset($_GET['y'])) $_GET['y'] = date('Y'); |
|
19 | -if (!isset($_GET['m'])) $_GET['m'] = date('n'); |
|
20 | -if (!isset($_GET['d'])) $_GET['d'] = date('j'); |
|
21 | -if (!isset($_GET['h'])) $_GET['h'] = date('H'); |
|
22 | -if (!isset($_GET['i'])) $_GET['i'] = date('i'); |
|
23 | -if (!isset($_GET['s'])) $_GET['s'] = date('s'); |
|
18 | +if (!isset($_GET['y'])) { |
|
19 | + $_GET['y'] = date('Y'); |
|
20 | +} |
|
21 | +if (!isset($_GET['m'])) { |
|
22 | + $_GET['m'] = date('n'); |
|
23 | +} |
|
24 | +if (!isset($_GET['d'])) { |
|
25 | + $_GET['d'] = date('j'); |
|
26 | +} |
|
27 | +if (!isset($_GET['h'])) { |
|
28 | + $_GET['h'] = date('H'); |
|
29 | +} |
|
30 | +if (!isset($_GET['i'])) { |
|
31 | + $_GET['i'] = date('i'); |
|
32 | +} |
|
33 | +if (!isset($_GET['s'])) { |
|
34 | + $_GET['s'] = date('s'); |
|
35 | +} |
|
24 | 36 | |
25 | 37 | $Unit = new Calendar_Second($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i'], $_GET['s']); |
26 | 38 |
@@ -19,15 +19,15 @@ discard block |
||
19 | 19 | class MonthDecorator extends Calendar_Decorator |
20 | 20 | { |
21 | 21 | /** |
22 | - * @param Calendar_Month |
|
23 | - */ |
|
22 | + * @param Calendar_Month |
|
23 | + */ |
|
24 | 24 | function MonthDecorator(& $Month) |
25 | 25 | { |
26 | 26 | parent::Calendar_Decorator($Month); |
27 | 27 | } |
28 | 28 | /** |
29 | - * Override the prevMonth method to format the output |
|
30 | - */ |
|
29 | + * Override the prevMonth method to format the output |
|
30 | + */ |
|
31 | 31 | function prevMonth() |
32 | 32 | { |
33 | 33 | $prevStamp = parent::prevMonth(TRUE); |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | '&m='.date('n',$prevStamp).'&d='.date('j',$prevStamp); |
37 | 37 | } |
38 | 38 | /** |
39 | - * Override the thisMonth method to format the output |
|
40 | - */ |
|
39 | + * Override the thisMonth method to format the output |
|
40 | + */ |
|
41 | 41 | function thisMonth() |
42 | 42 | { |
43 | 43 | $thisStamp = parent::thisMonth(TRUE); |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | return date('F Y',$thisStamp); |
46 | 46 | } |
47 | 47 | /** |
48 | - * Override the nextMonth method to format the output |
|
49 | - */ |
|
48 | + * Override the nextMonth method to format the output |
|
49 | + */ |
|
50 | 50 | function nextMonth() |
51 | 51 | { |
52 | 52 | $nextStamp = parent::nextMonth(TRUE); |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | * format the month while the days are accessed via the normal Month object |
8 | 8 | */ |
9 | 9 | if (!@include 'Calendar/Calendar.php') { |
10 | - define('CALENDAR_ROOT','../../'); |
|
10 | + define('CALENDAR_ROOT', '../../'); |
|
11 | 11 | } |
12 | -require_once CALENDAR_ROOT.'Month/Weekdays.php'; |
|
13 | -require_once CALENDAR_ROOT.'Decorator.php'; |
|
12 | +require_once CALENDAR_ROOT . 'Month/Weekdays.php'; |
|
13 | +require_once CALENDAR_ROOT . 'Decorator.php'; |
|
14 | 14 | |
15 | 15 | // Decorate a Month with methods to improve formatting |
16 | 16 | /** |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | { |
33 | 33 | $prevStamp = parent::prevMonth(TRUE); |
34 | 34 | // Build the URL for the previous month |
35 | - return $_SERVER['PHP_SELF'].'?y='.date('Y',$prevStamp). |
|
36 | - '&m='.date('n',$prevStamp).'&d='.date('j',$prevStamp); |
|
35 | + return $_SERVER['PHP_SELF'] . '?y=' . date('Y', $prevStamp) . |
|
36 | + '&m=' . date('n', $prevStamp) . '&d=' . date('j', $prevStamp); |
|
37 | 37 | } |
38 | 38 | /** |
39 | 39 | * Override the thisMonth method to format the output |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | $thisStamp = parent::thisMonth(TRUE); |
44 | 44 | // A human readable string from this month |
45 | - return date('F Y',$thisStamp); |
|
45 | + return date('F Y', $thisStamp); |
|
46 | 46 | } |
47 | 47 | /** |
48 | 48 | * Override the nextMonth method to format the output |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | { |
52 | 52 | $nextStamp = parent::nextMonth(TRUE); |
53 | 53 | // Build the URL for next month |
54 | - return $_SERVER['PHP_SELF'].'?y='.date('Y',$nextStamp). |
|
55 | - '&m='.date('n',$nextStamp).'&d='.date('j',$nextStamp); |
|
54 | + return $_SERVER['PHP_SELF'] . '?y=' . date('Y', $nextStamp) . |
|
55 | + '&m=' . date('n', $nextStamp) . '&d=' . date('j', $nextStamp); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if (!isset($_GET['m'])) $_GET['m'] = date('n'); |
61 | 61 | |
62 | 62 | // Creata a month as usual |
63 | -$Month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']); |
|
63 | +$Month = new Calendar_Month_Weekdays($_GET['y'], $_GET['m']); |
|
64 | 64 | |
65 | 65 | // Pass it to the decorator and use the decorator from now on... |
66 | 66 | $MonthDecorator = new MonthDecorator($Month); |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | <body> |
76 | 76 | <h1>A Simple Decorator</h1> |
77 | 77 | <table> |
78 | -<caption><?php echo ( $MonthDecorator->thisMonth() ); ?></caption> |
|
78 | +<caption><?php echo ($MonthDecorator->thisMonth()); ?></caption> |
|
79 | 79 | <?php |
80 | -while ( $Day = $MonthDecorator->fetch() ) { |
|
81 | - if ( $Day->isFirst() ) { |
|
82 | - echo ( "\n<tr>\n" ); |
|
80 | +while ($Day = $MonthDecorator->fetch()) { |
|
81 | + if ($Day->isFirst()) { |
|
82 | + echo ("\n<tr>\n"); |
|
83 | 83 | } |
84 | - if ( $Day->isEmpty() ) { |
|
85 | - echo ( "<td> </td>" ); |
|
84 | + if ($Day->isEmpty()) { |
|
85 | + echo ("<td> </td>"); |
|
86 | 86 | } else { |
87 | - echo ( "<td>".$Day->thisDay()."</td>" ); |
|
87 | + echo ("<td>" . $Day->thisDay() . "</td>"); |
|
88 | 88 | } |
89 | - if ( $Day->isLast() ) { |
|
90 | - echo ( "\n</tr>\n" ); |
|
89 | + if ($Day->isLast()) { |
|
90 | + echo ("\n</tr>\n"); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | ?> |
@@ -56,8 +56,12 @@ |
||
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | -if (!isset($_GET['y'])) $_GET['y'] = date('Y'); |
|
60 | -if (!isset($_GET['m'])) $_GET['m'] = date('n'); |
|
59 | +if (!isset($_GET['y'])) { |
|
60 | + $_GET['y'] = date('Y'); |
|
61 | +} |
|
62 | +if (!isset($_GET['m'])) { |
|
63 | + $_GET['m'] = date('n'); |
|
64 | +} |
|
61 | 65 | |
62 | 66 | // Creata a month as usual |
63 | 67 | $Month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']); |