[Koha-cvs] koha/opac opac-search.pl [rel_3_0]
Antoine Farnault
antoine at koha-fr.org
Thu Oct 19 17:33:48 CEST 2006
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: Antoine Farnault <toins> 06/10/19 15:33:48
Modified files:
opac : opac-search.pl
Log message:
sync with dev_week.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-search.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.38.2.3&r2=1.38.2.4
Patches:
Index: opac-search.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-search.pl,v
retrieving revision 1.38.2.3
retrieving revision 1.38.2.4
diff -u -b -r1.38.2.3 -r1.38.2.4
--- opac-search.pl 9 Oct 2006 16:47:31 -0000 1.38.2.3
+++ opac-search.pl 19 Oct 2006 15:33:48 -0000 1.38.2.4
@@ -3,7 +3,7 @@
# Script to perform searching
# For documentation try 'perldoc /path/to/search'
#
-# $Header: /sources/koha/koha/opac/opac-search.pl,v 1.38.2.3 2006/10/09 16:47:31 toins Exp $
+# $Header: /sources/koha/koha/opac/opac-search.pl,v 1.38.2.4 2006/10/19 15:33:48 toins Exp $
#
# Copyright 2006 LibLime
#
@@ -164,12 +164,12 @@
# decide which template to use
my $template_name;
my @params = $cgi->param("limit");
-if ((@params>1) || ($cgi->param("q")) ) {
- #warn "loading results";
+if ((@params>0) || ($cgi->param("q")) ) {
+ warn "loading results";
$template_name = 'opac-results.tmpl';
}
else {
- #warn "loading adv search page";
+ warn "loading adv search page";
$template_name = 'opac-advsearch.tmpl';
}
@@ -223,7 +223,7 @@
$template->param(branchloop => \@branch_loop,);
# load the itemtypes (Called Collection Codes in the template -- used for circ rules )
-my ($itemtypecount, at item_type_loop) = &GetItemTypes();
+my ($itemtypecount, at item_type_loop) = GetItemTypes();
$template->param(itemtypeloop=>\@item_type_loop,);
# load the itypes (Called item types in the template -- just authorized values for searching)
@@ -400,13 +400,18 @@
for (my $i=0;$i<=@servers;$i++) {
my $server = $servers[$i];
- if ($server =~/biblio/) { # this is the local bibliographic server
+ if ($server =~/biblioserver/) { # this is the local bibliographic server
$hits = $results_hashref->{$server}->{"hits"};
# build results for the template.
my @newresults = searchResults( $search_desc,$hits,$results_per_page,$offset,@{$results_hashref->{$server}->{"RECORDS"}});
-
$total = $total + $results_hashref->{$server}->{"hits"};
+ ## If there's just one result, redirect to the detail page
+ if ($total == 1) {
+ my $biblionumber=@newresults[0]->{biblionumber};
+ print $cgi->redirect("/bib/$biblionumber");
+ exit;
+ }
if ($hits) {
$template->param(total => $hits);
$template->param(searchdesc => $search_desc );
@@ -415,20 +420,32 @@
## 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;
+
# If we're within the first 10 pages, keep it simple
+ #warn "current page:".$current_page_number;
if ($current_page_number < 10) {
# just show the first 10 pages
- for ($i=1; $i<=10;$i++) {
+ #
+ # Loop through the pages
+ my $pages_to_show = 10;
+ $pages_to_show = $pages if $pages<10;
+ for ($i=1; $i<=$pages_to_show;$i++) {
+ # the offset for this page
my $this_offset = (($i*$results_per_page)-$results_per_page);
+ # the page number for this page
my $this_page_number = $i;
+ # it should only be highlighted if it's the current page
my $highlight = 1 if ($this_page_number == $current_page_number);
+ # put it in the array
push @page_numbers, { offset => $this_offset, pg => $this_page_number, highlight => $highlight, sort_by => join " ", at sort_by };
}
}
@@ -472,6 +489,8 @@
} #/end of the for loop
#$template->param(FEDERATED_RESULTS => \@results_array);
+
+
$template->param('Disable_Dictionary'=>C4::Context->preference("Disable_Dictionary")) if (C4::Context->preference("Disable_Dictionary"));
$template->param(
@@ -492,6 +511,7 @@
scan_use => $scan,
search_error => $error,
);
+
## Now let's find out if we have any supplemental data to show the user
# and in the meantime, save the current query for statistical purposes, etc.
my $koha_spsuggest; # a flag to tell if we've got suggestions coming from Koha
@@ -504,7 +524,7 @@
my $koha_spsuggest_dbh;
# FIXME: this needs to be moved to Context.pm
eval {
- $koha_spsuggest_dbh=DBI->connect("DBI:mysql:suggest:66.213.78.76","auth","Free2cirC");
+ $koha_spsuggest_dbh=DBI->connect("DBI:mysql:suggest:66.213.78.79","auth","Free2cirC");
};
if ($@) { warn "can't connect to spsuggest db";
}
More information about the Koha-cvs
mailing list