[Koha-cvs] CVS: koha/C4 Search.pm,1.26,1.27

Chris Cormack rangi at users.sourceforge.net
Tue May 14 23:36:41 CEST 2002


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

Modified Files:
	Search.pm 
Log Message:
Made a wrapper function catalogsearch
This then chooses whether to call KeywordSearch, or CatSearch, or any other
searches.


Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Search.pm,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** Search.pm	13 May 2002 23:07:47 -0000	1.26
--- Search.pm	14 May 2002 21:36:39 -0000	1.27
***************
*** 22,26 ****
  &getboracctrecord &ItemType &itemissues &subject &subtitle
  &addauthor &bibitems &barcodes &findguarantees &allissues &systemprefs
! &findguarantor &getwebsites &getwebbiblioitems);
  %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
  		  
--- 22,26 ----
  &getboracctrecord &ItemType &itemissues &subject &subtitle
  &addauthor &bibitems &barcodes &findguarantees &allissues &systemprefs
! &findguarantor &getwebsites &getwebbiblioitems &catalogsearch);
  %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
  		  
***************
*** 117,120 ****
--- 117,151 ----
  }    
  
+ sub catalogsearch {
+   my ($env,$type,$search,$num,$offset)=@_;
+   my $dbh = C4Connect();
+ #  foreach my $key (%$search){
+ #    $search->{$key}=$dbh->quote($search->{$key});
+ #  }
+   my ($count, at results);
+   if ($search->{'itemnumber'} ne '' || $search->{'isbn'} ne ''){
+     ($count, at results)=CatSearch($env,'precise',$search,$num,$offset);
+   } else {
+     if ($search->{'subject'} ne ''){
+       ($count, at results)=CatSearch($env,'subject',$search,$num,$offset);
+     } else {
+       if ($search->{'keyword'} ne ''){
+          ($count, at results)=&KeywordSearch($env,'keyword',$search,$num,$offset);
+       } elsif ($search->{'title'} ne '' || $search->{'author'} ne '' ||
+                $search->{'illustrator'} ne '' || $search->{'dewey'} ne '' ||
+ 	       $search->{'class'} ne ''){
+ 	($count, at results)=CatSearch($env,'loose',$search,$num,$offset);
+       }
+     }
+   }
+   if ($env->{itemcount}) {
+     foreach my $data (@results){
+       my ($count, $lcount, $nacount, $fcount, $scount, $lostcount, $mending, $transit, $ocount) = itemcount($env, $data->{'biblionumber'}, 'intra');
+       $data->{'itemcount'}=$count;
+     }
+   }
+   return ($count, at results);
+ }
+ 
    
  sub KeywordSearch {
***************
*** 288,295 ****
          $sth->finish;                                             
  	$data2->{'dewey'}=$dewey;
- 	if ($env->{itemcount}) {
- 	    my ($count, $lcount, $nacount, $fcount, $scount, $lostcount, $mending, $transit, $ocount) = itemcount($env, $data2->{'biblionumber'}, 'intra');
- 	    $data2->{'itemcount'}=$count;
- 	}
  	$res2[$i]=$data2;
  #	$res2[$i]="$data2->{'author'}\t$data2->{'title'}\t$data2->{'biblionumber'}\t$data2->{'copyrightdate'}\t$dewey";
--- 319,322 ----
***************
*** 541,556 ****
    $sti->finish;
    if ($true == 1){
!   if ($count > $offset && $count <= $limit){
! #    if ($type ne 'subject' && $type ne 'precise'){
! #       $results[$i]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey\t$data->{'illus'}";
! #    } elsif ($search->{'isbn'} ne '' || $search->{'item'} ne ''){
! #       $results[$i]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey\t$data->{'illus'}";
! #    } else {  
! #     $results[$i]="$data->{'author'}\t$data->{'subject'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$dewey\t$data->{'illus'}";
! #    }
!     $results[$i]=$data;
!     $i++;
!   }
!   $count++;
    }
  }
--- 568,576 ----
    $sti->finish;
    if ($true == 1){
!     if ($count > $offset && $count <= $limit){
!       $results[$i]=$data;
!       $i++;
!     }
!     $count++;
    }
  }
***************
*** 734,742 ****
      my $dbh   = C4Connect;
      my $query = "Select *, biblio.notes  
! from biblio, biblioitems 
! left join bibliosubtitle on
! biblio.biblionumber = bibliosubtitle.biblionumber
! where biblio.biblionumber = $bibnum
! and biblioitems.biblionumber = $bibnum";
      my $sth   = $dbh->prepare($query);
      my $data;
--- 754,762 ----
      my $dbh   = C4Connect;
      my $query = "Select *, biblio.notes  
!     from biblio, biblioitems 
!     left join bibliosubtitle on
!     biblio.biblionumber = bibliosubtitle.biblionumber
!     where biblio.biblionumber = $bibnum
!     and biblioitems.biblionumber = $bibnum";
      my $sth   = $dbh->prepare($query);
      my $data;
***************
*** 1252,1257 ****
  
    use C4::Search;
!   my ($count, at results)=KeywordSearch($env,$type,$search,$num,$offset);
!   my ($count, at results)=CatSearch($env,$type,$search,$num,$offset);
  
  =head1 DESCRIPTION
--- 1272,1276 ----
  
    use C4::Search;
!   my ($count, at results)=catalogsearch($env,$type,$search,$num,$offset);
  
  =head1 DESCRIPTION
***************
*** 1260,1268 ****
  Here I should go through and document each function thats exported and what it does. But I havent yet.
  
  =head2 EXPORT
  
! KeywordSearch
! CatSearch
! ItemInfo
  
  =head1 AUTHOR
--- 1279,1289 ----
  Here I should go through and document each function thats exported and what it does. But I havent yet.
  
+ my ($count, at results)=catalogsearch($env,$type,$search,$num,$offset);
+ This is a front end to all the other searches, depending on what is passed
+ to it, it calls the appropriate search
+ 
  =head2 EXPORT
  
! catalogsearch
  
  =head1 AUTHOR





More information about the Koha-cvs mailing list