Bug 7143 about.tt indentation fixes
[koha.git] / catalogue / export.pl
blob3a760844d7b00e39665d10a2465e42f690b80410
1 #!/usr/bin/perl
2 use strict;
3 #use warnings; FIXME - Bug 2505
5 use C4::Record;
6 use C4::Auth;
7 use C4::Output;
8 use C4::Biblio;
9 use CGI;
13 my $query = new CGI;
14 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
15 template_name => "tools/export.tt",
16 query => $query,
17 type => "intranet",
18 authnotrequired => 0,
19 flagsrequired => { tools => 'export_catalog' },
20 debug => 1,
21 });
23 my $op=$query->param("op");
24 my $format=$query->param("format");
25 my $error = '';
26 if ($op eq "export") {
27 my $biblionumber = $query->param("bib");
28 if ($biblionumber){
30 my $marc = GetMarcBiblio($biblionumber, 1);
32 if ($format =~ /endnote/) {
33 $marc = marc2endnote($marc);
34 $format = 'endnote';
36 elsif ($format =~ /marcxml/) {
37 $marc = marc2marcxml($marc);
39 elsif ($format=~ /mods/) {
40 $marc = marc2modsxml($marc);
42 elsif ($format =~ /dc/) {
43 ($error,$marc) = marc2dcxml($marc,1);
44 $format = "dublin-core.xml";
46 elsif ($format =~ /marc8/) {
47 $marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
48 $marc = $marc->as_usmarc();
50 elsif ($format =~ /utf8/) {
51 C4::Charset::SetUTF8Flag($marc, 1);
52 $marc = $marc->as_usmarc();
54 elsif ($format =~ /marcstd/) {
55 C4::Charset::SetUTF8Flag($marc,1);
56 ($error, $marc) = marc2marc($marc, 'marcstd', C4::Context->preference('marcflavour'));
58 print $query->header(
59 -type => 'application/octet-stream',
60 -attachment=>"bib-$biblionumber.$format");
61 print $marc;