6 * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
8 * Displays the main calendar page (month view).
10 * @copyright © 2002-2005 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 * @subpackage calendar
19 define('SM_PATH','../../');
21 /* Calender plugin required files. */
22 require_once(SM_PATH
. 'plugins/calendar/calendar_data.php');
23 require_once(SM_PATH
. 'plugins/calendar/functions.php');
25 /* SquirrelMail required files. */
26 require_once(SM_PATH
. 'include/validate.php');
27 require_once(SM_PATH
. 'functions/strings.php');
28 require_once(SM_PATH
. 'functions/date.php');
29 require_once(SM_PATH
. 'config/config.php');
30 require_once(SM_PATH
. 'functions/page_header.php');
31 require_once(SM_PATH
. 'include/load_prefs.php');
32 require_once(SM_PATH
. 'functions/html.php');
36 // undo rg = on effects
37 if (isset($month)) unset($month);
38 if (isset($year)) unset($year);
40 if (isset($_GET['month']) && is_numeric($_GET['month'])) {
41 $month = $_GET['month'];
43 if (isset($_GET['year']) && is_numeric($_GET['year'])) {
44 $year = $_GET['year'];
46 if (isset($_POST['year']) && is_numeric($_POST['year'])) {
47 $year = $_POST['year'];
49 if (isset($_POST['month']) && is_numeric($_POST['month'])) {
50 $month = $_POST['month'];
54 //display upper part of month calendar view
55 function startcalendar() {
56 global $year, $month, $color;
58 $prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
59 $act_date = mktime(0, 0, 0, $month, 1, $year);
60 $next_date = mktime(0, 0, 0, $month +
1, 1, $year);
61 $prev_month = date( 'm', $prev_date );
62 $next_month = date( 'm', $next_date);
63 $prev_year = date( 'Y', $prev_date);
64 $next_year = date( 'Y', $next_date );
65 $self = 'calendar.php';
67 echo html_tag( 'tr', "\n".
69 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
72 "<a href=\"$self?year=".($year-1)."&month=$month\"><< ".($year-1)."</a>"
75 "<a href=\"$self?year=$prev_year&month=$prev_month\">< " .
76 date_intl( 'M', $prev_date). "</a>"
78 html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') .
80 "<a href=\"$self?year=$next_year&month=$next_month\">" .
81 date_intl( 'M', $next_date) . " ></a>"
84 "<a href=\"$self?year=".($year+
1)."&month=$month\">".($year+
1)." >></a>"
88 html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
89 html_tag( 'th', _("Monday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
90 html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
91 html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
92 html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
93 html_tag( 'th', _("Friday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
94 html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%" width="90"' ) ."\n"
97 '', $color[0] ) ."\n";
100 //main logic for month view of calendar
101 function drawmonthview() {
102 global $year, $month, $color, $calendardata, $todayis;
104 $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
105 $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
106 while ($aday <= $days_in_month) {
107 echo html_tag( 'tr' );
108 for ($j=1; $j<=7; $j++
) {
110 ($aday<10)?
$cdate=$cdate."0$aday":$cdate=$cdate."$aday";
111 $cdate=$cdate."$year";
112 if ( $aday <= $days_in_month && $aday > 0){
113 echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n".
114 html_tag( 'div', '', 'right' );
115 echo(($cdate==$todayis) ?
'<font size="-1" color="'.$color[1].'">[ ' . _("TODAY") . " ] " : '<font size="-1">');
116 echo "<a href=day.php?year=$year&month=$month&day=";
117 echo(($aday<10) ?
"0" : "");
118 echo "$aday>$aday</a></font></div>";
120 echo html_tag( 'td', '', 'left', $color[0]) ."\n".
123 if (isset($calendardata[$cdate])){
125 while ($calfoo = each($calendardata[$cdate])) {
126 $calbar = $calendardata[$cdate][$calfoo['key']];
127 $title = '['. $calfoo['key']. '] ' .$calbar['message'];
128 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";
142 //end of monthly view and form to jump to any month and year
143 function endcalendar() {
144 global $year, $month, $day, $color;
146 echo html_tag( 'tr' ) ."\n" .
147 html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" .
148 " <form name=\"caljump\" action=\"calendar.php\" method=\"post\">\n".
149 " <select name=\"year\">\n";
150 select_option_year($year);
152 " <select name=\"month\">\n";
153 select_option_month($month);
155 ' <input type="submit" value="' . _("Go") . "\" />\n".
158 "</table></td></tr></table>\n";
162 if( !isset( $month ) ||
$month <= 0){
163 $month = date( 'm' );
165 if( !isset($year) ||
$year <= 0){
168 if( !isset($day) ||
$day <= 0){
172 $todayis = date( 'mdY' );
173 $calself=basename($PHP_SELF);
175 displayPageHeader($color, 'None');