Bug 24488: perf - Group by at DBMS level
[srvgit] / opac / opac-shelves.pl
index c0140c7..b94b412 100755 (executable)
@@ -33,6 +33,7 @@ use C4::XSLT;
 use Koha::Biblios;
 use Koha::Biblioitems;
 use Koha::CirculationRules;
+use Koha::CsvProfiles;
 use Koha::Items;
 use Koha::ItemTypes;
 use Koha::Patrons;
@@ -41,7 +42,7 @@ use Koha::RecordProcessor;
 
 use constant ANYONE => 2;
 
-my $query = new CGI;
+my $query = CGI->new;
 
 my $template_name = $query->param('rss') ? "opac-shelves-rss.tt" : "opac-shelves.tt";
 
@@ -316,9 +317,17 @@ if ( $op eq 'view' ) {
                 });
                 $record_processor->process($record);
 
-                if ( $xslfile ) {
-                    $this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "OPACXSLTListsDisplay",
-                                                                1, undef, $sysxml, $xslfile, $lang);
+                if ($xslfile) {
+                    my $variables = {
+                        anonymous_session => ($loggedinuser) ? 0 : 1
+                    };
+                    $this_item->{XSLTBloc} = XSLTParse4Display(
+                        $biblionumber,          $record,
+                        "OPACXSLTListsDisplay", 1,
+                        undef,                  $sysxml,
+                        $xslfile,               $lang,
+                        $variables
+                    );
                 }
 
                 my $marcflavour = C4::Context->preference("marcflavour");
@@ -377,6 +386,11 @@ if ( $op eq 'view' ) {
                 itemsloop          => \@items,
                 sortfield          => $sortfield,
                 direction          => $direction,
+                csv_profiles => [
+                    Koha::CsvProfiles->search(
+                        { type => 'marc', used_for => 'export_records', staff_only => 0 }
+                    )
+                ],
             );
             if ( $page ) {
                 my $pager = $contents->pager;
@@ -425,4 +439,5 @@ $template->param(
     listsview => 1,
 );
 
-output_html_with_http_headers $query, $cookie, $template->output;
+my $content_type = $query->param('rss')? 'rss' : 'html';
+output_with_http_headers $query, $cookie, $template->output, $content_type;