koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha search.pl,1.14,1.15


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha search.pl,1.14,1.15
Date: Wed, 09 Oct 2002 08:44:52 -0700

Update of /cvsroot/koha/koha
In directory usw-pr-cvs1:/tmp/cvs-serv4722

Modified Files:
        search.pl 
Log Message:
merging from 1,2 branch. Seems OK

Index: search.pl
===================================================================
RCS file: /cvsroot/koha/koha/search.pl,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** search.pl   7 Oct 2002 14:02:47 -0000       1.14
--- search.pl   9 Oct 2002 15:44:49 -0000       1.15
***************
*** 1,5 ****
  #!/usr/bin/perl
  use HTML::Template;
! #script to provide intranet (librarian) advanced search facility
  
  
--- 1,6 ----
  #!/usr/bin/perl
+ 
  use HTML::Template;
! 
  
  
***************
*** 23,53 ****
  use strict;
  require Exporter;
  use CGI;
  use C4::Context;
  use C4::Search;
  use C4::Output;
  
  my $query=new CGI;
  
- my $includes = C4::Context->config('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);
  
  my $subject=$query->param('subject');
- # if its a subject we need to use the subject.tmpl
  my $template;
  if ($subject) {
!       $template = gettemplate("catalogue/subject.tmpl")
! #    $templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
! #    $theme=picktemplate($includes, $templatebase);
  } else {
!       $template = gettemplate("catalogue/searchresults.tmpl")
  }
  
- #my $template = HTML::Template->new(filename => 
"$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => 
[$includes]);
- 
  my $env;
  $env->{itemcount}=1;
--- 24,53 ----
  use strict;
  require Exporter;
+ 
  use CGI;
  use C4::Context;
  use C4::Search;
+ use C4::Auth;
  use C4::Output;
  
  my $query=new CGI;
+ my $type=$query->param('type');
+ (-e "opac") && ($type='opac');
+ 
+ my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') 
? (1) : (0));
+ 
  
  my $startfrom=$query->param('startfrom');
  ($startfrom) || ($startfrom=0);
  
  my $subject=$query->param('subject');
  my $template;
+ # if its a subject we need to use the subject.tmpl
  if ($subject) {
!       $template = gettemplate("catalogue/subject.tmpl",0);
  } else {
!       $template = gettemplate("catalogue/searchresults.tmpl",);
  }
  
  my $env;
  $env->{itemcount}=1;
***************
*** 66,69 ****
--- 66,71 ----
  my $author=$query->param('author');
  $search{'author'}=$author;
+ $search{'authoresc'}=$author;
+ #$search{'authorhtmlescaped'}=~s/ /%20/g;
  my $illustrator=$query->param('illustrator');
  $search{'param'}=$illustrator;
***************
*** 77,81 ****
  $search{'class'}=$class;
  my $dewey=$query->param('dewey');
! $search{'dewey'};             # FIXME - This should be $search{'dewey'} = 
$dewey, right?
  my $branch=$query->param('branch');
  $search{'branch'}=$branch;
--- 79,83 ----
  $search{'class'}=$class;
  my $dewey=$query->param('dewey');
! $search{'dewey'}=$dewey;
  my $branch=$query->param('branch');
  $search{'branch'}=$branch;
***************
*** 105,108 ****
--- 107,111 ----
  ($abstract) && (push @$forminputs, { line => "abstract=$abstract"});
  ($publisher) && (push @$forminputs, { line => "publisher=$publisher"});
+ ($forminputs) || (@$forminputs=());
  $template->param(FORMINPUTS => $forminputs);
  # whats this for?
***************
*** 111,136 ****
  
  my $num=10;
! my ($count,@results)=catalogsearch($env,'',\%search,$num,$startfrom);
  
! my address@hidden;
  
  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";
--- 114,167 ----
  
  my $num=10;
! my @results;
! my $count;
! if (my $subject=$query->param('subjectitems')) {
!     my $blah;
!     @results=subsearch(\$blah,$subject);
!     $count=$#results+1;
! } else {
!     ($count,@results)=catalogsearch($env,'',\%search,$num,$startfrom);
! }
  
! #my address@hidden;
! my $resultsarray;
  
+ foreach my $result (@results) {
+     $result->{'authorhtmlescaped'}=$result->{'author'};
+     $result->{'authorhtmlescaped'}=~s/ /%20/g;
+     ($result->{'copyrightdate'}==0) && ($result->{'copyrightdate'}='');
+     ($type eq 'opac') ? ($result->{'opac'}=1) : ($result->{'opac'}=0);
+     push (@$resultsarray, $result);
+ }
+ ($resultsarray) || (@$resultsarray=());
  my $search="num=20";
+ my $searchdesc='';
  if ($keyword){
      $search=$search."&keyword=$keyword";
+     $searchdesc.="keyword $keyword, ";
+ }
+ if (my $subjectitems=$query->param('subjectitems')){
+     $search=$search."&subjectitems=$subjectitems";
+     $searchdesc.="subject $subjectitems, ";
  }
  if ($subject){
      $search=$search."&subject=$subject";
+     $searchdesc.="subject $subject, ";
  }
  if ($author){
      $search=$search."&author=$author";
+     $searchdesc.="author $author, ";
  }
  if ($class){
      $search=$search."&class=$class";
+     $searchdesc.="class $class, ";
  }
  if ($title){
      $search=$search."&title=$title";
+     $searchdesc.="title $title, ";
  }
  if ($dewey){
      $search=$search."&dewey=$dewey";
+     $searchdesc.="dewey $dewey, ";
  }
  $search.="&ttype=$ttype";
***************
*** 138,152 ****
  $search=~ s/ /%20/g;
  $template->param(startfrom => $startfrom+1);
! $template->param(endat => $startfrom+$num);
  $template->param(numrecords => $count);
! my $nextstartfrom=($startfrom+$num<$count-$num) ? ($startfrom+$num) : 
($count-$num);
! my $prevstartfrom=($startfrom-$num>0) ? ($startfrom-$num) : (0);
  $template->param(nextstartfrom => $nextstartfrom);
  $template->param(prevstartfrom => $prevstartfrom);
  $template->param(search => $search);
  $template->param(SEARCH_RESULTS => $resultsarray);
! $template->param(includesdir => $includes);
  
  
! print "Content-Type: text/html\n\n", $template->output;
  
--- 169,214 ----
  $search=~ s/ /%20/g;
  $template->param(startfrom => $startfrom+1);
! ($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : 
($template->param(endat => $count));
  $template->param(numrecords => $count);
! my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
! my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$num) : (-1);
  $template->param(nextstartfrom => $nextstartfrom);
+ my $displaynext=1;
+ my $displayprev=0;
+ ($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
+ ($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
+ $template->param(displaynext => $displaynext);
+ $template->param(displayprev => $displayprev);
+ ($type eq 'opac') ? ($template->param(opac => 1)) : ($template->param(opac => 
0));
  $template->param(prevstartfrom => $prevstartfrom);
  $template->param(search => $search);
+ $template->param(searchdesc => $searchdesc);
  $template->param(SEARCH_RESULTS => $resultsarray);
! #$template->param(includesdir => $includes);
! $template->param(loggedinuser => $loggedinuser);
! 
! my $numbers;
! @$numbers=();
! if ($count>10) {
!     for (my $i=1; $i<$count/10+1; $i++) {
!       if ($i<16) {
!           ($title) && (push @$forminputs, { line => "title=$title"});
!           my $highlight=0;
!           ($startfrom==($i-1)*10) && ($highlight=1);
!           my $formelements='';
!           foreach (@$forminputs) {
!               my $line=$_->{line};
!               $formelements.="$line&";
!           }
!           $formelements=~s/ /+/g;
!           push @$numbers, { number => $i, highlight => $highlight , 
FORMELEMENTS => $formelements, FORMINPUTS => $forminputs, startfrom => 
($i-1)*10, opac => (($type eq 'opac') ? (1) : (0))};
!       }
!     }
! }
! 
! $template->param(numbers => $numbers);
! 
  
  
! print $query->header(-cookie => $cookie), $template->output;
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]