Merge remote-tracking branch 'origin/new/bug_7751'
[koha.git] / catalogue / export.pl
index 9bd49de..3a76084 100755 (executable)
@@ -1,5 +1,4 @@
 #!/usr/bin/perl
-use HTML::Template::Pro;
 use strict;
 #use warnings; FIXME - Bug 2505
 
@@ -8,11 +7,22 @@ use C4::Auth;
 use C4::Output;
 use C4::Biblio;
 use CGI;
-use C4::Auth;
+
+
 
 my $query = new CGI;
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
+                                                                     template_name   => "tools/export.tt",
+                                                                     query           => $query,
+                                                                     type            => "intranet",
+                                                                     authnotrequired => 0,
+                                                                     flagsrequired   => { tools => 'export_catalog' },
+                                                                     debug           => 1,
+                                                                     });
+
 my $op=$query->param("op");
 my $format=$query->param("format");
+my $error = '';
 if ($op eq "export") {
        my $biblionumber = $query->param("bib");
                if ($biblionumber){
@@ -30,7 +40,6 @@ if ($op eq "export") {
                                $marc = marc2modsxml($marc);
                        }
                        elsif ($format =~ /dc/) {
-                               my $error;
                                ($error,$marc) = marc2dcxml($marc,1);
                                $format = "dublin-core.xml";
                        }
@@ -42,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");