<?php
-/*
- *
- * calendar.php
- *
- * Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
- * Displays the main calendar page (month view).
+
+/**
+ * Displays the main calendar page (month view).
*
- * $Id$
+ * @copyright © 2002-2007 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package plugins
+ * @subpackage calendar
*/
-require_once('calendar_data.php');
-require_once('functions.php');
-chdir('..');
-require_once('../src/validate.php');
-require_once('../functions/strings.php');
-require_once('../functions/date.php');
-require_once('../config/config.php');
-require_once('../functions/page_header.php');
-require_once('../src/load_prefs.php');
-
-//display upper part of month calendar view
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
+
+/* load date_intl() */
+include_once(SM_PATH . 'functions/date.php');
+
+/* Calendar plugin required files. */
+include_once(SM_PATH . 'plugins/calendar/calendar_data.php');
+include_once(SM_PATH . 'plugins/calendar/functions.php');
+
+/* get globals */
+if (! sqgetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
+ unset($month);
+}
+if (! sqgetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) {
+ unset($year);
+}
+/* got 'em */
+
+/**
+ * display upper part of month calendar view
+ * @return void
+ * @access private
+ */
function startcalendar() {
- global $year, $month, $day, $color;
+ global $year, $month, $color;
$prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
$act_date = mktime(0, 0, 0, $month, 1, $year);
html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
html_tag( 'tr', "\n".
html_tag( 'th',
- "<a href=\"$self?year=".($year-1)."&month=$month\"><< ".($year-1)."</a>"
+ "<a href=\"$self?year=".($year-1)."&month=$month\"><< ".($year-1)."</a>"
) . "\n".
html_tag( 'th',
- "<a href=\"$self?year=$prev_year&month=$prev_month\">< " .
+ "<a href=\"$self?year=$prev_year&month=$prev_month\">< " .
date_intl( 'M', $prev_date). "</a>"
) . "\n".
html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') .
html_tag( 'th',
- "<a href=\"$self?year=$next_year&month=$next_month\">" .
+ "<a href=\"$self?year=$next_year&month=$next_month\">" .
date_intl( 'M', $next_date) . " ></a>"
) . "\n".
html_tag( 'th',
- "<a href=\"$self?year=".($year+1)."&month=$month\">".($year+1)." >></a>"
+ "<a href=\"$self?year=".($year+1)."&month=$month\">".($year+1)." >></a>"
)
) . "\n".
html_tag( 'tr',
'', $color[0] ) ."\n";
}
-//main logic for month view of calendar
+/**
+ * main logic for month view of calendar
+ * @return void
+ * @access private
+ */
function drawmonthview() {
- global $year, $month, $day, $color, $calendardata, $todayis;
+ global $year, $month, $color, $calendardata, $todayis;
$aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
$days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
if ( $aday <= $days_in_month && $aday > 0){
echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n".
html_tag( 'div', '', 'right' );
- echo(($cdate==$todayis) ? "<font size=-1 color=$color[1]>[ " . _("TODAY") . " ] " : "<font size=-1>");
- echo "<a href=day.php?year=$year&month=$month&day=";
+ echo(($cdate==$todayis) ? '<font size="-1" color="'.$color[1].'">[ ' . _("TODAY") . " ] " : '<font size="-1">');
+ echo "<a href=day.php?year=$year&month=$month&day=";
echo(($aday<10) ? "0" : "");
echo "$aday>$aday</a></font></div>";
} else {
$i=0;
while ($calfoo = each($calendardata[$cdate])) {
$calbar = $calendardata[$cdate][$calfoo['key']];
- echo ($calbar['priority']==1) ? "<FONT COLOR=\"$color[1]\">$calbar[title]</FONT><br>\n" : "$calbar[title]<br>\n";
+ // FIXME: how to display multiline task
+ $title = '['. $calfoo['key']. '] ' .
+ str_replace(array("\r","\n"),array(' ',' '),htmlspecialchars($calbar['message']));
+ // FIXME: link to nowhere
+ echo "<a href=\"#\" style=\"text-decoration:none; color: "
+ .($calbar['priority']==1 ? $color[1] : $color[6])
+ ."\" title=\"$title\">".htmlspecialchars($calbar['title'])."</a><br />\n";
$i=$i+1;
if($i==2){
break;
}
}
-//end of monthly view and form to jump to any month and year
+/**
+ * end of monthly view and form to jump to any month and year
+ * @return void
+ * @access private
+ */
function endcalendar() {
global $year, $month, $day, $color;
echo html_tag( 'tr' ) ."\n" .
html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" .
- " <FORM NAME=caljump ACTION=\"calendar.php\" METHOD=POST>\n".
- " <SELECT NAME=\"year\">\n";
+ " <form name=\"caljump\" action=\"calendar.php\" method=\"post\">\n".
+ " <select name=\"year\">\n";
select_option_year($year);
- echo " </SELECT>\n".
- " <SELECT NAME=\"month\">\n";
+ echo " </select>\n".
+ " <select name=\"month\">\n";
select_option_month($month);
- echo " </SELECT>\n".
- ' <INPUT TYPE=SUBMIT VALUE="' . _("Go") . "\">\n".
- " </FORM>\n".
- " </TD></TR>\n".
- "</TABLE></TD></TR></TABLE>\n";
+ echo " </select>\n".
+ ' <input type="submit" value="' . _("Go") . "\" />\n".
+ " </form>\n".
+ " </td></tr>\n".
+ "</table></td></tr></table>\n";
}