4 * Displays the main calendar page (month view).
6 * @copyright © 2002-2007 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @subpackage calendar
14 * Include the SquirrelMail initialization file.
16 require('../../include/init.php');
18 /* load date_intl() */
19 include_once(SM_PATH
. 'functions/date.php');
21 /* Calendar plugin required files. */
22 include_once(SM_PATH
. 'plugins/calendar/calendar_data.php');
23 include_once(SM_PATH
. 'plugins/calendar/functions.php');
26 if (! sqgetGlobalVar('month',$month,SQ_FORM
) ||
! is_numeric($month)) {
29 if (! sqgetGlobalVar('year',$year,SQ_FORM
) ||
! is_numeric($year)) {
35 * display upper part of month calendar view
39 function startcalendar() {
40 global $year, $month, $color;
42 $prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
43 $act_date = mktime(0, 0, 0, $month, 1, $year);
44 $next_date = mktime(0, 0, 0, $month +
1, 1, $year);
45 $prev_month = date( 'm', $prev_date );
46 $next_month = date( 'm', $next_date);
47 $prev_year = date( 'Y', $prev_date);
48 $next_year = date( 'Y', $next_date );
49 $self = 'calendar.php';
51 echo html_tag( 'tr', "\n".
53 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
56 "<a href=\"$self?year=".($year-1)."&month=$month\"><< ".($year-1)."</a>"
59 "<a href=\"$self?year=$prev_year&month=$prev_month\">< " .
60 date_intl( 'M', $prev_date). "</a>"
62 html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') .
64 "<a href=\"$self?year=$next_year&month=$next_month\">" .
65 date_intl( 'M', $next_date) . " ></a>"
68 "<a href=\"$self?year=".($year+
1)."&month=$month\">".($year+
1)." >></a>"
72 html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
73 html_tag( 'th', _("Monday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
74 html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
75 html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
76 html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
77 html_tag( 'th', _("Friday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
78 html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%" width="90"' ) ."\n"
81 '', $color[0] ) ."\n";
85 * main logic for month view of calendar
89 function drawmonthview() {
90 global $year, $month, $color, $calendardata, $todayis;
92 $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
93 $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
94 while ($aday <= $days_in_month) {
95 echo html_tag( 'tr' );
96 for ($j=1; $j<=7; $j++
) {
98 ($aday<10)?
$cdate=$cdate."0$aday":$cdate=$cdate."$aday";
99 $cdate=$cdate."$year";
100 if ( $aday <= $days_in_month && $aday > 0){
101 echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n".
102 html_tag( 'div', '', 'right' );
103 echo(($cdate==$todayis) ?
'<font size="-1" color="'.$color[1].'">[ ' . _("TODAY") . " ] " : '<font size="-1">');
104 echo "<a href=day.php?year=$year&month=$month&day=";
105 echo(($aday<10) ?
"0" : "");
106 echo "$aday>$aday</a></font></div>";
108 echo html_tag( 'td', '', 'left', $color[0]) ."\n".
111 if (isset($calendardata[$cdate])){
113 while ($calfoo = each($calendardata[$cdate])) {
114 $calbar = $calendardata[$cdate][$calfoo['key']];
115 // FIXME: how to display multiline task
116 $title = '['. $calfoo['key']. '] ' .
117 str_replace(array("\r","\n"),array(' ',' '),htmlspecialchars($calbar['message']));
118 // FIXME: link to nowhere
119 echo "<a href=\"#\" style=\"text-decoration:none; color: "
120 .($calbar['priority']==1 ?
$color[1] : $color[6])
121 ."\" title=\"$title\">".htmlspecialchars($calbar['title'])."</a><br />\n";
136 * 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');