Began making changes to do better handling of character sets.
[citadel.git] / webcit / wiki.c
index dc72dba059d2a517859bb7d694d69def15ebe2b6..0f35b6150a2a8b00e8b689c138fbf613ec9bd034 100644 (file)
@@ -4,11 +4,12 @@
 /**
  *
  * \defgroup Wiki Wiki; Functions pertaining to rooms with a wiki view
- *
+ * \ingroup WebcitDisplayItems
  */
 
 /*@{*/
 #include "webcit.h"
+#include "groupdav.h"
 
 
 
@@ -38,16 +39,70 @@ void str_wiki_index(char *s)
 
 /**
  * \brief Display a specific page from a wiki room
- *
- * \param roomname The name of the room containing the wiki
- * \param pagename The index of the page being requested
  */
-void display_wiki_page(char *roomname, char *pagename)
+void display_wiki_page(void)
 {
-       output_headers(1, 1, 1, 0, 0, 0);
+       char roomname[128];
+       char pagename[128];
+       char errmsg[256];
+       long msgnum = (-1L);
+
+       safestrncpy(roomname, bstr("room"), sizeof roomname);
+       safestrncpy(pagename, bstr("page"), sizeof pagename);
+       str_wiki_index(pagename);
+
+       if (strlen(roomname) > 0) {
+
+               /* If we're not in the correct room, try going there. */
+               if (strcasecmp(roomname, WC->wc_roomname)) {
+                       gotoroom(roomname);
+               }
+       
+               /* If we're still not in the correct room, it doesn't exist. */
+               if (strcasecmp(roomname, WC->wc_roomname)) {
+                       snprintf(errmsg, sizeof errmsg,
+                               _("There is no room called '%s'."),
+                               roomname);
+                       convenience_page("FF0000", _("Error"), errmsg);
+                       return;
+               }
 
-       wprintf("roomname=%s<br>pagename=%s<br>\n", roomname, pagename);
+       }
+
+       if (WC->wc_view != VIEW_WIKI) {
+               snprintf(errmsg, sizeof errmsg,
+                       _("'%s' is not a Wiki room."),
+                       roomname);
+               convenience_page("FF0000", _("Error"), errmsg);
+               return;
+       }
+
+       if (strlen(pagename) == 0) {
+               strcpy(pagename, "home");
+       }
+
+       /* Found it!  Now read it. */
+       msgnum = locate_message_by_uid(pagename);
+       if (msgnum >= 0L) {
+               output_headers(1, 1, 1, 0, 0, 0);
+               read_message(msgnum, 0, "");
+               wDumpContent(1);
+               return;
+       }
 
+       output_headers(1, 1, 1, 0, 0, 0);
+       wprintf("<br /><br />"
+               "<div align=\"center\">"
+               "<table border=\"0\" bgcolor=\"#ffffff\" cellpadding=\"10\">"
+               "<tr><td align=\"center\">"
+       );
+       wprintf("<br><b>");
+       wprintf(_("There is no page called '%s' here."), pagename);
+       wprintf("</b><br><br>");
+       wprintf(_("Select the 'Edit this page' link in the room banner "
+               "if you would like to create this page."));
+       wprintf("<br><br>");
+       wprintf("</td></tr></table></div>\n");
        wDumpContent(1);
 }