Bugzilla – Attachment 144335 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]
[patch]
Bug 17385: Add custom export XSLT
Bug-17385-Add-custom-export-XSLT.patch (text/plain), 32.96 KB, created by
Hammat wele
on 2022-11-29 20:23:53 UTC
(
hide
)
Description:
Bug 17385: Add custom export XSLT
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2022-11-29 20:23:53 UTC
Size:
32.96 KB
patch
obsolete
>From e090412bc8211fbeb565d4c9da9f25f4216102cd Mon Sep 17 00:00:00 2001 >From: David Bourgault <david.bourgault@inlibro.com> >Date: Tue, 26 Sep 2017 10:17:06 -0400 >Subject: [PATCH] Bug 17385: Add custom export XSLT > >Rebase >--- > C4/XSLT.pm | 36 ++++++++++- > basket/basket.pl | 4 ++ > basket/downloadcart.pl | 6 ++ > catalogue/detail.pl | 3 + > catalogue/export.pl | 16 +++++ > .../prog/en/includes/cat-toolbar.inc | 3 + > .../en/includes/virtualshelves-toolbar.inc | 3 + > .../en/modules/admin/preferences/opac.pref | 1 + > .../prog/en/modules/basket/basket.tt | 3 + > .../prog/en/modules/catalogue/detail.tt | 7 ++- > .../modules/virtualshelves/downloadshelf.tt | 3 + > .../biblioexport/MARC21_simple_export.xsl | 62 +++++++++++++++++++ > .../en/includes/opac-detail-sidebar.inc | 50 ++++++++------- > .../bootstrap/en/modules/opac-downloadcart.tt | 3 + > .../en/modules/opac-downloadshelf.tt | 3 + > .../biblioexport/MARC21_simple_export.xsl | 62 +++++++++++++++++++ > opac/opac-detail.pl | 3 + > opac/opac-downloadcart.pl | 8 +++ > opac/opac-downloadshelf.pl | 10 ++- > opac/opac-export.pl | 11 ++++ > t/XSLT.t | 3 +- > t/db_dependent/XSLT.t | 23 ++++++- > virtualshelves/downloadshelf.pl | 7 ++- > virtualshelves/shelves.pl | 1 + > 24 files changed, 298 insertions(+), 33 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport/MARC21_simple_export.xsl > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport/MARC21_simple_export.xsl > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index 21d270e3df..64e2ec6710 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -33,6 +33,14 @@ use Koha::XSLT::Base; > use Koha::Libraries; > use Koha::Recalls; > >+ >+use XML::LibXML; >+ >+use Encode; >+ >+use vars qw(@ISA @EXPORT); >+ >+ > my $engine; #XSLT Handler object > > our (@ISA, @EXPORT_OK); >@@ -42,6 +50,7 @@ BEGIN { > @EXPORT_OK = qw( > buildKohaItemsNamespace > XSLTParse4Display >+ &CustomXSLTExportList > ); > $engine=Koha::XSLT::Base->new( { do_not_return_source => 1 } ); > } >@@ -84,6 +93,12 @@ sub _get_best_default_xslt_filename { > return $xslfilename; > } > >+=head2 get_xslt_sysprefs >+ >+ returns XML xslt sysprefs. >+ >+=cut >+ > sub get_xslt_sysprefs { > my $sysxml = "<sysprefs>\n"; > foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow >@@ -121,7 +136,21 @@ sub get_xsl_filename { > > my $xslfilename = C4::Context->preference($xslsyspref) || "default"; > >- if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { >+ if ($xslsyspref eq "XSLTCustomExport") { >+ my $dir; >+ $dir = C4::Context->config('intrahtdocs') . >+ '/' . C4::Context->preference("template") . >+ '/' . C4::Languages::getlanguage() . >+ '/xslt/biblioexport'; >+ $xslfilename = $dir . "/" . $xslfilename; >+ } elsif ($xslsyspref eq "OPACXSLTCustomExport") { >+ my $dir; >+ $dir = C4::Context->config('opachtdocs') . >+ '/' . C4::Context->preference("opacthemes") . >+ '/' . C4::Languages::getlanguage() . >+ '/xslt/biblioexport'; >+ $xslfilename = $dir . "/" . $xslfilename; >+ } elsif ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { > > my ( $htdocs, $theme, $xslfile ); > >@@ -206,9 +235,10 @@ sub XSLTParse4Display { > } > my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); > >- $variables ||= {}; > my $biblio; >- if ( $interface eq 'opac' && C4::Context->preference('OPACShowOpenURL')) { >+ my $variables ||= {}; >+ >+ if (C4::Context->preference('OPACShowOpenURL')) { > my @biblio_itemtypes; > $biblio //= Koha::Biblios->find($biblionumber); > if (C4::Context->preference('item-level_itypes')) { >diff --git a/basket/basket.pl b/basket/basket.pl >index 7aeed4df64..40e00bceeb 100755 >--- a/basket/basket.pl >+++ b/basket/basket.pl >@@ -19,6 +19,7 @@ > use Modern::Perl; > use CGI qw ( -utf8 ); > use C4::Koha; >+ > use C4::Biblio qw( > GetMarcSeries > GetMarcSubjects >@@ -26,6 +27,8 @@ 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 Koha::AuthorisedValues; > use Koha::Biblios; >@@ -107,6 +110,7 @@ my $resultsarray = \@results; > $template->param( > BIBLIO_RESULTS => $resultsarray, > csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }), >+ xsl_exports => CustomXSLTExportList(), > bib_list => $bib_list, > ); > >diff --git a/basket/downloadcart.pl b/basket/downloadcart.pl >index 806ad4959f..07527e897a 100755 >--- a/basket/downloadcart.pl >+++ b/basket/downloadcart.pl >@@ -26,6 +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 Koha::CsvProfiles; > use Koha::Biblios; >@@ -78,11 +79,15 @@ if ($bib_list && $format) { > elsif ($format eq 'bibtex') { > $output .= marc2bibtex($record, $biblionumber); > } >+ elsif ($format =~ /^xsl\.(.*)$/) { >+ $output .= XSLTParse4Display($biblio, $record, 'XSLTCustomExport', 1, undef, , '', $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 => 'application/octet-stream', >@@ -92,6 +97,7 @@ if ($bib_list && $format) { > > } else { > $template->param(csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' })); >+ $template->param(xsl_exports => CustomXSLTExportList()); > $template->param(bib_list => $bib_list); > output_html_with_http_headers $query, $cookie, $template->output; > } >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index c7908bc969..afb69febab 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -85,6 +85,9 @@ if ( C4::Context->config('enable_plugins') ) { > ); > } > >+##### ADD CUSTOM XSLT >+$template->param(filesOptions => CustomXSLTExportList(0)); >+ > my $biblionumber = $query->param('biblionumber'); > $biblionumber = HTML::Entities::encode($biblionumber); > my $biblio = Koha::Biblios->find( $biblionumber ); >diff --git a/catalogue/export.pl b/catalogue/export.pl >index ff02cea67f..e023a55e71 100755 >--- a/catalogue/export.pl >+++ b/catalogue/export.pl >@@ -7,6 +7,8 @@ use C4::Output; > use C4::Biblio qw( GetMarcControlnumber ); > use CGI qw ( -utf8 ); > use C4::Ris qw( marc2ris ); >+use C4::XSLT; >+ > > > >@@ -86,4 +88,18 @@ if ($op eq "export") { > -attachment=>"$file_pre$file_id.$format"); > print $marc; > } >+}elsif ($op eq "exportxsl"){ >+ my $biblionumber = $query->param("bib"); >+ if ($biblionumber){ >+ my $xslFile = $query->param("file"); >+ my $marc = GetMarcBiblio( { biblionumber => $biblionumber, embed_items => 1 } ); >+ my $format=$query->param("format")||'txt'; >+ my @hiddenitems; >+ >+ $marc = XSLTParse4Display($biblionumber, $marc, 'XSLTCustomExport', 1, \@hiddenitems, '', $xslFile,''); >+ print $query->header( >+ -type => 'application/octet-stream', >+ -attachment=>"bib-$biblionumber.$format"); >+ print $marc; >+ } > } >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 a1ca101dba..fb6f0bcbf5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >@@ -102,6 +102,9 @@ > <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcstd&op=export&bib=[% biblionumber | uri %]">MARC (Unicode/UTF-8, Standard)</a></li> > <li><a href="/cgi-bin/koha/catalogue/export.pl?format=mods&op=export&bib=[% biblionumber | uri %]">MODS (XML)</a></li> > <li><a href="/cgi-bin/koha/catalogue/export.pl?format=ris&op=export&bib=[% biblionumber | uri %]">RIS</a></li> >+ [% FOREACH filesOption IN filesOptions %] >+ <li><a href="/cgi-bin/koha/catalogue/export.pl?format=[% filesOption.format | uri %]&op=exportxsl&file=[% filesOption.value | uri %]&bib=[% biblionumber | uri %]">XSL - [% filesOption.filename | html %]</a></li> >+ [% END %] > </ul> > </div> > >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 c5a6306a78..c241f343f3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc >@@ -31,6 +31,9 @@ > [% FOREACH csv_profile IN csv_profiles %] > <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> >+ [% END %] > </ul> > </div> > <div class="btn-group"><a class="btn btn-default" href="#" id="sendlist"><i class="fa fa-envelope"></i> Send list</a></div> >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 043c5276d8..4245a7b4d1 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 >@@ -285,6 +285,7 @@ OPAC: > mods: MODS > ris: RIS > isbd: ISBD >+ custom: XSL - Simple Export > - > - pref: OpacSeparateHoldings > choices: >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 50c83759f2..73b6c3e12c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt >@@ -58,6 +58,9 @@ > [% FOREACH csv_profile IN csv_profiles %] > <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> >+ [% END %] > </ul> > </div> > <a class="btn btn-default" href="basket.pl" id="print_cart"><i class="fa fa-print"></i> Print</a> >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 e59ed096b9..070d4ead2a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1075,8 +1075,11 @@ Note that permanent location is a code, and location may be an authval. > <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option> > <option value="marcxml">MARCXML</option> > <option value="marc8">MARC (non-Unicode/MARC-8)</option> >- <option value="utf8">MARC (Unicode/UTF-8)</option> </select> >- <input type="submit" name="save" class="btn btn-primary" value="Download record" /></td> >+ <option value="utf8">MARC (Unicode/UTF-8)</option> >+ [% FOREACH filesOption IN filesOptions %] >+ <option value="[% filesOption.value | html %]">XSL -[% filesOption.filename | html %]</option> >+ [% END %]</select> >+ <input type="submit" name="save" value="Download Record" /></td> > </tr> > <tr><td> > <input type="hidden" name="op" value="export" /><input type="hidden" name="bib" value="[% biblionumber | html %]" /> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tt >index ebc7d8d9a1..6ecc0ba64f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tt >@@ -36,6 +36,9 @@ > [% FOREACH csv_profile IN csv_profiles %] > <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option> > [% END %] >+ [% FOREACH xsl_export IN xsl_exports %] >+ <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option> >+ [% END %] > </select> > </li></ol> > </fieldset> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport/MARC21_simple_export.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport/MARC21_simple_export.xsl >new file mode 100644 >index 0000000000..faad19d521 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport/MARC21_simple_export.xsl >@@ -0,0 +1,62 @@ >+<?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="Simple Export"> >+<xsl:output method="html" encoding="UTF-8"/> >+ >+ <xsl:template match="/"> >+ <xsl:apply-templates/> >+ </xsl:template> >+ >+ <xsl:template match="marc:record"> >+ <p> >+ <xsl:if test="marc:datafield[@tag=245]"> >+ <xsl:for-each select="marc:datafield[@tag=245]"> >+ <xsl:value-of select="marc:subfield[@code='a']"/> >+ <xsl:if test="marc:subfield[@code='b']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of> >+ </xsl:if> >+ <xsl:if test="marc:subfield[@code='c']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of> >+ </xsl:if> >+ </xsl:for-each> >+ </xsl:if> >+ <xsl:if test="marc:datafield[@tag=260]"> >+ <br/> >+ <xsl:for-each select="marc:datafield[@tag=260]"> >+ <xsl:if test="marc:subfield[@code='a']"> >+ <xsl:value-of select="marc:subfield[@code='a']"/> >+ </xsl:if> >+ <xsl:if test="marc:subfield[@code='b']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of> >+ </xsl:if> >+ <xsl:if test="marc:subfield[@code='c']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of> >+ </xsl:if> >+ </xsl:for-each> >+ </xsl:if> >+ <xsl:if test="marc:datafield[@tag=264]"> >+ <br/> >+ <xsl:for-each select="marc:datafield[@tag=264]"> >+ <xsl:if test="marc:subfield[@code='a']"> >+ <xsl:value-of select="marc:subfield[@code='a']"/> >+ </xsl:if> >+ <xsl:if test="marc:subfield[@code='b']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of> >+ </xsl:if> >+ <xsl:if test="marc:subfield[@code='c']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of> >+ </xsl:if> >+ </xsl:for-each> >+ </xsl:if> >+ </p> >+ </xsl:template> >+ >+</xsl:stylesheet> >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 2602ad7502..74c3790579 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,30 +62,36 @@ > <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" 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' %] >- <a class="dropdown-item" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a> >- [% ELSE %] >- <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> >+ <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"> >+ [% 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> > [% END %] >- </a> >+ [% END %] > [% END %] >- [% END %] >- </div> <!-- /.dropdown-menu --> >- </div> <!-- /.dropdown --> >- </div> <!-- /#export --> >+ </ul> >+ </div> >+ </div> > </li> > [% END %] > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt >index 090936c72a..ab9d4e7de1 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt >@@ -20,6 +20,9 @@ > [% FOREACH csv_profile IN csv_profiles %] > <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option> > [% END %] >+ [% FOREACH xsl_export IN xsl_exports %] >+ <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option> >+ [% END %] > </select> > <fieldset class="action"> > <input type="hidden" name="bib_list" value="[% bib_list | html %]" /> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt >index 076fed519f..fbe38a25c7 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt >@@ -70,6 +70,9 @@ > [% FOREACH csv_profile IN csv_profiles %] > <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option> > [% END %] >+ [% FOREACH xsl_export IN xsl_exports %] >+ <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option> >+ [% END %] > </select> > <span class="required">Required</span> > </fieldset> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport/MARC21_simple_export.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport/MARC21_simple_export.xsl >new file mode 100644 >index 0000000000..faad19d521 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport/MARC21_simple_export.xsl >@@ -0,0 +1,62 @@ >+<?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="Simple Export"> >+<xsl:output method="html" encoding="UTF-8"/> >+ >+ <xsl:template match="/"> >+ <xsl:apply-templates/> >+ </xsl:template> >+ >+ <xsl:template match="marc:record"> >+ <p> >+ <xsl:if test="marc:datafield[@tag=245]"> >+ <xsl:for-each select="marc:datafield[@tag=245]"> >+ <xsl:value-of select="marc:subfield[@code='a']"/> >+ <xsl:if test="marc:subfield[@code='b']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of> >+ </xsl:if> >+ <xsl:if test="marc:subfield[@code='c']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of> >+ </xsl:if> >+ </xsl:for-each> >+ </xsl:if> >+ <xsl:if test="marc:datafield[@tag=260]"> >+ <br/> >+ <xsl:for-each select="marc:datafield[@tag=260]"> >+ <xsl:if test="marc:subfield[@code='a']"> >+ <xsl:value-of select="marc:subfield[@code='a']"/> >+ </xsl:if> >+ <xsl:if test="marc:subfield[@code='b']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of> >+ </xsl:if> >+ <xsl:if test="marc:subfield[@code='c']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of> >+ </xsl:if> >+ </xsl:for-each> >+ </xsl:if> >+ <xsl:if test="marc:datafield[@tag=264]"> >+ <br/> >+ <xsl:for-each select="marc:datafield[@tag=264]"> >+ <xsl:if test="marc:subfield[@code='a']"> >+ <xsl:value-of select="marc:subfield[@code='a']"/> >+ </xsl:if> >+ <xsl:if test="marc:subfield[@code='b']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of> >+ </xsl:if> >+ <xsl:if test="marc:subfield[@code='c']"> >+ <xsl:text> </xsl:text> >+ <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of> >+ </xsl:if> >+ </xsl:for-each> >+ </xsl:if> >+ </p> >+ </xsl:template> >+ >+</xsl:stylesheet> >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 961be88143..9bd921dafc 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -103,6 +103,9 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > } > ); > >+#### ADD CUSTOM XSLT >+$template->param(filesOptions => CustomXSLTExportList(1)); >+ > my $patron = Koha::Patrons->find( $borrowernumber ); > > my $biblio = Koha::Biblios->find( $biblionumber ); >diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl >index 1f4b20d1fb..e16204c53b 100755 >--- a/opac/opac-downloadcart.pl >+++ b/opac/opac-downloadcart.pl >@@ -28,6 +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 Koha::CsvProfiles; > use Koha::RecordProcessor; > >@@ -114,11 +116,15 @@ if ($bib_list && $format) { > $extension = "txt"; > $type = "text/plain"; > } >+ elsif ($format =~ /^xsl\.(.*)$/) { >+ $output .= XSLTParse4Display($biblio, $record, 'OPACXSLTCustomExport', 1, undef, undef, $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', >@@ -138,5 +144,7 @@ if ($bib_list && $format) { > ), > bib_list => $bib_list, > ); >+ $template->param(bib_list => $bib_list); >+ $template->param(xsl_exports => CustomXSLTExportList()); > output_html_with_http_headers $query, $cookie, $template->output; > } >diff --git a/opac/opac-downloadshelf.pl b/opac/opac-downloadshelf.pl >index 2414d1566a..7090a31734 100755 >--- a/opac/opac-downloadshelf.pl >+++ b/opac/opac-downloadshelf.pl >@@ -27,6 +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 Koha::CsvProfiles; > use Koha::RecordProcessor; > use Koha::Virtualshelves; >@@ -122,13 +124,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', >@@ -154,6 +158,8 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { > ), > shelf => $shelf, > ); >+ $template->param(xsl_exports => CustomXSLTExportList()); >+ $template->param( shelf => $shelf ); > output_html_with_http_headers $query, $cookie, $template->output; > } > >diff --git a/opac/opac-export.pl b/opac/opac-export.pl >index 1b0fdad59a..610d5d27e5 100755 >--- a/opac/opac-export.pl >+++ b/opac/opac-export.pl >@@ -31,6 +31,8 @@ use CGI qw ( -utf8 ); > use C4::Auth; > use C4::Ris qw( marc2ris ); > use Koha::Biblios; >+use C4::XSLT; >+ > use Koha::RecordProcessor; > > my $query = CGI->new; >@@ -137,6 +139,15 @@ elsif ( $format =~ /isbd/ ) { > }); > $format = 'isbd'; > } >+elsif ($format =~ /html/ ) { >+ if ($biblionumber){ >+ my $xslFile = $query->param("file"); >+ $marc = C4::Biblio::GetMarcBiblio({biblionumber => $biblionumber}); >+ my @hiddenitems; >+ >+ $marc = XSLTParse4Display($biblionumber, $marc, 'OPACXSLTCustomExport', 1, \@hiddenitems, undef, $xslFile, undef); >+ } >+} > else { > $error= "Format $format is not supported."; > } >diff --git a/t/XSLT.t b/t/XSLT.t >index e3a733251c..e20a7b80e1 100755 >--- a/t/XSLT.t >+++ b/t/XSLT.t >@@ -75,5 +75,4 @@ is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en', 'Fell ba > > my $matching_string = q{<syspref name="singleBranchMode">0</syspref>}; > my $sysprefs_xml = C4::XSLT::get_xslt_sysprefs(); >-ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has a value of 0'); >- >+ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has a value of 0'); >\ No newline at end of file >diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t >index c4013aed2f..22dc4916a1 100755 >--- a/t/db_dependent/XSLT.t >+++ b/t/db_dependent/XSLT.t >@@ -150,7 +150,28 @@ 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'); >+ 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; > > subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub { >diff --git a/virtualshelves/downloadshelf.pl b/virtualshelves/downloadshelf.pl >index 1138b530ce..d9939c5cb0 100755 >--- a/virtualshelves/downloadshelf.pl >+++ b/virtualshelves/downloadshelf.pl >@@ -25,6 +25,8 @@ 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 Koha::Biblios; > use Koha::CsvProfiles; >@@ -79,12 +81,15 @@ if ($shelfid && $format) { > elsif ($format eq 'bibtex') { > $output .= marc2bibtex($record, $biblionumber); > } >+ elsif ($format =~ /^xsl\.(.*)$/){ >+ $output .= XSLTParse4Display($biblionumber, $record, 'XSLTCustomExport', 1, undef, ,'',$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 => 'application/octet-stream', > -'Content-Transfer-Encoding' => 'binary', >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index fa92cfcd6e..aad027b485 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -385,6 +385,7 @@ $template->param( > print => scalar $query->param('print') || 0, > csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' })->as_list ], > allow_transfer => $allow_transfer, >+ xsl_exports => CustomXSLTExportList() > ); > > output_html_with_http_headers $query, $cookie, $template->output; >-- >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 Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
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