Will work now with the existing C4/Search.pm at least the one in the main
[koha.git] / html-template / search.pl
1 #!/usr/bin/perl -w
2 use HTML::Template;
3 use strict;
4 require Exporter;
5 use C4::Database;
6 use CGI;
7 use C4::Search;
8  
9 my $query=new CGI;
10
11 # temporary variable for testing. Replace from /etc/koha.conf
12
13 my $templatedir="/usr/share/koha/intranet/htdocs/includes/templates";
14
15 my $templatename=$query->param('template');
16 my $startfrom=$query->param('startfrom');
17 ($startfrom) || ($startfrom=0);
18 ($templatename) || ($templatename="$templatedir/searchresults.tmpl");
19
20
21 my $dbh=&C4Connect;  
22
23
24 my $template = HTML::Template->new(filename => $templatename, die_on_bad_params => 0);
25
26 ##my @results;
27 #my $sth=$dbh->prepare("select * from biblio where author like 's%' order by author limit $startfrom,20");
28 #$sth->execute;
29 #while (my $data=$sth->fetchrow_hashref){    
30 #    push @results, $data;
31 #}
32
33 my $blah;
34 my %search;
35 my $keyword='bear';
36 $search{'keyword'}=$keyword;
37
38 my ($count, @results) = &KeywordSearch(\$blah, 'intra', \%search, 20, $startfrom);
39 my $resultshash=\@results;
40
41
42
43 $template->param(startfrom => $startfrom);
44 $startfrom+=20;
45 $template->param(nextstartfrom => $startfrom);
46 $template->param(template => $templatename);
47 $template->param(SEARCH_RESULTS => $resultshash);
48
49 print "Content-Type: text/html\n\n", $template->output;