From 7744483ccb08fbf027b1052dc03ac06f8c69d77c Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Mon, 18 Jul 2011 00:06:17 +0000 Subject: [PATCH] templatize uploading dialog for room/... graphics. --- webcit/graphics.c | 90 +++++++---------------- webcit/static/t/files/graphicsupload.html | 22 ++++++ webcit/webcit.h | 2 - 3 files changed, 50 insertions(+), 64 deletions(-) create mode 100644 webcit/static/t/files/graphicsupload.html diff --git a/webcit/graphics.c b/webcit/graphics.c index ee7d6bd97..f798cc3e5 100644 --- a/webcit/graphics.c +++ b/webcit/graphics.c @@ -20,13 +20,10 @@ #include "webcit.h" -void display_graphics_upload(char *description, char *filename, char *uplurl) +void display_graphics_upload(char *filename) { - WCTemplputParams SubTP; - StrBuf *Buf; char buf[SIZ]; - snprintf(buf, SIZ, "UIMG 0||%s", filename); serv_puts(buf); serv_getln(buf, sizeof buf); @@ -35,46 +32,9 @@ void display_graphics_upload(char *description, char *filename, char *uplurl) display_main_menu(); return; } - /*output_headers(1, 1, 0, 0, 0, 0); */ - - output_headers(1, 1, 1, 0, 0, 0); - - Buf = NewStrBufPlain(_("Image upload"), -1); - memset(&SubTP, 0, sizeof(WCTemplputParams)); - SubTP.Filter.ContextType = CTX_STRBUF; - SubTP.Context = Buf; - DoTemplate(HKEY("box_begin"), NULL, &SubTP); - - FreeStrBuf(&Buf); - - wc_printf("
\n", uplurl); - - wc_printf("\n", WC->nonce); - wc_printf("\n"); - - wc_printf(_("You can upload an image directly from your computer")); - wc_printf("

\n"); - - wc_printf(_("Please select a file to upload:")); - wc_printf("\n"); - - wc_printf("
\n", filename); - - wc_printf("
"); - wc_printf("\n", _("Upload")); - wc_printf(" "); - wc_printf("\n", _("Reset form")); - wc_printf(" "); - wc_printf("\n", _("Cancel")); - wc_printf("
\n"); - wc_printf("
\n"); - - do_template("box_end"); - - wDumpContent(1); + output_headers(1, 0, 0, 0, 1, 0); + do_template("files_graphicsupload"); + end_burst(); } void do_graphics_upload(char *filename) @@ -143,38 +103,44 @@ void editgoodbuyepic(void) { do_graphics_upload("UIMG 1|%s|goodbuye"); } /* The users photo display / upload facility */ void display_editpic(void) { - display_graphics_upload(_("your photo"), - "_userpic_", - "editpic"); + putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_userpic_"))); + putbstr("__PICDESC", NewStrBufPlain(_("your photo"), -1)); + putbstr("__UPLURL", NewStrBufPlain(HKEY("editpic"))); + display_graphics_upload("editpic"); } /* room picture dispay / upload facility */ void display_editroompic(void) { - display_graphics_upload(_("the icon for this room"), - "_roompic_", - "editroompic"); + putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_roompic_"))); + putbstr("__PICDESC", NewStrBufPlain(_("the icon for this room"), -1)); + putbstr("__UPLURL", NewStrBufPlain(HKEY("editroompic"))); + display_graphics_upload("editroompic"); } /* the greetingpage hello pic */ void display_edithello(void) { - display_graphics_upload(_("the Greetingpicture for the login prompt"), - "hello", - "edithellopic"); + putbstr("__WHICHPIC", NewStrBufPlain(HKEY("hello"))); + putbstr("__PICDESC", NewStrBufPlain(_("the Greetingpicture for the login prompt"), -1)); + putbstr("__UPLURL", NewStrBufPlain(HKEY("edithellopic"))); + display_graphics_upload("edithellopic"); } /* the logoff banner */ void display_editgoodbyepic(void) { - display_graphics_upload(_("the Logoff banner picture"), - "UIMG 0|%s|goodbuye", - "editgoodbuyepic"); + putbstr("__WHICHPIC", NewStrBufPlain(HKEY("UIMG 0|%s|goodbuye"))); + putbstr("__PICDESC", NewStrBufPlain(_("the Logoff banner picture"), -1)); + putbstr("__UPLURL", NewStrBufPlain(HKEY("editgoodbuyepic"))); + display_graphics_upload("editgoodbuyepic"); } void display_editfloorpic(void) { - char buf[SIZ]; - snprintf(buf, SIZ, "_floorpic_|%s", - bstr("which_floor")); - display_graphics_upload(_("the icon for this floor"), - buf, - "editfloorpic"); + StrBuf *PicAction; + + PicAction = NewStrBuf(); + StrBufPrintf(PicAction, "_floorpic_|%s", bstr("which_floor")); + putbstr("__WHICHPIC", PicAction); + putbstr("__PICDESC", NewStrBufPlain(_("the icon for this floor"), -1)); + putbstr("__UPLURL", NewStrBufPlain(HKEY("editfloorpic"))); + display_graphics_upload("editfloorpic"); } void editroompic(void) { diff --git a/webcit/static/t/files/graphicsupload.html b/webcit/static/t/files/graphicsupload.html new file mode 100644 index 000000000..8caaef576 --- /dev/null +++ b/webcit/static/t/files/graphicsupload.html @@ -0,0 +1,22 @@ + + +
+ + +"> +

+ + + +
">
+ +
+ "> +   + " > +   + "> +
+
+ + diff --git a/webcit/webcit.h b/webcit/webcit.h index efb7f8242..602bca535 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -807,8 +807,6 @@ int ical_ctdl_is_overlap( extern char *months[]; extern char *days[]; -void display_graphics_upload(char *, char *, char *); -void do_graphics_upload(char *upl_cmd); int serv_write(const char *buf, int nbytes); int serv_putbuf(const StrBuf *string); int serv_printf(const char *format,...)__attribute__((__format__(__printf__,1,2))); -- 2.30.2