Bugzilla – Attachment 58308 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 notices
Bug-17385---Add-custom-export-notices.patch (text/plain), 32.33 KB, created by
Bouzid Fergani
on 2016-12-20 17:04:29 UTC
(
hide
)
Description:
Bug 17385 - Add custom export notices
Filename:
MIME Type:
Creator:
Bouzid Fergani
Created:
2016-12-20 17:04:29 UTC
Size:
32.33 KB
patch
obsolete
>From be7b05d7e12eeb95f34ed7fb0e9719a6b18cd618 Mon Sep 17 00:00:00 2001 >From: Bouzid Fergani <bouzid.fergani@inlibro.com> >Date: Fri, 30 Sep 2016 11:01:30 -0400 >Subject: [PATCH] Bug 17385 - Add custom export notices > > test case: > - Apply patch > - Open intranet or opac interface and submit any search. > - Click title of found item > - Click save and you found Simple Export. > - Click Simple Export and you have a file.html, it contain informations returned by the xslt file. > - It work correctly in basket and lists. > - The name 'Simple Export' it's extract in the xslt file, curently the name is MARC21_simple_export.xsl. > for Intranet the xsl file is : koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport/MARC21_simple_export.xsl > for opac the xsl file is : koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport/MARC21_simple_export.xsl >--- > C4/XSLT.pm | 77 +++++++++++++++++++++- > Koha/XSLT_Handler.pm | 1 - > basket/basket.pl | 2 + > basket/downloadcart.pl | 7 +- > catalogue/detail.pl | 3 + > catalogue/export.pl | 15 +++++ > .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 3 + > .../prog/en/includes/virtualshelves-toolbar.inc | 3 + > .../intranet-tmpl/prog/en/modules/basket/basket.tt | 3 + > .../prog/en/modules/catalogue/detail.tt | 5 +- > .../en/modules/virtualshelves/downloadshelf.tt | 3 + > .../biblioexport-samples/MARC21_simple_export.xsl | 62 +++++++++++++++++ > .../en/xslt/biblioexport/MARC21_simple_export.xsl | 62 +++++++++++++++++ > .../intranet-tmpl/prog/en/xslt/biblioexport/README | 0 > .../bootstrap/en/includes/opac-detail-sidebar.inc | 3 + > .../bootstrap/en/modules/opac-downloadcart.tt | 3 + > .../bootstrap/en/modules/opac-downloadshelf.tt | 3 + > .../biblioexport-samples/MARC21_simple_export.xsl | 62 +++++++++++++++++ > .../en/xslt/biblioexport/MARC21_simple_export.xsl | 62 +++++++++++++++++ > .../bootstrap/en/xslt/biblioexport/README | 0 > opac/opac-detail.pl | 3 + > opac/opac-downloadcart.pl | 6 ++ > opac/opac-export.pl | 11 +++- > virtualshelves/downloadshelf.pl | 6 +- > virtualshelves/shelves.pl | 1 + > 25 files changed, 398 insertions(+), 8 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport-samples/MARC21_simple_export.xsl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport/MARC21_simple_export.xsl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport/README > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport-samples/MARC21_simple_export.xsl > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport/MARC21_simple_export.xsl > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport/README > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index a829402..0dcfc48 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -47,6 +47,7 @@ BEGIN { > @ISA = qw(Exporter); > @EXPORT = qw( > &XSLTParse4Display >+ &CustomXSLTExportList > ); > $engine=Koha::XSLT_Handler->new( { do_not_return_source => 1 } ); > } >@@ -187,13 +188,27 @@ sub get_xslt_sysprefs { > } > > sub XSLTParse4Display { >- my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang ) = @_; >+ my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $xslFile, $opac ) = @_; > > $sysxml ||= C4::Context->preference($xslsyspref); > $xslfilename ||= C4::Context->preference($xslsyspref); > $lang ||= C4::Languages::getlanguage(); > >- if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { >+ if ($xslFile) { >+ my $myDir; >+ if ($opac) { >+ $myDir = C4::Context->config('opachtdocs') . >+ '/' . C4::Context->preference("opacthemes") . >+ '/' . C4::Languages::getlanguage() . >+ '/xslt/biblioexport'; >+ } else { >+ $myDir = C4::Context->config('intrahtdocs') . >+ '/' . C4::Context->preference("template") . >+ '/' . C4::Languages::getlanguage() . >+ '/xslt/biblioexport'; >+ } >+ $xslfilename = $myDir."/".$xslFile; >+ }elsif( $xslfilename =~ /^\s*"?default"?\s*$/i ) { > my $htdocs; > my $theme; > my $xslfile; >@@ -241,7 +256,6 @@ sub XSLTParse4Display { > my $record = transformMARCXML4XSLT($biblionumber, $orig_record); > my $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items); > my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); >- > $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/; > if ($fixamps) { # We need to correct the HTML entities that Zebra outputs > $xmlrecord =~ s/\&amp;/\&/g; >@@ -350,6 +364,63 @@ Returns reference to XSLT handler object. > sub engine { > return $engine; > } >+=head2 CustomXSLTExportList >+ >+ Returns list of file for custom xslt conversion >+ >+=cut >+ >+sub CustomXSLTExportList { >+ my $opac = shift; # opac (1) vs intranet (0) >+ my @tabFiles; >+ >+ my $myDir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') . >+ '/' . C4::Context->preference( $opac ? "opacthemes" : "template") . >+ '/' . C4::Languages::getlanguage() . >+ '/xslt/biblioexport'; >+ my @files = <$myDir/*.xsl>; >+ foreach my $file (@files) { >+ if ( -f "$file" ) { >+ local $/ = undef; >+ open FILE, $file or die $!; >+ my @lines = split('\n', <FILE>); >+ close (FILE); >+ (my $text = $file) =~ s/.*\///g; >+ my $title = ""; >+ my $outputformat = ""; >+ ## Get title of the option >+ >+ foreach my $line (@lines){ >+ next unless $line =~ /xml/; >+ $line =~ /title="([\w\s]+)"/; >+ $title = $1; >+ >+ last if defined $title; >+ } >+ ($title = $text) =~ s/\.xsl// unless defined $title; >+ >+ ## Get output format >+ foreach my $line (@lines){ >+ next unless $line =~ /xsl:output/; >+ $line =~ /method="([\w\s]+)"/; >+ $outputformat = $1; >+ >+ last if defined $outputformat; >+ } >+ $outputformat = "txt" if ($outputformat eq "" || $outputformat eq "text"); >+ >+ my %row = ( >+ value => $text, >+ filename => $title, >+ format => $outputformat, >+ ); >+ >+ push @tabFiles, \%row; >+ } >+ } >+ return \@tabFiles; >+} >+ > > 1; > >diff --git a/Koha/XSLT_Handler.pm b/Koha/XSLT_Handler.pm >index f4e9411..d211019 100644 >--- a/Koha/XSLT_Handler.pm >+++ b/Koha/XSLT_Handler.pm >@@ -165,7 +165,6 @@ sub transform { > } else { > ( $xml, $filename ) = @_; > } >- > #Initialized yet? > if ( !$self->{xslt_hash} ) { > $self->_init; >diff --git a/basket/basket.pl b/basket/basket.pl >index 62a37ab..04c9646 100755 >--- a/basket/basket.pl >+++ b/basket/basket.pl >@@ -23,6 +23,7 @@ use C4::Biblio; > use C4::Items; > use C4::Auth; > use C4::Output; >+use C4::XSLT; > > use Koha::AuthorisedValues; > use Koha::CsvProfiles; >@@ -123,6 +124,7 @@ my $resultsarray = \@results; > $template->param( > BIBLIO_RESULTS => $resultsarray, > csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ], >+ xsl_exports => CustomXSLTExportList(), > bib_list => $bib_list, > ); > >diff --git a/basket/downloadcart.pl b/basket/downloadcart.pl >index f5cec95..87a92d8 100755 >--- a/basket/downloadcart.pl >+++ b/basket/downloadcart.pl >@@ -28,7 +28,7 @@ use C4::Items; > use C4::Output; > use C4::Record; > use C4::Ris; >- >+use C4::XSLT; > use Koha::CsvProfiles; > > use utf8; >@@ -77,11 +77,15 @@ if ($bib_list && $format) { > elsif ($format eq 'bibtex') { > $output .= marc2bibtex($record, $biblio); > } >+ elsif ($format =~ /^xsl\.(.*)$/) { >+ $output .= XSLTParse4Display($biblio, $record, 'Results', 1, 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 => 'application/octet-stream', >@@ -91,6 +95,7 @@ if ($bib_list && $format) { > > } else { > $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]); >+ $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 a31a0c5..31459e2 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -59,6 +59,9 @@ my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( > } > ); > >+##### ADD CUSTOM XSLT >+$template->param(filesOptions => CustomXSLTExportList(0)); >+ > my $biblionumber = $query->param('biblionumber'); > $biblionumber = HTML::Entities::encode($biblionumber); > my $record = GetMarcBiblio($biblionumber); >diff --git a/catalogue/export.pl b/catalogue/export.pl >index f82250d..546095f 100755 >--- a/catalogue/export.pl >+++ b/catalogue/export.pl >@@ -8,6 +8,7 @@ use C4::Output; > use C4::Biblio; > use CGI qw ( -utf8 ); > use C4::Ris; >+use C4::XSLT; > > > >@@ -77,4 +78,18 @@ if ($op eq "export") { > -attachment=>"bib-$biblionumber.$format"); > print $marc; > } >+}elsif ($op eq "exportxsl"){ >+ my $biblionumber = $query->param("bib"); >+ if ($biblionumber){ >+ my $xslFile = $query->param("file"); >+ my $marc = GetMarcBiblio($biblionumber, 1); >+ my $format=$query->param("format")||'txt'; >+ my @hiddenitems; >+ >+ $marc = XSLTParse4Display($biblionumber, $marc, 'Results', 1, \@hiddenitems,'', $xslFile,'', $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 a8868ab..a58f47e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >@@ -222,6 +222,9 @@ CAN_user_serials_create_subscription ) %] > <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcstd&op=export&bib=[% biblionumber %]">MARC (Unicode/UTF-8, Standard)</a></li> > <li><a href="/cgi-bin/koha/catalogue/export.pl?format=mods&op=export&bib=[% biblionumber %]">MODS (XML)</a></li> > <li><a href="/cgi-bin/koha/catalogue/export.pl?format=ris&op=export&bib=[% biblionumber %]">RIS</a></li> >+ [% FOREACH filesOption IN filesOptions %] >+ <li><a href="/cgi-bin/koha/catalogue/export.pl?format=[% filesOption.format %]&op=exportxsl&file=[% filesOption.value %]&bib=[% biblionumber %]">[% filesOption.filename %]</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 8d7a482..4b457b7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc >@@ -49,6 +49,9 @@ > [% FOREACH csv_profile IN csv_profiles %] > <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=[% csv_profile.export_format_id %]&shelfid=[% shelf.shelfnumber %]">CSV - [% csv_profile.profile %]</a></li> > [% END %] >+ [% FOREACH xsl_export IN xsl_exports %] >+ <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=xsl.[% xsl_export.value %]&shelfid=[% shelf.shelfnumber %]">XSL - [% xsl_export.filename %]</a></li> >+ [% END %] > </ul> > </div> > <div class="btn-group"><a class="btn btn-small" href="#" id="sendlist"><i class="fa fa-envelope"></i> Send list</a></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 ce2fc16..cc6490e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt >@@ -61,6 +61,9 @@ > [% FOREACH csv_profile IN csv_profiles %] > <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=[% csv_profile.export_format_id %]&bib_list=[% bib_list %]">CSV - [% csv_profile.profile %]</a></li> > [% END %] >+ [% FOREACH xsl_export IN xsl_exports %] >+ <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=xsl.[% xsl_export.value %]&bib_list=[% bib_list %]">XSL - [% xsl_export.filename %]</a></li> >+ [% END %] > </ul> > </div> > <a class="btn btn-small" 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 c0151e9..fc2458e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1113,7 +1113,10 @@ function verify_images() { > <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> >+ <option value="utf8">MARC (Unicode/UTF-8)</option> >+ [% FOREACH filesOption IN filesOptions %] >+ <option value="[% filesOption.value %]">[% filesOption.filename %]</option> >+ [% END %]</select> > <input type="submit" name="save" value="Download Record" /></td> > </tr> > <tr><td> >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 96fa994..201df77 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 %]">CSV - [% csv_profile.profile %]</option> > [% END %] >+ [% FOREACH xsl_export IN xsl_exports %] >+ <option value="xsl.[% xsl_export.value %]">XSL - [% xsl_export.filename %]</option> >+ [% END %] > </select> > </li></ol> > </fieldset> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport-samples/MARC21_simple_export.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport-samples/MARC21_simple_export.xsl >new file mode 100644 >index 0000000..3d5e5c5 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport-samples/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"> >+<!-- xml 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/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 0000000..3d5e5c5 >--- /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"> >+<!-- xml 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/intranet-tmpl/prog/en/xslt/biblioexport/README b/koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport/README >new file mode 100644 >index 0000000..e69de29 >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 17fd0e8..58d0ca1 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 >@@ -67,6 +67,9 @@ > </li> > [% END %] > [% END %] >+ [% FOREACH filesOption IN filesOptions %] >+ <li><a role="menuitem" href="/cgi-bin/koha/opac-export.pl?format=[% filesOption.format %]&op=exportxsl&file=[% filesOption.value %]&bib=[% biblionumber %]">[% filesOption.filename %]</a></li> >+ [% END %] > </ul> > </div> > </div> >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 f7eebd8..e565b35 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 %]">CSV - [% csv_profile.profile %]</option> > [% END %] >+ [% FOREACH xsl_export IN xsl_exports %] >+ <option value="xsl.[% xsl_export.value %]">XSL - [% xsl_export.filename %]</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 7824f31..290fd34 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt >@@ -59,6 +59,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 %]">XSL - [% xsl_export.filename %]</option> >+ [% END %] > </select> > <span class="required">Required</span> > </fieldset> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport-samples/MARC21_simple_export.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport-samples/MARC21_simple_export.xsl >new file mode 100644 >index 0000000..3d5e5c5 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport-samples/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"> >+<!-- xml 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/xslt/biblioexport/MARC21_simple_export.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport/MARC21_simple_export.xsl >new file mode 100644 >index 0000000..3d5e5c5 >--- /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"> >+<!-- xml 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/xslt/biblioexport/README b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport/README >new file mode 100644 >index 0000000..e69de29 >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index a7e643c..cba99d3 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -70,6 +70,9 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > } > ); > >+##### ADD CUSTOM XSLT >+$template->param(filesOptions => CustomXSLTExportList(1)); >+ > my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0; > $biblionumber = int($biblionumber); > >diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl >index 75ab4a1..c68c41c 100755 >--- a/opac/opac-downloadcart.pl >+++ b/opac/opac-downloadcart.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; > >@@ -97,11 +98,15 @@ if ($bib_list && $format) { > $extension = "txt"; > $type = "text/plain"; > } >+ elsif ($format =~ /^xsl\.(.*)$/) { >+ $output .= XSLTParse4Display($biblio, $record, 'Results', 1, undef, undef, 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', >@@ -112,6 +117,7 @@ if ($bib_list && $format) { > > } else { > $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]); >+ $template->param(xsl_exports => CustomXSLTExportList()); > $template->param(bib_list => $bib_list); > output_html_with_http_headers $query, $cookie, $template->output; > } >diff --git a/opac/opac-export.pl b/opac/opac-export.pl >index c0f18bf..fd663e1 100755 >--- a/opac/opac-export.pl >+++ b/opac/opac-export.pl >@@ -26,6 +26,7 @@ use C4::Biblio; > use CGI qw ( -utf8 ); > use C4::Auth; > use C4::Ris; >+use C4::XSLT; > use Koha::RecordProcessor; > > my $query = CGI->new; >@@ -34,7 +35,6 @@ my $format=$query->param("format")||'utf8'; > my $biblionumber = $query->param("bib")||0; > $biblionumber = int($biblionumber); > my $error = q{}; >- > my $include_items = ($format =~ /bibtex/) ? 0 : 1; > my $marc = GetMarcBiblio($biblionumber, $include_items) > if $biblionumber; >@@ -103,6 +103,15 @@ elsif ( $format =~ /isbd/ ) { > }); > $format = 'isbd'; > } >+elsif ($format =~ /html/ ) { >+ if ($biblionumber){ >+ my $xslFile = $query->param("file"); >+ $marc = C4::Biblio::GetMarcBiblio($biblionumber); >+ my @hiddenitems; >+ >+ $marc = XSLTParse4Display($biblionumber, $marc, 'Results', 1, \@hiddenitems, undef, undef, undef, $xslFile, 1); >+ } >+} > else { > $error= "Format $format is not supported."; > } >diff --git a/virtualshelves/downloadshelf.pl b/virtualshelves/downloadshelf.pl >index 5a9f440..2279825 100755 >--- a/virtualshelves/downloadshelf.pl >+++ b/virtualshelves/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::Virtualshelves; >@@ -81,12 +82,15 @@ if ($shelfid && $format) { > elsif ($format eq 'bibtex') { > $output .= marc2bibtex($record, $biblionumber); > } >+ elsif ($format =~ /^xsl\.(.*)$/){ >+ $output .= XSLTParse4Display($biblionumber, $record, 'Results', 1, 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 => 'application/octet-stream', > -'Content-Transfer-Encoding' => 'binary', >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index 691e215..1ef41c6 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -316,6 +316,7 @@ $template->param( > category => $category, > print => scalar $query->param('print') || 0, > csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ], >+ xsl_exports => CustomXSLTExportList() > ); > > output_html_with_http_headers $query, $cookie, $template->output; >-- >1.9.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