Bug 10500: (follow-up) adjust for name of UNIMARC ISBN indexes
[koha.git] / catalogue / showmarc.pl
blob9cc039d826261376e4f7330e9486926d5bcb591f
1 #!/usr/bin/perl
3 # Koha library project www.koha-community.org
5 # Copyright 2007 Liblime
6 # Parts copyright 2010 BibLibre
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 use strict;
24 use warnings;
26 # standard or CPAN modules used
27 use CGI qw(:standard);
28 use DBI;
29 use Encode;
31 # Koha modules used
32 use C4::Context;
33 use C4::Output;
34 use C4::Auth;
35 use C4::Biblio;
36 use C4::ImportBatch;
37 use XML::LibXSLT;
38 use XML::LibXML;
40 my $input= new CGI;
41 my $biblionumber= $input->param('id');
42 my $importid= $input->param('importid');
43 my $view= $input->param('viewas')||'';
45 my $record;
46 if ($importid) {
47 my ($marc) = GetImportRecordMarc($importid);
48 $record = MARC::Record->new_from_usmarc($marc);
50 else {
51 $record =GetMarcBiblio($biblionumber);
53 if(!ref $record) {
54 print $input->redirect("/cgi-bin/koha/errors/404.pl");
55 exit;
58 if($view eq 'card') {
59 my $themelang = '/' . C4::Templates::_current_language();
60 my $xmlrecord= $importid? $record->as_xml(): GetXmlBiblio($biblionumber);
61 my $xslfile =
62 C4::Context->config('intrahtdocs') . '/prog' . $themelang . "/xslt/compact.xsl";
63 if ( ! -f $xslfile && $themelang ne '/en' ) {
64 $xslfile=~s#$themelang#/en#;
66 my $parser = XML::LibXML->new();
67 my $xslt = XML::LibXSLT->new();
68 my $source = $parser->parse_string($xmlrecord);
69 my $style_doc = $parser->parse_file($xslfile);
70 my $stylesheet = $xslt->parse_stylesheet($style_doc);
71 my $results = $stylesheet->transform($source);
72 my $newxmlrecord = $stylesheet->output_string($results);
73 print $input->header(-charset => 'UTF-8'), Encode::encode_utf8($newxmlrecord);
75 else {
76 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
78 template_name => "catalogue/showmarc.tmpl",
79 query => $input,
80 type => "intranet",
81 authnotrequired => 0,
82 flagsrequired => { catalogue => 1 },
83 debug => 1,
86 $template->param( MARC_FORMATTED => $record->as_formatted );
87 output_html_with_http_headers $input, $cookie, $template->output;