source: branches/comu-ver2/data/module/Calendar/docs/examples/21.phps @ 17073

Revision 17073, 3.0 KB checked in by Yammy, 16 years ago (diff)

カレンダーブロックを追加(PEAR::Calendarクラス使用仕様)

Line 
1<?php
2/**
3* Description: a complete year with numeric week numbers
4*/
5function getmicrotime(){
6    list($usec, $sec) = explode(" ",microtime());
7    return ((float)$usec + (float)$sec);
8}
9$start = getmicrotime();
10
11if (!@include 'Calendar/Calendar.php') {
12    define('CALENDAR_ROOT', '../../');
13}
14
15require_once CALENDAR_ROOT.'Year.php';
16require_once CALENDAR_ROOT.'Month/Weeks.php';
17
18define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKS);
19
20if (!isset($_GET['year'])) $_GET['year'] = date('Y');
21
22$week_types = array(
23    'n_in_year',
24    'n_in_month',
25);
26
27if (!isset($_GET['week_type']) || !in_array($_GET['week_type'],$week_types) ) {
28    $_GET['week_type'] = 'n_in_year';
29}
30
31$Year = new Calendar_Year($_GET['year']);
32
33$Year->build();
34?>
35<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
36<html>
37<head>
38<title> <?php echo $Year->thisYear(); ?> </title>
39<style type="text/css">
40body {
41    font-family: Georgia, serif;
42}
43caption.year {
44    font-weight: bold;
45    font-size: 120%;
46    font-color: navy;
47}
48caption.month {
49    font-size: 110%;
50    font-color: navy;
51}
52table.month {
53    border: thin groove #800080
54}
55tr {
56    vertical-align: top;
57}
58th, td {
59    text-align: right;
60    font-size: 70%;
61}
62#prev {
63    float: left;
64    font-size: 70%;
65}
66#next {
67    float: right;
68    font-size: 70%;
69}
70#week_type {
71    float: none;
72    font-size: 70%;
73}
74.weekNumbers {
75    background-color: #e5e5f5;
76    padding-right: 3pt;
77}
78</style>
79</head>
80<body>
81<table>
82<caption class="year">
83<?php echo $Year->thisYear(); ?>
84<div id="next">
85<a href="?year=<?php echo $Year->nextYear(); ?>&week_type=<?php echo $_GET['week_type']; ?>">>></a>
86</div>
87<div id="prev">
88<a href="?year=<?php echo $Year->prevYear(); ?>&week_type=<?php echo $_GET['week_type']; ?>"><<</a>
89</div>
90<div id="week_type">
91<a href="?year=<?php echo $Year->thisYear(); ?>&week_type=n_in_year">Weeks by Year</a> :
92<a href="?year=<?php echo $Year->thisYear(); ?>&week_type=n_in_month">Weeks by Month</a> 
93</div>
94</caption>
95<?php
96$i = 0;
97while ($Month = $Year->fetch()) {
98
99    switch ($i) {
100        case 0:
101            echo "<tr>\n";
102            break;
103        case 3:
104        case 6:
105        case 9:
106            echo "</tr>\n<tr>\n";
107           break;
108        case 12:
109            echo "</tr>\n";
110            break;
111    }
112
113    echo "<td>\n<table class=\"month\">\n";
114    echo '<caption class="month">'.date('F', $Month->thisMonth(TRUE)).'</caption>';
115    echo '<colgroup><col class="weekNumbers"><col span="7"></colgroup>'."\n";
116    echo "<tr>\n<th>Week</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th><th>S</th>\n</tr>";
117    $Month->build();
118    while ($Week = $Month->fetch()) {
119        echo "<tr>\n";
120        echo '<td>'.$Week->thisWeek($_GET['week_type'])."</td>\n";
121        $Week->build();
122
123        while ($Day = $Week->fetch()) {
124            if ($Day->isEmpty()) {
125                echo "<td>&nbsp;</td>\n";
126            } else {
127                echo "<td>".$Day->thisDay()."</td>\n";
128            }
129        }
130    }
131    echo "</table>\n</td>\n";
132
133    $i++;
134}
135?>
136</table>
137<p>Took: <?php echo ((getmicrotime()-$start)); ?></p>
138</body>
139</html>
Note: See TracBrowser for help on using the repository browser.