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
;
30 use C4
::Koha
; # XXX subfield_is_koha_internal_p
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 );
45 my $authtypes = getauthtypes
;
47 foreach my $thisauthtype ( keys %$authtypes ) {
49 value
=> $thisauthtype,
50 selected
=> ($thisauthtype eq $authtypecode),
51 authtypetext
=> $authtypes->{$thisauthtype}{'authtypetext'},
54 push @authtypesloop, \
%row;
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')||undef, $query->param('value_main')||undef, $query->param('value_any')||undef, $query->param('value_match')||undef);
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);
74 # If an authority heading is repeated, add an arrayref to those repetions
75 # First heading -- Second heading
76 for my $heading ( @
$results ) {
77 my @repets = split / -- /, $heading->{summary
};
80 for (my $i = 0; $i < @repets; $i++) {
82 { index => $index, repet
=> $i+1, value
=> $repets[$i] };
84 $heading->{repets
} = \
@repets_loop;
87 # multi page display gestion
89 my $displayprev = $startfrom;
90 if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
97 $query->param('marclist')
98 ; # get marclist again, as the previous one has been modified by catalogsearch (mainentry replaced by field name
99 for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
100 push @field_data, { term
=> "marclist", val
=> $marclist_ini[$i] };
101 push @field_data, { term
=> "and_or", val
=> $and_or[$i] };
102 push @field_data, { term
=> "excluding", val
=> $excluding[$i] };
103 push @field_data, { term
=> "operator", val
=> $operator[$i] };
106 push @field_data, { term
=> "value_mainstr", val
=> $query->param('value_mainstr') || "" };
107 push @field_data, { term
=> "value_main", val
=> $query->param('value_main') || "" };
108 push @field_data, { term
=> "value_any", val
=> $query->param('value_any') || ""};
109 push @field_data, { term
=> "value_match", val
=> $query->param('value_match') || ""};
113 if ( $total > $resultsperpage ) {
114 for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
117 ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
121 highlight
=> $highlight,
122 searchdata
=> \
@field_data,
123 startfrom
=> ( $i - 1 )
129 my $from = $startfrom * $resultsperpage + 1;
132 if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
136 $to = ( ( $startfrom + 1 ) * $resultsperpage );
138 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
140 template_name
=> "authorities/searchresultlist-auth.tt",
143 authnotrequired
=> 0,
144 flagsrequired
=> { catalogue
=> 1 },
148 $template->param( result
=> $results ) if $results;
151 startfrom
=> $startfrom,
152 displaynext
=> $displaynext,
153 displayprev
=> $displayprev,
154 resultsperpage
=> $resultsperpage,
155 startfromnext
=> $startfrom + 1,
156 startfromprev
=> $startfrom - 1,
157 searchdata
=> \
@field_data,
161 numbers
=> \
@numbers,
162 authtypecode
=> $authtypecode,
163 value_mainstr
=> $query->param('value_mainstr') || "",
164 value_main
=> $query->param('value_main') || "",
165 value_any
=> $query->param('value_any') || "",
166 value_match
=> $query->param('value_match') || "",
169 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
171 template_name
=> "authorities/auth_finder.tt",
174 authnotrequired
=> 0,
175 flagsrequired
=> { catalogue
=> 1 },
180 resultstring
=> $resultstring,
185 value_mainstr
=> $query->param('value_mainstr') || "",
186 value_main
=> $query->param('value_main') || "",
187 value_any
=> $query->param('value_any') || "",
188 value_match
=> $query->param('value_match') || "",
191 authtypesloop
=> \
@authtypesloop,
192 authtypecode
=> $authtypecode,
196 output_html_with_http_headers
$query, $cookie, $template->output;