bugfix: reenable listing suggestions by anyone
[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 $userid = $ENV{'REMOTE_USER'};
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         template_name   => "opac-showmarc.tmpl",
50         query           => $input,
51         type            => "opac",
52         authnotrequired => 1,
53         debug           => 1,
54 });
55
56 $template->param( SCRIPT_NAME => $ENV{'SCRIPT_NAME'}, );
57 my ($record, $xmlrecord);
58 if ($importid) {
59         my ($marc,$encoding) = GetImportRecordMarc($importid);
60         $record = MARC::Record->new_from_usmarc($marc) ;
61         if($view eq 'card') {
62                 $xmlrecord = $record->as_xml();
63         } 
64 }
65                 
66 if ($view eq 'card') {
67 $xmlrecord = GetXmlBiblio($biblionumber) unless $xmlrecord;
68 my $xslfile = C4::Context->config('intranetdir')."/koha-tmpl/intranet-tmpl/prog/en/xslt/compact.xsl";
69 my $parser = XML::LibXML->new();
70 my $xslt   = XML::LibXSLT->new();
71 my $source = $parser->parse_string($xmlrecord);
72 my $style_doc = $parser->parse_file($xslfile);
73 my $stylesheet = $xslt->parse_stylesheet($style_doc);
74 my $results = $stylesheet->transform($source);
75 my $newxmlrecord = $stylesheet->output_string($results);
76 #warn $newxmlrecord;
77 print $input->header(), $newxmlrecord;
78     exit;
79 } else {
80     $record =GetMarcBiblio($biblionumber) unless $record; 
81     $template->param( MARC_FORMATTED => $record->as_formatted );
82     output_html_with_http_headers $input, $cookie, $template->output;
83 }