]> mj.ucw.cz Git - pciids.git/blob - PciIds/Html/Help.pm
Add item link below items
[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 "<div class='top'>\n";
22         print "<h1>$head".( defined $addr ? " (".$addr->pretty().")" : "" )."</h1>\n";
23         genMenu( $req, $addr, $args, $auth, [ [ 'Help index', 'help', 'index' ] ] );
24         genPath( $req, $addr, 1 );
25         print "<div class='clear'></div></div>\n";
26         my $url = setAddrPrefix( $req->uri(), 'read' ).buildExcept( 'help', $args ).'?help=';
27         delete $args->{'help'};
28         my %repls = ( 'HELP_URL' => $url, 'AC_URL' => setAddrPrefix( $req->uri(), 'mods' ).buildExcept( 'action', $args ).'?action=' );
29         while( defined( my $line = <HELP> ) ) {
30                 $line =~ s/\$(\w+_URL)\$/$repls{$1}/g;
31                 print $line;
32         }
33         close HELP;
34         genHtmlTail();
35         return OK;
36 }
37
38 1;