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