Lines 21-29
Link Here
|
21 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
21 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
22 |
|
22 |
|
23 |
use strict; |
23 |
use strict; |
24 |
#use warnings; FIXME - Bug 2505 |
24 |
use warnings; |
25 |
|
|
|
26 |
use open OUT=>":encoding(UTF-8)", ':std'; |
27 |
|
25 |
|
28 |
# standard or CPAN modules used |
26 |
# standard or CPAN modules used |
29 |
use CGI qw(:standard); |
27 |
use CGI qw(:standard); |
Lines 39-73
use C4::ImportBatch;
Link Here
|
39 |
use XML::LibXSLT; |
37 |
use XML::LibXSLT; |
40 |
use XML::LibXML; |
38 |
use XML::LibXML; |
41 |
|
39 |
|
42 |
my $input = new CGI; |
40 |
my $input= new CGI; |
43 |
my $biblionumber = $input->param('id'); |
41 |
my $biblionumber= $input->param('id'); |
44 |
my $importid = $input->param('importid'); |
42 |
my $importid= $input->param('importid'); |
45 |
my $view = $input->param('viewas'); |
43 |
my $view= $input->param('viewas')||''; |
46 |
|
44 |
|
47 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
45 |
my $record; |
48 |
{ |
46 |
if ($importid) { |
49 |
template_name => "catalogue/showmarc.tmpl", |
47 |
my ($marc) = GetImportRecordMarc($importid); |
50 |
query => $input, |
48 |
$record = MARC::Record->new_from_usmarc($marc); |
51 |
type => "intranet", |
49 |
} |
52 |
authnotrequired => 0, |
50 |
else { |
53 |
flagsrequired => { catalogue => 1 }, |
51 |
$record =GetMarcBiblio($biblionumber); |
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 |
} |
52 |
} |
67 |
|
53 |
|
68 |
if($view eq 'card') { |
54 |
if($view eq 'card') { |
69 |
my $themelang = '/' . C4::Context->preference("opacthemes") . '/' . C4::Templates::_current_language(); |
55 |
my $themelang = '/' . C4::Context->preference("opacthemes") . '/' . C4::Templates::_current_language(); |
70 |
$xmlrecord = GetXmlBiblio($biblionumber) unless $xmlrecord; |
56 |
my $xmlrecord= $importid? $record->as_xml(): GetXmlBiblio($biblionumber); |
71 |
my $xslfile = |
57 |
my $xslfile = |
72 |
C4::Context->config('intrahtdocs') . $themelang . "/xslt/compact.xsl"; |
58 |
C4::Context->config('intrahtdocs') . $themelang . "/xslt/compact.xsl"; |
73 |
my $parser = XML::LibXML->new(); |
59 |
my $parser = XML::LibXML->new(); |
Lines 77-94
if($view eq 'card') {
Link Here
|
77 |
my $stylesheet = $xslt->parse_stylesheet($style_doc); |
63 |
my $stylesheet = $xslt->parse_stylesheet($style_doc); |
78 |
my $results = $stylesheet->transform($source); |
64 |
my $results = $stylesheet->transform($source); |
79 |
my $newxmlrecord = $stylesheet->output_string($results); |
65 |
my $newxmlrecord = $stylesheet->output_string($results); |
80 |
$newxmlrecord = Encode::decode_utf8($newxmlrecord) |
66 |
print $input->header(-charset => 'UTF-8'), Encode::encode_utf8($newxmlrecord); |
81 |
unless utf8::is_utf8($newxmlrecord) |
|
|
82 |
; #decode only if not in perl internal format |
83 |
print $input->header( -charset => 'UTF-8' ), $newxmlrecord; |
84 |
} |
67 |
} |
85 |
else { |
68 |
else { |
86 |
$record =GetMarcBiblio($biblionumber) unless $record; |
69 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
87 |
|
70 |
{ |
88 |
my $formatted = $record->as_formatted; |
71 |
template_name => "catalogue/showmarc.tmpl", |
89 |
$template->param( MARC_FORMATTED => $formatted ); |
72 |
query => $input, |
90 |
|
73 |
type => "intranet", |
91 |
my $output= $template->output; |
74 |
authnotrequired => 0, |
92 |
$output=Encode::decode_utf8($output) unless utf8::is_utf8($output); |
75 |
flagsrequired => { catalogue => 1 }, |
93 |
output_html_with_http_headers $input, $cookie, $output; |
76 |
debug => 1, |
|
|
77 |
} |
78 |
); |
79 |
$template->param( MARC_FORMATTED => $record->as_formatted ); |
80 |
output_html_with_http_headers $input, $cookie, $template->output; |
94 |
} |
81 |
} |