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