6 * Copyright (c) 2002-2005 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 // undo rg = on effects
38 if (isset($month)) unset($month);
39 if (isset($year)) unset($year);
41 if (isset($_GET['month']) && is_numeric($_GET['month'])) {
42 $month = $_GET['month'];
44 if (isset($_GET['year']) && is_numeric($_GET['year'])) {
45 $year = $_GET['year'];
47 if (isset($_POST['year']) && is_numeric($_POST['year'])) {
48 $year = $_POST['year'];
50 if (isset($_POST['month']) && is_numeric($_POST['month'])) {
51 $month = $_POST['month'];
55 //display upper part of month calendar view
56 function startcalendar() {
57 global $year, $month, $color;
59 $prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
60 $act_date = mktime(0, 0, 0, $month, 1, $year);
61 $next_date = mktime(0, 0, 0, $month +
1, 1, $year);
62 $prev_month = date( 'm', $prev_date );
63 $next_month = date( 'm', $next_date);
64 $prev_year = date( 'Y', $prev_date);
65 $next_year = date( 'Y', $next_date );
66 $self = 'calendar.php';
68 echo html_tag( 'tr', "\n".
70 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
73 "<a href=\"$self?year=".($year-1)."&month=$month\"><< ".($year-1)."</a>"
76 "<a href=\"$self?year=$prev_year&month=$prev_month\">< " .
77 date_intl( 'M', $prev_date). "</a>"
79 html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') .
81 "<a href=\"$self?year=$next_year&month=$next_month\">" .
82 date_intl( 'M', $next_date) . " ></a>"
85 "<a href=\"$self?year=".($year+
1)."&month=$month\">".($year+
1)." >></a>"
89 html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
90 html_tag( 'th', _("Monday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
91 html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
92 html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
93 html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
94 html_tag( 'th', _("Friday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
95 html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%" width="90"' ) ."\n"
98 '', $color[0] ) ."\n";
101 //main logic for month view of calendar
102 function drawmonthview() {
103 global $year, $month, $color, $calendardata, $todayis;
105 $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
106 $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
107 while ($aday <= $days_in_month) {
108 echo html_tag( 'tr' );
109 for ($j=1; $j<=7; $j++
) {
111 ($aday<10)?
$cdate=$cdate."0$aday":$cdate=$cdate."$aday";
112 $cdate=$cdate."$year";
113 if ( $aday <= $days_in_month && $aday > 0){
114 echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n".
115 html_tag( 'div', '', 'right' );
116 echo(($cdate==$todayis) ?
'<font size="-1" color="'.$color[1].'">[ ' . _("TODAY") . " ] " : '<font size="-1">');
117 echo "<a href=day.php?year=$year&month=$month&day=";
118 echo(($aday<10) ?
"0" : "");
119 echo "$aday>$aday</a></font></div>";
121 echo html_tag( 'td', '', 'left', $color[0]) ."\n".
124 if (isset($calendardata[$cdate])){
126 while ($calfoo = each($calendardata[$cdate])) {
127 $calbar = $calendardata[$cdate][$calfoo['key']];
128 $title = '['. $calfoo['key']. '] ' .$calbar['message'];
129 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";
143 //end of monthly view and form to jump to any month and year
144 function endcalendar() {
145 global $year, $month, $day, $color;
147 echo html_tag( 'tr' ) ."\n" .
148 html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" .
149 " <form name=\"caljump\" action=\"calendar.php\" method=\"post\">\n".
150 " <select name=\"year\">\n";
151 select_option_year($year);
153 " <select name=\"month\">\n";
154 select_option_month($month);
156 ' <input type="submit" value="' . _("Go") . "\" />\n".
159 "</table></td></tr></table>\n";
163 if( !isset( $month ) ||
$month <= 0){
164 $month = date( 'm' );
166 if( !isset($year) ||
$year <= 0){
169 if( !isset($day) ||
$day <= 0){
173 $todayis = date( 'mdY' );
174 $calself=basename($PHP_SELF);
176 displayPageHeader($color, 'None');