7 use Yaala::Config qw#get_config#;
8 use Yaala::Data::Setup qw#$SELECTS#;
10 @Yaala::Html::EXPORT_OK = qw(escape head foot navbar get_filename get_title);
11 @Yaala::Html::ISA = ('Exporter');
15 A set of utilities used by report modules.
19 my $VERSION = '$Id: Html.pm,v 1.8 2003/12/07 14:52:02 octo Exp octo $';
20 print STDERR $/, __FILE__, ": $VERSION" if ($::DEBUG);
24 # NB: preserves all &foo; to allow inclusion of strange characters
43 return (join ('', @esc));
47 # generates only common header - with title and head.
50 my ($title, $header) = @_;
52 my $charset = get_config ('html_charset');
53 my $stylesheet = get_config ('html_stylesheet');
55 if (!defined ($charset) or !$charset) { $charset = 'iso-8859-1'; }
56 if (!defined ($stylesheet) or !$stylesheet) { $stylesheet = 'style.css'; }
58 $text = qq#<?xml version="1.0" encoding="$charset"?>\n#
59 . qq#<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"\n#
60 . qq#\t"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n#
61 . qq#<html>\n<head>\n#;
65 $text .= qq# <link rel="stylesheet" type="text/css" #
66 . qq#href="$stylesheet" />\n#;
69 $text .= " <title>$title</title>\n"
70 . qq# <meta name="robots" value="noindex, nofollow" />\n#
74 $text .= qq#<h1><img src="logo.png" /> $header</h1>\n# if $header;
82 . qq#<p id="footer">Generated by <a href="$::HOMEPAGE">$::NAME $::VERSION</a>, #
83 . scalar (localtime ())
86 $text .= "\n</body>\n</html>\n";
93 my $text = qq#<p class="navbar">\n#;
95 if (defined ($sel) and ref ($sel))
97 $text .= qq# <span>[ <a href="index.html">General</a> ]</span>\n#;
101 $text .= qq# <span>[ General ]</span>\n#;
108 my $title = get_title ($this_sel);
110 if ("$this_sel" eq "$sel")
112 $text .= qq# <span>[ $title ]</span>\n#;
116 my $filename = get_filename ($this_sel);
117 $text .= qq# <span>[ <a href="$filename">$title</a> ]</span>\n#;
129 my $aggs = join ('-', @{$sel->[0]});
130 my $flds = join ('-', @{$sel->[1]});
132 my $filename = $aggs . '_BY_' . $flds;
147 if (scalar (@{$sel->[2]}))
152 my ($key, $op, $val) = @$_;
155 $op = $sign_names{$op} if (defined ($sign_names{$op}));
156 push (@where, join ('-', ($key, $op, $val)));
159 $filename .= '_WHERE_' . join ('_AND_', @where);
162 $filename .= '.html';
171 my @aggs = map { ucfirst ($_) } (@{$sel->[0]});
172 my @flds = map { ucfirst ($_) } (@{$sel->[1]});
174 my $title = my_join (@aggs) . ' by ' . my_join (@flds);
176 if (scalar (@{$sel->[2]}))
181 ucfirst ($_->[0]) . ' '
183 . ' "' . $_->[2] . '"'
186 $title .= my_join (@wheres);
189 ($title) = escape ($title);
196 my $last = pop (@all);
198 return ($last) unless (@all);
200 my $retval = join (', ', @all) . " and $last";