$VERSION = 3.01;
$DEBUG = ($ENV{DEBUG}) ? 1 : 0;
}
-
+$DEBUG=1;
=head1 NAME
C4::Search - Functions for searching the Koha catalog.
=head2 SimpleSearch
-($error,$results) = SimpleSearch( $query, $offset, $max_results, [ @servers ] );
+( $error, $results, $total_hits ) = SimpleSearch( $query, $offset, $max_results, [@servers] );
This function provides a simple search API on the bibliographic catalog
* $max_results - if present, determines the maximum number of records to fetch. undef is All. defaults to undef.
-=item C<Output arg:>
+=item C<Output:>
+
* $error is a empty unless an error is detected
* \@results is an array of records.
+ * $total_hits is the number of hits that would have been returned with no limit
=item C<usage in the script:>
=back
-my ($error, $marcresults) = SimpleSearch($query);
+my ( $error, $marcresults, $total_hits ) = SimpleSearch($query);
if (defined $error) {
$template->param(query_error => $error);
my $hits = scalar @$marcresults;
my @results;
-for(my $i=0;$i<$hits;$i++) {
+for my $i (0..$hits) {
my %resultsloop;
my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]);
my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,'');
expandable => $expandable,
expand => $link_value,
}
- );
+ ) unless ( ($facets_info->{$link_value}->{'label_value'} =~ /Libraries/) and (C4::Context->preference('singleBranchMode')) );
}
}
}
foreach ( keys %{ C4::Context->stopwords } ) {
next if ( $_ =~ /(and|or|not)/ ); # don't remove operators
if ( $operand =~
- /(\P{IsAlpha}$_\P{IsAlpha}|^$_\P{IsAlpha}|\P{IsAlpha}$_$)/ )
+ /(\P{IsAlpha}$_\P{IsAlpha}|^$_\P{IsAlpha}|\P{IsAlpha}$_$|^$_$)/ )
{
$operand =~ s/\P{IsAlpha}$_\P{IsAlpha}/ /gi;
$operand =~ s/^$_\P{IsAlpha}/ /gi;
$operand =~ s/\P{IsAlpha}$_$/ /gi;
+ $operand =~ s/$1//gi;
push @stopwords_removed, $_;
}
}
# IMO this subroutine is pretty messy still -- it's responsible for
# building the HTML output for the template
sub searchResults {
- my ( $searchdesc, $hits, $results_per_page, $offset, @marcresults ) = @_;
+ my ( $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults ) = @_;
my $dbh = C4::Context->dbh;
my $even = 1;
my @newresults;
}
# XSLT processing of some stuff
- if (C4::Context->preference("XSLTResultsDisplay") ) {
+ if (C4::Context->preference("XSLTResultsDisplay") && !$scan) {
my $newxmlrecord = XSLTParse4Display($oldbiblio->{biblionumber},C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACResults.xsl");
$oldbiblio->{XSLTResultsRecord} = $newxmlrecord;
}