0e834c | 2000-02-24 | Martin Nilsson | |
|
d2bf2c | 1997-11-09 | Francesco Chemolli | |
|
ea0143 | 1997-08-03 | Fredrik Noring | |
|
d2bf2c | 1997-11-09 | Francesco Chemolli | |
|
f0d694 | 2001-01-29 | Per Hedbor | | constant cvs_version = "$Id: obox.pike,v 1.33 2001/01/29 05:40:32 per Exp $";
|
07bf51 | 1997-08-31 | Peter Bortas | | constant thread_safe=1;
|
ea0143 | 1997-08-03 | Fredrik Noring | | #include <module.h>
|
55a866 | 2000-11-20 | Per Hedbor | |
|
07bf51 | 1997-08-31 | Peter Bortas | | inherit "module";
|
ea0143 | 1997-08-03 | Fredrik Noring | |
|
55a866 | 2000-11-20 | Per Hedbor | |
#define SLOCALE(X,Y) _STR_LOCALE("mod_obox",X,Y)
#define LOCALE(X,Y) _DEF_LOCALE("mod_obox",X,Y)
|
ff8e66 | 2000-05-05 | Kenneth Johansson | |
|
55a866 | 2000-11-20 | Per Hedbor | | constant module_type = MODULE_TAG;
|
f0d694 | 2001-01-29 | Per Hedbor | | LocaleString module_name = LOCALE(1,"Outlined box");
|
ff8e66 | 2000-05-05 | Kenneth Johansson | |
|
f0d694 | 2001-01-29 | Per Hedbor | | LocaleString module_doc =
|
55a866 | 2000-11-20 | Per Hedbor | | LOCALE(2,"This module provides the <tt><obox></tt> tag that "
"draws outlined boxes.");
|
ea0143 | 1997-08-03 | Fredrik Noring | |
|
a68f5d | 1999-12-08 | Martin Nilsson | | constant unit_gif = "/internal-roxen-unit";
|
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+"\"" : "",
|
e3da5f | 1999-08-16 | Martin Nilsson | | args->titlecolor ? "<font color=\""+args->titlecolor+"\">" : "",
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | args->title,
|
e3da5f | 1999-08-16 | Martin Nilsson | | args->titlecolor ? "</font>" : "",
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | args->bgcolor ? " bgcolor=\""+args->bgcolor+"\"" : "",
args->outlinecolor,
empty,
args->outlinecolor,
empty,
args->bgcolor ? " bgcolor=\""+args->bgcolor+"\"" : "",
args->outlinecolor,
empty,
|
695303 | 2000-03-13 | Martin Nilsson | | args->left ? " width=\""+args->left+"\"" : "",
|
9f2fdf | 1998-10-18 | Martin Stjernholm | | (args->fixedleft ?
String.strmult (" ", (int) args->fixedleft) : " "),
|
695303 | 2000-03-13 | Martin Nilsson | | 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+"\"" : "",
|
e3da5f | 1999-08-16 | Martin Nilsson | | args->titlecolor ? "<font color=\""+args->titlecolor+"\">" : "",
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | args->title,
|
e3da5f | 1999-08-16 | Martin Nilsson | | args->titlecolor ? "</font>" : "",
|
5864ba | 1999-05-24 | David Hedbor | | args->outlinecolor,
empty,
empty,
args->outlinecolor,
empty,
|
695303 | 2000-03-13 | Martin Nilsson | | args->left ? " width=\""+args->left+"\"" : "",
|
5864ba | 1999-05-24 | David Hedbor | | (args->fixedleft ?
String.strmult (" ", (int) args->fixedleft) : " "),
|
695303 | 2000-03-13 | Martin Nilsson | | 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);
}
}
|
695303 | 2000-03-13 | Martin Nilsson | | string simpletag_obox(string name, mapping args, string contents)
|
ea0143 | 1997-08-03 | Fredrik Noring | | {
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | string s;
|
0e834c | 2000-02-24 | Martin Nilsson | |
|
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 | | }
|
e3da5f | 1999-08-16 | Martin Nilsson | | s = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"" +
(args->align?" align=\""+args->align+"\"":"") +
|
0e834c | 2000-02-24 | Martin Nilsson | | (args->width ? " width=" + args->width : "") +
(args->hspace ? " hspace=" + args->hspace : "") +
|
64324f | 1999-10-04 | Fred van Dijk | | (args->vspace ? " vspace=" + args->vspace : "") + ">\n" +
|
e3da5f | 1999-08-16 | Martin 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;
|
0e834c | 2000-02-24 | Martin Nilsson | |
|
e3da5f | 1999-08-16 | Martin Nilsson | | s += "</td></tr></table>\n"
"</td><td bgcolor=\"" + args->outlinecolor + "\">" +
img_placeholder(args) + "</td></tr>\n" +
horiz_line(args) + "</table>\n";
|
0e834c | 2000-02-24 | Martin Nilsson | |
|
ea0143 | 1997-08-03 | Fredrik Noring | | return s;
}
|
55a866 | 2000-11-20 | Per Hedbor | |
TAGDOCUMENTATION
#ifdef manual
constant tagdoc=(["obox":([
"standard":#"<desc cont><short>This tag creates an outlined box.</short></desc>
<attr name=align value=left|right>
Vertical alignment of the box.
</attr>
<attr name=bgcolor value=color>
Color of the background and title label.
</attr>
<attr name=fixedleft value=number>
Fixed length of line on the left side of the title. The unit is the
approximate width of a character.
</attr>
<attr name=fixedright value=number>
Fixed length of line on the right side of the title. The unit is the
approximate width of a character.
</attr>
<attr name=left value=number>
Length of the line on the left of the title.
</attr>
<attr name=outlinecolor value=color>
Color of the outline.
</attr>
<attr name=outlinewidth value=number>
Width, in pixels, of the outline.
</attr>
<attr name=right value=number>
Length of the line on the right of the title.
</attr>
<attr name=spacing value=number>
Width, in pixels, of the space in the box.
</attr>
<attr name=style value=caption|groupbox>
Style of the box. Groupbox is default
</attr>
<attr name=textcolor value=color>
Color of the text inside the box.
</attr>
<attr name=title value=string>
Sets the title of the obox.
</attr>
<attr name=titlecolor value=color>
Color of the title text.
</attr>
<attr name=width value=number>
Width, in pixels, of the box.
Note that the left and right attributes are constrained by the width
argument. If the title is not specified in the argument list, you can
put it in a <tag>title</tag> container in the obox contents.
<ex><obox align='left' outlinewidth='5' outlinecolor='green' width='200'>
<title>Sample box</title>
This is just a sample box.
</obox>
</ex>
</attr>",
"svenska":#"<desc cont><short>Denna tagg skapar en ramlåda runt dess innehåll.</short></desc>
<attr name=align value=left|right>
Ramlådans vertikala position.
</attr>
<attr name=bgcolor value=färg>
Färgen på bakgrunden samt titeln.
</attr>
<attr name=fixedleft value=nummer>
Längden på linjen till vänster om titeln. Värdet på 1 'nummer' är den
ungefärliga bredden av ett tecken.
</attr>
<attr name=fixedright value=nummer>
Längden på linjen till vänster om titeln. Värdet på 1 'nummer' är den
ungefärliga bredden av ett tecken.
</attr>
<attr name=left value=nummer>
Längden på linjen till vänster om titeln.
</attr>
<attr name=outlinecolor value=färg>
Färgen på ramen.
</attr>
<attr name=outlinewidth value=nummer>
Ramens bredd, i antal pixlar.
</attr>
<attr name=right value=nummer>
Längden på linjen till höger om titeln.
</attr>
<attr name=spacing value=nummer>
Vidden på utrymmet i ramlådan, i antal pixlar.
</attr>
<attr name=style value=caption|groupbox>
Ramlådans stil. Groupbox är standardvärde.
</attr>
<attr name=textcolor value=färg>
Färgen på texten inuti lådan.
</attr>
<attr name=title value=textsträng>
Ramlådans titel.
</attr>
<attr name=titlecolor value=färg>
Färgen på titeltexten.
</attr>
<attr name=width value=nummer>
Bredden på lådan, i antal pixlar.
Tänk på att <att>left</att> och <att>right</att> attributen begränsas
av värdet på <att>width</att> attributet. Om titeln inte är satt i
taggen, finns möjligheten att sätta den inuti en <tag>title</tag>
tagg och placera denna i ramlådans innehåll.
<ex><obox align='left' outlinewidth='5' outlinecolor='green' width='200'>
<title>Ramlåda</title>
Detta är innehållet.
</obox>
</ex>
</attr>"]) ]);
#endif
|