source: branches/version-2/data/module/Calendar/docs/examples/17.php @ 17143

Revision 17143, 2.2 KB checked in by adachi, 16 years ago (diff)

calendar bloc by Yammy (merge r17073, r17076, r17087, r17091)

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