]> mj.ucw.cz Git - pciids.git/commitdiff
Output better path
authorMichal Vaner <vorner@ucw.cz>
Wed, 3 Sep 2008 13:34:16 +0000 (15:34 +0200)
committerMichal Vaner <vorner@ucw.cz>
Wed, 3 Sep 2008 13:34:16 +0000 (15:34 +0200)
PciIds/Address/Base.pm
PciIds/Address/Pci.pm
PciIds/Html/Admin.pm
PciIds/Html/List.pm
PciIds/Html/Util.pm

index 8b40461dfe3e5921c893176f328bc69e161da249..b9f01aaaf4ddc7882abb8fb2c0a181b39cf8b7c1 100644 (file)
@@ -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;
 }
 
index 5fc5443eae07e1d0c179d49e1b00000974acfb19..0775689e808bdb7dd7d7dbb24c543b1f62a22dcb 100644 (file)
@@ -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;
 }
 
index c1ef0517a6ff110923607cfdcc294b4fd66437d2..61a0291dde5850561fd3b4f5ff65a7588e322819 100644 (file)
@@ -70,7 +70,7 @@ sub genNewAdminForm( $$$$$ ) {
                        }
                        print "<tr class='new'><td>New:<td><input type='text' name='name-$cnt' class='text'><td><input type='text' name='note-$cnt' class='text'><td><textarea name='disc-$cnt'></textarea>\n";
                        print "<td colspan='3'>";
-                       genPathBare( $req, $addr, 0, 0 );
+                       genPathBare( $req, $addr, 0, 0, 0 );
                        print "<td><input type='checkbox' name='loc-$cnt-softdel' value='del'>\n";
                }
                print "<tr class='unseen-history'><td class='empty'><td>".safeEncode( ( defined $name && $name eq '' ) ? 'Deletion request' : $name )."<td>".safeEncode( $note )."<td>".safeEncode( $disc )."<td>".mailEncode( $user );
index 116a33ff821632293308f559d3957ee1417c174f..6339e151f3c15a8f533089c3669f1d75a9fead80 100644 (file)
@@ -30,10 +30,7 @@ sub list( $$$$ ) {
        print "<div class='clear'></div>\n";
        print "</div\n>";
        genPath( $req, $address, 0 );
-       if( defined $name ) {
-               print '<h2>'.encode( $id ).'</h2>';
-               print htmlDiv( 'name', '<p>Name: '.encode( $name ) );
-       }
+       print htmlDiv( 'name', '<p>Name: '.encode( $name ) ) if defined $name && $name ne '';
        print htmlDiv( 'note', '<p>Note: '.encode( $note ) ) if defined $note && $note ne '';
        my $diss = 0;
        my $history;
index 56c1802edd50cc60d9db86db44ef0715bdb2afa0..d27435da8bd2610e37a9773fbed5e1a78146dc38 100644 (file)
@@ -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 "&nbsp;-&gt;&nbsp;";
+                       if( $exception ) {
+                               print ", ";
+                       } else {
+                               print " -&gt; ";
+                       }
                } else {
                        $started = 1;
                }
-               print "<a href='http://".$req->hostname()."/read/".$addr->get()."'>".encode( $addr->pretty() )."</a>";
+               print "(" if( $exception );
+               if( !$printAddr && $myAddr ) {
+                       print "<strong>".encode( $addr->pretty() )."</strong>";
+               } else {
+                       print "<a href='http://".$req->hostname()."/read/".$addr->get()."'>".encode( $addr->pretty() )."</a>";
+               }
+               print ")" if( $exception );
        }
 }
 
 sub genPath( $$$ ) {
        my( $req, $address, $printAddr ) = @_;
        print "<div class='path'>\n";
-       print "<p><a href='http://".$req->hostname()."/index.html'>Main page</a>";
-       genPathBare( $req, $address, $printAddr, 1 );
+       print "<p><a href='http://".$req->hostname()."/index.html'>Main</a>";
+       genPathBare( $req, $address, $printAddr, 1, 1 );
        print "</div>\n";
 }