]> git.koha-community.org Git - koha.git/blob - opac/opac-export.pl
Cleanup - moremember.pl and .tmpl
[koha.git] / opac / opac-export.pl
1 #!/usr/bin/perl
2 use HTML::Template::Pro;
3 use strict;
4
5 use C4::Record;
6 use C4::Auth;
7 use C4::Output;
8 use C4::Biblio;
9 use CGI;
10 use C4::Auth;
11
12 my $query = new CGI;
13 my $op=$query->param("op");
14 my $format=$query->param("format");
15 if ($op eq "export") {
16         my $biblionumber = $query->param("bib");
17         my $dbh=C4::Context->dbh;
18         my $sth;
19         if ($biblionumber) {
20                 $sth=$dbh->prepare("SELECT marc FROM biblioitems WHERE biblionumber =?");
21                 $sth->execute($biblionumber);
22         }
23         while (my ($marc) = $sth->fetchrow) {
24                 if ($marc){
25
26                         if ($format =~ /endnote/) {
27                                 $marc = marc2endnote($marc);
28                                 $format = 'endnote';
29                         }
30                         elsif ($format =~ /marcxml/) {
31                                 $marc = marc2marcxml($marc);
32                         }
33                         elsif ($format=~ /mods/) {
34                                 $marc = marc2modsxml($marc);
35                         }
36                         elsif ($format =~ /dc/) {
37                                 my $error;
38                                 ($error,$marc) = marc2dcxml($marc,1);
39                                 $format = "dublin-core.xml";
40                         }
41                         elsif ($format =~ /marc8/) {
42                                 $marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
43                                 $marc = $marc->as_usmarc();
44                         }
45                         elsif ($format =~ /utf8/) {
46                                 #default
47                         }
48                         print $query->header(
49                                 -type => 'application/octet-stream',
50                 -attachment=>"bib-$biblionumber.$format");
51                         print $marc;
52                 }
53         }
54 }