bug 4311: respect OPACXSLTResultsDisplay
Check OPACXSLTResultsDisplay instead of XSLTResultsDisplay when determining whether to use the XSLT bib results stylesheet for OPAC search results. In the process, added a new $search_context parameter to C4::Search::searchResults() to specify whether results are to be served up for the staff interface or for the OPAC. Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This commit is contained in:
parent
f243b83ec0
commit
b1ed3af633
4 changed files with 18 additions and 8 deletions
16
C4/Search.pm
16
C4/Search.pm
|
@ -1345,6 +1345,10 @@ sub buildQuery {
|
||||||
|
|
||||||
=head2 searchResults
|
=head2 searchResults
|
||||||
|
|
||||||
|
my @search_results = searchResults($search_context, $searchdesc, $hits,
|
||||||
|
$results_per_page, $offset, $scan,
|
||||||
|
@marcresults, $hidelostitems);
|
||||||
|
|
||||||
Format results in a form suitable for passing to the template
|
Format results in a form suitable for passing to the template
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
@ -1352,10 +1356,12 @@ Format results in a form suitable for passing to the template
|
||||||
# IMO this subroutine is pretty messy still -- it's responsible for
|
# IMO this subroutine is pretty messy still -- it's responsible for
|
||||||
# building the HTML output for the template
|
# building the HTML output for the template
|
||||||
sub searchResults {
|
sub searchResults {
|
||||||
my ( $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults, $hidelostitems ) = @_;
|
my ( $search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults, $hidelostitems ) = @_;
|
||||||
my $dbh = C4::Context->dbh;
|
my $dbh = C4::Context->dbh;
|
||||||
my @newresults;
|
my @newresults;
|
||||||
|
|
||||||
|
$search_context = 'opac' unless $search_context eq 'opac' or $search_context eq 'intranet';
|
||||||
|
|
||||||
#Build branchnames hash
|
#Build branchnames hash
|
||||||
#find branchname
|
#find branchname
|
||||||
#get branch information.....
|
#get branch information.....
|
||||||
|
@ -1664,9 +1670,11 @@ sub searchResults {
|
||||||
use C4::Charset;
|
use C4::Charset;
|
||||||
SetUTF8Flag($marcrecord);
|
SetUTF8Flag($marcrecord);
|
||||||
$debug && warn $marcrecord->as_formatted;
|
$debug && warn $marcrecord->as_formatted;
|
||||||
if (C4::Context->preference("XSLTResultsDisplay") && !$scan) {
|
if (!$scan && $search_context eq 'opac' && C4::Context->preference("OPACXSLTResultsDisplay")) {
|
||||||
$oldbiblio->{XSLTResultsRecord} = XSLTParse4Display(
|
# FIXME note that XSLTResultsDisplay (use of XSLT to format staff interface bib search results)
|
||||||
$oldbiblio->{biblionumber}, $marcrecord, 'Results' );
|
# is not implemented yet
|
||||||
|
$oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, 'Results',
|
||||||
|
$search_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
# last check for norequest : if itemtype is notforloan, it can't be reserved either, whatever the items
|
# last check for norequest : if itemtype is notforloan, it can't be reserved either, whatever the items
|
||||||
|
|
|
@ -513,7 +513,8 @@ for (my $i=0;$i<@servers;$i++) {
|
||||||
if ($server =~/biblioserver/) { # this is the local bibliographic server
|
if ($server =~/biblioserver/) { # this is the local bibliographic server
|
||||||
$hits = $results_hashref->{$server}->{"hits"};
|
$hits = $results_hashref->{$server}->{"hits"};
|
||||||
my $page = $cgi->param('page') || 0;
|
my $page = $cgi->param('page') || 0;
|
||||||
my @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,$scan,@{$results_hashref->{$server}->{"RECORDS"}});
|
my @newresults = searchResults('intranet', $query_desc, $hits, $results_per_page, $offset, $scan,
|
||||||
|
@{$results_hashref->{$server}->{"RECORDS"}});
|
||||||
$total = $total + $results_hashref->{$server}->{"hits"};
|
$total = $total + $results_hashref->{$server}->{"hits"};
|
||||||
## If there's just one result, redirect to the detail page
|
## If there's just one result, redirect to the detail page
|
||||||
if ($total == 1) {
|
if ($total == 1) {
|
||||||
|
|
|
@ -86,7 +86,7 @@ if ($query) {
|
||||||
# format output
|
# format output
|
||||||
# SimpleSearch() give the results per page we want, so 0 offet here
|
# SimpleSearch() give the results per page we want, so 0 offet here
|
||||||
my $total = scalar @$marcresults;
|
my $total = scalar @$marcresults;
|
||||||
my @newresults = searchResults( $query, $total, $results_per_page, 0, 0, @$marcresults );
|
my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, @$marcresults );
|
||||||
$template->param(
|
$template->param(
|
||||||
total => $total_hits,
|
total => $total_hits,
|
||||||
query => $query,
|
query => $query,
|
||||||
|
|
|
@ -442,12 +442,13 @@ for (my $i=0;$i<=@servers;$i++) {
|
||||||
# because pazGetRecords handles retieving only the records
|
# because pazGetRecords handles retieving only the records
|
||||||
# we want as specified by $offset and $results_per_page,
|
# we want as specified by $offset and $results_per_page,
|
||||||
# we need to set the offset parameter of searchResults to 0
|
# we need to set the offset parameter of searchResults to 0
|
||||||
my @group_results = searchResults( $query_desc, $group->{'group_count'},$results_per_page, 0, $scan,
|
my @group_results = searchResults( 'opac', $query_desc, $group->{'group_count'},$results_per_page, 0, $scan,
|
||||||
@{ $group->{"RECORDS"} }, C4::Context->preference('hidelostitems'));
|
@{ $group->{"RECORDS"} }, C4::Context->preference('hidelostitems'));
|
||||||
push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results };
|
push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,$scan,@{$results_hashref->{$server}->{"RECORDS"}},, C4::Context->preference('hidelostitems'));
|
@newresults = searchResults('opac', $query_desc, $hits, $results_per_page, $offset, $scan,
|
||||||
|
@{$results_hashref->{$server}->{"RECORDS"}},, C4::Context->preference('hidelostitems'));
|
||||||
}
|
}
|
||||||
my $tag_quantity;
|
my $tag_quantity;
|
||||||
if (C4::Context->preference('TagsEnabled') and
|
if (C4::Context->preference('TagsEnabled') and
|
||||||
|
|
Loading…
Reference in a new issue