]> mj.ucw.cz Git - pciids.git/blob - PciIds/Html/Help.pm
Merge branch 'master' of /home/vorner/pciids
[pciids.git] / PciIds / Html / Help.pm
1 #       PciIds web database
2 #       Copyright (C) 2008 Michal Vaner (vorner@ucw.cz)
3 #
4 #       This program is free software; you can redistribute it and/or modify
5 #       it under the terms of the GNU General Public License as published by
6 #       he Free Software Foundation; either version 2 of the License, or
7 #       (at your option) any later version.
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 #
13 #       GNU General Public License for more details.
14 #
15 #       You should have received a copy of the GNU General Public License
16 #       along with this program; if not, write to the Free Software
17 #       Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19 package PciIds::Html::Help;
20 use strict;
21 use warnings;
22 use PciIds::Startup;
23 use PciIds::Html::Util;
24 use PciIds::Address;
25 use Apache2::Const qw(:common :http);
26 use base 'Exporter';
27
28 our @EXPORT=qw(getHelp);
29
30 sub getHelp( $$ ) {
31         my( $req, $args, $tables, $auth ) = @_;
32         my $helpname = $args->{'help'};
33         return NOT_FOUND if( !defined $helpname || $helpname =~ /[\/.]/ || $helpname eq '' );
34         open HELP, "$directory/help/$helpname" or return NOT_FOUND;
35         my $head = <HELP>;
36         chomp $head;
37         genHtmlHead( $req, $head, undef );
38         my $addr = PciIds::Address::new( $req->uri() );
39         print "<div class='top'>\n";
40         genMenu( $req, $addr, $args, $auth, [ ( $helpname eq 'index' ) ? () : [ 'Help index', 'help', 'index' ] ] );
41         print "<div class='bluesquare'><h1>$head</h1><p class='home'>The PCI ID Repository</div>\n";
42         print "<div class='clear'></div></div>\n";
43         genPath( $req, $addr, 1 );
44         my $url = setAddrPrefix( $req->uri(), 'read' ).buildExcept( 'help', $args ).'?help=';
45         delete $args->{'help'};
46         my %repls = ( 'HELP_URL' => $url, 'AC_URL' => setAddrPrefix( $req->uri(), 'mods' ).buildExcept( 'action', $args ).'?action=' );
47         $repls{'AC_URL'} =~ s#mods/\?#mods/PC/?#;
48         while( defined( my $line = <HELP> ) ) {
49                 $line =~ s/\$(\w+_URL)\$/$repls{$1}/g;
50                 print $line;
51         }
52         close HELP;
53         genHtmlFooter( 1, $req, $args );
54         return OK;
55 }
56
57 1;