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

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