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
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
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 use C4
::AuthoritiesMarc
;
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 $source = $query->param('source') || '';
38 my $relationship = $query->param('relationship') || '';
40 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
42 template_name
=> ( $op eq 'do_search' )
43 ?
'authorities/searchresultlist-auth.tt'
44 : 'authorities/auth_finder.tt',
48 flagsrequired
=> { catalogue
=> 1 },
52 # Authority types loop
53 my $authtypes = C4
::Koha
::getauthtypes
();
55 foreach my $thisauthtype ( keys %$authtypes ) {
57 value
=> $thisauthtype,
58 selected
=> ( $thisauthtype eq $authtypecode ),
59 authtypetext
=> $authtypes->{$thisauthtype}{'authtypetext'},
62 push @authtypesloop, \
%row;
65 # If search form posted
66 if ( $op eq "do_search" ) {
67 my @marclist = $query->param('marclist');
68 my @and_or = $query->param('and_or');
69 my @excluding = $query->param('excluding');
70 my @operator = $query->param('operator');
72 $query->param('value_mainstr') || undef,
73 $query->param('value_main') || undef,
74 $query->param('value_any') || undef,
75 $query->param('value_match') || undef
77 my $orderby = $query->param('orderby') || '';
78 my $startfrom = $query->param('startfrom') || 0;
79 my $resultsperpage = $query->param('resultsperpage') || 20;
81 my ( $results, $total ) =
82 SearchAuthorities
( \
@marclist, \
@and_or, \
@excluding, \
@operator, \
@value,
83 $startfrom * $resultsperpage,
84 $resultsperpage, $authtypecode, $orderby );
86 # multi page display gestion
88 my $displayprev = $startfrom;
89 if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
95 # get marclist again, as the previous one has been modified by catalogsearch (mainentry replaced by field name)
96 my @marclist_ini = $query->param('marclist');
97 for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
98 push @field_data, { term
=> "marclist", val
=> $marclist_ini[$i] };
99 push @field_data, { term
=> "and_or", val
=> $and_or[$i] };
100 push @field_data, { term
=> "excluding", val
=> $excluding[$i] };
101 push @field_data, { term
=> "operator", val
=> $operator[$i] };
105 { term
=> "value_mainstr", val
=> $query->param('value_mainstr') || "" };
107 { term
=> "value_main", val
=> $query->param('value_main') || "" };
109 { term
=> "value_any", val
=> $query->param('value_any') || "" };
111 { term
=> "value_match", val
=> $query->param('value_match') || "" };
114 if ( $total > $resultsperpage ) {
115 for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
118 ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
122 highlight
=> $highlight,
123 searchdata
=> \
@field_data,
124 startfrom
=> ( $i - 1 )
130 my $from = $startfrom * $resultsperpage + 1;
132 if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
136 $to = ( ( $startfrom + 1 ) * $resultsperpage );
139 $template->param( result
=> $results ) if $results;
142 startfrom
=> $startfrom,
143 displaynext
=> $displaynext,
144 displayprev
=> $displayprev,
145 resultsperpage
=> $resultsperpage,
146 startfromnext
=> $startfrom + 1,
147 startfromprev
=> $startfrom - 1,
148 searchdata
=> \
@field_data,
152 numbers
=> \
@numbers,
153 operator_mainstr
=> ( @operator > 0 && $operator[0] )
156 operator_main
=> ( @operator > 1 && $operator[1] ) ?
$operator[1] : '',
157 operator_any
=> ( @operator > 2 && $operator[2] ) ?
$operator[2] : '',
158 operator_match
=> ( @operator > 3 && $operator[3] ) ?
$operator[3] : '',
163 # special case for UNIMARC field 210c builder
164 my $resultstring = $query->param('result') || '';
165 $template->param( resultstring
=> $resultstring, );
170 value_mainstr
=> $query->param('value_mainstr') || '',
171 value_main
=> $query->param('value_main') || '',
172 value_any
=> $query->param('value_any') || '',
173 value_match
=> $query->param('value_match') || '',
176 authtypesloop
=> \
@authtypesloop,
177 authtypecode
=> $authtypecode,
179 relationship
=> $relationship,
183 output_html_with_http_headers
$query, $cookie, $template->output;