6 * Copyright (c) 2002-2004 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).
15 * @subpackage calendar
20 define('SM_PATH','../../');
22 /* Calender plugin required files. */
23 require_once(SM_PATH
. 'plugins/calendar/calendar_data.php');
24 require_once(SM_PATH
. 'plugins/calendar/functions.php');
26 /* SquirrelMail required files. */
27 require_once(SM_PATH
. 'include/validate.php');
28 require_once(SM_PATH
. 'functions/strings.php');
29 require_once(SM_PATH
. 'functions/date.php');
30 require_once(SM_PATH
. 'config/config.php');
31 require_once(SM_PATH
. 'functions/page_header.php');
32 require_once(SM_PATH
. 'include/load_prefs.php');
33 require_once(SM_PATH
. 'functions/html.php');
37 if (isset($_GET['month'])) {
38 $month = $_GET['month'];
40 if (isset($_GET['year'])) {
41 $year = $_GET['year'];
43 if (isset($_POST['year'])) {
44 $year = $_POST['year'];
46 if (isset($_POST['month'])) {
47 $month = $_POST['month'];
51 //display upper part of month calendar view
52 function startcalendar() {
53 global $year, $month, $day, $color;
55 $prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
56 $act_date = mktime(0, 0, 0, $month, 1, $year);
57 $next_date = mktime(0, 0, 0, $month +
1, 1, $year);
58 $prev_month = date( 'm', $prev_date );
59 $next_month = date( 'm', $next_date);
60 $prev_year = date( 'Y', $prev_date);
61 $next_year = date( 'Y', $next_date );
62 $self = 'calendar.php';
64 echo html_tag( 'tr', "\n".
66 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
69 "<a href=\"$self?year=".($year-1)."&month=$month\"><< ".($year-1)."</a>"
72 "<a href=\"$self?year=$prev_year&month=$prev_month\">< " .
73 date_intl( 'M', $prev_date). "</a>"
75 html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') .
77 "<a href=\"$self?year=$next_year&month=$next_month\">" .
78 date_intl( 'M', $next_date) . " ></a>"
81 "<a href=\"$self?year=".($year+
1)."&month=$month\">".($year+
1)." >></a>"
85 html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
86 html_tag( 'th', _("Monday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
87 html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
88 html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
89 html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
90 html_tag( 'th', _("Friday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
91 html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%" width="90"' ) ."\n"
94 '', $color[0] ) ."\n";
97 //main logic for month view of calendar
98 function drawmonthview() {
99 global $year, $month, $day, $color, $calendardata, $todayis;
101 $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
102 $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
103 while ($aday <= $days_in_month) {
104 echo html_tag( 'tr' );
105 for ($j=1; $j<=7; $j++
) {
107 ($aday<10)?
$cdate=$cdate."0$aday":$cdate=$cdate."$aday";
108 $cdate=$cdate."$year";
109 if ( $aday <= $days_in_month && $aday > 0){
110 echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n".
111 html_tag( 'div', '', 'right' );
112 echo(($cdate==$todayis) ?
'<font size="-1" color="'.$color[1].'">[ ' . _("TODAY") . " ] " : '<font size="-1">');
113 echo "<a href=day.php?year=$year&month=$month&day=";
114 echo(($aday<10) ?
"0" : "");
115 echo "$aday>$aday</a></font></div>";
117 echo html_tag( 'td', '', 'left', $color[0]) ."\n".
120 if (isset($calendardata[$cdate])){
122 while ($calfoo = each($calendardata[$cdate])) {
123 $calbar = $calendardata[$cdate][$calfoo['key']];
124 $title = '['. $calfoo['key']. '] ' .$calbar['message'];
125 echo ($calbar['priority']==1) ?
"<a href=\"#\" style=\"text-decoration:none; color: $color[1]\" title=\"$title\">$calbar[title]</a><br />\n" : "<a href=\"#\" style=\"text-decoration:none; color: $color[6]\" title=\"$title\">$calbar[title]</a><br />\n";
139 //end of monthly view and form to jump to any month and year
140 function endcalendar() {
141 global $year, $month, $day, $color;
143 echo html_tag( 'tr' ) ."\n" .
144 html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" .
145 " <form name=\"caljump\" action=\"calendar.php\" method=\"post\">\n".
146 " <select name=\"year\">\n";
147 select_option_year($year);
149 " <select name=\"month\">\n";
150 select_option_month($month);
152 ' <input type="submit" value="' . _("Go") . "\" />\n".
155 "</table></td></tr></table>\n";
159 if( !isset( $month ) ||
$month <= 0){
160 $month = date( 'm' );
162 if( !isset($year) ||
$year <= 0){
165 if( !isset($day) ||
$day <= 0){
169 $todayis = date( 'mdY' );
170 $calself=basename($PHP_SELF);
172 displayPageHeader($color, 'None');