Calendar
[ class tree: Calendar ] [ index: Calendar ] [ all elements ]

Source for file 17.php

Documentation is available at 17.php

  1. <?php
  2. /**
  3. * Description: demonstrates using the Textual decorator
  4. */
  5.  
  6. if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php'{
  7.     define('CALENDAR_ROOT''../../');
  8. }
  9. require_once CALENDAR_ROOT.'Day.php';
  10. require_once CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php';
  11. require_once CALENDAR_ROOT.'Decorator'.DIRECTORY_SEPARATOR.'Textual.php';
  12.  
  13. // Could change language like this
  14. // setlocale (LC_TIME, "de_DE"); // Unix based (probably)
  15. // setlocale (LC_TIME, "ge"); // Windows
  16.  
  17. echo "<hr>Calling: Calendar_Decorator_Textual::monthNames('long');<pre>";
  18. echo '</pre>';
  19.  
  20. echo "<hr>Calling: Calendar_Decorator_Textual::weekdayNames('two');<pre>";
  21. echo '</pre>';
  22.  
  23. echo "<hr>Creating: new Calendar_Day(date('Y'), date('n'), date('d'));<br />";
  24. $Calendar = new Calendar_Day(date('Y')date('n')date('d'));
  25.  
  26. // Decorate
  27. $Textual new Calendar_Decorator_Textual($Calendar);
  28.  
  29. echo '<hr>Previous month is: '.$Textual->prevMonthName('two').'<br />';
  30. echo 'This month is: '.$Textual->thisMonthName('short').'<br />';
  31. echo 'Next month is: '.$Textual->nextMonthName().'<br /><hr />';
  32. echo 'Previous day is: '.$Textual->prevDayName().'<br />';
  33. echo 'This day is: '.$Textual->thisDayName('short').'<br />';
  34. echo 'Next day is: '.$Textual->nextDayName('one').'<br /><hr />';
  35.  
  36. echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week<br />";
  37. $Calendar = new Calendar_Month_Weekdays(date('Y')date('n')6);
  38.  
  39. // Decorate
  40. $Textual new Calendar_Decorator_Textual($Calendar);
  41. ?>
  42. <p>Rendering calendar....</p>
  43. <table>
  44. <caption><?php echo $Textual->thisMonthName().' '.$Textual->thisYear()?></caption>
  45. <tr>
  46. <?php
  47. $dayheaders $Textual->orderedWeekdays('short');
  48. foreach ($dayheaders as $dayheader{
  49.     echo '<th>'.$dayheader.'</th>';
  50. }
  51. ?>
  52. </tr>
  53. <?php
  54. $Calendar->build();
  55. while ($Day $Calendar->fetch()) {
  56.     if ($Day->isFirst()) {
  57.         echo "<tr>\n";
  58.     }
  59.     if ($Day->isEmpty()) {
  60.         echo '<td>&nbsp;</td>';
  61.     else {
  62.         echo '<td>'.$Day->thisDay().'</td>';
  63.     }
  64.     if ($Day->isLast()) {
  65.         echo "</tr>\n";
  66.     }
  67. }
  68. ?>
  69. </table>

Documentation generated on Mon, 11 Mar 2019 15:37:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.