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);
}
my $op=$query->param("op");
my $format=$query->param("format");
+my $error = '';
if ($op eq "export") {
my $biblionumber = $query->param("bib");
if ($biblionumber){
$marc = marc2modsxml($marc);
}
elsif ($format =~ /dc/) {
- my $error;
($error,$marc) = marc2dcxml($marc,1);
$format = "dublin-core.xml";
}
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");
{ 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({
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.";
}