@@ -, +, @@
resulting files are what you expect
---
C4/Record.pm | 54 +-
authorities/export.pl | 52 +
.../prog/en/includes/authorities-toolbar.inc | 23 +-
.../intranet-tmpl/prog/en/xslt/MARC21slim2MADS.xsl | 1388 ++++++++++++++++++++
4 files changed, 1502 insertions(+), 15 deletions(-)
create mode 100755 authorities/export.pl
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MADS.xsl
--- a/C4/Record.pm
+++ a/C4/Record.pm
@@ -52,6 +52,7 @@ $VERSION = 3.07.00.049;
&marcxml2marc
&marc2dcxml
&marc2modsxml
+ &marc2madsxml
&marc2bibtex
&marc2csv
&changeEncoding
@@ -267,25 +268,52 @@ sub marc2dcxml {
=head2 marc2modsxml - Convert from ISO-2709 to MODS
- my ($error,$modsxml) = marc2modsxml($marc);
+ my $modsxml = marc2modsxml($marc);
Returns a MODS scalar
=cut
sub marc2modsxml {
- my ($marc) = @_;
- # grab the XML, run it through our stylesheet, push it out to the browser
- my $xmlrecord = marc2marcxml($marc);
- my $xslfile = C4::Context->config('intrahtdocs')."/prog/en/xslt/MARC21slim2MODS3-1.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);
- return ($newxmlrecord);
+ my ($marc) = @_;
+ return _transformWithStylesheet($marc, "/prog/en/xslt/MARC21slim2MODS3-1.xsl");
+}
+
+=head2 marc2madsxml - Convert from ISO-2709 to MADS
+
+ my $madsxml = marc2madsxml($marc);
+
+Returns a MADS scalar
+
+=cut
+
+sub marc2madsxml {
+ my ($marc) = @_;
+ return _transformWithStylesheet($marc, "/prog/en/xslt/MARC21slim2MADS.xsl");
+}
+
+=head2 _transformWithStylesheet - Transform a MARC record with a stylesheet
+
+ my $xml = _transformWithStylesheet($marc, $stylesheet)
+
+Returns the XML scalar result of the transformation. $stylesheet should
+contain the path to a stylesheet under intrahtdocs.
+
+=cut
+
+sub _transformWithStylesheet {
+ my ($marc, $stylesheet) = @_;
+ # 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 $stylesheet = $xslt->parse_stylesheet($style_doc);
+ my $results = $stylesheet->transform($source);
+ my $newxmlrecord = $stylesheet->output_string($results);
+ return ($newxmlrecord);
}
sub marc2endnote {
--- a/authorities/export.pl
+++ a/authorities/export.pl
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use C4::Record;
+use C4::Auth;
+use C4::Output;
+use C4::AuthoritiesMarc;
+use CGI;
+
+my $query = new CGI;
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "tools/export.tt",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { editauthorities => 1 },
+ debug => 1,
+ }
+);
+
+my $op = $query->param("op");
+my $format = $query->param("format");
+my $error = '';
+if ( $op eq "export" ) {
+ my $authid = $query->param("authid");
+ if ($authid) {
+
+ my $marc = GetAuthority($authid);
+
+ if ( $format =~ /marcxml/ ) {
+ $marc = marc2marcxml($marc);
+ }
+ elsif ($format=~ /mads/) {
+ $marc = marc2madsxml($marc);
+ }
+ elsif ( $format =~ /marc8/ ) {
+ $marc = changeEncoding( $marc, "MARC", "MARC21", "MARC-8" );
+ $marc = $marc->as_usmarc();
+ }
+ elsif ( $format =~ /utf8/ ) {
+ C4::Charset::SetUTF8Flag( $marc, 1 );
+ $marc = $marc->as_usmarc();
+ }
+ print $query->header(
+ -type => 'application/octet-stream',
+ -attachment => "auth-$authid.$format"
+ );
+ print $marc;
+ }
+}
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc
@@ -7,6 +7,7 @@
$(document).ready(function() {
$("#newmenuc").empty();
$("#delAuthc").empty();
+ $("#savemenuc").empty();
yuiToolbar();
});
@@ -35,7 +36,23 @@
label: _("Delete"),
container: "delAuthc",
onclick: {fn: confirm_deletion }
- });
+ });
+
+ var savemenu = [
+ { text: _("MADS (XML)"), url: "/cgi-bin/koha/authorities/export.pl?format=mads&op=export&authid=[% authid %]" },
+ { text: _("MARCXML"), url: "/cgi-bin/koha/authorities/export.pl?format=marcxml&op=export&authid=[% authid %]" },
+ { text: _("MARC (non-Unicode/MARC-8)"), url: "/cgi-bin/koha/authorities/export.pl?format=marc8&op=export&authid=[% authid %]" },
+ { text: _("MARC (Unicode/UTF-8)"), url: "/cgi-bin/koha/authorities/export.pl?format=utf8&op=export&authid=[% authid %]" },
+ ];
+
+ new YAHOO.widget.Button({
+ type: "menu",
+ label: _("Save"),
+ id: "savemenuc",
+ name: "savemenubutton",
+ menu: savemenu,
+ container: "savemenuc"
+ });
}
//]]>
@@ -46,7 +63,9 @@
[% UNLESS ( count ) %]
Delete
- [% END %][% ELSE %] [% END %]
+ [% END %]
+
+[% ELSE %] [% END %]