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
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.
24 #use warnings; FIXME - Bug 2505
26 use open OUT=>":encoding(UTF-8)", ':std';
27 # standard or CPAN modules used
28 use CGI qw(:standard);
42 my $biblionumber = $input->param('id');
43 my $importid = $input->param('importid');
44 my $view = $input->param('viewas');
46 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
48 template_name => "catalogue/showmarc.tmpl",
52 flagsrequired => { catalogue => 1 },
57 $template->param( SCRIPT_NAME => $ENV{'SCRIPT_NAME'}, );
58 my ($record, $xmlrecord);
60 my ($marc,$encoding) = GetImportRecordMarc($importid);
61 $record = MARC::Record->new_from_usmarc($marc) ;
63 $xmlrecord = $record->as_xml();
68 my $themelang = '/' . C4::Context->preference("opacthemes") . '/' . C4::Templates::_current_language();
69 $xmlrecord = GetXmlBiblio($biblionumber) unless $xmlrecord;
71 C4::Context->config('intrahtdocs') . $themelang . "/xslt/compact.xsl";
72 my $parser = XML::LibXML->new();
73 my $xslt = XML::LibXSLT->new();
74 my $source = $parser->parse_string($xmlrecord);
75 my $style_doc = $parser->parse_file($xslfile);
76 my $stylesheet = $xslt->parse_stylesheet($style_doc);
77 my $results = $stylesheet->transform($source);
78 my $newxmlrecord = $stylesheet->output_string($results);
79 $newxmlrecord = Encode::decode_utf8($newxmlrecord)
80 unless utf8::is_utf8($newxmlrecord)
81 ; #decode only if not in perl internal format
82 print $input->header( -charset => 'UTF-8' ), $newxmlrecord;
85 $record =GetMarcBiblio($biblionumber) unless $record;
87 my $formatted = $record->as_formatted;
88 $template->param( MARC_FORMATTED => $formatted );
90 my $output= $template->output;
91 $output=Encode::decode_utf8($output) unless utf8::is_utf8($output);
92 output_html_with_http_headers $input, $cookie, $output;