Lines 29-34
use C4::Biblio qw( GetAuthorisedValueDesc GetFrameworkCode GetMarcStructure );
Link Here
|
29 |
use Koha::AuthorisedValues; |
29 |
use Koha::AuthorisedValues; |
30 |
use Koha::ItemTypes; |
30 |
use Koha::ItemTypes; |
31 |
use Koha::RecordProcessor; |
31 |
use Koha::RecordProcessor; |
|
|
32 |
use Koha::Caches; |
32 |
use Koha::XSLT::Base; |
33 |
use Koha::XSLT::Base; |
33 |
use Koha::Libraries; |
34 |
use Koha::Libraries; |
34 |
use Koha::Recalls; |
35 |
use Koha::Recalls; |
Lines 130-153
sub get_xslt_sysprefs {
Link Here
|
130 |
} |
131 |
} |
131 |
|
132 |
|
132 |
sub get_xsl_filename { |
133 |
sub get_xsl_filename { |
133 |
my ( $xslsyspref ) = @_; |
134 |
my ( $xslsyspref, $xslfilename ) = @_; |
134 |
|
135 |
|
135 |
my $lang = C4::Languages::getlanguage(); |
136 |
my $lang = C4::Languages::getlanguage(); |
136 |
|
137 |
|
137 |
my $xslfilename = C4::Context->preference($xslsyspref) || "default"; |
138 |
$xslfilename ||= C4::Context->preference($xslsyspref) || "default"; |
138 |
|
139 |
|
139 |
if ($xslsyspref eq "XSLTCustomExport") { |
140 |
if ($xslsyspref eq "XSLTCustomExport") { |
140 |
my $dir; |
141 |
my $dir; |
141 |
$dir = C4::Context->config('intrahtdocs') . |
142 |
$dir = C4::Context->config('intrahtdocs') . |
142 |
'/' . C4::Context->preference("template") . |
143 |
'/' . C4::Context->preference("template") . |
143 |
'/' . C4::Languages::getlanguage() . |
144 |
'/' . $lang . |
144 |
'/xslt/biblioexport'; |
145 |
'/xslt/biblioexport'; |
145 |
$xslfilename = $dir . "/" . $xslfilename; |
146 |
$xslfilename = $dir . "/" . $xslfilename; |
146 |
} elsif ($xslsyspref eq "OPACXSLTCustomExport") { |
147 |
} elsif ($xslsyspref eq "OPACXSLTCustomExport") { |
147 |
my $dir; |
148 |
my $dir; |
148 |
$dir = C4::Context->config('opachtdocs') . |
149 |
$dir = C4::Context->config('opachtdocs') . |
149 |
'/' . C4::Context->preference("opacthemes") . |
150 |
'/' . C4::Context->preference("opacthemes") . |
150 |
'/' . C4::Languages::getlanguage() . |
151 |
'/' . $lang . |
151 |
'/xslt/biblioexport'; |
152 |
'/xslt/biblioexport'; |
152 |
$xslfilename = $dir . "/" . $xslfilename; |
153 |
$xslfilename = $dir . "/" . $xslfilename; |
153 |
} elsif ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { |
154 |
} elsif ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { |
Lines 208-218
sub XSLTParse4Display {
Link Here
|
208 |
my $variables = $params->{xslt_variables}; |
209 |
my $variables = $params->{xslt_variables}; |
209 |
my $items_rs = $params->{items_rs}; |
210 |
my $items_rs = $params->{items_rs}; |
210 |
my $interface = C4::Context->interface; |
211 |
my $interface = C4::Context->interface; |
|
|
212 |
my $xslfilename = $params->{xslfilename}; |
211 |
|
213 |
|
212 |
die "Mandatory \$params->{xsl_syspref} was not provided, called with biblionumber $params->{biblionumber}" |
214 |
die "Mandatory \$params->{xsl_syspref} was not provided, called with biblionumber $params->{biblionumber}" |
213 |
if not defined $params->{xsl_syspref}; |
215 |
if not defined $params->{xsl_syspref}; |
214 |
|
216 |
|
215 |
my $xslfilename = get_xsl_filename( $xslsyspref); |
217 |
$xslfilename = get_xsl_filename( $xslsyspref, $xslfilename); |
216 |
|
218 |
|
217 |
my $frameworkcode = GetFrameworkCode($biblionumber) || ''; |
219 |
my $frameworkcode = GetFrameworkCode($biblionumber) || ''; |
218 |
my $record_processor = Koha::RecordProcessor->new( |
220 |
my $record_processor = Koha::RecordProcessor->new( |
Lines 236-242
sub XSLTParse4Display {
Link Here
|
236 |
my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); |
238 |
my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); |
237 |
|
239 |
|
238 |
my $biblio; |
240 |
my $biblio; |
239 |
my $variables ||= {}; |
|
|
240 |
|
241 |
|
241 |
if (C4::Context->preference('OPACShowOpenURL')) { |
242 |
if (C4::Context->preference('OPACShowOpenURL')) { |
242 |
my @biblio_itemtypes; |
243 |
my @biblio_itemtypes; |
Lines 414-419
sub engine {
Link Here
|
414 |
return $engine; |
415 |
return $engine; |
415 |
} |
416 |
} |
416 |
|
417 |
|
|
|
418 |
=head2 CustomXSLTExportList |
419 |
|
420 |
Returns list of file for custom xslt conversion |
421 |
|
422 |
=cut |
423 |
|
424 |
sub CustomXSLTExportList { |
425 |
my $opac = shift; # opac (1) vs intranet (0) |
426 |
return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/; |
427 |
|
428 |
# Check the cache first |
429 |
my $cache = Koha::Caches->get_instance; |
430 |
my $key = $opac ? 'CustomXSLTExportListOPAC' : 'CustomXSLTExportListIntra'; |
431 |
my $cached_val = $cache->get_from_cache($key); |
432 |
return $cached_val if $cached_val; |
433 |
|
434 |
my @tabFiles; |
435 |
|
436 |
my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') . |
437 |
'/' . C4::Context->preference( $opac ? "opacthemes" : "template") . |
438 |
'/' . C4::Languages::getlanguage() . |
439 |
'/xslt/biblioexport'; |
440 |
my @files = glob qq("$dir/*.xsl"); |
441 |
foreach my $file (@files) { |
442 |
if ( -f "$file" ) { |
443 |
(my $text = $file) =~ s/.*\///g; |
444 |
|
445 |
## Get title of the option |
446 |
my $dom; |
447 |
eval { $dom = XML::LibXML->load_xml( location => $file ); }; |
448 |
next unless $dom; |
449 |
|
450 |
my $node = $dom->documentElement(); |
451 |
my $title = $node->{"title"}; |
452 |
($title = $text) =~ s/\.xsl// unless defined $title; |
453 |
|
454 |
# Get output format |
455 |
# There should only be one xsl:output node, so taking the first one only is OK |
456 |
$node = @{$node->findnodes("xsl:output")}[0]; |
457 |
my $outputformat= ""; |
458 |
$outputformat = $node->{"method"} if $node; |
459 |
$outputformat = "txt" if ($outputformat eq "" || $outputformat eq "text"); |
460 |
|
461 |
my %row = ( |
462 |
value => $text, |
463 |
filename => $title, |
464 |
format => $outputformat, |
465 |
); |
466 |
|
467 |
push @tabFiles, \%row; |
468 |
} |
469 |
} |
470 |
$cache->set_in_cache( $key, [ @tabFiles ] ); |
471 |
return \@tabFiles; |
472 |
} |
417 |
1; |
473 |
1; |
418 |
|
474 |
|
419 |
__END__ |
475 |
__END__ |