Lines 18-24
Link Here
|
18 |
# Suite 330, Boston, MA 02111-1307 USA |
18 |
# Suite 330, Boston, MA 02111-1307 USA |
19 |
# |
19 |
# |
20 |
|
20 |
|
21 |
|
|
|
22 |
use strict; |
21 |
use strict; |
23 |
use warnings; |
22 |
use warnings; |
24 |
|
23 |
|
Lines 31-89
use C4::Auth;
Link Here
|
31 |
use C4::Ris; |
30 |
use C4::Ris; |
32 |
|
31 |
|
33 |
my $query = new CGI; |
32 |
my $query = new CGI; |
34 |
my $op=$query->param("op"); |
33 |
my $op=$query->param("op")||''; #op=export is currently the only use |
35 |
my $format=$query->param("format"); |
34 |
my $format=$query->param("format")||'utf8'; |
36 |
if ($op eq "export") { |
35 |
my $biblionumber = $query->param("bib")||0; |
37 |
my $biblionumber = $query->param("bib"); |
36 |
my ($marc, $error)= ('',''); |
38 |
my $error; |
|
|
39 |
|
40 |
if ($biblionumber){ |
41 |
|
37 |
|
42 |
my $marc = GetMarcBiblio($biblionumber, 1); |
38 |
$marc = GetMarcBiblio($biblionumber, 1) if $biblionumber; |
43 |
|
39 |
if(!$marc) { |
44 |
if ($format =~ /endnote/) { |
40 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); |
45 |
$marc = marc2endnote($marc); |
41 |
exit; |
46 |
$format = 'endnote'; |
42 |
} |
47 |
} |
43 |
elsif ($format =~ /endnote/) { |
48 |
elsif ($format =~ /marcxml/) { |
44 |
$marc = marc2endnote($marc); |
49 |
$marc = marc2marcxml($marc); |
45 |
} |
50 |
} |
46 |
elsif ($format =~ /marcxml/) { |
51 |
elsif ($format=~ /mods/) { |
47 |
$marc = marc2marcxml($marc); |
52 |
$marc = marc2modsxml($marc); |
48 |
} |
53 |
} |
49 |
elsif ($format=~ /mods/) { |
54 |
elsif ($format =~ /ris/) { |
50 |
$marc = marc2modsxml($marc); |
55 |
$marc = marc2ris(MARC::Record->new_from_usmarc($marc)); |
51 |
} |
56 |
} |
52 |
elsif ($format =~ /ris/) { |
57 |
elsif ($format =~ /bibtex/) { |
53 |
$marc = marc2ris(MARC::Record->new_from_usmarc($marc)); |
58 |
$marc = marc2bibtex(C4::Biblio::GetMarcBiblio($biblionumber),$biblionumber); |
54 |
} |
59 |
} |
55 |
elsif ($format =~ /bibtex/) { |
60 |
elsif ($format =~ /dc/) { |
56 |
$marc = marc2bibtex(C4::Biblio::GetMarcBiblio($biblionumber),$biblionumber); |
61 |
($error,$marc) = marc2dcxml($marc,1); |
57 |
} |
62 |
$format = "dublin-core.xml"; |
58 |
elsif ($format =~ /dc/) { |
63 |
} |
59 |
($error,$marc) = marc2dcxml($marc,1); |
64 |
elsif ($format =~ /marc8/) { |
60 |
$format = "dublin-core.xml"; |
65 |
($error,$marc) = changeEncoding($marc,"MARC","MARC21","MARC-8"); |
61 |
} |
66 |
if (! $error){ |
62 |
elsif ($format =~ /marc8/) { |
67 |
$marc = $marc->as_usmarc(); |
63 |
($error,$marc) = changeEncoding($marc,"MARC","MARC21","MARC-8"); |
68 |
} |
64 |
$marc = $marc->as_usmarc() unless $error; |
69 |
} |
65 |
} |
70 |
elsif ($format =~ /utf8/) { |
66 |
elsif ($format =~ /utf8/) { |
71 |
C4::Charset::SetUTF8Flag($marc,1); |
67 |
C4::Charset::SetUTF8Flag($marc,1); |
72 |
$marc = $marc->as_usmarc(); |
68 |
$marc = $marc->as_usmarc(); |
73 |
} |
69 |
} |
|
|
70 |
else { |
71 |
$error= "Format $format is not supported."; |
72 |
} |
74 |
|
73 |
|
75 |
if ($error){ |
74 |
if ($error){ |
76 |
print $query->header(); |
75 |
print $query->header(); |
77 |
print $query->start_html(); |
76 |
print $query->start_html(); |
78 |
print "<h1>An error occured </h1>"; |
77 |
print "<h1>An error occurred </h1>"; |
79 |
print $error; |
78 |
print $error; |
80 |
print $query->end_html(); |
79 |
print $query->end_html(); |
81 |
} |
80 |
} |
82 |
else { |
81 |
else { |
83 |
print $query->header( |
82 |
print $query->header( |
84 |
-type => 'application/octet-stream', |
83 |
-type => 'application/octet-stream', |
85 |
-attachment=>"bib-$biblionumber.$format"); |
84 |
-attachment=>"bib-$biblionumber.$format"); |
86 |
print $marc; |
85 |
print $marc; |
87 |
} |
|
|
88 |
} |
89 |
} |
86 |
} |
90 |
- |
|
|