Began making changes to do better handling of character sets.
[citadel.git] / webcit / floors.c
index 48cca50f51fd88a7cf00154a4594b52871eccfc5..d9192854094877b0aca6e8ecd574c18dca43ad43 100644 (file)
@@ -1,36 +1,23 @@
 /*
- * Administrative screens for floor maintenance
- *
+ * $Id$
  */
+/**
+ * \defgroup AdminFloor Administrative screens for floor maintenance
+ * \ingroup CitadelConfig
+ */
+/*@{*/
 
-
-#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 <sys/time.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 "webcit.h"
+#include "webserver.h"
 
 
 
 
-/*
+/**
+ * \brief Display floor config
  * Display floor configuration.  If prepend_html is not NULL, its contents
  * will be displayed at the top of the screen.
+ * \param prepend_html pagetitle to prepend
  */
 void display_floorconfig(char *prepend_html)
 {
@@ -40,85 +27,111 @@ void display_floorconfig(char *prepend_html)
        char floorname[SIZ];
        int refcount;
 
-       output_headers(3);
-
+        output_headers(1, 1, 2, 0, 0, 0);
+        wprintf("<div id=\"banner\">\n"
+                "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
+                "<SPAN CLASS=\"titlebar\">");
+       wprintf(_("Add/change/delete floors"));
+       wprintf("</SPAN>"
+                "</TD></TR></TABLE>\n"
+                "</div>\n<div id=\"content\">\n"
+        );
+                                                                                                                             
        if (prepend_html != NULL) {
-               write(WC->http_sock, prepend_html, strlen(prepend_html));
+               wprintf("<br /><b><i>");
+               client_write(prepend_html, strlen(prepend_html));
+               wprintf("</i></b><br /><br />\n");
        }
 
-       serv_printf("LFLR");    /* FIXME put a real test here */
-       serv_gets(buf);
+       serv_printf("LFLR");
+       serv_getln(buf, sizeof buf);
        if (buf[0] != '1') {
-               wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
-               wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-               wprintf("<B>Error</B>\n");
-               wprintf("</FONT></TD></TR></TABLE><BR>\n");
-               wprintf("%s<BR>\n", &buf[4]);
+               wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
+               wprintf("<SPAN CLASS=\"titlebar\">");
+               wprintf(_("Error"));
+               wprintf("</SPAN>\n");
+               wprintf("</TD></TR></TABLE>\n");
+               wprintf("%s<br />\n", &buf[4]);
                wDumpContent(1);
                return;
        }
 
-       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>"
-               "<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>Floor configuration"
-               "</B></FONT></TD></TR></TABLE>\n"
-       );
-
-       wprintf("<TABLE BORDER=1 WIDTH=100%>\n"
-               "<TR><TH>Floor number</TH>"
-               "<TH>Floor name</TH>"
-               "<TH>Number of rooms</TH></TR>\n"
-       );
-
-       while (serv_gets(buf), strcmp(buf, "000")) {
+       wprintf("<div class=\"fix_scrollbar_bug\">"
+               "<TABLE BORDER=1 WIDTH=100%% bgcolor=\"#ffffff\">\n"
+               "<TR><TH>");
+       wprintf(_("Floor number"));
+       wprintf("</TH><TH>");
+       wprintf(_("Floor name"));
+       wprintf("</TH><TH>");
+       wprintf(_("Number of rooms"));
+       wprintf("</TH><TH>");
+       wprintf(_("Floor CSS"));
+       wprintf("</TH></TR>\n");
+
+       while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
                floornum = extract_int(buf, 0);
-               extract(floorname, buf, 1);
+               extract_token(floorname, buf, 1, '|', sizeof floorname);
                refcount = extract_int(buf, 2);
 
                wprintf("<TR><TD><TABLE border=0><TR><TD>%d", floornum);
                if (refcount == 0) {
                        wprintf("</TD><TD>"
-                               "<A HREF=\"/delete_floor?floornum=%d\">"
-                               "<FONT SIZE=-1>(delete floor)</A>"
-                               "</FONT><BR>", floornum
-                       );
+                               "<a href=\"delete_floor?floornum=%d\">"
+                               "<FONT SIZE=-1>", floornum);
+                       wprintf(_("(delete floor)"));
+                       wprintf("</A></FONT><br />");
                }
                wprintf("<FONT SIZE=-1>"
-                       "<A HREF=\"/display_editfloorpic&"
-                       "which_floor=%d\">(edit graphic)</A>",
-                       floornum);
-               wprintf("</TD></TR></TABLE>");
+                       "<a href=\"display_editfloorpic&"
+                       "which_floor=%d\">", floornum);
+               wprintf(_("(edit graphic)"));
+               wprintf("</A></TD></TR></TABLE>");
                wprintf("</TD>");
 
                wprintf("<TD>"
-                       "<FORM METHOD=\"POST\" ACTION=\"/rename_floor\">"
+                       "<FORM METHOD=\"POST\" action=\"rename_floor\">"
                        "<INPUT TYPE=\"hidden\" NAME=\"floornum\" "
                        "VALUE=\"%d\">"
                        "<INPUT TYPE=\"text\" NAME=\"floorname\" "
                        "VALUE=\"%s\" MAXLENGTH=\"250\">\n",
                        floornum, floorname);
                wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
-                       "VALUE=\"Change name\">"
-                       "</FORM></TD>");
+                       "VALUE=\"%s\">"
+                       "</FORM></TD>", _("Change name"));
 
-               wprintf("<TD>%d</TD></TR>\n", refcount);
+               wprintf("<TD>%d</TD>\n", refcount);
+
+               wprintf("<TD>"
+                       "<FORM METHOD=\"POST\" action=\"set_floor_css\">"
+                       "<INPUT TYPE=\"hidden\" NAME=\"floornum\" "
+                       "VALUE=\"%d\">"
+                       "<INPUT TYPE=\"text\" NAME=\"floorcss\" "
+                       "VALUE=\"%s\" MAXLENGTH=\"250\">\n",
+                       floornum, floorname);
+               wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
+                       "VALUE=\"%s\">"
+                       "</FORM></TD>", _("Change CSS"));
+
+               wprintf("</TR>\n");
        }
 
        wprintf("<TR><TD>&nbsp;</TD>"
-               "<TD><FORM METHOD=\"POST\" ACTION=\"/create_floor\">"
+               "<TD><FORM METHOD=\"POST\" action=\"create_floor\">"
                "<INPUT TYPE=\"text\" NAME=\"floorname\" "
                "MAXLENGTH=\"250\">\n"
                "<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
-               "VALUE=\"Create new floor\">"
+               "VALUE=\"%s\">"
                "</FORM></TD>"
-               "<TD>&nbsp;</TD></TR>\n");
-
-       wprintf("</TABLE>\n");
+               "<TD>&nbsp;</TD></TR>\n", _("Create new floor"));
 
+       wprintf("</table></div>\n");
        wDumpContent(1);
 }
 
 
-
+/**
+ * \brief delete the actual floor
+ */
 void delete_floor(void) {
        int floornum;
        char buf[SIZ];
@@ -127,20 +140,21 @@ void delete_floor(void) {
        floornum = atoi(bstr("floornum"));
 
        serv_printf("KFLR %d|1", floornum);
-       serv_gets(buf);
+       serv_getln(buf, sizeof buf);
 
        if (buf[0] == '2') {
-               sprintf(message, "<B><I>Floor has been deleted."
-                               "</I></B><BR><BR>\n");
+               sprintf(message, _("Floor has been deleted."));
        }
        else {
-               sprintf(message, "<B><I>%s</I></B>><BR>", &buf[4]);
+               sprintf(message, "%s", &buf[4]);
        }
 
        display_floorconfig(message);
 }
 
-
+/**
+ * \brief tart creating a new floor
+ */
 void create_floor(void) {
        char buf[SIZ];
        char message[SIZ];
@@ -149,14 +163,20 @@ void create_floor(void) {
        strcpy(floorname, bstr("floorname"));
 
        serv_printf("CFLR %s|1", floorname);
-       serv_gets(buf);
+       serv_getln(buf, sizeof buf);
 
-       sprintf(message, "<B><I>%s</I></B>><BR>", &buf[4]);
+       if (buf[0] == '2') {
+               sprintf(message, _("New floor has been created."));
+       } else {
+               sprintf(message, "%s", &buf[4]);
+       }
 
        display_floorconfig(message);
 }
 
-
+/**
+ * \brief rename this floor
+ */
 void rename_floor(void) {
        int floornum;
        char buf[SIZ];
@@ -167,11 +187,12 @@ void rename_floor(void) {
        strcpy(floorname, bstr("floorname"));
 
        serv_printf("EFLR %d|%s", floornum, floorname);
-       serv_gets(buf);
+       serv_getln(buf, sizeof buf);
 
-       sprintf(message, "<B><I>%s</I></B>><BR>", &buf[4]);
+       sprintf(message, "%s", &buf[4]);
 
        display_floorconfig(message);
 }
 
 
+/*@}*/