Now works with all searches, this plus the templates should now be close to
authorrangi <rangi>
Tue, 14 May 2002 21:33:23 +0000 (21:33 +0000)
committerrangi <rangi>
Tue, 14 May 2002 21:33:23 +0000 (21:33 +0000)
a drop in replacement for the existing search.pl

Actually, just the subject search to go (requires a slightly different
template .. or some kind of TMPL_IF in the template

html-template/search.pl

index 5756278..2f3ba3c 100755 (executable)
@@ -28,36 +28,79 @@ while (<KC>) {
    $configfile{$variable}=$value;
  }
 }
+#print $query->header;
+
 my $includes=$configfile{'includes'};
 ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
 my $templatebase="catalogue/searchresults.tmpl";
 my $startfrom=$query->param('startfrom');
 ($startfrom) || ($startfrom=0);
-my $theme=picktemplate($includes, $templatebase);
-
-
+($templatename) || ($templatename=picktemplate($templatebase));
 
 
 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
 
-##my @results;
-#my $sth=$dbh->prepare("select * from biblio where author like 's%' order by author limit $startfrom,20");
-#$sth->execute;
-#while (my $data=$sth->fetchrow_hashref){    
-#    push @results, $data;
-#}
-
 my $env;
 $env->{itemcount}=1;
+
+# get all the search variables
+# we assume that C4::Search will validate these values for us
 my %search;
-my $keyword='tree';
+my $keyword=$query->param('keyword');
 $search{'keyword'}=$keyword;
-
-my ($count, @results) = &KeywordSearch($env, 'intra', \%search, 20, $startfrom);
-
+my $subject=$query->param('subject');
+$search{'subject'}=$subject;
+my $author=$query->param('author');
+$search{'author'}=$author;
+my $illustrator=$query->param('illustrator');
+$search{'param'}=$illustrator;
+my $itemnumber=$query->param('itemnumber');
+$search{'itemnumber'}=$itemnumber;
+my $isbn=$query->param('isbn');
+$search{'isbn'}=$isbn;
+my $datebefore=$query->param('date-before');
+$search{'date-before'}=$datebefore;
+my $class=$query->param('class');
+$search{'class'}=$class;
+my $dewey=$query->param('dewey');
+$search{'dewey'};
+my $branch=$query->param('branch');
+$search{'branch'}=$branch;
+my $title=$query->param('title');
+$search{'title'}=$title;
+my $ttype=$query->param('ttype');
+$search{'ttype'}=$ttype;
+
+# whats this for?
+$search{'front'}=$query->param('front');
+
+my $num=20;
+my ($count,@results)=catalogsearch($env,'',\%search,$num,$startfrom);
 
 my $resultsarray=\@results;
 
+my $search="num=20";
+if ($keyword){
+    $search=$search."&keyword=$keyword";
+}
+if ($subject){
+    $search=$search."&subject=$subject";
+}
+if ($author){
+    $search=$search."&author=$author";
+}
+if ($class){
+    $search=$search."&class=$class";
+}
+if ($title){
+    $search=$search."&title=$title";
+}
+if ($dewey){
+    $search=$search."&dewey=$dewey";
+}
+$search.="&ttype=$ttype";
+
+$search=~ s/ /%20/g;
 $template->param(startfrom => $startfrom+1);
 $template->param(endat => $startfrom+20);
 $template->param(numrecords => $count);
@@ -65,9 +108,12 @@ my $nextstartfrom=($startfrom+20<$count-20) ? ($startfrom+20) : ($count-20);
 my $prevstartfrom=($startfrom-20>0) ? ($startfrom-20) : (0);
 $template->param(nextstartfrom => $nextstartfrom);
 $template->param(prevstartfrom => $prevstartfrom);
+$template->param(template => $templatename);
+$template->param(search => $search);
 $template->param(SEARCH_RESULTS => $resultsarray);
 $template->param(includesdir => $includes);
 
+
 print "Content-Type: text/html\n\n", $template->output;