]> code.citadel.org Git - citadel.git/blobdiff - webcit/calendar_view.c
* Created IsEmptyStr define to be used rather then using some weird strlen constructs
[citadel.git] / webcit / calendar_view.c
index dde6f216908bf6dd484c08c91e64e8b9edbbf0b0..54ebc2be1432340600fb1202575a3e69da6bdeb1 100644 (file)
@@ -38,10 +38,13 @@ void calendar_month_view_display_events(time_t thetime) {
        time_t event_tt;
        struct tm event_tm;
        struct tm today_tm;
-       icalproperty *p;
+       icalproperty *p = NULL;
+       icalproperty *q = NULL;
        struct icaltimetype t;
        int month, day, year;
        int all_day_event = 0;
+       time_t tt;
+       char buf[256];
 
        if (WC->num_cal == 0) {
                wprintf("<br /><br /><br />\n");
@@ -86,13 +89,85 @@ void calendar_month_view_display_events(time_t thetime) {
                                        }
 
                                        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\""
+                                               " btt_tooltext=\"",
                                                WC->disp_cal[i].cal_msgnum,
                                                bstr("calview"),
                                                bstr("year"),
                                                bstr("month"),
                                                bstr("day")
                                        );
+
+                                       wprintf("<i>%s</i> ", _("Summary:"));
+                                       escputs((char *)icalproperty_get_comment(p));
+                                       wprintf("<br />");
+
+                                       q = icalcomponent_get_first_property(
+                                                       WC->disp_cal[i].cal,
+                                                       ICAL_LOCATION_PROPERTY);
+                                       if (q) {
+                                               wprintf("<i>%s</i> ", _("Location:"));
+                                               escputs((char *)icalproperty_get_comment(q));
+                                               wprintf("<br />");
+                                       }
+
+                                       /**
+                                        * Only show start/end times if we're actually looking at the VEVENT
+                                        * component.  Otherwise it shows bogus dates for e.g. timezones
+                                        */
+                                       if (icalcomponent_isa(WC->disp_cal[i].cal) == ICAL_VEVENT_COMPONENT) {
+                               
+                                               q = icalcomponent_get_first_property(WC->disp_cal[i].cal,
+                                                                               ICAL_DTSTART_PROPERTY);
+                                               if (q != NULL) {
+                                                       t = icalproperty_get_dtstart(q);
+                               
+                                                       if (t.is_date) {
+                                                               struct tm d_tm;
+                                                               char d_str[32];
+                                                               memset(&d_tm, 0, sizeof d_tm);
+                                                               d_tm.tm_year = t.year - 1900;
+                                                               d_tm.tm_mon = t.month - 1;
+                                                               d_tm.tm_mday = t.day;
+                                                               wc_strftime(d_str, sizeof d_str, "%x", &d_tm);
+                                                               wprintf("<i>%s</i> %s<br>",
+                                                                       _("Date:"), d_str);
+                                                       }
+                                                       else {
+                                                               tt = icaltime_as_timet(t);
+                                                               fmt_date(buf, tt, 1);
+                                                               wprintf("<i>%s</i> %s<br>",
+                                                                       _("Starting date/time:"), buf);
+
+                                                               /* Embed the 'show end date/time' loop inside here so it
+                                                                * only executes if this is NOT an all day event.
+                                                                */
+                                                               q = icalcomponent_get_first_property(WC->disp_cal[i].cal,
+                                                                                                       ICAL_DTEND_PROPERTY);
+                                                               if (q != NULL) {
+                                                                       t = icalproperty_get_dtend(q);
+                                                                       tt = icaltime_as_timet(t);
+                                                                       fmt_date(buf, tt, 1);
+                                                                       wprintf("<i>%s</i> %s<br>",
+                                                                               _("Ending date/time:"), buf);
+                                                               }
+
+                                                       }
+                                               }
+                                       
+                                       }
+
+                                       q = icalcomponent_get_first_property(
+                                                       WC->disp_cal[i].cal,
+                                                       ICAL_DESCRIPTION_PROPERTY);
+                                       if (q) {
+                                               wprintf("<i>%s</i> ", _("Notes:"));
+                                               escputs((char *)icalproperty_get_comment(q));
+                                               wprintf("<br />");
+                                       }
+
+                                       wprintf("\">");
                                        escputs((char *)
                                                icalproperty_get_comment(p));
                                        wprintf("</a></font><br />\n");
@@ -289,7 +364,7 @@ void calendar_month_view(int year, int month, int day) {
 
        /** Inner table (the real one) */
        wprintf("<table width=100%% border=0 cellpadding=1 cellspacing=1 "
-               "bgcolor=#204B78><tr>");
+               "bgcolor=#204B78 id=\"inner_month\"><tr>");
        colheader_time = thetime;
        for (i=0; i<7; ++i) {
                colheader_time = thetime + (i * 86400) ;
@@ -342,6 +417,22 @@ void calendar_month_view(int year, int month, int day) {
        wprintf("</table>"                      /** end of inner table */
                "</td></tr></table>"            /** end of outer table */
                "</div>\n");
+
+       /**
+        * Initialize the bubble tooltips.
+        *
+        * Yes, this is as stupid as it looks.  Instead of just making the call
+        * to btt_enableTooltips() straight away, we have to create a timer event
+        * and let it initialize as an event after 1 millisecond.  This is to
+        * work around a bug in Internet Explorer that causes it to crash if we
+        * manipulate the innerHTML of various DOM nodes while the page is still
+        * being rendered.  See http://www.shaftek.org/blog/archives/000212.html
+        * for more information.
+        */ 
+       wprintf("<script type=\"text/javascript\">"
+               " setTimeout(\"btt_enableTooltips('inner_month')\", 1); "
+               "</script>\n"
+       );
 }
 
 /**
@@ -431,7 +522,7 @@ void calendar_brief_month_view(int year, int month, int day) {
                if ((i % 7) == 0) {
                        wc_strftime(&weeknumber[0], sizeof(weeknumber), "%U", &tm);
                        wprintf("<table border='0' bgcolor=\"#EEEECC\" width='100%'> <tr><th colspan='4'>%s %s</th></tr>"
-                                       "   <tr><td>%s</td><td width='70%'>%s</td><td>%s</td><td>%s</td></tr>\n",
+                                       "   <tr><td>%s</td><td width=70%%>%s</td><td>%s</td><td>%s</td></tr>\n",
                                        _("Week"), 
                                        weeknumber,
                                        _("Hours"),
@@ -584,9 +675,9 @@ void calendar_day_view(int year, int month, int day) {
 
        get_preference("calhourformat", calhourformat, sizeof calhourformat);
        get_preference("daystart", daystart_str, sizeof daystart_str);
-       if (strlen(daystart_str) > 0) daystart = atoi(daystart_str);
+       if (!IsEmptyStr(daystart_str)) daystart = atoi(daystart_str);
        get_preference("dayend", dayend_str, sizeof dayend_str);
-       if (strlen(dayend_str) > 0) dayend = atoi(dayend_str);
+       if (!IsEmptyStr(dayend_str)) dayend = atoi(dayend_str);
        
 
        /** Figure out the dates for "yesterday" and "tomorrow" links */
@@ -824,12 +915,12 @@ void do_calendar_view(void) {
        day = tm.tm_mday;
 
        /** Now see if a date was specified */
-       if (strlen(bstr("year")) > 0) year = atoi(bstr("year"));
-       if (strlen(bstr("month")) > 0) month = atoi(bstr("month"));
-       if (strlen(bstr("day")) > 0) day = atoi(bstr("day"));
+       if (!IsEmptyStr(bstr("year"))) year = atoi(bstr("year"));
+       if (!IsEmptyStr(bstr("month"))) month = atoi(bstr("month"));
+       if (!IsEmptyStr(bstr("day"))) day = atoi(bstr("day"));
 
        /** How would you like that cooked? */
-       if (strlen(bstr("calview")) > 0) {
+       if (!IsEmptyStr(bstr("calview"))) {
                strcpy(calview, bstr("calview"));
        }
        else {
@@ -925,7 +1016,7 @@ void do_tasks_view(void) {
        icalproperty *p;
 
        wprintf("<div class=\"fix_scrollbar_bug\">"
-               "<table border=0 cellspacing=0 width=100%% bgcolor=\"#FFFFFF\">\n<tr>\n"
+               "<table class=\"calendar_view_background\">\n<tr>\n"
                "<th>");
        wprintf(_("Name of task"));
        wprintf("</th><th>");