Add pl-PL to syspref test
[koha.git] / authorities / auth_finder.pl
blob9f183a5fb27d708f2a93241ce77b8fd2c0bf2213
1 #!/usr/bin/perl
2 # WARNING: 4-character tab stops here
4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
21 use strict;
22 use warnings;
24 use CGI;
25 use C4::Output;
26 use C4::Auth;
27 use C4::Context;
28 use C4::AuthoritiesMarc;
29 use C4::Acquisition;
30 use C4::Koha; # XXX subfield_is_koha_internal_p
32 my $query = new CGI;
33 my $op = $query->param('op');
34 my $authtypecode = $query->param('authtypecode');
35 my $index = $query->param('index');
36 my $tagid = $query->param('tagid');
37 my $resultstring = $query->param('result');
38 my $dbh = C4::Context->dbh;
40 my $startfrom = $query->param('startfrom');
41 $startfrom = 0 if ( !defined $startfrom );
42 my ( $template, $loggedinuser, $cookie );
43 my $resultsperpage;
45 my $authtypes = getauthtypes;
46 my @authtypesloop;
47 foreach my $thisauthtype ( keys %$authtypes ) {
48 my %row = (
49 value => $thisauthtype,
50 selected => ($thisauthtype eq $authtypecode),
51 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
52 index => $index,
54 push @authtypesloop, \%row;
57 $op ||= q{};
58 if ( $op eq "do_search" ) {
59 my @marclist = $query->param('marclist');
60 my @and_or = $query->param('and_or');
61 my @excluding = $query->param('excluding');
62 my @operator = $query->param('operator');
63 my @value = ($query->param('value_mainstr'), $query->param('value_main'), $query->param('value_any'));
64 my $orderby = $query->param('orderby');
66 $resultsperpage = $query->param('resultsperpage');
67 $resultsperpage = 20 if ( !defined $resultsperpage );
69 my ( $results, $total ) =
70 SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value,
71 $startfrom * $resultsperpage,
72 $resultsperpage, $authtypecode, $orderby);
73 # multi page display gestion
74 my $displaynext = 0;
75 my $displayprev = $startfrom;
76 if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
77 $displaynext = 1;
80 my @field_data = ();
82 my @marclist_ini =
83 $query->param('marclist')
84 ; # get marclist again, as the previous one has been modified by catalogsearch (mainentry replaced by field name
85 for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
86 push @field_data, { term => "marclist", val => $marclist_ini[$i] };
87 push @field_data, { term => "and_or", val => $and_or[$i] };
88 push @field_data, { term => "excluding", val => $excluding[$i] };
89 push @field_data, { term => "operator", val => $operator[$i] };
92 push @field_data, { term => "value_mainstr", val => $query->param('value_mainstr') || "" };
93 push @field_data, { term => "value_main", val => $query->param('value_main') || "" };
94 push @field_data, { term => "value_any", val => $query->param('value_any') || ""};
96 my @numbers = ();
98 if ( $total > $resultsperpage ) {
99 for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
100 if ( $i < 16 ) {
101 my $highlight = 0;
102 ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
103 push @numbers,
105 number => $i,
106 highlight => $highlight,
107 searchdata => \@field_data,
108 startfrom => ( $i - 1 )
114 my $from = $startfrom * $resultsperpage + 1;
115 my $to;
117 if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
118 $to = $total;
120 else {
121 $to = ( ( $startfrom + 1 ) * $resultsperpage );
123 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
125 template_name => "authorities/searchresultlist-auth.tmpl",
126 query => $query,
127 type => 'intranet',
128 authnotrequired => 0,
129 flagsrequired => { catalogue => 1 },
133 $template->param( result => $results ) if $results;
134 $template->param(
135 orderby => $orderby,
136 startfrom => $startfrom,
137 displaynext => $displaynext,
138 displayprev => $displayprev,
139 resultsperpage => $resultsperpage,
140 startfromnext => $startfrom + 1,
141 startfromprev => $startfrom - 1,
142 searchdata => \@field_data,
143 total => $total,
144 from => $from,
145 to => $to,
146 numbers => \@numbers,
147 authtypecode => $authtypecode,
148 value_mainstr => $query->param('value_mainstr') || "",
149 value_main => $query->param('value_main') || "",
150 value_any => $query->param('value_any') || "",
152 } else {
153 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
155 template_name => "authorities/auth_finder.tmpl",
156 query => $query,
157 type => 'intranet',
158 authnotrequired => 0,
159 flagsrequired => { catalogue => 1 },
163 $template->param(
164 resultstring => $resultstring,
168 $template->param(
169 tagid => $tagid,
170 index => $index,
171 authtypesloop => \@authtypesloop,
172 authtypecode => $authtypecode,
173 value_mainstr => $query->param('value_mainstr') || "",
174 value_main => $query->param('value_main') || "",
175 value_any => $query->param('value_any') || "",
178 # Print the page
179 output_html_with_http_headers $query, $cookie, $template->output;
181 # Local Variables:
182 # tab-width: 4
183 # End: