[Koha-patches] [PATCH] Porting SimpleSearch return changes to all code calling it.
Chris Nighswonger
cnighswonger at foundations.edu
Tue Apr 15 14:41:56 CEST 2008
---
C4/AuthoritiesMarc.pm | 2 +-
C4/Heading.pm | 4 ++--
C4/Matcher.pm | 2 +-
cataloguing/addbiblio.pl | 2 +-
cataloguing/addbooks.pl | 2 +-
cataloguing/value_builder/unimarc_field_4XX.pl | 2 +-
labels/label-item-search.pl | 7 ++++---
opac/opac-rss.pl | 2 +-
serials/subscription-bib-search.pl | 2 +-
9 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm
index c46187d..28d36cb 100644
--- a/C4/AuthoritiesMarc.pm
+++ b/C4/AuthoritiesMarc.pm
@@ -802,7 +802,7 @@ sub FindDuplicateAuthority {
# build a request for SearchAuthorities
my $query='at='.$authtypecode.' ';
map {$query.= " and he=\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/)} $record->field($auth_tag_to_report)->subfields() if $record->field($auth_tag_to_report);
- my ($error,$results)=SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
+ my ($error, $results, $total_hits)=SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
# there is at least 1 result => return the 1st one
if (@$results>0) {
my $marcrecord = MARC::File::USMARC::decode($results->[0]);
diff --git a/C4/Heading.pm b/C4/Heading.pm
index 0371d2a..3f0302d 100644
--- a/C4/Heading.pm
+++ b/C4/Heading.pm
@@ -119,7 +119,7 @@ sub authorities {
my $self = shift;
my $query = qq(Match-heading,ext="$self->{'search_form'}");
$query .= $self->_query_limiters();
- my $results = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
+ my ($error, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
return $results;
}
@@ -140,7 +140,7 @@ sub preferred_authorities {
my $self = shift;
my $query = "Match-heading-see-from,ext='$self->{'search_form'}'";
$query .= $self->_query_limiters();
- my $results = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
+ my ($error, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
return $results;
}
diff --git a/C4/Matcher.pm b/C4/Matcher.pm
index 210c8fa..a0f1a98 100644
--- a/C4/Matcher.pm
+++ b/C4/Matcher.pm
@@ -661,7 +661,7 @@ sub get_matches {
# build query
my $query = join(" or ", map { "$matchpoint->{'index'}=$_" } @source_keys);
# FIXME only searching biblio index at the moment
- my ($error, $searchresults) = SimpleSearch($query);
+ my ($error, $searchresults, $total_hits) = SimpleSearch($query);
warn "search failed ($query) $error" if $error;
foreach my $matched (@$searchresults) {
diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl
index cd6f1e1..c16c426 100755
--- a/cataloguing/addbiblio.pl
+++ b/cataloguing/addbiblio.pl
@@ -695,7 +695,7 @@ AND (authtypecode IS NOT NULL AND authtypecode<>\"\")|);
# Search if there is any authorities to link to.
my $query='at='.$data->{authtypecode}.' ';
map {$query.= ' and he,ext="'.$_->[1].'"' if ($_->[0]=~/[A-z]/)} $field->subfields();
- my ($error,$results)=SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
+ my ($error, $results, $total_hits)=SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
# there is only 1 result
if ( $error ) {
warn "BIBLIOADDSAUTHORITIES: $error";
diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl
index a24797b..1876133 100755
--- a/cataloguing/addbooks.pl
+++ b/cataloguing/addbooks.pl
@@ -68,7 +68,7 @@ foreach my $thisframeworkcode ( keys %$frameworks ) {
if ($query) {
# find results
- my ( $error, $marcresults ) = SimpleSearch($query);
+ my ( $error, $marcresults, $total_hits ) = SimpleSearch($query);
if ( defined $error ) {
$template->param( error => $error );
diff --git a/cataloguing/value_builder/unimarc_field_4XX.pl b/cataloguing/value_builder/unimarc_field_4XX.pl
index a7094c7..44bc27c 100755
--- a/cataloguing/value_builder/unimarc_field_4XX.pl
+++ b/cataloguing/value_builder/unimarc_field_4XX.pl
@@ -330,7 +330,7 @@ sub plugin {
my $startfrom = $query->param('startfrom');
my $resultsperpage = $query->param('resultsperpage');
my $orderby;
- my ( $errors, $results ) = SimpleSearch($search);
+ my ( $errors, $results, $total_hits ) = SimpleSearch($search);
my $total = scalar(@$results);
$resultsperpage = 20 unless $resultsperpage;
diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl
index 22ea645..a967dcc 100755
--- a/labels/label-item-search.pl
+++ b/labels/label-item-search.pl
@@ -58,6 +58,7 @@ my $dbh = C4::Context->dbh;
my $startfrom = $query->param('startfrom') || 0;
my ( $template, $loggedinuser, $cookie );
+my $total_hits;
my (@marclist, at and_or, at excluding, at operator, at value,$orderby, at tags,$results,$total,$error,$marcresults);
# XXX should this be maxItemsInSearchResults or numSearchResults preference instead of 19?
my $resultsperpage = $query->param('resultsperpage') || 19;
@@ -74,8 +75,7 @@ if ( $op eq "do_search" ) {
#catalogsearch( $dbh, \@tags, \@and_or, \@excluding, \@operator, \@value,
# $startfrom * $resultsperpage,
# $resultsperpage, $orderby );
- ( $error, $marcresults, $total ) = SimpleSearch( $marclist[0], $startfrom, $resultsperpage );
- warn "\$total=$total";
+ ( $error, $marcresults, $total_hits ) = SimpleSearch( $marclist[0], $startfrom, $resultsperpage );
if ($marcresults) {
$show_results = scalar @$marcresults;
} else {
@@ -150,6 +150,7 @@ if ( $show_results ) {
}
my @numbers = ();
+ $total = $total_hits;
if ( $total > $resultsperpage ) {
for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
if ( $i < 16 ) {
@@ -183,7 +184,7 @@ if ( $show_results ) {
startfromnext => $startfrom + min( $resultsperpage, scalar @results ),
startfromprev => max( $startfrom - $resultsperpage, 0 ),
searchdata => \@field_data,
- total => $total,
+ total => $total_hits,
from => $startfrom + 1,
to => $startfrom + min( $resultsperpage, scalar @results ),
numbers => \@numbers,
diff --git a/opac/opac-rss.pl b/opac/opac-rss.pl
index d73a6cb..864a7c1 100755
--- a/opac/opac-rss.pl
+++ b/opac/opac-rss.pl
@@ -122,7 +122,7 @@ if ($RDF_update_needed) {
);
warn "fetching $size results for $query";
- my ( $error, $marcresults ) = SimpleSearch( $query, 0, $size );
+ my ( $error, $marcresults, $total_hits ) = SimpleSearch( $query, 0, $size );
my $hits = scalar @$marcresults;
my @results;
diff --git a/serials/subscription-bib-search.pl b/serials/subscription-bib-search.pl
index 3e8d7a9..f8e77ee 100755
--- a/serials/subscription-bib-search.pl
+++ b/serials/subscription-bib-search.pl
@@ -78,7 +78,7 @@ if ($op eq "do_search" && $query) {
$resultsperpage= $input->param('resultsperpage');
$resultsperpage = 19 if(!defined $resultsperpage);
- my ($error,$marcrecords) = SimpleSearch($query);
+ my ($error, $marcrecords, $total_hits) = SimpleSearch($query);
my $total = scalar @$marcrecords;
if (defined $error) {
--
1.5.3.7
More information about the Koha-patches
mailing list