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');
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] };
89 push @field_data, { term
=> "value", val
=> $value[$i] };
94 if ( $total > $resultsperpage ) {
95 for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
98 ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
102 highlight
=> $highlight,
103 searchdata
=> \
@field_data,
104 startfrom
=> ( $i - 1 )
110 my $from = $startfrom * $resultsperpage + 1;
113 if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
117 $to = ( ( $startfrom + 1 ) * $resultsperpage );
119 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
121 template_name
=> "authorities/searchresultlist-auth.tmpl",
124 authnotrequired
=> 0,
125 flagsrequired
=> { catalogue
=> 1 },
129 $template->param( result
=> $results ) if $results;
132 startfrom
=> $startfrom,
133 displaynext
=> $displaynext,
134 displayprev
=> $displayprev,
135 resultsperpage
=> $resultsperpage,
136 startfromnext
=> $startfrom + 1,
137 startfromprev
=> $startfrom - 1,
138 searchdata
=> \
@field_data,
142 numbers
=> \
@numbers,
143 authtypecode
=> $authtypecode,
144 mainmainstring
=> $value[0],
145 mainstring
=> $value[1],
146 anystring
=> $value[2],
149 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
151 template_name
=> "authorities/auth_finder.tmpl",
154 authnotrequired
=> 0,
155 flagsrequired
=> { catalogue
=> 1 },
160 resultstring
=> $resultstring,
167 authtypesloop
=> \
@authtypesloop,
168 authtypecode
=> $authtypecode,
172 output_html_with_http_headers
$query, $cookie, $template->output;