remove superfluous retrieval of $ENV{'REMOTE_USER'}
[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.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 with
24 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
25 # Suite 330, Boston, MA  02111-1307 USA
26
27 use strict;
28
29 # standard or CPAN modules used
30 use CGI qw(:standard);
31 use DBI;
32
33 # Koha modules used
34 use C4::Context;
35 use C4::Output;
36 use C4::Auth;
37 use C4::Biblio;
38 use C4::ImportBatch;
39 use XML::LibXSLT;
40 use XML::LibXML;
41
42 my $input       = new CGI;
43 my $biblionumber = $input->param('id');
44 my $importid            =       $input->param('importid');
45 my $view                = $input->param('viewas');
46
47 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
48     {
49         template_name   => "catalogue/showmarc.tmpl",
50         query           => $input,
51         type            => "intranet",
52         authnotrequired => 0,
53         flagsrequired   => { catalogue => 1  },
54         debug           => 1,
55     }
56 );
57
58 $template->param( SCRIPT_NAME => $ENV{'SCRIPT_NAME'}, );
59 my ($record, $xmlrecord);
60 if($importid) {
61         my ($marc,$encoding) = GetImportRecordMarc($importid);
62                 $record = MARC::Record->new_from_usmarc($marc) ;
63         if($view eq 'card') {
64                 $xmlrecord = $record->as_xml();
65         } 
66 }
67                 
68 if($view eq 'card') {
69 $xmlrecord = GetXmlBiblio($biblionumber) unless $xmlrecord;
70
71 my $xslfile = C4::Context->config('intrahtdocs')."/prog/en/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 #warn $newxmlrecord;
80 print "Content-type: text/html\n\n";
81 print $newxmlrecord;
82
83 } else {
84
85 $record =GetMarcBiblio($biblionumber) unless $record; 
86
87 my $formatted = $record->as_formatted;
88 $template->param( MARC_FORMATTED => $formatted );
89
90 output_html_with_http_headers $input, $cookie, $template->output;
91 }