3 #script to provide intranet (librarian) advanced search facility
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA 02111-1307 USA
32 my $includes = C4::Context->config('includes') ||
33 "/usr/local/www/hdl/htdocs/includes";
34 #my $templatebase="catalogue/searchresults.tmpl";
35 my $startfrom=$query->param('startfrom');
36 ($startfrom) || ($startfrom=0);
37 #my $theme=picktemplate($includes, $templatebase);
39 my $subject=$query->param('subject');
40 # if its a subject we need to use the subject.tmpl
43 $template = gettemplate("catalogue/subject.tmpl")
44 # $templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
45 # $theme=picktemplate($includes, $templatebase);
47 $template = gettemplate("catalogue/searchresults.tmpl")
50 #my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
55 # get all the search variables
56 # we assume that C4::Search will validate these values for us
57 # FIXME - This whole section, up to the &catalogsearch call, is crying
59 # foreach $search_term (qw(keyword subject author ...))
62 my $keyword=$query->param('keyword');
63 $search{'keyword'}=$keyword;
65 $search{'subject'}=$subject;
66 my $author=$query->param('author');
67 $search{'author'}=$author;
68 my $illustrator=$query->param('illustrator');
69 $search{'param'}=$illustrator;
70 my $itemnumber=$query->param('itemnumber');
71 $search{'itemnumber'}=$itemnumber;
72 my $isbn=$query->param('isbn');
73 $search{'isbn'}=$isbn;
74 my $datebefore=$query->param('date-before');
75 $search{'date-before'}=$datebefore;
76 my $class=$query->param('class');
77 $search{'class'}=$class;
78 my $dewey=$query->param('dewey');
79 $search{'dewey'}; # FIXME - This should be $search{'dewey'} = $dewey, right?
80 my $branch=$query->param('branch');
81 $search{'branch'}=$branch;
82 my $title=$query->param('title');
83 $search{'title'}=$title;
84 my $abstract=$query->param('abstract');
85 $search{'abstract'}=$abstract;
86 my $publisher=$query->param('publisher');
87 $search{'publisher'}=$publisher;
89 my $ttype=$query->param('ttype');
90 $search{'ttype'}=$ttype;
93 ($keyword) && (push @$forminputs, { line => "keyword=$keyword"});
94 ($subject) && (push @$forminputs, { line => "subject=$subject"});
95 ($author) && (push @$forminputs, { line => "author=$author"});
96 ($illustrator) && (push @$forminputs, { line => "illustrator=$illustrator"});
97 ($itemnumber) && (push @$forminputs, { line => "itemnumber=$itemnumber"});
98 ($isbn) && (push @$forminputs, { line => "isbn=$isbn"});
99 ($datebefore) && (push @$forminputs, { line => "date-before=$datebefore"});
100 ($class) && (push @$forminputs, { line => "class=$class"});
101 ($dewey) && (push @$forminputs, { line => "dewey=$dewey"});
102 ($branch) && (push @$forminputs, { line => "branch=$branch"});
103 ($title) && (push @$forminputs, { line => "title=$title"});
104 ($ttype) && (push @$forminputs, { line => "ttype=$ttype"});
105 ($abstract) && (push @$forminputs, { line => "abstract=$abstract"});
106 ($publisher) && (push @$forminputs, { line => "publisher=$publisher"});
107 $template->param(FORMINPUTS => $forminputs);
109 # I think it is (or was) a search from the "front" page... [st]
110 $search{'front'}=$query->param('front');
113 my ($count,@results)=catalogsearch($env,'',\%search,$num,$startfrom);
115 my $resultsarray=\@results;
119 $search=$search."&keyword=$keyword";
122 $search=$search."&subject=$subject";
125 $search=$search."&author=$author";
128 $search=$search."&class=$class";
131 $search=$search."&title=$title";
134 $search=$search."&dewey=$dewey";
136 $search.="&ttype=$ttype";
139 $template->param(startfrom => $startfrom+1);
140 $template->param(endat => $startfrom+$num);
141 $template->param(numrecords => $count);
142 my $nextstartfrom=($startfrom+$num<$count-$num) ? ($startfrom+$num) : ($count-$num);
143 my $prevstartfrom=($startfrom-$num>0) ? ($startfrom-$num) : (0);
144 $template->param(nextstartfrom => $nextstartfrom);
145 $template->param(prevstartfrom => $prevstartfrom);
146 $template->param(search => $search);
147 $template->param(SEARCH_RESULTS => $resultsarray);
148 $template->param(includesdir => $includes);
151 print "Content-Type: text/html\n\n", $template->output;