[Koha-cvs] koha C4/Search.pm koha-tmpl/opac-tmpl/npl/en/in... [dev_week]

Joshua Ferraro jmf at kados.org
Mon Aug 7 21:56:51 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Joshua Ferraro <kados>	06/08/07 19:56:50

Modified files:
	C4             : Search.pm 
	koha-tmpl/opac-tmpl/npl/en/includes: navigation.inc 
	opac           : opac-zoomsearch.pl 

Log message:
	if there are more than 6 entries in a facet, only show the first 5,
	if you click on 'Show More', reload the page and show the rest.

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.17&r2=1.99.2.11.2.18
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/opac-tmpl/npl/en/includes/navigation.inc?cvsroot=koha&only_with_tag=dev_week&r1=1.2.2.4.2.10&r2=1.2.2.4.2.11
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-zoomsearch.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.19&r2=1.1.2.20

Patches:
Index: C4/Search.pm
===================================================================
RCS file: /sources/koha/koha/C4/Search.pm,v
retrieving revision 1.99.2.11.2.17
retrieving revision 1.99.2.11.2.18
diff -u -b -r1.99.2.11.2.17 -r1.99.2.11.2.18
--- C4/Search.pm	7 Aug 2006 18:41:01 -0000	1.99.2.11.2.17
+++ C4/Search.pm	7 Aug 2006 19:56:50 -0000	1.99.2.11.2.18
@@ -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.17 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.99.2.11.2.18 $' =~ /\d+/g;
           shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
@@ -4091,7 +4091,7 @@
 
 
 sub searchZOOM {
-    my ($search_or_scan,$type,$query,$num,$startfrom,$then_sort_by) = @_;
+    my ($search_or_scan,$type,$query,$num,$startfrom,$then_sort_by,$expanded_facet) = @_;
 	# establish database connections
     my $dbh = C4::Context->dbh;
     my $zconn=C4::Context->Zconn("biblioserver");
@@ -4105,7 +4105,7 @@
 
 	# prepare the query depending on the type
     if ($type eq 'ccl') {
-		$query =~ s/(\(|\))//g;
+		#$query =~ s/(\(|\))//g;
         eval {
         	$zoom_query_obj = new ZOOM::Query::CCL2RPN($query,$zconn);
 		};
@@ -4224,48 +4224,83 @@
         }
     }
 	# BUILD FACETS
+	my $expandable;
     # Build subject facets
+	my $number_of_subject_facets;
 	my @subject_facets_array;
+	my $expand_subjects;
+	$expand_subjects = 'su' unless ($expanded_facet eq 'su');
     foreach my $value (sort { $subject_facets_counter{$b} <=> $subject_facets_counter{$a} } keys %subject_facets_counter) {
+		$number_of_subject_facets++;
         my $linkvalue = $value;
         my $captionvalue = $value;
         my $count = $subject_facets_counter{$value};
         $linkvalue =~ s/\'/\\\'/g;
         $captionvalue =~ s/\'/&apos;/g;
+		if (($number_of_subject_facets < 6) || (!$expand_subjects)) {
 		push @subject_facets_array , (
 			{count => $count,label => $captionvalue,link =>"/cgi-bin/koha/opac-zoomsearch.pl?op=get_results&amp;ccl_query=su=&quot;$linkvalue&quot;"}
 		);
     }
-	push @facets_loop, ( {type => 'Subjects',facets => \@subject_facets_array} );
+    }
+	if (($number_of_subject_facets > 6) && ($expand_subjects)) {
+		$expandable = 1;
+	}
+	else {
+		undef $expandable;
+	}
+	push @facets_loop, ( {type => 'Subjects',typeid => 'subject_facet',facets => \@subject_facets_array, expandable => $expandable,expand => $expand_subjects} );
 
 	# Build series facets
+	my $number_of_series_facets;
 	my @series_facets_array;
+	my $expand_series;
+	$expand_series = 'series' unless ($expanded_facet eq 'series');
 	foreach my $value (sort { $series_facets_counter{$b} <=> $series_facets_counter{$a} } keys %series_facets_counter) {
+		$number_of_series_facets++;
 		my $linkvalue = $value;
 		my $captionvalue = $value;
 		my $count = $series_facets_counter{$value};
 		$linkvalue =~ s/\'/\\\'/g;
 		$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;"}
 		);
 	}
-    push @facets_loop, ( {type => 'Series',facets => \@series_facets_array} );
+	}
+    if (($number_of_series_facets > 6) && ($expand_series)) {
+		$expandable = 1;
+	}
+	else {
+		undef $expandable;
+	}
+    push @facets_loop, ( {type => 'Series',typeid => 'series_facet',facets => \@series_facets_array, expandable => $expandable,expand => $expand_series} );
 
     # Build author facets
+	my $number_of_author_facets;
 	my @author_facets_array;
+	my $expand_authors;
+	$expand_authors = 'au' unless ($expanded_facet eq 'au');
     foreach my $value (sort { $author_facets_counter{$b} <=> $author_facets_counter{$a} } keys %author_facets_counter) {
+		$number_of_author_facets++;
         my $linkvalue = $value;
 		my $captionvalue = $value;
 		my $count = $author_facets_counter{$value};
         $linkvalue =~ s/\'/\\\'/g;
 		$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;"}
         );
     }
-    push @facets_loop, ( {type => 'Authors',facets => \@author_facets_array} );
+    }
+    if (($number_of_author_facets > 6) && ($expand_authors)) {
+	        $expandable = 1;    
+	}    else {
+	        undef $expandable;    
+	}
+    push @facets_loop, ( {type => 'Authors', typeid => 'author_facet',facets => \@author_facets_array, expandable => $expandable, expand => $expand_authors} );
 
 	return(undef,$numresults,\@facets_loop, at results);
 }

Index: koha-tmpl/opac-tmpl/npl/en/includes/navigation.inc
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/opac-tmpl/npl/en/includes/navigation.inc,v
retrieving revision 1.2.2.4.2.10
retrieving revision 1.2.2.4.2.11
diff -u -b -r1.2.2.4.2.10 -r1.2.2.4.2.11
--- koha-tmpl/opac-tmpl/npl/en/includes/navigation.inc	7 Aug 2006 18:41:02 -0000	1.2.2.4.2.10
+++ koha-tmpl/opac-tmpl/npl/en/includes/navigation.inc	7 Aug 2006 19:56:50 -0000	1.2.2.4.2.11
@@ -21,11 +21,14 @@
 <!-- TMPL_IF NAME="opacfacets" -->
 <ul>
 <!-- TMPL_LOOP NAME="facets_loop" -->
-<li><!-- TMPL_VAR NAME="type" --></li>
+<li id=<!-- TMPL_VAR NAME=typeid -->><!-- TMPL_VAR NAME=type --></li>
 <li><ul>
 	<!-- TMPL_LOOP NAME="facets" -->
 		<li><a href="<!-- TMPL_VAR NAME=link -->"><!-- TMPL_VAR NAME="label" --></a>(<!-- TMPL_VAR NAME="count" -->)</li>
 	<!-- /TMPL_LOOP -->
+<!-- TMPL_IF NAME="expandable" -->
+	<li><a href="/cgi-bin/koha/opac-zoomsearch.pl?op=get_results&amp;ccl_query=<!-- TMPL_VAR NAME=searchdesc -->&expand=<!-- TMPL_VAR NAME=expand -->#<!-- TMPL_VAR NAME=typeid -->">-->Show More</a></li>
+<!-- /TMPL_IF -->
 </ul></li>
 <!-- /TMPL_LOOP -->
 </ul>

Index: opac/opac-zoomsearch.pl
===================================================================
RCS file: /sources/koha/koha/opac/Attic/opac-zoomsearch.pl,v
retrieving revision 1.1.2.19
retrieving revision 1.1.2.20
diff -u -b -r1.1.2.19 -r1.1.2.20
--- opac/opac-zoomsearch.pl	7 Aug 2006 18:41:02 -0000	1.1.2.19
+++ opac/opac-zoomsearch.pl	7 Aug 2006 19:56:50 -0000	1.1.2.20
@@ -34,6 +34,9 @@
 my $query=new CGI;
 my $op = $query->param('op'); # show the search form or execute the search
 
+# expanded facet?
+my $expanded_facet = $query->param('expand');
+
 ### Gather up all our search queries
 ## CQL
 my $cql_query = $query->param('cql_query');
@@ -137,24 +140,24 @@
 	# queries are handled differently, so alert our API and pass in the variables
 	if ($ccl_query) { # CCL
         	if ($query->param('scan')) {
-            		($error,$count, $facets, at results) = searchZOOM('scan','ccl',$ccl_query,$number_of_results,$startfrom,$then_sort_by);
+            		($error,$count, $facets, at results) = searchZOOM('scan','ccl',$ccl_query,$number_of_results,$startfrom,$then_sort_by,$expanded_facet);
             		$template->param(scan => 1);
         	} else {
-            		($error,$count,$facets, at results) = searchZOOM('search','ccl',$ccl_query,$number_of_results,$startfrom,$then_sort_by);
+            		($error,$count,$facets, at results) = searchZOOM('search','ccl',$ccl_query,$number_of_results,$startfrom,$then_sort_by,$expanded_facet);
         	}
 	} elsif ($query->param('cql_query')) { # CQL
 		if ($query->param('scan')) {
-			($error,$count,$facets, at results) = searchZOOM('scan','cql',$cql_query,$number_of_results,$startfrom,$then_sort_by);
+			($error,$count,$facets, at results) = searchZOOM('scan','cql',$cql_query,$number_of_results,$startfrom,$then_sort_by,$expanded_facet);
 			$template->param(scan => 1);
 		} else {
-			($error,$count,$facets, at results) = searchZOOM('search','cql',$cql_query,$number_of_results,$startfrom,$then_sort_by);
+			($error,$count,$facets, at results) = searchZOOM('search','cql',$cql_query,$number_of_results,$startfrom,$then_sort_by,$expanded_facet);
 		}
 	} else { # we're in PQF territory now
 		if ($query->param('scan')) {
 			$template->param(scan => 1);
-			($error,$count,$facets, at results) = searchZOOM('scan','pqf',"$pqf_sort_by $pqf_prox_ops $pqf_bool_ops $pqf_query",$number_of_results,$startfrom,$then_sort_by);
+			($error,$count,$facets, at results) = searchZOOM('scan','pqf',"$pqf_sort_by $pqf_prox_ops $pqf_bool_ops $pqf_query",$number_of_results,$startfrom,$then_sort_by,$expanded_facet);
 		} else {
-			($error,$count,$facets, at results) = searchZOOM('search','pqf',"$pqf_sort_by $pqf_prox_ops $pqf_bool_ops $pqf_query",$number_of_results,$startfrom,$then_sort_by);
+			($error,$count,$facets, at results) = searchZOOM('search','pqf',"$pqf_sort_by $pqf_prox_ops $pqf_bool_ops $pqf_query",$number_of_results,$startfrom,$then_sort_by,$expanded_facet);
 		}
 	}
 	@newresults=searchResults( $searchdesc,$number_of_results,$count, at results) ;





More information about the Koha-cvs mailing list