2 # Copyright (C) 2008 Michal Vaner (vorner@ucw.cz)
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.
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
13 # GNU General Public License for more details.
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
19 package PciIds::Html::Help;
23 use PciIds::Html::Util;
25 use Apache2::Const qw(:common :http);
28 our @EXPORT=qw(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;
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(), 'mods' ).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 $repls{'HELP_URL'} =~ s#(mods|read)/\?#$1/PC/?#;
49 while( defined( my $line = <HELP> ) ) {
50 $line =~ s/\$(\w+_URL)\$/$repls{$1}/g;
54 genHtmlFooter( 1, $req, $args );