[Koha-cvs] koha/opac search [dev_week]

Joshua Ferraro jmf at kados.org
Sun Oct 8 20:42:45 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Joshua Ferraro <kados>	06/10/08 18:42:45

Modified files:
	opac           : search 

Log message:
	making the page numbers look like google:
	
	for pages 1-10, there are 10 pages displayed with the current page floating
	within them
	
	for pages above 10, there are 20 pages displayed with the current page
	floating in the center.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/opac/search?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.5&r2=1.1.2.6

Patches:
Index: search
===================================================================
RCS file: /sources/koha/koha/opac/Attic/search,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -b -r1.1.2.5 -r1.1.2.6
--- search	24 Sep 2006 20:18:02 -0000	1.1.2.5
+++ search	8 Oct 2006 18:42:45 -0000	1.1.2.6
@@ -2,7 +2,7 @@
 # Script to perform searching
 # For documentation try 'perldoc /path/to/search'
 #
-# $Header: /sources/koha/koha/opac/Attic/search,v 1.1.2.5 2006/09/24 20:18:02 kados Exp $
+# $Header: /sources/koha/koha/opac/Attic/search,v 1.1.2.6 2006/10/08 18:42:45 kados Exp $
 #
 # Copyright 2006 LibLime
 #
@@ -409,18 +409,39 @@
     		$template->param(results_per_page =>  $results_per_page);
     		$template->param(SEARCH_RESULTS => \@newresults);
 
+			## Build the page numbers on the bottom of the page
 			my @page_numbers;
+
+			# total number of pages there will be
 			my $pages = ceil($hits / $results_per_page);
+
+			# default page number
 			my $current_page_number = 1;
 			$current_page_number = ($offset / $results_per_page + 1) if $offset;
 			my $previous_page_offset = $offset - $results_per_page unless ($offset - $results_per_page <0);
 			my $next_page_offset = $offset + $results_per_page;
-			for ($i=1; $i<=$pages;$i++) {
+
+			# If we're within the first 10 pages, keep it simple
+			if ($current_page_number < 10) {
+				# just show the first 10 pages
+				for ($i=1; $i<=10;$i++) {
 				my $this_offset = (($i*$results_per_page)-$results_per_page);
 				my $this_page_number = $i;
 				my $highlight = 1 if ($this_page_number == $current_page_number);
 				push @page_numbers, { offset => $this_offset, pg => $this_page_number, highlight => $highlight, sort_by => join " ", at sort_by };
 			}
+			}
+			# now, show twenty pages, with the current one smack in the middle
+			else {
+				for ($i=$current_page_number; $i<=($current_page_number + 20);$i++) {
+                    my $this_offset = ((($i-9)*$results_per_page)-$results_per_page);
+                    my $this_page_number = $i-9;
+                    my $highlight = 1 if ($this_page_number == $current_page_number);
+                    push @page_numbers, { offset => $this_offset, pg => $this_page_number, highlight => $highlight, sort_by => join " ", at sort_by };
+                }
+	
+			}
+
 			$template->param(PAGE_NUMBERS => \@page_numbers,
 							previous_page_offset => $previous_page_offset,
 							next_page_offset => $next_page_offset) unless $pages < 2;





More information about the Koha-cvs mailing list