bug 4311: respect OPACXSLTResultsDisplay
authorGalen Charlton <gmcharlt@gmail.com>
Tue, 25 May 2010 15:00:29 +0000 (11:00 -0400)
committerGalen Charlton <gmcharlt@gmail.com>
Tue, 25 May 2010 15:22:47 +0000 (11:22 -0400)
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>
C4/Search.pm
catalogue/search.pl
cataloguing/addbooks.pl
opac/opac-search.pl

index 229ee40..b1a23e9 100644 (file)
@@ -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
index 5f0286b..920afb7 100755 (executable)
@@ -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) {         
index 4ee7141..4c8a989 100755 (executable)
@@ -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,
index 34491c3..a142cb1 100755 (executable)
@@ -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