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

(-)a/C4/XSLT.pm (-6 / +62 lines)
Lines 29-34 use C4::Biblio qw( GetAuthorisedValueDesc GetFrameworkCode GetMarcStructure ); Link Here
29
use Koha::AuthorisedValues;
29
use Koha::AuthorisedValues;
30
use Koha::ItemTypes;
30
use Koha::ItemTypes;
31
use Koha::RecordProcessor;
31
use Koha::RecordProcessor;
32
use Koha::Caches;
32
use Koha::XSLT::Base;
33
use Koha::XSLT::Base;
33
use Koha::Libraries;
34
use Koha::Libraries;
34
use Koha::Recalls;
35
use Koha::Recalls;
Lines 130-153 sub get_xslt_sysprefs { Link Here
130
}
131
}
131
132
132
sub get_xsl_filename {
133
sub get_xsl_filename {
133
    my ( $xslsyspref ) = @_;
134
    my ( $xslsyspref, $xslfilename ) = @_;
134
135
135
    my $lang   = C4::Languages::getlanguage();
136
    my $lang   = C4::Languages::getlanguage();
136
137
137
    my $xslfilename = C4::Context->preference($xslsyspref) || "default";
138
    $xslfilename ||= C4::Context->preference($xslsyspref) || "default";
138
139
139
    if ($xslsyspref eq "XSLTCustomExport") {
140
    if ($xslsyspref eq "XSLTCustomExport") {
140
        my $dir;
141
        my $dir;
141
        $dir = C4::Context->config('intrahtdocs') .
142
        $dir = C4::Context->config('intrahtdocs') .
142
            '/' . C4::Context->preference("template") .
143
            '/' . C4::Context->preference("template") .
143
            '/' . C4::Languages::getlanguage() .
144
            '/' . $lang .
144
            '/xslt/biblioexport';
145
            '/xslt/biblioexport';
145
        $xslfilename = $dir . "/" . $xslfilename;
146
        $xslfilename = $dir . "/" . $xslfilename;
146
    } elsif ($xslsyspref eq "OPACXSLTCustomExport") {
147
    } elsif ($xslsyspref eq "OPACXSLTCustomExport") {
147
        my $dir;
148
        my $dir;
148
        $dir = C4::Context->config('opachtdocs') .
149
        $dir = C4::Context->config('opachtdocs') .
149
            '/' . C4::Context->preference("opacthemes") .
150
            '/' . C4::Context->preference("opacthemes") .
150
            '/' . C4::Languages::getlanguage() .
151
            '/' . $lang .
151
            '/xslt/biblioexport';
152
            '/xslt/biblioexport';
152
        $xslfilename = $dir . "/" . $xslfilename;
153
        $xslfilename = $dir . "/" . $xslfilename;
153
    } elsif ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
154
    } elsif ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
Lines 208-218 sub XSLTParse4Display { Link Here
208
    my $variables    = $params->{xslt_variables};
209
    my $variables    = $params->{xslt_variables};
209
    my $items_rs     = $params->{items_rs};
210
    my $items_rs     = $params->{items_rs};
210
    my $interface    = C4::Context->interface;
211
    my $interface    = C4::Context->interface;
212
    my $xslfilename  = $params->{xslfilename};
211
213
212
    die "Mandatory \$params->{xsl_syspref} was not provided, called with biblionumber $params->{biblionumber}"
214
    die "Mandatory \$params->{xsl_syspref} was not provided, called with biblionumber $params->{biblionumber}"
213
        if not defined $params->{xsl_syspref};
215
        if not defined $params->{xsl_syspref};
214
216
215
    my $xslfilename = get_xsl_filename( $xslsyspref);
217
    $xslfilename = get_xsl_filename( $xslsyspref, $xslfilename);
216
218
217
    my $frameworkcode = GetFrameworkCode($biblionumber) || '';
219
    my $frameworkcode = GetFrameworkCode($biblionumber) || '';
218
    my $record_processor = Koha::RecordProcessor->new(
220
    my $record_processor = Koha::RecordProcessor->new(
Lines 236-242 sub XSLTParse4Display { Link Here
236
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
238
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
237
239
238
    my $biblio;
240
    my $biblio;
239
    my $variables ||= {};
240
241
241
    if (C4::Context->preference('OPACShowOpenURL')) {
242
    if (C4::Context->preference('OPACShowOpenURL')) {
242
        my @biblio_itemtypes;
243
        my @biblio_itemtypes;
Lines 414-419 sub engine { Link Here
414
    return $engine;
415
    return $engine;
415
}
416
}
416
417
418
=head2 CustomXSLTExportList
419
420
 Returns list of file for custom xslt conversion
421
422
=cut
423
424
sub CustomXSLTExportList {
425
    my $opac = shift; # opac (1) vs intranet (0)
426
    return [] if $opac && C4::Context->preference('OpacExportOptions') !~ /custom/;
427
428
    # Check the cache first
429
    my $cache = Koha::Caches->get_instance;
430
    my $key = $opac ? 'CustomXSLTExportListOPAC' : 'CustomXSLTExportListIntra';
431
    my $cached_val = $cache->get_from_cache($key);
432
    return $cached_val if $cached_val;
433
434
    my @tabFiles;
435
436
    my $dir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
437
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
438
                      '/' . C4::Languages::getlanguage() .
439
                      '/xslt/biblioexport';
440
    my @files = glob qq("$dir/*.xsl");
441
    foreach my $file (@files) {
442
        if ( -f "$file" ) {
443
            (my $text = $file) =~ s/.*\///g;
444
445
            ## Get title of the option
446
            my $dom;
447
            eval { $dom = XML::LibXML->load_xml( location => $file ); };
448
            next unless $dom;
449
450
            my $node = $dom->documentElement();
451
            my $title = $node->{"title"};
452
            ($title = $text) =~ s/\.xsl// unless defined $title;
453
454
            # Get output format
455
            # There should only be one xsl:output node, so taking the first one only is OK
456
            $node = @{$node->findnodes("xsl:output")}[0];
457
            my $outputformat= "";
458
            $outputformat = $node->{"method"} if $node;
459
            $outputformat = "txt" if ($outputformat eq "" || $outputformat eq "text");
460
461
            my %row = (
462
                value       => $text,
463
                filename    => $title,
464
                format      => $outputformat,
465
            );
466
467
            push @tabFiles, \%row;
468
        }
469
    }
470
    $cache->set_in_cache( $key, [ @tabFiles ] );
471
    return \@tabFiles;
472
}
417
1;
473
1;
418
474
419
__END__
475
__END__
(-)a/basket/basket.pl (-1 / +1 lines)
Lines 27-33 use C4::Biblio qw( Link Here
27
);
27
);
28
use C4::Auth qw( get_template_and_user );
28
use C4::Auth qw( get_template_and_user );
29
use C4::Output qw( output_html_with_http_headers );
29
use C4::Output qw( output_html_with_http_headers );
30
use C4::XSLT;
30
use C4::XSLT qw( CustomXSLTExportList );
31
31
32
32
33
use Koha::AuthorisedValues;
33
use Koha::AuthorisedValues;
(-)a/basket/downloadcart.pl (-2 / +12 lines)
Lines 26-32 use C4::Auth qw( get_template_and_user ); Link Here
26
use C4::Output qw( output_html_with_http_headers );
26
use C4::Output qw( output_html_with_http_headers );
27
use C4::Record;
27
use C4::Record;
28
use C4::Ris qw( marc2ris );
28
use C4::Ris qw( marc2ris );
29
use C4::XSLT;
29
use C4::XSLT qw( XSLTParse4Display );
30
30
31
use Koha::CsvProfiles;
31
use Koha::CsvProfiles;
32
use Koha::Biblios;
32
use Koha::Biblios;
Lines 66-71 if ($bib_list && $format) { Link Here
66
66
67
            my $biblio = Koha::Biblios->find($biblionumber);
67
            my $biblio = Koha::Biblios->find($biblionumber);
68
            my $record = $biblio->metadata->record({ embed_items => 1 });
68
            my $record = $biblio->metadata->record({ embed_items => 1 });
69
            my $xslFile = $query->param("file");
69
            next unless $record;
70
            next unless $record;
70
71
71
            if ($format eq 'iso2709') {
72
            if ($format eq 'iso2709') {
Lines 80-86 if ($bib_list && $format) { Link Here
80
                $output .= marc2bibtex($record, $biblionumber);
81
                $output .= marc2bibtex($record, $biblionumber);
81
            }
82
            }
82
            elsif ($format =~ /^xsl\.(.*)$/) {
83
            elsif ($format =~ /^xsl\.(.*)$/) {
83
                $output .= XSLTParse4Display($biblio, $record, 'XSLTCustomExport', 1, undef, , '', $1, '');
84
                $output .= XSLTParse4Display(
85
                    {
86
                      biblionumber => $biblio,
87
                      record       => $record,
88
                      xsl_syspref  => "XSLTCustomExport",
89
                      fix_amps     => 1,
90
                      hidden_items => undef,
91
                      xslfilename  => $xslFile,
92
                    }
93
                );
84
            }
94
            }
85
        }
95
        }
86
    }
96
    }
(-)a/catalogue/detail.pl (-1 / +1 lines)
Lines 40-46 use C4::XISBN qw( get_xisbns ); Link Here
40
use C4::External::Amazon qw( get_amazon_tld );
40
use C4::External::Amazon qw( get_amazon_tld );
41
use C4::Search qw( z3950_search_args enabled_staff_search_views new_record_from_zebra );
41
use C4::Search qw( z3950_search_args enabled_staff_search_views new_record_from_zebra );
42
use C4::Tags qw( get_tags );
42
use C4::Tags qw( get_tags );
43
use C4::XSLT qw( XSLTParse4Display );
43
use C4::XSLT qw( XSLTParse4Display CustomXSLTExportList );
44
use Koha::DateUtils qw( format_sqldatetime );
44
use Koha::DateUtils qw( format_sqldatetime );
45
use C4::HTML5Media;
45
use C4::HTML5Media;
46
use C4::CourseReserves qw( GetItemCourseReservesInfo );
46
use C4::CourseReserves qw( GetItemCourseReservesInfo );
(-)a/catalogue/export.pl (-4 / +14 lines)
Lines 7-14 use C4::Output; Link Here
7
use C4::Biblio qw( GetMarcControlnumber );
7
use C4::Biblio qw( GetMarcControlnumber );
8
use CGI qw ( -utf8 );
8
use CGI qw ( -utf8 );
9
use C4::Ris qw( marc2ris );
9
use C4::Ris qw( marc2ris );
10
use C4::XSLT;
10
use C4::XSLT qw( XSLTParse4Display );
11
11
use Koha::Biblios;
12
12
13
13
14
14
Lines 92-102 if ($op eq "export") { Link Here
92
    my $biblionumber = $query->param("bib");
92
    my $biblionumber = $query->param("bib");
93
    if ($biblionumber){
93
    if ($biblionumber){
94
        my $xslFile = $query->param("file");
94
        my $xslFile = $query->param("file");
95
        my $marc = GetMarcBiblio( { biblionumber => $biblionumber, embed_items => 1 } );
95
        my $biblio = Koha::Biblios->find($biblionumber);
96
        my $marc = $biblio->metadata->record( { embed_items => 1 } );
96
        my $format=$query->param("format")||'txt';
97
        my $format=$query->param("format")||'txt';
97
        my @hiddenitems;
98
        my @hiddenitems;
98
99
99
        $marc = XSLTParse4Display($biblionumber, $marc, 'XSLTCustomExport', 1, \@hiddenitems, '', $xslFile,'');
100
        $marc = XSLTParse4Display(
101
            {
102
              biblionumber   => $biblionumber,
103
              record         => $marc,
104
              xsl_syspref    => "XSLTCustomExport",
105
              fix_amps       => 1,
106
              hidden_items   => \@hiddenitems,
107
              xslfilename    => $xslFile,
108
            }
109
        );
100
        print $query->header(
110
        print $query->header(
101
            -type => 'application/octet-stream',
111
            -type => 'application/octet-stream',
102
            -attachment=>"bib-$biblionumber.$format");
112
            -attachment=>"bib-$biblionumber.$format");
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc (-1 / +1 lines)
Lines 32-38 Link Here
32
                        <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=[% csv_profile.export_format_id | uri %]&amp;shelfid=[% shelf.shelfnumber | uri %]">CSV - [% csv_profile.profile | html %]</a></li>
32
                        <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=[% csv_profile.export_format_id | uri %]&amp;shelfid=[% shelf.shelfnumber | uri %]">CSV - [% csv_profile.profile | html %]</a></li>
33
                    [% END %]
33
                    [% END %]
34
                    [% FOREACH xsl_export IN xsl_exports %]
34
                    [% FOREACH xsl_export IN xsl_exports %]
35
                        <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=xsl.[% xsl_export.value | uri %]&amp;shelfid=[% shelf.shelfnumber | uri %]">XSL - [% xsl_export.filename | html %]</a></li>
35
                        <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=xsl.[% xsl_export.value | uri %]&amp;file=[% xsl_export.value | uri %]&amp;shelfid=[% shelf.shelfnumber | uri %]">XSL - [% xsl_export.filename | html %]</a></li>
36
                    [% END %]
36
                    [% END %]
37
                </ul>
37
                </ul>
38
        </div>
38
        </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt (-1 / +1 lines)
Lines 59-65 Link Here
59
                                <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=[% csv_profile.export_format_id | uri %]&amp;bib_list=[% bib_list | uri %]">CSV - [% csv_profile.profile | html %]</a></li>
59
                                <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=[% csv_profile.export_format_id | uri %]&amp;bib_list=[% bib_list | uri %]">CSV - [% csv_profile.profile | html %]</a></li>
60
                            [% END %]
60
                            [% END %]
61
                            [% FOREACH xsl_export IN xsl_exports %]
61
                            [% FOREACH xsl_export IN xsl_exports %]
62
                                <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=xsl.[% xsl_export.value | uri %]&amp;bib_list=[% bib_list | uri %]">XSL - [% xsl_export.filename | html %]</a></li>
62
                                <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=xsl.[% xsl_export.value | uri %]&amp;file=[% xsl_export.value | uri %]&amp;bib_list=[% bib_list | uri %]">XSL - [% xsl_export.filename | html %]</a></li>
63
                            [% END %]
63
                            [% END %]
64
                            </ul>
64
                            </ul>
65
                        </div>
65
                        </div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (-6 / +4 lines)
Lines 63-74 Link Here
63
            <div id="export">
63
            <div id="export">
64
                <div class="dropdown">
64
                <div class="dropdown">
65
                    <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>
65
                    <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>
66
                        <ul class="dropdown-menu pull-left" role="menu" aria-labelledby="format">
66
                        <div class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="format">
67
                            [% FOREACH option IN export_options %]
67
                            [% FOREACH option IN export_options %]
68
                                [% IF option == 'dc' %]
68
                                [% IF option == 'dc' %]
69
                                    <li><a role="menuitem" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li>
69
                                    <a role="menuitem" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a>
70
                                [% ELSIF option != 'custom' %]
70
                                [% ELSIF option != 'custom' %]
71
                                <li>
72
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
71
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
73
                                        [% SWITCH option %]
72
                                        [% SWITCH option %]
74
                                            [% CASE 'bibtex' %]BIBTEX
73
                                            [% CASE 'bibtex' %]BIBTEX
Lines 82-95 Link Here
82
                                            [% CASE 'isbd' %]ISBD
81
                                            [% CASE 'isbd' %]ISBD
83
                                        [% END %]
82
                                        [% END %]
84
                                    </a>
83
                                    </a>
85
                                </li>
86
                                [% ELSE %]
84
                                [% ELSE %]
87
                                    [% FOREACH filesOption IN filesOptions %]
85
                                    [% FOREACH filesOption IN filesOptions %]
88
                                        <li><a role="menuitem" href="/cgi-bin/koha/opac-export.pl?format=[% filesOption.format | html %]&amp;op=exportxsl&amp;file=[% filesOption.value | html %]&amp;bib=[% biblionumber | html %]">XSL - [% filesOption.filename | html %]</a></li>
86
                                        <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?format=[% filesOption.format | html %]&amp;op=exportxsl&amp;file=[% filesOption.value | html %]&amp;bib=[% biblionumber | html %]">XSL - [% filesOption.filename | html %]</a>
89
                                    [% END %]
87
                                    [% END %]
90
                                [% END %]
88
                                [% END %]
91
                            [% END %]
89
                            [% END %]
92
                        </ul>
90
                        </div>
93
                </div>
91
                </div>
94
            </div>
92
            </div>
95
        </li>
93
        </li>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt (+8 lines)
Lines 28-33 Link Here
28
                                    <a class="btn btn-link btn-sm send" href="opac-basket.pl"><i class="fa fa-fw fa-envelope" aria-hidden="true"></i> Send</a>
28
                                    <a class="btn btn-link btn-sm send" href="opac-basket.pl"><i class="fa fa-fw fa-envelope" aria-hidden="true"></i> Send</a>
29
                                [% END %]
29
                                [% END %]
30
30
31
                                [% SET export_options = Koha.Preference('OpacExportOptions').split(',') %]
31
                                <div id="download-cart" class="btn-group dropdown">
32
                                <div id="download-cart" class="btn-group dropdown">
32
                                    <a id="format" class="btn btn-link dropdown-toggle" data-toggle="dropdown" role="button" href="#"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Download <b class="caret"></b></a>
33
                                    <a id="format" class="btn btn-link dropdown-toggle" data-toggle="dropdown" role="button" href="#"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Download <b class="caret"></b></a>
33
                                    <div class="dropdown-menu" role="menu" aria-labelledby="format">
34
                                    <div class="dropdown-menu" role="menu" aria-labelledby="format">
Lines 38-43 Link Here
38
                                        [% FOREACH csv_profile IN csv_profiles %]
39
                                        [% FOREACH csv_profile IN csv_profiles %]
39
                                            <a role="menuitem" class="dropdown-item download-cart" data-format="[% csv_profile.export_format_id | html %]" href="#">CSV - [% csv_profile.profile | html %]</a>
40
                                            <a role="menuitem" class="dropdown-item download-cart" data-format="[% csv_profile.export_format_id | html %]" href="#">CSV - [% csv_profile.profile | html %]</a>
40
                                        [% END %]
41
                                        [% END %]
42
                                        [% FOREACH option IN export_options %]
43
                                            [% IF option == 'custom' %]
44
                                                [% FOREACH xsl_export IN xsl_exports %]
45
                                                    <a role="menuitem" class="dropdown-item" href="/cgi-bin/koha/opac-downloadcart.pl?format=xsl.[% xsl_export.value | uri %]&amp;file=[% xsl_export.value | uri %]&amp;bib_list=[% bib_list | uri %]">XSL - [% xsl_export.filename | html %]</a></li>
46
                                                [% END %]
47
                                            [% END %]
48
                                        [% END %]
41
                                    </div>
49
                                    </div>
42
                                </div>
50
                                </div>
43
51
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt (+8 lines)
Lines 222-227 Link Here
222
                                    <div class="list-actions">
222
                                    <div class="list-actions">
223
                                        <a class="btn btn-link newshelf" href="/cgi-bin/koha/opac-shelves.pl?op=add_form"><i class="fa fa-fw fa-plus" aria-hidden="true"></i> New list</a> <span class="sep">|</span>
223
                                        <a class="btn btn-link newshelf" href="/cgi-bin/koha/opac-shelves.pl?op=add_form"><i class="fa fa-fw fa-plus" aria-hidden="true"></i> New list</a> <span class="sep">|</span>
224
224
225
                                        [% SET export_options = Koha.Preference('OpacExportOptions').split(',') %]
225
                                        <div id="download-list" class="btn-group dropdown">
226
                                        <div id="download-list" class="btn-group dropdown">
226
                                            <a id="format" class="btn btn-link dropdown-toggle" data-toggle="dropdown" href="/cgi-bin/koha/opac-downloadshelf.pl?shelfnumber=[% shelf.shelfnumber | html %]"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Download <b class="caret"></b></a>
227
                                            <a id="format" class="btn btn-link dropdown-toggle" data-toggle="dropdown" href="/cgi-bin/koha/opac-downloadshelf.pl?shelfnumber=[% shelf.shelfnumber | html %]"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Download <b class="caret"></b></a>
227
                                            <div class="dropdown-menu pull-left" role="menu" aria-labelledby="format">
228
                                            <div class="dropdown-menu pull-left" role="menu" aria-labelledby="format">
Lines 232-237 Link Here
232
                                                [% FOREACH csv_profile IN csv_profiles %]
233
                                                [% FOREACH csv_profile IN csv_profiles %]
233
                                                    <a role="menuitem" class="dropdown-item download-list" data-format="[% csv_profile.export_format_id | html %]" href="#">CSV - [% csv_profile.profile | html %]</a>
234
                                                    <a role="menuitem" class="dropdown-item download-list" data-format="[% csv_profile.export_format_id | html %]" href="#">CSV - [% csv_profile.profile | html %]</a>
234
                                                [% END %]
235
                                                [% END %]
236
                                                [% FOREACH option IN export_options %]
237
                                                    [% IF option == 'custom' %]
238
                                                        [% FOREACH xsl_export IN xsl_exports %]
239
                                                            <a role="menuitem" class="dropdown-item" href="/cgi-bin/koha/opac-downloadshelf.pl?format=xsl.[% xsl_export.value | uri %]&amp;file=[% xsl_export.value | uri %]&amp;shelfnumber=[% shelf.shelfnumber | uri %]">XSL - [% xsl_export.filename | html %]</a></li>
240
                                                        [% END %]
241
                                                    [% END %]
242
                                                [% END %]
235
                                            </div>
243
                                            </div>
236
                                        </div>
244
                                        </div>
237
245
(-)a/opac/opac-basket.pl (+2 lines)
Lines 28-33 use C4::Biblio qw( Link Here
28
);
28
);
29
use C4::Auth qw( get_template_and_user );
29
use C4::Auth qw( get_template_and_user );
30
use C4::Output qw( output_html_with_http_headers );
30
use C4::Output qw( output_html_with_http_headers );
31
use C4::XSLT qw( CustomXSLTExportList );
31
use Koha::RecordProcessor;
32
use Koha::RecordProcessor;
32
use Koha::CsvProfiles;
33
use Koha::CsvProfiles;
33
use Koha::AuthorisedValues;
34
use Koha::AuthorisedValues;
Lines 154-159 $template->param( Link Here
154
        { type => 'marc', used_for => 'export_records', staff_only => 0 } ),
155
        { type => 'marc', used_for => 'export_records', staff_only => 0 } ),
155
    bib_list => $bib_list,
156
    bib_list => $bib_list,
156
    BIBLIO_RESULTS => $resultsarray,
157
    BIBLIO_RESULTS => $resultsarray,
158
    xsl_exports => CustomXSLTExportList(),
157
);
159
);
158
160
159
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
161
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
(-)a/opac/opac-detail.pl (-1 / +1 lines)
Lines 58-64 use C4::External::Syndetics qw( Link Here
58
    get_syndetics_toc
58
    get_syndetics_toc
59
);
59
);
60
use C4::Members;
60
use C4::Members;
61
use C4::XSLT qw( XSLTParse4Display );
61
use C4::XSLT qw( XSLTParse4Display CustomXSLTExportList );
62
use C4::ShelfBrowser qw( GetNearbyItems );
62
use C4::ShelfBrowser qw( GetNearbyItems );
63
use C4::Reserves qw( GetReserveStatus );
63
use C4::Reserves qw( GetReserveStatus );
64
use C4::Charset qw( SetUTF8Flag );
64
use C4::Charset qw( SetUTF8Flag );
(-)a/opac/opac-downloadcart.pl (-2 / +12 lines)
Lines 28-34 use C4::Output qw( output_html_with_http_headers ); Link Here
28
use C4::Record;
28
use C4::Record;
29
use C4::Ris qw( marc2ris );
29
use C4::Ris qw( marc2ris );
30
use Koha::Biblios;
30
use Koha::Biblios;
31
use C4::XSLT;
31
use C4::XSLT qw( XSLTParse4Display );
32
32
33
use Koha::CsvProfiles;
33
use Koha::CsvProfiles;
34
use Koha::RecordProcessor;
34
use Koha::RecordProcessor;
Lines 86-91 if ($bib_list && $format) { Link Here
86
                    patron      => $patron,
86
                    patron      => $patron,
87
                }
87
                }
88
            );
88
            );
89
            my $xslFile = $query->param("file");
89
            my $framework = &GetFrameworkCode( $biblio );
90
            my $framework = &GetFrameworkCode( $biblio );
90
            $record_processor->options({
91
            $record_processor->options({
91
                interface => 'opac',
92
                interface => 'opac',
Lines 117-123 if ($bib_list && $format) { Link Here
117
                $type      = "text/plain";
118
                $type      = "text/plain";
118
            }
119
            }
119
            elsif ($format =~ /^xsl\.(.*)$/) {
120
            elsif ($format =~ /^xsl\.(.*)$/) {
120
                $output .= XSLTParse4Display($biblio, $record, 'OPACXSLTCustomExport', 1, undef, undef, $1, '');
121
                $output .= XSLTParse4Display(
122
                   {
123
                     biblionumber   => $biblio,
124
                     record         => $record,
125
                     xsl_syspref    => "OPACXSLTCustomExport",
126
                     fix_amps       => 1,
127
                     hidden_items => undef,
128
                     xslfilename  => $xslFile,
129
                   }
130
               );
121
            }
131
            }
122
        }
132
        }
123
    }
133
    }
(-)a/opac/opac-downloadshelf.pl (-3 / +13 lines)
Lines 27-33 use C4::Output qw( output_html_with_http_headers ); Link Here
27
use C4::Record;
27
use C4::Record;
28
use C4::Ris qw( marc2ris );
28
use C4::Ris qw( marc2ris );
29
use Koha::Biblios;
29
use Koha::Biblios;
30
use C4::XSLT;
30
use C4::XSLT qw( XSLTParse4Display );
31
31
32
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
33
use Koha::RecordProcessor;
33
use Koha::RecordProcessor;
Lines 99-104 if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { Link Here
99
                        patron      => $patron,
99
                        patron      => $patron,
100
                    }
100
                    }
101
                );
101
                );
102
                my $xslFile = $query->param("file");
102
                my $framework = $biblio->frameworkcode;
103
                my $framework = $biblio->frameworkcode;
103
                $record_processor->options({
104
                $record_processor->options({
104
                    interface => 'opac',
105
                    interface => 'opac',
Lines 125-132 if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { Link Here
125
                    $extension = "txt";
126
                    $extension = "txt";
126
                    $type      = "text/plain";
127
                    $type      = "text/plain";
127
                }elsif ($format =~ /^xsl\.(.*)$/){
128
                }elsif ($format =~ /^xsl\.(.*)$/){
128
                         $output .= XSLTParse4Display($biblionumber, $record, 'XSLTCustomExport', 1, undef, undef, $1, '', 1);
129
                    $output .= XSLTParse4Display(
129
                    }
130
                        {
131
                          biblionumber => $biblionumber,
132
                          record => $record,
133
                          xsl_syspref  => "XSLTCustomExport",
134
                          fix_amps  => 1,
135
                          hidden_items => undef,
136
                          xslfilename  => $xslFile,
137
                        }
138
                    );
139
                }
130
            }
140
            }
131
        }
141
        }
132
142
(-)a/opac/opac-export.pl (-3 / +13 lines)
Lines 31-37 use CGI qw ( -utf8 ); Link Here
31
use C4::Auth;
31
use C4::Auth;
32
use C4::Ris qw( marc2ris );
32
use C4::Ris qw( marc2ris );
33
use Koha::Biblios;
33
use Koha::Biblios;
34
use C4::XSLT;
34
use C4::XSLT qw( XSLTParse4Display );
35
35
36
use Koha::RecordProcessor;
36
use Koha::RecordProcessor;
37
37
Lines 142-151 elsif ( $format =~ /isbd/ ) { Link Here
142
elsif ($format =~ /html/ ) {
142
elsif ($format =~ /html/ ) {
143
    if ($biblionumber){
143
    if ($biblionumber){
144
        my $xslFile = $query->param("file");
144
        my $xslFile = $query->param("file");
145
        $marc = C4::Biblio::GetMarcBiblio({biblionumber => $biblionumber});
145
        my $biblio = Koha::Biblios->find($biblionumber);
146
        $marc = $biblio->metadata->record;
146
        my @hiddenitems;
147
        my @hiddenitems;
147
148
148
        $marc = XSLTParse4Display($biblionumber, $marc, 'OPACXSLTCustomExport', 1, \@hiddenitems, undef, $xslFile, undef);
149
        $marc = XSLTParse4Display(
150
            {
151
              biblionumber => $biblionumber,
152
              record => $marc,
153
              xsl_syspref  => "OPACXSLTCustomExport",
154
              fix_amps  => 1,
155
              hidden_items => \@hiddenitems,
156
              xslfilename    => $xslFile,
157
            }
158
        );
149
    }
159
    }
150
}
160
}
151
else {
161
else {
(-)a/opac/opac-shelves.pl (-1 / +2 lines)
Lines 32-38 use C4::Koha qw( Link Here
32
use C4::Members;
32
use C4::Members;
33
use C4::Output qw( pagination_bar output_with_http_headers );
33
use C4::Output qw( pagination_bar output_with_http_headers );
34
use C4::Tags qw( get_tags );
34
use C4::Tags qw( get_tags );
35
use C4::XSLT qw( XSLTParse4Display );
35
use C4::XSLT qw( XSLTParse4Display CustomXSLTExportList );
36
36
37
use Koha::Biblios;
37
use Koha::Biblios;
38
use Koha::Biblioitems;
38
use Koha::Biblioitems;
Lines 491-496 $template->param( Link Here
491
    print    => scalar $query->param('print') || 0,
491
    print    => scalar $query->param('print') || 0,
492
    listsview => 1,
492
    listsview => 1,
493
    staffuser => $staffuser,
493
    staffuser => $staffuser,
494
    xsl_exports => CustomXSLTExportList()
494
);
495
);
495
496
496
my $content_type = $query->param('rss')? 'rss' : 'html';
497
my $content_type = $query->param('rss')? 'rss' : 'html';
(-)a/t/XSLT.t (-4 / +35 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 73-78 is(find_and_slurp($dir, 'test', 'fr-FR'), 'Theme test, language en', 'Fell ba Link Here
73
is(find_and_slurp($dir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES');
73
is(find_and_slurp($dir, 'nope', 'es-ES'), 'Theme prog, language es-ES', 'Fell back to prog/es-ES for nope/es-ES');
74
is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en',    'Fell back to prog/en for nope/fr-FR');
74
is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en',    'Fell back to prog/en for nope/fr-FR');
75
75
76
my $matching_string = q{<syspref name="singleBranchMode">0</syspref>};
76
my $matching_string = q{<syspref name="singleBranchMode">[0|1]</syspref>};
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 no value');
79
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");
(-)a/t/db_dependent/XSLT.t (+1 lines)
Lines 33-38 BEGIN { Link Here
33
33
34
my $schema  = Koha::Database->new->schema;
34
my $schema  = Koha::Database->new->schema;
35
my $builder = t::lib::TestBuilder->new;
35
my $builder = t::lib::TestBuilder->new;
36
our $cache = Koha::Caches->get_instance;
36
37
37
$schema->storage->txn_begin;
38
$schema->storage->txn_begin;
38
39
(-)a/virtualshelves/downloadshelf.pl (-2 / +12 lines)
Lines 25-31 use C4::Auth qw( get_template_and_user ); Link Here
25
use C4::Output qw( output_html_with_http_headers );
25
use C4::Output qw( output_html_with_http_headers );
26
use C4::Record;
26
use C4::Record;
27
use C4::Ris qw( marc2ris );
27
use C4::Ris qw( marc2ris );
28
use C4::XSLT;
28
use C4::XSLT qw( XSLTParse4Display );
29
29
30
30
31
use Koha::Biblios;
31
use Koha::Biblios;
Lines 72-77 if ($shelfid && $format) { Link Here
72
                    my $biblionumber = $content->biblionumber;
72
                    my $biblionumber = $content->biblionumber;
73
                    my $biblio = Koha::Biblios->find($biblionumber);
73
                    my $biblio = Koha::Biblios->find($biblionumber);
74
                    my $record = $biblio->metadata->record({ embed_items => 1 });
74
                    my $record = $biblio->metadata->record({ embed_items => 1 });
75
                    my $xslFile = $query->param("file");
75
                    if ($format eq 'iso2709') {
76
                    if ($format eq 'iso2709') {
76
                        $output .= $record->as_usmarc();
77
                        $output .= $record->as_usmarc();
77
                    }
78
                    }
Lines 82-88 if ($shelfid && $format) { Link Here
82
                        $output .= marc2bibtex($record, $biblionumber);
83
                        $output .= marc2bibtex($record, $biblionumber);
83
                    }
84
                    }
84
                    elsif ($format =~ /^xsl\.(.*)$/){
85
                    elsif ($format =~ /^xsl\.(.*)$/){
85
                        $output .= XSLTParse4Display($biblionumber, $record, 'XSLTCustomExport', 1, undef, ,'',$1,'');
86
                        $output .= XSLTParse4Display(
87
                        {
88
                            biblionumber => $biblionumber,
89
                            record => $record,
90
                            xsl_syspref  => 'XSLTCustomExport',
91
                            fix_amps     => 1,
92
                            hidden_items => undef,
93
                            xslfilename  => $xslFile,
94
                        }
95
                      );
86
                    }
96
                    }
87
                }
97
                }
88
            }
98
            }
(-)a/virtualshelves/shelves.pl (-2 / +1 lines)
Lines 30-36 use C4::Koha qw( Link Here
30
);
30
);
31
use C4::Members;
31
use C4::Members;
32
use C4::Output qw( pagination_bar output_html_with_http_headers );
32
use C4::Output qw( pagination_bar output_html_with_http_headers );
33
use C4::XSLT qw( XSLTParse4Display );
33
use C4::XSLT qw( XSLTParse4Display CustomXSLTExportList );
34
34
35
use Koha::Biblios;
35
use Koha::Biblios;
36
use Koha::Biblioitems;
36
use Koha::Biblioitems;
37
- 

Return to bug 17385