SearchPage.pm

filter: Statementstmt 3.8% 38 / 998 Branchbran 0.0% 0 / 484 Conditioncond 0.0% 0 / 182 MC/DCmcdc 0.0% 0 / 103 Subroutinesub 13.6% 12 / 88 Podpod 0.0% 0 / 54 totaltotal 2.6% 50 / 1909 CC 355 SCAR 69.4
CC
355
Cov
2%
_generate_search_form
4160.0
_format_data
1806.0
_generate_sql_statements
1560.0
CRAP 1037.2
↑ Summary SearchPage/Param.pm »
1 package HTML::SearchPage;
2  
3 1 our $VERSION = '0.05';
4  
5 # $Id: SearchPage.pm,v 1.24 2007/09/19 21:30:18 canaran Exp $
6  
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use HTML::SearchPage::Files;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use CGI;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use CGI::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Spreadsheet::WriteExcel;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Tie::IxHash;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Time::Format qw(%time);
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 ###############
23 # CONSTRUCTOR #
24 ###############
25  
26 0 ▶sub new {
Subroutine new: not called CC=33 SCAR=70.2
Pod undocumented
27 0 my ($class, %raw_params) = @_;
28  
29 # Remove dashes from param names
30 my %params = map {
31 0 my $key = $_;
32 0 my $value = $raw_params{$key};
33 0 $key =~ s/^-//;
34 0 $key => $value;
35 } keys %raw_params;
36  
37 0 my $self = bless {}, $class;
38  
39 0 eval {
40  
41 # CGI obj created initially
42 0 my $cgi = CGI->new;
43 0 $self->cgi($cgi);
44  
45 0 my $cgi_params = $self->cgi->Vars;
46 0 $self->cgi_params($cgi_params);
47  
48 # Temp dir
49 0 ▶ $params{temp_dir} or croak("A temp_dir param is required!");
Branch: 1 branch
BranchTrueFalseTotal
$params{"temp_dir"} or croak("A temp_dir param is required!") 0 0 0
50 0 $self->temp_dir($params{temp_dir});
51  
52 0 ▶ $params{temp_dir_eq} or croak("A temp_dir_eq param is required!");
Branch: 1 branch
BranchTrueFalseTotal
$params{"temp_dir_eq"} or croak("A temp_dir_eq param is required!") 0 0 0
53 0 $self->temp_dir_eq($params{temp_dir_eq});
54  
55 # Cookie params
56 my $cookie =
57 0 ▶ defined $params{cookie} ? $params{cookie} : 'html-searchpage';
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'cookie'} ? : 0 0 0
58 0 $self->cookie($cookie);
59  
60 my $cookie_expires_in_min =
61 defined $params{cookie_expires_in_min}
62 ? $params{cookie_expires_in_min}
63 0 ▶ : 30;
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'cookie_expires_in_min'} ? : 0 0 0
64 0 $self->cookie_expires_in_min($cookie_expires_in_min);
65  
66 # Session id from URL/cookie
67 my $session_id =
68 $self->cgi_params->{session_id}
69 0 ▶ || $self->cgi->cookie($self->cookie)
Condition0%0/5
$self->cgi_params->{'session_id'} || $self->cgi->cookie($self->cookie) || undef
l!l
00
$self->cgi_params->{"session_id"} or $self->cgi->cookie($self->cookie)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->cgi_params->{'session_id'} || $self->cgi->cookie($self->cookie) || undef
$self->cgi_params->{"session_id"} $self->cgi->cookie($self->cookie)
Truth table0%0/3
A or B
A= $self->cgi_params->{"session_id"}B= $self->cgi->cookie($self->cookie)
ABresult
1X1
011
000
70 || undef;
71  
72 0 my $session_dir = $self->temp_dir . '/sessions';
73 0 my $session =
74 CGI::Session->new('file', $session_id, {Directory => $session_dir});
75  
76 # Session id may change at this step
77 0 $self->session_id($session->id);
78 0 $self->session($session);
79  
80 # Required params
81 0 ▶ $params{db_access_params} or croak("A db_access_params is required!");
Branch: 1 branch
BranchTrueFalseTotal
$params{"db_access_params"} or croak("A db_access_params is required!") 0 0 0
82 0 $self->db_access_params($params{db_access_params});
83  
84 0 ▶ $params{temp_dir} or croak("A temp_dir param is required!");
Branch: 1 branch
BranchTrueFalseTotal
$params{"temp_dir"} or croak("A temp_dir param is required!") 0 0 0
85 0 $self->temp_dir($params{temp_dir});
86  
87 0 ▶ $params{temp_dir_eq} or croak("A temp_dir_eq param is required!");
Branch: 1 branch
BranchTrueFalseTotal
$params{"temp_dir_eq"} or croak("A temp_dir_eq param is required!") 0 0 0
88 0 $self->temp_dir_eq($params{temp_dir_eq});
89  
90 0 ▶ $params{base_sql_table} or croak("A base_sql_table is required!");
Branch: 1 branch
BranchTrueFalseTotal
$params{"base_sql_table"} or croak("A base_sql_table is required!") 0 0 0
91 0 $self->base_sql_table($params{base_sql_table});
92  
93 0 ▶ $params{base_sql_fields} or croak("A base_sql_fields is required!");
Branch: 1 branch
BranchTrueFalseTotal
$params{"base_sql_fields"} or croak("A base_sql_fields is required!") 0 0 0
94 0 $self->base_sql_fields($params{base_sql_fields});
95  
96 $params{base_output_headers}
97 0 ▶ or croak("A base_output_headers is required!");
Branch: 1 branch
BranchTrueFalseTotal
$params{"base_output_headers"} or croak("A base_output_headers is required!") 0 0 0
98 0 $self->base_output_headers($params{base_output_headers});
99  
100 # Create image files
101 0 HTML::SearchPage::Files->new(temp_dir => $self->temp_dir);
102  
103 # Required param for only display_info
104 0 $self->base_identifier($params{base_identifier});
105  
106 # Optional params
107 my $page_title =
108 0 ▶ defined $params{page_title} ? $params{page_title} : 'Search Page';
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'page_title'} ? : 0 0 0
109 0 $self->page_title($page_title);
110  
111 0 $self->header($params{header});
112  
113 0 $self->footer($params{footer});
114  
115 0 $self->css($params{css});
116  
117 0 $self->instructions($params{instructions});
118  
119 0 $self->distinct($params{distinct});
120  
121 0 $self->no_reset($params{no_reset});
122  
123 0 $self->new_search($params{new_search});
124  
125 0 $self->group_by($params{group_by});
126  
127 0 $self->sort_fields($params{sort_fields});
128  
129 0 $self->sort_defaults($params{sort_defaults});
130  
131 0 ▶ my $method = defined $params{method} ? $params{method} : 'GET';
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'method'} ? : 0 0 0
132 0 $self->method($method);
133 0 ▶ unless ($method eq 'GET' or $method eq 'POST') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($method eq "GET" or $method eq "POST") 0 0 0
Condition0%0/3
$method eq "GET" or $method eq "POST"
l!l&&r!l&&!r
000
MC/DC0%0/2
$method eq "GET" or $method eq "POST"
$method eq "GET" $method eq "POST"
Truth table0%0/3
A or B
A= $method eq "GET"B= $method eq "POST"
ABresult
1X1
011
000
134 0 croak("Invalid method ($method)!");
135 }
136  
137 my $action =
138 0 ▶ defined $params{action} ? $params{action} : $ENV{SCRIPT_NAME};
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'action'} ? : 0 0 0
139 0 $self->action($action);
140  
141 0 ▶ my $page_size = defined $params{page_size} ? $params{page_size} : 50;
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'page_size'} ? : 0 0 0
142 0 $self->page_size($page_size);
143  
144 0 $self->show_search_url($params{show_search_url});
145  
146 0 $self->debug_level($params{debug_level});
147  
148 my $go_to_results =
149 0 ▶ defined $params{go_to_results} ? $params{go_to_results} : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'go_to_results'} ? : 0 0 0
150 0 $self->go_to_results($go_to_results);
151  
152 0 $self->modifier($params{modifier});
153  
154 0 $self->external_where_clauses($params{external_where_clauses});
155  
156 # If reset, empty cgi_params
157 0 ▶ if ($self->cgi_params->{reset}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cgi_params->{"reset"}) 0 0 0
158 0 $self->cgi_params({});
159 }
160  
161 # If new search, redirect
162 0 ▶ if ($self->cgi_params->{new_search}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cgi_params->{"new_search"}) 0 0 0
163 0 my $url = "http://" . $ENV{HTTP_HOST} . $self->new_search;
164 0 print $self->cgi->redirect($url);
165 0 exit 0;
166 }
167  
168 # Calculate super headers
169 0 $self->_calculate_super_headers();
170  
171 # Validate cgi params
172 0 $self->_validate_cgi_params();
173  
174 # Create db_handle from db_access_params
175 0 my $db_access_params = $self->db_access_params;
176  
177 # -- Re-format if a single db is entered
178 0 ▶ if ( ref($db_access_params)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $db_access_params and ref $db_access_params eq "ARRAY") 0 0 0
Condition0%0/3
ref $db_access_params and ref $db_access_params eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $db_access_params and ref $db_access_params eq "ARRAY"
ref $db_access_params ref $db_access_params eq "ARRAY"
Truth table0%0/3
A and B
A= ref $db_access_paramsB= ref $db_access_params eq "ARRAY"
ABresult
0X0
100
111
179 and ref($db_access_params) eq 'ARRAY') {
180 0 my ($datasource, $username, $password) = @$db_access_params;
181 0 my $db_access_params = {
182 database => [
183 { alias => 'default',
184 display => 'Default Database',
185 datasource => $datasource,
186 username => $username,
187 password => $password,
188 }
189 ]
190 };
191 }
192 0 $self->db_access_params($db_access_params);
193  
194 # -- Extract params
195 my $database =
196 $self->cgi_params->{database}
197 0 ▶ || $self->session->param('db_selected');
Condition0%0/3
$self->cgi_params->{'database'} || $self->session->param('db_selected')
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->cgi_params->{'database'} || $self->session->param('db_selected')
$self->cgi_params->{'database'} $self->session->param('db_selected')
Truth table0%0/3
A || B
A= $self->cgi_params->{'database'}B= $self->session->param('db_selected')
ABresult
1X1
011
000
198
199 my @available_databases = ( ref $db_access_params->{database}
200 && ref $db_access_params->{database} eq 'ARRAY')
201 0 ? @{$db_access_params->{database}}
202 0 ▶ : ($db_access_params->{database});
Branch: 1 branch
BranchTrueFalseTotal
ref $db_access_params->{'database'} && ref $db_access_params->{'database'} eq 'ARRAY' ? : 0 0 0
Condition0%0/3
ref $db_access_params->{"database"} and ref $db_access_params->{"database"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $db_access_params->{"database"} and ref $db_access_params->{"database"} eq "ARRAY"
ref $db_access_params->{"database"} ref $db_access_params->{"database"} eq "ARRAY"
Truth table0%0/3
A and B
A= ref $db_access_params->{"database"}B= ref $db_access_params->{"database"} eq "ARRAY"
ABresult
0X0
100
111
203  
204 0 ▶ unless (@available_databases) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@available_databases) 0 0 0
205 0 croak("No database specified!");
206 }
207  
208 0 ▶ if (!$database) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($database) 0 0 0
209 0 $database = $available_databases[0]->{alias};
210 }
211  
212 my $selected_db =
213 0 ▶ first { $_->{alias} eq $database } @available_databases;
Subroutine __ANON__: not called CC=1 SCAR=6.9
214  
215 0 ▶ if (!defined($selected_db)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $selected_db) 0 0 0
216 0 croak("Cannot determine database ($database)!");
217 }
218  
219 my $dbh = DBI->connect(
220 $selected_db->{datasource},
221 $selected_db->{username}, $selected_db->{password},
222 0 ▶ {PrintError => 1, RaiseError => 1}
Condition0%0/2
'DBI'->connect($selected_db->{'datasource'}, $selected_db->{'username'}, $selected_db->{'password'}, {'PrintError', 1, 'RaiseError', 1}) || croak('Cannot connect to database!')
l!l
00
MC/DC0%0/1
'DBI'->connect($selected_db->{'datasource'}, $selected_db->{'username'}, $selected_db->{'password'}, {'PrintError', 1, 'RaiseError', 1}) || croak('Cannot connect to database!')
'DBI'->connect($selected_db->{'datasource'}, $selected_db->{'username'}, $selected_db->{'password'}, {'PrintError', 1, 'RaiseError', 1})
Truth table0%0/2
A
A= 'DBI'->connect($selected_db->{'datasource'}, $selected_db->{'username'}, $selected_db->{'password'}, {'PrintError', 1, 'RaiseError', 1})
Aresult
11
00
223 ) || croak("Cannot connect to database!");
224  
225 0 $self->dbh($dbh);
226 0 $self->db_selected($database);
227 0 $self->db_display($selected_db->{display});
228
229 0 $self->session->param('db_selected', $database);
230  
231 # Adjust URL if "go_to_results"
232 0 ▶ if ($self->go_to_results) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->go_to_results) 0 0 0
233 0 my $action = $self->action;
234 0 $self->action("$action#results");
235 }
236  
237 # Create an empty param_fields container
238 0 $self->{param_fields} = {};
239  
240 # Create an empty modifications container
241 0 $self->{modifications} = [];
242 };
243  
244 0 ▶ $self->display_error_page($@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
245  
246 0 return $self;
247 }
248  
249 ##################
250 # PUBLIC METHODS #
251 ##################
252  
253 # Function : Adds/retrieves param_field.
254 # Arguments : $id [$ParamField_object]
255 # Returns : $ParamField_object
256 # Notes : None specified.
257  
258 0 ▶sub param_field {
Subroutine param_field: not called CC=6 SCAR=37.4
Pod undocumented
259 0 my ($self, $id, $value) = @_;
260 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
261 0 ▶ croak(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "HTML::SearchPage::Param" 0 0 0
262 "A HTML::SearchPage::Param object is needed to add param_field!")
263 unless ref $value eq 'HTML::SearchPage::Param';
264  
265 0 my $max = 0;
266  
267 0 foreach (keys %{$self->param_fields}) {
268 0 my $pf = $self->param_fields->{$_};
269 0 ▶ $max = $pf->rank if $pf->rank > $max;
Branch: 1 branch
BranchTrueFalseTotal
if $pf->rank > $max 0 0 0
270 }
271  
272 0 $value->rank(++$max);
273  
274 0 $self->param_fields->{$id} = $value;
275 }
276  
277 croak("This param_field ($id) does not exist!")
278 0 ▶ unless exists $self->param_fields->{$id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->param_fields->{$id} 0 0 0
279  
280 0 return $self->param_fields->{$id};
281 }
282  
283 # Function : Adds modification.
284 # Arguments : $hashref
285 # Returns : 1
286 # Notes : None specified.
287  
288 0 ▶sub add_modification {
Subroutine add_modification: not called CC=2 SCAR=17.9
Pod undocumented
289 0 my ($self, %value) = @_;
290  
291 0 ▶ croak("A modification hashref is needed!") unless %value;
Branch: 1 branch
BranchTrueFalseTotal
unless %value 0 0 0
292  
293 0 push @{$self->modifications}, \%value;
294  
295 0 return 1;
296 }
297  
298 # Function : Performs the necessary operations and
299 # displays a complete search page.
300 # Arguments : None
301 # Returns : 1
302 # Notes : None specified.
303  
304 0 ▶sub display_page {
Subroutine display_page: not called CC=13 SCAR=52.0
Pod undocumented
305 0 my ($self) = @_;
306  
307 0 my $submit = $self->cgi_params->{'submit'};
308  
309 0 eval {
310 0 ▶ $self->_generate_search_form unless $self->search_form;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->search_form 0 0 0
311 0 ▶ $self->_generate_sql_statements
Branch: 1 branch
BranchTrueFalseTotal
if $submit and not $self->query_sql_statement 0 0 0
Condition0%0/3
$submit and not $self->query_sql_statement
!ll&&!rl&&r
000
MC/DC0%0/2
$submit and not $self->query_sql_statement
$submit not $self->query_sql_statement
Truth table0%0/3
A and not(B)
A= $submitB= not $self->query_sql_statement
ABresult
0X0
100
111
312 if ($submit and !$self->query_sql_statement);
313 0 ▶ $self->_get_debug_info if $self->debug_level;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug_level 0 0 0
314 0 ▶ $self->_retrieve_data if ($submit and !$self->data);
Branch: 1 branch
BranchTrueFalseTotal
if $submit and not $self->data 0 0 0
Condition0%0/3
$submit and not $self->data
!ll&&!rl&&r
000
MC/DC0%0/2
$submit and not $self->data
$submit not $self->data
Truth table0%0/3
A and not(B)
A= $submitB= not $self->data
ABresult
0X0
100
111
315 0 ▶ $self->_retrieve_count if ($submit and !(defined $self->count));
Branch: 1 branch
BranchTrueFalseTotal
if $submit and not defined $self->count 0 0 0
Condition0%0/3
$submit and not defined $self->count
!ll&&!rl&&r
000
MC/DC0%0/2
$submit and not defined $self->count
$submit not defined $self->count
Truth table0%0/3
A and not(B)
A= $submitB= not defined $self->count
ABresult
0X0
100
111
316 0 ▶ $self->_format_data if ($submit and !$self->formatted_data);
Branch: 1 branch
BranchTrueFalseTotal
if $submit and not $self->formatted_data 0 0 0
Condition0%0/3
$submit and not $self->formatted_data
!ll&&!rl&&r
000
MC/DC0%0/2
$submit and not $self->formatted_data
$submit not $self->formatted_data
Truth table0%0/3
A and not(B)
A= $submitB= not $self->formatted_data
ABresult
0X0
100
111
317 };
318  
319 0 ▶ $self->display_error_page($@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
320  
321 0 eval { $self->_print_page; };
322  
323 0 ▶ $self->display_error_page($@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
324  
325 0 return 1;
326 }
327  
328 # Function : Generates an error page.
329 # Arguments : $error
330 # Returns : - exists with 0 -
331 # Notes : None specified.
332  
333 0 ▶sub display_error_page {
Subroutine display_error_page: not called CC=2 SCAR=17.9
Pod undocumented
334 0 my ($self, $error) = @_;
335  
336 0 my $cookie = $self->cookie;
337 0 my $session_id = $self->session_id;
338 0 my $cookie_expires_in_min = $self->cookie_expires_in_min;
339  
340 0 my $cookie_obj = CGI::cookie(
341 -name => $cookie,
342 -value => $session_id,
343 -expires => "+${cookie_expires_in_min}m",
344 );
345  
346 0 print $self->cgi->header(-cookie => $cookie_obj);
347  
348 0 my $header = $self->_content($self->header);
349 0 my $css = $self->_content($self->css);
350 0 ▶ my $page_title =
Branch: 1 branch
BranchTrueFalseTotal
$self->page_title ? : 0 0 0
351 $self->page_title ? 'Error: ' . $self->page_title : 'Error Page';
352 0 my $instructions = $self->_content($self->instructions);
353 0 my $debug_info = $self->debug_info;
354 0 my $footer = $self->_content($self->footer);
355 0 my $temp_dir_eq = $self->temp_dir_eq;
356  
357 0 print <<HTML;
358 <html>
359 <head>
360 <title>$page_title</title>
361 <link rel="stylesheet" type="text/css" href="$temp_dir_eq/searchpage-main.css" />
362 $css
363 </head>
364  
365 <body>
366 <table border="0" width="100%">
367 <tr><td colspan="2">$header</td></tr>
368 <tr><td colspan="2"><h1>$page_title</h1></td></tr>
369 <tr><td width="60%"><b>An error occured: $error</b></td><td width="40%">&nbsp;</td></tr>
370 <tr><td colspan="2">&nbsp;</td></tr>
371 <tr><td colspan="2" align="center">$debug_info</td></tr>
372 <tr><td colspan="2">$footer</td></tr>
373 </table>
374 </body>
375 </html>
376 HTML
377  
378 0 exit 0;
379 }
380  
381 # Function : Performs the necessary operations and displays a complete info page.
382 # Arguments : None
383 # Returns : 1
384 # Notes : None specified.
385  
386 0 ▶sub display_info {
Subroutine display_info: not called CC=13 SCAR=52.0
Pod undocumented
387 0 my ($self) = @_;
388  
389 # This display is *not* interactive, no search form is provided
390 # "submit" is assumed, no need to check for it
391  
392 # We must have an identifier provided
393 0 my $identifier = $self->cgi_params->{'identifier'};
394 0 ▶ $self->display_error_page('A valid identifier is required!')
Branch: 1 branch
BranchTrueFalseTotal
unless defined $identifier 0 0 0
395 unless defined $identifier;
396  
397 # Automatically set parameter field
398 0 my $base_identifier = $self->base_identifier;
399 0 ▶ $self->display_error_page('A base_identifier is not specified!')
Branch: 1 branch
BranchTrueFalseTotal
unless defined $base_identifier 0 0 0
400 unless defined $base_identifier;
401 0 ▶ my $pf = HTML::SearchPage::Param->new(
Branch: 1 branch
BranchTrueFalseTotal
my $pf = "HTML::SearchPage::Param"->new("-sql_column", $base_identifier, "-form_name", "identifier", "-param_type", "text:12") or $self->display_error_page($@) 0 0 0
402 -sql_column => $base_identifier,
403 -form_name => 'identifier',
404 -param_type => 'text:12', # place-holder
405 ) or $self->display_error_page($@);
406 0 $self->param_field('identifier', $pf);
407  
408 # We set the "identifier_operator" to "equals" by default
409 0 $self->cgi_params->{'identifier_operator'} = '=';
410  
411 # We set the "output_format" to "html" by default
412 0 $self->cgi_params->{'output_format'} = 'html';
413  
414 0 eval {
415  
416 # -> do not generate search form
417 0 ▶ $self->_generate_sql_statements if !$self->query_sql_statement;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->query_sql_statement 0 0 0
418 0 ▶ $self->_get_debug_info if $self->debug_level;
Branch: 1 branch
BranchTrueFalseTotal
if $self->debug_level 0 0 0
419 0 ▶ $self->_retrieve_data if !$self->data;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->data 0 0 0
420 0 ▶ $self->_retrieve_count if !(defined $self->count);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->count 0 0 0
421  
422 # We have to retrieve one and only one record
423 0 ▶ if ($self->count == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->count == 0) 0 0 0
424 0 $self->display_error_page(
425 "Cannot find identifier ($identifier)!");
426 }
427 0 ▶ if ($self->count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->count > 1) 0 0 0
428 0 $self->display_error_page(
429 "Multiple records found for identifier ($identifier)!");
430 }
431  
432 #Use different method to format data
433 0 ▶ $self->_format_vertical_data if !$self->formatted_data;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->formatted_data 0 0 0
434 };
435  
436 0 ▶ $self->display_error_page($@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
437  
438 0 eval { $self->_print_page; };
439  
440 0 ▶ $self->display_error_page($@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
441  
442 0 return 1;
443 }
444  
445 # Function : Retrieves values for a distinct statement.
446 # Arguments : $statement
447 # Returns : @columns
448 # Notes : None specified.
449  
450 0 ▶sub run_distinct_statement {
Subroutine run_distinct_statement: not called CC=5 SCAR=34.0
Pod undocumented
451 0 my ($self, $statement) = @_;
452  
453 0 my $dbh = $self->dbh;
454  
455 0 ▶ my $sth = $dbh->prepare($statement) or croak($dbh->errstr);
Branch: 1 branch
BranchTrueFalseTotal
my $sth = $dbh->prepare($statement) or croak($dbh->errstr) 0 0 0
456 0 ▶ $sth->execute or croak($dbh->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute or croak($dbh->errstr) 0 0 0
457  
458 0 my @columns;
459 0 ▶ while (my ($value) = $sth->fetchrow_array) { push @columns, $value; }
Branch: 1 branch
BranchTrueFalseTotal
if (my($value) = $sth->fetchrow_array) 0 0 0
460  
461 0 ▶ $sth->finish or croak($dbh->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$sth->finish or croak($dbh->errstr) 0 0 0
462  
463 0 return @columns;
464 }
465  
466 # Function : URL-encodes a given string.
467 # Arguments : $string
468 # Returns : $url_encoded_string
469 # Notes : This is a private method.
470  
471 0 ▶sub url_encode {
Subroutine url_encode: not called CC=1 SCAR=6.9
Pod undocumented
472 0 my ($self, $string) = @_;
473  
474 0 $string =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
475  
476 0 return $string;
477 }
478  
479 # Function : URL-decodes a given string.
480 # Arguments : $string
481 # Returns : $url_decoded_string
482 # Notes : This is a private method.
483  
484 0 ▶sub url_decode {
Subroutine url_decode: not called CC=2 SCAR=17.9
Pod undocumented
485 0 my ($self, $string) = @_;
486  
487 0 ▶ $string =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg if $string;
Branch: 1 branch
BranchTrueFalseTotal
if $string 0 0 0
488  
489 0 return $string;
490 }
491  
492 ###########################
493 # PRIVATE/UTILITY METHODS #
494 ###########################
495  
496 # Function : Parse base_output_headers for super headers,
497 # store in base_super_headers as an array.
498 # Arguments : None
499 # Returns : 1
500 # Notes : This is a private method.
501  
502 0 ▶sub _calculate_super_headers {
Subroutine _calculate_super_headers: not called CC=5 SCAR=34.0
503 0 my ($self) = @_;
504  
505 0 my $headers = $self->base_output_headers;
506  
507 0 my %super_headers;
508  
509 0 my $current_group = 0;
510 0 my $current_super_header = qq[];
511  
512 0 foreach my $pos (0 .. $#{@$headers}) {
513 0 my $super_header = qq[];
514 0 ▶ $super_header = $1 if $headers->[$pos] =~ s/^([^~]*)~//;
Branch: 1 branch
BranchTrueFalseTotal
if $headers->[$pos] =~ s/^([^~]*)~// 0 0 0
515  
516 0 ▶ if ($super_header && $super_header eq $current_super_header) {
Branch: 1 branch
BranchTrueFalseTotal
if ($super_header and $super_header eq $current_super_header) { } 0 0 0
Condition0%0/3
$super_header and $super_header eq $current_super_header
!ll&&!rl&&r
000
MC/DC0%0/2
$super_header and $super_header eq $current_super_header
$super_header $super_header eq $current_super_header
Truth table0%0/3
A and B
A= $super_headerB= $super_header eq $current_super_header
ABresult
0X0
100
111
517 0 push @{$super_headers{$current_group}{headers}}, $headers->[$pos];
518 0 $super_headers{$current_group}{colspan}++;
519 }
520  
521 else {
522 0 $current_group++;
523 0 $current_super_header = $super_header;
524  
525 0 $super_headers{$current_group}{super_header} = $super_header;
526 0 push @{$super_headers{$current_group}{headers}}, $headers->[$pos];
527 0 $super_headers{$current_group}{colspan}++;
528 }
529 }
530  
531 0 $self->super_output_headers(\%super_headers);
532  
533 0 return 1;
534 }
535  
536 # Function : Validates CGI params. Checks the CGI parameters
537 # passed on as a hashref and croaks
538 # if an error is found.
539 # Arguments : \%cgi
540 # Returns : 1
541 # Notes : This is a private method.
542  
543 0 ▶sub _validate_cgi_params {
Subroutine _validate_cgi_params: not called CC=17 SCAR=57.2
544 0 my ($self) = @_;
545  
546 0 my $cgi_params = $self->cgi_params;
547  
548 0 my %validated_cgi_params = %{$cgi_params};
549  
550 0 my @fields = @{$self->base_output_headers};
551  
552 0 my %allowed_order_by_fields;
553 0 foreach my $field (@fields) {
554 0 my ($column_name, $order_by_field) = split(':', $field);
555 0 ▶ if ($order_by_field) {
Branch: 1 branch
BranchTrueFalseTotal
if ($order_by_field) 0 0 0
556 0 $allowed_order_by_fields{$self->url_decode($order_by_field)} = 1;
557 }
558 }
559  
560 0 $allowed_order_by_fields{asc} = 1;
561 0 $allowed_order_by_fields{desc} = 1;
562 0 $allowed_order_by_fields{not_selected} = 1;
563  
564 0 my %allowed_operators = (
565 '=' => 1,
566 'like_m' => 1,
567 'like_c' => 1,
568 '>' => 1,
569 '>=' => 1,
570 '<' => 1,
571 '<=' => 1,
572 '<>' => 1,
573 'not_like_m' => 1,
574 'not_like_c' => 1,
575 );
576  
577 0 my %allowed_output_formats = (
578 'html' => 1,
579 'csv' => 1,
580 'tab' => 1,
581 'text' => 1,
582 'excel' => 1,
583 );
584  
585 0 foreach my $key (keys %$cgi_params) {
586 0 ▶ unless ($cgi_params->{$key} or $cgi_params->{$key} eq '0') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cgi_params->{$key} or $cgi_params->{$key} eq 0) 0 0 0
Condition0%0/3
$cgi_params->{$key} or $cgi_params->{$key} eq 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$cgi_params->{$key} or $cgi_params->{$key} eq 0
$cgi_params->{$key} $cgi_params->{$key} eq 0
Truth table0%0/3
A or B
A= $cgi_params->{$key}B= $cgi_params->{$key} eq 0
ABresult
1X1
011
000
587 0 $cgi_params->{$key} = undef;
588 0 next;
589 }
590  
591 0 my @value = split("\0", $cgi_params->{$key});
592  
593 0 foreach (@value) {
594 0 $_ =~ s/^\s+//;
595 0 $_ =~ s/\s+$//;
596  
597 # Check all values against this
598 0 ▶ if ($_ =~ /[^A-Za-z0-9\-\_\?\*\.\%\(\)\,\'\+\=\:\# ]/
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /[^A-Za-z0-9\-\_\?\*\.\%\(\)\,\'\+\=\:\# ]/ and not $allowed_operators{$_}) 0 0 0
Condition0%0/3
$_ =~ /[^A-Za-z0-9\-\_\?\*\.\%\(\)\,\'\+\=\:\# ]/ and not $allowed_operators{$_}
!ll&&!rl&&r
000
MC/DC0%0/2
$_ =~ /[^A-Za-z0-9\-\_\?\*\.\%\(\)\,\'\+\=\:\# ]/ and not $allowed_operators{$_}
$_ =~ /[^A-Za-z0-9\-\_\?\*\.\%\(\)\,\'\+\=\:\# ]/ not $allowed_operators{$_}
Truth table0%0/3
A and not(B)
A= $_ =~ /[^A-Za-z0-9\-\_\?\*\.\%\(\)\,\'\+\=\:\# ]/B= not $allowed_operators{$_}
ABresult
0X0
100
111
599 and !$allowed_operators{$_}) {
600 0 croak("Illegal character in value ($key:$_)!");
601 }
602  
603 # Check individual values
604 0 ▶ if ($key =~ /_operator$/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($key =~ /_operator$/) { } 0 0 0
elsif ($key eq 'order_by') { } 0 0 0
elsif ($key eq 'output_format') { } 0 0 0
605 croak("Illegal operator ($key:$_)!")
606 0 ▶ unless $allowed_operators{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $allowed_operators{$_} 0 0 0
607 }
608  
609 elsif ($key eq 'order_by') {
610 0 my $lc_cgi_value = lc $_;
611 croak("Invalid order by column ($key:$_)!")
612 unless ($allowed_order_by_fields{$_}
613 0 ▶ or $allowed_order_by_fields{$lc_cgi_value});
Branch: 1 branch
BranchTrueFalseTotal
unless $allowed_order_by_fields{$_} or $allowed_order_by_fields{$lc_cgi_value} 0 0 0
Condition0%0/3
$allowed_order_by_fields{$_} or $allowed_order_by_fields{$lc_cgi_value}
l!l&&r!l&&!r
000
MC/DC0%0/2
$allowed_order_by_fields{$_} or $allowed_order_by_fields{$lc_cgi_value}
$allowed_order_by_fields{$_} $allowed_order_by_fields{$lc_cgi_value}
Truth table0%0/3
A or B
A= $allowed_order_by_fields{$_}B= $allowed_order_by_fields{$lc_cgi_value}
ABresult
1X1
011
000
614 }
615  
616 elsif ($key eq 'output_format') {
617 croak("Invalid output format($key:$_)!")
618 0 ▶ unless $allowed_output_formats{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $allowed_output_formats{$_} 0 0 0
619 }
620 }
621 0 ▶ $validated_cgi_params{$key} = @value > 1 ? \@value : $value[0];
Branch: 1 branch
BranchTrueFalseTotal
@value > 1 ? : 0 0 0
622  
623 # (Array memory location stringified if passed to $cgi_params)
624 }
625  
626 0 $self->cgi_params(\%validated_cgi_params);
627  
628 0 return 1;
629 }
630  
631 # Function : Generates and stores the HTML code for the
632 # search form component.
633 # Arguments : None
634 # Returns : 1
635 # Notes : This is a private method.
636  
637 0 ▶sub _generate_search_form {
Subroutine _generate_search_form: not called CC=64 SCAR=83.3
638 0 my ($self) = @_;
639  
640 # Assign form information
641 0 my $dbh = $self->dbh;
642 0 my $action = $self->action;
643 0 my $method = $self->method;
644 0 my $cgi = $self->cgi_params;
645  
646 0 my $database = $self->cgi_params->{database};
647  
648 0 my @order_by = @{$self->cgi_params->{order_by}}
649 0 ▶ if $self->cgi_params->{order_by};
Branch: 1 branch
BranchTrueFalseTotal
if $self->cgi_params->{"order_by"} 0 0 0
650 0 my $sort_fields = $self->sort_fields;
651 0 ▶ my @sort_defaults = @{$self->sort_defaults} if $self->sort_defaults;
Branch: 1 branch
BranchTrueFalseTotal
if $self->sort_defaults 0 0 0
652 0 my @base_output_headers = @{$self->base_output_headers};
653  
654 0 ▶ my $reset_button =
Branch: 2 branches
BranchTrueFalseTotal
$self->new_search ? : 0 0 0
!$self->no_reset ? : 0 0 0
655 $self->new_search
656 ? qq[&nbsp; <input type="submit" name="new_search" value="New Search"></input>]
657 : !$self->no_reset
658 ? qq[&nbsp; <input type="submit" name="reset" value="Reset"></input>]
659 : qq[];
660 0 my $db_selector = $self->_make_db_selector;
661  
662 0 my @field_sections;
663  
664 0 foreach my $id (
665 0 sort { $self->param_field($a)->rank <=> $self->param_field($b)->rank }
666 0 keys %{$self->param_fields}
667 ) {
668 0 my $pf = $self->param_field($id);
669  
670 0 my $field_section;
671  
672 # Assign field information
673 0 my $label = $pf->label;
674 0 my $sql_column = $pf->sql_column;
675 0 my $form_name = $pf->form_name;
676 0 ▶ my @operator_list = @{$pf->operator_list} if $pf->operator_list;
Branch: 1 branch
BranchTrueFalseTotal
if $pf->operator_list 0 0 0
677 0 my $operator_display = $pf->operator_display;
678 0 my $disabled = $pf->disabled;
679 0 ▶ my $operator_default = $pf->operator_default || qq[];
Condition0%0/2
$pf->operator_default || ''
l!l
00
MC/DC0%0/1
$pf->operator_default || ''
$pf->operator_default
Truth table0%0/2
A
A= $pf->operator_default
Aresult
11
00
680 0 my $case_sensitive = $pf->case_sensitive;
681 0 my $exact = $pf->exact;
682 0 my $numerical = $pf->numerical;
683 0 my $param_type = $pf->param_type;
684 0 ▶ my @param_list = @{$pf->param_list} if $pf->param_list;
Branch: 1 branch
BranchTrueFalseTotal
if $pf->param_list 0 0 0
685 0 my $auto_all = $pf->auto_all;
686 0 my $auto_null = $pf->auto_null;
687 0 ▶ my $param_default = $pf->param_default || qq[];
Condition0%0/2
$pf->param_default || ''
l!l
00
MC/DC0%0/1
$pf->param_default || ''
$pf->param_default
Truth table0%0/2
A
A= $pf->param_default
Aresult
11
00
688  
689 # my %param_default;
690 # foreach (@param_default) {
691 # $param_default{$_} = 1 if $_;
692 # }
693  
694 # Adjustments
695  
696 # (i) Resolve DISTINCT statements in param_list
697 0 my @resolved_param_list;
698 0 foreach my $param_statement (@param_list) {
699 0 ▶ if ($param_statement && $param_statement =~ s/^DISTINCT://) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param_statement and $param_statement =~ s/^DISTINCT://) { } 0 0 0
Condition0%0/3
$param_statement and $param_statement =~ s/^DISTINCT://
!ll&&!rl&&r
000
MC/DC0%0/2
$param_statement and $param_statement =~ s/^DISTINCT://
$param_statement $param_statement =~ s/^DISTINCT://
Truth table0%0/3
A and B
A= $param_statementB= $param_statement =~ s/^DISTINCT://
ABresult
0X0
100
111
700 0 my @resolved_params =
701 $self->run_distinct_statement($param_statement);
702 0 foreach (@resolved_params) {
703 0 ▶ next if !defined $_;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 0 0
704 0 $_ = $self->url_encode($_);
705 0 push(@resolved_param_list, $_);
706 }
707 }
708 0 else { push(@resolved_param_list, $param_statement); }
709 }
710 0 @param_list = @resolved_param_list;
711 0 $pf->param_list(\@param_list);
712  
713 # (ii) Append AUTO NULL AND ALL to param list
714 0 ▶ unshift @param_list, 'null:NULL' if $auto_null;
Branch: 1 branch
BranchTrueFalseTotal
if $auto_null 0 0 0
715 0 ▶ unshift @param_list, 'all:ALL' if $auto_all;
Branch: 1 branch
BranchTrueFalseTotal
if $auto_all 0 0 0
716  
717 # Make sure param_list is populated
718 0 ▶ if ( $param_type eq 'drop_down'
Branch: 1 branch
BranchTrueFalseTotal
if ($param_type eq "drop_down" or $param_type =~ /^scrolling_list:\d+$/) 0 0 0
Condition0%0/3
$param_type eq "drop_down" or $param_type =~ /^scrolling_list:\d+$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$param_type eq "drop_down" or $param_type =~ /^scrolling_list:\d+$/
$param_type eq "drop_down" $param_type =~ /^scrolling_list:\d+$/
Truth table0%0/3
A or B
A= $param_type eq "drop_down"B= $param_type =~ /^scrolling_list:\d+$/
ABresult
1X1
011
000
719 or $param_type =~ /^scrolling_list:\d+$/) {
720 0 ▶ croak("Parameter field ($label) has empty param_list!")
Branch: 1 branch
BranchTrueFalseTotal
unless @param_list 0 0 0
721 unless @param_list;
722 }
723
724 # (iii) Auto-complete display names for param_list
725 0 foreach (@operator_list, @param_list) {
726 0 ▶ $_ = "$1:$1" if ($_ && $_ =~ /^([^:]+)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $_ and $_ =~ /^([^:]+)$/ 0 0 0
Condition0%0/3
$_ and $_ =~ /^([^:]+)$/
!ll&&!rl&&r
000
MC/DC0%0/2
$_ and $_ =~ /^([^:]+)$/
$_ $_ =~ /^([^:]+)$/
Truth table0%0/3
A and B
A= $_B= $_ =~ /^([^:]+)$/
ABresult
0X0
100
111
727 }
728  
729 # Prepare operator section
730 0 my $operator_section;
731  
732 0 ▶ if (@operator_list > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@operator_list > 1) { } 0 0 0
elsif (@operator_list == 1) { } 0 0 0
733 0 $operator_section .= qq[<select name="${form_name}_operator">\n];
734 0 foreach (@operator_list) {
735 0 my ($operator, $display) = split(':', $_);
736 0 ▶ $operator = $self->url_decode($operator) || qq[];
Condition0%0/2
$self->url_decode($operator) || ''
l!l
00
MC/DC0%0/1
$self->url_decode($operator) || ''
$self->url_decode($operator)
Truth table0%0/2
A
A= $self->url_decode($operator)
Aresult
11
00
737 0 ▶ $display = $self->url_decode($display) || qq[];
Condition0%0/2
$self->url_decode($display) || ''
l!l
00
MC/DC0%0/1
$self->url_decode($display) || ''
$self->url_decode($display)
Truth table0%0/2
A
A= $self->url_decode($display)
Aresult
11
00
738  
739 0 my $selected = qq[];
740 0 ▶ if ( defined $cgi->{$form_name}
Branch: 2 branches
BranchTrueFalseTotal
if (defined $cgi->{$form_name} and defined $$cgi{"${form_name}_operator"} and $$cgi{"${form_name}_operator"} eq $operator) { } 0 0 0
elsif ($operator eq $operator_default and not defined $cgi->{$form_name}) { } 0 0 0
Condition0%0/6
defined $cgi->{$form_name} and defined $$cgi{"${form_name}_operator"} and $$cgi{"${form_name}_operator"} eq $operator
!ll&&!rl&&r
000
defined $cgi->{$form_name} and defined $$cgi{"${form_name}_operator"}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $cgi->{$form_name} and defined $$cgi{"${form_name}_operator"} and $$cgi{"${form_name}_operator"} eq $operator
defined $cgi->{$form_name} defined $$cgi{"${form_name}_operator"} $$cgi{"${form_name}_operator"} eq $operator
Truth table0%0/4
A and B and C
A= defined $cgi->{$form_name}B= defined $$cgi{"${form_name}_operator"}C= $$cgi{"${form_name}_operator"} eq $operator
ABCresult
0XX0
10X0
1100
1111
741 && defined $cgi->{"${form_name}_operator"}
742 && $cgi->{"${form_name}_operator"} eq $operator) {
743 0 $selected = 'selected';
744 }
745 ▶ elsif ($operator eq $operator_default
Condition0%0/3
$operator eq $operator_default and not defined $cgi->{$form_name}
!ll&&!rl&&r
000
MC/DC0%0/2
$operator eq $operator_default and not defined $cgi->{$form_name}
$operator eq $operator_default not defined $cgi->{$form_name}
Truth table0%0/3
A and not(B)
A= $operator eq $operator_defaultB= not defined $cgi->{$form_name}
ABresult
0X0
100
111
746 && !defined $cgi->{$form_name}) {
747 0 $selected = 'selected';
748 }
749  
750 $operator_section .=
751 0 qq[<option $selected value="$operator">$display</option>\n];
752 }
753 0 $operator_section .= qq[</select>\n];
754 }
755  
756 elsif (@operator_list == 1) {
757 0 my ($operator, $display) = split(':', $operator_list[0]);
758 0 $operator = $self->url_decode($operator);
759 0 $display = $self->url_decode($display);
760  
761 0 ▶ my ($field_type, $disabled) =
Branch: 1 branch
BranchTrueFalseTotal
$operator_display ? : 0 0 0
762 $operator_display ? ('text', 'disabled') : ('hidden', qq[]);
763 0 $operator_section .=
764 qq[<input type="$field_type" name="${form_name}_operator" value="$operator" $disabled>&nbsp;</input>\n];
765 }
766  
767 0 else { croak("No opearator specified (form field: $form_name)!"); }
768  
769 # Prepare param section
770 0 my $param_section;
771  
772 0 ▶ if ( $param_type eq 'drop_down'
Branch: 2 branches
BranchTrueFalseTotal
if ($param_type eq 'drop_down' or $param_type =~ /^scrolling_list:\d+$/) { } 0 0 0
elsif ($param_type =~ /^text:(\d+)$/) { } 0 0 0
Condition0%0/3
$param_type eq "drop_down" or $param_type =~ /^scrolling_list:\d+$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$param_type eq "drop_down" or $param_type =~ /^scrolling_list:\d+$/
$param_type eq "drop_down" $param_type =~ /^scrolling_list:\d+$/
Truth table0%0/3
A or B
A= $param_type eq "drop_down"B= $param_type =~ /^scrolling_list:\d+$/
ABresult
1X1
011
000
773 or $param_type =~ /^scrolling_list:\d+$/) {
774 0 ▶ if ($param_type eq 'drop_down') {
Branch: 2 branches
BranchTrueFalseTotal
if ($param_type eq 'drop_down') { } 0 0 0
elsif ($param_type =~ /^scrolling_list:(\d+)$/) { } 0 0 0
775 0 $param_section .= qq[<select name="$form_name">\n];
776 }
777 elsif ($param_type =~ /^scrolling_list:(\d+)$/) {
778 0 $param_section .=
779 qq[<select name="$form_name" size="$1" multiple>\n];
780 }
781  
782 0 my @values;
783 0 ▶ if (defined $cgi->{$form_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cgi->{$form_name}) 0 0 0
784 @values =
785 ref $cgi->{$form_name}
786 0 ? @{$cgi->{$form_name}}
787 0 ▶ : ($cgi->{$form_name});
Branch: 1 branch
BranchTrueFalseTotal
ref $cgi->{$form_name} ? : 0 0 0
788 }
789 0 my %values = map { ($_, 1) } @values;
790  
791 0 foreach (@param_list) {
792 0 my ($param, $display) = split(':', $_);
793 0 $param = $self->url_decode($param);
794 0 $display = $self->url_decode($display);
795  
796 0 my $selected = ' ';
797 0 ▶ if (@values and $values{$param}) { $selected = 'selected'; }
Branch: 2 branches
BranchTrueFalseTotal
if (@values and $values{$param}) { } 0 0 0
elsif (not @values and $param_default eq $param) { } 0 0 0
Condition0%0/3
@values and $values{$param}
!ll&&!rl&&r
000
MC/DC0%0/2
@values and $values{$param}
@values $values{$param}
Truth table0%0/3
A and B
A= @valuesB= $values{$param}
ABresult
0X0
100
111
798 ▶ elsif (!@values and $param_default eq $param) {
Condition0%0/3
not @values and $param_default eq $param
!ll&&!rl&&r
000
MC/DC0%0/2
not @values and $param_default eq $param
not @values $param_default eq $param
Truth table0%0/3
not(A) and B
A= not @valuesB= $param_default eq $param
ABresult
0X0
100
111
799 0 $selected = 'selected';
800 }
801  
802 $param_section .=
803 0 qq[<option $selected value="$param">$display</option>\n];
804 }
805 0 $param_section .= qq[</select>\n];
806 }
807  
808 elsif ($param_type =~ /^text:(\d+)$/) {
809 0 my $field_size = $1;
810  
811 0 my $value = qq[];
812 0 ▶ if ($cgi->{"${form_name}"} and ($cgi->{"${form_name}"} ne 'all'))
Branch: 2 branches
BranchTrueFalseTotal
if ($$cgi{"$form_name"} and $$cgi{"$form_name"} ne 'all') { } 0 0 0
elsif ($param_default and $param_default ne 'all') { } 0 0 0
Condition0%0/3
$$cgi{"$form_name"} and $$cgi{"$form_name"} ne "all"
!ll&&!rl&&r
000
MC/DC0%0/2
$$cgi{"$form_name"} and $$cgi{"$form_name"} ne "all"
$$cgi{"$form_name"} $$cgi{"$form_name"} ne "all"
Truth table0%0/3
A and B
A= $$cgi{"$form_name"}B= $$cgi{"$form_name"} ne "all"
ABresult
0X0
100
111
813 {
814 0 $value = $cgi->{"${form_name}"};
815 }
816 ▶ elsif ($param_default && $param_default ne 'all') {
Condition0%0/3
$param_default and $param_default ne "all"
!ll&&!rl&&r
000
MC/DC0%0/2
$param_default and $param_default ne "all"
$param_default $param_default ne "all"
Truth table0%0/3
A and B
A= $param_defaultB= $param_default ne "all"
ABresult
0X0
100
111
817 0 $value = $param_default;
818 }
819  
820 0 ▶ my $disable_status = $disabled ? qq[disabled="1"] : qq[];
Branch: 1 branch
BranchTrueFalseTotal
$disabled ? : 0 0 0
821  
822 0 $param_section .=
823 qq[<input type="text" name="$form_name" value="$value" size="$field_size" maxlength="$field_size" $disable_status></input>\n];
824 }
825  
826 else {
827 0 croak(
828 "Invalid param field type designation ($form_name : $param_type)!"
829 );
830 }
831  
832 0 $field_section .=
833 qq[<tr><td align="left" width="50%"><b>$label</b></td><td align="left" width="25%">$operator_section</td><td align="left" width="25%">$param_section</td></tr>\n];
834  
835 0 push @field_sections, $field_section;
836 }
837  
838 0 my @order_by_sections;
839  
840 0 my @sortable_fields = ('-- Select --:not_selected');
841 0 ▶ foreach (@base_output_headers) { push @sortable_fields, $_ if /:/; }
Branch: 1 branch
BranchTrueFalseTotal
if /:/ 0 0 0
842  
843 0 foreach my $i (1 .. $sort_fields) {
844 0 my $label = "Sort by (\#$i):";
845  
846 # Direction
847 0 my $direction = lc(shift @order_by);
848 0 ▶ if ($direction and !($direction =~ /^asc$/ or $direction =~ /^desc$/))
Branch: 1 branch
BranchTrueFalseTotal
if ($direction and not $direction =~ /^asc$/ || $direction =~ /^desc$/) 0 0 0
Condition0%0/6
$direction and not $direction =~ /^asc$/ || $direction =~ /^desc$/
!ll&&!rl&&r
000
$direction =~ /^asc$/ || $direction =~ /^desc$/
l!l&&r!l&&!r
000
MC/DC0%0/3
$direction and not $direction =~ /^asc$/ || $direction =~ /^desc$/
$direction $direction =~ /^asc$/ $direction =~ /^desc$/
Truth table0%0/4
A and not(B || C)
A= $directionB= $direction =~ /^asc$/C= $direction =~ /^desc$/
ABCresult
0XX0
11X0
1010
1001
849 {
850 0 croak("Illegal direction (order_by) param ($direction)!");
851 }
852  
853 0 my $direction_default = lc(shift @sort_defaults);
854 0 ▶ if ($direction_default
Branch: 1 branch
BranchTrueFalseTotal
if ($direction_default and not $direction_default =~ /^asc$/ || $direction_default =~ /^desc$/) 0 0 0
Condition0%0/6
$direction_default and not $direction_default =~ /^asc$/ || $direction_default =~ /^desc$/
!ll&&!rl&&r
000
$direction_default =~ /^asc$/ || $direction_default =~ /^desc$/
l!l&&r!l&&!r
000
MC/DC0%0/3
$direction_default and not $direction_default =~ /^asc$/ || $direction_default =~ /^desc$/
$direction_default $direction_default =~ /^asc$/ $direction_default =~ /^desc$/
Truth table0%0/4
A and not(B || C)
A= $direction_defaultB= $direction_default =~ /^asc$/C= $direction_default =~ /^desc$/
ABCresult
0XX0
11X0
1010
1001
855 and !(
856 $direction_default =~ /^asc$/
857 or $direction_default =~ /^desc$/
858 )
859 ) {
860 0 croak(
861 "Illegal direction (sort_defaults) param ($direction_default)!"
862 );
863 }
864  
865 0 ▶ my $direction_selected =
Branch: 2 branches
BranchTrueFalseTotal
$direction ? : 0 0 0
$direction_default ? : 0 0 0
866 $direction ? $direction
867 : $direction_default ? $direction_default
868 : qq[];
869  
870 0 my $direction_section = $self->_make_select(
871 'order_by', [qw(ascending:asc descending:desc)],
872 $direction_selected
873 );
874  
875 # Field
876 0 my $field = shift @order_by;
877 0 my $field_default = shift @sort_defaults;
878 0 ▶ my $field_selected =
Branch: 2 branches
BranchTrueFalseTotal
$field ? : 0 0 0
$field_default ? : 0 0 0
879 $field ? $field
880 : $field_default ? $field_default
881 : 'not_selected';
882 0 my $field_section =
883 $self->_make_select('order_by', \@sortable_fields, $field_selected);
884  
885 # Order by
886 0 my $order_by_section =
887 qq[<tr><td align="left" width="50%"><b><i>$label</i></b></td><td align="left" width="25%">$direction_section</td><td align="left" width="25%">$field_section</td></tr>\n];
888 0 push @order_by_sections, $order_by_section;
889 }
890  
891 # Render complete HTML form
892 0 my $search_form;
893  
894 0 $search_form .= <<HTML;
895 <form method="$method" action="$action">
896 <table border="0" align="center" width="100%" cellpadding="1" cellspacing="1">
897 HTML
898  
899 0 $search_form .= $db_selector;
900  
901 0 $search_form .= join("\n", @field_sections);
902  
903 0 $search_form .= <<HTML;
904 <tr>
905 <td align="left">&nbsp;</td>
906 <td align="left">&nbsp;</td>
907 <td align="left">&nbsp;</td>
908 </tr>
909 HTML
910  
911 0 $search_form .= join("\n", @order_by_sections);
912  
913 0 $search_form .= <<HTML;
914 <tr>
915 <td align="left"><b><i>Output Format:</i></b></td>
916 <td align="left">&nbsp;</td>
917 <td align="left">
918 <select name="output_format">
919 <option selected value="html">HTML</option>
920 <option value="excel">Excel</option>
921 <option value="text">text (fixed-width)</option>
922 <option value="csv">csv (comma-separated)</option>
923 <option value="tab">tsv (tab-delimited)</option>
924 </select>
925 </td>
926 </tr>
927  
928 <tr>
929 <td align="left">&nbsp;</td>
930 <td align="center" colspan="2">
931 &nbsp;&nbsp;
932 <input type="submit" name="submit" value="Submit"></input>
933 $reset_button
934 </td>
935 </tr>
936  
937 </table>
938 </form>
939  
940 <script type="text/javascript">
941 <!--
942 document.getElementById("javascript_warning").deleteRow(0)
943 -->
944 </script>
945 HTML
946  
947 # Store in the object
948 0 $self->search_form($search_form);
949  
950 0 return 1;
951 }
952  
953 # Function : Returns a select box.
954 # Arguments : $name, \@fields, $selected
955 # Returns : $html
956 # Notes : This is a private method.
957 # Members of @fields are
958 # in the format: "<display>:<value>"
959  
960 0 ▶sub _make_select {
Subroutine _make_select: not called CC=3 SCAR=24.8
961 0 my ($self, $name, $fields_ref, $selected) = @_;
962 0 my @fields_ref = @$fields_ref;
963  
964 0 my $html;
965  
966 0 $html .= qq[<select name="$name">\n];
967  
968 0 foreach (@$fields_ref) {
969 0 my ($display, $field) = split(':', $_);
970 0 ▶ my $selected_switch = $field eq $selected ? 'selected' : qq[];
Branch: 1 branch
BranchTrueFalseTotal
$field eq $selected ? : 0 0 0
971 0 $html .=
972 qq[<option $selected_switch value="$field">$display</option>\n];
973 }
974  
975 0 $html .= qq[</select>\n];
976  
977 0 return $html;
978 }
979  
980 # Function : Returns a db selection box.
981 # Arguments :
982 # Returns : $html
983 # Notes : This is a private method.
984  
985 0 ▶sub _make_db_selector {
Subroutine _make_db_selector: not called CC=6 SCAR=37.4
986 0 my ($self) = @_;
987  
988 0 my $db_access_params = $self->db_access_params;
989 0 my $database = $self->db_selected;
990  
991 my @available_databases =
992 ( ref($db_access_params->{database})
993 and ref($db_access_params->{database}) eq 'ARRAY')
994 0 ? @{$db_access_params->{database}}
995 0 ▶ : ($db_access_params->{database});
Branch: 1 branch
BranchTrueFalseTotal
ref $db_access_params->{'database'} && ref $db_access_params->{'database'} eq 'ARRAY' ? : 0 0 0
Condition0%0/3
ref $db_access_params->{"database"} and ref $db_access_params->{"database"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $db_access_params->{"database"} and ref $db_access_params->{"database"} eq "ARRAY"
ref $db_access_params->{"database"} ref $db_access_params->{"database"} eq "ARRAY"
Truth table0%0/3
A and B
A= ref $db_access_params->{"database"}B= ref $db_access_params->{"database"} eq "ARRAY"
ABresult
0X0
100
111
996 0 my $html;
997  
998 0 ▶ if (@available_databases > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@available_databases > 1) { } 0 0 0
999 0 my $select;
1000  
1001 0 $select .=
1002 qq[<select id="db_selector" name="database" onchange="select_db()">\n];
1003 0 foreach my $available_database (@available_databases) {
1004 0 my $alias = $available_database->{alias};
1005 0 my $display = $available_database->{display};
1006 0 ▶ my $selected_switch = $alias eq $database ? 'selected' : qq[];
Branch: 1 branch
BranchTrueFalseTotal
$alias eq $database ? : 0 0 0
1007 0 $select .=
1008 qq[<option $selected_switch value="$alias">$display</option>\n];
1009 }
1010 0 $select .= qq[</select>\n];
1011  
1012 0 $html = <<HTML;
1013 <tr>
1014 <td align="left"><b><i>Database:</i></b></td>
1015 <td align="left">&nbsp;</td>
1016 <td align="left">
1017 <script type="text/javascript">
1018 <!--
1019 function select_db()
1020 {
1021 var database=document.getElementById("db_selector").value
1022 var target_url= location.pathname + "?database=" + database
1023 window.location=target_url
1024 }
1025 -->
1026 </script>
1027 $select
1028 </td>
1029 </tr>
1030  
1031 <tr>
1032 <td align="left" colspan="3">
1033  
1034 <table id="javascript_warning" width="100%">
1035 <tr>
1036 <td>
1037 <a style="color:red; font-style:italic">
1038 (Javascript must be enabled for automatic refresh!)</a>
1039 </td>
1040 </tr>
1041 </table>
1042  
1043 </td>
1044 </tr>
1045  
1046 <tr>
1047 <td align="left">&nbsp;</td>
1048 <td align="left">&nbsp;</td>
1049 <td align="left">&nbsp;</td>
1050 </tr>
1051 HTML
1052  
1053 }
1054  
1055 else {
1056 0 $html .=
1057 qq[<input type="hidden" name="database" value="$database"/></input>\n];
1058 }
1059  
1060 0 return $html;
1061 }
1062  
1063 # Function : Generates and stores the relevant SQL statements
1064 # (query and count).
1065 # Arguments : None
1066 # Returns : 1
1067 # Notes : This is a private method.
1068  
1069 0 ▶sub _generate_sql_statements {
Subroutine _generate_sql_statements: not called CC=39 SCAR=73.5
1070 0 my ($self) = @_;
1071  
1072 0 my $base_sql_table = $self->base_sql_table;
1073 0 my $page_size = $self->page_size;
1074  
1075 my $current_page =
1076 $self->cgi_params->{page}
1077 ? $self->cgi_params->{page}
1078 0 ▶ : 1; # Page defaults to 1
Branch: 1 branch
BranchTrueFalseTotal
$self->cgi_params->{'page'} ? : 0 0 0
1079  
1080 0 my $output_format = $self->cgi_params->{output_format};
1081  
1082 0 my $group_by = $self->group_by;
1083  
1084 0 my @fields = @{$self->base_sql_fields};
1085 0 ▶ my $distinct = $self->distinct ? 'distinct' : qq[];
Branch: 1 branch
BranchTrueFalseTotal
$self->distinct ? : 0 0 0
1086 0 my @where_clauses;
1087 my @order_by_clauses
1088 ; # Currently only a single sort column is supported although data is stored in a list
1089 0 my $limit_clause;
1090  
1091 # Assign CGI information and clean values
1092 0 my @order_by = @{$self->cgi_params->{"order_by"}}
1093 0 ▶ if $self->cgi_params->{"order_by"};
Branch: 1 branch
BranchTrueFalseTotal
if $self->cgi_params->{"order_by"} 0 0 0
1094  
1095 0 foreach my $id (sort keys %{$self->param_fields}) {
1096 0 my $pf = $self->param_field($id);
1097  
1098 # Assign field information
1099 0 my $param_type = $pf->param_type;
1100 0 my $sql_column = $pf->sql_column;
1101 0 my $form_name = $pf->form_name;
1102 0 my $case_sensitive = $pf->case_sensitive;
1103 0 my $exact = $pf->exact;
1104 0 my $numerical = $pf->numerical;
1105  
1106 # Skip this ParamField if sql_column is 'INDEPENDENT'
1107 0 ▶ next if $sql_column eq 'INDEPENDENT';
Branch: 1 branch
BranchTrueFalseTotal
if $sql_column eq "INDEPENDENT" 0 0 0
1108  
1109 # Assign CGI information and clean values
1110 0 my $value = $self->cgi_params->{$form_name};
1111 0 my $operator = $self->cgi_params->{"${form_name}_operator"};
1112  
1113 # Add the field to the WHERE <SOMETHING> segment if it is defined, observe additional rules
1114 0 ▶ if (defined $value
Branch: 3 branches
BranchTrueFalseTotal
if (defined $value and ($value || $value eq '0' and $param_type =~ /^scrolling_list:\d+$/)) { } 0 0 0
elsif ($operator eq '<>' || $operator =~ /^not_/ and $value eq 'all') { } 0 0 0
elsif (defined $value and $value || $value eq '0' and $value ne 'all') { } 0 0 0
Condition0%0/9
defined $value and ($value || $value eq 0 and $param_type =~ /^scrolling_list:\d+$/)
!ll&&!rl&&r
000
$value || $value eq 0 and $param_type =~ /^scrolling_list:\d+$/
!ll&&!rl&&r
000
$value or $value eq 0
l!l&&r!l&&!r
000
MC/DC0%0/4
defined $value and ($value || $value eq 0 and $param_type =~ /^scrolling_list:\d+$/)
defined $value $value $value eq 0 $param_type =~ /^scrolling_list:\d+$/
Truth table0%0/6
A and B or C and D
A= defined $valueB= $valueC= $value eq 0D= $param_type =~ /^scrolling_list:\d+$/
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
1115 and ($value or $value eq '0')
1116 && $param_type =~ /^scrolling_list:\d+$/) {
1117 0 ▶ my @values = ref $value ? @$value : ($value);
Branch: 1 branch
BranchTrueFalseTotal
ref $value ? : 0 0 0
1118  
1119 0 ▶ if (($operator eq '<>' or $operator =~ /^not_/)
Branch: 1 branch
BranchTrueFalseTotal
if ($operator eq "<>" || $operator =~ /^not_/ and $self->_ary_exists(\@values, "all")) 0 0 0
Condition0%0/6
$operator eq "<>" || $operator =~ /^not_/ and $self->_ary_exists(\@values, "all")
!ll&&!rl&&r
000
$operator eq "<>" or $operator =~ /^not_/
l!l&&r!l&&!r
000
MC/DC0%0/3
$operator eq "<>" || $operator =~ /^not_/ and $self->_ary_exists(\@values, "all")
$operator eq "<>" $operator =~ /^not_/ $self->_ary_exists(\@values, "all")
Truth table0%0/5
A or B and C
A= $operator eq "<>"B= $operator =~ /^not_/C= $self->_ary_exists(\@values, "all")
ABCresult
00X0
1X00
0100
1X11
0111
1120 and $self->_ary_exists(\@values, 'all')) {
1121 0 croak("Negation operators cannot be used with value ALL!");
1122 }
1123  
1124 0 ▶ unless ($self->_ary_exists(\@values, 'all')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_ary_exists(\@values, "all")) 0 0 0
1125 0 my @in_where_clauses;
1126  
1127 0 foreach my $value (@values) {
1128 0 push @in_where_clauses,
1129 $self->_make_where_clause($operator, $value, $pf);
1130 }
1131  
1132 0 ▶ if ($operator eq '<>' or $operator =~ /^not_/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($operator eq '<>' or $operator =~ /^not_/) { } 0 0 0
Condition0%0/3
$operator eq "<>" or $operator =~ /^not_/
l!l&&r!l&&!r
000
MC/DC0%0/2
$operator eq "<>" or $operator =~ /^not_/
$operator eq "<>" $operator =~ /^not_/
Truth table0%0/3
A or B
A= $operator eq "<>"B= $operator =~ /^not_/
ABresult
1X1
011
000
1133 0 push @where_clauses,
1134 "(" . join(" AND ", @in_where_clauses) . ")";
1135 }
1136 else {
1137 0 push @where_clauses,
1138 "(" . join(" OR ", @in_where_clauses) . ")";
1139 }
1140 }
1141 }
1142  
1143 ▶ elsif (($operator eq '<>' or $operator =~ /^not_/)
Condition0%0/6
$operator eq "<>" || $operator =~ /^not_/ and $value eq "all"
!ll&&!rl&&r
000
$operator eq "<>" or $operator =~ /^not_/
l!l&&r!l&&!r
000
MC/DC0%0/3
$operator eq "<>" || $operator =~ /^not_/ and $value eq "all"
$operator eq "<>" $operator =~ /^not_/ $value eq "all"
Truth table0%0/5
A or B and C
A= $operator eq "<>"B= $operator =~ /^not_/C= $value eq "all"
ABCresult
00X0
1X00
0100
1X11
0111
1144 and $value eq 'all') {
1145 0 croak("Negation operators cannot be used with value ALL!");
1146 }
1147  
1148 ▶ elsif ( defined $value
Condition0%0/9
defined $value and $value || $value eq 0 and $value ne "all"
!ll&&!rl&&r
000
defined $value and $value || $value eq 0
!ll&&!rl&&r
000
$value or $value eq 0
l!l&&r!l&&!r
000
MC/DC0%0/4
defined $value and $value || $value eq 0 and $value ne "all"
defined $value $value $value eq 0 $value ne "all"
Truth table0%0/6
A and B or C and D
A= defined $valueB= $valueC= $value eq 0D= $value ne "all"
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
1149 and ($value or $value eq '0')
1150 and $value ne 'all') {
1151 0 ▶ croak("Operator is not specified for field ($form_name)!")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $operator 0 0 0
1152 unless defined $operator;
1153  
1154 0 push @where_clauses,
1155 $self->_make_where_clause($operator, $value, $pf);
1156 }
1157 }
1158  
1159 # Add external WHERE clause rule
1160 0 ▶ my @external_where_clauses = @{$self->external_where_clauses}
Branch: 1 branch
BranchTrueFalseTotal
if $self->external_where_clauses 0 0 0
1161 if $self->external_where_clauses;
1162 0 push @where_clauses, @external_where_clauses;
1163  
1164 # Add the field to ORDER BY <SOMETHING>
1165 0 ▶ while (@order_by) {
Branch: 1 branch
BranchTrueFalseTotal
if (@order_by) 0 0 0
1166 0 my $direction = shift @order_by;
1167 0 my $field = shift @order_by;
1168 0 ▶ croak("Invalid order direction ($direction)!")
Branch: 1 branch
BranchTrueFalseTotal
unless $direction eq "asc" or $direction eq "desc" 0 0 0
Condition0%0/3
$direction eq "asc" or $direction eq "desc"
l!l&&r!l&&!r
000
MC/DC0%0/2
$direction eq "asc" or $direction eq "desc"
$direction eq "asc" $direction eq "desc"
Truth table0%0/3
A or B
A= $direction eq "asc"B= $direction eq "desc"
ABresult
1X1
011
000
1169 unless ($direction eq 'asc' or $direction eq 'desc');
1170  
1171 0 ▶ push @order_by_clauses, "$field $direction"
Branch: 1 branch
BranchTrueFalseTotal
if $field and $field ne "not_selected" 0 0 0
Condition0%0/3
$field and $field ne "not_selected"
!ll&&!rl&&r
000
MC/DC0%0/2
$field and $field ne "not_selected"
$field $field ne "not_selected"
Truth table0%0/3
A and B
A= $fieldB= $field ne "not_selected"
ABresult
0X0
100
111
1172 if ($field and $field ne 'not_selected');
1173 }
1174  
1175 # Add LIMIT section (for pagination)
1176 0 my $limit_start = ($current_page - 1) * $page_size;
1177 0 $limit_clause = "LIMIT $limit_start, $page_size";
1178  
1179 # Generate query SQL statement
1180 0 my $query_sql_statement = "SELECT $distinct " . join(", ", @fields);
1181 0 $query_sql_statement .= " FROM " . $base_sql_table;
1182 0 ▶ $query_sql_statement .= " WHERE " . join(" AND ", @where_clauses)
Branch: 1 branch
BranchTrueFalseTotal
if @where_clauses 0 0 0
1183 if @where_clauses;
1184 0 ▶ $query_sql_statement .= " GROUP BY " . $group_by if $group_by;
Branch: 1 branch
BranchTrueFalseTotal
if $group_by 0 0 0
1185 0 ▶ $query_sql_statement .= " ORDER BY " . join(", ", @order_by_clauses)
Branch: 1 branch
BranchTrueFalseTotal
if @order_by_clauses 0 0 0
1186 if @order_by_clauses;
1187 0 ▶ $query_sql_statement .= " " . $limit_clause if $output_format eq 'html';
Branch: 1 branch
BranchTrueFalseTotal
if $output_format eq "html" 0 0 0
1188  
1189 # Generate count SQL statement
1190 0 my $count_sql_statement = "SELECT COUNT(*) FROM (";
1191  
1192 # Mysql 5 complains about duplicate column names in select ocunt(*)
1193 # Added placeholder aliases
1194 0 my @aliased_fields;
1195 0 foreach my $i (0 .. $#fields) {
1196 0 push @aliased_fields, $fields[$i] . " as alias$i";
1197 }
1198  
1199 0 $count_sql_statement .= "SELECT $distinct " . join(", ", @aliased_fields);
1200 0 $count_sql_statement .= " FROM " . $base_sql_table;
1201 0 ▶ $count_sql_statement .= " WHERE " . join(" AND ", @where_clauses)
Branch: 1 branch
BranchTrueFalseTotal
if @where_clauses 0 0 0
1202 if @where_clauses;
1203 0 ▶ $count_sql_statement .= " GROUP BY " . $group_by if $group_by;
Branch: 1 branch
BranchTrueFalseTotal
if $group_by 0 0 0
1204 0 $count_sql_statement .= ") a";
1205  
1206 # Store in the object
1207 0 $self->query_sql_statement($query_sql_statement);
1208 0 $self->count_sql_statement($count_sql_statement);
1209  
1210 0 return 1;
1211 }
1212  
1213 # Function : Return whether the query exists in the ary
1214 # Arguments : $aryref, $query
1215 # Returns : undef | 1
1216 # Notes : This is a private method.
1217  
1218 0 ▶sub _ary_exists {
Subroutine _ary_exists: not called CC=3 SCAR=24.8
1219 0 my ($self, $ary, $query) = @_;
1220  
1221 0 ▶ foreach (@$ary) { return 1 if $_ eq $query; }
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq $query 0 0 0
1222  
1223 0 return;
1224 }
1225  
1226 # Function : Generates WHERE clause for the SQL statement.
1227 # Arguments : $operator, $value, $ParamField
1228 # Returns : $where_clause
1229 # Notes : This is a private method.
1230  
1231 0 ▶sub _make_where_clause {
Subroutine _make_where_clause: not called CC=12 SCAR=50.5
1232 0 my ($self, $operator, $value, $pf) = @_;
1233  
1234 0 my $dbh = $self->dbh;
1235  
1236 0 my $sql_column = $pf->sql_column;
1237 0 my $case_sensitive = $pf->case_sensitive;
1238 0 my $numerical = $pf->numerical;
1239  
1240 0 my $where_clause;
1241  
1242 0 ▶ if ($value eq 'null') {
Branch: 1 branch
BranchTrueFalseTotal
if ($value eq 'null') { } 0 0 0
1243 0 ▶ if ( $operator eq '='
Branch: 2 branches
BranchTrueFalseTotal
if ($operator eq '=' or $operator eq 'like_m' or $operator eq 'like_c') { } 0 0 0
elsif ($operator eq '<>' or $operator eq 'not_like_m' or $operator eq 'not_like_c') { } 0 0 0
Condition0%0/6
$operator eq "=" or $operator eq "like_m" or $operator eq "like_c"
l!l&&r!l&&!r
000
$operator eq "=" or $operator eq "like_m"
l!l&&r!l&&!r
000
MC/DC0%0/3
$operator eq "=" or $operator eq "like_m" or $operator eq "like_c"
$operator eq "=" $operator eq "like_m" $operator eq "like_c"
Truth table0%0/4
A or B or C
A= $operator eq "="B= $operator eq "like_m"C= $operator eq "like_c"
ABCresult
1XX1
01X1
0011
0000
1244 or $operator eq 'like_m'
1245 or $operator eq 'like_c') {
1246 0 $where_clause = qq[$sql_column IS NULL];
1247 }
1248 ▶ elsif ($operator eq '<>'
Condition0%0/6
$operator eq "<>" or $operator eq "not_like_m" or $operator eq "not_like_c"
l!l&&r!l&&!r
000
$operator eq "<>" or $operator eq "not_like_m"
l!l&&r!l&&!r
000
MC/DC0%0/3
$operator eq "<>" or $operator eq "not_like_m" or $operator eq "not_like_c"
$operator eq "<>" $operator eq "not_like_m" $operator eq "not_like_c"
Truth table0%0/4
A or B or C
A= $operator eq "<>"B= $operator eq "not_like_m"C= $operator eq "not_like_c"
ABCresult
1XX1
01X1
0011
0000
1249 or $operator eq 'not_like_m'
1250 or $operator eq 'not_like_c') {
1251 0 $where_clause = qq[$sql_column IS NOT NULL];
1252 }
1253 else {
1254 0 croak(
1255 "Unable to process reserved keyword null, invalid operator ($operator)!"
1256 );
1257 }
1258 }
1259  
1260 else {
1261 0 ▶ if ($operator eq 'like_c') {
Branch: 2 branches
BranchTrueFalseTotal
if ($operator eq 'like_c') { } 0 0 0
elsif ($operator eq 'like_m') { } 0 0 0
1262 0 $operator = 'like';
1263 0 $value = qq[%$value%];
1264 0 $value = $dbh->quote($value);
1265 }
1266 elsif ($operator eq 'like_m') {
1267 0 $operator = 'like';
1268 0 $value =~ s/\*/%/g;
1269 0 $value =~ s/\?/_/g;
1270 0 $value = $dbh->quote($value);
1271 }
1272 0 ▶ else { $value = $numerical ? qq[$value] : qq["$value"]; }
Branch: 1 branch
BranchTrueFalseTotal
$numerical ? : 0 0 0
1273  
1274 0 ▶ $value = qq[BINARY $value] if $case_sensitive;
Branch: 1 branch
BranchTrueFalseTotal
if $case_sensitive 0 0 0
1275 0 $where_clause = qq[$sql_column $operator $value];
1276 }
1277  
1278 0 return $where_clause;
1279 }
1280  
1281 # Function : Executes the query SQL statement, retrieves and stores the raw data.
1282 # Arguments : None
1283 # Returns : 1
1284 # Notes : This is a private method.
1285  
1286 0 ▶sub _retrieve_data {
Subroutine _retrieve_data: not called CC=7 SCAR=40.3
1287 0 my ($self) = @_;
1288  
1289 0 my $dbh = $self->dbh;
1290 0 ▶ my $statement = $self->query_sql_statement
Condition0%0/2
$self->query_sql_statement || croak('No pre-set (query) SQL statement!')
l!l
00
MC/DC0%0/1
$self->query_sql_statement || croak('No pre-set (query) SQL statement!')
$self->query_sql_statement
Truth table0%0/2
A
A= $self->query_sql_statement
Aresult
11
00
1291 || croak("No pre-set (query) SQL statement!");
1292  
1293 0 my @data;
1294  
1295 0 ▶ my $sth = $dbh->prepare($statement)
Condition0%0/2
$dbh->prepare($statement) || croak("Cannot prepare statement ($statement)!")
l!l
00
MC/DC0%0/1
$dbh->prepare($statement) || croak("Cannot prepare statement ($statement)!")
$dbh->prepare($statement)
Truth table0%0/2
A
A= $dbh->prepare($statement)
Aresult
11
00
1296 || croak("Cannot prepare statement ($statement)!");
1297 0 ▶ $sth->execute() || croak("Cannot execute statement ($statement)!");
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute or croak("Cannot execute statement ($statement)!") 0 0 0
1298  
1299 0 ▶ while (my @row = $sth->fetchrow_array) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@row) = $sth->fetchrow_array) 0 0 0
1300 0 foreach (@row) {
1301 0 ▶ $_ = '' unless defined $_;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 0 0
1302 }
1303 0 push @data, \@row;
1304 }
1305  
1306 # Store in the object
1307 0 $self->data(\@data);
1308  
1309 0 return 1;
1310 }
1311  
1312 # Function : Executes the count SQL statement, retrieves
1313 # and stores the data count.
1314 # Arguments : None
1315 # Returns : 1
1316 # Notes : This is a private method.
1317  
1318 0 ▶sub _retrieve_count {
Subroutine _retrieve_count: not called CC=4 SCAR=30.0
1319 0 my ($self) = @_;
1320  
1321 0 my $dbh = $self->dbh;
1322 0 ▶ my $statement = $self->count_sql_statement
Condition0%0/2
$self->count_sql_statement || croak('No pre-set (count) SQL statement!')
l!l
00
MC/DC0%0/1
$self->count_sql_statement || croak('No pre-set (count) SQL statement!')
$self->count_sql_statement
Truth table0%0/2
A
A= $self->count_sql_statement
Aresult
11
00
1323 || croak("No pre-set (count) SQL statement!");
1324  
1325 0 ▶ my $sth = $dbh->prepare($statement)
Condition0%0/2
$dbh->prepare($statement) || croak("Cannot prepare statement ($statement)!")
l!l
00
MC/DC0%0/1
$dbh->prepare($statement) || croak("Cannot prepare statement ($statement)!")
$dbh->prepare($statement)
Truth table0%0/2
A
A= $dbh->prepare($statement)
Aresult
11
00
1326 || croak("Cannot prepare statement ($statement)!");
1327 0 ▶ $sth->execute() || croak("Cannot execute statement ($statement)!");
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute or croak("Cannot execute statement ($statement)!") 0 0 0
1328  
1329 0 my ($count) = $sth->fetchrow_array;
1330  
1331 # Store in the object
1332 0 $self->count($count);
1333  
1334 0 return 1;
1335 }
1336  
1337 # Function : Compiles debug info and stores in object.
1338 # Arguments : None
1339 # Returns : 1
1340 # Notes : This is a private method.
1341  
1342 0 ▶sub _get_debug_info {
Subroutine _get_debug_info: not called CC=4 SCAR=30.0
1343 0 my ($self) = @_;
1344  
1345 0 my $debug_level = $self->debug_level;
1346  
1347 0 my $dbh = $self->dbh;
1348 0 my $alias = $self->db_selected;
1349 0 my ($database_name) = $dbh->{Name} =~ /database=([^;]+)/;
1350  
1351 0 my $datasource_info = qq[alias=$alias; database_name=$database_name];
1352  
1353 0 my $html;
1354  
1355 0 my $debug_info = qq[];
1356  
1357 0 ▶ if ($debug_level > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug_level > 0) 0 0 0
1358 0 my $time_stamp = $time{'dd-Mon-yyyy hh:mm:ss tz'};
1359  
1360 0 my $url = $ENV{HTTP_HOST} . $ENV{REQUEST_URI};
1361  
1362 0 my @software;
1363 0 foreach my $file (
1364 $0, $INC{'HTML/SearchPage/Param.pm'},
1365 $INC{'HTML/SearchPage.pm'},
1366 ) {
1367 0 my ($id) = $self->_get_version_information($file);
1368 0 my ($file_name) = $file =~ /([^\/]+)$/;
1369 0 push(@software, "SW: $file_name", $id);
1370 }
1371  
1372 0 my $query_sql_statement = $self->query_sql_statement;
1373 0 my $count_sql_statement = $self->count_sql_statement;
1374  
1375 0 $debug_info .= '<p>'
1376 . $self->_format_box(
1377 'VERSION & PROCESSING INFORMATION',
1378 'URL', $url,
1379 'Time', $time_stamp,
1380 @software,
1381 'Datasource', $datasource_info,
1382 'Query SQL Statement', $query_sql_statement,
1383 'Count SQL Statement', $count_sql_statement,
1384 );
1385 }
1386  
1387 0 ▶ if ($debug_level > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug_level > 1) 0 0 0
1388 0 $debug_info .= '<p>' . $self->_format_box('ENVIRONMENT', %ENV);
1389 }
1390  
1391 # Store in the object
1392 0 $self->debug_info($debug_info);
1393  
1394 0 return 1;
1395 }
1396  
1397 # Function :
1398 # Arguments :
1399 # Returns :
1400 # Notes : This is a private method.
1401  
1402 0 ▶sub _format_box {
Subroutine _format_box: not called CC=4 SCAR=30.0
1403 0 my ($self, $title, @content) = @_;
1404  
1405 0 tie my %content, 'Tie::IxHash';
1406 0 %content = @content;
1407  
1408 0 my $formatted_box;
1409  
1410 0 $formatted_box .= qq[<table class="small_box2" border="0" width="100%">];
1411 0 $formatted_box .=
1412 qq[<tr><td align="left"colspan="2"><b><u>$title</u></b></td></tr>];
1413  
1414 0 foreach my $key (keys %content) {
1415 0 ▶ my $line = $content{$key} || qq[];
Condition0%0/2
$content{$key} || ''
l!l
00
MC/DC0%0/1
$content{$key} || ''
$content{$key}
Truth table0%0/2
A
A= $content{$key}
Aresult
11
00
1416 0 ▶ $line =~ s/(.{100})/ $1<br>/g if $line =~ /\S{100,}/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /\S{100,}/ 0 0 0
1417 0 $formatted_box .= qq[<tr><td><b>$key</b></td><td>$line</td></tr>];
1418 }
1419 0 $formatted_box .= qq[</table>];
1420  
1421 0 return $formatted_box;
1422 }
1423  
1424 # Function :
1425 # Arguments :
1426 # Returns :
1427 # Notes : This is a private method.
1428  
1429 0 ▶sub _get_version_information {
Subroutine _get_version_information: not called CC=2 SCAR=17.9
1430 0 my ($self, $file) = @_;
1431 0 ▶ open(IN, "<$file") or die("Cannot read file ($file)");
Branch: 1 branch
BranchTrueFalseTotal
open IN, "<$file" or die "Cannot read file ($file)" 0 0 0
1432 0 my $content;
1433 0 { local $/; $content = <IN>; }
1434 0 close IN;
1435 0 my ($id) = $content =~ /\n(\$Id[^\$]*\$)/;
1436 0 return ($id);
1437 }
1438  
1439 # Function : Formats the stored data based on the selected output format.
1440 # Arguments : None
1441 # Returns : 1
1442 # Notes : This is a private method.
1443  
1444 0 ▶sub _format_data {
Subroutine _format_data: not called CC=42 SCAR=75.0
1445 0 my ($self) = @_;
1446  
1447 # Do modifications if any
1448 0 ▶ $self->_modify_data if @{$self->modifications};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->modifications;} 0 0 0
1449  
1450 # Assign form information
1451 0 my $temp_dir_eq = $self->temp_dir_eq;
1452  
1453 0 my $action = $self->action;
1454 0 my $method = $self->method;
1455 0 my $page_size = $self->page_size;
1456  
1457 # Self-referencing URL, without explicit database
1458 0 ▶ my $search_url =
Branch: 1 branch
BranchTrueFalseTotal
$self->show_search_url ? : 0 0 0
1459 $self->show_search_url ? $self->cgi->self_url . "#results" : qq[];
1460  
1461 0 my $order_by = $self->cgi_params->{"order_by"};
1462 0 my $order_direction = $self->cgi_params->{"order_direction"};
1463  
1464 my $current_page =
1465 $self->cgi_params->{page}
1466 ? $self->cgi_params->{page}
1467 0 ▶ : 1; # Page defaults to 1
Branch: 1 branch
BranchTrueFalseTotal
$self->cgi_params->{'page'} ? : 0 0 0
1468  
1469 0 my $count = $self->count;
1470  
1471 0 ▶ my $number_of_pages =
Branch: 1 branch
BranchTrueFalseTotal
$count % $page_size ? : 0 0 0
1472 $count % $page_size
1473 ? int($count / $page_size) + 1
1474 : $count / $page_size;
1475  
1476 0 ▶ $current_page = 1 if $current_page < 1;
Branch: 1 branch
BranchTrueFalseTotal
if $current_page < 1 0 0 0
1477 0 ▶ $current_page = $number_of_pages if $current_page > $number_of_pages;
Branch: 1 branch
BranchTrueFalseTotal
if $current_page > $number_of_pages 0 0 0
1478  
1479 0 my $output_format = $self->cgi_params->{output_format};
1480  
1481 0 my @data = @{$self->data};
1482  
1483 0 my @base_sql_fields = @{$self->base_sql_fields};
1484 0 my @base_output_headers = @{$self->base_output_headers};
1485  
1486 0 my $column_width_percent = int(100 / @base_output_headers);
1487  
1488 0 my %super_output_headers = %{$self->super_output_headers};
1489 0 my @trimmed_boh = map { /^([^:]+)/; $1; } @base_output_headers;
1490  
1491 0 my $formatted_data;
1492  
1493 0 ▶ if ($output_format eq 'html') {
Branch: 5 branches
BranchTrueFalseTotal
if ($output_format eq 'html') { } 0 0 0
elsif ($output_format eq 'text') { } 0 0 0
elsif ($output_format eq 'excel') { } 0 0 0
elsif ($output_format eq 'csv') { } 0 0 0
elsif ($output_format eq 'tab') { } 0 0 0
1494  
1495 # Prepare segment to display page navigation
1496 0 my %no_page_cgi = %{$self->cgi_params};
1497 0 delete $no_page_cgi{page};
1498 0 my $no_page_opt = $self->_form_opt(\%no_page_cgi);
1499  
1500 0 my $display_start = ($current_page - 1) * $page_size + 1;
1501 0 ▶ $display_start = 0 if $count == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $count == 0 0 0 0
1502  
1503 0 my $display_end = $current_page * $page_size;
1504 0 ▶ $display_end = $count if $display_end > $count;
Branch: 1 branch
BranchTrueFalseTotal
if $display_end > $count 0 0 0
1505 0 ▶ $display_end = 0 if $count == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $count == 0 0 0 0
1506  
1507 0 my $prev_page = $current_page - 1;
1508 0 ▶ $prev_page = 1 if $prev_page < 1;
Branch: 1 branch
BranchTrueFalseTotal
if $prev_page < 1 0 0 0
1509 0 my $next_page = $current_page + 1;
1510 0 ▶ $next_page = $number_of_pages if $next_page > $number_of_pages;
Branch: 1 branch
BranchTrueFalseTotal
if $next_page > $number_of_pages 0 0 0
1511  
1512 my @page_list =
1513 map {
1514 0 ▶ $current_page eq $_
Branch: 1 branch
BranchTrueFalseTotal
$current_page eq $_ ? : 0 0 0
1515 ? qq[<option selected value="$_">Page $_</option>\n]
1516 : qq[<option value="$_">Page $_</option>\n]
1517 } (1 .. $number_of_pages);
1518 0 my $page_list = join(qq[], @page_list);
1519  
1520 0 ▶ my $search_url_link =
Branch: 1 branch
BranchTrueFalseTotal
$search_url ? : 0 0 0
1521 $search_url ? qq[<a href="$search_url">[Search URL]</a>] : '&nbsp;';
1522  
1523 0 my $page_navigation = <<HTML;
1524  
1525 <table border="0" width="100%" class="navigator_color">
1526 <tr>
1527 <td width="40%" align="left">
1528 Record $display_start-$display_end of $count
1529 &nbsp;&nbsp;&nbsp;$search_url_link
1530 </td>
1531  
1532 <td align="center">
1533 <form method="$method" action="$action">
1534 $no_page_opt
1535 <input type="hidden" name="page" value="$prev_page"/></input>
1536 <input type="image" src="$temp_dir_eq/left-arrow.png" alt="Previous" width="25" height="25" name="submit"></input>
1537 </form>
1538 </td>
1539  
1540 <td align="center">
1541 Page $current_page of $number_of_pages
1542 </td>
1543  
1544 <td align="center">
1545 <form method="$method" action="$action">
1546 $no_page_opt
1547 <input type="hidden" name="page" value="$next_page"></input>
1548 <input type="image" src="$temp_dir_eq/right-arrow.png" alt="Next" width="25" height="25" name="submit"></input>
1549 </form>
1550 </td>
1551  
1552 <td width="40%" align="right">
1553 <form method="$method" action="$action">
1554 $no_page_opt
1555 <select name="page">
1556 $page_list
1557 </select>
1558 <input type="submit" name="submit" value="Go"></input>
1559 </form>
1560 </td>
1561  
1562 </tr>
1563 </table>
1564 HTML
1565  
1566 # Add navigation bar to the top
1567 0 $formatted_data .=
1568 qq[<table border="0" width="100%"><tr><td>$page_navigation</td></tr></table>\n];
1569  
1570 # Start table
1571 0 $formatted_data .=
1572 qq[<table border="1" width="100%" class="header_color">\n];
1573  
1574 # Add headers - 1st row
1575 0 $formatted_data .= qq[<tr>\n];
1576 0 foreach my $group (sort { $a <=> $b } keys %super_output_headers) {
1577 0 my $super_header = $super_output_headers{$group}{super_header};
1578 0 my @headers = @{$super_output_headers{$group}{headers}};
1579 0 my $colspan = $super_output_headers{$group}{colspan};
1580  
1581 0 ▶ if ($colspan == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($colspan == 1) { } 0 0 0
1582 0 my $header_piece = $self->_get_header_piece($headers[0]);
1583 0 $formatted_data .=
1584 qq[<td rowspan="2" width="$column_width_percent\%" align="center">$header_piece</td>\n];
1585 }
1586  
1587 else {
1588 0 $formatted_data .=
1589 qq[<td colspan="$colspan" align="center"><b>$super_header</b></td>\n];
1590 }
1591 }
1592 0 $formatted_data .= qq[</tr>\n];
1593  
1594 # Add headers - 2nd row
1595 0 $formatted_data .= qq[<tr>\n];
1596 0 foreach my $group (sort { $a <=> $b } keys %super_output_headers) {
1597 0 my @headers = @{$super_output_headers{$group}{headers}};
1598 0 my $colspan = $super_output_headers{$group}{colspan};
1599  
1600 0 ▶ if ($colspan > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($colspan > 1) 0 0 0
1601 0 foreach (@headers) {
1602 0 my $header_piece = $self->_get_header_piece($_);
1603 0 $formatted_data .=
1604 qq[<td align="center" width="$column_width_percent\%">$header_piece</td>\n];
1605 }
1606 }
1607 }
1608 0 $formatted_data .= qq[</tr>\n];
1609  
1610 # Add data
1611 0 my $counter = 0;
1612 0 foreach my $row (@data) {
1613 0 $counter++;
1614 0 ▶ my $background_color =
Branch: 1 branch
BranchTrueFalseTotal
$counter % 2 == 1 ? : 0 0 0
1615 $counter % 2 == 1
1616 ? qq[class="row_color_one"]
1617 : qq[class="row_color_two"];
1618  
1619 0 $formatted_data .= qq[<tr $background_color>\n];
1620 0 foreach (@$row) {
1621 0 ▶ $formatted_data .=
Branch: 1 branch
BranchTrueFalseTotal
defined $_ && $_ ne '' ? : 0 0 0
Condition0%0/3
defined $_ and $_ ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_ and $_ ne ""
defined $_ $_ ne ""
Truth table0%0/3
A and B
A= defined $_B= $_ ne ""
ABresult
0X0
100
111
1622 (defined $_ and $_ ne qq[])
1623 ? qq[<td>$_</td>]
1624 : qq[<td>&nbsp;</td>];
1625 0 $formatted_data .= "\n";
1626 }
1627 0 $formatted_data .= qq[</tr>];
1628 }
1629  
1630 # End table
1631 0 $formatted_data .= qq[</table>\n];
1632  
1633 # Add navigation bar to the bottom
1634 0 $formatted_data .=
1635 qq[<table border="0" width="100%"><tr><td>$page_navigation</td></tr></table>\n];
1636 }
1637  
1638 elsif ($output_format eq 'text') {
1639  
1640 # Calculate field length for each column
1641 0 my @index = @{$self->_get_column_lengths(\@trimmed_boh, @data)};
1642  
1643 # Add headers and data
1644 0 foreach my $row (\@trimmed_boh, @data) {
1645 0 my @row = @$row;
1646  
1647 0 foreach my $i (0 .. $#row) {
1648 0 my $size = $index[$i] + 1;
1649 0 $formatted_data .= sprintf("\%-${size}s", $row[$i]);
1650 }
1651 0 $formatted_data .= "\n";
1652 }
1653  
1654 # Add end marker
1655 0 $formatted_data .= '# [END]';
1656 }
1657  
1658 elsif ($output_format eq 'excel') {
1659 0 ▶ open my $fh, '>', \$formatted_data
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", \$formatted_data or croak("Failed to open filehandle to write excel output: $!") 0 0 0
1660 or croak("Failed to open filehandle to write excel output: $!");
1661  
1662 # Create WriteExcel object
1663 0 my $workbook = Spreadsheet::WriteExcel->new($fh);
1664 0 my $worksheet = $workbook->add_worksheet();
1665  
1666 # Add header format to WriteExcel object
1667 0 my $header_format = $workbook->add_format;
1668 0 $header_format->set_properties(
1669 bold => 1,
1670 );
1671  
1672 # Set column widths
1673 my @index =
1674 0 @{$self->_get_column_lengths(\@base_output_headers, @data)};
1675 0 foreach my $i (0 .. $#index) {
1676 0 $worksheet->set_column($i, $i, $index[$i]);
1677 }
1678  
1679 # Add headers and data
1680 0 my $row_number = 0;
1681 0 foreach my $row (\@trimmed_boh, @data) {
1682 0 foreach my $i (0 .. $#{@$row}) {
1683 0 ▶ if ($row_number == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row_number == 0) { } 0 0 0
1684 0 $worksheet->write(
1685 $row_number, $i, $row->[$i],
1686 $header_format
1687 );
1688 }
1689 else {
1690 0 $worksheet->write($row_number, $i, $row->[$i]);
1691 }
1692 }
1693 0 $row_number++;
1694 }
1695  
1696 0 $workbook->close;
1697 }
1698  
1699 elsif ($output_format eq 'csv') {
1700  
1701 # Add headers and data
1702 0 foreach my $row (\@trimmed_boh, @data) {
1703 0 foreach (@$row) { $_ = qq["$_"]; }
1704 0 $formatted_data .= join(',', @$row) . "\n";
1705 }
1706  
1707 # Add end marker
1708 0 $formatted_data .= '# [END]';
1709 }
1710  
1711 elsif ($output_format eq 'tab') {
1712  
1713 # Track tab conversion
1714 0 my @tab_removed;
1715  
1716 # Add headers and data
1717 0 my $row_number = 0;
1718 0 foreach my $row (\@trimmed_boh, @data) {
1719 0 foreach my $i (0 .. $#{@$row}) {
1720 0 ▶ if ($row->[$i] =~ s/\t/_/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row->[$i] =~ s/\t/_/g) 0 0 0
1721 0 push @tab_removed, "Row: row_number, Column: $i";
1722 }
1723 }
1724 0 $formatted_data .= join("\t", @$row) . "\n";
1725 0 $row_number++;
1726 }
1727  
1728 # Record tab removals
1729 0 foreach (@tab_removed) {
1730 0 $formatted_data .= "# tab conveted to underscore $_\n";
1731 }
1732  
1733 # Add end marker
1734 0 $formatted_data .= "# [END]\n";
1735 }
1736  
1737 # Store in the object
1738 0 $self->formatted_data($formatted_data);
1739  
1740 0 return 1;
1741 }
1742  
1743 # Function : Generates the oheader segment that contains the sort icons
1744 # Arguments : $label (header:sql_column)
1745 # Returns : $html_code
1746 # Notes : This is a private method.
1747  
1748 0 ▶sub _get_header_piece {
Subroutine _get_header_piece: not called CC=2 SCAR=17.9
1749 0 my ($self, $label) = @_;
1750  
1751 0 my $temp_dir_eq = $self->temp_dir_eq;
1752  
1753 0 my ($header, $sql_column) = split(':', $label);
1754  
1755 0 my $content;
1756  
1757 0 ▶ my $image = $sql_column
Branch: 1 branch
BranchTrueFalseTotal
$sql_column ? : 0 0 0
1758 ? qq[<img src="$temp_dir_eq/sort-button.png" alt="Sortable" width="14" height="14">]
1759 : '&nbsp;';
1760 0 $content .=
1761 qq[<table><tr><td><b>$header</b></td><td>$image</td></tr></table>];
1762  
1763 0 return $content;
1764 }
1765  
1766 # Function : Generates the options segment of a form, given
1767 # a hasref of cgi params
1768 # Arguments : \%cgi
1769 # Returns : $options_segment
1770 # Notes : This is a private method.
1771  
1772 0 ▶sub _form_opt {
Subroutine _form_opt: not called CC=5 SCAR=34.0
1773 0 my ($self, $cgi) = @_;
1774  
1775 0 my $options;
1776  
1777 0 foreach my $key (keys %$cgi) {
1778 0 ▶ my @values = ref $cgi->{$key} ? @{$cgi->{$key}} : ($cgi->{$key});
Branch: 1 branch
BranchTrueFalseTotal
ref $cgi->{$key} ? : 0 0 0
1779 0 foreach my $value (@values) {
1780 0 ▶ $value ||= qq[];
Condition0%0/2
$value ||= ""
l!l
00
MC/DC0%0/1
$value ||= ""
$value
Truth table0%0/2
A
A= $value
Aresult
11
00
1781 0 $options .=
1782 qq[<input type="hidden" name="$key" value="$value"></input>\n];
1783 }
1784 }
1785  
1786 0 return $options;
1787 }
1788  
1789 # Function : For a given arrayref of data, calculate max column lengths
1790 # Arguments : \@data (Each member is an arrayref of column data)
1791 # Returns : \@index (Each member is the max length of that column)
1792 # Notes : This is a private method.
1793  
1794 0 ▶sub _get_column_lengths {
Subroutine _get_column_lengths: not called CC=5 SCAR=34.0
1795 0 my ($self, @data) = @_;
1796  
1797 0 my @index;
1798  
1799 0 foreach my $row_ref (@data) {
1800 0 my @row = @{$row_ref};
1801 0 foreach my $i (0 .. $#row) {
1802 0 ▶ if (!defined $index[$i] || length($row[$i]) > $index[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $index[$i] or length $row[$i] > $index[$i]) 0 0 0
Condition0%0/3
not defined $index[$i] or length $row[$i] > $index[$i]
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $index[$i] or length $row[$i] > $index[$i]
not defined $index[$i] length $row[$i] > $index[$i]
Truth table0%0/3
not(A) or B
A= not defined $index[$i]B= length $row[$i] > $index[$i]
ABresult
1X1
011
000
1803 0 $index[$i] = length($row[$i]);
1804 }
1805 }
1806 }
1807  
1808 0 return \@index;
1809 }
1810  
1811 # Function : Generates the HTML code for the search page
1812 # Arguments : None
1813 # Returns : 1
1814 # Notes : This is a private method.
1815  
1816 0 ▶sub _print_page {
Subroutine _print_page: not called CC=11 SCAR=48.8
1817 0 my ($self) = @_;
1818 0 my $header = $self->_content($self->header);
1819 0 my $css = $self->_content($self->css);
1820 0 my $page_title = $self->page_title;
1821 0 my $instructions = $self->_content($self->instructions);
1822 0 ▶ my $search_form = $self->search_form || qq[];
Condition0%0/2
$self->search_form || ''
l!l
00
MC/DC0%0/1
$self->search_form || ''
$self->search_form
Truth table0%0/2
A
A= $self->search_form
Aresult
11
00
1823 0 ▶ my $formatted_data = $self->formatted_data || qq[];
Condition0%0/2
$self->formatted_data || ''
l!l
00
MC/DC0%0/1
$self->formatted_data || ''
$self->formatted_data
Truth table0%0/2
A
A= $self->formatted_data
Aresult
11
00
1824 0 ▶ my $debug_info = $self->debug_info || qq[];
Condition0%0/2
$self->debug_info || ''
l!l
00
MC/DC0%0/1
$self->debug_info || ''
$self->debug_info
Truth table0%0/2
A
A= $self->debug_info
Aresult
11
00
1825 0 my $footer = $self->_content($self->footer);
1826 0 my $temp_dir_eq = $self->temp_dir_eq;
1827  
1828 0 my $cookie = $self->cookie;
1829 0 my $session_id = $self->session_id;
1830 0 my $cookie_expires_in_min = $self->cookie_expires_in_min;
1831  
1832 0 my $cookie_obj = CGI::cookie(
1833 -name => $cookie,
1834 -value => $session_id,
1835 -expires => "+${cookie_expires_in_min}m",
1836 );
1837  
1838 0 ▶ my $output_format = $self->cgi_params->{output_format} || 'html';
Condition0%0/2
$self->cgi_params->{'output_format'} || 'html'
l!l
00
MC/DC0%0/1
$self->cgi_params->{'output_format'} || 'html'
$self->cgi_params->{'output_format'}
Truth table0%0/2
A
A= $self->cgi_params->{'output_format'}
Aresult
11
00
1839  
1840 0 ▶ my $results_anchor =
Branch: 1 branch
BranchTrueFalseTotal
$formatted_data ? : 0 0 0
1841 $formatted_data
1842 ? "results"
1843 : "placeholder"; # Don't display results anchor if there
1844 # are no results
1845  
1846 0 ▶ if ($output_format eq 'html') {
Branch: 5 branches
BranchTrueFalseTotal
if ($output_format eq 'html') { } 0 0 0
elsif ($output_format eq 'excel') { } 0 0 0
elsif ($output_format eq 'csv') { } 0 0 0
elsif ($output_format eq 'tab') { } 0 0 0
elsif ($output_format eq 'text') { } 0 0 0
1847 0 print $self->cgi->header(-cookie => $cookie_obj);
1848 0 print <<HTML;
1849 <html>
1850 <head>
1851 <title>$page_title</title>
1852 <link rel="stylesheet" type="text/css" href="$temp_dir_eq/searchpage-main.css" />
1853 $css
1854 </head>
1855  
1856 <body>
1857 <table border="0" width="97%" align="center">
1858 <tr><td colspan="2" align="center">$header</td></tr>
1859 <tr><td colspan="2" align="center"><h1>$page_title</h1></td></tr>
1860 <tr><td width="60%" align="left">$instructions</td><td width="40%" align="center">$search_form</td></tr>
1861 <tr><td colspan="2" align="center"><a name="$results_anchor"></a>$formatted_data</td></tr>
1862 <tr><td colspan="2" align="center">$debug_info</td></tr>
1863 <tr><td colspan="2" align="center">$footer</td></tr>
1864 </table>
1865 </body>
1866 </html>
1867 HTML
1868 }
1869  
1870 elsif ($output_format eq 'excel') {
1871 0 print $self->cgi->header(
1872 -cookie => $cookie_obj,
1873 -type => 'application/vnd.ms-excel'
1874 );
1875 0 print $formatted_data;
1876 }
1877  
1878 elsif ($output_format eq 'csv') {
1879 0 print $self->cgi->header(
1880 -cookie => $cookie_obj,
1881 -type => 'text/comma-separated-values'
1882 );
1883 0 print $formatted_data;
1884 }
1885  
1886 elsif ($output_format eq 'tab') {
1887 0 print $self->cgi->header(
1888 -cookie => $cookie_obj,
1889 -type => 'text/tab-separated-values'
1890 );
1891 0 print $formatted_data;
1892 }
1893  
1894 elsif ($output_format eq 'text') {
1895 0 print $self->cgi->header(
1896 -cookie => $cookie_obj,
1897 -type => 'text/plain'
1898 );
1899 0 print $formatted_data;
1900 }
1901  
1902 else {
1903 0 print $self->cgi->header(
1904 -cookie => $cookie_obj,
1905 -type => 'text/plain'
1906 );
1907 0 print $formatted_data;
1908 }
1909  
1910 0 return 1;
1911 }
1912  
1913 # Function : Retrieves the content for the directive specified;
1914 # supports GET (retrieval by LWP), EXEC (executes a command-line
1915 # and captures output), FILE (retrieves a file content).
1916 # Arguments : $directive
1917 # Returns : $content
1918 # Notes : This is a private method.
1919  
1920 0 ▶sub _content {
Subroutine _content: not called CC=11 SCAR=48.8
1921 0 my ($self, $container) = @_;
1922  
1923 0 ▶ return '&nbsp;' unless $container;
Branch: 1 branch
BranchTrueFalseTotal
unless $container 0 0 0
1924  
1925 0 ▶ my $content = $container || qq[];
Condition0%0/2
$container || ''
l!l
00
MC/DC0%0/1
$container || ''
$container
Truth table0%0/2
A
A= $container
Aresult
11
00
1926  
1927 0 ▶ if ($container =~ s/^(FILE|EXEC|GET)://) {
Branch: 1 branch
BranchTrueFalseTotal
if ($container =~ s/^(FILE|EXEC|GET)://) 0 0 0
1928 0 my $type = $1;
1929  
1930 0 ▶ if ($type eq 'GET') {
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'GET') { } 0 0 0
elsif ($type eq 'EXEC') { } 0 0 0
elsif ($type eq 'FILE') { } 0 0 0
1931 0 my $self_url = $self->cgi->self_url;
1932 0 my ($current_url, $current_args) = split(/\?/, $self_url);
1933 0 ▶ $current_args ||= qq[];
Condition0%0/2
$current_args ||= ""
l!l
00
MC/DC0%0/1
$current_args ||= ""
$current_args
Truth table0%0/2
A
A= $current_args
Aresult
11
00
1934  
1935 0 $current_url =~ s!^http://[^/]+!!;
1936 0 $current_url = CGI::escape($current_url);
1937 0 $current_args = CGI::escape($current_args);
1938 0 $container =~ s/__CURRENT_URL__/$current_url/;
1939 0 $container =~ s/__CURRENT_ARGS__/$current_args/;
1940 0 ▶ $content = get($container)
Branch: 1 branch
BranchTrueFalseTotal
$content = &get($container) or croak("Cannot get container ($container)!") 0 0 0
1941 or croak("Cannot get container ($container)!");
1942 }
1943  
1944 elsif ($type eq 'EXEC') {
1945 0 ▶ open(EXEC, "$container|")
Branch: 1 branch
BranchTrueFalseTotal
open EXEC, "$container|" or croak("Cannot exec container ($container)! - $!") 0 0 0
1946 or croak("Cannot exec container ($container)! - $!");
1947 0 { local $/; $content = <EXEC>; }
1948 0 close EXEC;
1949 }
1950  
1951 elsif ($type eq 'FILE') {
1952 0 ▶ open(FILE, "<$container")
Branch: 1 branch
BranchTrueFalseTotal
open FILE, "<$container" or croak("Cannot open container ($container)! - $!") 0 0 0
1953 or croak("Cannot open container ($container)! - $!");
1954 0 { local $/; $content = <FILE>; }
1955 0 close FILE;
1956 }
1957 }
1958  
1959 0 return $content;
1960 }
1961  
1962 # Function : Modifies the data in its raw form.
1963 # Arguments : %params
1964 # Returns : 1
1965 # Notes : This is a private method.
1966  
1967 0 ▶sub _modify_data {
Subroutine _modify_data: not called CC=6 SCAR=37.4
1968 0 my ($self) = @_;
1969  
1970 0 ▶ my $modifier = $self->modifier
Branch: 1 branch
BranchTrueFalseTotal
my $modifier = $self->modifier or croak("Cannot modify without a modifier object!") 0 0 0
1971 or croak("Cannot modify without a modifier object!");
1972  
1973 0 foreach my $params (@{$self->modifications}) {
1974  
1975 $params->{-page_obj} =
1976 0 $self; # temporary hack to be able to modify SearchPage obj
1977 0 $params->{-data} = $self->data;
1978 $params->{-output_format} = $self->cgi_params->{output_format}
1979 0 ▶ || 'html';
Condition0%0/2
$self->cgi_params->{'output_format'} || 'html'
l!l
00
MC/DC0%0/1
$self->cgi_params->{'output_format'} || 'html'
$self->cgi_params->{'output_format'}
Truth table0%0/2
A
A= $self->cgi_params->{'output_format'}
Aresult
11
00
1980 0 $params->{-dbh} = $self->dbh;
1981  
1982 my $action = $params->{-action}
1983 0 ▶ or croak("No modifier action specified!");
Branch: 1 branch
BranchTrueFalseTotal
my $action = $params->{"-action"} or croak("No modifier action specified!") 0 0 0
1984 0 delete $params->{-action};
1985  
1986 0 eval { $modifier->$action(%$params); };
1987  
1988 0 ▶ croak($@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1989 }
1990  
1991 # Ref to data is passed on, changes are made directly.
1992  
1993 0 return 1;
1994 }
1995  
1996 # Function : Formats the stored data based on the selected output format.
1997 # Arguments : None
1998 # Returns : 1
1999 # Notes : This is a private method.
2000  
2001 0 ▶sub _format_vertical_data {
Subroutine _format_vertical_data: not called CC=10 SCAR=47.0
2002 0 my ($self) = @_;
2003  
2004 # Do modifications if any
2005 0 ▶ $self->_modify_data if @{$self->modifications};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->modifications;} 0 0 0
2006  
2007 # Assign form information
2008 0 my $action = $self->action;
2009 0 my $method = $self->method;
2010  
2011 0 my $output_format = $self->cgi_params->{output_format};
2012  
2013 0 my @data = @{$self->data};
2014  
2015 0 my @base_output_headers = @{$self->base_output_headers};
2016  
2017 0 my @trimmed_boh = map { /^([^:]+)/; $1; } @base_output_headers;
2018  
2019 # Combine @data and trimmed_boh to make data vertical
2020 0 my @vertical_data;
2021 0 foreach my $i (0 .. $#trimmed_boh) {
2022 0 $vertical_data[$i] = [$trimmed_boh[$i], $data[0][$i]];
2023 }
2024  
2025 0 my $formatted_data;
2026  
2027 0 ▶ if ($output_format eq 'html') {
Branch: 1 branch
BranchTrueFalseTotal
if ($output_format eq 'html') { } 0 0 0
2028  
2029 # Start table
2030 0 $formatted_data .=
2031 qq[<table border="1" align="center" width="75%">\n];
2032  
2033 # Add data
2034 0 my $counter = 0;
2035 0 foreach my $row (@vertical_data) {
2036 0 $counter++;
2037 0 ▶ my $background_color =
Branch: 1 branch
BranchTrueFalseTotal
$counter % 2 == 1 ? : 0 0 0
2038 $counter % 2 == 1
2039 ? qq[class="row_color_one"]
2040 : qq[class="row_color_two"];
2041  
2042 0 $formatted_data .= qq[<tr $background_color>\n];
2043 0 foreach my $i (0 .. $#{@$row}) {
2044 0 my $value = $row->[$i];
2045 0 ▶ if ($i == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0) { } 0 0 0
2046 0 ▶ $formatted_data .= $value
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
2047 ? qq[<td width="20%"><b>$value</b></td>]
2048 : qq[<td>&nbsp;</td>];
2049 }
2050 else {
2051 0 ▶ $formatted_data .= $value
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
2052 ? qq[<td width="80%">$value</td>]
2053 : qq[<td>&nbsp;</td>];
2054 }
2055  
2056 0 $formatted_data .= "\n";
2057 }
2058 0 $formatted_data .= qq[</tr>];
2059 }
2060  
2061 # End table
2062 0 $formatted_data .= qq[</table>\n];
2063  
2064 # Add some space
2065 0 $formatted_data .= qq[<p>&nbsp;<p>&nbsp;<p>&nbsp;\n];
2066  
2067 }
2068  
2069 0 else { croak("Unknown output_format ($output_format) to display_info!"); }
2070  
2071 # Store in the object
2072 0 $self->formatted_data($formatted_data);
2073  
2074 0 return 1;
2075 }
2076  
2077 ###################
2078 # GET/SET METHODS #
2079 ###################
2080  
2081 0 ▶sub action {
Subroutine action: not called CC=2 SCAR=17.9
Pod undocumented
2082 0 my ($self, $value) = @_;
2083 0 ▶ $self->{action} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2084 0 return $self->{action};
2085 }
2086  
2087 0 ▶sub base_identifier {
Subroutine base_identifier: not called CC=2 SCAR=17.9
Pod undocumented
2088 0 my ($self, $value) = @_;
2089 0 ▶ $self->{base_identifier} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2090 0 return $self->{base_identifier};
2091 }
2092  
2093 0 ▶sub base_output_headers {
Subroutine base_output_headers: not called CC=2 SCAR=17.9
Pod undocumented
2094 0 my ($self, $value) = @_;
2095 0 ▶ $self->{base_output_headers} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2096 0 return $self->{base_output_headers};
2097 }
2098  
2099 0 ▶sub base_sql_fields {
Subroutine base_sql_fields: not called CC=2 SCAR=17.9
Pod undocumented
2100 0 my ($self, $value) = @_;
2101 0 ▶ $self->{base_sql_fields} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2102 0 return $self->{base_sql_fields};
2103 }
2104  
2105 0 ▶sub base_sql_table {
Subroutine base_sql_table: not called CC=2 SCAR=17.9
Pod undocumented
2106 0 my ($self, $value) = @_;
2107 0 ▶ $self->{base_sql_table} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2108 0 return $self->{base_sql_table};
2109 }
2110  
2111 0 ▶sub cgi {
Subroutine cgi: not called CC=2 SCAR=17.9
Pod undocumented
2112 0 my ($self, $value) = @_;
2113 0 ▶ $self->{cgi} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2114 0 return $self->{cgi};
2115 }
2116  
2117 0 ▶sub cgi_params {
Subroutine cgi_params: not called CC=2 SCAR=17.9
Pod undocumented
2118 0 my ($self, $value) = @_;
2119 0 ▶ $self->{cgi_params} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2120 0 return $self->{cgi_params};
2121 }
2122  
2123 0 ▶sub cookie {
Subroutine cookie: not called CC=2 SCAR=17.9
Pod undocumented
2124 0 my ($self, $value) = @_;
2125 0 ▶ $self->{cookie} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2126 0 return $self->{cookie};
2127 }
2128  
2129 0 ▶sub cookie_expires_in_min {
Subroutine cookie_expires_in_min: not called CC=2 SCAR=17.9
Pod undocumented
2130 0 my ($self, $value) = @_;
2131 0 ▶ $self->{cookie_expires_in_min} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2132 0 return $self->{cookie_expires_in_min};
2133 }
2134  
2135 0 ▶sub count {
Subroutine count: not called CC=2 SCAR=17.9
Pod undocumented
2136 0 my ($self, $value) = @_;
2137 0 ▶ $self->{count} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2138 0 return $self->{count};
2139 }
2140  
2141 0 ▶sub count_sql_statement {
Subroutine count_sql_statement: not called CC=2 SCAR=17.9
Pod undocumented
2142 0 my ($self, $value) = @_;
2143 0 ▶ $self->{count_sql_statement} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2144 0 return $self->{count_sql_statement};
2145 }
2146  
2147 0 ▶sub css {
Subroutine css: not called CC=2 SCAR=17.9
Pod undocumented
2148 0 my ($self, $value) = @_;
2149 0 ▶ $self->{css} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2150 0 return $self->{css};
2151 }
2152  
2153 0 ▶sub data {
Subroutine data: not called CC=2 SCAR=17.9
Pod undocumented
2154 0 my ($self, $value) = @_;
2155 0 ▶ $self->{data} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2156 0 return $self->{data};
2157 }
2158  
2159 0 ▶sub db_access_params {
Subroutine db_access_params: not called CC=2 SCAR=17.9
Pod undocumented
2160 0 my ($self, $value) = @_;
2161 0 ▶ $self->{db_access_params} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2162 0 return $self->{db_access_params};
2163 }
2164  
2165 0 ▶sub db_display {
Subroutine db_display: not called CC=2 SCAR=17.9
Pod undocumented
2166 0 my ($self, $value) = @_;
2167 0 ▶ $self->{db_display} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2168 0 return $self->{db_display};
2169 }
2170  
2171 0 ▶sub dbh {
Subroutine dbh: not called CC=2 SCAR=17.9
Pod undocumented
2172 0 my ($self, $value) = @_;
2173 0 ▶ $self->{dbh} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2174 0 return $self->{dbh};
2175 }
2176  
2177 0 ▶sub db_selected {
Subroutine db_selected: not called CC=2 SCAR=17.9
Pod undocumented
2178 0 my ($self, $value) = @_;
2179 0 ▶ $self->{db_selected} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2180 0 return $self->{db_selected};
2181 }
2182  
2183 0 ▶sub debug_info {
Subroutine debug_info: not called CC=2 SCAR=17.9
Pod undocumented
2184 0 my ($self, $value) = @_;
2185 0 ▶ $self->{debug_info} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2186 0 return $self->{debug_info};
2187 }
2188  
2189 0 ▶sub debug_level {
Subroutine debug_level: not called CC=2 SCAR=17.9
Pod undocumented
2190 0 my ($self, $value) = @_;
2191 0 ▶ $self->{debug_level} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2192 0 return $self->{debug_level};
2193 }
2194  
2195 0 ▶sub distinct {
Subroutine distinct: not called CC=2 SCAR=17.9
Pod undocumented
2196 0 my ($self, $value) = @_;
2197 0 ▶ $self->{distinct} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2198 0 return $self->{distinct};
2199 }
2200  
2201 0 ▶sub external_where_clauses {
Subroutine external_where_clauses: not called CC=2 SCAR=17.9
Pod undocumented
2202 0 my ($self, $value) = @_;
2203 0 ▶ $self->{external_where_clauses} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2204 0 return $self->{external_where_clauses};
2205 }
2206  
2207 0 ▶sub footer {
Subroutine footer: not called CC=2 SCAR=17.9
Pod undocumented
2208 0 my ($self, $value) = @_;
2209 0 ▶ $self->{footer} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2210 0 return $self->{footer};
2211 }
2212  
2213 0 ▶sub formatted_data {
Subroutine formatted_data: not called CC=2 SCAR=17.9
Pod undocumented
2214 0 my ($self, $value) = @_;
2215 0 ▶ $self->{formatted_data} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2216 0 return $self->{formatted_data};
2217 }
2218  
2219 0 ▶sub go_to_results {
Subroutine go_to_results: not called CC=2 SCAR=17.9
Pod undocumented
2220 0 my ($self, $value) = @_;
2221 0 ▶ $self->{go_to_results} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2222 0 return $self->{go_to_results};
2223 }
2224  
2225 0 ▶sub group_by {
Subroutine group_by: not called CC=2 SCAR=17.9
Pod undocumented
2226 0 my ($self, $value) = @_;
2227 0 ▶ $self->{group_by} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2228 0 return $self->{group_by};
2229 }
2230  
2231 0 ▶sub header {
Subroutine header: not called CC=2 SCAR=17.9
Pod undocumented
2232 0 my ($self, $value) = @_;
2233 0 ▶ $self->{header} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2234 0 return $self->{header};
2235 }
2236  
2237 0 ▶sub instructions {
Subroutine instructions: not called CC=2 SCAR=17.9
Pod undocumented
2238 0 my ($self, $value) = @_;
2239 0 ▶ $self->{instructions} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2240 0 return $self->{instructions};
2241 }
2242  
2243 0 ▶sub method {
Subroutine method: not called CC=2 SCAR=17.9
Pod undocumented
2244 0 my ($self, $value) = @_;
2245 0 ▶ $self->{method} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2246 0 return $self->{method};
2247 }
2248  
2249 0 ▶sub modifications {
Subroutine modifications: not called CC=2 SCAR=17.9
Pod undocumented
2250 0 my ($self, $value) = @_;
2251 0 ▶ $self->{modifications} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2252 0 return $self->{modifications};
2253 }
2254  
2255 0 ▶sub modifier {
Subroutine modifier: not called CC=2 SCAR=17.9
Pod undocumented
2256 0 my ($self, $value) = @_;
2257 0 ▶ $self->{modifier} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2258 0 return $self->{modifier};
2259 }
2260  
2261 0 ▶sub new_search {
Subroutine new_search: not called CC=2 SCAR=17.9
Pod undocumented
2262 0 my ($self, $value) = @_;
2263 0 ▶ $self->{new_search} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2264 0 return $self->{new_search};
2265 }
2266  
2267 0 ▶sub no_reset {
Subroutine no_reset: not called CC=2 SCAR=17.9
Pod undocumented
2268 0 my ($self, $value) = @_;
2269 0 ▶ $self->{no_reset} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2270 0 return $self->{no_reset};
2271 }
2272  
2273 0 ▶sub page_size {
Subroutine page_size: not called CC=2 SCAR=17.9
Pod undocumented
2274 0 my ($self, $value) = @_;
2275 0 ▶ $self->{page_size} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2276 0 return $self->{page_size};
2277 }
2278  
2279 0 ▶sub page_title {
Subroutine page_title: not called CC=2 SCAR=17.9
Pod undocumented
2280 0 my ($self, $value) = @_;
2281 0 ▶ $self->{page_title} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2282 0 return $self->{page_title};
2283 }
2284  
2285 0 ▶sub param_fields {
Subroutine param_fields: not called CC=2 SCAR=17.9
Pod undocumented
2286 0 my ($self, $value) = @_;
2287 0 ▶ $self->{param_fields} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2288 0 return $self->{param_fields};
2289 }
2290  
2291 0 ▶sub query_sql_statement {
Subroutine query_sql_statement: not called CC=2 SCAR=17.9
Pod undocumented
2292 0 my ($self, $value) = @_;
2293 0 ▶ $self->{query_sql_statement} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2294 0 return $self->{query_sql_statement};
2295 }
2296  
2297 0 ▶sub search_form {
Subroutine search_form: not called CC=2 SCAR=17.9
Pod undocumented
2298 0 my ($self, $value) = @_;
2299 0 ▶ $self->{search_form} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2300 0 return $self->{search_form};
2301 }
2302  
2303 0 ▶sub session {
Subroutine session: not called CC=2 SCAR=17.9
Pod undocumented
2304 0 my ($self, $value) = @_;
2305 0 ▶ $self->{session} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2306 0 return $self->{session};
2307 }
2308  
2309 0 ▶sub session_id {
Subroutine session_id: not called CC=2 SCAR=17.9
Pod undocumented
2310 0 my ($self, $value) = @_;
2311 0 ▶ $self->{session_id} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2312 0 return $self->{session_id};
2313 }
2314  
2315 0 ▶sub show_search_url {
Subroutine show_search_url: not called CC=2 SCAR=17.9
Pod undocumented
2316 0 my ($self, $value) = @_;
2317 0 ▶ $self->{show_search_url} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2318 0 return $self->{show_search_url};
2319 }
2320  
2321 0 ▶sub sort_defaults {
Subroutine sort_defaults: not called CC=2 SCAR=17.9
Pod undocumented
2322 0 my ($self, $value) = @_;
2323 0 ▶ $self->{sort_defaults} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2324 0 return $self->{sort_defaults};
2325 }
2326  
2327 0 ▶sub sort_fields {
Subroutine sort_fields: not called CC=2 SCAR=17.9
Pod undocumented
2328 0 my ($self, $value) = @_;
2329 0 ▶ $self->{sort_fields} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2330 0 return $self->{sort_fields};
2331 }
2332  
2333 0 ▶sub super_output_headers {
Subroutine super_output_headers: not called CC=2 SCAR=17.9
Pod undocumented
2334 0 my ($self, $value) = @_;
2335 0 ▶ $self->{super_output_headers} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2336 0 return $self->{super_output_headers};
2337 }
2338  
2339 0 ▶sub temp_dir {
Subroutine temp_dir: not called CC=2 SCAR=17.9
Pod undocumented
2340 0 my ($self, $value) = @_;
2341 0 ▶ $self->{temp_dir} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2342 0 return $self->{temp_dir};
2343 }
2344  
2345 0 ▶sub temp_dir_eq {
Subroutine temp_dir_eq: not called CC=2 SCAR=17.9
Pod undocumented
2346 0 my ($self, $value) = @_;
2347 0 ▶ $self->{temp_dir_eq} = $value if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
2348 0 return $self->{temp_dir_eq};
2349 }
2350  
2351 1 1;
2352  
2353 __END__
↑ Summary SearchPage/Param.pm »