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.
30 use C4
::AuthoritiesMarc
;
31 use C4
::Koha
; # XXX subfield_is_koha_internal_p
34 my $op = $query->param('op') || '';
35 my $authtypecode = $query->param('authtypecode') || '';
36 my $dbh = C4
::Context
->dbh;
38 my $startfrom = $query->param('startfrom');
39 my $authid = $query->param('authid');
40 $startfrom = 0 if ( !defined $startfrom );
41 my ( $template, $loggedinuser, $cookie );
44 my $authtypes = getauthtypes
();
45 my @authtypesloop = ();
46 foreach my $thisauthtype (
48 $authtypes->{$a}->{'authtypetext'}
49 cmp $authtypes->{$b}->{'authtypetext'}
54 { value
=> $thisauthtype,
55 selected
=> $thisauthtype eq $authtypecode,
56 authtypetext
=> $authtypes->{$thisauthtype}->{'authtypetext'},
60 if ( $op eq "do_search" ) {
61 my @marclist = ($query->param('marclist'));
62 my @and_or = ($query->param('and_or'));
63 my @excluding = ($query->param('excluding'),);
64 my @operator = ($query->param('operator'));
65 my $orderby = $query->param('orderby');
66 my @value = ($query->param('value') || "",);
68 $resultsperpage = $query->param('resultsperpage');
69 $resultsperpage = 20 if ( !defined $resultsperpage );
71 my ( $results, $total, @fields ) =
72 SearchAuthorities
( \
@marclist, \
@and_or, \
@excluding, \
@operator,
73 \
@value, $startfrom * $resultsperpage,
74 $resultsperpage, $authtypecode, $orderby );
75 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
77 template_name
=> "opac-authoritiessearchresultlist.tmpl",
85 # multi page display gestion
87 my $displayprev = $startfrom;
89 if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
94 { term
=> "marclist", val
=> $marclist[0] },
95 { term
=> "and_or", val
=> $and_or[0] },
96 { term
=> "excluding", val
=> $excluding[0] },
97 { term
=> "operator", val
=> $operator[0] },
98 { term
=> "value", val
=> $value[0] },
103 if ( $total > $resultsperpage ) {
104 for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
107 ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
111 highlight
=> $highlight,
112 searchdata
=> \
@field_data,
113 startfrom
=> ( $i - 1 )
119 my $from = $startfrom * $resultsperpage + 1;
122 if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
126 $to = ( ( $startfrom + 1 ) * $resultsperpage );
128 unless (C4
::Context
->preference('OPACShowUnusedAuthorities')) {
129 my @usedauths = grep { $_->{used
} > 0 } @
$results;
130 $results = \
@usedauths;
132 $template->param( result
=> $results ) if $results;
133 $template->param( FIELDS
=> \
@fields );
134 $template->param( 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 countfuzzy
=> !(C4
::Context
->preference('OPACShowUnusedAuthorities')),
147 resultcount
=> scalar @
$results,
148 numbers
=> \
@numbers,
149 authtypecode
=> $authtypecode,
150 authtypetext
=> $authtypes->{$authtypecode}{'authtypetext'},
151 isEDITORS
=> $authtypecode eq 'EDITORS',
156 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
158 template_name
=> "opac-authorities-home.tmpl",
161 authnotrequired
=> ( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
168 $template->param( authtypesloop
=> \
@authtypesloop );
171 output_html_with_http_headers
$query, $cookie, $template->output;