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

(-)a/C4/XSLT.pm (-13 / +16 lines)
Lines 193-199 sub get_xslt_sysprefs { Link Here
193
}
193
}
194
194
195
sub XSLTParse4Display {
195
sub XSLTParse4Display {
196
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang , $opac) = @_;
196
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang) = @_;
197
197
198
    $sysxml ||= C4::Context->preference($xslsyspref);
198
    $sysxml ||= C4::Context->preference($xslsyspref);
199
    $xslfilename ||= C4::Context->preference($xslsyspref);
199
    $xslfilename ||= C4::Context->preference($xslsyspref);
Lines 201-217 sub XSLTParse4Display { Link Here
201
201
202
    if ($xslsyspref eq "XSLTCustomExport") {
202
    if ($xslsyspref eq "XSLTCustomExport") {
203
        my $dir;
203
        my $dir;
204
        if ($opac) {
204
        $dir = C4::Context->config('intrahtdocs') .
205
            $dir = C4::Context->config('opachtdocs') .
205
            '/' . C4::Context->preference("template") .
206
                '/' . C4::Context->preference("opacthemes") .
206
            '/' . C4::Languages::getlanguage() .
207
                '/' . C4::Languages::getlanguage() .
207
            '/xslt/biblioexport';
208
                '/xslt/biblioexport';
208
        $xslfilename = $dir . "/" . $xslfilename;
209
        } else {
209
    } elsif ($xslsyspref eq "OPACXSLTCustomExport") {
210
            $dir = C4::Context->config('intrahtdocs') .
210
        my $dir;
211
                '/' . C4::Context->preference("template") .
211
        $dir = C4::Context->config('opachtdocs') .
212
                '/' . C4::Languages::getlanguage() .
212
            '/' . C4::Context->preference("opacthemes") .
213
                '/xslt/biblioexport';
213
            '/' . C4::Languages::getlanguage() .
214
        }
214
            '/xslt/biblioexport';
215
        $xslfilename = $dir . "/" . $xslfilename;
215
        $xslfilename = $dir . "/" . $xslfilename;
216
    } elsif( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
216
    } elsif( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
217
        my $htdocs;
217
        my $htdocs;
Lines 424-430 sub CustomXSLTExportList { Link Here
424
            (my $text = $file) =~ s/.*\///g;
424
            (my $text = $file) =~ s/.*\///g;
425
425
426
            ## Get title of the option
426
            ## Get title of the option
427
            my $dom = XML::LibXML->load_xml( location => $file );
427
            my $dom;
428
            eval { $dom = XML::LibXML->load_xml( location => $file ); };
429
            next unless $dom;
430
428
            my $node = $dom->documentElement();
431
            my $node = $dom->documentElement();
429
            my $title = $node->{"title"};
432
            my $title = $node->{"title"};
430
            ($title = $text) =~ s/\.xsl// unless defined $title;
433
            ($title = $text) =~ s/\.xsl// unless defined $title;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+1 lines)
Lines 321-326 OPAC: Link Here
321
                mods: MODS
321
                mods: MODS
322
                ris: RIS
322
                ris: RIS
323
                isbd: ISBD
323
                isbd: ISBD
324
                custom: Custom
324
        -
325
        -
325
            - pref: OpacSeparateHoldings
326
            - pref: OpacSeparateHoldings
326
              choices:
327
              choices:
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (-4 / +5 lines)
Lines 62-68 Link Here
62
                            [% FOREACH option IN export_options %]
62
                            [% FOREACH option IN export_options %]
63
                                [% IF option == 'dc' %]
63
                                [% IF option == 'dc' %]
64
                                    <li><a role="menuitem" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li>
64
                                    <li><a role="menuitem" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li>
65
                                [% ELSE %]
65
                                [% ELSIF option != 'custom' %]
66
                                <li>
66
                                <li>
67
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
67
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
68
                                        [% SWITCH option %]
68
                                        [% SWITCH option %]
Lines 78-88 Link Here
78
                                        [% END %]
78
                                        [% END %]
79
                                    </a>
79
                                    </a>
80
                                </li>
80
                                </li>
81
                                [% ELSE %]
82
                                    [% FOREACH filesOption IN filesOptions %]
83
                                        <li><a role="menuitem" href="/cgi-bin/koha/opac-export.pl?format=[% filesOption.format %]&amp;op=exportxsl&amp;file=[% filesOption.value %]&amp;bib=[% biblionumber %]">[% filesOption.filename %]</a></li>
84
                                    [% END %]
81
                                [% END %]
85
                                [% END %]
82
                            [% END %]
86
                            [% END %]
83
                            [% FOREACH filesOption IN filesOptions %]
84
                                <li><a role="menuitem" href="/cgi-bin/koha/opac-export.pl?format=[% filesOption.format %]&amp;op=exportxsl&amp;file=[% filesOption.value %]&amp;bib=[% biblionumber %]">[% filesOption.filename %]</a></li>
85
                            [% END %]
86
                        </ul>
87
                        </ul>
87
                </div>
88
                </div>
88
            </div>
89
            </div>
(-)a/opac/opac-downloadcart.pl (-1 / +1 lines)
Lines 110-116 if ($bib_list && $format) { Link Here
110
                $type      = "text/plain";
110
                $type      = "text/plain";
111
            }
111
            }
112
            elsif ($format =~ /^xsl\.(.*)$/) {
112
            elsif ($format =~ /^xsl\.(.*)$/) {
113
                $output .= XSLTParse4Display($biblio, $record, 'XSLTCustomExport', 1, undef, undef, $1, '', 1);
113
                $output .= XSLTParse4Display($biblio, $record, 'OPACXSLTCustomExport', 1, undef, undef, $1, '');
114
            }
114
            }
115
        }
115
        }
116
    }
116
    }
(-)a/opac/opac-export.pl (-1 / +1 lines)
Lines 127-133 elsif ($format =~ /html/ ) { Link Here
127
        $marc = C4::Biblio::GetMarcBiblio({biblionumber => $biblionumber});
127
        $marc = C4::Biblio::GetMarcBiblio({biblionumber => $biblionumber});
128
        my @hiddenitems;
128
        my @hiddenitems;
129
129
130
        $marc = XSLTParse4Display($biblionumber, $marc, 'XSLTCustomExport', 1, \@hiddenitems, undef, $xslFile, undef, 1);
130
        $marc = XSLTParse4Display($biblionumber, $marc, 'OPACXSLTCustomExport', 1, \@hiddenitems, undef, $xslFile, undef);
131
    }
131
    }
132
}
132
}
133
else {
133
else {
(-)a/t/XSLT.t (-3 / +32 lines)
Lines 21-33 use Test::More; Link Here
21
use File::Temp;
21
use File::Temp;
22
use File::Path qw/make_path/;
22
use File::Path qw/make_path/;
23
23
24
use t::lib::Mocks;
24
use t::lib::Mocks qw( mock_preference );
25
25
26
use Module::Load::Conditional qw/check_install/;
26
use Module::Load::Conditional qw/check_install/;
27
27
28
BEGIN {
28
BEGIN {
29
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
29
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
30
        plan tests => 9;
30
        plan tests => 12;
31
    } else {
31
    } else {
32
        plan skip_all => "Need Test::DBIx::Class"
32
        plan skip_all => "Need Test::DBIx::Class"
33
    }
33
    }
Lines 77-79 my $matching_string = q{<syspref name="singleBranchMode">0</syspref>}; Link Here
77
my $sysprefs_xml = C4::XSLT::get_xslt_sysprefs();
77
my $sysprefs_xml = C4::XSLT::get_xslt_sysprefs();
78
ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has a value of 0');
78
ok( $sysprefs_xml =~ m/$matching_string/, 'singleBranchMode has a value of 0');
79
79
80
- 
80
t::lib::Mocks::mock_config('opachtdocs', "$dir");
81
make_path("$dir/bootstrap/en/xslt/biblioexport");
82
83
# Make XSL with title
84
open my $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_01.xsl";
85
print $fh qq|<?xml version="1.0" encoding="UTF-8"?>
86
<xsl:stylesheet version="1.0"
87
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
88
   xmlns:marc="http://www.loc.gov/MARC21/slim"
89
   title="Export 01">
90
</xsl:stylesheet>|;
91
close $fh;
92
93
# Make XSL without title
94
open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_02.xsl";
95
print $fh qq|<?xml version="1.0" encoding="UTF-8"?>
96
<xsl:stylesheet version="1.0"
97
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
98
   xmlns:marc="http://www.loc.gov/MARC21/slim">
99
</xsl:stylesheet>|;
100
close $fh;
101
102
open $fh, '>', "$dir/bootstrap/en/xslt/biblioexport/export_03.xsl";
103
print $fh qq|<?xml version="1.0" encoding="UTF-8"?>|;
104
close $fh;
105
106
my @custom_xslts = @{C4::XSLT::CustomXSLTExportList(1)};
107
ok((scalar @custom_xslts) == 2, "CustomXSLTExportList finds custom XSLTs");
108
ok($custom_xslts[0]->{filename} eq "Export 01", "Title is specified in root node");
109
ok($custom_xslts[1]->{filename} eq "export_02", "Title is filename if not specified");

Return to bug 17385