]> mj.ucw.cz Git - pciids.git/blob - PciIds/Html/Tables.pm
Tooltips with name in admin interface
[pciids.git] / PciIds / Html / Tables.pm
1 #       PciIds web database
2 #       Copyright (C) 2008 Michal Vaner (vorner@ucw.cz)
3 #
4 #       This program is free software; you can redistribute it and/or modify
5 #       it under the terms of the GNU General Public License as published by
6 #       he Free Software Foundation; either version 2 of the License, or
7 #       (at your option) any later version.
8 #
9 #       This program is distributed in the hope that it will be useful,
10 #       but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #
13 #       GNU General Public License for more details.
14 #
15 #       You should have received a copy of the GNU General Public License
16 #       along with this program; if not, write to the Free Software
17 #       Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19 package PciIds::Html::Tables;
20 use strict;
21 use warnings;
22 use base 'PciIds::DBQ';
23 use PciIds::Html::Format;
24 use PciIds::Address;
25
26 sub new( $ ) {
27         my( $dbh ) = @_;
28         return bless PciIds::DBQ::new( $dbh );
29 }
30
31 sub formatLink( $ ) {
32         my $address = PciIds::Address::new( shift );
33         return '<a href="/read/'.$address->get().'">'.$address->tail().'</a>';
34 }
35
36 sub nodes( $$$ ) {
37         my( $self, $parent, $args ) = @_;
38         my $restrict = $args->{'restrict'};
39         $restrict = '' unless( defined $restrict );
40         $restrict = PciIds::Address::new( $parent )->restrictRex( $restrict );#How do I know if the restrict is OK?
41         htmlFormatTable( PciIds::DBQ::nodes( $self, $parent, $args, $restrict ), 3, [], [ \&formatLink ], sub { 1; }, sub {
42                 my $name = shift->[ 1 ];
43                 return ' class="'.( defined $name && $name ne '' ? 'item' : 'unnamedItem' ).'"';
44         } );
45 }
46
47 1;