/*
* $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 */
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)) {
}
wprintf("<FONT SIZE=-1>"
- "<A HREF=\"/display_edit_event?msgnum=%ld&calview=%s&year=%s&month=%s&day=%s\">",
+ "<a href=\"display_edit_event?msgnum=%ld&calview=%s&year=%s&month=%s&day=%s\">",
WC->disp_cal[i].cal_msgnum,
bstr("calview"),
bstr("year"),
}
/* 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");
wprintf("<TD ALIGN=CENTER>");
localtime_r(&previous_month, &tm);
- wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
+ 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(" "
"<FONT SIZE=+1 COLOR=\"#FFFFFF\">"
" ", months[month-1], year);
localtime_r(&next_month, &tm);
- wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
+ 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");
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"))
if ((i==0) || (tm.tm_mday == 1)) {
wprintf("%s ", months[tm.tm_mon]);
}
- wprintf("<A HREF=\"readfwd?calview=day&year=%d&month=%d&day=%d\">"
+ wprintf("<a href=\"readfwd?calview=day&year=%d&month=%d&day=%d\">"
"%d</A></B><br />",
tm.tm_year + 1900,
tm.tm_mon + 1,
wprintf("</TABLE>" /* end of inner table */
"</TD></TR></TABLE>" /* end of outer table */
- "</CENTER>\n");
+ "</div>\n");
}
int all_day_event = 0;
if (WC->num_cal == 0) {
- wprintf("<br /><br /><br />\n");
+ // FIXME wprintf("<br /><br /><br />\n");
return;
}
if (p != NULL) {
t = icalproperty_get_dtstart(p);
event_tt = icaltime_as_timet(t);
- if (t.is_date) all_day_event = 1;
+ if (t.is_date) {
+ all_day_event = 1;
+ }
+ else {
+ all_day_event = 0;
+ }
if (all_day_event) {
event_tm = gmtime(&event_tt);
}
wprintf("<FONT SIZE=-1>"
- "<A HREF=\"/display_edit_event?msgnum=%ld&calview=day&year=%d&month=%d&day=%d\">",
+ "<a href=\"display_edit_event?msgnum=%ld&calview=day&year=%d&month=%d&day=%d\">",
WC->disp_cal[i].cal_msgnum,
year, month, day
);
void calendar_day_view(int year, int month, int day) {
int hour;
struct icaltimetype today, yesterday, tomorrow;
-
+ char calhourformat[16];
+ int daystart = 8;
+ int dayend = 17;
+ char daystart_str[16], dayend_str[16];
+
+ get_preference("calhourformat", calhourformat, sizeof calhourformat);
+ get_preference("daystart", daystart_str, sizeof daystart_str);
+ if (strlen(daystart_str) > 0) daystart = atoi(daystart_str);
+ get_preference("dayend", dayend_str, sizeof dayend_str);
+ if (strlen(dayend_str) > 0) dayend = atoi(dayend_str);
+
/* Figure out the dates for "yesterday" and "tomorrow" links */
/* 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) */
wprintf("<TR>"
"<TD BGCOLOR=\"#CCCCDD\" VALIGN=MIDDLE WIDTH=10%%></TD>"
"<TD BGCOLOR=\"#FFFFFF\" VALIGN=TOP>");
- for (hour = (-1); hour <= 7; ++hour) {
+ for (hour = (-1); hour <= (daystart-1); ++hour) {
calendar_day_view_display_events(year, month, day, hour);
}
wprintf("</TD></TR>\n");
/* Now the middle of the day... */
- for (hour = 8; hour <= 17; ++hour) { /* could do HEIGHT=xx */
+ for (hour = daystart; hour <= dayend; ++hour) { /* could do HEIGHT=xx */
wprintf("<TR HEIGHT=30><TD BGCOLOR=\"#CCCCDD\" ALIGN=MIDDLE "
"VALIGN=MIDDLE WIDTH=10%%>");
- wprintf("<A HREF=\"/display_edit_event?msgnum=0"
+ wprintf("<a href=\"display_edit_event?msgnum=0"
"&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 */
wprintf("<TR>"
"<TD BGCOLOR=\"#CCCCDD\" VALIGN=MIDDLE WIDTH=10%%></TD>"
"<TD BGCOLOR=\"#FFFFFF\" VALIGN=TOP>");
- for (hour = 18; hour <= 23; ++hour) {
+ for (hour = (dayend+1); hour <= 23; ++hour) {
calendar_day_view_display_events(year, month, day, hour);
}
wprintf("</TD></TR>\n");
/* Left arrow */
wprintf("<TD ALIGN=CENTER>");
- wprintf("<A HREF=\"readfwd?calview=day&year=%d&month=%d&day=%d\">",
+ 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 */
/* Right arrow */
wprintf("<TD ALIGN=CENTER>");
- wprintf("<A HREF=\"readfwd?calview=day&year=%d&month=%d&day=%d\">",
+ 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>"
- " <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");
wprintf("</TR></TABLE>" /* end of inner table */
- "</TD></TR></TABLE>" /* end of outer table */
+ "</TD></TR></TABLE></div>" /* end of outer table */
);
if (p != NULL) {
t = icalproperty_get_dtstart(p);
event_tt = icaltime_as_timet(t);
- if (t.is_date) all_day_event = 1;
+ if (t.is_date) {
+ all_day_event = 1;
+ }
+ else {
+ all_day_event = 0;
+ }
fmt_time(timestring, event_tt);
if (all_day_event) {
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 */
p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
ICAL_SUMMARY_PROPERTY);
- wprintf("<A HREF=\"/display_edit_task?msgnum=%ld&taskrm=",
+ wprintf("<a href=\"display_edit_task?msgnum=%ld&taskrm=",
WC->disp_cal[i].cal_msgnum );
urlescputs(WC->wc_roomname);
wprintf("\">");
+ wprintf("<IMG ALIGN=MIDDLE "
+ "src=\"static/taskmanag_16x.gif\" BORDER=0> ");
if (p != NULL) {
escputs((char *)icalproperty_get_comment(p));
}
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\"");
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();