3 # Copyright 2007 Liblime
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 # standard or CPAN modules used
34 use Koha::RecordProcessor;
37 my $biblionumber = $input->param('id');
38 $biblionumber = int($biblionumber);
39 my $importid= $input->param('importid');
40 my $view= $input->param('viewas') || 'marc';
42 my $record_unfiltered;
44 my ($marc) = GetImportRecordMarc($importid);
45 $record_unfiltered = MARC::Record->new_from_usmarc($marc);
48 $record_unfiltered = GetMarcBiblio($biblionumber);
50 if(!ref $record_unfiltered) {
51 print $input->redirect("/cgi-bin/koha/errors/404.pl");
55 my $record_processor = Koha::RecordProcessor->new({ filters => 'ViewPolicy' });
56 my $record_filtered = $record_unfiltered->clone();
57 my $record = $record_processor->process($record_filtered);
59 if ($view eq 'card' || $view eq 'html') {
60 # FIXME: GetXmlBiblio needs filtering later.
61 my $xml = $importid ? $record->as_xml(): GetXmlBiblio($biblionumber);
62 if (!$importid && $view eq 'html') {
63 my $unfiltered_record = MARC::Record->new_from_xml($xml);
64 my $frameworkcode = GetFrameworkCode($biblionumber);
65 $record_processor->options({ frameworkcode => $frameworkcode});
66 my $filtered_record = $record_processor->process($unfiltered_record);
67 $xml = $filtered_record->as_xml();
69 my $xsl = $view eq 'card' ? 'compact.xsl' : 'plainMARC.xsl';
70 my $htdocs = C4::Context->config('opachtdocs');
71 my ($theme, $lang) = C4::Templates::themelanguage($htdocs, $xsl, 'opac', $input);
72 $xsl = "$htdocs/$theme/$lang/xslt/$xsl";
73 print $input->header(-charset => 'UTF-8'),
74 Encode::encode_utf8(C4::XSLT::engine->transform($xml, $xsl));
77 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
78 template_name => "opac-showmarc.tt",
81 authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
84 $template->param( MARC_FORMATTED => $record->as_formatted );
85 output_html_with_http_headers $input, $cookie, $template->output;