Bug 26330: Change encoding of text used as tab triggers in MARC subfield constraints
[koha.git] / catalogue / showmarc.pl
blobd21683ee72f37ea1e554564ed52a30b722993acf
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
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use Modern::Perl;
25 # standard or CPAN modules used
26 use CGI qw(:standard -utf8);
27 use DBI;
28 use Encode;
30 # Koha modules used
31 use C4::Context;
32 use C4::Output;
33 use C4::Auth;
34 use C4::Biblio;
35 use C4::ImportBatch;
36 use C4::XSLT ();
38 my $input= new CGI;
39 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
41 template_name => "catalogue/showmarc.tt",
42 query => $input,
43 type => "intranet",
44 flagsrequired => { catalogue => 1 },
45 debug => 1,
49 my $biblionumber= $input->param('id');
50 my $importid= $input->param('importid');
51 my $view= $input->param('viewas')||'';
53 my $record;
54 if ($importid) {
55 $record = C4::ImportBatch::GetRecordFromImportBiblio( $importid, 'embed_items' );
57 else {
58 $record =GetMarcBiblio({ biblionumber => $biblionumber });
60 if(!ref $record) {
61 print $input->redirect("/cgi-bin/koha/errors/404.pl");
62 exit;
65 if($view eq 'card' || $view eq 'html') {
66 my $xml = $importid ? $record->as_xml(): GetXmlBiblio($biblionumber);
67 my $xsl;
68 if ( $view eq 'card' ){
69 $xsl = C4::Context->preference('marcflavour') eq 'UNIMARC'
70 ? 'UNIMARC_compact.xsl' : 'compact.xsl';
72 else {
73 $xsl = 'plainMARC.xsl';
75 my $htdocs = C4::Context->config('intrahtdocs');
76 my ($theme, $lang) = C4::Templates::themelanguage($htdocs, $xsl, 'intranet', $input);
77 $xsl = "$htdocs/$theme/$lang/xslt/$xsl";
78 print $input->header(-charset => 'UTF-8'),
79 Encode::encode_utf8(C4::XSLT::engine->transform($xml, $xsl));
81 else {
82 $template->param( MARC_FORMATTED => $record->as_formatted );
83 output_html_with_http_headers $input, $cookie, $template->output;