From: Michal Vaner Date: Sat, 30 Aug 2008 17:14:33 +0000 (+0200) Subject: Integrate ID syntax help X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=b4d2a8f2c63d013bd0477acc3fa4549d9e8c0d0e;p=pciids.git Integrate ID syntax help --- diff --git a/PciIds/Address/Base.pm b/PciIds/Address/Base.pm index 428245d..1ec3cb8 100644 --- a/PciIds/Address/Base.pm +++ b/PciIds/Address/Base.pm @@ -45,4 +45,8 @@ sub path( $ ) { return \@result; } +sub helpName( $ ) { + return undef; +} + 1; diff --git a/PciIds/Address/Pci.pm b/PciIds/Address/Pci.pm index 33e4afc..c9b3a16 100644 --- a/PciIds/Address/Pci.pm +++ b/PciIds/Address/Pci.pm @@ -60,4 +60,8 @@ sub path( $ ) { return $result; } +sub helpName( $ ) { + return 'pci'; +} + 1; diff --git a/PciIds/Address/PciClass.pm b/PciIds/Address/PciClass.pm index 13656ef..f0ac793 100644 --- a/PciIds/Address/PciClass.pm +++ b/PciIds/Address/PciClass.pm @@ -44,4 +44,8 @@ sub append( $$ ) { return ( PciIds::Address::new( $self->{'value'} . ( ( $self->{'value'} =~ /\/$/ ) ? '' : '/' ) . $suffix ), undef ); } +sub helpName( $ ) { + return 'pci_class'; +} + 1; diff --git a/PciIds/Address/Toplevel.pm b/PciIds/Address/Toplevel.pm index bc66024..614db47 100644 --- a/PciIds/Address/Toplevel.pm +++ b/PciIds/Address/Toplevel.pm @@ -73,4 +73,13 @@ sub parent( $ ) { return undef; } +sub helpName( $ ) { + my( $self ) = @_; + if( $self->{'value'} =~ /^PC/ ) { + return 'pci'; + } else { + return 'pci_class'; + } +} + 1; diff --git a/PciIds/Html/Changes.pm b/PciIds/Html/Changes.pm index 2fa3d2c..a23d50d 100644 --- a/PciIds/Html/Changes.pm +++ b/PciIds/Html/Changes.pm @@ -16,7 +16,7 @@ sub genNewItemForm( $$$$$$ ) { my $prettyAddr = encode( $address->pretty() ); genHtmlHead( $req, "$prettyAddr - add new item", undef ); print "

$prettyAddr - add new item

\n"; - genLocMenu( $req, $args, [ logItem( $auth ), $address->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), [ 'Notifications', 'notifications' ], [ 'Help', 'help', 'newitem' ] ] ); + genLocMenu( $req, $args, [ logItem( $auth ), $address->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), [ 'Notifications', 'notifications' ], [ 'Help', 'help', 'newitem' ], [ 'ID syntax', 'help', $address->helpName() ] ] ); print "
$error
\n" if( defined $error ); print "
\n"; genFormEx( [ [ 'input', 'Id:', 'text', 'id', 'maxlength="50"' ], diff --git a/PciIds/Html/List.pm b/PciIds/Html/List.pm index 02c62c9..040d35a 100644 --- a/PciIds/Html/List.pm +++ b/PciIds/Html/List.pm @@ -25,7 +25,7 @@ sub list( $$$$ ) { my $id = $address->pretty(); genHtmlHead( $req, $id, undef ); print '

'.encode( $id ).'

'; - genMenu( $req, $address, $args, $auth, 'list' ); + genMenu( $req, $address, $args, $auth, [ [ 'Help', 'help', 'list' ], $address->helpName() ? [ 'ID syntax', 'help', $address->helpName() ] : () ] ); genPath( $req, $address, 0 ); print htmlDiv( 'name', '

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

'.encode( $note ) ) if( defined( $note ) ); diff --git a/PciIds/Html/Util.pm b/PciIds/Html/Util.pm index 37538f3..63f98bf 100644 --- a/PciIds/Html/Util.pm +++ b/PciIds/Html/Util.pm @@ -69,7 +69,7 @@ sub logItem( $ ) { } sub genMenu( $$$$$ ) { - my( $req, $address, $args, $auth, $help ) = @_; + my( $req, $address, $args, $auth, $append ) = @_; my @list = ( logItem( $auth ) ); if( defined $address ) { push @list, [ 'Add item', 'newitem' ] if( $address->canAddItem() ); @@ -78,7 +78,7 @@ sub genMenu( $$$$$ ) { push @list, [ 'Administrate', 'admin' ] if( hasRight( $auth->{'accrights'}, 'validate' ) ); push @list, [ 'Profile', 'profile' ] if defined $auth->{'authid'}; push @list, [ 'Notifications', 'notifications' ] if defined $auth->{'authid'}; - push @list, [ 'Help', 'help', $help ] if defined $help; + push @list, @{$append} if defined $append; genCustomMenu( $req, $address, $args, \@list ); }