552217b3f463698d01e8215ceb3c02e04ffc131e
[www.jankratochvil.net.git] / product / hotelgate / Lib.pm
1 # $Id$
2 # Common functions for the HotelGate project
3 # Copyright (C) 2005 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
4
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
8
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.
13
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
17
18
19 package product::hotelgate::Lib;
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; };
22 our $CVS_ID=q$Id$;
23 use strict;
24 use warnings;
25
26 use My::Web;
27 use Carp qw(cluck confess);
28
29 use Exporter;
30 our @EXPORT=qw();
31 Wrequire 'product::Lib';
32 our @ISA=qw(product::Lib Exporter);
33
34
35 sub menu($;%)
36 {
37 my($class,%args)=@_;
38
39         my $r="";
40         $r.='<table border="0" class="margin-center"><tr>'."\n";
41                 $r.='<td>';
42                         $r.='<table border="1" style="border-collapse: collapse; border-style: solid; border-width: 1px;">'."\n";
43                                 $r.='<tr>'."\n";
44                                         $r.='<td style="padding: 5px; font-weight: bold;">'."\n";
45                                                 my $ListItem=product::Lib->name_to_hashref($W->{"product_name"});
46                                                 $r.=product::Lib->title($ListItem);
47                                         $r.='</td>'."\n";
48                                 $r.='</tr>'."\n";
49                         $r.='</table>';
50                 $r.='</td>';
51                 $r.='<td>';
52                         $r.='<table border="1" style="border-collapse: collapse; border-style: solid;" class="margin-center">'."\n";
53                                 $r.='<tr>'."\n";
54                                         my @sections=(
55                                                         "Index"=>"Overview",
56                                                         "Case"=>"Deployment",
57                                                         "Screenshot"=>"Screenshots",
58                                                         "Spec"=>"Specification",
59                                                         "Order"=>"Order",
60                                                         );
61                                         while (@sections) {
62                                                 my $section_path=shift @sections;
63                                                 my $section_name=shift @sections;
64                                                 my $chosen=($My::Web::W->{"__PACKAGE__"} eq "product::hotelgate::".$section_path);
65                                                 $r.='<td style="padding: 5px;">';
66                                                         $r.=(($chosen || "") ? "<b>$section_name</b>"
67                                                                         : My::Web::a_href("./".($section_path eq "Index" ? "" : $section_path.".pm"),$section_name,
68                                                                                         "attr"=>'style="text-decoration: inherit; /* revoke underline */;"'));
69                                                 $r.="</td>\n";
70                                                 }
71                                 $r.='</tr>'."\n";
72                         $r.='</table>'."\n";
73                 $r.='</td>'."\n";
74         $r.='</tr></table>'."\n";
75         if (!$args{"novskip"}) {
76                 Wrequire 'WebConfig';
77                 $r.=WebConfig->vskip_hr();
78                 }
79         return $r;
80 }
81
82 sub init($%)
83 {
84 my($class,%args)=@_;
85
86         $args{"__PACKAGE__"}||=caller();
87         my $W=$class->SUPER::init(
88                         %args,
89                         "novskip"=>1,
90                         );
91         print $class->menu(%args);
92         return $W;
93 }
94
95 1;