Bugzilla – Attachment 26021 Details for
Bug 11915
Extending the use of Koha/XSLT_Handler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11915: Use xslt handler object in showmarc, Record.pm
Bug-11915-Use-xslt-handler-object-in-showmarc-Reco.patch (text/plain), 8.37 KB, created by
Marcel de Rooy
on 2014-03-10 15:28:29 UTC
(
hide
)
Description:
Bug 11915: Use xslt handler object in showmarc, Record.pm
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2014-03-10 15:28:29 UTC
Size:
8.37 KB
patch
obsolete
>From 3972a45387ca883176dae306bd58298021d9389c Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 10 Mar 2014 13:54:36 +0100 >Subject: [PATCH] Bug 11915: Use xslt handler object in showmarc, Record.pm >Content-Type: text/plain; charset=utf-8 > >Modifies showmarc and opac-showmarc to use new xslt handler. >Removes cardview.pl as obsolete script. >Modifies C4/Record.pm and a typo in the test Record.t. > >Test plan: >[1] catalogue/showmarc: Go to Cataloging. Search. Click Card. >[2] opac-showmarc: Go to opac detail, MARC view. > Open URL for plain view in new tab. > Change URL: Change viewas=html to viewas=card >[3] Verify that there are no references in the codebase to cardview.pl >[4] C4/Record.pm: Run the Record.t test in db_dependent. > This test uses marc2modsxml, triggering the change. > Additional: export to MODS from opac-detail. >--- > C4/Record.pm | 12 +-------- > catalogue/cardview.pl | 60 ----------------------------------------------- > catalogue/showmarc.pl | 13 ++-------- > opac/opac-showmarc.pl | 20 ++------------- > t/db_dependent/Record.t | 2 +- > 5 files changed, 9 insertions(+), 98 deletions(-) > delete mode 100755 catalogue/cardview.pl > >diff --git a/C4/Record.pm b/C4/Record.pm >index adb0c81..e291486 100644 >--- a/C4/Record.pm >+++ b/C4/Record.pm >@@ -28,11 +28,10 @@ use MARC::File::XML; # marc2marcxml, marcxml2marc, changeEncoding > use MARC::Crosswalk::DublinCore; # marc2dcxml > use Biblio::EndnoteStyle; > use Unicode::Normalize; # _entity_encode >-use XML::LibXSLT; >-use XML::LibXML; > use C4::Biblio; #marc2bibtex > use C4::Csv; #marc2csv > use C4::Koha; #marc2csv >+use C4::XSLT (); > use YAML; #marcrecords2csv > use Text::CSV::Encoded; #marc2csv > >@@ -306,14 +305,7 @@ sub _transformWithStylesheet { > # grab the XML, run it through our stylesheet, push it out to the browser > my $xmlrecord = marc2marcxml($marc); > my $xslfile = C4::Context->config('intrahtdocs') . $stylesheet; >- my $parser = XML::LibXML->new(); >- my $xslt = XML::LibXSLT->new(); >- my $source = $parser->parse_string($xmlrecord); >- my $style_doc = $parser->parse_file($xslfile); >- my $style_sheet = $xslt->parse_stylesheet($style_doc); >- my $results = $style_sheet->transform($source); >- my $newxmlrecord = $style_sheet->output_string($results); >- return ($newxmlrecord); >+ return C4::XSLT::engine->transform($xmlrecord, $xslfile); > } > > sub marc2endnote { >diff --git a/catalogue/cardview.pl b/catalogue/cardview.pl >deleted file mode 100755 >index a288d4a..0000000 >--- a/catalogue/cardview.pl >+++ /dev/null >@@ -1,60 +0,0 @@ >-#!/usr/bin/perl >-use strict; >-# parts copyright 2010 BibLibre >-# 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 2 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, write to the Free Software Foundation, Inc., >-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >- >-#use warnings; FIXME - Bug 2505 >- >-use CGI; >-use XML::LibXSLT; >-use XML::LibXML; >-use C4::Koha; >-use C4::Auth; >-use C4::Biblio; >-use C4::Languages qw(getTranslatedLanguages); >- >-my $query=new CGI; >-my ($template, $borrowernumber, $cookie) >- = get_template_and_user({template_name => "opac-detail.tmpl", >- query => $query, >- type => "opac", >- authnotrequired => 1, >- flagsrequired => {borrow => 1}, >- }); >- >-# load the languages >-my @languages_options = getTranslatedLanguages($query); >-my $languages_count = @languages_options; >-if($languages_count > 1){ >- $template->param(languages => \@languages_options); >-} >-my $biblionumber=$query->param('biblionumber'); >-$template->param(biblionumber => $biblionumber); >- >-# grab the XML, run it through our stylesheet, push it out to the browser >-my $xmlrecord = GetXmlBiblio($biblionumber); >-#my $xslfile = "/home/kohacat/etc/xslt/MARC21slim2HTML.xsl"; >-#my $xslfile = "/home/kohacat/etc/xslt/MARC21slim2English.xsl"; >-my $xslfile = C4::Context->config('intranetdir')."/koha-tmpl/intranet-tmpl/prog/en/xslt/compact.xsl"; >-my $parser = XML::LibXML->new(); >-my $xslt = XML::LibXSLT->new(); >-my $source = $parser->parse_string($xmlrecord); >-my $style_doc = $parser->parse_file($xslfile); >-my $stylesheet = $xslt->parse_stylesheet($style_doc); >-my $results = $stylesheet->transform($source); >-my $newxmlrecord = $stylesheet->output_string($results); >-print "Content-type: text/html\n\n"; >-print $newxmlrecord; >diff --git a/catalogue/showmarc.pl b/catalogue/showmarc.pl >index 9cc039d..9470019 100755 >--- a/catalogue/showmarc.pl >+++ b/catalogue/showmarc.pl >@@ -9,7 +9,7 @@ > # > # 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 2 of the License, or (at your option) any later >+# 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 >@@ -34,8 +34,7 @@ use C4::Output; > use C4::Auth; > use C4::Biblio; > use C4::ImportBatch; >-use XML::LibXSLT; >-use XML::LibXML; >+use C4::XSLT (); > > my $input= new CGI; > my $biblionumber= $input->param('id'); >@@ -63,13 +62,7 @@ if($view eq 'card') { > if ( ! -f $xslfile && $themelang ne '/en' ) { > $xslfile=~s#$themelang#/en#; > } >- my $parser = XML::LibXML->new(); >- my $xslt = XML::LibXSLT->new(); >- my $source = $parser->parse_string($xmlrecord); >- my $style_doc = $parser->parse_file($xslfile); >- my $stylesheet = $xslt->parse_stylesheet($style_doc); >- my $results = $stylesheet->transform($source); >- my $newxmlrecord = $stylesheet->output_string($results); >+ my $newxmlrecord = C4::XSLT::engine->transform($xmlrecord, $xslfile); > print $input->header(-charset => 'UTF-8'), Encode::encode_utf8($newxmlrecord); > } > else { >diff --git a/opac/opac-showmarc.pl b/opac/opac-showmarc.pl >index 27ab61c..623b42b 100755 >--- a/opac/opac-showmarc.pl >+++ b/opac/opac-showmarc.pl >@@ -1,19 +1,12 @@ > #!/usr/bin/perl > >-# $Id: showmarc.pl,v 1.1.2.1 2007/06/18 21:57:23 rangi Exp $ >- >- >-# Koha library project www.koha-community.org >- >-# Licensed under the GPL >- > # Copyright 2007 Liblime > # > # 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 2 of the License, or (at your option) any later >+# 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 >@@ -37,8 +30,7 @@ use C4::Output; > use C4::Auth; > use C4::Biblio; > use C4::ImportBatch; >-use XML::LibXSLT; >-use XML::LibXML; >+use C4::XSLT (); > > my $input = new CGI; > my $biblionumber = $input->param('id'); >@@ -78,13 +70,7 @@ if ($view eq 'card' || $view eq 'html') { > $xslfilename = "$htdocs/prog/$lang/xslt/$xslfile" unless ( -f $xslfile ); > $xslfilename = "$htdocs/prog/en/xslt/$xslfile" unless ( $lang ne 'en' && -f $xslfilename ); > >- my $parser = XML::LibXML->new(); >- my $xslt = XML::LibXSLT->new(); >- my $source = $parser->parse_string($xmlrecord); >- my $style_doc = $parser->parse_file($xslfilename); >- my $stylesheet = $xslt->parse_stylesheet($style_doc); >- my $results = $stylesheet->transform($source); >- my $newxmlrecord = $stylesheet->output_string($results); >+ my $newxmlrecord = C4::XSLT::engine->transform($xmlrecord, $xslfilename); > print $input->header(-charset => 'UTF-8'), Encode::encode_utf8($newxmlrecord); > } > else { #view eq marc >diff --git a/t/db_dependent/Record.t b/t/db_dependent/Record.t >index 34a47c0..e8d6094 100755 >--- a/t/db_dependent/Record.t >+++ b/t/db_dependent/Record.t >@@ -81,7 +81,7 @@ my $test4xml=qq(<?xml version="1.0" encoding="UTF-8"?> > </mods> > ); > >-is ($mods, $test4xml, "testing marc2mosxml"); >+is ($mods, $test4xml, "testing marc2modsxml"); > > $marc->append_fields(MARC::Field->new( > '100', ' ', ' ', a => 'Rowling, J.K.' >-- >1.7.7.6
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 11915
:
26020
|
26021