[Koha-cvs] CVS: koha/html-template search.pl,1.10,1.11

Chris Cormack rangi at users.sourceforge.net
Tue May 14 23:33:25 CEST 2002


Update of /cvsroot/koha/koha/html-template
In directory usw-pr-cvs1:/tmp/cvs-serv8064

Modified Files:
	search.pl 
Log Message:
Now works with all searches, this plus the templates should now be close to
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


Index: search.pl
===================================================================
RCS file: /cvsroot/koha/koha/html-template/search.pl,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** search.pl	14 May 2002 19:34:44 -0000	1.10
--- search.pl	14 May 2002 21:33:23 -0000	1.11
***************
*** 29,32 ****
--- 29,34 ----
   }
  }
+ #print $query->header;
+ 
  my $includes=$configfile{'includes'};
  ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
***************
*** 34,62 ****
  my $startfrom=$query->param('startfrom');
  ($startfrom) || ($startfrom=0);
! my $theme=picktemplate($includes, $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;
  my %search;
! my $keyword='tree';
  $search{'keyword'}=$keyword;
  
! my ($count, @results) = &KeywordSearch($env, 'intra', \%search, 20, $startfrom);
  
  
  my $resultsarray=\@results;
  
  $template->param(startfrom => $startfrom+1);
  $template->param(endat => $startfrom+20);
--- 36,105 ----
  my $startfrom=$query->param('startfrom');
  ($startfrom) || ($startfrom=0);
! ($templatename) || ($templatename=picktemplate($templatebase));
  
  
  my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
  
  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=$query->param('keyword');
  $search{'keyword'}=$keyword;
+ 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, at 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);
***************
*** 66,71 ****
--- 109,117 ----
  $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;





More information about the Koha-cvs mailing list