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

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