Fix updatedatabase.pl syntax error
[koha.git] / catalogue / export.pl
blobf82250db89c31f6becbce401ce22b716db1f2f06
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 qw ( -utf8 );
10 use C4::Ris;
14 my $query = new CGI;
15 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
16 template_name => "tools/export.tt",
17 query => $query,
18 type => "intranet",
19 authnotrequired => 0,
20 flagsrequired => { catalogue => 1 },
21 debug => 1,
22 });
24 my $op=$query->param("op");
25 my $format=$query->param("format");
26 my $error = '';
27 if ($op eq "export") {
28 my $biblionumber = $query->param("bib");
29 if ($biblionumber){
31 my $marc = GetMarcBiblio($biblionumber, 1);
33 if ($format =~ /endnote/) {
34 $marc = marc2endnote($marc);
35 $format = 'endnote';
37 elsif ($format =~ /marcxml/) {
38 $marc = marc2marcxml($marc);
39 $format = "marcxml";
41 elsif ($format=~ /mods/) {
42 $marc = marc2modsxml($marc);
43 $format = "mods";
45 elsif ($format =~ /ris/) {
46 $marc = marc2ris($marc);
47 $format = "ris";
49 elsif ($format =~ /bibtex/) {
50 $marc = marc2bibtex($marc);
51 $format = "bibtex";
53 elsif ($format =~ /dc$/) {
54 $marc = marc2dcxml(undef, undef, $biblionumber, $format);
55 $format = "dublin-core.xml";
57 elsif ($format =~ /marc8/) {
58 $marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
59 $marc = $marc->as_usmarc();
60 $format = "marc8";
62 elsif ($format =~ /utf8/) {
63 C4::Charset::SetUTF8Flag($marc, 1);
64 $marc = $marc->as_usmarc();
65 $format = "utf8";
67 elsif ($format =~ /marcstd/) {
68 C4::Charset::SetUTF8Flag($marc,1);
69 ($error, $marc) = marc2marc($marc, 'marcstd', C4::Context->preference('marcflavour'));
70 $format = "marcstd";
72 if ( $format =~ /utf8/ or $format =~ /marcstd/ ) {
73 binmode STDOUT, ':encoding(UTF-8)';
75 print $query->header(
76 -type => 'application/octet-stream',
77 -attachment=>"bib-$biblionumber.$format");
78 print $marc;