koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] koha/C4 Search.pm [dev_week]


From: Joshua Ferraro
Subject: [Koha-cvs] koha/C4 Search.pm [dev_week]
Date: Tue, 08 Aug 2006 13:33:43 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Joshua Ferraro <kados>  06/08/08 13:33:43

Modified files:
        C4             : Search.pm 

Log message:
        bugfix to Search facets

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Search.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.99.2.11.2.18&r2=1.99.2.11.2.19

Patches:
Index: Search.pm
===================================================================
RCS file: /sources/koha/koha/C4/Search.pm,v
retrieving revision 1.99.2.11.2.18
retrieving revision 1.99.2.11.2.19
diff -u -b -r1.99.2.11.2.18 -r1.99.2.11.2.19
--- Search.pm   7 Aug 2006 19:56:50 -0000       1.99.2.11.2.18
+++ Search.pm   8 Aug 2006 13:33:43 -0000       1.99.2.11.2.19
@@ -35,7 +35,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.99.2.11.2.18 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.99.2.11.2.19 $' =~ /\d+/g;
           shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
@@ -4156,7 +4156,7 @@
        my @facets_loop; # stores the ref to array of hashes for template
        my ($subject_facets, $series_facets, $author_facets);
        my (%subject_facets_counter, %series_facets_counter, 
%author_facets_counter);
-
+       my (%branch_facets_counter, %language_limits_counter, 
%content_limits_counter, %format_limits_counter, %audience_limits_counter);
        #### LOOP THROUGH THE RESULTS   
     $numresults = 0 | $result->size() if  ($result);
     for ( my $i=$startfrom; $i<(($startfrom+$num<=$numresults) ? 
($startfrom+$num):$numresults) ; $i++){
@@ -4179,9 +4179,21 @@
             my $rec = $result->record($i);
             push(@results,$rec->raw()) if $rec; #FIXME: sometimes this fails
                        
-            ##### BUILD FACETS ####
+            ##### BUILD FACETS AND LIMITS ####
                        my $facet_record = 
MARC::Record->new_from_usmarc($rec->raw());
 
+                       # Define Holdings Limits
+                       my @holdings_fields = $facet_record->field('952');
+                       my $holdings_code;
+                       foreach my $holdingsfield (@holdings_fields) {
+                               my @fields = $holdingsfield->subfields();
+                               foreach my $subfield(@fields) {
+                                       my ($code,$data) = @$subfield;
+                                       if ($code eq 'b') { # homebranch
+                                               $branch_facets_counter{$data}++;
+                                       }
+                               }
+                       }
             # Define Subject Facets
             my @subject_fields = $facet_record->field('650');
             my $subject_term;
@@ -4225,6 +4237,30 @@
     }
        # BUILD FACETS
        my $expandable;
+
+    # Build branch facets
+       use C4::Koha;
+       my $branch = getbranches;
+       my $number_of_branch_facets;
+    my @branch_facets_array;
+    my $expand_branch;
+    foreach my $value (sort { $branch_facets_counter{$b} <=> 
$branch_facets_counter{$a} } keys %branch_facets_counter) {
+        my $linkvalue = $value;
+        my $captionvalue = $branch->{$value}->{'branchname'};
+        my $count = $branch_facets_counter{$value};
+               $linkvalue =~ s/\'/\\\'/g;
+        $captionvalue =~ s/\'/&apos;/g;
+            push @branch_facets_array , (
+            {count => $count,label => $captionvalue,link 
=>"/cgi-bin/koha/opac-zoomsearch.pl?op=get_results&amp;ccl_query=$query and 
branch=&quot;$linkvalue&quot;"}
+            );
+    }
+    if (($number_of_branch_facets > 6) && ($expand_branch)) {
+        $expandable = 1;    }
+    else {
+        undef $expandable;
+    }
+    push @facets_loop, ( {type => 'Branches',typeid => 'branch_facet',facets 
=> address@hidden, expandable => $expandable,expand => $expand_branch} );
+
     # Build subject facets
        my $number_of_subject_facets;
        my @subject_facets_array;
@@ -4265,7 +4301,7 @@
                $captionvalue =~ s/\'/&apos;/g;
                if (($number_of_series_facets < 6) || (!$expand_series)) {
                        push @series_facets_array , (
-            {count => $count,label => $captionvalue,link 
=>"/cgi-bin/koha/opac-zoomsearch.pl?op=get_results&amp;ccl_query=series=&quot;$linkvalue&quot;"}
+            {count => $count,label => $captionvalue,link 
=>"/cgi-bin/koha/opac-zoomsearch.pl?op=get_results&amp;ccl_query=$query and 
series=&quot;$linkvalue&quot;"}
                        );
                }
        }
@@ -4291,7 +4327,7 @@
                $captionvalue =~ s/\'/&apos;/g;
                if (($number_of_author_facets < 6) || (!$expand_authors)) {
                        push @author_facets_array , (
-            {count => $count,label => $captionvalue,link 
=>"/cgi-bin/koha/opac-zoomsearch.pl?op=get_results&amp;ccl_query=au=&quot;$linkvalue&quot;"}
+            {count => $count,label => $captionvalue,link 
=>"/cgi-bin/koha/opac-zoomsearch.pl?op=get_results&amp;ccl_query=$query and 
au=&quot;$linkvalue&quot;"}
                );
                }
     }




reply via email to

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