* calendar_view.c event.c floors.c graphics.c html2html.c iconbar.c: i18n
[citadel.git] / webcit / calendar_view.c
index 4f46c51cd3e0515ac459326b3df7da3f8aebe6e4..062df0c4dbbe5dbfa831affb074d843cab1943a8 100644 (file)
@@ -1,39 +1,24 @@
 /*
  * $Id$
  *
- *
+ * Handles the HTML display of calendar items.
  */
 
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <limits.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <string.h>
-#include <pwd.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <pthread.h>
-#include <signal.h>
-#include <time.h>
 #include "webcit.h"
 #include "webserver.h"
 
 #ifndef WEBCIT_WITH_CALENDAR_SERVICE
 
 void do_calendar_view(void) {  /* stub for non-libical builds */
-       wprintf("<CENTER><I>Calendar view not available</I></CENTER><br />\n");
+       wprintf("<CENTER><I>");
+       wprintf(_("The calendar view is not available."));
+       wprintf("</I></CENTER><br />\n");
 }
 
 void do_tasks_view(void) {     /* stub for non-libical builds */
-       wprintf("<CENTER><I>Tasks view not available</I></CENTER><br />\n");
+       wprintf("<CENTER><I>");
+       wprintf(_("The tasks view is not available."));
+       wprintf("</I></CENTER><br />\n");
 }
 
 #else  /* WEBCIT_WITH_CALENDAR_SERVICE */
@@ -78,14 +63,6 @@ void calendar_month_view_display_events(time_t thetime) {
                                localtime_r(&event_tt, &event_tm);
                        }
 
-lprintf(9, "Event: %04d-%s-%02d, Now: %04d-%s-%02d\n",
-       event_tm.tm_year + 1900,
-       ascmonths[event_tm.tm_mon],
-       event_tm.tm_mday,
-       today_tm.tm_year + 1900,
-       ascmonths[today_tm.tm_mon],
-       today_tm.tm_mday);
-
                        if ((event_tm.tm_year == today_tm.tm_year)
                           && (event_tm.tm_mon == today_tm.tm_mon)
                           && (event_tm.tm_mday == today_tm.tm_mday)) {
@@ -163,7 +140,8 @@ void calendar_month_view(int year, int month, int day) {
        }
 
        /* Outer table (to get the background color) */
-       wprintf("<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
+       wprintf("<div id=\"fix_scrollbar_bug\">"
+               "<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
                "bgcolor=#204B78><TR><TD>\n");
 
        wprintf("<TABLE width=100%% border=0 cellpadding=0 cellspacing=0><tr>\n");
@@ -173,7 +151,7 @@ void calendar_month_view(int year, int month, int day) {
        localtime_r(&previous_month, &tm);
        wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
                (int)(tm.tm_year)+1900, tm.tm_mon + 1);
-       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/back.gif\" BORDER=0></A>\n");
+       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/prevdate_32x.gif\" BORDER=0></A>\n");
 
        wprintf("&nbsp;&nbsp;"
                "<FONT SIZE=+1 COLOR=\"#FFFFFF\">"
@@ -184,7 +162,7 @@ void calendar_month_view(int year, int month, int day) {
        localtime_r(&next_month, &tm);
        wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
                (int)(tm.tm_year)+1900, tm.tm_mon + 1);
-       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/forward.gif\" BORDER=0></A>\n");
+       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/nextdate_32x.gif\" BORDER=0></A>\n");
 
        wprintf("</TD></TR></TABLE>\n");
 
@@ -206,7 +184,7 @@ void calendar_month_view(int year, int month, int day) {
                        wprintf("<TR>");
                }
 
-               wprintf("<TD BGCOLOR=\"#%s\" WIDTH=14%% HEIGHT=60 VALIGN=TOP><B>",
+               wprintf("<TD BGCOLOR=\"#%s\" WIDTH=14%% HEIGHT=60 align=left VALIGN=TOP><B>",
                        ((tm.tm_mon != month-1) ? "DDDDDD" :
                        ((tm.tm_wday==0 || tm.tm_wday==6) ? "EEEECC" :
                        "FFFFFF"))
@@ -236,7 +214,7 @@ void calendar_month_view(int year, int month, int day) {
 
        wprintf("</TABLE>"                      /* end of inner table */
                "</TD></TR></TABLE>"            /* end of outer table */
-               "</CENTER>\n");
+               "</div>\n");
 }
 
 
@@ -259,7 +237,7 @@ void calendar_day_view_display_events(int year, int month,
        int all_day_event = 0;
 
        if (WC->num_cal == 0) {
-               wprintf("<br /><br /><br />\n");
+               // FIXME wprintf("<br /><br /><br />\n");
                return;
        }
 
@@ -322,7 +300,9 @@ void calendar_day_view_display_events(int year, int month,
 void calendar_day_view(int year, int month, int day) {
        int hour;
        struct icaltimetype today, yesterday, tomorrow;
+       char calhourformat[16];
 
+       get_preference("calhourformat", calhourformat, sizeof calhourformat);
 
        /* Figure out the dates for "yesterday" and "tomorrow" links */
 
@@ -342,7 +322,8 @@ void calendar_day_view(int year, int month, int day) {
 
 
        /* Outer table (to get the background color) */
-       wprintf("<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
+       wprintf("<div id=\"fix_scrollbar_bug\">"
+               "<TABLE width=100%% border=0 cellpadding=0 cellspacing=0 "
                "bgcolor=#204B78><TR><TD>\n");
 
        /* Inner table (the real one) */
@@ -371,10 +352,17 @@ void calendar_day_view(int year, int month, int day) {
                        "&year=%d&month=%d&day=%d&hour=%d&minute=0\">",
                        year, month, day, hour
                );
-               wprintf("%d:00%s</A> ",
-                       (hour <= 12 ? hour : hour-12),
-                       (hour < 12 ? "am" : "pm")
-               );
+
+               if (!strcasecmp(calhourformat, "24")) {
+                       wprintf("%2d:00</A> ", hour);
+               }
+               else {
+                       wprintf("%d:00%s</A> ",
+                               (hour <= 12 ? hour : hour-12),
+                               (hour < 12 ? "am" : "pm")
+                       );
+               }
+
                wprintf("</TD><TD BGCOLOR=\"#FFFFFF\" VALIGN=TOP>");
 
                /* put the data here, stupid */
@@ -409,7 +397,7 @@ void calendar_day_view(int year, int month, int day) {
        wprintf("<TD ALIGN=CENTER>");
        wprintf("<A HREF=\"readfwd?calview=day&year=%d&month=%d&day=%d\">",
                yesterday.year, yesterday.month, yesterday.day);
-       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/back.gif\" BORDER=0></A>");
+       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/prevdate_32x.gif\" BORDER=0></A>");
        wprintf("</TD>");
 
        /* Today's date */
@@ -424,23 +412,14 @@ void calendar_day_view(int year, int month, int day) {
        wprintf("<TD ALIGN=CENTER>");
        wprintf("<A HREF=\"readfwd?calview=day&year=%d&month=%d&day=%d\">",
                tomorrow.year, tomorrow.month, tomorrow.day);
-       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/forward.gif\""
+       wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/nextdate_32x.gif\""
                " BORDER=0></A>\n");
        wprintf("</TD>");
 
        wprintf("</TR></TABLE>\n");
        /* End todays-date-with-left-and-right-arrows */
 
-       wprintf("<br /><br /><CENTER><font color=#FFFFFF>"
-               "&nbsp;<A HREF=\"/display_edit_event?msgnum=0"
-               "&year=%d&month=%d&day=%d\">"
-               "Add new calendar event</A>"
-               "<br /><br />\n",
-               year, month, day
-       );
-
-       wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">"
-               "Back to month view</A>\n", year, month);
+       /* In the future we might want to put a month-o-matic here */
 
        wprintf("</FONT></CENTER>\n");
 
@@ -449,7 +428,7 @@ void calendar_day_view(int year, int month, int day) {
 
 
        wprintf("</TR></TABLE>"                 /* end of inner table */
-               "</TD></TR></TABLE>"            /* end of outer table */
+               "</TD></TR></TABLE></div>"      /* end of outer table */
        );
 
 
@@ -629,11 +608,13 @@ void do_tasks_view(void) {
        char buf[SIZ];
        icalproperty *p;
 
-       do_template("beginbox_nt");
-
-       wprintf("<TABLE BORDER=0 CELLSPACING=0 WIDTH=100%%>\n<TR>\n"
-               "<TH>Name of task</TH>\n"
-               "<TH>Date due</TH></TR>\n"
+       wprintf("<div id=\"fix_scrollbar_bug\">"
+               "<table border=0 cellspacing=0 width=100%% bgcolor=\"#FFFFFF\">\n<tr>\n"
+               "<TH>");
+       wprintf(_("Name of task"));
+       wprintf("</TH><TH>");
+       wprintf(_("Date due"));
+       wprintf("</TH></TR>\n"
        );
 
        /* Sort them if necessary */
@@ -658,6 +639,8 @@ void do_tasks_view(void) {
                        WC->disp_cal[i].cal_msgnum );
                urlescputs(WC->wc_roomname);
                wprintf("\">");
+               wprintf("<IMG ALIGN=MIDDLE "
+                       "SRC=\"/static/taskmanag_16x.gif\" BORDER=0>&nbsp;");
                if (p != NULL) {
                        escputs((char *)icalproperty_get_comment(p));
                }
@@ -665,7 +648,7 @@ void do_tasks_view(void) {
                wprintf("</TD>\n");
 
                due = get_task_due_date(WC->disp_cal[i].cal);
-               fmt_date(buf, due);
+               fmt_date(buf, due, 0);
                wprintf("<TD><FONT");
                if (due < time(NULL)) {
                        wprintf(" COLOR=\"#FF0000\"");
@@ -673,14 +656,7 @@ void do_tasks_view(void) {
                wprintf(">%s</FONT></TD></TR>\n", buf);
        }
 
-       wprintf("</TABLE>\n");
-
-       wprintf("<hr /><A HREF=\"/display_edit_task?msgnum=0\">"
-               "Add new task</A>\n"
-       );
-
-       do_template("endbox");
-
+       wprintf("</table></div>\n");
 
        /* Free the list */
        free_calendar_buffer();