Subversion Repositories Applications.papyrus

Rev

Rev 1087 | 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 util
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.'Util'.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_Util_Textual::monthNames('long');<pre>";
18
print_r(Calendar_Util_Textual::monthNames('long'));
19
echo '</pre>';
20
 
21
echo "<hr>Calling: Calendar_Util_Textual::weekdayNames('two');<pre>";
22
print_r(Calendar_Util_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
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
echo 'Next month is: '.Calendar_Util_Textual::nextMonthName($Calendar).'<br /><hr />';
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 />';
34
 
35
echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week<br />";
36
$Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6);
37
 
38
?>
39
<p>Rendering calendar....</p>
40
<table>
41
<caption><?php echo Calendar_Util_Textual::thisMonthName($Calendar).' '.$Calendar->thisYear(); ?></caption>
42
<tr>
43
<?php
44
$dayheaders = Calendar_Util_Textual::orderedWeekdays($Calendar,'short');
45
foreach ($dayheaders as $dayheader) {
46
    echo '<th>'.$dayheader.'</th>';
47
}
48
?>
49
</tr>
50
<?php
51
$Calendar->build();
52
while ($Day = $Calendar->fetch()) {
53
    if ($Day->isFirst()) {
54
        echo "<tr>\n";
55
    }
56
    if ($Day->isEmpty()) {
57
        echo '<td>&nbsp;</td>';
58
    } else {
59
        echo '<td>'.$Day->thisDay().'</td>';
60
    }
61
    if ($Day->isLast()) {
62
        echo "</tr>\n";
63
    }
64
}
65
?>
66
</table>