d2bf2c | 1997-11-09 | Francesco Chemolli | |
|
ea0143 | 1997-08-03 | Fredrik Noring | |
|
d2bf2c | 1997-11-09 | Francesco Chemolli | |
|
14ae4b | 1999-07-26 | Martin Nilsson | | constant cvs_version = "$Id: obox.pike,v 1.14 1999/07/26 13:15:01 nilsson Exp $";
|
07bf51 | 1997-08-31 | Peter Bortas | | constant thread_safe=1;
|
ea0143 | 1997-08-03 | Fredrik Noring | | #include <module.h>
|
07bf51 | 1997-08-31 | Peter Bortas | | inherit "module";
|
ea0143 | 1997-08-03 | Fredrik Noring | | inherit "roxenlib";
|
89a77c | 1998-03-07 | Fredrik Noring | | constant unit_gif = "/internal-roxen-unit";
|
ea0143 | 1997-08-03 | Fredrik Noring | |
|
89a77c | 1998-03-07 | Fredrik Noring | | static private int loaded;
|
ea0143 | 1997-08-03 | Fredrik Noring | |
|
89a77c | 1998-03-07 | Fredrik Noring | | static private string doc()
{
return !loaded?"":replace(Stdio.read_bytes("modules/tags/doc/obox")||"",
({ "{", "}" }), ({ "<", ">" }));
}
|
5458ff | 1997-08-23 | Henrik Grubbström (Grubba) | |
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | static string img_placeholder (mapping args)
{
int width=((int)args->outlinewidth)||1;
|
14ae4b | 1999-07-26 | Martin Nilsson | | return sprintf("<img src=\"%s\" alt=\"\" width=\"%d\" height=\"%d\"%s>",
unit_gif, width, width, (args->noxml?"":" /"));
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | }
static string handle_title(string name, mapping junk_args,
string contents, mapping args)
{
args->title=contents;
return "";
}
static string horiz_line(mapping args)
{
|
9f2fdf | 1998-10-18 | Martin Stjernholm | | args->fixedleft="";
|
14ae4b | 1999-07-26 | Martin Nilsson | | return sprintf("<tr><td colspan=\"5\" bgcolor=\"%s\">\n"
|
d2bf2c | 1997-11-09 | Francesco 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);
|
5864ba | 1999-05-24 | David 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";
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | switch (args->style) {
|
5864ba | 1999-05-24 | David Hedbor | | case "groupbox":
|
14ae4b | 1999-07-26 | Martin Nilsson | | return sprintf("<tr><td colspan=\"2\"><font size=\"-3\"> </font></td>\n"
"<td rowspan=\"3\"%s nowrap=\"nowrap\"> <b>"
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "%s%s%s"
|
9f2fdf | 1998-10-18 | Martin Stjernholm | | "</b> </td>\n"
|
14ae4b | 1999-07-26 | Martin Nilsson | | "<td colspan=\"2\"><font size=\"-3\"> </font></td></tr>\n"
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "<tr%s>"
|
14ae4b | 1999-07-26 | Martin Nilsson | | "<td bgcolor=\"%s\" colspan=\"2\">\n"
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "%s</td>\n"
|
14ae4b | 1999-07-26 | Martin Nilsson | | "<td bgcolor=\"%s\" colspan=\"2\">\n"
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "%s</td></tr>\n"
"<tr%s><td bgcolor=\"%s\">"
"%s</td>\n"
|
14ae4b | 1999-07-26 | Martin Nilsson | | "<td%s><font size=\"-3\">%s</font></td>"
"<td%s><font size=\"-3\">%s</font></td>\n"
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "<td bgcolor=\"%s\">"
"%s</td></tr>\n"
,
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,
|
5864ba | 1999-05-24 | David Hedbor | | (args->left ? " width="+args->left : ""),
|
9f2fdf | 1998-10-18 | Martin Stjernholm | | (args->fixedleft ?
String.strmult (" ", (int) args->fixedleft) : " "),
|
5864ba | 1999-05-24 | David Hedbor | | (args->right ? " width="+args->right : ""),
|
9f2fdf | 1998-10-18 | Martin Stjernholm | | (args->fixedright ?
String.strmult (" ", (int) args->fixedright) : " "),
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | args->outlinecolor,
empty);
|
5864ba | 1999-05-24 | David Hedbor | | case "caption":
|
14ae4b | 1999-07-26 | Martin Nilsson | | return sprintf("<tr%s><td colspan=\"2\"><font size=\"-3\"> </font></td>\n"
"<td rowspan=\"3\" nowrap=\"nowrap\"> <b>"
|
5864ba | 1999-05-24 | David Hedbor | | "%s%s%s"
"</b> </td>\n"
|
14ae4b | 1999-07-26 | Martin Nilsson | | "<td colspan=\"2\"><font size=\"-3\"> </font></td></tr>\n"
|
5864ba | 1999-05-24 | David Hedbor | | "<tr bgcolor=\"%s\">"
|
14ae4b | 1999-07-26 | Martin Nilsson | | "<td colspan=\"2\">\n"
|
5864ba | 1999-05-24 | David Hedbor | | "%s</td>\n"
|
14ae4b | 1999-07-26 | Martin Nilsson | | "<td colspan=\"2\">\n"
|
5864ba | 1999-05-24 | David Hedbor | | "%s</td></tr>\n"
"<tr bgcolor=\"%s\"><td>"
"%s</td>\n"
|
14ae4b | 1999-07-26 | Martin Nilsson | | "<td%s><font size=\"-3\">%s</font></td>"
"<td%s><font size=\"-3\">%s</font></td>\n"
|
5864ba | 1999-05-24 | David Hedbor | | "<td bgcolor=\"%s\">"
"%s</td></tr>\n"
,
args->outlinecolor ? " bgcolor=\""+args->outlinecolor+"\"" : "",
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | args->titlecolor ? "<FONT color=\""+args->titlecolor+"\">" : "",
args->title,
args->titlecolor ? "</FONT>" : "",
|
5864ba | 1999-05-24 | David Hedbor | | args->outlinecolor,
empty,
empty,
args->outlinecolor,
empty,
(args->left ? " width="+args->left : ""),
(args->fixedleft ?
String.strmult (" ", (int) args->fixedleft) : " "),
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | (args->right ? " width="+args->right : ""),
|
5864ba | 1999-05-24 | David Hedbor | | (args->fixedright ?
String.strmult (" ", (int) args->fixedright) : " "),
args->outlinecolor,
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | empty);
}
}
|
ea0143 | 1997-08-03 | Fredrik Noring | | string container_obox(string name, mapping args,
string contents, object request_id)
{
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | string s;
|
ea0143 | 1997-08-03 | Fredrik Noring | |
if (args->help) {
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | args->right = 250;
args->title = "The Outlined Box container tag";
|
89a77c | 1998-03-07 | Fredrik Noring | | contents = doc();
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | }
args->outlinecolor = args->outlinecolor || "#000000";
args->style = args->style || "groupbox";
if (!args->title) {
contents=parse_html(contents,([]),(["title":handle_title,]),args);
|
ea0143 | 1997-08-03 | Fredrik Noring | | }
switch (name) {
case "obox":
|
9f2fdf | 1998-10-18 | Martin Stjernholm | | s = title(args);
|
14ae4b | 1999-07-26 | Martin Nilsson | | s = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"" +
(args->align?" align=\""+args->align+"\"":"") +
(args->width ? " width=\"" + args->width+"\"" : "") + ">\n" +
|
9f2fdf | 1998-10-18 | Martin Stjernholm | | s +
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "<tr" +
|
a7464c | 1999-05-24 | David Hedbor | | (args->bgcolor?" bgcolor=\""+args->bgcolor+"\"":"") +
"><td bgcolor=\"" + args->outlinecolor + "\">" +
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | img_placeholder(args) + "</td>\n"
|
14ae4b | 1999-07-26 | Martin Nilsson | | "<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+"\"":"")+">"
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "<tr><td>\n";
if (args->textcolor) {
s += "<font color=\""+args->textcolor+"\">" + contents + "</font>";
|
c2e9ea | 1997-10-27 | Francesco Chemolli | | } else {
s += contents;
}
|
ea0143 | 1997-08-03 | Fredrik Noring | |
s += "</td></tr></table>\n"
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "</td><td bgcolor=\"" + args->outlinecolor + "\">" +
img_placeholder(args) + "</td></tr>\n" +
horiz_line(args) + "</table>\n";
|
ea0143 | 1997-08-03 | Fredrik Noring | | break;
}
return s;
}
array register_module()
{
return ({
|
5458ff | 1997-08-23 | Henrik Grubbström (Grubba) | | MODULE_PARSER,
|
ea3d3f | 1998-11-22 | Per Hedbor | | ([
"standard":"Outlined box",
"svenska":"Ramlåda",
]),
([
"standard":
|
89a77c | 1998-03-07 | Fredrik Noring | | "This is a container tag making outlined boxes.<p>"
|
ea3d3f | 1998-11-22 | Per Hedbor | | "<tt><obox help></obox></tt> gives help.\n\n "
|
a7464c | 1999-05-24 | David Hedbor | | +doc(),
|
ea3d3f | 1998-11-22 | Per Hedbor | | "svenska":
"<tt><obox help></obox></tt> är en tag som ramar "
"in det som står i den. <obox title=exempel>innehåll</obox>",
]), 0, 1 });
|
ea0143 | 1997-08-03 | Fredrik Noring | | }
|
89a77c | 1998-03-07 | Fredrik Noring | | void start(int num, object configuration)
{
loaded = 1;
}
|
ea0143 | 1997-08-03 | Fredrik Noring | | mapping query_container_callers()
{
return ([ "obox":container_obox, ]);
}
|