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

(-)a/C4/XSLT.pm (-13 / +16 lines)
Lines 191-197 sub get_xslt_sysprefs { Link Here
191
}
191
}
192
192
193
sub XSLTParse4Display {
193
sub XSLTParse4Display {
194
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang , $opac) = @_;
194
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang) = @_;
195
195
196
    $sysxml ||= C4::Context->preference($xslsyspref);
196
    $sysxml ||= C4::Context->preference($xslsyspref);
197
    $xslfilename ||= C4::Context->preference($xslsyspref);
197
    $xslfilename ||= C4::Context->preference($xslsyspref);
Lines 199-215 sub XSLTParse4Display { Link Here
199
199
200
    if ($xslsyspref eq "XSLTCustomExport") {
200
    if ($xslsyspref eq "XSLTCustomExport") {
201
        my $dir;
201
        my $dir;
202
        if ($opac) {
202
        $dir = C4::Context->config('intrahtdocs') .
203
            $dir = C4::Context->config('opachtdocs') .
203
            '/' . C4::Context->preference("template") .
204
                '/' . C4::Context->preference("opacthemes") .
204
            '/' . C4::Languages::getlanguage() .
205
                '/' . C4::Languages::getlanguage() .
205
            '/xslt/biblioexport';
206
                '/xslt/biblioexport';
206
        $xslfilename = $dir . "/" . $xslfilename;
207
        } else {
207
    } elsif ($xslsyspref eq "OPACXSLTCustomExport") {
208
            $dir = C4::Context->config('intrahtdocs') .
208
        my $dir;
209
                '/' . C4::Context->preference("template") .
209
        $dir = C4::Context->config('opachtdocs') .
210
                '/' . C4::Languages::getlanguage() .
210
            '/' . C4::Context->preference("opacthemes") .
211
                '/xslt/biblioexport';
211
            '/' . C4::Languages::getlanguage() .
212
        }
212
            '/xslt/biblioexport';
213
        $xslfilename = $dir . "/" . $xslfilename;
213
        $xslfilename = $dir . "/" . $xslfilename;
214
    } elsif( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
214
    } elsif( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
215
        my $htdocs;
215
        my $htdocs;
Lines 389-395 sub CustomXSLTExportList { Link Here
389
            (my $text = $file) =~ s/.*\///g;
389
            (my $text = $file) =~ s/.*\///g;
390
390
391
            ## Get title of the option
391
            ## Get title of the option
392
            my $dom = XML::LibXML->load_xml( location => $file );
392
            my $dom;
393
            eval { $dom = XML::LibXML->load_xml( location => $file ); };
394
            next unless $dom;
395
393
            my $node = $dom->documentElement();
396
            my $node = $dom->documentElement();
394
            my $title = $node->{"title"};
397
            my $title = $node->{"title"};
395
            ($title = $text) =~ s/\.xsl// unless defined $title;
398
            ($title = $text) =~ s/\.xsl// unless defined $title;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+1 lines)
Lines 298-303 OPAC: Link Here
298
                mods: MODS
298
                mods: MODS
299
                ris: RIS
299
                ris: RIS
300
                isbd: ISBD
300
                isbd: ISBD
301
                custom: Custom
301
        -
302
        -
302
            - pref: OpacSeparateHoldings
303
            - pref: OpacSeparateHoldings
303
              choices:
304
              choices:
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (-4 / +5 lines)
Lines 50-56 Link Here
50
                            [% FOREACH option IN export_options %]
50
                            [% FOREACH option IN export_options %]
51
                                [% IF option == 'dc' %]
51
                                [% IF option == 'dc' %]
52
                                    <li><a role="menuitem" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li>
52
                                    <li><a role="menuitem" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li>
53
                                [% ELSE %]
53
                                [% ELSIF option != 'custom' %]
54
                                <li>
54
                                <li>
55
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
55
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
56
                                        [% SWITCH option %]
56
                                        [% SWITCH option %]
Lines 66-76 Link Here
66
                                        [% END %]
66
                                        [% END %]
67
                                    </a>
67
                                    </a>
68
                                </li>
68
                                </li>
69
                                [% ELSE %]
70
                                    [% FOREACH filesOption IN filesOptions %]
71
                                        <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>
72
                                    [% END %]
69
                                [% END %]
73
                                [% END %]
70
                            [% END %]
74
                            [% END %]
71
                            [% FOREACH filesOption IN filesOptions %]
72
                                <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>
73
                            [% END %]
74
                        </ul>
75
                        </ul>
75
                </div>
76
                </div>
76
            </div>
77
            </div>
(-)a/opac/opac-downloadcart.pl (-1 / +1 lines)
Lines 101-107 if ($bib_list && $format) { Link Here
101
                $type      = "text/plain";
101
                $type      = "text/plain";
102
            }
102
            }
103
            elsif ($format =~ /^xsl\.(.*)$/) {
103
            elsif ($format =~ /^xsl\.(.*)$/) {
104
                $output .= XSLTParse4Display($biblio, $record, 'XSLTCustomExport', 1, undef, undef, $1, '', 1);
104
                $output .= XSLTParse4Display($biblio, $record, 'OPACXSLTCustomExport', 1, undef, undef, $1, '');
105
            }
105
            }
106
        }
106
        }
107
    }
107
    }
(-)a/opac/opac-export.pl (-1 / +1 lines)
Lines 113-119 elsif ($format =~ /html/ ) { Link Here
113
        $marc = C4::Biblio::GetMarcBiblio({biblionumber => $biblionumber});
113
        $marc = C4::Biblio::GetMarcBiblio({biblionumber => $biblionumber});
114
        my @hiddenitems;
114
        my @hiddenitems;
115
115
116
        $marc = XSLTParse4Display($biblionumber, $marc, 'XSLTCustomExport', 1, \@hiddenitems, undef, $xslFile, undef, 1);
116
        $marc = XSLTParse4Display($biblionumber, $marc, 'OPACXSLTCustomExport', 1, \@hiddenitems, undef, $xslFile, undef);
117
    }
117
    }
118
}
118
}
119
else {
119
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