Koha/opac/opac-export.pl
Owen Leonard f3dd19f2f7 Fix for Bug 4400, BIBTEX export from OPAC results in empty file
opac-export.pl tries to get two variables from marc2bibtex(),
but it only returns one.

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
2010-05-11 06:14:38 -04:00

61 lines
1.4 KiB
Perl
Executable file

#!/usr/bin/perl
use HTML::Template::Pro;
use strict;
use warnings;
use C4::Record;
use C4::Auth;
use C4::Output;
use C4::Biblio;
use CGI;
use C4::Auth;
use C4::Ris;
my $query = new CGI;
my $op=$query->param("op");
my $format=$query->param("format");
if ($op eq "export") {
my $biblionumber = $query->param("bib");
my $dbh=C4::Context->dbh;
my $sth;
if ($biblionumber) {
$sth=$dbh->prepare("SELECT marc FROM biblioitems WHERE biblionumber =?");
$sth->execute($biblionumber);
}
while (my ($marc) = $sth->fetchrow) {
if ($marc){
if ($format =~ /endnote/) {
$marc = marc2endnote($marc);
$format = 'endnote';
}
elsif ($format =~ /marcxml/) {
$marc = marc2marcxml($marc);
}
elsif ($format=~ /mods/) {
$marc = marc2modsxml($marc);
}
elsif ($format =~ /ris/) {
$marc = marc2ris(MARC::Record->new_from_usmarc($marc));
}
elsif ($format =~ /bibtex/) {
$marc = marc2bibtex(C4::Biblio::GetMarcBiblio($biblionumber),$biblionumber);
}elsif ($format =~ /dc/) {
my $error;
($error,$marc) = marc2dcxml($marc,1);
$format = "dublin-core.xml";
}
elsif ($format =~ /marc8/) {
$marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
$marc = $marc->as_usmarc();
}
elsif ($format =~ /utf8/) {
#default
}
print $query->header(
-type => 'application/octet-stream',
-attachment=>"bib-$biblionumber.$format");
print $marc;
}
}
}