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 with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
27 use C4
::AuthoritiesMarc
;
29 use C4
::Koha
; # XXX subfield_is_koha_internal_p
32 my $op = $query->param('op');
33 my $authtypecode = $query->param('authtypecode');
34 my $index = $query->param('index');
35 my $tagid = $query->param('tagid');
36 my $resultstring = $query->param('result');
37 my $dbh = C4
::Context
->dbh;
39 my $startfrom = $query->param('startfrom');
40 $startfrom = 0 if ( !defined $startfrom );
41 my ( $template, $loggedinuser, $cookie );
44 my $authtypes = getauthtypes
;
46 foreach my $thisauthtype ( keys %$authtypes ) {
47 my $selected = 1 if $thisauthtype eq $authtypecode;
49 value
=> $thisauthtype,
50 selected
=> $selected,
51 authtypetext
=> $authtypes->{$thisauthtype}{'authtypetext'},
54 push @authtypesloop, \
%row;
57 if ( $op eq "do_search" ) {
58 my @marclist = $query->param('marclist');
59 my @and_or = $query->param('and_or');
60 my @excluding = $query->param('excluding');
61 my @operator = $query->param('operator');
62 my @value = ($query->param('value_mainstr'), $query->param('value_main'), $query->param('value_any'));
63 my $orderby = $query->param('orderby');
65 $resultsperpage = $query->param('resultsperpage');
66 $resultsperpage = 20 if ( !defined $resultsperpage );
68 my ( $results, $total ) =
69 SearchAuthorities
( \
@marclist, \
@and_or, \
@excluding, \
@operator, \
@value,
70 $startfrom * $resultsperpage,
71 $resultsperpage, $authtypecode, $orderby);
72 # multi page display gestion
74 my $displayprev = $startfrom;
75 if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
82 $query->param('marclist')
83 ; # get marclist again, as the previous one has been modified by catalogsearch (mainentry replaced by field name
84 for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
85 push @field_data, { term
=> "marclist", val
=> $marclist_ini[$i] };
86 push @field_data, { term
=> "and_or", val
=> $and_or[$i] };
87 push @field_data, { term
=> "excluding", val
=> $excluding[$i] };
88 push @field_data, { term
=> "operator", val
=> $operator[$i] };
91 push @field_data, { term
=> "value_mainstr", val
=> $query->param('value_mainstr') || "" };
92 push @field_data, { term
=> "value_main", val
=> $query->param('value_main') || "" };
93 push @field_data, { term
=> "value_any", val
=> $query->param('value_any') || ""};
97 if ( $total > $resultsperpage ) {
98 for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
101 ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
105 highlight
=> $highlight,
106 searchdata
=> \
@field_data,
107 startfrom
=> ( $i - 1 )
113 my $from = $startfrom * $resultsperpage + 1;
116 if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
120 $to = ( ( $startfrom + 1 ) * $resultsperpage );
122 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
124 template_name
=> "authorities/searchresultlist-auth.tmpl",
127 authnotrequired
=> 0,
128 flagsrequired
=> { catalogue
=> 1 },
132 $template->param( result
=> $results ) if $results;
135 startfrom
=> $startfrom,
136 displaynext
=> $displaynext,
137 displayprev
=> $displayprev,
138 resultsperpage
=> $resultsperpage,
139 startfromnext
=> $startfrom + 1,
140 startfromprev
=> $startfrom - 1,
141 searchdata
=> \
@field_data,
145 numbers
=> \
@numbers,
146 authtypecode
=> $authtypecode,
147 value_mainstr
=> $query->param('value_mainstr') || "",
148 value_main
=> $query->param('value_main') || "",
149 value_any
=> $query->param('value_any') || "",
152 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
154 template_name
=> "authorities/auth_finder.tmpl",
157 authnotrequired
=> 0,
158 flagsrequired
=> { catalogue
=> 1 },
163 resultstring
=> $resultstring,
170 authtypesloop
=> \
@authtypesloop,
171 authtypecode
=> $authtypecode,
172 value_mainstr
=> $query->param('value_mainstr') || "",
173 value_main
=> $query->param('value_main') || "",
174 value_any
=> $query->param('value_any') || "",
178 output_html_with_http_headers
$query, $cookie, $template->output;