@@ -, +, @@ folder --- C4/XSLT.pm | 48 +++++++++++++++++++++++++++++++++++++++++++ t/db_dependent/XSLT.t | 1 + 2 files changed, 49 insertions(+) --- a/C4/XSLT.pm +++ a/C4/XSLT.pm @@ -409,6 +409,54 @@ sub engine { return $engine; } +=head2 CustomXSLTExportList + + Returns list of file for custom xslt conversion + +=cut + +sub CustomXSLTExportList { + my $opac = shift; # opac (1) vs intranet (0) + return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/; + + my @tabFiles; + + my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') . + '/' . C4::Context->preference( $opac ? "opacthemes" : "template") . + '/' . C4::Languages::getlanguage() . + '/xslt/biblioexport'; + my @files = glob qq("$dir/*.xsl"); + foreach my $file (@files) { + if ( -f "$file" ) { + (my $text = $file) =~ s/.*\///g; + + ## Get title of the option + my $dom; + eval { $dom = XML::LibXML->load_xml( location => $file ); }; + next unless $dom; + + my $node = $dom->documentElement(); + my $title = $node->{"title"}; + ($title = $text) =~ s/\.xsl// unless defined $title; + + # Get output format + # There should only be one xsl:output node, so taking the first one only is OK + $node = @{$node->findnodes("xsl:output")}[0]; + my $outputformat= ""; + $outputformat = $node->{"method"} if $node; + $outputformat = "txt" if ($outputformat eq "" || $outputformat eq "text"); + + my %row = ( + value => $text, + filename => $title, + format => $outputformat, + ); + + push @tabFiles, \%row; + } + } + return \@tabFiles; +} 1; __END__ --- a/t/db_dependent/XSLT.t +++ a/t/db_dependent/XSLT.t @@ -1,3 +1,4 @@ +original #!/usr/bin/perl # This file is part of Koha. --