start of big MARC21 authorities work
[koha.git] / opac / opac-export.pl
blob758afd3fa736dd27095cdce3d800576b6168b8d5
1 #!/usr/bin/perl
2 use HTML::Template::Pro;
3 use strict;
4 require Exporter;
5 use C4::Record;
6 use C4::Auth;
7 use C4::Output;
8 use C4::Biblio;
9 use CGI;
10 use C4::Auth;
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);
23 while (my ($marc) = $sth->fetchrow) {
24 if ($marc){
26 if ($format =~ /endnote/) {
27 $marc = marc2endnote($marc);
28 $format = 'endnote';
30 elsif ($format =~ /marcxml/) {
31 $marc = marc2marcxml($marc);
33 elsif ($format=~ /mods/) {
34 $marc = marc2modsxml($marc);
36 elsif ($format =~ /dc/) {
37 my $error;
38 ($error,$marc) = marc2dcxml($marc,1);
39 $format = "dublin-core.xml";
41 elsif ($format =~ /marc8/) {
42 $marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
43 $marc = $marc->as_usmarc();
45 elsif ($format =~ /utf8/) {
46 #default
48 print $query->header(
49 -type => 'application/octet-stream',
50 -attachment=>"bib-$biblionumber.$format");
51 print $marc;