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 
2ec5a01999-04-18David Hedbor constant cvs_version = "$Id: obox.pike,v 1.8 1999/04/18 18:21:00 neotron 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";
89a77c1998-03-07Fredrik Noring constant unit_gif = "/internal-roxen-unit";
ea01431997-08-03Fredrik Noring 
89a77c1998-03-07Fredrik Noring static private int loaded;
ea01431997-08-03Fredrik Noring 
89a77c1998-03-07Fredrik Noring static private string doc() { return !loaded?"":replace(Stdio.read_bytes("modules/tags/doc/obox")||"", ({ "{", "}" }), ({ "&lt;", "&gt;" })); }
5458ff1997-08-23Henrik Grubbström (Grubba) 
d2bf2c1997-11-09Francesco Chemolli static string img_placeholder (mapping args) { int width=((int)args->outlinewidth)||1; return sprintf("<img src=\"%s\" alt=\"\" width=%d height=%d>", unit_gif, width, width); } static string handle_title(string name, mapping junk_args, string contents, mapping args) { args->title=contents; return ""; } static string horiz_line(mapping args) {
2ec5a01999-04-18David Hedbor  args->fixedleft="";
d2bf2c1997-11-09Francesco Chemolli  return sprintf("<tr><td colspan=5 bgcolor=\"%s\">\n" "%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); switch (args->style) { case "groupbox":
2ec5a01999-04-18David Hedbor  if (!args->left && !args->fixedleft) if (args->width && !args->fixedright) args->fixedleft = "7"; else args->left = "1"; if (!args->right && !args->fixedright) args->right = "1"; return sprintf("<tr><td colspan=2><font size=-3>&nbsp;</font></td>\n"
d2bf2c1997-11-09Francesco Chemolli  "<td rowspan=3%s>&nbsp;<b>" /* bgcolor */ "%s%s%s" /* titlecolor, title, titlecolor */
2ec5a01999-04-18David Hedbor  "</b>&nbsp;</td>\n" "<td colspan=2><font size=-3>&nbsp;</font></td></tr>\n"
d2bf2c1997-11-09Francesco Chemolli  "<tr%s>" /* bgcolor */ "<td bgcolor=\"%s\" colspan=2>\n" /* outlinecolor */ "%s</td>\n" /* empty */ "<td bgcolor=\"%s\" colspan=2>\n" "%s</td></tr>\n" /* empty */ "<tr%s><td bgcolor=\"%s\">" /* bgcolor, outlinecolor */ "%s</td>\n" /* empty */
2ec5a01999-04-18David Hedbor  "<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+"\"" : "", args->titlecolor ? "<FONT color=\""+args->titlecolor+"\">" : "", args->title, args->titlecolor ? "</FONT>" : "", args->bgcolor ? " bgcolor=\""+args->bgcolor+"\"" : "", args->outlinecolor, empty, args->outlinecolor, empty, args->bgcolor ? " bgcolor=\""+args->bgcolor+"\"" : "", args->outlinecolor, empty,
2ec5a01999-04-18David Hedbor  (args->left ? " width="+args->left+"000" : ""), (args->fixedleft ? String.strmult ("&nbsp;", (int) args->fixedleft) : "&nbsp;"), (args->right ? " width="+args->right+"000" : ""), (args->fixedright ? String.strmult ("&nbsp;", (int) args->fixedright) : "&nbsp;"),
d2bf2c1997-11-09Francesco Chemolli  args->outlinecolor, empty); case "caption": return sprintf("<TR bgcolor=%s>" "<TD>%s</TD>" "<TD%s>&nbsp;</TD>" "<TD>%s%s%s</TD>" "<TD%s>&nbsp;</TD>" "<TD>%s</TD></TR>", args->outlinecolor, empty, (args->left ? " width="+args->left : ""), args->titlecolor ? "<FONT color=\""+args->titlecolor+"\">" : "", args->title, args->titlecolor ? "</FONT>" : "", (args->right ? " width="+args->right : ""), 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  if (args->help) {
d2bf2c1997-11-09Francesco Chemolli  args->right = 250; args->title = "The Outlined Box container tag";
89a77c1998-03-07Fredrik Noring  contents = doc();
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  } switch (name) { case "obox":
2ec5a01999-04-18David Hedbor  s = title(args);
d2bf2c1997-11-09Francesco Chemolli  s = "<table border=0 cellpadding=0 cellspacing=0" + (args->align?" align="+args->align:"") +
2ec5a01999-04-18David Hedbor  (args->width ? " width=" + args->width : "") + ">\n" + s +
d2bf2c1997-11-09Francesco Chemolli  "<tr" + (args->bgcolor?" bgcolor="+args->bgcolor:"") + "><td bgcolor=\"" + args->outlinecolor + "\">" + img_placeholder(args) + "</td>\n"
2ec5a01999-04-18David Hedbor  "<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?" width="+(string)args->spacing:"")+">"
d2bf2c1997-11-09Francesco Chemolli  "<tr><td>\n"; if (args->textcolor) { s += "<font color=\""+args->textcolor+"\">" + contents + "</font>";
c2e9ea1997-10-27Francesco Chemolli  } else { s += contents; }
ea01431997-08-03Fredrik Noring  s += "</td></tr></table>\n"
d2bf2c1997-11-09Francesco Chemolli  "</td><td bgcolor=\"" + args->outlinecolor + "\">" + img_placeholder(args) + "</td></tr>\n" + horiz_line(args) + "</table>\n";
ea01431997-08-03Fredrik Noring  break; } return s; } array register_module() { return ({
2ec5a01999-04-18David Hedbor  MODULE_PARSER, "Outlined box", "This is a container tag making outlined boxes.<p>" "<tt>&lt;obox help&gt;&lt;/obox&gt;</tt> gives help.\n\n " "<obox title=example>contents</obox>", 0, 1 });
ea01431997-08-03Fredrik Noring }
89a77c1998-03-07Fredrik Noring void start(int num, object configuration) { loaded = 1; }
ea01431997-08-03Fredrik Noring mapping query_container_callers() { return ([ "obox":container_obox, ]); }