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