524b9dd289cea2368c25d862a97e16b7a9232f26
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).
15 define('SM_PATH','../../');
17 /* Calender plugin required files. */
18 require_once(SM_PATH
. 'plugins/calendar/calendar_data.php');
19 require_once(SM_PATH
. 'plugins/calendar/functions.php');
21 /* SquirrelMail required files. */
22 require_once(SM_PATH
. 'include/validate.php');
23 require_once(SM_PATH
. 'functions/strings.php');
24 require_once(SM_PATH
. 'functions/date.php');
25 require_once(SM_PATH
. 'config/config.php');
26 require_once(SM_PATH
. 'functions/page_header.php');
27 require_once(SM_PATH
. 'include/load_prefs.php');
28 require_once(SM_PATH
. 'functions/html.php');
30 //display upper part of month calendar view
31 function startcalendar() {
32 global $year, $month, $day, $color;
34 $prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
35 $act_date = mktime(0, 0, 0, $month, 1, $year);
36 $next_date = mktime(0, 0, 0, $month +
1, 1, $year);
37 $prev_month = date( 'm', $prev_date );
38 $next_month = date( 'm', $next_date);
39 $prev_year = date( 'Y', $prev_date);
40 $next_year = date( 'Y', $next_date );
41 $self = 'calendar.php';
43 echo html_tag( 'tr', "\n".
45 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
48 "<a href=\"$self?year=".($year-1)."&month=$month\"><< ".($year-1)."</a>"
51 "<a href=\"$self?year=$prev_year&month=$prev_month\">< " .
52 date_intl( 'M', $prev_date). "</a>"
54 html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') .
56 "<a href=\"$self?year=$next_year&month=$next_month\">" .
57 date_intl( 'M', $next_date) . " ></a>"
60 "<a href=\"$self?year=".($year+
1)."&month=$month\">".($year+
1)." >></a>"
64 html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
65 html_tag( 'th', _("Monday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
66 html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
67 html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
68 html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
69 html_tag( 'th', _("Friday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
70 html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%" width="90"' ) ."\n"
73 '', $color[0] ) ."\n";
76 //main logic for month view of calendar
77 function drawmonthview() {
78 global $year, $month, $day, $color, $calendardata, $todayis;
80 $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
81 $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
82 while ($aday <= $days_in_month) {
83 echo html_tag( 'tr' );
84 for ($j=1; $j<=7; $j++
) {
86 ($aday<10)?
$cdate=$cdate."0$aday":$cdate=$cdate."$aday";
87 $cdate=$cdate."$year";
88 if ( $aday <= $days_in_month && $aday > 0){
89 echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n".
90 html_tag( 'div', '', 'right' );
91 echo(($cdate==$todayis) ?
"<font size=-1 color=$color[1]>[ " . _("TODAY") . " ] " : "<font size=-1>");
92 echo "<a href=day.php?year=$year&month=$month&day=";
93 echo(($aday<10) ?
"0" : "");
94 echo "$aday>$aday</a></font></div>";
96 echo html_tag( 'td', '', 'left', $color[0]) ."\n".
99 if (isset($calendardata[$cdate])){
101 while ($calfoo = each($calendardata[$cdate])) {
102 $calbar = $calendardata[$cdate][$calfoo['key']];
103 echo ($calbar['priority']==1) ?
"<FONT COLOR=\"$color[1]\">$calbar[title]</FONT><br>\n" : "$calbar[title]<br>\n";
117 //end of monthly view and form to jump to any month and year
118 function endcalendar() {
119 global $year, $month, $day, $color;
121 echo html_tag( 'tr' ) ."\n" .
122 html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" .
123 " <FORM NAME=caljump ACTION=\"calendar.php\" METHOD=POST>\n".
124 " <SELECT NAME=\"year\">\n";
125 select_option_year($year);
127 " <SELECT NAME=\"month\">\n";
128 select_option_month($month);
130 ' <INPUT TYPE=SUBMIT VALUE="' . _("Go") . "\">\n".
133 "</TABLE></TD></TR></TABLE>\n";
137 if( !isset( $month ) ||
$month <= 0){
138 $month = date( 'm' );
140 if( !isset($year) ||
$year <= 0){
143 if( !isset($day) ||
$day <= 0){
147 $todayis = date( 'mdY' );
148 $calself=basename($PHP_SELF);
150 displayPageHeader($color, 'None');