Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
493 ddelon 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
print_r(Calendar_Decorator_Textual::monthNames('long'));
19
echo '</pre>';
20
 
21
echo "<hr>Calling: Calendar_Decorator_Textual::weekdayNames('two');<pre>";
22
print_r(Calendar_Decorator_Textual::weekdayNames('two'));
23
echo '</pre>';
24
 
25
echo "<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
 
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
 
38
echo "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');
50
foreach ($dayheaders as $dayheader) {
51
    echo '<th>'.$dayheader.'</th>';
52
}
53
?>
54
</tr>
55
<?php
56
$Calendar->build();
57
while ($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>