@@ -96,41 +96,41 @@ |
||
96 | 96 | { |
97 | 97 | $firstDay = defined('CALENDAR_FIRST_DAY_OF_WEEK') ? CALENDAR_FIRST_DAY_OF_WEEK : 1; |
98 | 98 | switch ($type) { |
99 | - case 'Day': |
|
100 | - return new Day($y, $m, $d); |
|
101 | - case 'Month': |
|
102 | - // Set default state for which month type to build |
|
103 | - if (!defined('CALENDAR_MONTH_STATE')) { |
|
104 | - define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH); |
|
105 | - } |
|
106 | - switch (CALENDAR_MONTH_STATE) { |
|
107 | - case CALENDAR_USE_MONTH_WEEKDAYS: |
|
108 | - $class = 'Calendar_Month_Weekdays'; |
|
109 | - break; |
|
110 | - case CALENDAR_USE_MONTH_WEEKS: |
|
111 | - $class = 'Calendar_Month_Weeks'; |
|
112 | - break; |
|
113 | - case CALENDAR_USE_MONTH: |
|
114 | - default: |
|
115 | - $class = 'Pear\Calendar\Month'; |
|
116 | - break; |
|
117 | - } |
|
99 | + case 'Day': |
|
100 | + return new Day($y, $m, $d); |
|
101 | + case 'Month': |
|
102 | + // Set default state for which month type to build |
|
103 | + if (!defined('CALENDAR_MONTH_STATE')) { |
|
104 | + define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH); |
|
105 | + } |
|
106 | + switch (CALENDAR_MONTH_STATE) { |
|
107 | + case CALENDAR_USE_MONTH_WEEKDAYS: |
|
108 | + $class = 'Calendar_Month_Weekdays'; |
|
109 | + break; |
|
110 | + case CALENDAR_USE_MONTH_WEEKS: |
|
111 | + $class = 'Calendar_Month_Weeks'; |
|
112 | + break; |
|
113 | + case CALENDAR_USE_MONTH: |
|
114 | + default: |
|
115 | + $class = 'Pear\Calendar\Month'; |
|
116 | + break; |
|
117 | + } |
|
118 | 118 | return new $class($y, $m, $firstDay); |
119 | - case 'Week': |
|
120 | - return new Week($y, $m, $d, $firstDay); |
|
121 | - case 'Hour': |
|
122 | - return new Hour($y, $m, $d, $h); |
|
123 | - case 'Minute': |
|
124 | - return new Minute($y, $m, $d, $h, $i); |
|
125 | - case 'Second': |
|
126 | - return new Second($y, $m, $d, $h, $i, $s); |
|
127 | - case 'Year': |
|
128 | - return new Year($y); |
|
129 | - default: |
|
130 | - include_once 'PEAR.php'; |
|
131 | - PEAR::raiseError('Calendar_Factory::create() unrecognised type: '.$type, |
|
132 | - null, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar_Factory::create()'); |
|
133 | - return false; |
|
119 | + case 'Week': |
|
120 | + return new Week($y, $m, $d, $firstDay); |
|
121 | + case 'Hour': |
|
122 | + return new Hour($y, $m, $d, $h); |
|
123 | + case 'Minute': |
|
124 | + return new Minute($y, $m, $d, $h, $i); |
|
125 | + case 'Second': |
|
126 | + return new Second($y, $m, $d, $h, $i, $s); |
|
127 | + case 'Year': |
|
128 | + return new Year($y); |
|
129 | + default: |
|
130 | + include_once 'PEAR.php'; |
|
131 | + PEAR::raiseError('Calendar_Factory::create() unrecognised type: '.$type, |
|
132 | + null, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar_Factory::create()'); |
|
133 | + return false; |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @access public |
82 | 82 | */ |
83 | - function __construct($y, $m, $firstDay=null) |
|
83 | + function __construct($y, $m, $firstDay = null) |
|
84 | 84 | { |
85 | 85 | parent::__construct($y, $m); |
86 | 86 | $this->firstDay = $this->defineFirstDayOfWeek($firstDay); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | include_once CALENDAR_ROOT.'Day.php'; |
101 | 101 | $daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month); |
102 | - for ($i=1; $i<=$daysInMonth; $i++) { |
|
102 | + for ($i = 1; $i <= $daysInMonth; $i++) { |
|
103 | 103 | $this->children[$i] = new Day($this->year, $this->month, $i); |
104 | 104 | } |
105 | 105 | if (count($sDates) > 0) { |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | $stamp = mktime(0, 0, 0, $i, 1, 2003); |
97 | 97 | $month = strftime($formats[$format], $stamp); |
98 | 98 | switch($format) { |
99 | - case 'one': |
|
100 | - $month = substr($month, 0, 1); |
|
101 | - break; |
|
102 | - case 'two': |
|
103 | - $month = substr($month, 0, 2); |
|
104 | - break; |
|
99 | + case 'one': |
|
100 | + $month = substr($month, 0, 1); |
|
101 | + break; |
|
102 | + case 'two': |
|
103 | + $month = substr($month, 0, 2); |
|
104 | + break; |
|
105 | 105 | } |
106 | 106 | $months[$i] = $month; |
107 | 107 | } |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | $stamp = mktime(0, 0, 0, 11, $i+2, 2003); |
134 | 134 | $day = strftime($formats[$format], $stamp); |
135 | 135 | switch($format) { |
136 | - case 'one': |
|
137 | - $day = substr($day, 0, 1); |
|
138 | - break; |
|
139 | - case 'two': |
|
140 | - $day = substr($day, 0, 2); |
|
141 | - break; |
|
136 | + case 'one': |
|
137 | + $day = substr($day, 0, 1); |
|
138 | + break; |
|
139 | + case 'two': |
|
140 | + $day = substr($day, 0, 2); |
|
141 | + break; |
|
142 | 142 | } |
143 | 143 | $days[$i] = $day; |
144 | 144 | } |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | $format = 'long'; |
81 | 81 | } |
82 | 82 | $months = array(); |
83 | - for ($i=1; $i<=12; $i++) { |
|
83 | + for ($i = 1; $i <= 12; $i++) { |
|
84 | 84 | $stamp = mktime(0, 0, 0, $i, 1, 2003); |
85 | 85 | $month = strftime($formats[$format], $stamp); |
86 | - switch($format) { |
|
86 | + switch ($format) { |
|
87 | 87 | case 'one': |
88 | 88 | $month = substr($month, 0, 1); |
89 | 89 | break; |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | $format = 'long'; |
118 | 118 | } |
119 | 119 | $days = array(); |
120 | - for ($i=0; $i<=6; $i++) { |
|
121 | - $stamp = mktime(0, 0, 0, 11, $i+2, 2003); |
|
120 | + for ($i = 0; $i <= 6; $i++) { |
|
121 | + $stamp = mktime(0, 0, 0, 11, $i + 2, 2003); |
|
122 | 122 | $day = strftime($formats[$format], $stamp); |
123 | - switch($format) { |
|
123 | + switch ($format) { |
|
124 | 124 | case 'one': |
125 | 125 | $day = substr($day, 0, 1); |
126 | 126 | break; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @access public |
213 | 213 | * @static |
214 | 214 | */ |
215 | - function thisDayName($Calendar, $format='long') |
|
215 | + function thisDayName($Calendar, $format = 'long') |
|
216 | 216 | { |
217 | 217 | $days = Textual::weekdayNames($format); |
218 | 218 | $stamp = $Calendar->thisDay('timestamp'); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @access public |
232 | 232 | * @static |
233 | 233 | */ |
234 | - function nextDayName($Calendar, $format='long') |
|
234 | + function nextDayName($Calendar, $format = 'long') |
|
235 | 235 | { |
236 | 236 | $days = Textual::weekdayNames($format); |
237 | 237 | $stamp = $Calendar->nextDay('timestamp'); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | //check if defined / set |
265 | 265 | if (defined('CALENDAR_FIRST_DAY_OF_WEEK')) { |
266 | 266 | $firstDay = CALENDAR_FIRST_DAY_OF_WEEK; |
267 | - } elseif(isset($Calendar->firstDay)) { |
|
267 | + } elseif (isset($Calendar->firstDay)) { |
|
268 | 268 | $firstDay = $Calendar->firstDay; |
269 | 269 | } |
270 | 270 | $ordereddays = array(); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @access public |
100 | 100 | */ |
101 | - function __construct($y, $m=null, $d=null, $h=null, $i=null, $s=null) |
|
101 | + function __construct($y, $m = null, $d = null, $h = null, $i = null, $s = null) |
|
102 | 102 | { |
103 | 103 | $this->setFragments($y, $m, $d, $h, $i, $s); |
104 | 104 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @return void |
117 | 117 | * @access public |
118 | 118 | */ |
119 | - function setFragments($y, $m=null, $d=null, $h=null, $i=null, $s=null) |
|
119 | + function setFragments($y, $m = null, $d = null, $h = null, $i = null, $s = null) |
|
120 | 120 | { |
121 | 121 | if (!is_null($y)) $this->uris['Year'] = $y; |
122 | 122 | if (!is_null($m)) $this->uris['Month'] = $m; |
@@ -118,12 +118,24 @@ |
||
118 | 118 | */ |
119 | 119 | function setFragments($y, $m=null, $d=null, $h=null, $i=null, $s=null) |
120 | 120 | { |
121 | - if (!is_null($y)) $this->uris['Year'] = $y; |
|
122 | - if (!is_null($m)) $this->uris['Month'] = $m; |
|
123 | - if (!is_null($d)) $this->uris['Day'] = $d; |
|
124 | - if (!is_null($h)) $this->uris['Hour'] = $h; |
|
125 | - if (!is_null($i)) $this->uris['Minute'] = $i; |
|
126 | - if (!is_null($s)) $this->uris['Second'] = $s; |
|
121 | + if (!is_null($y)) { |
|
122 | + $this->uris['Year'] = $y; |
|
123 | + } |
|
124 | + if (!is_null($m)) { |
|
125 | + $this->uris['Month'] = $m; |
|
126 | + } |
|
127 | + if (!is_null($d)) { |
|
128 | + $this->uris['Day'] = $d; |
|
129 | + } |
|
130 | + if (!is_null($h)) { |
|
131 | + $this->uris['Hour'] = $h; |
|
132 | + } |
|
133 | + if (!is_null($i)) { |
|
134 | + $this->uris['Minute'] = $i; |
|
135 | + } |
|
136 | + if (!is_null($s)) { |
|
137 | + $this->uris['Second'] = $s; |
|
138 | + } |
|
127 | 139 | } |
128 | 140 | |
129 | 141 | /** |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return int e.g. 4 or Unix timestamp |
395 | 395 | * @access public |
396 | - */ |
|
396 | + */ |
|
397 | 397 | function prevMonth($format = 'int') |
398 | 398 | { |
399 | 399 | return $this->calendar->prevMonth($format); |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * |
433 | 433 | * @return int e.g. 4 or Unix timestamp |
434 | 434 | * @access public |
435 | - */ |
|
435 | + */ |
|
436 | 436 | function prevWeek($format = 'n_in_month') |
437 | 437 | { |
438 | 438 | if ( method_exists($this->calendar, 'prevWeek')) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @return void |
241 | 241 | * @access private |
242 | 242 | */ |
243 | - function setEmpty ($state = true) |
|
243 | + function setEmpty($state = true) |
|
244 | 244 | { |
245 | 245 | if (method_exists($this->calendar, 'setEmpty')) { |
246 | 246 | $this->calendar->setEmpty($state); |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | */ |
436 | 436 | function prevWeek($format = 'n_in_month') |
437 | 437 | { |
438 | - if ( method_exists($this->calendar, 'prevWeek')) { |
|
438 | + if (method_exists($this->calendar, 'prevWeek')) { |
|
439 | 439 | return $this->calendar->prevWeek($format); |
440 | 440 | } else { |
441 | 441 | include_once 'PEAR.php'; |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | */ |
458 | 458 | function thisWeek($format = 'n_in_month') |
459 | 459 | { |
460 | - if ( method_exists($this->calendar, 'thisWeek')) { |
|
460 | + if (method_exists($this->calendar, 'thisWeek')) { |
|
461 | 461 | return $this->calendar->thisWeek($format); |
462 | 462 | } else { |
463 | 463 | include_once 'PEAR.php'; |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | */ |
480 | 480 | function nextWeek($format = 'n_in_month') |
481 | 481 | { |
482 | - if ( method_exists($this->calendar, 'nextWeek')) { |
|
482 | + if (method_exists($this->calendar, 'nextWeek')) { |
|
483 | 483 | return $this->calendar->nextWeek($format); |
484 | 484 | } else { |
485 | 485 | include_once 'PEAR.php'; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @access public |
115 | 115 | */ |
116 | - function __construct($y, $m, $firstDay=null) |
|
116 | + function __construct($y, $m, $firstDay = null) |
|
117 | 117 | { |
118 | 118 | parent::__construct($y, $m, $firstDay); |
119 | 119 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | function buildEmptyDaysBefore() |
152 | 152 | { |
153 | 153 | $eBefore = $this->tableHelper->getEmptyDaysBefore(); |
154 | - for ($i=0; $i < $eBefore; $i++) { |
|
154 | + for ($i = 0; $i < $eBefore; $i++) { |
|
155 | 155 | $stamp = $this->cE->dateToStamp($this->year, $this->month, -$i); |
156 | 156 | $Day = new Day( |
157 | 157 | $this->cE->stampToYear($stamp), |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | { |
188 | 188 | $eAfter = $this->tableHelper->getEmptyDaysAfter(); |
189 | 189 | $sDOM = $this->tableHelper->getNumTableDaysInMonth(); |
190 | - for ($i=1; $i <= $sDOM-$eAfter; $i++) { |
|
191 | - $Day = new Day($this->year, $this->month+1, $i); |
|
190 | + for ($i = 1; $i <= $sDOM - $eAfter; $i++) { |
|
191 | + $Day = new Day($this->year, $this->month + 1, $i); |
|
192 | 192 | $Day->setEmpty(); |
193 | 193 | $Day->adjust(); |
194 | 194 | array_push($this->children, $Day); |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | $this->thisDay() |
211 | 211 | ); |
212 | 212 | $sDOM = $this->tableHelper->getNumTableDaysInMonth(); |
213 | - for ($i=1; $i <= $sDOM; $i+= $dIW) { |
|
213 | + for ($i = 1; $i <= $sDOM; $i += $dIW) { |
|
214 | 214 | $this->children[$i]->setFirst(); |
215 | - $this->children[$i+($dIW-1)]->setLast(); |
|
215 | + $this->children[$i + ($dIW - 1)]->setLast(); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @access public |
107 | 107 | */ |
108 | - function __construct($y, $m, $firstDay=null) |
|
108 | + function __construct($y, $m, $firstDay = null) |
|
109 | 109 | { |
110 | 110 | parent::__construct($y, $m, $firstDay); |
111 | 111 | } |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | $this->tableHelper = new Helper($this, $this->firstDay); |
125 | 125 | include_once CALENDAR_ROOT.'Week.php'; |
126 | 126 | $numWeeks = $this->tableHelper->getNumWeeks(); |
127 | - for ($i=1, $d=1; $i<=$numWeeks; $i++, |
|
128 | - $d+=$this->cE->getDaysInWeek( |
|
127 | + for ($i = 1, $d = 1; $i <= $numWeeks; $i++, |
|
128 | + $d += $this->cE->getDaysInWeek( |
|
129 | 129 | $this->thisYear(), |
130 | 130 | $this->thisMonth(), |
131 | 131 | $this->thisDay() |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | 'Hour', $h, CALENDAR_VALUE_TOOSMALL.$min); |
205 | 205 | return false; |
206 | 206 | } |
207 | - $max = ($this->cE->getHoursInDay($this->calendar->thisDay())-1); |
|
207 | + $max = ($this->cE->getHoursInDay($this->calendar->thisDay()) - 1); |
|
208 | 208 | if ($h > $max) { |
209 | 209 | $this->errors[] = new Calendar_Validation_Error( |
210 | 210 | 'Hour', $h, CALENDAR_VALUE_TOOLARGE.$max); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | 'Minute', $i, CALENDAR_VALUE_TOOSMALL.$min); |
229 | 229 | return false; |
230 | 230 | } |
231 | - $max = ($this->cE->getMinutesInHour($this->calendar->thisHour())-1); |
|
231 | + $max = ($this->cE->getMinutesInHour($this->calendar->thisHour()) - 1); |
|
232 | 232 | if ($i > $max) { |
233 | 233 | $this->errors[] = new Calendar_Validation_Error( |
234 | 234 | 'Minute', $i, CALENDAR_VALUE_TOOLARGE.$max); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | 'Second', $s, CALENDAR_VALUE_TOOSMALL.$min); |
253 | 253 | return false; |
254 | 254 | } |
255 | - $max = ($this->cE->getSecondsInMinute($this->calendar->thisMinute())-1); |
|
255 | + $max = ($this->cE->getSecondsInMinute($this->calendar->thisMinute()) - 1); |
|
256 | 256 | if ($s > $max) { |
257 | 257 | $this->errors[] = new Calendar_Validation_Error( |
258 | 258 | 'Second', $s, CALENDAR_VALUE_TOOLARGE.$max); |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @return string |
370 | 370 | * @access public |
371 | 371 | */ |
372 | - function toString () |
|
372 | + function toString() |
|
373 | 373 | { |
374 | 374 | return $this->unit.' = '.$this->value.' ['.$this->message.']'; |
375 | 375 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | include_once CALENDAR_ROOT.'Hour.php'; |
120 | 120 | |
121 | 121 | $hID = $this->cE->getHoursInDay($this->year, $this->month, $this->day); |
122 | - for ($i=0; $i < $hID; $i++) { |
|
122 | + for ($i = 0; $i < $hID; $i++) { |
|
123 | 123 | $this->children[$i] = |
124 | 124 | new Hour($this->year, $this->month, $this->day, $i); |
125 | 125 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @return void |
215 | 215 | * @access private |
216 | 216 | */ |
217 | - function setEmpty ($state = true) |
|
217 | + function setEmpty($state = true) |
|
218 | 218 | { |
219 | 219 | $this->empty = $state; |
220 | 220 | } |