Lines 46-51
BEGIN {
Link Here
|
46 |
@ISA = qw(Exporter); |
46 |
@ISA = qw(Exporter); |
47 |
@EXPORT = qw( |
47 |
@EXPORT = qw( |
48 |
&XSLTParse4Display |
48 |
&XSLTParse4Display |
|
|
49 |
&CustomXSLTExportList |
49 |
); |
50 |
); |
50 |
$engine=Koha::XSLT_Handler->new( { do_not_return_source => 1 } ); |
51 |
$engine=Koha::XSLT_Handler->new( { do_not_return_source => 1 } ); |
51 |
} |
52 |
} |
Lines 186-198
sub get_xslt_sysprefs {
Link Here
|
186 |
} |
187 |
} |
187 |
|
188 |
|
188 |
sub XSLTParse4Display { |
189 |
sub XSLTParse4Display { |
189 |
my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang ) = @_; |
190 |
my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $xslFile, $opac ) = @_; |
190 |
|
191 |
|
191 |
$sysxml ||= C4::Context->preference($xslsyspref); |
192 |
$sysxml ||= C4::Context->preference($xslsyspref); |
192 |
$xslfilename ||= C4::Context->preference($xslsyspref); |
193 |
$xslfilename ||= C4::Context->preference($xslsyspref); |
193 |
$lang ||= C4::Languages::getlanguage(); |
194 |
$lang ||= C4::Languages::getlanguage(); |
194 |
|
195 |
|
195 |
if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { |
196 |
if ($xslFile) { |
|
|
197 |
my $myDir; |
198 |
if ($opac) { |
199 |
$myDir = C4::Context->config('opachtdocs') . |
200 |
'/' . C4::Context->preference("opacthemes") . |
201 |
'/' . C4::Languages::getlanguage() . |
202 |
'/xslt/biblioexport'; |
203 |
} else { |
204 |
$myDir = C4::Context->config('intrahtdocs') . |
205 |
'/' . C4::Context->preference("template") . |
206 |
'/' . C4::Languages::getlanguage() . |
207 |
'/xslt/biblioexport'; |
208 |
} |
209 |
$xslfilename = $myDir."/".$xslFile; |
210 |
}elsif( $xslfilename =~ /^\s*"?default"?\s*$/i ) { |
196 |
my $htdocs; |
211 |
my $htdocs; |
197 |
my $theme; |
212 |
my $theme; |
198 |
my $xslfile; |
213 |
my $xslfile; |
Lines 240-246
sub XSLTParse4Display {
Link Here
|
240 |
my $record = transformMARCXML4XSLT($biblionumber, $orig_record); |
255 |
my $record = transformMARCXML4XSLT($biblionumber, $orig_record); |
241 |
my $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items); |
256 |
my $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items); |
242 |
my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); |
257 |
my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); |
243 |
|
|
|
244 |
$xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/; |
258 |
$xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/; |
245 |
if ($fixamps) { # We need to correct the HTML entities that Zebra outputs |
259 |
if ($fixamps) { # We need to correct the HTML entities that Zebra outputs |
246 |
$xmlrecord =~ s/\&amp;/\&/g; |
260 |
$xmlrecord =~ s/\&amp;/\&/g; |
Lines 345-350
Returns reference to XSLT handler object.
Link Here
|
345 |
sub engine { |
359 |
sub engine { |
346 |
return $engine; |
360 |
return $engine; |
347 |
} |
361 |
} |
|
|
362 |
=head2 CustomXSLTExportList |
363 |
|
364 |
Returns list of file for custom xslt conversion |
365 |
|
366 |
=cut |
367 |
|
368 |
sub CustomXSLTExportList { |
369 |
my $opac = shift; # opac (1) vs intranet (0) |
370 |
my @tabFiles; |
371 |
|
372 |
my $myDir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') . |
373 |
'/' . C4::Context->preference( $opac ? "opacthemes" : "template") . |
374 |
'/' . C4::Languages::getlanguage() . |
375 |
'/xslt/biblioexport'; |
376 |
my @files = <$myDir/*.xsl>; |
377 |
foreach my $file (@files) { |
378 |
if ( -f "$file" ) { |
379 |
local $/ = undef; |
380 |
open FILE, $file or die $!; |
381 |
my @lines = split('\n', <FILE>); |
382 |
close (FILE); |
383 |
(my $text = $file) =~ s/.*\///g; |
384 |
my $title = ""; |
385 |
my $outputformat = ""; |
386 |
## Get title of the option |
387 |
|
388 |
foreach my $line (@lines){ |
389 |
next unless $line =~ /xml/; |
390 |
$line =~ /title="([\w\s]+)"/; |
391 |
$title = $1; |
392 |
|
393 |
last if defined $title; |
394 |
} |
395 |
($title = $text) =~ s/\.xsl// unless defined $title; |
396 |
|
397 |
## Get output format |
398 |
foreach my $line (@lines){ |
399 |
next unless $line =~ /xsl:output/; |
400 |
$line =~ /method="([\w\s]+)"/; |
401 |
$outputformat = $1; |
402 |
|
403 |
last if defined $outputformat; |
404 |
} |
405 |
$outputformat = "txt" if ($outputformat eq "" || $outputformat eq "text"); |
406 |
|
407 |
my %row = ( |
408 |
value => $text, |
409 |
filename => $title, |
410 |
format => $outputformat, |
411 |
); |
412 |
|
413 |
push @tabFiles, \%row; |
414 |
} |
415 |
} |
416 |
return \@tabFiles; |
417 |
} |
418 |
|
348 |
|
419 |
|
349 |
1; |
420 |
1; |
350 |
|
421 |
|