From 810581ac2f7b7832632416d16876226245bf4c1f Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Wed, 3 Sep 2008 15:34:16 +0200 Subject: [PATCH] Output better path --- PciIds/Address/Base.pm | 3 ++- PciIds/Address/Pci.pm | 2 +- PciIds/Html/Admin.pm | 2 +- PciIds/Html/List.pm | 5 +---- PciIds/Html/Util.pm | 24 +++++++++++++++++------- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/PciIds/Address/Base.pm b/PciIds/Address/Base.pm index 8b40461..b9f01aa 100644 --- a/PciIds/Address/Base.pm +++ b/PciIds/Address/Base.pm @@ -40,8 +40,9 @@ sub path( $ ) { my @result; my $address = $self; while( defined( $address = $address->parent() ) ) { - push @result, $address; + push @result, [ $address, 0 ]; } + unshift @result, [ $self, 0, 1 ]; return \@result; } diff --git a/PciIds/Address/Pci.pm b/PciIds/Address/Pci.pm index 5fc5443..0775689 100644 --- a/PciIds/Address/Pci.pm +++ b/PciIds/Address/Pci.pm @@ -70,7 +70,7 @@ sub path( $ ) { my( $self ) = @_; my $result = PciIds::Address::Base::path( $self ); my( $vid ) = ( $self->get() =~ /^PC\/[0-9a-f]{4}\/[0-9a-f]{4}\/([0-9a-f]{4})/ ); - splice @{$result}, 2, 0, PciIds::Address::new( "PC/$vid" ) if( defined $vid ) && ( $result->[1]->get() ne "PC/$vid" ); + unshift @{$result}, [ PciIds::Address::new( "PC/$vid" ), 1 ] if( defined $vid );# && ( $result->[1]->[0]->get() ne "PC/$vid" ); return $result; } diff --git a/PciIds/Html/Admin.pm b/PciIds/Html/Admin.pm index c1ef051..61a0291 100644 --- a/PciIds/Html/Admin.pm +++ b/PciIds/Html/Admin.pm @@ -70,7 +70,7 @@ sub genNewAdminForm( $$$$$ ) { } print "New:\n"; print ""; - genPathBare( $req, $addr, 0, 0 ); + genPathBare( $req, $addr, 0, 0, 0 ); print "\n"; } print "".safeEncode( ( defined $name && $name eq '' ) ? 'Deletion request' : $name )."".safeEncode( $note )."".safeEncode( $disc )."".mailEncode( $user ); diff --git a/PciIds/Html/List.pm b/PciIds/Html/List.pm index 116a33f..6339e15 100644 --- a/PciIds/Html/List.pm +++ b/PciIds/Html/List.pm @@ -30,10 +30,7 @@ sub list( $$$$ ) { print "
\n"; print ""; genPath( $req, $address, 0 ); - if( defined $name ) { - print '

'.encode( $id ).'

'; - print htmlDiv( 'name', '

Name: '.encode( $name ) ); - } + print htmlDiv( 'name', '

Name: '.encode( $name ) ) if defined $name && $name ne ''; print htmlDiv( 'note', '

Note: '.encode( $note ) ) if defined $note && $note ne ''; my $diss = 0; my $history; diff --git a/PciIds/Html/Util.pm b/PciIds/Html/Util.pm index 56c1802..d27435d 100644 --- a/PciIds/Html/Util.pm +++ b/PciIds/Html/Util.pm @@ -150,30 +150,40 @@ sub HTTPRedirect( $$ ) { return HTTP_SEE_OTHER; } -sub genPathBare( $$$$ ) { +sub genPathBare( $$$$$ ) { my( $req, $address, $printAddr, $started ) = @_; my $path; if( defined $address ) { $path = $address->path(); - unshift @{$path}, $address if( $printAddr ); } else { $path = []; } - foreach my $addr ( reverse @{$path} ) { + foreach my $item ( reverse @{$path} ) { + my( $addr, $exception, $myAddr ) = @{$item}; if( $started ) { - print " -> "; + if( $exception ) { + print ", "; + } else { + print " -> "; + } } else { $started = 1; } - print "".encode( $addr->pretty() ).""; + print "(" if( $exception ); + if( !$printAddr && $myAddr ) { + print "".encode( $addr->pretty() ).""; + } else { + print "".encode( $addr->pretty() ).""; + } + print ")" if( $exception ); } } sub genPath( $$$ ) { my( $req, $address, $printAddr ) = @_; print "

\n"; - print "

Main page"; - genPathBare( $req, $address, $printAddr, 1 ); + print "

Main"; + genPathBare( $req, $address, $printAddr, 1, 1 ); print "

\n"; } -- 2.39.2