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

(-)a/C4/XSLT.pm (+48 lines)
Lines 430-435 sub engine { Link Here
430
    return $engine;
430
    return $engine;
431
}
431
}
432
432
433
=head2 CustomXSLTExportList
434
435
 Returns list of file for custom xslt conversion
436
437
=cut
438
439
sub CustomXSLTExportList {
440
    my $opac = shift; # opac (1) vs intranet (0)
441
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
442
443
    my @tabFiles;
444
445
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
446
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
447
                      '/' . C4::Languages::getlanguage() .
448
                      '/xslt/biblioexport';
449
    my @files = glob qq("$dir/*.xsl");
450
    foreach my $file (@files) {
451
        if ( -f "$file" ) {
452
            (my $text = $file) =~ s/.*\///g;
453
454
            ## Get title of the option
455
            my $dom;
456
            eval { $dom = XML::LibXML->load_xml( location => $file ); };
457
            next unless $dom;
458
459
            my $node = $dom->documentElement();
460
            my $title = $node->{"title"};
461
            ($title = $text) =~ s/\.xsl// unless defined $title;
462
463
            # Get output format
464
            # There should only be one xsl:output node, so taking the first one only is OK
465
            $node = @{$node->findnodes("xsl:output")}[0];
466
            my $outputformat= "";
467
            $outputformat = $node->{"method"} if $node;
468
            $outputformat = "txt" if ($outputformat eq "" || $outputformat eq "text");
469
470
            my %row = (
471
                value       => $text,
472
                filename    => $title,
473
                format      => $outputformat,
474
            );
475
476
            push @tabFiles, \%row;
477
        }
478
    }
479
    return \@tabFiles;
480
}
433
1;
481
1;
434
482
435
__END__
483
__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