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
28 use C4::Output; # no contains picktemplate
33 my $language='french';
37 open (KC, "/etc/koha.conf");
41 if (/(.*)\s*=\s*(.*)/) {
44 # Clean up white space at beginning and end
49 $configfile{$variable}=$value;
52 #print $query->header;
54 my $includes=$configfile{'includes'};
55 ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
56 my $templatebase="catalogue/searchresults.tmpl";
57 my $startfrom=$query->param('startfrom');
58 ($startfrom) || ($startfrom=0);
59 my $theme=picktemplate($includes, $templatebase);
61 my $subject=$query->param('subject');
62 # if its a subject we need to use the subject.tmpl
64 $templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
65 $theme=picktemplate($includes, $templatebase);
68 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
73 # get all the search variables
74 # we assume that C4::Search will validate these values for us
76 my $keyword=$query->param('keyword');
77 $search{'keyword'}=$keyword;
79 $search{'subject'}=$subject;
80 my $author=$query->param('author');
81 $search{'author'}=$author;
82 my $illustrator=$query->param('illustrator');
83 $search{'param'}=$illustrator;
84 my $itemnumber=$query->param('itemnumber');
85 $search{'itemnumber'}=$itemnumber;
86 my $isbn=$query->param('isbn');
87 $search{'isbn'}=$isbn;
88 my $datebefore=$query->param('date-before');
89 $search{'date-before'}=$datebefore;
90 my $class=$query->param('class');
91 $search{'class'}=$class;
92 my $dewey=$query->param('dewey');
94 my $branch=$query->param('branch');
95 $search{'branch'}=$branch;
96 my $title=$query->param('title');
97 $search{'title'}=$title;
98 my $abstract=$query->param('abstract');
99 $search{'abstract'}=$abstract;
100 my $publisher=$query->param('publisher');
101 $search{'publisher'}=$publisher;
103 my $ttype=$query->param('ttype');
104 $search{'ttype'}=$ttype;
107 ($keyword) && (push @$forminputs, { line => "keyword=$keyword"});
108 ($subject) && (push @$forminputs, { line => "subject=$subject"});
109 ($author) && (push @$forminputs, { line => "author=$author"});
110 ($illustrator) && (push @$forminputs, { line => "illustrator=$illustrator"});
111 ($itemnumber) && (push @$forminputs, { line => "itemnumber=$itemnumber"});
112 ($isbn) && (push @$forminputs, { line => "isbn=$isbn"});
113 ($datebefore) && (push @$forminputs, { line => "date-before=$datebefore"});
114 ($class) && (push @$forminputs, { line => "class=$class"});
115 ($dewey) && (push @$forminputs, { line => "dewey=$dewey"});
116 ($branch) && (push @$forminputs, { line => "branch=$branch"});
117 ($title) && (push @$forminputs, { line => "title=$title"});
118 ($ttype) && (push @$forminputs, { line => "ttype=$ttype"});
119 ($abstract) && (push @$forminputs, { line => "abstract=$abstract"});
120 ($publisher) && (push @$forminputs, { line => "publisher=$publisher"});
121 $template->param(FORMINPUTS => $forminputs);
123 # I think it is (or was) a search from the "front" page... [st]
124 $search{'front'}=$query->param('front');
127 my ($count,@results)=catalogsearch($env,'',\%search,$num,$startfrom);
129 my $resultsarray=\@results;
133 $search=$search."&keyword=$keyword";
136 $search=$search."&subject=$subject";
139 $search=$search."&author=$author";
142 $search=$search."&class=$class";
145 $search=$search."&title=$title";
148 $search=$search."&dewey=$dewey";
150 $search.="&ttype=$ttype";
153 $template->param(startfrom => $startfrom+1);
154 $template->param(endat => $startfrom+$num);
155 $template->param(numrecords => $count);
156 my $nextstartfrom=($startfrom+$num<$count-$num) ? ($startfrom+$num) : ($count-$num);
157 my $prevstartfrom=($startfrom-$num>0) ? ($startfrom-$num) : (0);
158 $template->param(nextstartfrom => $nextstartfrom);
159 $template->param(prevstartfrom => $prevstartfrom);
160 $template->param(search => $search);
161 $template->param(SEARCH_RESULTS => $resultsarray);
162 $template->param(includesdir => $includes);
165 print "Content-Type: text/html\n\n", $template->output;