d61a01d4 |
1 | <?php |
2 | /* |
3 | * |
4 | * calendar.php |
5 | * |
6 | * Copyright (c) 2001 Michal Szczotka <michal@tuxy.org> |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Displays the main calendar page (month view). |
10 | * |
2c85de8f |
11 | * $Id$ |
d61a01d4 |
12 | */ |
13 | |
14 | require_once('calendar_data.php'); |
15 | require_once('functions.php'); |
16 | chdir('..'); |
17 | require_once('../src/validate.php'); |
18 | require_once('../functions/strings.php'); |
19 | require_once('../functions/date.php'); |
20 | require_once('../config/config.php'); |
21 | require_once('../functions/page_header.php'); |
22 | require_once('../src/load_prefs.php'); |
23 | |
24 | //display upper part of month calendar view |
25 | function startcalendar() { |
26 | global $year, $month, $day, $color; |
27 | |
28 | $prev_date = mktime(0, 0, 0, $month - 1, 1, $year); |
29 | $act_date = mktime(0, 0, 0, $month, 1, $year); |
30 | $next_date = mktime(0, 0, 0, $month + 1, 1, $year); |
31 | $prev_month = date( 'm', $prev_date ); |
32 | $next_month = date( 'm', $next_date); |
33 | $prev_year = date( 'Y', $prev_date); |
34 | $next_year = date( 'Y', $next_date ); |
88cb1b4d |
35 | $self = 'calendar.php'; |
d61a01d4 |
36 | |
b01b21d0 |
37 | echo html_tag( 'tr', "\n". |
38 | html_tag( 'td', "\n". |
39 | html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) . |
40 | html_tag( 'tr', "\n". |
41 | html_tag( 'th', |
42 | "<a href=\"$self?year=".($year-1)."&month=$month\"><< ".($year-1)."</a>" |
43 | ) . "\n". |
44 | html_tag( 'th', |
45 | "<a href=\"$self?year=$prev_year&month=$prev_month\">< " . |
46 | date_intl( 'M', $prev_date). "</a>" |
47 | ) . "\n". |
48 | html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') . |
49 | html_tag( 'th', |
50 | "<a href=\"$self?year=$next_year&month=$next_month\">" . |
51 | date_intl( 'M', $next_date) . " ></a>" |
52 | ) . "\n". |
53 | html_tag( 'th', |
54 | "<a href=\"$self?year=".($year+1)."&month=$month\">".($year+1)." >></a>" |
55 | ) |
56 | ) . "\n". |
57 | html_tag( 'tr', |
58 | html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . |
59 | html_tag( 'th', _("Monday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . |
60 | html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . |
61 | html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . |
62 | html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . |
63 | html_tag( 'th', _("Friday"), '', $color[5], 'width="14%" width="90"' ) ."\n" . |
64 | html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%" width="90"' ) ."\n" |
65 | ) |
66 | ) , |
67 | '', $color[0] ) ."\n"; |
d61a01d4 |
68 | } |
69 | |
70 | //main logic for month view of calendar |
71 | function drawmonthview() { |
72 | global $year, $month, $day, $color, $calendardata, $todayis; |
73 | |
74 | $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year)); |
75 | $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year)); |
76 | while ($aday <= $days_in_month) { |
b01b21d0 |
77 | echo html_tag( 'tr' ); |
d61a01d4 |
78 | for ($j=1; $j<=7; $j++) { |
79 | $cdate="$month"; |
80 | ($aday<10)?$cdate=$cdate."0$aday":$cdate=$cdate."$aday"; |
81 | $cdate=$cdate."$year"; |
82 | if ( $aday <= $days_in_month && $aday > 0){ |
b01b21d0 |
83 | echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n". |
84 | html_tag( 'div', '', 'right' ); |
d61a01d4 |
85 | echo(($cdate==$todayis) ? "<font size=-1 color=$color[1]>[ " . _("TODAY") . " ] " : "<font size=-1>"); |
86 | echo "<a href=day.php?year=$year&month=$month&day="; |
87 | echo(($aday<10) ? "0" : ""); |
88 | echo "$aday>$aday</a></font></div>"; |
89 | } else { |
b01b21d0 |
90 | echo html_tag( 'td', '', 'left', $color[0]) ."\n". |
d61a01d4 |
91 | " "; |
92 | } |
93 | if (isset($calendardata[$cdate])){ |
94 | $i=0; |
95 | while ($calfoo = each($calendardata[$cdate])) { |
88cb1b4d |
96 | $calbar = $calendardata[$cdate][$calfoo['key']]; |
97 | echo ($calbar['priority']==1) ? "<FONT COLOR=\"$color[1]\">$calbar[title]</FONT><br>\n" : "$calbar[title]<br>\n"; |
d61a01d4 |
98 | $i=$i+1; |
99 | if($i==2){ |
100 | break; |
101 | } |
102 | } |
103 | } |
b01b21d0 |
104 | echo "\n</td>\n"; |
d61a01d4 |
105 | $aday++; |
106 | } |
107 | echo '</tr>'; |
108 | } |
109 | } |
110 | |
111 | //end of monthly view and form to jump to any month and year |
112 | function endcalendar() { |
113 | global $year, $month, $day, $color; |
114 | |
b01b21d0 |
115 | echo html_tag( 'tr' ) ."\n" . |
116 | html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" . |
d61a01d4 |
117 | " <FORM NAME=caljump ACTION=\"calendar.php\" METHOD=POST>\n". |
118 | " <SELECT NAME=\"year\">\n"; |
119 | select_option_year($year); |
120 | echo " </SELECT>\n". |
121 | " <SELECT NAME=\"month\">\n"; |
122 | select_option_month($month); |
123 | echo " </SELECT>\n". |
124 | ' <INPUT TYPE=SUBMIT VALUE="' . _("Go") . "\">\n". |
125 | " </FORM>\n". |
126 | " </TD></TR>\n". |
127 | "</TABLE></TD></TR></TABLE>\n"; |
128 | } |
129 | |
130 | |
88cb1b4d |
131 | if( !isset( $month ) || $month <= 0){ |
d61a01d4 |
132 | $month = date( 'm' ); |
133 | } |
88cb1b4d |
134 | if( !isset($year) || $year <= 0){ |
d61a01d4 |
135 | $year = date( 'Y' ); |
136 | } |
88cb1b4d |
137 | if( !isset($day) || $day <= 0){ |
d61a01d4 |
138 | $day = date( 'd' ); |
139 | } |
140 | |
141 | $todayis = date( 'mdY' ); |
142 | $calself=basename($PHP_SELF); |
143 | |
144 | displayPageHeader($color, 'None'); |
145 | calendar_header(); |
146 | readcalendardata(); |
147 | startcalendar(); |
148 | drawmonthview(); |
149 | endcalendar(); |
150 | |
151 | ?> |
152 | </body></html> |