wiki.c

00001 /*
00002  * $Id: wiki.c 5147 2007-05-08 15:36:22Z ajc $
00003  */
00011 #include "webcit.h"
00012 #include "groupdav.h"
00013 
00014 
00015 
00021 void str_wiki_index(char *s)
00022 {
00023         int i;
00024 
00025         if (s == NULL) return;
00026 
00027         /* First remove all non-alphanumeric characters */
00028         for (i=0; i<strlen(s); ++i) {
00029                 if (!isalnum(s[i])) {
00030                         strcpy(&s[i], &s[i+1]);
00031                 }
00032         }
00033 
00034         /* Then make everything lower case */
00035         for (i=0; i<strlen(s); ++i) {
00036                 s[i] = tolower(s[i]);
00037         }
00038 }
00039 
00043 void display_wiki_page(void)
00044 {
00045         char roomname[128];
00046         char pagename[128];
00047         char errmsg[256];
00048         long msgnum = (-1L);
00049 
00050         safestrncpy(roomname, bstr("room"), sizeof roomname);
00051         safestrncpy(pagename, bstr("page"), sizeof pagename);
00052         str_wiki_index(pagename);
00053 
00054         if (strlen(roomname) > 0) {
00055 
00056                 /* If we're not in the correct room, try going there. */
00057                 if (strcasecmp(roomname, WC->wc_roomname)) {
00058                         gotoroom(roomname);
00059                 }
00060         
00061                 /* If we're still not in the correct room, it doesn't exist. */
00062                 if (strcasecmp(roomname, WC->wc_roomname)) {
00063                         snprintf(errmsg, sizeof errmsg,
00064                                 _("There is no room called '%s'."),
00065                                 roomname);
00066                         convenience_page("FF0000", _("Error"), errmsg);
00067                         return;
00068                 }
00069 
00070         }
00071 
00072         if (WC->wc_view != VIEW_WIKI) {
00073                 snprintf(errmsg, sizeof errmsg,
00074                         _("'%s' is not a Wiki room."),
00075                         roomname);
00076                 convenience_page("FF0000", _("Error"), errmsg);
00077                 return;
00078         }
00079 
00080         if (strlen(pagename) == 0) {
00081                 strcpy(pagename, "home");
00082         }
00083 
00084         /* Found it!  Now read it. */
00085         msgnum = locate_message_by_uid(pagename);
00086         if (msgnum >= 0L) {
00087                 output_headers(1, 1, 1, 0, 0, 0);
00088                 read_message(msgnum, 0, "");
00089                 wDumpContent(1);
00090                 return;
00091         }
00092 
00093         output_headers(1, 1, 1, 0, 0, 0);
00094         wprintf("<br /><br />"
00095                 "<div align=\"center\">"
00096                 "<table border=\"0\" bgcolor=\"#ffffff\" cellpadding=\"10\">"
00097                 "<tr><td align=\"center\">"
00098         );
00099         wprintf("<br><b>");
00100         wprintf(_("There is no page called '%s' here."), pagename);
00101         wprintf("</b><br><br>");
00102         wprintf(_("Select the 'Edit this page' link in the room banner "
00103                 "if you would like to create this page."));
00104         wprintf("<br><br>");
00105         wprintf("</td></tr></table></div>\n");
00106         wDumpContent(1);
00107 }
00108 
00109 

Generated on Wed Jun 20 23:13:12 2007 for webcit by  doxygen 1.5.2