Bugzilla – Attachment 7612 Details for
Bug 7345
Should be possible to export MARC records without private fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
patch.txt (text/plain), 6.01 KB, created by
Marcel de Rooy
on 2012-02-13 08:06:02 UTC
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2012-02-13 08:06:02 UTC
Size:
6.01 KB
patch
obsolete
>From 5d759a899022f8848a1992838b8dbd42a026e323 Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Sat, 10 Dec 2011 20:14:52 -0500 >Subject: [PATCH] Bug 7345: Enable exporting records sans private fields >Content-Type: text/plain; charset="utf-8" > >Add an option for marcstd to the opac-export.pl and catalogue/export.pl >scripts. This new format removes all 9XX, X9X, XX9 fields and subfield $9 >(with the exception of 490 in flavours of MARC other than UNIMARC). The work is >done in C4::Record::marc2marc. > >This patch adds the new export option 'marcstd' for exporting MARC >records without 9xx, x9x and xx9 fields and subfields to the staff >detail page. > >Testing plan: >1. Export a record in "MARC (Unicode/UTF-8)" format as a control >2. In the OPAC, run the following jQuery to add the marcstd option to the UI: >> $("#export #format").append("<option value='marcstd'>MARC (no 9xx)</option>"); >3. Export the same record in "MARC (no 9xx)" format >4. Compare the two, noticing that any subfield $9 or fields including 9 (other > than 490 in flavours of MARC other than UNIMARC) have been removed > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Works as advertised now. >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >This patch squashes both the original patch and Katrin's follow-up adding >marcstd as an export option on the staff client. > >Feb 13, 2012 (marcel): Amended this patch to resolved two definitions of $error in catalogue/export script. >--- > C4/Record.pm | 27 +++++++++++++++++++- > catalogue/export.pl | 6 +++- > .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 3 +- > opac/opac-export.pl | 4 +++ > 4 files changed, 37 insertions(+), 3 deletions(-) > >diff --git a/C4/Record.pm b/C4/Record.pm >index e906850..89bde32 100644 >--- a/C4/Record.pm >+++ b/C4/Record.pm >@@ -77,7 +77,32 @@ Returns an ISO-2709 scalar > > sub marc2marc { > my ($marc,$to_flavour,$from_flavour,$encoding) = @_; >- my $error = "Feature not yet implemented\n"; >+ my $error; >+ if ($to_flavour =~ m/marcstd/) { >+ my $marc_record_obj; >+ if ($marc =~ /^MARC::Record/) { # it's already a MARC::Record object >+ $marc_record_obj = $marc; >+ } else { # it's not a MARC::Record object, make it one >+ eval { $marc_record_obj = MARC::Record->new_from_usmarc($marc) }; # handle exceptions >+ >+# conversion to MARC::Record object failed, populate $error >+ if ($@) { $error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR }; >+ } >+ unless ($error) { >+ my @privatefields; >+ foreach my $field ($marc_record_obj->fields()) { >+ if ($field->tag() =~ m/9/ && ($field->tag() != '490' || C4::Context->preference("marcflavour") eq 'UNIMARC')) { >+ push @privatefields, $field; >+ } elsif (! ($field->is_control_field())) { >+ $field->delete_subfield(code => '9') if ($field->subfield('9')); >+ } >+ } >+ $marc_record_obj->delete_field($_) for @privatefields; >+ $marc = $marc_record_obj->as_usmarc(); >+ } >+ } else { >+ $error = "Feature not yet implemented\n"; >+ } > return ($error,$marc); > } > >diff --git a/catalogue/export.pl b/catalogue/export.pl >index 2b55d9f..3a76084 100755 >--- a/catalogue/export.pl >+++ b/catalogue/export.pl >@@ -22,6 +22,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ > > my $op=$query->param("op"); > my $format=$query->param("format"); >+my $error = ''; > if ($op eq "export") { > my $biblionumber = $query->param("bib"); > if ($biblionumber){ >@@ -39,7 +40,6 @@ if ($op eq "export") { > $marc = marc2modsxml($marc); > } > elsif ($format =~ /dc/) { >- my $error; > ($error,$marc) = marc2dcxml($marc,1); > $format = "dublin-core.xml"; > } >@@ -51,6 +51,10 @@ if ($op eq "export") { > C4::Charset::SetUTF8Flag($marc, 1); > $marc = $marc->as_usmarc(); > } >+ elsif ($format =~ /marcstd/) { >+ C4::Charset::SetUTF8Flag($marc,1); >+ ($error, $marc) = marc2marc($marc, 'marcstd', C4::Context->preference('marcflavour')); >+ } > print $query->header( > -type => 'application/octet-stream', > -attachment=>"bib-$biblionumber.$format"); >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 bd597b5..5159d2a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >@@ -123,7 +123,8 @@ function confirm_items_deletion() { > { text: _("Dublin Core (XML)"), url: "/cgi-bin/koha/catalogue/export.pl?format=dc&op=export&bib=[% biblionumber %]" }, > { text: _("MARCXML"), url: "/cgi-bin/koha/catalogue/export.pl?format=marcxml&op=export&bib=[% biblionumber %]" }, > { text: _("MARC (non-Unicode/MARC-8)"), url: "/cgi-bin/koha/catalogue/export.pl?format=marc8&op=export&bib=[% biblionumber %]" }, >- { text: _("MARC (Unicode/UTF-8)"), url: "/cgi-bin/koha/catalogue/export.pl?format=utf8&op=export&bib=[% biblionumber %]" } >+ { text: _("MARC (Unicode/UTF-8)"), url: "/cgi-bin/koha/catalogue/export.pl?format=utf8&op=export&bib=[% biblionumber %]" }, >+ { text: _("MARC (Unicode/UTF-8, Standard)"), url: "/cgi-bin/koha/catalogue/export.pl?format=marcstd&op=export&bib=[% biblionumber %]" } > ]; > > new YAHOO.widget.Button({ >diff --git a/opac/opac-export.pl b/opac/opac-export.pl >index 411fd3f..fb8dee7 100755 >--- a/opac/opac-export.pl >+++ b/opac/opac-export.pl >@@ -66,6 +66,10 @@ elsif ($format =~ /utf8/) { > C4::Charset::SetUTF8Flag($marc,1); > $marc = $marc->as_usmarc(); > } >+elsif ($format =~ /marcstd/) { >+ C4::Charset::SetUTF8Flag($marc,1); >+ ($error,$marc) = marc2marc($marc, 'marcstd', C4::Context->preference('marcflavour')); >+} > else { > $error= "Format $format is not supported."; > } >-- >1.6.0.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 7345
:
6704
|
6707
|
6738
|
7001
|
7006
|
7017
|
7460
|
7462
|
7566
| 7612