d2bf2c1997-11-09Francesco Chemolli // The outlined box module // // Fredrik Noring et al // // Several modifications by Francesco Chemolli.
ea01431997-08-03Fredrik Noring 
d2bf2c1997-11-09Francesco Chemolli 
a68f5d1999-12-08Martin Nilsson constant cvs_version = "$Id: obox.pike,v 1.17 1999/12/08 14:14:14 nilsson Exp $";
07bf511997-08-31Peter Bortas constant thread_safe=1;
ea01431997-08-03Fredrik Noring #include <module.h>
07bf511997-08-31Peter Bortas inherit "module";
ea01431997-08-03Fredrik Noring inherit "roxenlib";
a68f5d1999-12-08Martin Nilsson TAGDOCUMENTATION #ifdef manual constant tagdoc=(["obox": ([ "standard":"<desc cont>Outlined box</desc>", "svenska":"<desc cont>Ramlåda</desc>"]) ]); #endif
ea01431997-08-03Fredrik Noring 
a68f5d1999-12-08Martin Nilsson constant unit_gif = "/internal-roxen-unit";
5458ff1997-08-23Henrik Grubbström (Grubba) 
d2bf2c1997-11-09Francesco Chemolli static string img_placeholder (mapping args) { int width=((int)args->outlinewidth)||1;
14ae4b1999-07-26Martin Nilsson  return sprintf("<img src=\"%s\" alt=\"\" width=\"%d\" height=\"%d\"%s>", unit_gif, width, width, (args->noxml?"":" /"));
d2bf2c1997-11-09Francesco Chemolli } static string handle_title(string name, mapping junk_args, string contents, mapping args) { args->title=contents; return ""; } static string horiz_line(mapping args) {
9f2fdf1998-10-18Martin Stjernholm  args->fixedleft="";
14ae4b1999-07-26Martin Nilsson  return sprintf("<tr><td colspan=\"5\" bgcolor=\"%s\">\n"
d2bf2c1997-11-09Francesco Chemolli  "%s</td></tr>\n", args->outlinecolor, img_placeholder(args)); } static string title(mapping args) { if (!args->title) return horiz_line(args); string empty=img_placeholder(args);
5864ba1999-05-24David Hedbor  if (!args->left && !args->fixedleft) if (args->width && !args->fixedright) args->fixedleft = "7"; else args->left = "20"; if (!args->right && !args->fixedright) args->right = args->width || "20";
d2bf2c1997-11-09Francesco Chemolli  switch (args->style) {
5864ba1999-05-24David Hedbor  case "groupbox":
14ae4b1999-07-26Martin Nilsson  return sprintf("<tr><td colspan=\"2\"><font size=\"-3\">&nbsp;</font></td>\n" "<td rowspan=\"3\"%s nowrap=\"nowrap\">&nbsp;<b>" /* bgcolor */
d2bf2c1997-11-09Francesco Chemolli  "%s%s%s" /* titlecolor, title, titlecolor */
9f2fdf1998-10-18Martin Stjernholm  "</b>&nbsp;</td>\n"
14ae4b1999-07-26Martin Nilsson  "<td colspan=\"2\"><font size=\"-3\">&nbsp;</font></td></tr>\n"
d2bf2c1997-11-09Francesco Chemolli  "<tr%s>" /* bgcolor */
14ae4b1999-07-26Martin Nilsson  "<td bgcolor=\"%s\" colspan=\"2\">\n" /* outlinecolor */
d2bf2c1997-11-09Francesco Chemolli  "%s</td>\n" /* empty */
14ae4b1999-07-26Martin Nilsson  "<td bgcolor=\"%s\" colspan=\"2\">\n"
d2bf2c1997-11-09Francesco Chemolli  "%s</td></tr>\n" /* empty */ "<tr%s><td bgcolor=\"%s\">" /* bgcolor, outlinecolor */ "%s</td>\n" /* empty */
14ae4b1999-07-26Martin Nilsson  "<td%s><font size=\"-3\">%s</font></td>" /* left, fixedleft */ "<td%s><font size=\"-3\">%s</font></td>\n" /* right, fixedright */
d2bf2c1997-11-09Francesco Chemolli  "<td bgcolor=\"%s\">" /* outlinecolor */ "%s</td></tr>\n" /* empty */ , args->bgcolor ? " bgcolor=\""+args->bgcolor+"\"" : "",
e3da5f1999-08-16Martin Nilsson  args->titlecolor ? "<font color=\""+args->titlecolor+"\">" : "",
d2bf2c1997-11-09Francesco Chemolli  args->title,
e3da5f1999-08-16Martin Nilsson  args->titlecolor ? "</font>" : "",
d2bf2c1997-11-09Francesco Chemolli  args->bgcolor ? " bgcolor=\""+args->bgcolor+"\"" : "", args->outlinecolor, empty, args->outlinecolor, empty, args->bgcolor ? " bgcolor=\""+args->bgcolor+"\"" : "", args->outlinecolor, empty,
5864ba1999-05-24David Hedbor  (args->left ? " width="+args->left : ""),
9f2fdf1998-10-18Martin Stjernholm  (args->fixedleft ? String.strmult ("&nbsp;", (int) args->fixedleft) : "&nbsp;"),
5864ba1999-05-24David Hedbor  (args->right ? " width="+args->right : ""),
9f2fdf1998-10-18Martin Stjernholm  (args->fixedright ? String.strmult ("&nbsp;", (int) args->fixedright) : "&nbsp;"),
d2bf2c1997-11-09Francesco Chemolli  args->outlinecolor, empty);
5864ba1999-05-24David Hedbor  case "caption":
14ae4b1999-07-26Martin Nilsson  return sprintf("<tr%s><td colspan=\"2\"><font size=\"-3\">&nbsp;</font></td>\n" "<td rowspan=\"3\" nowrap=\"nowrap\">&nbsp;<b>" /* bgcolor */
5864ba1999-05-24David Hedbor  "%s%s%s" /* titlecolor, title, titlecolor */ "</b>&nbsp;</td>\n"
14ae4b1999-07-26Martin Nilsson  "<td colspan=\"2\"><font size=\"-3\">&nbsp;</font></td></tr>\n"
5864ba1999-05-24David Hedbor  "<tr bgcolor=\"%s\">" /* outlinecolor */
14ae4b1999-07-26Martin Nilsson  "<td colspan=\"2\">\n"
5864ba1999-05-24David Hedbor  "%s</td>\n" /* empty */
14ae4b1999-07-26Martin Nilsson  "<td colspan=\"2\">\n"
5864ba1999-05-24David Hedbor  "%s</td></tr>\n" /* empty */ "<tr bgcolor=\"%s\"><td>" /* outlinecolor */ "%s</td>\n" /* empty */
14ae4b1999-07-26Martin Nilsson  "<td%s><font size=\"-3\">%s</font></td>" /* left, fixedleft */ "<td%s><font size=\"-3\">%s</font></td>\n" /* right, fixedright */
5864ba1999-05-24David Hedbor  "<td bgcolor=\"%s\">" /* outlinecolor */ "%s</td></tr>\n" /* empty */ , args->outlinecolor ? " bgcolor=\""+args->outlinecolor+"\"" : "",
e3da5f1999-08-16Martin Nilsson  args->titlecolor ? "<font color=\""+args->titlecolor+"\">" : "",
d2bf2c1997-11-09Francesco Chemolli  args->title,
e3da5f1999-08-16Martin Nilsson  args->titlecolor ? "</font>" : "",
5864ba1999-05-24David Hedbor  args->outlinecolor, empty, empty, args->outlinecolor, empty, (args->left ? " width="+args->left : ""), (args->fixedleft ? String.strmult ("&nbsp;", (int) args->fixedleft) : "&nbsp;"),
d2bf2c1997-11-09Francesco Chemolli  (args->right ? " width="+args->right : ""),
5864ba1999-05-24David Hedbor  (args->fixedright ? String.strmult ("&nbsp;", (int) args->fixedright) : "&nbsp;"), args->outlinecolor,
d2bf2c1997-11-09Francesco Chemolli  empty); } }
ea01431997-08-03Fredrik Noring string container_obox(string name, mapping args, string contents, object request_id) {
d2bf2c1997-11-09Francesco Chemolli  string s;
ea01431997-08-03Fredrik Noring 
d2bf2c1997-11-09Francesco Chemolli  // Set the defaults... args->outlinecolor = args->outlinecolor || "#000000"; args->style = args->style || "groupbox"; if (!args->title) { contents=parse_html(contents,([]),(["title":handle_title,]),args);
ea01431997-08-03Fredrik Noring  }
e3da5f1999-08-16Martin Nilsson  s = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"" + (args->align?" align=\""+args->align+"\"":"") +
64324f1999-10-04Fred van Dijk  (args->width ? " width=" + args->width : "") + (args->hspace ? " hspace=" + args->hspace : "") + (args->vspace ? " vspace=" + args->vspace : "") + ">\n" +
e3da5f1999-08-16Martin Nilsson  title(args) + "<tr" + (args->bgcolor?" bgcolor=\""+args->bgcolor+"\"":"") + "><td bgcolor=\"" + args->outlinecolor + "\">" + img_placeholder(args) + "</td>\n" "<td" + (args->width && !args->fixedleft && !args->fixedright ? " width=\"1\"" : "") + (args->aligncontents ? " align=" + args->aligncontents : "") + " colspan=\"3\"" + ">\n" "<table border=\"0\" cellspacing=\"0\" cellpadding=\"" + (args->padding || "5") + "\""+ (!args->spacing && args->width?" width=\""+(string)((int)args->width-((int)args->outlinewidth*2||2))+"\"":"")+ (args->spacing?" width=\""+(string)args->spacing+"\"":"")+">" "<tr><td>\n"; if (args->textcolor) s += "<font color=\""+args->textcolor+"\">" + contents + "</font>"; else s += contents;
ea01431997-08-03Fredrik Noring 
e3da5f1999-08-16Martin Nilsson  s += "</td></tr></table>\n" "</td><td bgcolor=\"" + args->outlinecolor + "\">" + img_placeholder(args) + "</td></tr>\n" + horiz_line(args) + "</table>\n";
ea01431997-08-03Fredrik Noring  return s; } array register_module() { return ({
5458ff1997-08-23Henrik Grubbström (Grubba)  MODULE_PARSER,
ea3d3f1998-11-22Per Hedbor  ([ "standard":"Outlined box", "svenska":"Ramlåda", ]), ([ "standard":
a68f5d1999-12-08Martin Nilsson  "This is a container tag making outlined boxes.",
ea3d3f1998-11-22Per Hedbor  "svenska": "<tt>&lt;obox help&gt;&lt;/obox&gt;</tt> är en tag som ramar " "in det som står i den. <obox title=exempel>innehåll</obox>", ]), 0, 1 });
ea01431997-08-03Fredrik Noring }