Validation of opac results and detail pages, normalization
[koha.git] / catalogue / showmarc.pl
blobcf1ee3c18154eea860b058e49fe723673a4a7a0d
1 #!/usr/bin/perl
3 # $Id: showmarc.pl,v 1.1.2.1 2007/06/18 21:57:23 rangi Exp $
6 # Koha library project www.koha.org
8 # Licensed under the GPL
10 # Copyright 2007 Liblime
12 # This file is part of Koha.
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.
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.
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
27 use strict;
29 # standard or CPAN modules used
30 use CGI qw(:standard);
31 use DBI;
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;
42 my $userid = $ENV{'REMOTE_USER'};
44 my $input = new CGI;
45 my $biblionumber = $input->param('id');
46 my $importid = $input->param('importid');
47 my $view = $input->param('viewas');
49 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
51 template_name => "catalogue/showmarc.tmpl",
52 query => $input,
53 type => "intranet",
54 authnotrequired => 0,
55 flagsrequired => { acquisition => 1 },
56 debug => 1,
60 $template->param( SCRIPT_NAME => $ENV{'SCRIPT_NAME'}, );
61 my ($record, $xmlrecord);
62 if($importid) {
63 my ($marc,$encoding) = GetImportRecordMarc($importid);
64 $record = MARC::Record->new_from_usmarc($marc) ;
65 if($view eq 'card') {
66 $xmlrecord = $record->as_xml();
70 if($view eq 'card') {
71 $xmlrecord = GetXmlBiblio($biblionumber) unless $xmlrecord;
73 my $xslfile = C4::Context->config('intrahtdocs')."/prog/en/xslt/compact.xsl";
74 my $parser = XML::LibXML->new();
75 my $xslt = XML::LibXSLT->new();
76 my $source = $parser->parse_string($xmlrecord);
77 my $style_doc = $parser->parse_file($xslfile);
78 my $stylesheet = $xslt->parse_stylesheet($style_doc);
79 my $results = $stylesheet->transform($source);
80 my $newxmlrecord = $stylesheet->output_string($results);
81 #warn $newxmlrecord;
82 print "Content-type: text/html\n\n";
83 print $newxmlrecord;
85 } else {
87 $record =GetMarcBiblio($biblionumber) unless $record;
89 my $formatted = $record->as_formatted;
90 $template->param( MARC_FORMATTED => $formatted );
92 output_html_with_http_headers $input, $cookie, $template->output;