koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] koha/opac opac-zoomsearch.pl [dev_week]


From: Joshua Ferraro
Subject: [Koha-cvs] koha/opac opac-zoomsearch.pl [dev_week]
Date: Fri, 21 Jul 2006 17:19:39 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Joshua Ferraro <kados>  06/07/21 17:19:39

Modified files:
        opac           : opac-zoomsearch.pl 

Log message:
        remove searchZOOM from script, put it in Search.pm

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-zoomsearch.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.10&r2=1.1.2.11

Patches:
Index: opac-zoomsearch.pl
===================================================================
RCS file: /sources/koha/koha/opac/Attic/opac-zoomsearch.pl,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -b -r1.1.2.10 -r1.1.2.11
--- opac-zoomsearch.pl  11 Jul 2006 21:15:23 -0000      1.1.2.10
+++ opac-zoomsearch.pl  21 Jul 2006 17:19:39 -0000      1.1.2.11
@@ -21,6 +21,9 @@
 use C4::Context;
 use C4::Interface::CGI::Output;
 use C4::Auth;
+use C4::Search;
+use C4::Biblio;
+
 use POSIX qw(ceil floor);
 
 # load other modules
@@ -32,6 +35,7 @@
 my $op = $query->param('op'); # show the search form or execute the search
 my $cql_query = $query->param('cql_query');
 my $ccl_query = $query->param('ccl_query');
+my $pqf_query = $query->param('pqf_query');
 my @newresults;
 my ($template,$borrowernumber,$cookie);
 my @forminputs;                # this is for the links to navigate among the 
results when they are more than the maximum number of results per page
@@ -54,7 +58,8 @@
        ## OK, We're searching
        # STEP 1. We're a CGI script,so first thing to do is get the
        # query into PQF format so we can use the Koha API properly
-       my ($error,$pqf_sort_by, $pqf_prox_ops, $pqf_bool_ops, $pqf_query, 
$nice_query) = cgi2pqf($query);
+       my ($error,$pqf_sort_by, $pqf_prox_ops, $pqf_bool_ops, $nice_query);
+       ($error,$pqf_sort_by, $pqf_prox_ops, $pqf_bool_ops, $pqf_query, 
$nice_query)= cgi2pqf($query);
        my $then_sort_by = $query->param('then_sort_by');
        #warn "AFTER CGI: $pqf_sort_by $pqf_prox_ops $pqf_bool_ops $pqf_query";
        # implement a query history
@@ -272,140 +277,6 @@
 }
 output_html_with_http_headers $query, $cookie, $template->output;
 
-=head2 searchZOOM
-=cut
-###Move these subs to a proper Search.pm
-sub searchZOOM {
-       use C4::Biblio;
-       my ($search_or_scan,$type,$query,$num,$startfrom,$then_sort_by) = @_;
-       my $dbh = C4::Context->dbh;
-       my $zconn=C4::Context->Zconn("biblioserver");
-
-       #warn ($type,$query,$num,$startfrom) ;
-       if ($zconn eq "error") {
-               return("error with connection",undef); #FIXME: better error 
handling
-       }
-       
-       my $zoom_query_obj;
-
-       if ($type eq 'ccl') {
-               $zoom_query_obj = new ZOOM::Query::CCL2RPN($query,$zconn);
-       } elsif ($type eq 'cql') {
-               eval {
-                       $zoom_query_obj = new 
ZOOM::Query::CQL2RPN($query,$zconn);
-               };
-               if ($@) {
-                       return ("error: Sorry, there was a problem with your 
query: $@",undef); #FIXME: better error handling
-               }
-       } else {
-               eval {
-                       $zoom_query_obj = new ZOOM::Query::PQF($query);
-               };
-               if ($@) {
-                       return("error with search: $@",undef); #FIXME: better 
error handling
-               }
-       }       
-
-       # PERFORM THE SEARCH
-       my $result;
-       my @results;
-       my $numresults;
-       if ($search_or_scan =~ /scan/) {
-               eval {
-                       $result = $zconn->scan($zoom_query_obj);
-               };
-               if ($@) {
-                       return ("error with scan: $@",undef);
-               }
-       } else {
-               eval {
-                       $result = $zconn->search($zoom_query_obj);
-               };
-               if ($@) {
-                       return("error with search: $@",undef); #FIXME: better 
error handling
-               }
-       }
-
-       # RESORT RESULT SET
-       if ($then_sort_by) {
-               $result->sort("yaz", "$then_sort_by")
-       }
-       # build our results and faceted searching
-       my @facets; my %facets_counter; my %facets_counter_subs; my 
@facets_counter_subs_array;
-       $numresults = 0 | $result->size() if  ($result);
-       for ( my $i=$startfrom; $i<(($startfrom+$num<=$numresults) ? 
($startfrom+$num):$numresults) ; $i++){
-               if  ($search_or_scan =~ /scan/) { # this is an index scan
-                       my ($term,$occ) = $result->term($i);
-                       # here we create a minimal MARC record and hand it off 
to the
-                       # template just like a normal result ... perhaps not 
ideal, but 
-                       # it works for now FIXME: distinguish between MARC21 
and UNIMARC
-                       use MARC::Record;
-                       my $tmprecord = MARC::Record->new();
-                       $tmprecord->encoding('UTF-8');
-                       my $tmptitle = MARC::Field->new( '245',' ',' ',
-                                               a => $term,
-                                               b => $occ);
-                                               
$tmprecord->append_fields($tmptitle);
-                       push @results, $tmprecord->as_usmarc();
-               } else { # this is a real search
-                       my $rec = $result->record($i);
-                       push(@results,$rec->raw()) if $rec; #FIXME: sometimes 
this fails
-
-                       ##### build facets ####
-                       my $tmprecord = 
MARC::Record->new_from_usmarc($rec->raw());
-                       my @subfields = $tmprecord->field('650');       
#subject facets
-                       my @authfields = $tmprecord->field('100');      #author 
facets
-                       my @serfields = $tmprecord->field('440');       #series 
facets
-                       my $subject_added_entry;
-                       foreach my $subjectfield (@subfields) {
-                               my @fields = $subjectfield->subfields();
-                               foreach my $subfield (@fields) {                
                
-                                       my ($code,$data) = @$subfield;
-                                       if ($code eq 'a') {
-                                               $facets_counter{$data}++;
-                                               $subject_added_entry = $data;
-                                       }
-                               }
-                               my $fieldstring = $subjectfield->as_string();
-                               $facets_counter_subs{$subject_added_entry} = 
$fieldstring;
-                       }
-
-               }
-       }
-       #foreach my $value (keys %facets_counter_subs) {
-       #       my %facets_row = (
-       #               'facetsubjectsub' => $value,
-       #       );      
-       #       push @facets_counter_subs_array, \%facets_row; 
#facets_counter_subs{$subject_added_entry};
-       #}#
-       foreach my $value (sort { $facets_counter{$b} <=> $facets_counter{$a} } 
keys %facets_counter) {
-
-               #foreach my $subvalue (keys %facets_counter_subs) {
-               #       my %facets_row = (
-               #               'facetsubjectsub' => 
$facets_counter_subs{$subvalue}, #$subvalue{$value},
-               #       );
-               #       push @facets_counter_subs_array, \%facets_row;
-               #}#
-               
-
-               my %facets_row = (
-                'facetsubject' => $value,
-                'facetcount' => $facets_counter{$value},
-                               'facetcountersubs' => address@hidden, 
#%facets_counter_subs->{$value},
-                );      
-               push @facets,\%facets_row;
-
-       }
-       #while( my ($k, $v) = each %$facets_counter ) {
-        #       my %facets_row = (
-       #       'facetsubject' => $k,
-       #       'facetcount' => $v,
-       #       );
-       #       push @facets,\%facets_row;
-       #}#
-       return(undef,$numresults,address@hidden,@results);
-}
-
 =head2 cgi2pdf
 =cut
 # build a valid PQF query from the CGI form
@@ -530,6 +401,12 @@
        foreach my $prox(@pqf_prox_ops_array) {
                $pqf_prox_ops.=" ".$prox;
        }
+
+       # finally, nice_query needs to be populated if it hasn't been
+       $nice_query = $pqf_query unless $nice_query;
+       # and cleaned up FIXME: bad bad ... 
+       $nice_query =~ s/address@hidden//g;
+       $nice_query =~ s/\d+=\d+//g;
        # OK, done with that, now lets have a look
        warn "Boolean Operators: ".$pqf_bool_ops if $pqf_bool_ops;
        warn "Proximigy Operators: ".$pqf_prox_ops if $pqf_prox_ops;




reply via email to

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