View | Details | Raw Unified | Return to bug 17385
Collapse All | Expand All

(-)a/C4/XSLT.pm (+48 lines)
Lines 476-481 sub engine { Link Here
476
    return $engine;
476
    return $engine;
477
}
477
}
478
478
479
=head2 CustomXSLTExportList
480
481
 Returns list of file for custom xslt conversion
482
483
=cut
484
485
sub CustomXSLTExportList {
486
    my $opac = shift; # opac (1) vs intranet (0)
487
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
488
489
    my @tabFiles;
490
491
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
492
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
493
                      '/' . C4::Languages::getlanguage() .
494
                      '/xslt/biblioexport';
495
    my @files = glob qq("$dir/*.xsl");
496
    foreach my $file (@files) {
497
        if ( -f "$file" ) {
498
            (my $text = $file) =~ s/.*\///g;
499
500
            ## Get title of the option
501
            my $dom;
502
            eval { $dom = XML::LibXML->load_xml( location => $file ); };
503
            next unless $dom;
504
505
            my $node = $dom->documentElement();
506
            my $title = $node->{"title"};
507
            ($title = $text) =~ s/\.xsl// unless defined $title;
508
509
            # Get output format
510
            # There should only be one xsl:output node, so taking the first one only is OK
511
            $node = @{$node->findnodes("xsl:output")}[0];
512
            my $outputformat= "";
513
            $outputformat = $node->{"method"} if $node;
514
            $outputformat = "txt" if ($outputformat eq "" || $outputformat eq "text");
515
516
            my %row = (
517
                value       => $text,
518
                filename    => $title,
519
                format      => $outputformat,
520
            );
521
522
            push @tabFiles, \%row;
523
        }
524
    }
525
    return \@tabFiles;
526
}
479
1;
527
1;
480
528
481
__END__
529
__END__
(-)a/t/db_dependent/XSLT.t (-1 / +1 lines)
Lines 1-3 Link Here
1
original
1
#!/usr/bin/perl
2
#!/usr/bin/perl
2
3
3
# This file is part of Koha.
4
# This file is part of Koha.
4
- 

Return to bug 17385