remove superfluous retrieval of $ENV{'REMOTE_USER'}
[koha.git] / opac / opac-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;
31
32 # Koha modules used
33 use C4::Context;
34 use C4::Output;
35 use C4::Auth;
36 use C4::Biblio;
37 use C4::ImportBatch;
38 use XML::LibXSLT;
39 use XML::LibXML;
40
41 my $input       = new CGI;
42 my $biblionumber = $input->param('id');
43 my $importid    = $input->param('importid');
44 my $view                = $input->param('viewas');
45
46 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
47         template_name   => "opac-showmarc.tmpl",
48         query           => $input,
49         type            => "opac",
50         authnotrequired => 1,
51         debug           => 1,
52 });
53
54 $template->param( SCRIPT_NAME => $ENV{'SCRIPT_NAME'}, );
55 my ($record, $xmlrecord);
56 if ($importid) {
57         my ($marc,$encoding) = GetImportRecordMarc($importid);
58         $record = MARC::Record->new_from_usmarc($marc) ;
59         if($view eq 'card') {
60                 $xmlrecord = $record->as_xml();
61         } 
62 }
63                 
64 if ($view eq 'card') {
65 $xmlrecord = GetXmlBiblio($biblionumber) unless $xmlrecord;
66 my $xslfile = C4::Context->config('intranetdir')."/koha-tmpl/intranet-tmpl/prog/en/xslt/compact.xsl";
67 my $parser = XML::LibXML->new();
68 my $xslt   = XML::LibXSLT->new();
69 my $source = $parser->parse_string($xmlrecord);
70 my $style_doc = $parser->parse_file($xslfile);
71 my $stylesheet = $xslt->parse_stylesheet($style_doc);
72 my $results = $stylesheet->transform($source);
73 my $newxmlrecord = $stylesheet->output_string($results);
74 #warn $newxmlrecord;
75 print $input->header(), $newxmlrecord;
76     exit;
77 } else {
78     $record =GetMarcBiblio($biblionumber) unless $record; 
79     $template->param( MARC_FORMATTED => $record->as_formatted );
80     output_html_with_http_headers $input, $cookie, $template->output;
81 }