From: Michal Vaner Date: Sat, 30 Aug 2008 12:18:41 +0000 (+0200) Subject: Help works X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=603808d6fe06a611c79e65ba50d46ce2a6b03088;p=pciids.git Help works --- diff --git a/PciIds/Html/Handler.pm b/PciIds/Html/Handler.pm index 4392baf..f490f08 100644 --- a/PciIds/Html/Handler.pm +++ b/PciIds/Html/Handler.pm @@ -39,7 +39,8 @@ my %handlers = ( #Some debug 'test' => \&PciIds::Html::Debug::test, #Notifications - 'notifications' => \&PciIds::Html::Notifications::notifForm + 'notifications' => \&PciIds::Html::Notifications::notifForm, + 'help' => \&PciIds::Html::Help::getHelp }, 'POST' => { 'newitem' => \&PciIds::Html::Changes::newItemSubmit, @@ -59,7 +60,6 @@ sub handler( $$ ) { my( $req, $hasSSL ) = @_; return HTTPRedirect( $req, $req->uri()."index.html" ) if( $req->uri() eq '/' ); return DECLINED if( $req->uri() =~ /^\/((static)\/|robots.txt|index.html)/ ); - return getHelp( $req ) if( $req->uri() =~ /^\/help/ ); my $args = parseArgs( $req->args() ); my $action = $args->{'action'}; $action = '' unless( defined $action ); diff --git a/PciIds/Html/Help.pm b/PciIds/Html/Help.pm index 512f38e..803d922 100644 --- a/PciIds/Html/Help.pm +++ b/PciIds/Html/Help.pm @@ -3,21 +3,28 @@ use strict; use warnings; use PciIds::Startup; use PciIds::Html::Util; +use PciIds::Address; use Apache2::Const qw(:common :http); use base 'Exporter'; our @EXPORT=qw(getHelp); -sub getHelp($) { - my( $req ) = @_; - my( $helpname ) = ( $req->uri() =~ /^\/help\/(.*)/ ); - return NOT_FOUND if( $helpname =~ /[\/.]/ || $helpname eq '' ); +sub getHelp( $$ ) { + my( $req, $args, $tables, $auth ) = @_; + my $helpname = $args->{'help'}; + return NOT_FOUND if( !defined $helpname || $helpname =~ /[\/.]/ || $helpname eq '' ); open HELP, "$directory/help/$helpname" or return NOT_FOUND; my $head = ; chomp $head; genHtmlHead( $req, $head, undef ); - print "

$head

\n"; + my $addr = PciIds::Address::new( $req->uri() ); + print "

$head (".$addr->pretty().")

\n"; + genMenu( $req, $addr, $args, $auth, undef ); + genPath( $req, $addr, 1 ); + my $url = '/read'.$req->uri().buildExcept( 'help', $args ).'?help='; + print "\n" if( $helpname ne 'index' ); while( defined( my $line = ) ) { + $line =~ s/\$CUR_LINK\$/$url/g; print $line; } close HELP; diff --git a/PciIds/Html/List.pm b/PciIds/Html/List.pm index 875640b..02c62c9 100644 --- a/PciIds/Html/List.pm +++ b/PciIds/Html/List.pm @@ -25,10 +25,10 @@ sub list( $$$$ ) { my $id = $address->pretty(); genHtmlHead( $req, $id, undef ); print '

'.encode( $id ).'

'; - genMenu( $req, $address, $args, $auth ); + genMenu( $req, $address, $args, $auth, 'list' ); + genPath( $req, $address, 0 ); print htmlDiv( 'name', '

'.encode( $name ) ) if( defined( $name ) ); print htmlDiv( 'note', '

'.encode( $note ) ) if( defined( $note ) ); - genPath( $req, $address, 0 ); my $diss = 0; my $history; foreach $history ( @{$tables->history( $address->get() )} ) { @@ -53,7 +53,7 @@ sub list( $$$$ ) { } print "\n" if( $diss ); unless( $address->leaf() ) { - print "

Subitems

\n"; + print "

Sub-items

\n"; my $restricts = $address->defaultRestrictList(); if( scalar @{$restricts} ) { print "

"; diff --git a/PciIds/Html/Notifications.pm b/PciIds/Html/Notifications.pm index 1d5523a..b39bc07 100644 --- a/PciIds/Html/Notifications.pm +++ b/PciIds/Html/Notifications.pm @@ -29,18 +29,18 @@ sub genNotifForm( $$$$$$ ) { } print "\n" if( $started ); print "

\n"; - print "

Effect range

\n"; + print "

Effect range

\n"; print "

{'recursive'} ? " checked='checked'" : "" )."> Recursive\n"; - print "

Notification level

\n"; + print "

Notification level

\n"; print "

\n"; genRadios( [ [ 'None', '3' ], [ 'Main comment & new subitem', '2' ], [ 'Description', '1' ], [ 'Comment', '0' ] ], 'notification', ( defined $data->{'notification'} ) ? $data->{'notification'} : '3' ); - print "

Notification way

\n"; + print "

Notification way

\n"; print "

\n"; genRadios( [ [ 'Email', '0' ], [ 'Xmpp', '1' ], [ 'Both', '2' ] ], 'way', ( defined $data->{'way'} ) ? $data->{'way'} : '0' ); print "

\n"; print "

\n"; if( @{$notifs} ) { - print "