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 313-318 OPAC: Link Here
313
                mods: MODS
313
                mods: MODS
314
                ris: RIS
314
                ris: RIS
315
                isbd: ISBD
315
                isbd: ISBD
316
                custom: Custom
316
        -
317
        -
317
            - pref: OpacSeparateHoldings
318
            - pref: OpacSeparateHoldings
318
              choices:
319
              choices:
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (+33 lines)
Lines 57-62 Link Here
57
        <li>
57
        <li>
58
            <div id="export">
58
            <div id="export">
59
                <div class="dropdown">
59
                <div class="dropdown">
60
<<<<<<< HEAD
60
                    <a id="format" class="btn btn-link btn-lg dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Save record <b class="caret"></b></a>
61
                    <a id="format" class="btn btn-link btn-lg dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Save record <b class="caret"></b></a>
61
                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="format">
62
                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="format">
62
                        [% FOREACH option IN export_options %]
63
                        [% FOREACH option IN export_options %]
Lines 84-89 Link Here
84
                    </div> <!-- /.dropdown-menu -->
85
                    </div> <!-- /.dropdown-menu -->
85
                </div> <!-- /.dropdown -->
86
                </div> <!-- /.dropdown -->
86
            </div> <!-- /#export -->
87
            </div> <!-- /#export -->
88
=======
89
                    <a id="format" class="btn btn-link btn-lg dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-fw fa-download"></i> Save record <b class="caret"></b></a>
90
                        <ul class="dropdown-menu pull-left" role="menu" aria-labelledby="format">
91
                            [% FOREACH option IN export_options %]
92
                                [% IF option == 'dc' %]
93
                                    <li><a role="menuitem" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li>
94
                                [% ELSIF option != 'custom' %]
95
                                <li>
96
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
97
                                        [% SWITCH option %]
98
                                            [% CASE 'bibtex' %]BIBTEX
99
                                            [% CASE 'endnote' %]EndNote
100
                                            [% CASE 'marcxml' %]MARCXML
101
                                            [% CASE 'marc8' %]MARC (non-Unicode/MARC-8)
102
                                            [% CASE 'utf8' %]MARC (Unicode/UTF-8)
103
                                            [% CASE 'marcstd' %]MARC (Unicode/UTF-8, Standard)
104
                                            [% CASE 'mods' %]MODS (XML)
105
                                            [% CASE 'ris' %]RIS
106
                                            [% CASE 'isbd' %]ISBD
107
                                        [% END %]
108
                                    </a>
109
                                </li>
110
                                [% ELSE %]
111
                                    [% FOREACH filesOption IN filesOptions %]
112
                                        <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>
113
                                    [% END %]
114
                                [% END %]
115
                            [% END %]
116
                        </ul>
117
                </div>
118
            </div>
119
>>>>>>> Bug 17385: Add tests for CustomXSLTExportList
87
        </li>
120
        </li>
88
    [% END %]
121
    [% END %]
89
122
(-)a/opac/opac-downloadcart.pl (-1 / +1 lines)
Lines 118-124 if ($bib_list && $format) { Link Here
118
                $type      = "text/plain";
118
                $type      = "text/plain";
119
            }
119
            }
120
            elsif ($format =~ /^xsl\.(.*)$/) {
120
            elsif ($format =~ /^xsl\.(.*)$/) {
121
                $output .= XSLTParse4Display($biblio, $record, 'XSLTCustomExport', 1, undef, undef, $1, '', 1);
121
                $output .= XSLTParse4Display($biblio, $record, 'OPACXSLTCustomExport', 1, undef, undef, $1, '');
122
            }
122
            }
123
        }
123
        }
124
    }
124
    }
(-)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