From 565a374722914d15070be0f6a15b0dbd6b2079a8 Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Tue, 29 Nov 2022 20:57:02 +0000 Subject: [PATCH] This patch adds 'XSL-Simple Export' when saving a bibliographic record To test: 1) Search for a record in the intranet. 2) Click on the 'Save' button and observe the dropdown menu. 3) Notice that 'XSL- Simple Export' is not in the menu. 4) Apply the patch. 5) In System preferences search for OpacExportOptions and enable XSL 6) Repeat the steps 1 and 2. 7) Notice that 'XSL - Simple Export' is in the menu. 8) Click on 'XSL - Simple Export'. A .html file should be downloaded. 9) Open the .html file. You should see the record's informations. 10) Add some items to your Cart 11) Open the Cart 12) Click on the 'Download' button and observe the dropdown menu. 13) Notice that 'XSL - Simple Export' is in the menu. 14) Click on 'XSL - Simple Export'. A .html file should be downloaded. 15) Open the .html file. You should see the record's informations. 16) Add some items to a List 17) Open the List 18) Click on the 'Download' button and observe the dropdown menu. 19) Notice that 'XSL - Simple Export' is in the menu. 20) Click on 'XSL - Simple Export'. A .html file should be downloaded. 21) Open the .html file. You should see the record's informations. 22) Do the same steps in OPAC 23) In System preferences search for OpacExportOptions and disable XSL 24) Repeat all steps 25) Notice that 'XSL - Simple Export' is no more in the menus. https://bugs.koha-community.org/show_bug.cgi?id=17385 --- C4/XSLT.pm | 1 - basket/downloadcart.pl | 8 +++++--- .../prog/en/includes/virtualshelves-toolbar.inc | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt | 2 +- .../bootstrap/en/includes/opac-detail-sidebar.inc | 9 +++++---- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt | 8 ++++++++ koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 8 ++++++++ opac/opac-basket.pl | 2 ++ opac/opac-downloadcart.pl | 7 +++++-- opac/opac-downloadshelf.pl | 7 +++++-- opac/opac-shelves.pl | 3 ++- t/XSLT.t | 4 ---- virtualshelves/downloadshelf.pl | 2 ++ 13 files changed, 44 insertions(+), 19 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index d0dcb6e91b..031c95c99a 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -238,7 +238,6 @@ sub XSLTParse4Display { my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); my $biblio; - my $variables ||= {}; if (C4::Context->preference('OPACShowOpenURL')) { my @biblio_itemtypes; diff --git a/basket/downloadcart.pl b/basket/downloadcart.pl index 70c8d0f065..69438ee179 100755 --- a/basket/downloadcart.pl +++ b/basket/downloadcart.pl @@ -66,6 +66,7 @@ if ($bib_list && $format) { my $biblio = Koha::Biblios->find($biblionumber); my $record = $biblio->metadata->record({ embed_items => 1 }); + my $xslFile = $query->param("file"); next unless $record; if ($format eq 'iso2709') { @@ -83,10 +84,11 @@ if ($bib_list && $format) { $output .= XSLTParse4Display( { biblionumber => $biblio, - record => $record, - xsl_syspref => "XSLTCustomExport", - fix_amps => 1, + record => $record, + xsl_syspref => "XSLTCustomExport", + fix_amps => 1, hidden_items => undef, + xslfilename => $xslFile, } ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc index c241f343f3..acfecbb3b7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc @@ -32,7 +32,7 @@
  • CSV - [% csv_profile.profile | html %]
  • [% END %] [% FOREACH xsl_export IN xsl_exports %] -
  • XSL - [% xsl_export.filename | html %]
  • +
  • XSL - [% xsl_export.filename | html %]
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt index 73b6c3e12c..4eacbf5856 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt @@ -59,7 +59,7 @@
  • CSV - [% csv_profile.profile | html %]
  • [% END %] [% FOREACH xsl_export IN xsl_exports %] -
  • XSL - [% xsl_export.filename | html %]
  • +
  • XSL - [% xsl_export.filename | html %]
  • [% 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 880f002967..95fe80cd56 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 @@ -83,12 +83,13 @@ [% ELSE %] [% FOREACH filesOption IN filesOptions %] - XSL - [% filesOption.filename | html %] + XSL - [% filesOption.filename | html %] [% END %] [% END %] - - - + [% END %] + + + [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt index 4e6219c0bd..b6d3ad747c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt @@ -28,6 +28,7 @@ Send [% END %] + [% SET export_options = Koha.Preference('OpacExportOptions').split(',') %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index 93a35b7225..d7049dba96 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -222,6 +222,7 @@
    New list | + [% SET export_options = Koha.Preference('OpacExportOptions').split(',') %] diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl index 411ae6444c..58a7eefe2c 100755 --- a/opac/opac-basket.pl +++ b/opac/opac-basket.pl @@ -28,6 +28,7 @@ use C4::Biblio qw( ); use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); +use C4::XSLT qw( CustomXSLTExportList ); use Koha::RecordProcessor; use Koha::CsvProfiles; use Koha::AuthorisedValues; @@ -154,6 +155,7 @@ $template->param( { type => 'marc', used_for => 'export_records', staff_only => 0 } ), bib_list => $bib_list, BIBLIO_RESULTS => $resultsarray, + xsl_exports => CustomXSLTExportList(), ); output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl index f428471d5d..2488249613 100755 --- a/opac/opac-downloadcart.pl +++ b/opac/opac-downloadcart.pl @@ -28,7 +28,8 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Record; use C4::Ris qw( marc2ris ); use Koha::Biblios; -use C4::XSLT; +use C4::XSLT qw( XSLTParse4Display ); + use Koha::CsvProfiles; use Koha::RecordProcessor; @@ -85,6 +86,7 @@ if ($bib_list && $format) { patron => $patron, } ); + my $xslFile = $query->param("file"); my $framework = &GetFrameworkCode( $biblio ); $record_processor->options({ interface => 'opac', @@ -116,13 +118,14 @@ if ($bib_list && $format) { $type = "text/plain"; } elsif ($format =~ /^xsl\.(.*)$/) { - $output .= XSLTParse4Display( + $output .= XSLTParse4Display( { biblionumber => $biblio, record => $record, xsl_syspref => "OPACXSLTCustomExport", fix_amps => 1, hidden_items => undef, + xslfilename => $xslFile, } ); } diff --git a/opac/opac-downloadshelf.pl b/opac/opac-downloadshelf.pl index 31231b7e96..81425f1898 100755 --- a/opac/opac-downloadshelf.pl +++ b/opac/opac-downloadshelf.pl @@ -27,7 +27,8 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Record; use C4::Ris qw( marc2ris ); use Koha::Biblios; -use C4::XSLT; +use C4::XSLT qw( XSLTParse4Display ); + use Koha::CsvProfiles; use Koha::RecordProcessor; use Koha::Virtualshelves; @@ -91,13 +92,14 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { my $biblionumber = $content->biblionumber; my $biblio = Koha::Biblios->find($biblionumber); - my $record = $biblio->metadata->record->( + my $record = $biblio->metadata->record( { embed_items => 1, opac => 1, patron => $patron, } ); + my $xslFile = $query->param("file"); my $framework = $biblio->frameworkcode; $record_processor->options({ interface => 'opac', @@ -131,6 +133,7 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { xsl_syspref => "XSLTCustomExport", fix_amps => 1, hidden_items => undef, + xslfilename => $xslFile, } ); } diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index e228b3dfb0..6eb760b201 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -32,7 +32,7 @@ use C4::Koha qw( use C4::Members; use C4::Output qw( pagination_bar output_with_http_headers ); use C4::Tags qw( get_tags ); -use C4::XSLT qw( XSLTParse4Display ); +use C4::XSLT qw( XSLTParse4Display CustomXSLTExportList ); use Koha::Biblios; use Koha::Biblioitems; @@ -491,6 +491,7 @@ $template->param( print => scalar $query->param('print') || 0, listsview => 1, staffuser => $staffuser, + xsl_exports => CustomXSLTExportList() ); my $content_type = $query->param('rss')? 'rss' : 'html'; diff --git a/t/XSLT.t b/t/XSLT.t index 9b14990b6c..20e486659e 100755 --- a/t/XSLT.t +++ b/t/XSLT.t @@ -75,7 +75,6 @@ is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en', 'Fell ba my $matching_string = q{[0|1]}; my $sysprefs_xml = C4::XSLT::get_xslt_sysprefs(); -<<<<<<< HEAD ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has no value'); t::lib::Mocks::mock_config('opachtdocs', "$dir"); @@ -109,6 +108,3 @@ ok((scalar @custom_xslts) == 2, "CustomXSLTExportList finds custom XSLTs"); ok($custom_xslts[0]->{filename} eq "Export 01", "Title is specified in root node"); ok($custom_xslts[1]->{filename} eq "export_02", "Title is filename if not specified"); -======= -ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has a value of 0'); ->>>>>>> Bug 17385: Add custom export XSLT diff --git a/virtualshelves/downloadshelf.pl b/virtualshelves/downloadshelf.pl index 8aaae927c9..7a811fd474 100755 --- a/virtualshelves/downloadshelf.pl +++ b/virtualshelves/downloadshelf.pl @@ -71,6 +71,7 @@ if ($shelfid && $format) { my $biblionumber = $content->biblionumber; my $biblio = Koha::Biblios->find($biblionumber); my $record = $biblio->metadata->record({ embed_items => 1 }); + my $xslFile = $query->param("file"); if ($format eq 'iso2709') { $output .= $record->as_usmarc(); } @@ -88,6 +89,7 @@ if ($shelfid && $format) { xsl_syspref => 'XSLTCustomExport', fix_amps => 1, hidden_items => undef, + xslfilename => $xslFile, } ); } -- 2.34.1