|
Lines 20-26
Link Here
|
| 20 |
# - we delete the record having primkey=$primkey |
20 |
# - we delete the record having primkey=$primkey |
| 21 |
|
21 |
|
| 22 |
use strict; |
22 |
use strict; |
| 23 |
#use warnings; FIXME - Bug 2505 |
23 |
use warnings; |
| 24 |
use CGI; |
24 |
use CGI; |
| 25 |
use C4::Context; |
25 |
use C4::Context; |
| 26 |
use C4::Auth; |
26 |
use C4::Auth; |
|
Lines 29-44
use C4::Output;
Link Here
|
| 29 |
sub StringSearch { |
29 |
sub StringSearch { |
| 30 |
my ($searchstring,$type)=@_; |
30 |
my ($searchstring,$type)=@_; |
| 31 |
my $dbh = C4::Context->dbh; |
31 |
my $dbh = C4::Context->dbh; |
| 32 |
$searchstring=~ s/\'/\\\'/g; |
32 |
my @data = ('%'); |
| 33 |
my @data=split(' ',$searchstring); |
33 |
my $count = 1; |
| 34 |
my $count=@data; |
34 |
if ( defined $searchstring ) { |
| 35 |
my $sth=$dbh->prepare("Select host,port,db,userid,password,name,id,checked,rank,syntax,encoding from z3950servers where (name like ?) order by rank,name"); |
35 |
$searchstring =~ s/\'/\\\'/g; |
| 36 |
$sth->execute("$data[0]\%"); |
36 |
@data=split(' ',$searchstring); |
|
|
37 |
$count=@data; |
| 38 |
} |
| 39 |
else { |
| 40 |
$searchstring = ''; |
| 41 |
} |
| 42 |
|
| 43 |
my $query = "SELECT host,port,db,userid,password,name,id,checked,rank,syntax,encoding"; |
| 44 |
$query .= " FROM z3950servers"; |
| 45 |
if ( $searchstring ne '' ) { $query .= " WHERE (name like ?)" } |
| 46 |
$query .= " ORDER BY rank,name"; |
| 47 |
my $sth=$dbh->prepare($query); |
| 48 |
|
| 49 |
if ( $searchstring ne '' ) { |
| 50 |
$sth->execute("$data[0]\%"); |
| 51 |
} |
| 52 |
else { |
| 53 |
$sth->execute; |
| 54 |
} |
| 37 |
my @results; |
55 |
my @results; |
| 38 |
while (my $data=$sth->fetchrow_hashref) { |
56 |
while (my $data=$sth->fetchrow_hashref) { |
| 39 |
push(@results,$data); |
57 |
push(@results,$data); |
| 40 |
} |
58 |
} |
| 41 |
# $sth->execute; |
|
|
| 42 |
$sth->finish; |
59 |
$sth->finish; |
| 43 |
$dbh->disconnect; |
60 |
$dbh->disconnect; |
| 44 |
return (scalar(@results),\@results); |
61 |
return (scalar(@results),\@results); |
|
Lines 46-56
sub StringSearch {
Link Here
|
| 46 |
|
63 |
|
| 47 |
my $input = new CGI; |
64 |
my $input = new CGI; |
| 48 |
my $searchfield=$input->param('searchfield'); |
65 |
my $searchfield=$input->param('searchfield'); |
| 49 |
my $offset=$input->param('offset'); |
66 |
my $offset=$input->param('offset') || 0; |
| 50 |
my $script_name="/cgi-bin/koha/admin/z3950servers.pl"; |
67 |
my $script_name="/cgi-bin/koha/admin/z3950servers.pl"; |
| 51 |
|
68 |
|
| 52 |
my $pagesize=20; |
69 |
my $pagesize=20; |
| 53 |
my $op = $input->param('op'); |
70 |
my $op = $input->param('op') || ''; |
| 54 |
|
71 |
|
| 55 |
my ($template, $loggedinuser, $cookie) |
72 |
my ($template, $loggedinuser, $cookie) |
| 56 |
= get_template_and_user({template_name => "admin/z3950servers.tmpl", |
73 |
= get_template_and_user({template_name => "admin/z3950servers.tmpl", |
|
Lines 119-125
if ($op eq 'add_form') {
Link Here
|
| 119 |
$input->param( 'userid' ), |
136 |
$input->param( 'userid' ), |
| 120 |
$input->param( 'password' ), |
137 |
$input->param( 'password' ), |
| 121 |
$input->param( 'searchfield' ), |
138 |
$input->param( 'searchfield' ), |
| 122 |
$input->param( 'checked' ), |
139 |
$checked, |
| 123 |
$input->param( 'rank' ), |
140 |
$input->param( 'rank' ), |
| 124 |
$input->param( 'syntax' ), |
141 |
$input->param( 'syntax' ), |
| 125 |
$input->param( 'encoding' ) ); |
142 |
$input->param( 'encoding' ) ); |
|
Lines 162-169
if ($op eq 'add_form') {
Link Here
|
| 162 |
$template->param(else => 1); |
179 |
$template->param(else => 1); |
| 163 |
my ($count,$results)=StringSearch($searchfield,'web'); |
180 |
my ($count,$results)=StringSearch($searchfield,'web'); |
| 164 |
my @loop; |
181 |
my @loop; |
|
|
182 |
|
| 165 |
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ |
183 |
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ |
| 166 |
|
|
|
| 167 |
my $urlsearchfield=$results->[$i]{name}; |
184 |
my $urlsearchfield=$results->[$i]{name}; |
| 168 |
$urlsearchfield=~s/ /%20/g; |
185 |
$urlsearchfield=~s/ /%20/g; |
| 169 |
my %row = ( name => $results->[$i]{'name'}, |
186 |
my %row = ( name => $results->[$i]{'name'}, |
| 170 |
- |
|
|