Bugzilla – Attachment 144384 Details for
Bug 17385
Add custom export formats for bibliographic records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
This patch adds 'XSL-Simple Export' when saving a bibliographic record
This-patch-adds-XSL-Simple-Export-when-saving-a-bi.patch (text/plain), 33.15 KB, created by
Hammat wele
on 2022-12-01 21:19:48 UTC
(
hide
)
Description:
This patch adds 'XSL-Simple Export' when saving a bibliographic record
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2022-12-01 21:19:48 UTC
Size:
33.15 KB
patch
obsolete
>From 3fb19d4bd5f837b37de33683858497671e3da35e Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >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 | 12 ++--- > basket/basket.pl | 3 +- > basket/downloadcart.pl | 14 +++++- > catalogue/detail.pl | 2 +- > catalogue/export.pl | 18 +++++-- > .../en/includes/virtualshelves-toolbar.inc | 2 +- > .../prog/en/modules/basket/basket.tt | 2 +- > .../en/includes/opac-detail-sidebar.inc | 50 +++++++++---------- > .../bootstrap/en/modules/opac-basket.tt | 8 +++ > .../bootstrap/en/modules/opac-shelves.tt | 8 +++ > opac/opac-basket.pl | 2 + > opac/opac-detail.pl | 3 +- > opac/opac-downloadcart.pl | 14 +++++- > opac/opac-downloadshelf.pl | 18 +++++-- > opac/opac-export.pl | 17 +++++-- > opac/opac-shelves.pl | 3 +- > t/XSLT.t | 40 +++++++++++++-- > t/db_dependent/XSLT.t | 31 +++++++----- > virtualshelves/downloadshelf.pl | 14 +++++- > virtualshelves/shelves.pl | 2 +- > 20 files changed, 188 insertions(+), 75 deletions(-) > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index ec2db098f9..031c95c99a 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -131,24 +131,24 @@ sub get_xslt_sysprefs { > } > > sub get_xsl_filename { >- my ( $xslsyspref ) = @_; >+ my ( $xslsyspref, $xslfilename ) = @_; > > my $lang = C4::Languages::getlanguage(); > >- my $xslfilename = C4::Context->preference($xslsyspref) || "default"; >+ $xslfilename ||= C4::Context->preference($xslsyspref) || "default"; > > if ($xslsyspref eq "XSLTCustomExport") { > my $dir; > $dir = C4::Context->config('intrahtdocs') . > '/' . C4::Context->preference("template") . >- '/' . C4::Languages::getlanguage() . >+ '/' . $lang . > '/xslt/biblioexport'; > $xslfilename = $dir . "/" . $xslfilename; > } elsif ($xslsyspref eq "OPACXSLTCustomExport") { > my $dir; > $dir = C4::Context->config('opachtdocs') . > '/' . C4::Context->preference("opacthemes") . >- '/' . C4::Languages::getlanguage() . >+ '/' . $lang . > '/xslt/biblioexport'; > $xslfilename = $dir . "/" . $xslfilename; > } elsif ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { >@@ -209,11 +209,12 @@ sub XSLTParse4Display { > my $variables = $params->{xslt_variables}; > my $items_rs = $params->{items_rs}; > my $interface = C4::Context->interface; >+ my $xslfilename = $params->{xslfilename}; > > die "Mandatory \$params->{xsl_syspref} was not provided, called with biblionumber $params->{biblionumber}" > if not defined $params->{xsl_syspref}; > >- my $xslfilename = get_xsl_filename( $xslsyspref); >+ $xslfilename = get_xsl_filename( $xslsyspref, $xslfilename); > > my $frameworkcode = GetFrameworkCode($biblionumber) || ''; > my $record_processor = Koha::RecordProcessor->new( >@@ -237,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/basket.pl b/basket/basket.pl >index 40e00bceeb..7c49237564 100755 >--- a/basket/basket.pl >+++ b/basket/basket.pl >@@ -27,8 +27,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; >- >+use C4::XSLT qw( CustomXSLTExportList ); > > use Koha::AuthorisedValues; > use Koha::Biblios; >diff --git a/basket/downloadcart.pl b/basket/downloadcart.pl >index 07527e897a..69438ee179 100755 >--- a/basket/downloadcart.pl >+++ b/basket/downloadcart.pl >@@ -26,7 +26,7 @@ use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Record; > use C4::Ris qw( marc2ris ); >-use C4::XSLT; >+use C4::XSLT qw( XSLTParse4Display ); > > use Koha::CsvProfiles; > use Koha::Biblios; >@@ -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') { >@@ -80,7 +81,16 @@ if ($bib_list && $format) { > $output .= marc2bibtex($record, $biblionumber); > } > elsif ($format =~ /^xsl\.(.*)$/) { >- $output .= XSLTParse4Display($biblio, $record, 'XSLTCustomExport', 1, undef, , '', $1, ''); >+ $output .= XSLTParse4Display( >+ { >+ biblionumber => $biblio, >+ record => $record, >+ xsl_syspref => "XSLTCustomExport", >+ fix_amps => 1, >+ hidden_items => undef, >+ xslfilename => $xslFile, >+ } >+ ); > } > } > } >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index afb69febab..d725b71ce9 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -40,7 +40,7 @@ use C4::XISBN qw( get_xisbns ); > use C4::External::Amazon qw( get_amazon_tld ); > use C4::Search qw( z3950_search_args enabled_staff_search_views new_record_from_zebra ); > use C4::Tags qw( get_tags ); >-use C4::XSLT qw( XSLTParse4Display ); >+use C4::XSLT qw( XSLTParse4Display CustomXSLTExportList ); > use Koha::DateUtils qw( format_sqldatetime ); > use C4::HTML5Media; > use C4::CourseReserves qw( GetItemCourseReservesInfo ); >diff --git a/catalogue/export.pl b/catalogue/export.pl >index e023a55e71..34bf7857e1 100755 >--- a/catalogue/export.pl >+++ b/catalogue/export.pl >@@ -7,8 +7,8 @@ use C4::Output; > use C4::Biblio qw( GetMarcControlnumber ); > use CGI qw ( -utf8 ); > use C4::Ris qw( marc2ris ); >-use C4::XSLT; >- >+use C4::XSLT qw( XSLTParse4Display ); >+use Koha::Biblios; > > > >@@ -92,11 +92,21 @@ if ($op eq "export") { > my $biblionumber = $query->param("bib"); > if ($biblionumber){ > my $xslFile = $query->param("file"); >- my $marc = GetMarcBiblio( { biblionumber => $biblionumber, embed_items => 1 } ); >+ my $biblio = Koha::Biblios->find($biblionumber); >+ my $marc = $biblio->metadata->record( { embed_items => 1 } ); > my $format=$query->param("format")||'txt'; > my @hiddenitems; > >- $marc = XSLTParse4Display($biblionumber, $marc, 'XSLTCustomExport', 1, \@hiddenitems, '', $xslFile,''); >+ $marc = XSLTParse4Display( >+ { >+ biblionumber => $biblionumber, >+ record => $marc, >+ xsl_syspref => "XSLTCustomExport", >+ fix_amps => 1, >+ hidden_items => \@hiddenitems, >+ xslfilename => $xslFile, >+ } >+ ); > print $query->header( > -type => 'application/octet-stream', > -attachment=>"bib-$biblionumber.$format"); >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 @@ > <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=[% csv_profile.export_format_id | uri %]&shelfid=[% shelf.shelfnumber | uri %]">CSV - [% csv_profile.profile | html %]</a></li> > [% END %] > [% FOREACH xsl_export IN xsl_exports %] >- <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=xsl.[% xsl_export.value | uri %]&shelfid=[% shelf.shelfnumber | uri %]">XSL - [% xsl_export.filename | html %]</a></li> >+ <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=xsl.[% xsl_export.value | uri %]&file=[% xsl_export.value | uri %]&shelfid=[% shelf.shelfnumber | uri %]">XSL - [% xsl_export.filename | html %]</a></li> > [% END %] > </ul> > </div> >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 @@ > <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=[% csv_profile.export_format_id | uri %]&bib_list=[% bib_list | uri %]">CSV - [% csv_profile.profile | html %]</a></li> > [% END %] > [% FOREACH xsl_export IN xsl_exports %] >- <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=xsl.[% xsl_export.value | uri %]&bib_list=[% bib_list | uri %]">XSL - [% xsl_export.filename | html %]</a></li> >+ <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=xsl.[% xsl_export.value | uri %]&file=[% xsl_export.value | uri %]&bib_list=[% bib_list | uri %]">XSL - [% xsl_export.filename | html %]</a></li> > [% END %] > </ul> > </div> >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 74c3790579..e7147fa92a 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 >@@ -62,36 +62,34 @@ > <li> > <div id="export"> > <div class="dropdown"> >- <a id="format" class="btn btn-link btn-lg dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-fw fa-download"></i> Save record <b class="caret"></b></a> >- <ul class="dropdown-menu pull-left" role="menu" aria-labelledby="format"> >+ <a id="format" class="btn btn-link btn-lg dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Save record <b class="caret"></b></a> >+ <div class="dropdown-menu dropdown-menu-right" aria-labelledby="format"> > [% FOREACH option IN export_options %] >- [% IF option == 'dc' %] >- <li><a role="menuitem" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li> >- [% ELSIF option != 'custom' %] >- <li> >- <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&bib=[% biblio.biblionumber | html %]&format=[% option | html %]"> >- [% SWITCH option %] >- [% CASE 'bibtex' %]BIBTEX >- [% CASE 'endnote' %]EndNote >- [% CASE 'marcxml' %]MARCXML >- [% CASE 'marc8' %]MARC (non-Unicode/MARC-8) >- [% CASE 'utf8' %]MARC (Unicode/UTF-8) >- [% CASE 'marcstd' %]MARC (Unicode/UTF-8, Standard) >- [% CASE 'mods' %]MODS (XML) >- [% CASE 'ris' %]RIS >- [% CASE 'isbd' %]ISBD >- [% END %] >- </a> >- </li> >- [% ELSE %] >- [% FOREACH filesOption IN filesOptions %] >- <li><a role="menuitem" href="/cgi-bin/koha/opac-export.pl?format=[% filesOption.format | html %]&op=exportxsl&file=[% filesOption.value | html %]&bib=[% biblionumber | html %]">XSL - [% filesOption.filename | html %]</a></li> >+ [% IF option == 'dc' %] >+ <a class="dropdown-item" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a> >+ [% ELSIF option != 'custom' %] >+ <a class="dropdown-item" href="/cgi-bin/koha/opac-export.pl?op=export&bib=[% biblio.biblionumber | html %]&format=[% option | html %]"> >+ [% SWITCH option %] >+ [% CASE 'bibtex' %]<span>BIBTEX</span> >+ [% CASE 'endnote' %]<span>EndNote</span> >+ [% CASE 'marcxml' %]<span>MARCXML</span> >+ [% CASE 'marc8' %]<span>MARC (non-Unicode/MARC-8)</span> >+ [% CASE 'utf8' %]<span>MARC (Unicode/UTF-8)</span> >+ [% CASE 'marcstd' %]<span>MARC (Unicode/UTF-8, Standard)</span> >+ [% CASE 'mods' %]<span>MODS (XML)</span> >+ [% CASE 'ris' %]<span>RIS</span> >+ [% CASE 'isbd' %]<span>ISBD</span> > [% END %] >+ </a> >+ [% ELSE %] >+ [% FOREACH filesOption IN filesOptions %] >+ <a href="/cgi-bin/koha/opac-export.pl?format=[% filesOption.format | html %]&op=exportxsl&file=[% filesOption.value | html %]&bib=[% biblionumber | html %]" >XSL - [% filesOption.filename | html %]</a> > [% END %] > [% END %] >- </ul> >- </div> >- </div> >+ [% END %] >+ </div> <!-- /.dropdown-menu --> >+ </div> <!-- /.dropdown --> >+ </div> <!-- /#export --> > </li> > [% 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 @@ > <a class="btn btn-link btn-sm send" href="opac-basket.pl"><i class="fa fa-fw fa-envelope" aria-hidden="true"></i> Send</a> > [% END %] > >+ [% SET export_options = Koha.Preference('OpacExportOptions').split(',') %] > <div id="download-cart" class="btn-group dropdown"> > <a id="format" class="btn btn-link dropdown-toggle" data-toggle="dropdown" role="button" href="#"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Download <b class="caret"></b></a> > <div class="dropdown-menu" role="menu" aria-labelledby="format"> >@@ -38,6 +39,13 @@ > [% FOREACH csv_profile IN csv_profiles %] > <a role="menuitem" class="dropdown-item download-cart" data-format="[% csv_profile.export_format_id | html %]" href="#">CSV - [% csv_profile.profile | html %]</a> > [% END %] >+ [% FOREACH option IN export_options %] >+ [% IF option == 'custom' %] >+ [% FOREACH xsl_export IN xsl_exports %] >+ <a role="menuitem" class="dropdown-item" href="/cgi-bin/koha/opac-downloadcart.pl?format=xsl.[% xsl_export.value | uri %]&file=[% xsl_export.value | uri %]&bib_list=[% bib_list | uri %]">XSL - [% xsl_export.filename | html %]</a></li> >+ [% END %] >+ [% END %] >+ [% END %] > </div> > </div> > >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 @@ > <div class="list-actions"> > <a class="btn btn-link newshelf" href="/cgi-bin/koha/opac-shelves.pl?op=add_form"><i class="fa fa-fw fa-plus" aria-hidden="true"></i> New list</a> <span class="sep">|</span> > >+ [% SET export_options = Koha.Preference('OpacExportOptions').split(',') %] > <div id="download-list" class="btn-group dropdown"> > <a id="format" class="btn btn-link dropdown-toggle" data-toggle="dropdown" href="/cgi-bin/koha/opac-downloadshelf.pl?shelfnumber=[% shelf.shelfnumber | html %]"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Download <b class="caret"></b></a> > <div class="dropdown-menu pull-left" role="menu" aria-labelledby="format"> >@@ -232,6 +233,13 @@ > [% FOREACH csv_profile IN csv_profiles %] > <a role="menuitem" class="dropdown-item download-list" data-format="[% csv_profile.export_format_id | html %]" href="#">CSV - [% csv_profile.profile | html %]</a> > [% END %] >+ [% FOREACH option IN export_options %] >+ [% IF option == 'custom' %] >+ [% FOREACH xsl_export IN xsl_exports %] >+ <a role="menuitem" class="dropdown-item" href="/cgi-bin/koha/opac-downloadshelf.pl?format=xsl.[% xsl_export.value | uri %]&file=[% xsl_export.value | uri %]&shelfnumber=[% shelf.shelfnumber | uri %]">XSL - [% xsl_export.filename | html %]</a></li> >+ [% END %] >+ [% END %] >+ [% END %] > </div> > </div> > >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-detail.pl b/opac/opac-detail.pl >index 9bd921dafc..5e07bdd9f2 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -58,7 +58,7 @@ use C4::External::Syndetics qw( > get_syndetics_toc > ); > use C4::Members; >-use C4::XSLT qw( XSLTParse4Display ); >+use C4::XSLT qw( XSLTParse4Display CustomXSLTExportList ); > use C4::ShelfBrowser qw( GetNearbyItems ); > use C4::Reserves qw( GetReserveStatus ); > use C4::Charset qw( SetUTF8Flag ); >@@ -103,7 +103,6 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > } > ); > >-#### ADD CUSTOM XSLT > $template->param(filesOptions => CustomXSLTExportList(1)); > > my $patron = Koha::Patrons->find( $borrowernumber ); >diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl >index e16204c53b..2488249613 100755 >--- a/opac/opac-downloadcart.pl >+++ b/opac/opac-downloadcart.pl >@@ -28,7 +28,7 @@ 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; >@@ -86,6 +86,7 @@ if ($bib_list && $format) { > patron => $patron, > } > ); >+ my $xslFile = $query->param("file"); > my $framework = &GetFrameworkCode( $biblio ); > $record_processor->options({ > interface => 'opac', >@@ -117,7 +118,16 @@ if ($bib_list && $format) { > $type = "text/plain"; > } > elsif ($format =~ /^xsl\.(.*)$/) { >- $output .= XSLTParse4Display($biblio, $record, 'OPACXSLTCustomExport', 1, undef, undef, $1, ''); >+ $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 7090a31734..81425f1898 100755 >--- a/opac/opac-downloadshelf.pl >+++ b/opac/opac-downloadshelf.pl >@@ -27,7 +27,7 @@ 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; >@@ -92,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', >@@ -125,8 +126,17 @@ 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); >- } >+ $output .= XSLTParse4Display( >+ { >+ biblionumber => $biblionumber, >+ record => $record, >+ xsl_syspref => "XSLTCustomExport", >+ fix_amps => 1, >+ hidden_items => undef, >+ xslfilename => $xslFile, >+ } >+ ); >+ } > } > } > >diff --git a/opac/opac-export.pl b/opac/opac-export.pl >index 610d5d27e5..8f0037f546 100755 >--- a/opac/opac-export.pl >+++ b/opac/opac-export.pl >@@ -31,8 +31,7 @@ use CGI qw ( -utf8 ); > use C4::Auth; > use C4::Ris qw( marc2ris ); > use Koha::Biblios; >-use C4::XSLT; >- >+use C4::XSLT qw( XSLTParse4Display ); > use Koha::RecordProcessor; > > my $query = CGI->new; >@@ -142,10 +141,20 @@ elsif ( $format =~ /isbd/ ) { > elsif ($format =~ /html/ ) { > if ($biblionumber){ > my $xslFile = $query->param("file"); >- $marc = C4::Biblio::GetMarcBiblio({biblionumber => $biblionumber}); >+ my $biblio = Koha::Biblios->find($biblionumber); >+ $marc = $biblio->metadata->record; > my @hiddenitems; > >- $marc = XSLTParse4Display($biblionumber, $marc, 'OPACXSLTCustomExport', 1, \@hiddenitems, undef, $xslFile, undef); >+ $marc = XSLTParse4Display( >+ { >+ biblionumber => $biblionumber, >+ record => $marc, >+ xsl_syspref => "OPACXSLTCustomExport", >+ fix_amps => 1, >+ hidden_items => \@hiddenitems, >+ xslfilename => $xslFile, >+ } >+ ); > } > } > else { >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 e20a7b80e1..20e486659e 100755 >--- a/t/XSLT.t >+++ b/t/XSLT.t >@@ -21,13 +21,13 @@ use Test::More; > use File::Temp; > use File::Path qw/make_path/; > >-use t::lib::Mocks; >+use t::lib::Mocks qw( mock_preference ); > > use Module::Load::Conditional qw/check_install/; > > BEGIN { > if ( check_install( module => 'Test::DBIx::Class' ) ) { >- plan tests => 9; >+ plan tests => 12; > } else { > plan skip_all => "Need Test::DBIx::Class" > } >@@ -73,6 +73,38 @@ is(find_and_slurp($dir, 'test', 'fr-FR'), 'Theme test, language en', 'Fell ba > is(find_and_slurp($dir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES'); > is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en', 'Fell back to prog/en for nope/fr-FR'); > >-my $matching_string = q{<syspref name="singleBranchMode">0</syspref>}; >+my $matching_string = q{<syspref name="singleBranchMode">[0|1]</syspref>}; > my $sysprefs_xml = C4::XSLT::get_xslt_sysprefs(); >-ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has a value of 0'); >\ No newline at end of file >+ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has no value'); >+ >+t::lib::Mocks::mock_config('opachtdocs', "$dir"); >+make_path("$dir/bootstrap/en/xslt/biblioexport"); >+ >+# Make XSL with title >+open my $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_01.xsl"; >+print $fh qq|<?xml version="1.0" encoding="UTF-8"?> >+<xsl:stylesheet version="1.0" >+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >+ xmlns:marc="http://www.loc.gov/MARC21/slim" >+ title="Export 01"> >+</xsl:stylesheet>|; >+close $fh; >+ >+# Make XSL without title >+open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_02.xsl"; >+print $fh qq|<?xml version="1.0" encoding="UTF-8"?> >+<xsl:stylesheet version="1.0" >+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >+ xmlns:marc="http://www.loc.gov/MARC21/slim"> >+</xsl:stylesheet>|; >+close $fh; >+ >+open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_03.xsl"; >+print $fh qq|<?xml version="1.0" encoding="UTF-8"?>|; >+close $fh; >+ >+my @custom_xslts = @{C4::XSLT::CustomXSLTExportList(1)}; >+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"); >+ >diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t >index 865e87a575..4b4deccd4a 100755 >--- a/t/db_dependent/XSLT.t >+++ b/t/db_dependent/XSLT.t >@@ -1,3 +1,20 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ > use Modern::Perl; > > use MARC::Record; >@@ -16,6 +33,8 @@ BEGIN { > } > > our $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+our $cache = Koha::Caches->get_instance; > > # Here we go > $schema->storage->txn_begin; >@@ -146,18 +165,6 @@ subtest 'buildKohaItemsNamespace status tests' => sub { > t::lib::Mocks::mock_preference('UseRecalls', 0); > > }; >-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'); >diff --git a/virtualshelves/downloadshelf.pl b/virtualshelves/downloadshelf.pl >index d9939c5cb0..8d1fff2ac1 100755 >--- a/virtualshelves/downloadshelf.pl >+++ b/virtualshelves/downloadshelf.pl >@@ -25,7 +25,7 @@ use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Record; > use C4::Ris qw( marc2ris ); >-use C4::XSLT; >+use C4::XSLT qw( XSLTParse4Display ); > > > use Koha::Biblios; >@@ -72,6 +72,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(); > } >@@ -82,7 +83,16 @@ if ($shelfid && $format) { > $output .= marc2bibtex($record, $biblionumber); > } > elsif ($format =~ /^xsl\.(.*)$/){ >- $output .= XSLTParse4Display($biblionumber, $record, 'XSLTCustomExport', 1, undef, ,'',$1,''); >+ $output .= XSLTParse4Display( >+ { >+ biblionumber => $biblionumber, >+ record => $record, >+ xsl_syspref => 'XSLTCustomExport', >+ fix_amps => 1, >+ hidden_items => undef, >+ xslfilename => $xslFile, >+ } >+ ); > } > } > } >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index aad027b485..f061970f7c 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -30,7 +30,7 @@ use C4::Koha qw( > ); > use C4::Members; > use C4::Output qw( pagination_bar output_html_with_http_headers ); >-use C4::XSLT qw( XSLTParse4Display ); >+use C4::XSLT qw( XSLTParse4Display CustomXSLTExportList ); > > use Koha::Biblios; > use Koha::Biblioitems; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 17385
:
55961
|
58308
|
64033
|
64034
|
67357
|
67579
|
74660
|
74661
|
79055
|
79056
|
80675
|
81385
|
81386
|
84388
|
84389
|
84390
|
86875
|
86876
|
86877
|
86878
|
86879
|
86880
|
97076
|
97101
|
97102
|
97103
|
97104
|
97105
|
100289
|
100290
|
100291
|
100292
|
100293
|
100663
|
100670
|
100671
|
100672
|
100673
|
100674
|
100675
|
112671
|
112672
|
112673
|
112674
|
112675
|
112676
|
112677
|
112678
|
112679
|
112680
|
112681
|
112682
|
112956
|
112957
|
112958
|
112959
|
130283
|
130284
|
130285
|
130286
|
130287
|
130691
|
130692
|
130693
|
130694
|
130695
|
131492
|
132488
|
132489
|
132490
|
132491
|
132492
|
132493
|
132581
|
133498
|
133499
|
133500
|
133501
|
133502
|
133503
|
133504
|
138031
|
138032
|
138033
|
138034
|
138035
|
138036
|
138037
|
138082
|
138083
|
138084
|
138085
|
138086
|
138087
|
138088
|
138132
|
139277
|
139278
|
139279
|
139280
|
139281
|
139282
|
139283
|
139284
|
141157
|
141158
|
141159
|
141160
|
141161
|
141162
|
141163
|
141164
|
144335
|
144336
|
144380
|
144384
|
151095
|
151096
|
151097
|
151098
|
151099
|
151102
|
151103
|
151104
|
151105
|
151106
|
151377
|
151378
|
151379
|
151380
|
151381
|
154379
|
154380
|
154381
|
154382
|
154383
|
156815
|
156816
|
156817
|
156818
|
156819
|
159142
|
159143
|
159144
|
159145
|
159146
|
159147
|
159148
|
163623
|
170014
|
170015
|
170016
|
170017
|
170018
|
170019
|
170026
|
170027
|
170028
|
170029
|
170030
|
170031
|
170983
|
170984
|
170985
|
170986
|
170987
|
170988