From 321d640037c655c9d9f7727ce7271e3a0afbc43f Mon Sep 17 00:00:00 2001 From: Gabriel DeCarufel Date: Thu, 12 Mar 2020 16:23:42 -0400 Subject: [PATCH] Bug 17385: Added download option in list Signed-off-by: David Nind --- .../prog/en/includes/cat-toolbar.inc | 2 +- .../en/modules/admin/preferences/opac.pref | 2 +- .../prog/en/modules/catalogue/detail.tt | 2 +- .../en/includes/opac-detail-sidebar.inc | 2 +- opac/opac-downloadshelf.pl | 8 +++++-- t/db_dependent/XSLT.t | 22 +++++++++++++++++++ 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index 64fd082012..8a1dbf308b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -98,7 +98,7 @@ CAN_user_serials_create_subscription ) %]
  • MODS (XML)
  • RIS
  • [% FOREACH filesOption IN filesOptions %] -
  • [% filesOption.filename | html %]
  • +
  • XSL - [% filesOption.filename | html %]
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index fda2187f1a..a916fbf975 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -313,7 +313,7 @@ OPAC: mods: MODS ris: RIS isbd: ISBD - custom: Custom + custom: XSL - Simple Export - - pref: OpacSeparateHoldings choices: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 60bcccd540..0c0024e010 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -949,7 +949,7 @@ Note that permanent location is a code, and location may be an authval. [% FOREACH filesOption IN filesOptions %] - + [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc index a89ddf5bee..25112275c6 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc @@ -109,7 +109,7 @@ [% ELSE %] [% FOREACH filesOption IN filesOptions %] -
  • [% filesOption.filename | html %]
  • +
  • XSL - [% filesOption.filename | html %]
  • [% END %] [% END %] [% END %] diff --git a/opac/opac-downloadshelf.pl b/opac/opac-downloadshelf.pl index 99d14a73da..7794ba784b 100755 --- a/opac/opac-downloadshelf.pl +++ b/opac/opac-downloadshelf.pl @@ -28,6 +28,7 @@ use C4::Items; use C4::Output; use C4::Record; use C4::Ris; +use C4::XSLT; use Koha::CsvProfiles; use Koha::RecordProcessor; use Koha::Virtualshelves; @@ -125,13 +126,15 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { }); $extension = "txt"; $type = "text/plain"; - } + }elsif ($format =~ /^xsl\.(.*)$/){ + $output .= XSLTParse4Display($biblionumber, $record, 'XSLTCustomExport', 1, undef, undef, $1, '', 1); + } } } # If it was a CSV export we change the format after the export so the file extension is fine $format = "csv" if ($format =~ m/^\d+$/); - + $format = "html" if ($format =~ /^xsl\./); print $query->header( -type => ($type) ? $type : 'application/octet-stream', -'Content-Transfer-Encoding' => 'binary', @@ -158,6 +161,7 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { ) ] ); + $template->param(xsl_exports => CustomXSLTExportList()); $template->param( shelf => $shelf ); output_html_with_http_headers $query, $cookie, $template->output; } diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t index 5abb8b7c09..1372173b7b 100755 --- a/t/db_dependent/XSLT.t +++ b/t/db_dependent/XSLT.t @@ -102,4 +102,26 @@ subtest 'buildKohaItemsNamespace status tests' => sub { $xml = C4::XSLT::buildKohaItemsNamespace( $item->biblionumber,[]); like($xml,qr{Pending hold},"Pending status takes precedence over all"); }; +subtest 'CustomXSLTExportList: Caching' => sub { + plan tests => 1; + t::lib::Mocks::mock_preference('OpacExportOptions', 'custom'); + $cache->clear_from_cache('CustomXSLTExportListOPAC'); + my $list = C4::XSLT::CustomXSLTExportList(1); + push @$list, { nonsense => 1 }; + $cache->set_in_cache('CustomXSLTExportListOPAC', $list ); + my $n = @$list; + $list = C4::XSLT::CustomXSLTExportList(1); + is( @$list, $n, 'This list comes from the cache and that is fine' ); + $cache->clear_from_cache('CustomXSLTExportListOPAC'); +}; +subtest 'CustomXSLTExportList: Check export options' => sub { + plan tests => 2; + t::lib::Mocks::mock_preference('OpacExportOptions', 'custom'); + my $list = C4::XSLT::CustomXSLTExportList(1); + is( $list>0, 1, 'We expect at least one result: simple export' ); + $cache->clear_from_cache('CustomXSLTExportListOPAC'); + t::lib::Mocks::mock_preference('OpacExportOptions', 'dc'); + $list = C4::XSLT::CustomXSLTExportList(1); + is( @$list, 0, 'We expect an empty list now' ); +}; $schema->storage->txn_rollback; -- 2.17.1