13cbbb79dd
Adds the ability to save individual authority records in MADS, MARCXML, or binary MARC format to the staff client. To test: 1. Apply patch 2. View authority record in staff client 3. Try saving record as MADS, MARCXML, and MARC, and confirm that the resulting files are what you expect Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Works nicely, tested different export options on different records.
52 lines
1.3 KiB
Perl
Executable file
52 lines
1.3 KiB
Perl
Executable file
#!/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;
|
|
}
|
|
}
|