3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
30 my $type=$query->param('type');
32 #(-e "opac") && ($type='opac');
34 my ($loggedinuser, $cookie, $sessionID) = checkauth
($query, ($type eq 'opac') ?
(1) : (0));
36 my $startfrom=$query->param('startfrom');
37 ($startfrom) || ($startfrom=0);
39 my $subject=$query->param('subject');
41 # if it's a subject we need to use the subject.tmpl
43 $template = gettemplate
("catalogue/subject.tmpl",0);
45 $template = gettemplate
("catalogue/searchresults.tmpl", 0);
49 # Additional parameters for &catalogsearch
51 itemcount
=> 1, # If set to 1, &catalogsearch enumerates
52 # the results found and returns the number
53 # of items found, where they're located,
57 # get all the search variables
58 # we assume that C4::Search will validate these values for us
59 my %search; # Search terms. If the key is "author",
60 # then $search{author} is the author the
61 # user is looking for.
63 my @forminputs; # This is used in the form template.
65 foreach my $term (qw(keyword subject author illustrator itemnumber
66 isbn date-before class dewey branch title abstract
69 my $value = $query->param($term);
71 next unless defined $value && $value ne "";
72 # Skip blank search terms
73 $search{$term} = $value;
74 push @forminputs, { line
=> "$term=$value" };
77 $template->param(FORMINPUTS
=> \
@forminputs);
80 # I think it is (or was) a search from the "front" page... [st]
81 $search{'front'}=$query->param('front');
86 if (my $subject=$query->param('subjectitems')) {
88 @results=subsearch
(\
$blah,$subject);
91 ($count,@results)=catalogsearch
(\
%env,'',\
%search,$num,$startfrom);
94 #my $resultsarray=\@results;
97 foreach my $result (@results) {
98 $result->{'authorhtmlescaped'}=$result->{'author'};
99 $result->{'authorhtmlescaped'}=~s/ /%20/g;
100 ($result->{'copyrightdate'}==0) && ($result->{'copyrightdate'}='');
101 ($type eq 'opac') ?
($result->{'opac'}=1) : ($result->{'opac'}=0);
102 push (@
$resultsarray, $result);
104 ($resultsarray) || (@
$resultsarray=());
107 if ($search{"keyword"}) {
108 $search .= "&keyword=$search{keyword}";
109 $searchdesc.="keyword $search{keyword}, ";
111 if (my $subjectitems=$query->param('subjectitems')){
112 $search .= "&subjectitems=$subjectitems";
113 $searchdesc.="subject $subjectitems, ";
116 $search .= "&subject=$subject";
117 $searchdesc.="subject $subject, ";
119 if ($search{"author"}){
120 $search .= "&author=$search{author}";
121 $searchdesc.="author $search{author}, ";
123 if ($search{"class"}){
124 $search .= "&class=$search{class}";
125 $searchdesc.="class $search{class}, ";
127 if ($search{"title"}){
128 $search .= "&title=$search{title}";
129 $searchdesc.="title $search{title}, ";
131 if ($search{"dewey"}){
132 $search .= "&dewey=$search{dewey}";
133 $searchdesc.="dewey $search{dewey}, ";
135 $search.="&ttype=$search{ttype}";
138 $template->param(startfrom
=> $startfrom+1);
139 ($startfrom+$num<=$count) ?
($template->param(endat
=> $startfrom+$num)) : ($template->param(endat
=> $count));
140 $template->param(numrecords
=> $count);
141 my $nextstartfrom=($startfrom+$num<$count) ?
($startfrom+$num) : (-1);
142 my $prevstartfrom=($startfrom-$num>=0) ?
($startfrom-$num) : (-1);
143 $template->param(nextstartfrom
=> $nextstartfrom);
146 ($nextstartfrom==-1) ?
($displaynext=0) : ($displaynext=1);
147 ($prevstartfrom==-1) ?
($displayprev=0) : ($displayprev=1);
148 $template->param(displaynext
=> $displaynext);
149 $template->param(displayprev
=> $displayprev);
150 ($type eq 'opac') ?
($template->param(opac
=> 1)) : ($template->param(opac
=> 0));
151 $template->param(prevstartfrom
=> $prevstartfrom);
152 $template->param(search
=> $search);
153 $template->param(searchdesc
=> $searchdesc);
154 $template->param(SEARCH_RESULTS
=> $resultsarray);
155 #$template->param(includesdir => $includes);
156 $template->param(loggedinuser
=> $loggedinuser);
160 for (my $i=1; $i<$count/10+1; $i++) {
162 if ($search{"title"})
164 push @forminputs, { line
=> "title=$search{title}"};
167 ($startfrom==($i-1)*10) && ($highlight=1);
169 foreach (@forminputs) {
171 $formelements.="$line&";
173 $formelements=~s/ /+/g;
174 push @numbers, { number
=> $i, highlight
=> $highlight , FORMELEMENTS
=> $formelements, FORMINPUTS
=> \
@forminputs, startfrom
=> ($i-1)*10, opac
=> (($type eq 'opac') ?
(1) : (0))};
179 $template->param(numbers
=> \
@numbers);
180 if (C4
::Context
->preference('acquisitions') eq 'simple') {
181 $template->param(script
=> "MARCdetail.pl");
183 $template->param(script
=> "detail.pl");
187 print $query->header(-cookie
=> $cookie), $template->output;