From b1ed3af63350d0d754fb309644b3d57be707041b Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 25 May 2010 11:00:29 -0400 Subject: [PATCH] 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 --- C4/Search.pm | 16 ++++++++++++---- catalogue/search.pl | 3 ++- cataloguing/addbooks.pl | 2 +- opac/opac-search.pl | 5 +++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 229ee40e19..b1a23e9da6 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1345,6 +1345,10 @@ sub buildQuery { =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 =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 # building the HTML output for the template 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 @newresults; + $search_context = 'opac' unless $search_context eq 'opac' or $search_context eq 'intranet'; + #Build branchnames hash #find branchname #get branch information..... @@ -1664,9 +1670,11 @@ sub searchResults { use C4::Charset; SetUTF8Flag($marcrecord); $debug && warn $marcrecord->as_formatted; - if (C4::Context->preference("XSLTResultsDisplay") && !$scan) { - $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display( - $oldbiblio->{biblionumber}, $marcrecord, 'Results' ); + if (!$scan && $search_context eq 'opac' && C4::Context->preference("OPACXSLTResultsDisplay")) { + # FIXME note that XSLTResultsDisplay (use of XSLT to format staff interface bib search 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 diff --git a/catalogue/search.pl b/catalogue/search.pl index 5f0286b611..920afb776a 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -513,7 +513,8 @@ for (my $i=0;$i<@servers;$i++) { if ($server =~/biblioserver/) { # this is the local bibliographic server $hits = $results_hashref->{$server}->{"hits"}; 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"}; ## If there's just one result, redirect to the detail page if ($total == 1) { diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl index 4ee7141663..4c8a9898ab 100755 --- a/cataloguing/addbooks.pl +++ b/cataloguing/addbooks.pl @@ -86,7 +86,7 @@ if ($query) { # format output # SimpleSearch() give the results per page we want, so 0 offet here 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( total => $total_hits, query => $query, diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 34491c355d..a142cb1f93 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -442,12 +442,13 @@ for (my $i=0;$i<=@servers;$i++) { # because pazGetRecords handles retieving only the records # we want as specified by $offset and $results_per_page, # 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')); push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results }; } } 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; if (C4::Context->preference('TagsEnabled') and -- 2.39.5