All this document.write stuff is overkill when we already have checkForJavascript...
[squirrelmail.git] / plugins / calendar / day.php
index 36ae7171bb6acbf8e26cb4c7d645c11d02e84590..a2a2049bf73610e2ba67e96b152fc590bf4db998 100644 (file)
@@ -1,41 +1,70 @@
 <?php
-/*
- *  day.php
- *
- *  Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
- *  Licensed under the GNU GPL. For full terms see the file COPYING.
- *
- *  Displays the day page (day view).
+
+/**
+ * Displays the day page (day view).
  *
- * $Id$
+ * @copyright &copy; 2002-2007 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package plugins
+ * @subpackage calendar
+ */
+
+/**
+ * Include the SquirrelMail initialization file.
  */
+require('../../include/init.php');
 
-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');
-
-//displays head of day calendar view
+/* 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('year',$year,SQ_FORM) || ! is_numeric($year)) {
+    unset($year);
+}
+if (! sqGetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
+    unset($month);
+}
+if (! sqGetGlobalVar('day',$day,SQ_FORM) || ! is_numeric($day)) {
+    unset($day);
+}
+/* got 'em */
+
+/**
+ * displays head of day calendar view
+ * @return void
+ * @access private
+ */
 function day_header() {
     global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day,
            $prev_date, $next_month, $next_day, $next_year, $next_date;
 
-    echo "    <TR BGCOLOR=\"$color[0]\"><TD>" .
-         "         <TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n" .
-         "         <TR><TH WIDTH=\"5%\" ALIGN=LEFT><A HREF=\"day.php?year=$prev_year&month=$prev_month&day=$prev_day\">&lt;&nbsp;".
-         date_intl('D',$prev_date)."</A></TH>\n" .
-         "         <TH WIDTH=\"75%\">" .
-         date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)) . "</TH>\n" .
-         "         <TH ALIGN=RIGHT><A HREF=\"day.php?year=$next_year&month=$next_month&day=$next_day\">".
-         date_intl('D',$next_date)."&nbsp;&gt;</A></TH></TR>\n";
+    echo html_tag( 'tr', '', '', $color[0] ) . "\n".
+                html_tag( 'td', '', 'left' ) .
+                    html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n" .
+                        html_tag( 'tr',
+                            html_tag( 'th',
+                                "<a href=\"day.php?year=$prev_year&amp;month=$prev_month&amp;day=$prev_day\">&lt;&nbsp;".
+                                date_intl('D',$prev_date)."</a>",
+                            'left' ) .
+                            html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
+                                '', '', 'width="75%"' ) .
+                            html_tag( 'th',
+                                "<a href=\"day.php?year=$next_year&amp;month=$next_month&amp;day=$next_day\">".
+                                date_intl('D',$next_date)."&nbsp;&gt;</a>" ,
+                            'right' )
+                        );
 }
 
-//events for specific day  are inserted into "daily" array
+/**
+ * events for specific day  are inserted into "daily" array
+ * @return void
+ * @access private
+ */
 function initialize_events() {
     global $daily_events, $calendardata, $month, $day, $year;
 
@@ -57,7 +86,11 @@ function initialize_events() {
     }
 }
 
-//main loop for displaying daily events
+/**
+ * main loop for displaying daily events
+ * @return void
+ * @access private
+ */
 function display_events() {
     global $daily_events, $month, $day, $year, $color;
 
@@ -73,32 +106,45 @@ function display_events() {
         $ehour = substr($calfoo['key'],0,2);
         $eminute = substr($calfoo['key'],2,2);
         if (!is_array($calfoo['value'])){
-            echo "         <TR BGCOLOR=\"$color[$eo]\"><TD>$ehour:$eminute</TD>\n" .
-                 "              <TD>&nbsp;</TD>\n" .
-                 "              <TD ALIGN=CENTER><FONT SIZE=-1><A HREF=\"event_create.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."\">".
-                 _("ADD") . "</A></FONT></TD></TR>\n";
+            echo html_tag( 'tr',
+                       html_tag( 'td', $ehour . ':' . $eminute, 'left' ) .
+                       html_tag( 'td', '&nbsp;', 'left' ) .
+                       html_tag( 'td',
+                           "<font size=\"-1\"><a href=\"event_create.php?year=$year&amp;month=$month&amp;day=$day&amp;hour="
+                           .substr($calfoo['key'],0,2)."\">".
+                           _("ADD") . "</a></font>" ,
+                       'center' ) ,
+                   '', $color[$eo]);
+
         } else {
             $calbar=$calfoo['value'];
             if ($calbar['length']!=0){
-                $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
+                $elength = '-'.date_intl(_("H:i"),mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
             } else {
                 $elength='';
             }
-            echo "         <TR BGCOLOR=\"$color[$eo]\"><TD>$ehour:$eminute$elength</TD>\n" .
-                 "              <TD>[";
-            echo ($calbar['priority']==1) ? "<FONT COLOR=\"$color[1]\">$calbar[title]</FONT>" : "$calbar[title]";
-            echo"] $calbar[message]&nbsp;</TD>\n" .
-                 "              <TD ALIGN=CENTER><FONT SIZE=-1><nobr>\n" .
-                 "<A HREF=\"event_edit.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."&minute=".substr($calfoo['key'],2,2)."\">".
-                 _("EDIT") . "</A>&nbsp;|&nbsp;\n" .
-                 "<A HREF=\"event_delete.php?dyear=$year&dmonth=$month&dday=$day&dhour=".substr($calfoo['key'],0,2)."&dminute=".substr($calfoo['key'],2,2)."&year=$year&month=$month&day=$day\">" .
-                 _("DEL") . '</A>' .
-                 "              </nobr></FONT></TD></TR>\n";
+            echo html_tag( 'tr', '', '', $color[$eo] ) .
+                        html_tag( 'td', date_intl(_("H:i"),mktime($ehour,$eminute,0,1,1,0)) . $elength, 'left' ) .
+                        html_tag( 'td', '', 'left' ) . '[';
+                            echo ($calbar['priority']==1) ?
+                                "<font color=\"$color[1]\">".htmlspecialchars($calbar['title']).'</font>' :
+                                htmlspecialchars($calbar['title']);
+                            echo'] <div style="margin-left:10px">'.nl2br(htmlspecialchars($calbar['message'])).'</div>' .
+                        html_tag( 'td',
+                            "<font size=\"-1\"><nobr>\n" .
+                            "<a href=\"event_edit.php?year=$year&amp;month=$month&amp;day=$day&amp;hour=".
+                            substr($calfoo['key'],0,2)."&amp;minute=".substr($calfoo['key'],2,2)."\">".
+                            _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
+                            "<a href=\"event_delete.php?dyear=$year&amp;dmonth=$month&amp;dday=$day&amp;dhour=".
+                            substr($calfoo['key'],0,2)."&amp;dminute=".substr($calfoo['key'],2,2).
+                            "&amp;year=$year&amp;month=$month&amp;day=$day\">" .
+                            _("DEL") . '</a>' .
+                            "</nobr></font>\n" ,
+                        'center' );
+        }
     }
 }
-
-
-}
+/* end of day functions */
 
 if ($month <= 0){
     $month = date( 'm');
@@ -131,4 +177,4 @@ initialize_events();
 display_events();
 ?>
 </table></td></tr></table>
-</body></html>
+</body></html>
\ No newline at end of file