blib/lib/CGI/OptimalQuery/SimpleQuery.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 54 SCAR 24.8
CC
3
Cov
0%
output
12.0
escapeHTML
2.0
BEGIN
2.0
CRAP 12.0
1 package CGI::OptimalQuery::SimpleQuery;
2  
3 use strict;
4 use warnings;
5 no warnings qw( uninitialized );
6 use base 'CGI::OptimalQuery::Base';
7  
8 sub escapeHTML { CGI::OptimalQuery::Base::escapeHTML(@_) }
9  
10 sub output {
11 my ($o) = @_;
12  
13 my $tbody;
14 my $typeMap = $o->{oq}->get_col_types('select');
15 while (my $r = $o->fetch()) {
16 $tbody .= "<tr data-uid='".escapeHTML($$r{U_ID})."'>";
17  
18 foreach my $col (@{ $o->get_usersel_cols }) {
19 my $val = $o->get_html_val($col);
20 my $type = $$typeMap{$col} || 'char';
21 $tbody .= "<td".(($type ne 'char')?" class=$type":"").">$val</td>";
22 }
23 $tbody .= "</tr>\n";
24 }
25 $o->finish();
26  
27 my $buf = $$o{q}->header(-type=>'text/html',-expires=>'now')."<html><body>";
28  
29 if ($tbody) {
30 $buf .= "<table class=grid><thead><tr>\n";
31  
32 foreach my $colAlias (@{ $o->get_usersel_cols }) {
33 my $colOpts = $$o{schema}{select}{$colAlias}[3];
34 $buf .= "<td data-col='".escapeHTML($colAlias)."'";
35 $buf .= ">".escapeHTML($o->get_nice_name($colAlias))."</td>";
36 }
37 $buf .= "\n</tr></thead><tbody>\n$tbody</tbody></table>";
38 }
39 else {
40 $buf .= "<em>none found</em>";
41 }
42  
43 $buf .= "</body></html>";
44  
45 $$o{output_handler}->($buf);
46 return undef;
47 }
48  
49 1;