]> mj.ucw.cz Git - pciids.git/blob - PciIds/Html/Tables.pm
Discuss link below discussion
[pciids.git] / PciIds / Html / Tables.pm
1 package PciIds::Html::Tables;
2 use strict;
3 use warnings;
4 use base 'PciIds::DBQ';
5 use PciIds::Html::Format;
6 use PciIds::Address;
7
8 sub new( $ ) {
9         my( $dbh ) = @_;
10         return bless PciIds::DBQ::new( $dbh );
11 }
12
13 sub formatLink( $$ ) {
14         my $address = PciIds::Address::new( shift );
15         my $url_prefix = shift;
16         return '<a href="'.$url_prefix.'/read/'.$address->get().'">'.$address->tail().'</a>';
17 }
18
19 sub nodes( $$$$ ) {
20         my( $self, $parent, $args, $url_prefix ) = @_;
21         my $restrict = $args->{'restrict'};
22         $restrict = '' unless( defined $restrict );
23         $restrict = PciIds::Address::new( $parent )->restrictRex( $restrict );#How do I know if the restrict is OK?
24         htmlFormatTable( PciIds::DBQ::nodes( $self, $parent, $args, $restrict ), 3, [], [ sub {
25                 return formatLink( shift, $url_prefix );
26         }, ], sub { 1; }, sub {
27                 my $name = shift->[ 1 ];
28                 return ' class="'.( defined $name && $name ne '' ? 'item' : 'unnamedItem' ).'"';
29         } );
30 }
31
32 1;