$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;
$oldbiblio->{result_number} = $i + 1;
# add imageurl to itemtype if there is one
- if ( $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} =~ /^http:/ ) {
- $oldbiblio->{imageurl} =
- $itemtypes{ $oldbiblio->{itemtype} }->{imageurl};
- } else {
- $oldbiblio->{imageurl} =
- getitemtypeimagesrc() . "/"
- . $itemtypes{ $oldbiblio->{itemtype} }->{imageurl}
- if ( $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} );
- }
+ $oldbiblio->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} );
+
my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $oldbiblio->{biblionumber} ) );
$oldbiblio->{authorised_value_images} = $biblio_authorised_value_images;
- my $aisbn = $oldbiblio->{'isbn'};
- $aisbn =~ /(\d*[X]*)/;
- $oldbiblio->{amazonisbn} = $1;
+ (my $aisbn) = $oldbiblio->{isbn} =~ /([\d-]*[X]*)/;
+ $aisbn =~ s/-//g;
+ $oldbiblio->{amazonisbn} = $aisbn;
$oldbiblio->{description} = $itemtypes{ $oldbiblio->{itemtype} }->{description};
# Build summary if there is one (the summary is defined in the itemtypes table)
# FIXME: is this used anywhere, I think it can be commented out? -- JF
$onloan_items->{$key}->{branchname} = $item->{branchname};
$onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} };
$onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber};
- $onloan_items->{$key}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl};
+ $onloan_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
# if something's checked out and lost, mark it as 'long overdue'
if ( $item->{itemlost} ) {
$onloan_items->{$prefix}->{longoverdue}++;
$other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value;
$other_items->{$key}->{count}++ if $item->{homebranch};
$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
- $other_items->{$key}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl};
+ $other_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
}
# item is available
else {
$available_items->{$prefix}->{$_} = $item->{$_};
}
$available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
- $available_items->{$prefix}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl};
+ $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
}
}
} # notforloan, item level and biblioitem level
}
# 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;
}