From 7f951d8070696d3010581da2a99e67b59f12fb98 Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Mon, 13 Oct 2008 22:47:45 +0200 Subject: [PATCH] Tooltips with name in admin interface --- PciIds/DBQ.pm | 9 ++++++++- PciIds/Html/Admin.pm | 2 +- PciIds/Html/Util.pm | 10 ++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/PciIds/DBQ.pm b/PciIds/DBQ.pm index cb82576..bf7134d 100644 --- a/PciIds/DBQ.pm +++ b/PciIds/DBQ.pm @@ -118,7 +118,8 @@ sub new( $ ) { 'searchlocalname' => 'SELECT l.id, l.name, p.name FROM locations AS l JOIN locations AS p ON l.parent = p.id WHERE l.name LIKE ? AND l.id LIKE ? ORDER BY LENGTH(l.id), l.id', 'hasChildren' => 'SELECT DISTINCT 1 FROM locations WHERE parent = ?', 'hasMain' => 'SELECT DISTINCT 1 FROM locations WHERE id = ? AND mainhistory IS NOT NULL', - 'notif-exists' => 'SELECT DISTINCT 1 FROM notifications WHERE user = ? AND ( location = ? OR ( recursive = 1 AND type <= 1 AND SUBSTR( ?, 1, LENGTH( location ) ) = location ) )' + 'notif-exists' => 'SELECT DISTINCT 1 FROM notifications WHERE user = ? AND ( location = ? OR ( recursive = 1 AND type <= 1 AND SUBSTR( ?, 1, LENGTH( location ) ) = location ) )', + 'itemname' => 'SELECT name FROM locations WHERE id = ?' } ); } @@ -387,4 +388,10 @@ sub searchName( $$$ ) { return $self->query( 'searchname', [ "%$search%" ] ); } +sub itemName( $$ ) { + my( $self, $id ) = @_; + my $result = $self->query( 'itemname', [ $id ] )->[0]->[0]; + return defined $result ? $result : ''; +} + 1; diff --git a/PciIds/Html/Admin.pm b/PciIds/Html/Admin.pm index 6b90c7c..056d353 100644 --- a/PciIds/Html/Admin.pm +++ b/PciIds/Html/Admin.pm @@ -166,7 +166,7 @@ function answer( id ) { print "\n"; print "

\n"; print ""; - genPathBare( $req, $addr, 1, 0 ); + genPathBare( $req, $addr, 1, 0, $tables ); print "" if( $subcnt ); $subcnt = 0; $cnt ++; diff --git a/PciIds/Html/Util.pm b/PciIds/Html/Util.pm index 8a5c804..615bac5 100644 --- a/PciIds/Html/Util.pm +++ b/PciIds/Html/Util.pm @@ -193,8 +193,8 @@ sub HTTPRedirect( $$ ) { return HTTP_SEE_OTHER; } -sub genPathBare( $$$$ ) { - my( $req, $address, $printAddr, $started ) = @_; +sub genPathBare( $$$$$ ) { + my( $req, $address, $printAddr, $started, $tables ) = @_; my $path; if( defined $address ) { $path = $address->path(); @@ -216,7 +216,9 @@ sub genPathBare( $$$$ ) { if( !$printAddr && $myAddr ) { print "".encode( $addr->pretty() ).""; } else { - print "".encode( $addr->pretty() ).""; + my $title = ''; + $title = ' title="'.encode( $tables->itemName( $addr->get() ) ).'"' if defined $tables; + print "".encode( $addr->pretty() ).""; } print ")" if( $exception ); } @@ -226,7 +228,7 @@ sub genPath( $$$ ) { my( $req, $address, $printAddr ) = @_; print "

\n"; print "

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

\n"; } -- 2.39.2