6 * Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays the main calendar page (month view).
14 require_once('calendar_data.php');
15 require_once('functions.php');
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');
24 //display upper part of month calendar view
25 function startcalendar() {
26 global $year, $month, $day, $color;
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 );
35 $self = 'calendar.php';
37 echo "<TR BGCOLOR=\"$color[0]\"><TD>" .
38 "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">" .
40 "<th><a href=\"$self?year=".($year-1)."&month=$month\"><< ".($year-1)."</a></th>\n".
41 "<th><a href=\"$self?year=$prev_year&month=$prev_month\">< " .
42 date_intl( 'M', $prev_date). "</a></th>\n".
43 "<th bgcolor=$color[0] colspan=3>" .
44 date_intl( 'F Y', $act_date ) . "</th>\n" .
45 "<th><a href=\"$self?year=$next_year&month=$next_month\">" .
46 date_intl( 'M', $next_date) . " ></a></th>".
47 "<th><a href=\"$self?year=".($year+
1)."&month=$month\">".($year+
1)." >></a></th>".
49 "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Sunday") . '</th>'.
50 "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Monday") . '</th>'.
51 "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Tuesday") . '</th>'.
52 "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Wednesday") . '</th>'.
53 "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Thursday") . '</th>'.
54 "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Friday") . '</th>'.
55 "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Saturday") . '</th>'.
60 //main logic for month view of calendar
61 function drawmonthview() {
62 global $year, $month, $day, $color, $calendardata, $todayis;
64 $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
65 $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
66 while ($aday <= $days_in_month) {
68 for ($j=1; $j<=7; $j++
) {
70 ($aday<10)?
$cdate=$cdate."0$aday":$cdate=$cdate."$aday";
71 $cdate=$cdate."$year";
72 if ( $aday <= $days_in_month && $aday > 0){
73 echo "<TD BGCOLOR=\"$color[4]\" height=50 valign=top>\n" .
75 echo(($cdate==$todayis) ?
"<font size=-1 color=$color[1]>[ " . _("TODAY") . " ] " : "<font size=-1>");
76 echo "<a href=day.php?year=$year&month=$month&day=";
77 echo(($aday<10) ?
"0" : "");
78 echo "$aday>$aday</a></font></div>";
80 echo "<TD BGCOLOR=\"$color[0]\">\n".
83 if (isset($calendardata[$cdate])){
85 while ($calfoo = each($calendardata[$cdate])) {
86 $calbar = $calendardata[$cdate][$calfoo['key']];
87 echo ($calbar['priority']==1) ?
"<FONT COLOR=\"$color[1]\">$calbar[title]</FONT><br>\n" : "$calbar[title]<br>\n";
101 //end of monthly view and form to jump to any month and year
102 function endcalendar() {
103 global $year, $month, $day, $color;
105 echo " <TR><TD COLSPAN=7>\n".
106 " <FORM NAME=caljump ACTION=\"calendar.php\" METHOD=POST>\n".
107 " <SELECT NAME=\"year\">\n";
108 select_option_year($year);
110 " <SELECT NAME=\"month\">\n";
111 select_option_month($month);
113 ' <INPUT TYPE=SUBMIT VALUE="' . _("Go") . "\">\n".
116 "</TABLE></TD></TR></TABLE>\n";
120 if( !isset( $month ) ||
$month <= 0){
121 $month = date( 'm' );
123 if( !isset($year) ||
$year <= 0){
126 if( !isset($day) ||
$day <= 0){
130 $todayis = date( 'mdY' );
131 $calself=basename($PHP_SELF);
133 displayPageHeader($color, 'None');