]> mj.ucw.cz Git - pciids.git/blob - PciIds/Html/Format.pm
Tooltips with name in admin interface
[pciids.git] / PciIds / Html / Format.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::Format;
20 use strict;
21 use warnings;
22 use PciIds::Html::Util;
23 use base 'Exporter';
24
25 our @EXPORT = qw(&htmlFormatTable);
26
27 sub htmlFormatTable( $$$$$$ ) {
28         my( $data, $cols, $headers, $funcs, $filter, $trHead ) = @_;
29         $trHead = sub { return ''; } unless( defined $trHead );
30         foreach my $line ( @{$data} ) {
31                 next unless( &{$filter}( $line ) );
32                 my $i;
33                 print '<tr'.&{$trHead}( $line ).'>';
34                 for( $i = 0; $i < $cols; $i ++ ) {
35                         my( $header, $func );
36                         if( ( scalar( @{$headers} ) > $i ) && defined( $headers->[ $i ] ) ) {
37                                 $header = $headers->[ $i ];
38                         } else {
39                                 $header = '<td>';
40                         }
41                         if( ( scalar( @{$funcs} ) > $i ) && defined( $funcs->[ $i ] ) ) {
42                                 $func = $funcs->[ $i ];
43                         } else {
44                                 $func = \&encode;
45                         }
46                         my $data = &{$func}( $line->[ $i ] );
47                         $data = "" unless( defined( $data ) );
48                         print $header.$data;
49                 }
50                 print "\n";
51         }
52 }
53
54 1;