line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::OptimalQuery; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
6348
|
use strict; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
226
|
|
4
|
8
|
|
|
8
|
|
35
|
use warnings; |
|
8
|
|
|
|
|
7
|
|
|
8
|
|
|
|
|
230
|
|
5
|
8
|
|
|
8
|
|
25
|
no warnings qw( uninitialized ); |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
289
|
|
6
|
8
|
|
|
8
|
|
5424
|
use CGI(); |
|
8
|
|
|
|
|
149830
|
|
|
8
|
|
|
|
|
216
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
8
|
|
|
8
|
|
66
|
use Exporter (); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
138
|
|
10
|
8
|
|
|
8
|
|
20
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
703
|
|
11
|
8
|
|
|
8
|
|
14
|
$VERSION = '0.22'; |
12
|
8
|
|
|
|
|
68
|
@ISA = qw(Exporter); |
13
|
|
|
|
|
|
|
#Give a hoot don't pollute, do not export more than needed by default |
14
|
8
|
|
|
|
|
12
|
@EXPORT = qw(); |
15
|
8
|
|
|
|
|
11
|
@EXPORT_OK = qw(); |
16
|
8
|
|
|
|
|
5054
|
%EXPORT_TAGS = (); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# module registry - when loading a sub module, the module CGI param is |
21
|
|
|
|
|
|
|
# consulted, and the value is loaded as a module. |
22
|
|
|
|
|
|
|
our $DEFAULT_MODULE = 'InteractiveQuery2'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our %DEFAULT_MODULES = ( |
25
|
|
|
|
|
|
|
'CustomOutput' => 'CGI::OptimalQuery::CustomOutput', |
26
|
|
|
|
|
|
|
'PrinterFriendly' => 'CGI::OptimalQuery::PrinterFriendly', |
27
|
|
|
|
|
|
|
'CSV' => 'CGI::OptimalQuery::CSV', |
28
|
|
|
|
|
|
|
'InteractiveFilter' => 'CGI::OptimalQuery::InteractiveFilter', |
29
|
|
|
|
|
|
|
'InteractiveQuery' => 'CGI::OptimalQuery::InteractiveQuery', |
30
|
|
|
|
|
|
|
'XML' => 'CGI::OptimalQuery::XML', |
31
|
|
|
|
|
|
|
'JSON' => 'CGI::OptimalQuery::JSON', |
32
|
|
|
|
|
|
|
'InteractiveQuery2' => 'CGI::OptimalQuery::InteractiveQuery2', |
33
|
|
|
|
|
|
|
'InteractiveFilter2' => 'CGI::OptimalQuery::InteractiveFilter2', |
34
|
|
|
|
|
|
|
'ShowColumns' => 'CGI::OptimalQuery::ShowColumns', |
35
|
|
|
|
|
|
|
'InteractiveQuery2Tools' => 'CGI::OptimalQuery::InteractiveQuery2Tools' |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Constructor |
40
|
|
|
|
|
|
|
# my $recset = CGI::OptimalQuery->new(\%schema ) |
41
|
|
|
|
|
|
|
# This constructor instantiates the correct class based on the module param. |
42
|
|
|
|
|
|
|
sub new { |
43
|
0
|
|
|
0
|
1
|
|
my $pack = shift; |
44
|
0
|
|
|
|
|
|
my $schema = $_[0]; |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
if ($CGI::OptimalQuery::q) { |
47
|
0
|
|
|
|
|
|
$$schema{q} = $CGI::OptimalQuery::q; |
48
|
|
|
|
|
|
|
} else { |
49
|
0
|
|
0
|
|
|
|
$$schema{q} ||= new CGI(); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# if this is a mod_perl query object, turn it into a CGI object |
53
|
0
|
0
|
|
|
|
|
if (! $$schema{q}->isa('CGI')) { |
54
|
0
|
|
|
|
|
|
my @names = $$schema{q}->param(); |
55
|
0
|
|
|
|
|
|
my %params; |
56
|
0
|
|
|
|
|
|
foreach my $p (@names) { |
57
|
0
|
|
|
|
|
|
my @v = $$schema{q}->param($p); |
58
|
0
|
|
|
|
|
|
$params{$p} = \@v; |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
|
$$schema{q} = new CGI(\%params); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# set default handlers |
64
|
0
|
|
0
|
0
|
|
|
$$schema{output_handler} ||= sub { print @_ }; |
|
0
|
|
|
|
|
|
|
65
|
0
|
|
0
|
0
|
|
|
$$schema{error_handler} ||= sub { print STDERR @_; 0; }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# find module & class |
68
|
0
|
|
0
|
|
|
|
my $module = $$schema{q}->param('module') || $$schema{module} || $DEFAULT_MODULE; |
69
|
0
|
|
0
|
|
|
|
my $class = $$schema{modules}{$module} || $DEFAULT_MODULES{$module}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# dynamically load class |
72
|
0
|
|
|
|
|
|
my $rv = eval "require $class"; |
73
|
0
|
0
|
|
|
|
|
if ($@ =~ /Not\ Found/) { die "Could not find class $class"; } |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
elsif ($@) { die "Compile Error in class $class: $@"; } |
75
|
0
|
|
|
|
|
|
elsif ($rv != 1) { die "Initialization error in class $class, should return 1"; } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# call appropriate constructor |
78
|
0
|
|
|
|
|
|
return $class->new(@_); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
0
|
0
|
|
sub escape_js { CGI::OptimalQuery::Base::escape_js(@_); } |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub get_saved_search_list { |
84
|
0
|
|
|
0
|
0
|
|
my $q = shift; |
85
|
0
|
|
|
|
|
|
my $dbh = shift; |
86
|
0
|
|
|
|
|
|
my $userid = shift; |
87
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
if ($q->param('OQ_remove_saved_search_id') =~ /^\d+$/) { |
89
|
0
|
|
|
|
|
|
$dbh->do("DELETE FROM oq_saved_search WHERE id = ? AND user_id = ?", undef, $q->param('OQ_remove_saved_search_id'), $userid); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $oracleReadLen; |
93
|
0
|
0
|
|
|
|
|
if ($$dbh{Driver}{Name} eq 'Oracle') { |
94
|
0
|
|
|
|
|
|
($oracleReadLen) = $dbh->selectrow_array("SELECT max(dbms_lob.getlength(params)) FROM oq_saved_search WHERE user_id = ?", undef, $userid); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
local $dbh->{LongReadLen} = $oracleReadLen |
97
|
0
|
0
|
0
|
|
|
|
if $oracleReadLen && $oracleReadLen > $dbh->{LongReadLen}; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare("SELECT id, uri, oq_title, user_title, params FROM oq_saved_search WHERE user_id = ? ORDER BY oq_title, user_title"); |
100
|
0
|
|
|
|
|
|
$sth->execute($userid); |
101
|
0
|
|
|
|
|
|
my $last_oq_title = ''; |
102
|
0
|
|
|
|
|
|
my $buffer = ''; |
103
|
0
|
|
|
|
|
|
while (my ($id, $uri, $oq_title, $user_title, $params) = $sth->fetchrow_array()) { |
104
|
0
|
0
|
|
|
|
|
if ($last_oq_title ne $oq_title) { |
105
|
0
|
|
|
|
|
|
$last_oq_title = $oq_title; |
106
|
0
|
0
|
|
|
|
|
$buffer .= " |
" if $buffer;