]> mj.ucw.cz Git - pciids.git/blob - PciIds/Html/Help.pm
Help works
[pciids.git] / PciIds / Html / Help.pm
1 package PciIds::Html::Help;
2 use strict;
3 use warnings;
4 use PciIds::Startup;
5 use PciIds::Html::Util;
6 use PciIds::Address;
7 use Apache2::Const qw(:common :http);
8 use base 'Exporter';
9
10 our @EXPORT=qw(getHelp);
11
12 sub getHelp( $$ ) {
13         my( $req, $args, $tables, $auth ) = @_;
14         my $helpname = $args->{'help'};
15         return NOT_FOUND if( !defined $helpname || $helpname =~ /[\/.]/ || $helpname eq '' );
16         open HELP, "$directory/help/$helpname" or return NOT_FOUND;
17         my $head = <HELP>;
18         chomp $head;
19         genHtmlHead( $req, $head, undef );
20         my $addr = PciIds::Address::new( $req->uri() );
21         print "<h1>$head (".$addr->pretty().")</h1>\n";
22         genMenu( $req, $addr, $args, $auth, undef );
23         genPath( $req, $addr, 1 );
24         my $url = '/read'.$req->uri().buildExcept( 'help', $args ).'?help=';
25         print "<div class='navigation'><ul><li><a href='$url=index'>Help index</a></ul></div>\n" if( $helpname ne 'index' );
26         while( defined( my $line = <HELP> ) ) {
27                 $line =~ s/\$CUR_LINK\$/$url/g;
28                 print $line;
29         }
30         close HELP;
31         genHtmlTail();
32         return OK;
33 }
34
35 1;