6 * Copyright (c) 2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
11 * Displays the main calendar page (month view).
16 require_once('calendar_data.php');
17 require_once('functions.php');
20 define('SM_PATH','../');
22 /* SquirrelMail required files. */
23 require_once(SM_PATH
. 'include/validate.php');
24 require_once(SM_PATH
. 'functions/strings.php');
25 require_once(SM_PATH
. 'functions/date.php');
26 require_once(SM_PATH
. 'config/config.php');
27 require_once(SM_PATH
. 'functions/page_header.php');
28 require_once(SM_PATH
. 'src/load_prefs.php');
29 require_once(SM_PATH
. 'functions/html.php');
31 //display upper part of month calendar view
32 function startcalendar() {
33 global $year, $month, $day, $color;
35 $prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
36 $act_date = mktime(0, 0, 0, $month, 1, $year);
37 $next_date = mktime(0, 0, 0, $month +
1, 1, $year);
38 $prev_month = date( 'm', $prev_date );
39 $next_month = date( 'm', $next_date);
40 $prev_year = date( 'Y', $prev_date);
41 $next_year = date( 'Y', $next_date );
42 $self = 'calendar.php';
44 echo html_tag( 'tr', "\n".
46 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
49 "<a href=\"$self?year=".($year-1)."&month=$month\"><< ".($year-1)."</a>"
52 "<a href=\"$self?year=$prev_year&month=$prev_month\">< " .
53 date_intl( 'M', $prev_date). "</a>"
55 html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') .
57 "<a href=\"$self?year=$next_year&month=$next_month\">" .
58 date_intl( 'M', $next_date) . " ></a>"
61 "<a href=\"$self?year=".($year+
1)."&month=$month\">".($year+
1)." >></a>"
65 html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
66 html_tag( 'th', _("Monday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
67 html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
68 html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
69 html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
70 html_tag( 'th', _("Friday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
71 html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%" width="90"' ) ."\n"
74 '', $color[0] ) ."\n";
77 //main logic for month view of calendar
78 function drawmonthview() {
79 global $year, $month, $day, $color, $calendardata, $todayis;
81 $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
82 $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
83 while ($aday <= $days_in_month) {
84 echo html_tag( 'tr' );
85 for ($j=1; $j<=7; $j++
) {
87 ($aday<10)?
$cdate=$cdate."0$aday":$cdate=$cdate."$aday";
88 $cdate=$cdate."$year";
89 if ( $aday <= $days_in_month && $aday > 0){
90 echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n".
91 html_tag( 'div', '', 'right' );
92 echo(($cdate==$todayis) ?
"<font size=-1 color=$color[1]>[ " . _("TODAY") . " ] " : "<font size=-1>");
93 echo "<a href=day.php?year=$year&month=$month&day=";
94 echo(($aday<10) ?
"0" : "");
95 echo "$aday>$aday</a></font></div>";
97 echo html_tag( 'td', '', 'left', $color[0]) ."\n".
100 if (isset($calendardata[$cdate])){
102 while ($calfoo = each($calendardata[$cdate])) {
103 $calbar = $calendardata[$cdate][$calfoo['key']];
104 echo ($calbar['priority']==1) ?
"<FONT COLOR=\"$color[1]\">$calbar[title]</FONT><br>\n" : "$calbar[title]<br>\n";
118 //end of monthly view and form to jump to any month and year
119 function endcalendar() {
120 global $year, $month, $day, $color;
122 echo html_tag( 'tr' ) ."\n" .
123 html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" .
124 " <FORM NAME=caljump ACTION=\"calendar.php\" METHOD=POST>\n".
125 " <SELECT NAME=\"year\">\n";
126 select_option_year($year);
128 " <SELECT NAME=\"month\">\n";
129 select_option_month($month);
131 ' <INPUT TYPE=SUBMIT VALUE="' . _("Go") . "\">\n".
134 "</TABLE></TD></TR></TABLE>\n";
138 if( !isset( $month ) ||
$month <= 0){
139 $month = date( 'm' );
141 if( !isset($year) ||
$year <= 0){
144 if( !isset($day) ||
$day <= 0){
148 $todayis = date( 'mdY' );
149 $calself=basename($PHP_SELF);
151 displayPageHeader($color, 'None');