@@ -14,18 +14,18 @@ |
||
| 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 ' |
|
| 17 | +echo ('<p>The current month is ' |
|
| 18 | 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> |
| 32 | 32 | \ No newline at end of file |
@@ -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']); |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | * Description: demonstrates a decorator used to "attach a payload" to a selection |
| 4 | 4 | * to make it available when iterating over calendar children |
| 5 | 5 | */ |
| 6 | -if ( !@include 'Calendar/Calendar.php' ) { |
|
| 7 | - define('CALENDAR_ROOT','../../'); |
|
| 6 | +if (!@include 'Calendar/Calendar.php') { |
|
| 7 | + define('CALENDAR_ROOT', '../../'); |
|
| 8 | 8 | } |
| 9 | 9 | require_once CALENDAR_ROOT.'Day.php'; |
| 10 | 10 | require_once CALENDAR_ROOT.'Hour.php'; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // Create a day to view the hours for |
| 28 | -$Day = & new Calendar_Day(2003,10,24); |
|
| 28 | +$Day = & new Calendar_Day(2003, 10, 24); |
|
| 29 | 29 | |
| 30 | 30 | // A sample query to get the data for today (NOT ACTUALLY USED HERE) |
| 31 | 31 | $sql = " |
@@ -39,18 +39,18 @@ discard block |
||
| 39 | 39 | eventtime < '".$Day->nextDay(TRUE)."';"; |
| 40 | 40 | |
| 41 | 41 | // An array simulating data from a database |
| 42 | -$result = array ( |
|
| 43 | - array('eventtime'=>mktime(9,0,0,10,24,2003),'entry'=>'Meeting with sales team'), |
|
| 44 | - array('eventtime'=>mktime(11,0,0,10,24,2003),'entry'=>'Conference call with Widget Inc.'), |
|
| 45 | - array('eventtime'=>mktime(15,0,0,10,24,2003),'entry'=>'Presentation to board of directors') |
|
| 42 | +$result = array( |
|
| 43 | + array('eventtime'=>mktime(9, 0, 0, 10, 24, 2003), 'entry'=>'Meeting with sales team'), |
|
| 44 | + array('eventtime'=>mktime(11, 0, 0, 10, 24, 2003), 'entry'=>'Conference call with Widget Inc.'), |
|
| 45 | + array('eventtime'=>mktime(15, 0, 0, 10, 24, 2003), 'entry'=>'Presentation to board of directors') |
|
| 46 | 46 | ); |
| 47 | 47 | |
| 48 | 48 | // An array to place selected hours in |
| 49 | 49 | $selection = array(); |
| 50 | 50 | |
| 51 | 51 | // Loop through the "database result" |
| 52 | -foreach ( $result as $row ) { |
|
| 53 | - $Hour = new Calendar_Hour(2000,1,1,1); // Create Hour with dummy values |
|
| 52 | +foreach ($result as $row) { |
|
| 53 | + $Hour = new Calendar_Hour(2000, 1, 1, 1); // Create Hour with dummy values |
|
| 54 | 54 | $Hour->setTimeStamp($row['eventtime']); // Set the real time with setTimeStamp |
| 55 | 55 | |
| 56 | 56 | // Create the decorator, passing it the Hour |
@@ -74,36 +74,36 @@ discard block |
||
| 74 | 74 | <body> |
| 75 | 75 | <h1>Passing a Selection "Payload" using a Decorator</h1> |
| 76 | 76 | <table> |
| 77 | -<caption><b>Your Schedule for <?php echo ( date('D nS F Y',$Day->thisDay(TRUE)) ); ?></b></caption> |
|
| 77 | +<caption><b>Your Schedule for <?php echo (date('D nS F Y', $Day->thisDay(TRUE))); ?></b></caption> |
|
| 78 | 78 | <tr> |
| 79 | 79 | <th width="5%">Time</th> |
| 80 | 80 | <th>Entry</th> |
| 81 | 81 | </tr> |
| 82 | 82 | <?php |
| 83 | -while ( $Hour = & $Day->fetch() ) { |
|
| 83 | +while ($Hour = & $Day->fetch()) { |
|
| 84 | 84 | |
| 85 | 85 | $hour = $Hour->thisHour(); |
| 86 | 86 | $minute = $Hour->thisMinute(); |
| 87 | 87 | |
| 88 | 88 | // Office hours only... |
| 89 | - if ( $hour >= 8 && $hour <= 18 ) { |
|
| 90 | - echo ( "<tr>\n" ); |
|
| 91 | - echo ( "<td>$hour:$minute</td>\n" ); |
|
| 89 | + if ($hour >= 8 && $hour <= 18) { |
|
| 90 | + echo ("<tr>\n"); |
|
| 91 | + echo ("<td>$hour:$minute</td>\n"); |
|
| 92 | 92 | |
| 93 | 93 | // If the hour is selected, call the decorator method... |
| 94 | - if ( $Hour->isSelected() ) { |
|
| 95 | - echo ( "<td bgcolor=\"silver\">".$Hour->getEntry()."</td>\n" ); |
|
| 94 | + if ($Hour->isSelected()) { |
|
| 95 | + echo ("<td bgcolor=\"silver\">".$Hour->getEntry()."</td>\n"); |
|
| 96 | 96 | } else { |
| 97 | - echo ( "<td> </td>\n" ); |
|
| 97 | + echo ("<td> </td>\n"); |
|
| 98 | 98 | } |
| 99 | - echo ( "</tr>\n" ); |
|
| 99 | + echo ("</tr>\n"); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | ?> |
| 103 | 103 | </table> |
| 104 | 104 | <p>The query to fetch this data, with help from PEAR::Calendar, might be;</p> |
| 105 | 105 | <pre> |
| 106 | -<?php echo ( $sql ); ?> |
|
| 106 | +<?php echo ($sql); ?> |
|
| 107 | 107 | </pre> |
| 108 | 108 | </body> |
| 109 | 109 | </html> |
| 110 | 110 | \ No newline at end of file |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | echo "<hr>Creating: new Calendar_Day(date('Y'), date('n'), date('d'));<br />"; |
| 26 | 26 | $Calendar = new Calendar_Day(date('Y'), date('n'), date('d')); |
| 27 | 27 | |
| 28 | -echo '<hr>Previous month is: '.Calendar_Util_Textual::prevMonthName($Calendar,'two').'<br />'; |
|
| 29 | -echo 'This month is: '.Calendar_Util_Textual::thisMonthName($Calendar,'short').'<br />'; |
|
| 28 | +echo '<hr>Previous month is: '.Calendar_Util_Textual::prevMonthName($Calendar, 'two').'<br />'; |
|
| 29 | +echo 'This month is: '.Calendar_Util_Textual::thisMonthName($Calendar, 'short').'<br />'; |
|
| 30 | 30 | echo 'Next month is: '.Calendar_Util_Textual::nextMonthName($Calendar).'<br /><hr />'; |
| 31 | 31 | echo 'Previous day is: '.Calendar_Util_Textual::prevDayName($Calendar).'<br />'; |
| 32 | -echo 'This day is: '.Calendar_Util_Textual::thisDayName($Calendar,'short').'<br />'; |
|
| 33 | -echo 'Next day is: '.Calendar_Util_Textual::nextDayName($Calendar,'one').'<br /><hr />'; |
|
| 32 | +echo 'This day is: '.Calendar_Util_Textual::thisDayName($Calendar, 'short').'<br />'; |
|
| 33 | +echo 'Next day is: '.Calendar_Util_Textual::nextDayName($Calendar, 'one').'<br /><hr />'; |
|
| 34 | 34 | |
| 35 | 35 | echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week<br />"; |
| 36 | 36 | $Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | <caption><?php echo Calendar_Util_Textual::thisMonthName($Calendar).' '.$Calendar->thisYear(); ?></caption> |
| 42 | 42 | <tr> |
| 43 | 43 | <?php |
| 44 | -$dayheaders = Calendar_Util_Textual::orderedWeekdays($Calendar,'short'); |
|
| 44 | +$dayheaders = Calendar_Util_Textual::orderedWeekdays($Calendar, 'short'); |
|
| 45 | 45 | foreach ($dayheaders as $dayheader) { |
| 46 | 46 | echo '<th>'.$dayheader.'</th>'; |
| 47 | 47 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $this->thisDay() |
| 224 | 224 | ); |
| 225 | 225 | |
| 226 | - for ($i=1; $i <= $end; $i++) { |
|
| 226 | + for ($i = 1; $i <= $end; $i++) { |
|
| 227 | 227 | $stamp = $this->cE->dateToStamp($year, $month, $day++); |
| 228 | 228 | $this->children[$i] = new Day( |
| 229 | 229 | $this->cE->stampToYear($stamp), |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | //set empty days (@see Calendar_Month_Weeks::build()) |
| 236 | 236 | if ($this->firstWeek) { |
| 237 | 237 | $eBefore = $this->tableHelper->getEmptyDaysBefore(); |
| 238 | - for ($i=1; $i <= $eBefore; $i++) { |
|
| 238 | + for ($i = 1; $i <= $eBefore; $i++) { |
|
| 239 | 239 | $this->children[$i]->setEmpty(); |
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | if ($this->lastWeek) { |
| 243 | 243 | $eAfter = $this->tableHelper->getEmptyDaysAfterOffset(); |
| 244 | - for ($i = $eAfter+1; $i <= $end; $i++) { |
|
| 244 | + for ($i = $eAfter + 1; $i <= $end; $i++) { |
|
| 245 | 245 | $this->children[$i]->setEmpty(); |
| 246 | 246 | } |
| 247 | 247 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | switch (strtolower($format)) { |
| 349 | 349 | case 'int': |
| 350 | 350 | case 'n_in_month': |
| 351 | - return ($this->firstWeek) ? null : $this->thisWeek('n_in_month') -1; |
|
| 351 | + return ($this->firstWeek) ? null : $this->thisWeek('n_in_month') - 1; |
|
| 352 | 352 | case 'n_in_year': |
| 353 | 353 | return $this->cE->getWeekNInYear( |
| 354 | 354 | $this->cE->stampToYear($this->prevWeek), |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | switch (strtolower($format)) { |
| 422 | 422 | case 'int': |
| 423 | 423 | case 'n_in_month': |
| 424 | - return ($this->lastWeek) ? null : $this->thisWeek('n_in_month') +1; |
|
| 424 | + return ($this->lastWeek) ? null : $this->thisWeek('n_in_month') + 1; |
|
| 425 | 425 | case 'n_in_year': |
| 426 | 426 | return $this->cE->getWeekNInYear( |
| 427 | 427 | $this->cE->stampToYear($this->nextWeek), |
@@ -331,21 +331,21 @@ discard block |
||
| 331 | 331 | function prevWeek($format = 'n_in_month') |
| 332 | 332 | { |
| 333 | 333 | switch (strtolower($format)) { |
| 334 | - case 'int': |
|
| 335 | - case 'n_in_month': |
|
| 336 | - return ($this->firstWeek) ? null : $this->thisWeek('n_in_month') -1; |
|
| 337 | - case 'n_in_year': |
|
| 338 | - return $this->cE->getWeekNInYear( |
|
| 339 | - $this->cE->stampToYear($this->prevWeek), |
|
| 340 | - $this->cE->stampToMonth($this->prevWeek), |
|
| 341 | - $this->cE->stampToDay($this->prevWeek)); |
|
| 342 | - case 'array': |
|
| 343 | - return $this->toArray($this->prevWeek); |
|
| 344 | - case 'object': |
|
| 345 | - return Factory::createByTimestamp('Week', $this->prevWeek); |
|
| 346 | - case 'timestamp': |
|
| 347 | - default: |
|
| 348 | - return $this->prevWeek; |
|
| 334 | + case 'int': |
|
| 335 | + case 'n_in_month': |
|
| 336 | + return ($this->firstWeek) ? null : $this->thisWeek('n_in_month') -1; |
|
| 337 | + case 'n_in_year': |
|
| 338 | + return $this->cE->getWeekNInYear( |
|
| 339 | + $this->cE->stampToYear($this->prevWeek), |
|
| 340 | + $this->cE->stampToMonth($this->prevWeek), |
|
| 341 | + $this->cE->stampToDay($this->prevWeek)); |
|
| 342 | + case 'array': |
|
| 343 | + return $this->toArray($this->prevWeek); |
|
| 344 | + case 'object': |
|
| 345 | + return Factory::createByTimestamp('Week', $this->prevWeek); |
|
| 346 | + case 'timestamp': |
|
| 347 | + default: |
|
| 348 | + return $this->prevWeek; |
|
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | |
@@ -360,34 +360,34 @@ discard block |
||
| 360 | 360 | function thisWeek($format = 'n_in_month') |
| 361 | 361 | { |
| 362 | 362 | switch (strtolower($format)) { |
| 363 | - case 'int': |
|
| 364 | - case 'n_in_month': |
|
| 365 | - if ($this->firstWeek) { |
|
| 366 | - return 1; |
|
| 367 | - } |
|
| 368 | - if ($this->lastWeek) { |
|
| 369 | - return $this->cE->getWeeksInMonth( |
|
| 363 | + case 'int': |
|
| 364 | + case 'n_in_month': |
|
| 365 | + if ($this->firstWeek) { |
|
| 366 | + return 1; |
|
| 367 | + } |
|
| 368 | + if ($this->lastWeek) { |
|
| 369 | + return $this->cE->getWeeksInMonth( |
|
| 370 | + $this->thisYear(), |
|
| 371 | + $this->thisMonth(), |
|
| 372 | + $this->firstDay); |
|
| 373 | + } |
|
| 374 | + return $this->cE->getWeekNInMonth( |
|
| 370 | 375 | $this->thisYear(), |
| 371 | 376 | $this->thisMonth(), |
| 377 | + $this->thisDay(), |
|
| 372 | 378 | $this->firstDay); |
| 373 | - } |
|
| 374 | - return $this->cE->getWeekNInMonth( |
|
| 375 | - $this->thisYear(), |
|
| 376 | - $this->thisMonth(), |
|
| 377 | - $this->thisDay(), |
|
| 378 | - $this->firstDay); |
|
| 379 | - case 'n_in_year': |
|
| 380 | - return $this->cE->getWeekNInYear( |
|
| 381 | - $this->cE->stampToYear($this->thisWeek), |
|
| 382 | - $this->cE->stampToMonth($this->thisWeek), |
|
| 383 | - $this->cE->stampToDay($this->thisWeek)); |
|
| 384 | - case 'array': |
|
| 385 | - return $this->toArray($this->thisWeek); |
|
| 386 | - case 'object': |
|
| 387 | - return Factory::createByTimestamp('Week', $this->thisWeek); |
|
| 388 | - case 'timestamp': |
|
| 389 | - default: |
|
| 390 | - return $this->thisWeek; |
|
| 379 | + case 'n_in_year': |
|
| 380 | + return $this->cE->getWeekNInYear( |
|
| 381 | + $this->cE->stampToYear($this->thisWeek), |
|
| 382 | + $this->cE->stampToMonth($this->thisWeek), |
|
| 383 | + $this->cE->stampToDay($this->thisWeek)); |
|
| 384 | + case 'array': |
|
| 385 | + return $this->toArray($this->thisWeek); |
|
| 386 | + case 'object': |
|
| 387 | + return Factory::createByTimestamp('Week', $this->thisWeek); |
|
| 388 | + case 'timestamp': |
|
| 389 | + default: |
|
| 390 | + return $this->thisWeek; |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
@@ -402,21 +402,21 @@ discard block |
||
| 402 | 402 | function nextWeek($format = 'n_in_month') |
| 403 | 403 | { |
| 404 | 404 | switch (strtolower($format)) { |
| 405 | - case 'int': |
|
| 406 | - case 'n_in_month': |
|
| 407 | - return ($this->lastWeek) ? null : $this->thisWeek('n_in_month') +1; |
|
| 408 | - case 'n_in_year': |
|
| 409 | - return $this->cE->getWeekNInYear( |
|
| 410 | - $this->cE->stampToYear($this->nextWeek), |
|
| 411 | - $this->cE->stampToMonth($this->nextWeek), |
|
| 412 | - $this->cE->stampToDay($this->nextWeek)); |
|
| 413 | - case 'array': |
|
| 414 | - return $this->toArray($this->nextWeek); |
|
| 415 | - case 'object': |
|
| 416 | - return Factory::createByTimestamp('Week', $this->nextWeek); |
|
| 417 | - case 'timestamp': |
|
| 418 | - default: |
|
| 419 | - return $this->nextWeek; |
|
| 405 | + case 'int': |
|
| 406 | + case 'n_in_month': |
|
| 407 | + return ($this->lastWeek) ? null : $this->thisWeek('n_in_month') +1; |
|
| 408 | + case 'n_in_year': |
|
| 409 | + return $this->cE->getWeekNInYear( |
|
| 410 | + $this->cE->stampToYear($this->nextWeek), |
|
| 411 | + $this->cE->stampToMonth($this->nextWeek), |
|
| 412 | + $this->cE->stampToDay($this->nextWeek)); |
|
| 413 | + case 'array': |
|
| 414 | + return $this->toArray($this->nextWeek); |
|
| 415 | + case 'object': |
|
| 416 | + return Factory::createByTimestamp('Week', $this->nextWeek); |
|
| 417 | + case 'timestamp': |
|
| 418 | + default: |
|
| 419 | + return $this->nextWeek; |
|
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | 422 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @return int (e.g. 12) |
| 187 | 187 | * @access protected |
| 188 | 188 | */ |
| 189 | - function getMonthsInYear($y=null) |
|
| 189 | + function getMonthsInYear($y = null) |
|
| 190 | 190 | { |
| 191 | 191 | } |
| 192 | 192 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @return int |
| 214 | 214 | * @access protected |
| 215 | 215 | */ |
| 216 | - function getFirstDayInMonth ($y, $m) |
|
| 216 | + function getFirstDayInMonth($y, $m) |
|
| 217 | 217 | { |
| 218 | 218 | } |
| 219 | 219 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @return int (e.g. 7) |
| 228 | 228 | * @access protected |
| 229 | 229 | */ |
| 230 | - function getDaysInWeek($y=null, $m=null, $d=null) |
|
| 230 | + function getDaysInWeek($y = null, $m = null, $d = null) |
|
| 231 | 231 | { |
| 232 | 232 | } |
| 233 | 233 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * @return int week number |
| 257 | 257 | * @access protected |
| 258 | 258 | */ |
| 259 | - function getWeekNInMonth($y, $m, $d, $firstDay=1) |
|
| 259 | + function getWeekNInMonth($y, $m, $d, $firstDay = 1) |
|
| 260 | 260 | { |
| 261 | 261 | } |
| 262 | 262 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * @return array list of numeric values of days in week, beginning 0 |
| 298 | 298 | * @access protected |
| 299 | 299 | */ |
| 300 | - function getWeekDays($y=null, $m=null, $d=null) |
|
| 300 | + function getWeekDays($y = null, $m = null, $d = null) |
|
| 301 | 301 | { |
| 302 | 302 | } |
| 303 | 303 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * @see getWeekDays |
| 314 | 314 | * @access protected |
| 315 | 315 | */ |
| 316 | - function getFirstDayOfWeek($y=null, $m=null, $d=null) |
|
| 316 | + function getFirstDayOfWeek($y = null, $m = null, $d = null) |
|
| 317 | 317 | { |
| 318 | 318 | } |
| 319 | 319 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * @return int (e.g. 24) |
| 328 | 328 | * @access protected |
| 329 | 329 | */ |
| 330 | - function getHoursInDay($y=null,$m=null,$d=null) |
|
| 330 | + function getHoursInDay($y = null, $m = null, $d = null) |
|
| 331 | 331 | { |
| 332 | 332 | } |
| 333 | 333 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @return int |
| 343 | 343 | * @access protected |
| 344 | 344 | */ |
| 345 | - function getMinutesInHour($y=null,$m=null,$d=null,$h=null) |
|
| 345 | + function getMinutesInHour($y = null, $m = null, $d = null, $h = null) |
|
| 346 | 346 | { |
| 347 | 347 | } |
| 348 | 348 | |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | * @return int |
| 359 | 359 | * @access protected |
| 360 | 360 | */ |
| 361 | - function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null) |
|
| 361 | + function getSecondsInMinute($y = null, $m = null, $d = null, $h = null, $i = null) |
|
| 362 | 362 | { |
| 363 | 363 | } |
| 364 | 364 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | function stampCollection($stamp) |
| 78 | 78 | { |
| 79 | 79 | static $stamps = array(); |
| 80 | - if ( !isset($stamps[$stamp]) ) { |
|
| 80 | + if (!isset($stamps[$stamp])) { |
|
| 81 | 81 | $date = @date('Y n j H i s t W w', $stamp); |
| 82 | 82 | $stamps[$stamp] = sscanf($date, "%d %d %d %d %d %d %d %d %d"); |
| 83 | 83 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @return int Unix timestamp |
| 182 | 182 | * @access protected |
| 183 | 183 | */ |
| 184 | - function dateToStamp($y, $m, $d, $h=0, $i=0, $s=0) |
|
| 184 | + function dateToStamp($y, $m, $d, $h = 0, $i = 0, $s = 0) |
|
| 185 | 185 | { |
| 186 | 186 | static $dates = array(); |
| 187 | 187 | if (!isset($dates[$y][$m][$d][$h][$i][$s])) { |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @return int (12) |
| 221 | 221 | * @access protected |
| 222 | 222 | */ |
| 223 | - function getMonthsInYear($y=null) |
|
| 223 | + function getMonthsInYear($y = null) |
|
| 224 | 224 | { |
| 225 | 225 | return 12; |
| 226 | 226 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * @return int (7) |
| 269 | 269 | * @access protected |
| 270 | 270 | */ |
| 271 | - function getDaysInWeek($y=null, $m=null, $d=null) |
|
| 271 | + function getDaysInWeek($y = null, $m = null, $d = null) |
|
| 272 | 272 | { |
| 273 | 273 | return 7; |
| 274 | 274 | } |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | * @return int week number |
| 302 | 302 | * @access protected |
| 303 | 303 | */ |
| 304 | - function getWeekNInMonth($y, $m, $d, $firstDay=1) |
|
| 304 | + function getWeekNInMonth($y, $m, $d, $firstDay = 1) |
|
| 305 | 305 | { |
| 306 | - $weekEnd = (0 == $firstDay) ? $this->getDaysInWeek()-1 : $firstDay-1; |
|
| 306 | + $weekEnd = (0 == $firstDay) ? $this->getDaysInWeek() - 1 : $firstDay - 1; |
|
| 307 | 307 | $end_of_week = 1; |
| 308 | 308 | while (@date('w', @mktime(0, 0, 0, $m, $end_of_week, $y)) != $weekEnd) { |
| 309 | 309 | ++$end_of_week; //find first weekend of the month |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * @return array (0,1,2,3,4,5,6) 1 = Monday |
| 372 | 372 | * @access protected |
| 373 | 373 | */ |
| 374 | - function getWeekDays($y=null, $m=null, $d=null) |
|
| 374 | + function getWeekDays($y = null, $m = null, $d = null) |
|
| 375 | 375 | { |
| 376 | 376 | return array(0, 1, 2, 3, 4, 5, 6); |
| 377 | 377 | } |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | * @return int (default 1 = Monday) |
| 387 | 387 | * @access protected |
| 388 | 388 | */ |
| 389 | - function getFirstDayOfWeek($y=null, $m=null, $d=null) |
|
| 389 | + function getFirstDayOfWeek($y = null, $m = null, $d = null) |
|
| 390 | 390 | { |
| 391 | 391 | return 1; |
| 392 | 392 | } |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * @return int (24) |
| 402 | 402 | * @access protected |
| 403 | 403 | */ |
| 404 | - function getHoursInDay($y=null, $m=null, $d=null) |
|
| 404 | + function getHoursInDay($y = null, $m = null, $d = null) |
|
| 405 | 405 | { |
| 406 | 406 | return 24; |
| 407 | 407 | } |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | * @return int (60) |
| 418 | 418 | * @access protected |
| 419 | 419 | */ |
| 420 | - function getMinutesInHour($y=null, $m=null, $d=null, $h=null) |
|
| 420 | + function getMinutesInHour($y = null, $m = null, $d = null, $h = null) |
|
| 421 | 421 | { |
| 422 | 422 | return 60; |
| 423 | 423 | } |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | * @return int (60) |
| 435 | 435 | * @access protected |
| 436 | 436 | */ |
| 437 | - function getSecondsInMinute($y=null, $m=null, $d=null, $h=null, $i=null) |
|
| 437 | + function getSecondsInMinute($y = null, $m = null, $d = null, $h = null, $i = null) |
|
| 438 | 438 | { |
| 439 | 439 | return 60; |
| 440 | 440 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $today = sscanf($today_date, '%d %d %d'); |
| 456 | 456 | } |
| 457 | 457 | $date = UnixTS::stampCollection($stamp); |
| 458 | - return ( $date[2] == $today[2] |
|
| 458 | + return ($date[2] == $today[2] |
|
| 459 | 459 | && $date[1] == $today[1] |
| 460 | 460 | && $date[0] == $today[0] |
| 461 | 461 | ); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @access protected |
| 116 | 116 | */ |
| 117 | - function __construct(& $calendar, $firstDay=null) |
|
| 117 | + function __construct(& $calendar, $firstDay = null) |
|
| 118 | 118 | { |
| 119 | 119 | $this->calendar = & $calendar; |
| 120 | 120 | $this->cE = & $calendar->getEngine(); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $this->calendar->thisYear(), $this->calendar->thisMonth()); |
| 173 | 173 | $firstDayInMonth = $this->cE->getFirstDayInMonth( |
| 174 | 174 | $this->calendar->thisYear(), $this->calendar->thisMonth()); |
| 175 | - $this->emptyBefore=0; |
|
| 175 | + $this->emptyBefore = 0; |
|
| 176 | 176 | foreach ($this->daysOfMonth as $dayOfWeek) { |
| 177 | 177 | if ($firstDayInMonth == $dayOfWeek) { |
| 178 | 178 | break; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $this->calendar->thisDay() |
| 189 | 189 | ) |
| 190 | 190 | ); |
| 191 | - for ($i=1; $i < $this->numWeeks; $i++) { |
|
| 191 | + for ($i = 1; $i < $this->numWeeks; $i++) { |
|
| 192 | 192 | $this->daysOfMonth = |
| 193 | 193 | array_merge($this->daysOfMonth, $this->daysOfWeek); |
| 194 | 194 | } |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | $this->calendar->thisYear(), |
| 284 | 284 | $this->calendar->thisMonth(), |
| 285 | 285 | $this->calendar->thisDay() |
| 286 | - ) * ($this->numWeeks-1)); |
|
| 286 | + ) * ($this->numWeeks - 1)); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * @return int timestamp |
| 298 | 298 | */ |
| 299 | - function getWeekStart($y, $m, $d, $firstDay=1) |
|
| 299 | + function getWeekStart($y, $m, $d, $firstDay = 1) |
|
| 300 | 300 | { |
| 301 | 301 | $dow = $this->cE->getDayOfWeek($y, $m, $d); |
| 302 | 302 | if ($dow > $firstDay) { |
@@ -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 | /** |