3 # Parts Copyright Catalyst IT 2011
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 my $op=$query->param("op")||''; #op=export is currently the only use
33 my $format=$query->param("format")||'utf8';
34 my $biblionumber = $query->param("bib")||0;
35 $biblionumber = int($biblionumber);
36 my ($marc, $error)= ('','');
38 $marc = GetMarcBiblio
($biblionumber, 1) if $biblionumber;
40 print $query->redirect("/cgi-bin/koha/errors/404.pl");
43 elsif ($format =~ /endnote/) {
44 $marc = marc2endnote
($marc);
47 elsif ($format =~ /marcxml/) {
48 $marc = marc2marcxml
($marc);
51 elsif ($format=~ /mods/) {
52 $marc = marc2modsxml
($marc);
55 elsif ($format =~ /ris/) {
56 $marc = marc2ris
($marc);
59 elsif ($format =~ /bibtex/) {
60 $marc = marc2bibtex
(C4
::Biblio
::GetMarcBiblio
($biblionumber),$biblionumber);
63 elsif ($format =~ /dc/) {
64 ($error,$marc) = marc2dcxml
($marc,1);
65 $format = "dublin-core.xml";
67 elsif ($format =~ /marc8/) {
68 ($error,$marc) = changeEncoding
($marc,"MARC","MARC21","MARC-8");
69 $marc = $marc->as_usmarc() unless $error;
72 elsif ($format =~ /utf8/) {
73 C4
::Charset
::SetUTF8Flag
($marc,1);
74 $marc = $marc->as_usmarc();
77 elsif ($format =~ /marcstd/) {
78 C4
::Charset
::SetUTF8Flag
($marc,1);
79 ($error,$marc) = marc2marc
($marc, 'marcstd', C4
::Context
->preference('marcflavour'));
83 $error= "Format $format is not supported.";
87 print $query->header();
88 print $query->start_html();
89 print "<h1>An error occurred </h1>";
90 print $query->escapeHTML("$error");
91 print $query->end_html();
95 -type
=> 'application/octet-stream',
96 -attachment
=>"bib-$biblionumber.$format");