2 # Common functions for HTML/XHTML output generation
3 # Copyright (C) 2003 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; exactly version 2 of June 1991 is required
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway
21 our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
27 use Carp qw(cluck confess);
32 our @ISA=qw(My::Web Lib Exporter);
35 my $LIST_ABSPATH="/product/SUBDIRS";
38 # Returns: hashref if !wantarray(), list if wantarray().
43 return $self->list_abspath($LIST_ABSPATH);
46 sub products_sorted($)
50 my %item=$self->name_to_hashref();
52 ($item{$b}{"priority"} <=> $item{$a}{"priority"})
54 (lc($item{$a}{"name"}) cmp lc($item{$b}{"name"}));
58 # $args{"is_index"}=1;
61 my($class,$product_selected,%args)=@_;
64 $r.='<table border="0" class="margin-center"><tr>'."\n";
66 $r.='<table border="1" style="border-collapse: collapse; border-style: solid; border-width: 1px;">'."\n";
68 $r.='<td style="padding: 5px; font-weight: bold;">'."\n";
75 $r.='<table border="1" style="border-collapse: collapse; border-style: solid;">'."\n";
77 my %item=$class->name_to_hashref();
78 for my $product_found ($class->products_sorted()) {
79 my $chosen=($product_selected && $product_selected eq $product_found);
80 $r.='<td style="padding: 5px;">';
81 $r.=($chosen && $args{"is_index"} ? "<b>".$item{$product_found}{"name"}."</b>"
82 : a_href "/product/$product_found/",$item{$product_found}{"name"},
84 ? 'style="text-decoration: underline; font-weight: bold;"'
85 : 'style="text-decoration: inherit; /* revoke underline */"'));
91 $r.='</tr></table>'."\n";
93 # Products menu DISABLED:
96 if (!$args{"novskip"}) {
98 $r.=WebConfig->vskip_hr();
107 $args{"__PACKAGE__"}||=caller();
108 $args{"product_name"}||=($args{"__PACKAGE__"}=~/^product::(\w+)::/)[0]
109 or cluck "Error finding product name of the package: ".$args{"__PACKAGE__"};
110 my $ListItem=$class->name_to_hashref($args{"product_name"});
111 my $W=$class->SUPER::init(
112 "title"=>My::Web->a_href_inhibit(sub { return $class->title($ListItem); }),
115 "rel_up"=>'/product/',
116 # "rel_start"=>"/", # TODO:homepage
117 "css_push"=>"/product/Lib.css",
119 "heading_novskip"=>1,
122 my $is_index=($args{"__PACKAGE__"}=~/^product::\w+::Index$/);
123 print $class->products($args{"product_name"},
124 "is_index"=>$is_index,