|
Lines 3-8
package C4::XSLT;
Link Here
|
| 3 |
# <jmf at liblime dot com> |
3 |
# <jmf at liblime dot com> |
| 4 |
# Parts Copyright Katrin Fischer 2011 |
4 |
# Parts Copyright Katrin Fischer 2011 |
| 5 |
# Parts Copyright ByWater Solutions 2011 |
5 |
# Parts Copyright ByWater Solutions 2011 |
|
|
6 |
# Parts Copyright Biblibre 2012 |
| 6 |
# |
7 |
# |
| 7 |
# This file is part of Koha. |
8 |
# This file is part of Koha. |
| 8 |
# |
9 |
# |
|
Lines 32-37
use C4::Reserves;
Link Here
|
| 32 |
use Encode; |
33 |
use Encode; |
| 33 |
use XML::LibXML; |
34 |
use XML::LibXML; |
| 34 |
use XML::LibXSLT; |
35 |
use XML::LibXSLT; |
|
|
36 |
use LWP::Simple; |
| 35 |
|
37 |
|
| 36 |
use vars qw($VERSION @ISA @EXPORT); |
38 |
use vars qw($VERSION @ISA @EXPORT); |
| 37 |
|
39 |
|
|
Lines 41-46
BEGIN {
Link Here
|
| 41 |
@ISA = qw(Exporter); |
43 |
@ISA = qw(Exporter); |
| 42 |
@EXPORT = qw( |
44 |
@EXPORT = qw( |
| 43 |
&XSLTParse4Display |
45 |
&XSLTParse4Display |
|
|
46 |
&GetURI |
| 44 |
); |
47 |
); |
| 45 |
} |
48 |
} |
| 46 |
|
49 |
|
|
Lines 50-55
C4::XSLT - Functions for displaying XSLT-generated content
Link Here
|
| 50 |
|
53 |
|
| 51 |
=head1 FUNCTIONS |
54 |
=head1 FUNCTIONS |
| 52 |
|
55 |
|
|
|
56 |
=head2 GetURI |
| 57 |
|
| 58 |
GetURI file and returns the xslt as a string |
| 59 |
|
| 60 |
=cut |
| 61 |
|
| 62 |
sub GetURI { |
| 63 |
my ($uri) = @_; |
| 64 |
my $string; |
| 65 |
$string = get $uri ; |
| 66 |
return $string; |
| 67 |
} |
| 68 |
|
| 53 |
=head2 transformMARCXML4XSLT |
69 |
=head2 transformMARCXML4XSLT |
| 54 |
|
70 |
|
| 55 |
Replaces codes with authorized values in a MARC::Record object |
71 |
Replaces codes with authorized values in a MARC::Record object |
|
Lines 121-128
sub getAuthorisedValues4MARCSubfields {
Link Here
|
| 121 |
my $stylesheet; |
137 |
my $stylesheet; |
| 122 |
|
138 |
|
| 123 |
sub XSLTParse4Display { |
139 |
sub XSLTParse4Display { |
| 124 |
my ( $biblionumber, $orig_record, $xsl_suffix, $interface, $fixamps, $hidden_items ) = @_; |
140 |
my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_; |
| 125 |
$interface = 'opac' unless $interface; |
141 |
my $xslfilename = C4::Context->preference($xslsyspref); |
|
|
142 |
if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { |
| 143 |
if ($xslsyspref eq "XSLTDetailsDisplay") { |
| 144 |
$xslfilename = C4::Context->config('intrahtdocs') . |
| 145 |
'/' . C4::Context->preference("template") . |
| 146 |
'/' . C4::Templates::_current_language() . |
| 147 |
'/xslt/' . |
| 148 |
C4::Context->preference('marcflavour') . |
| 149 |
"slim2intranetDetail.xsl"; |
| 150 |
} elsif ($xslsyspref eq "XSLTResultsDisplay") { |
| 151 |
$xslfilename = C4::Context->config('intrahtdocs') . |
| 152 |
'/' . C4::Context->preference("template") . |
| 153 |
'/' . C4::Templates::_current_language() . |
| 154 |
'/xslt/' . |
| 155 |
C4::Context->preference('marcflavour') . |
| 156 |
"slim2intranetResults.xsl"; |
| 157 |
} elsif ($xslsyspref eq "OPACXSLTDetailsDisplay") { |
| 158 |
$xslfilename = C4::Context->config('opachtdocs') . |
| 159 |
'/' . C4::Context->preference("opacthemes") . |
| 160 |
'/' . C4::Templates::_current_language() . |
| 161 |
'/xslt/' . |
| 162 |
C4::Context->preference('marcflavour') . |
| 163 |
"slim2OPACDetail.xsl"; |
| 164 |
} elsif ($xslsyspref eq "OPACXSLTResultsDisplay") { |
| 165 |
$xslfilename = C4::Context->config('opachtdocs') . |
| 166 |
'/' . C4::Context->preference("opacthemes") . |
| 167 |
'/' . C4::Templates::_current_language() . |
| 168 |
'/xslt/' . |
| 169 |
C4::Context->preference('marcflavour') . |
| 170 |
"slim2OPACResults.xsl"; |
| 171 |
} |
| 172 |
} |
| 126 |
# grab the XML, run it through our stylesheet, push it out to the browser |
173 |
# grab the XML, run it through our stylesheet, push it out to the browser |
| 127 |
my $record = transformMARCXML4XSLT($biblionumber, $orig_record); |
174 |
my $record = transformMARCXML4XSLT($biblionumber, $orig_record); |
| 128 |
#return $record->as_formatted(); |
175 |
#return $record->as_formatted(); |
|
Lines 153-181
sub XSLTParse4Display {
Link Here
|
| 153 |
# don't die when you find &, >, etc |
200 |
# don't die when you find &, >, etc |
| 154 |
$parser->recover_silently(0); |
201 |
$parser->recover_silently(0); |
| 155 |
my $source = $parser->parse_string($xmlrecord); |
202 |
my $source = $parser->parse_string($xmlrecord); |
| 156 |
unless ( $stylesheet ) { |
203 |
unless ( $stylesheet->{$xslfilename} ) { |
| 157 |
my $xslt = XML::LibXSLT->new(); |
204 |
my $xslt = XML::LibXSLT->new(); |
| 158 |
my $xslfile; |
205 |
my $style_doc; |
| 159 |
if ($interface eq 'intranet') { |
206 |
if ( $xslfilename =~ /^https?:\/\// ) { |
| 160 |
$xslfile = C4::Context->config('intrahtdocs') . |
207 |
my $xsltstring = GetURI($xslfilename); |
| 161 |
'/' . C4::Context->preference("template") . |
208 |
$style_doc = $parser->parse_string($xsltstring); |
| 162 |
'/' . C4::Templates::_current_language() . |
|
|
| 163 |
'/xslt/' . |
| 164 |
C4::Context->preference('marcflavour') . |
| 165 |
"slim2intranet$xsl_suffix.xsl"; |
| 166 |
} else { |
209 |
} else { |
| 167 |
$xslfile = C4::Context->config('opachtdocs') . |
210 |
use Cwd; |
| 168 |
'/' . C4::Context->preference("opacthemes") . |
211 |
$style_doc = $parser->parse_file($xslfilename); |
| 169 |
'/' . C4::Templates::_current_language() . |
|
|
| 170 |
'/xslt/' . |
| 171 |
C4::Context->preference('marcflavour') . |
| 172 |
"slim2OPAC$xsl_suffix.xsl"; |
| 173 |
} |
212 |
} |
| 174 |
my $style_doc = $parser->parse_file($xslfile); |
213 |
$stylesheet->{$xslfilename} = $xslt->parse_stylesheet($style_doc); |
| 175 |
$stylesheet = $xslt->parse_stylesheet($style_doc); |
|
|
| 176 |
} |
214 |
} |
| 177 |
my $results = $stylesheet->transform($source); |
215 |
my $results = $stylesheet->{$xslfilename}->transform($source); |
| 178 |
my $newxmlrecord = $stylesheet->output_string($results); |
216 |
my $newxmlrecord = $stylesheet->{$xslfilename}->output_string($results); |
| 179 |
return $newxmlrecord; |
217 |
return $newxmlrecord; |
| 180 |
} |
218 |
} |
| 181 |
|
219 |
|