Bug 4263: Remove duplicated lines from C4::Items
[koha.git] / catalogue / showmarc.pl
1 #!/usr/bin/perl
2
3 # $Id: showmarc.pl,v 1.1.2.1 2007/06/18 21:57:23 rangi Exp $
4
5
6 # Koha library project  www.koha-community.org
7
8 # Licensed under the GPL
9
10 # Copyright 2007 Liblime
11 #
12 # This file is part of Koha.
13 #
14 # Koha is free software; you can redistribute it and/or modify it under the
15 # terms of the GNU General Public License as published by the Free Software
16 # Foundation; either version 2 of the License, or (at your option) any later
17 # version.
18 #
19 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
20 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
21 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License along
24 # with Koha; if not, write to the Free Software Foundation, Inc.,
25 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26
27 use strict;
28 #use warnings; FIXME - Bug 2505
29
30 # standard or CPAN modules used
31 use CGI qw(:standard);
32 use DBI;
33
34 # Koha modules used
35 use C4::Context;
36 use C4::Output;
37 use C4::Auth;
38 use C4::Biblio;
39 use C4::ImportBatch;
40 use XML::LibXSLT;
41 use XML::LibXML;
42
43 my $input       = new CGI;
44 my $biblionumber = $input->param('id');
45 my $importid            =       $input->param('importid');
46 my $view                = $input->param('viewas');
47
48 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
49     {
50         template_name   => "catalogue/showmarc.tmpl",
51         query           => $input,
52         type            => "intranet",
53         authnotrequired => 0,
54         flagsrequired   => { catalogue => 1  },
55         debug           => 1,
56     }
57 );
58
59 $template->param( SCRIPT_NAME => $ENV{'SCRIPT_NAME'}, );
60 my ($record, $xmlrecord);
61 if($importid) {
62         my ($marc,$encoding) = GetImportRecordMarc($importid);
63                 $record = MARC::Record->new_from_usmarc($marc) ;
64         if($view eq 'card') {
65                 $xmlrecord = $record->as_xml();
66         } 
67 }
68                 
69 if($view eq 'card') {
70 $xmlrecord = GetXmlBiblio($biblionumber) unless $xmlrecord;
71
72 my $xslfile = C4::Context->config('intrahtdocs')."/prog/en/xslt/compact.xsl";
73 my $parser = XML::LibXML->new();
74 my $xslt = XML::LibXSLT->new();
75 my $source = $parser->parse_string($xmlrecord);
76 my $style_doc = $parser->parse_file($xslfile);
77 my $stylesheet = $xslt->parse_stylesheet($style_doc);
78 my $results = $stylesheet->transform($source);
79 my $newxmlrecord = $stylesheet->output_string($results);
80 #warn $newxmlrecord;
81 print "Content-type: text/html\n\n";
82 utf8::encode($newxmlrecord);
83 print $newxmlrecord;
84
85 } else {
86
87 $record =GetMarcBiblio($biblionumber) unless $record; 
88
89 my $formatted = $record->as_formatted;
90 $template->param( MARC_FORMATTED => $formatted );
91
92 output_html_with_http_headers $input, $cookie, $template->output;
93 }