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

(-)a/C4/XSLT.pm (-2 / +32 lines)
Lines 32-37 use Koha::XSLT::Base; Link Here
32
use Koha::Libraries;
32
use Koha::Libraries;
33
use Koha::Recalls;
33
use Koha::Recalls;
34
34
35
36
use XML::LibXML;
37
38
use Encode;
39
40
use vars qw(@ISA @EXPORT);
41
42
35
my $engine; #XSLT Handler object
43
my $engine; #XSLT Handler object
36
my %authval_per_framework;
44
my %authval_per_framework;
37
    # Cache for tagfield-tagsubfield to decode per framework.
45
    # Cache for tagfield-tagsubfield to decode per framework.
Lines 46-51 BEGIN { Link Here
46
        getAuthorisedValues4MARCSubfields
54
        getAuthorisedValues4MARCSubfields
47
        buildKohaItemsNamespace
55
        buildKohaItemsNamespace
48
        XSLTParse4Display
56
        XSLTParse4Display
57
        &CustomXSLTExportList
49
    );
58
    );
50
    $engine=Koha::XSLT::Base->new( { do_not_return_source => 1 } );
59
    $engine=Koha::XSLT::Base->new( { do_not_return_source => 1 } );
51
}
60
}
Lines 157-162 sub _get_best_default_xslt_filename { Link Here
157
    return $xslfilename;
166
    return $xslfilename;
158
}
167
}
159
168
169
=head2 get_xslt_sysprefs
170
171
    returns XML xslt sysprefs.
172
173
=cut
174
160
sub get_xslt_sysprefs {
175
sub get_xslt_sysprefs {
161
    my $sysxml = "<sysprefs>\n";
176
    my $sysxml = "<sysprefs>\n";
162
    foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow
177
    foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow
Lines 194-200 sub get_xsl_filename { Link Here
194
209
195
    my $xslfilename = C4::Context->preference($xslsyspref) || "default";
210
    my $xslfilename = C4::Context->preference($xslsyspref) || "default";
196
211
197
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
212
    if ($xslsyspref eq "XSLTCustomExport") {
213
        my $dir;
214
        $dir = C4::Context->config('intrahtdocs') .
215
            '/' . C4::Context->preference("template") .
216
            '/' . C4::Languages::getlanguage() .
217
            '/xslt/biblioexport';
218
        $xslfilename = $dir . "/" . $xslfilename;
219
    } elsif ($xslsyspref eq "OPACXSLTCustomExport") {
220
        my $dir;
221
        $dir = C4::Context->config('opachtdocs') .
222
            '/' . C4::Context->preference("opacthemes") .
223
            '/' . C4::Languages::getlanguage() .
224
            '/xslt/biblioexport';
225
        $xslfilename = $dir . "/" . $xslfilename;
226
    } elsif ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
198
227
199
        my ( $htdocs, $theme, $xslfile );
228
        my ( $htdocs, $theme, $xslfile );
200
229
Lines 267-274 sub XSLTParse4Display { Link Here
267
    }
296
    }
268
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
297
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
269
298
270
    $variables ||= {};
271
    my $biblio;
299
    my $biblio;
300
    my $variables ||= {};
301
272
    if (C4::Context->preference('OPACShowOpenURL')) {
302
    if (C4::Context->preference('OPACShowOpenURL')) {
273
        my @biblio_itemtypes;
303
        my @biblio_itemtypes;
274
        $biblio //= Koha::Biblios->find($biblionumber);
304
        $biblio //= Koha::Biblios->find($biblionumber);
(-)a/basket/basket.pl (+4 lines)
Lines 19-24 Link Here
19
use Modern::Perl;
19
use Modern::Perl;
20
use CGI qw ( -utf8 );
20
use CGI qw ( -utf8 );
21
use C4::Koha;
21
use C4::Koha;
22
22
use C4::Biblio qw(
23
use C4::Biblio qw(
23
    GetMarcBiblio
24
    GetMarcBiblio
24
    GetMarcSeries
25
    GetMarcSeries
Lines 28-33 use C4::Biblio qw( Link Here
28
use C4::Items qw( GetItemsInfo );
29
use C4::Items qw( GetItemsInfo );
29
use C4::Auth qw( get_template_and_user );
30
use C4::Auth qw( get_template_and_user );
30
use C4::Output qw( output_html_with_http_headers );
31
use C4::Output qw( output_html_with_http_headers );
32
use C4::XSLT;
33
31
34
32
use Koha::AuthorisedValues;
35
use Koha::AuthorisedValues;
33
use Koha::Biblios;
36
use Koha::Biblios;
Lines 118-123 my $resultsarray = \@results; Link Here
118
$template->param(
121
$template->param(
119
    BIBLIO_RESULTS => $resultsarray,
122
    BIBLIO_RESULTS => $resultsarray,
120
    csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }),
123
    csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }),
124
    xsl_exports => CustomXSLTExportList(),
121
    bib_list => $bib_list,
125
    bib_list => $bib_list,
122
);
126
);
123
127
(-)a/basket/downloadcart.pl (+6 lines)
Lines 27-32 use C4::Biblio qw( GetMarcBiblio ); Link Here
27
use C4::Output qw( output_html_with_http_headers );
27
use C4::Output qw( output_html_with_http_headers );
28
use C4::Record;
28
use C4::Record;
29
use C4::Ris qw( marc2ris );
29
use C4::Ris qw( marc2ris );
30
use C4::XSLT;
30
31
31
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
32
33
Lines 79-89 if ($bib_list && $format) { Link Here
79
            elsif ($format eq 'bibtex') {
80
            elsif ($format eq 'bibtex') {
80
                $output .= marc2bibtex($record, $biblio);
81
                $output .= marc2bibtex($record, $biblio);
81
            }
82
            }
83
            elsif ($format =~ /^xsl\.(.*)$/) {
84
                $output .= XSLTParse4Display($biblio, $record, 'XSLTCustomExport', 1, undef, , '', $1, '');
85
            }
82
        }
86
        }
83
    }
87
    }
84
88
85
    # If it was a CSV export we change the format after the export so the file extension is fine
89
    # If it was a CSV export we change the format after the export so the file extension is fine
86
    $format = "csv" if ($format =~ m/^\d+$/);
90
    $format = "csv" if ($format =~ m/^\d+$/);
91
    $format = "html" if ($format =~ /^xsl\./);
87
92
88
    print $query->header(
93
    print $query->header(
89
	-type => 'application/octet-stream',
94
	-type => 'application/octet-stream',
Lines 93-98 if ($bib_list && $format) { Link Here
93
98
94
} else { 
99
} else { 
95
    $template->param(csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }));
100
    $template->param(csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }));
101
    $template->param(xsl_exports => CustomXSLTExportList());
96
    $template->param(bib_list => $bib_list); 
102
    $template->param(bib_list => $bib_list); 
97
    output_html_with_http_headers $query, $cookie, $template->output;
103
    output_html_with_http_headers $query, $cookie, $template->output;
98
}
104
}
(-)a/catalogue/detail.pl (+3 lines)
Lines 82-87 if ( C4::Context->config('enable_plugins') ) { Link Here
82
    );
82
    );
83
}
83
}
84
84
85
##### ADD CUSTOM XSLT
86
$template->param(filesOptions => CustomXSLTExportList(0));
87
85
my $biblionumber = $query->param('biblionumber');
88
my $biblionumber = $query->param('biblionumber');
86
$biblionumber = HTML::Entities::encode($biblionumber);
89
$biblionumber = HTML::Entities::encode($biblionumber);
87
my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
90
my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
(-)a/catalogue/export.pl (+16 lines)
Lines 7-12 use C4::Output; Link Here
7
use C4::Biblio qw( GetMarcBiblio GetMarcControlnumber );
7
use C4::Biblio qw( GetMarcBiblio 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;
11
10
12
11
13
12
14
Lines 87-90 if ($op eq "export") { Link Here
87
                -attachment=>"$file_pre$file_id.$format");
89
                -attachment=>"$file_pre$file_id.$format");
88
            print $marc;
90
            print $marc;
89
        }
91
        }
92
}elsif ($op eq "exportxsl"){
93
    my $biblionumber = $query->param("bib");
94
    if ($biblionumber){
95
        my $xslFile = $query->param("file");
96
        my $marc = GetMarcBiblio( { biblionumber => $biblionumber, embed_items => 1 } );
97
        my $format=$query->param("format")||'txt';
98
        my @hiddenitems;
99
100
        $marc = XSLTParse4Display($biblionumber, $marc, 'XSLTCustomExport', 1, \@hiddenitems, '', $xslFile,'');
101
        print $query->header(
102
            -type => 'application/octet-stream',
103
            -attachment=>"bib-$biblionumber.$format");
104
        print $marc;
105
    }
90
}
106
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (+3 lines)
Lines 102-107 Link Here
102
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcstd&amp;op=export&amp;bib=[% biblionumber | uri %]">MARC (Unicode/UTF-8, Standard)</a></li>
102
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcstd&amp;op=export&amp;bib=[% biblionumber | uri %]">MARC (Unicode/UTF-8, Standard)</a></li>
103
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=mods&amp;op=export&amp;bib=[% biblionumber | uri %]">MODS (XML)</a></li>
103
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=mods&amp;op=export&amp;bib=[% biblionumber | uri %]">MODS (XML)</a></li>
104
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=ris&amp;op=export&amp;bib=[% biblionumber | uri %]">RIS</a></li>
104
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=ris&amp;op=export&amp;bib=[% biblionumber | uri %]">RIS</a></li>
105
        [% FOREACH filesOption IN filesOptions %]
106
            <li><a href="/cgi-bin/koha/catalogue/export.pl?format=[% filesOption.format | uri %]&amp;op=exportxsl&amp;file=[% filesOption.value | uri %]&amp;bib=[% biblionumber | uri %]">XSL - [% filesOption.filename | html %]</a></li>
107
        [% END %]
105
    </ul>
108
    </ul>
106
    </div>
109
    </div>
107
110
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc (+3 lines)
Lines 31-36 Link Here
31
                    [% FOREACH csv_profile IN csv_profiles %]
31
                    [% FOREACH csv_profile IN csv_profiles %]
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 %]
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>
36
                    [% END %]
34
                </ul>
37
                </ul>
35
        </div>
38
        </div>
36
        <div class="btn-group"><a class="btn btn-default" href="#" id="sendlist"><i class="fa fa-envelope"></i> Send list</a></div>
39
        <div class="btn-group"><a class="btn btn-default" href="#" id="sendlist"><i class="fa fa-envelope"></i> Send list</a></div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+1 lines)
Lines 280-285 OPAC: Link Here
280
                mods: MODS
280
                mods: MODS
281
                ris: RIS
281
                ris: RIS
282
                isbd: ISBD
282
                isbd: ISBD
283
                custom: XSL - Simple Export
283
        -
284
        -
284
            - pref: OpacSeparateHoldings
285
            - pref: OpacSeparateHoldings
285
              choices:
286
              choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt (+3 lines)
Lines 56-61 Link Here
56
                            [% FOREACH csv_profile IN csv_profiles %]
56
                            [% FOREACH csv_profile IN csv_profiles %]
57
                                <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>
57
                                <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>
58
                            [% END %]
58
                            [% END %]
59
                            [% FOREACH xsl_export IN xsl_exports %]
60
                                <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>
61
                            [% END %]
59
                            </ul>
62
                            </ul>
60
                        </div>
63
                        </div>
61
                        <a class="btn btn-default" href="basket.pl" id="print_cart"><i class="fa fa-print"></i> Print</a>
64
                        <a class="btn btn-default" href="basket.pl" id="print_cart"><i class="fa fa-print"></i> Print</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +5 lines)
Lines 1014-1021 Note that permanent location is a code, and location may be an authval. Link Here
1014
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
1014
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
1015
        <option value="marcxml">MARCXML</option>
1015
        <option value="marcxml">MARCXML</option>
1016
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1016
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1017
        <option value="utf8">MARC (Unicode/UTF-8)</option>    </select>
1017
        <option value="utf8">MARC (Unicode/UTF-8)</option>
1018
        <input type="submit" name="save" value="Download record" /></td>
1018
        [% FOREACH filesOption IN filesOptions %]
1019
            <option value="[% filesOption.value | html %]">XSL -[% filesOption.filename | html %]</option>
1020
        [% END %]</select>
1021
        <input type="submit" name="save" value="Download Record" /></td>
1019
  </tr>
1022
  </tr>
1020
  <tr><td>
1023
  <tr><td>
1021
    <input type="hidden" name="op" value="export" /><input type="hidden" name="bib" value="[% biblionumber | html %]" />
1024
    <input type="hidden" name="op" value="export" /><input type="hidden" name="bib" value="[% biblionumber | html %]" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tt (+3 lines)
Lines 36-41 Link Here
36
	    [% FOREACH csv_profile IN csv_profiles %]
36
	    [% FOREACH csv_profile IN csv_profiles %]
37
	    <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
37
	    <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
38
	    [% END %]
38
	    [% END %]
39
        [% FOREACH xsl_export IN xsl_exports %]
40
            <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option>
41
        [% END %]
39
	</select>
42
	</select>
40
	</li></ol>
43
	</li></ol>
41
	</fieldset>
44
	</fieldset>
(-)a/koha-tmpl/intranet-tmpl/prog/en/xslt/biblioexport/MARC21_simple_export.xsl (+62 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet version="1.0"
3
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
   xmlns:marc="http://www.loc.gov/MARC21/slim"
5
   title="Simple Export">
6
<xsl:output method="html" encoding="UTF-8"/>
7
8
    <xsl:template match="/">
9
      <xsl:apply-templates/>
10
    </xsl:template>
11
12
    <xsl:template match="marc:record">
13
      <p>
14
        <xsl:if test="marc:datafield[@tag=245]">
15
        <xsl:for-each select="marc:datafield[@tag=245]">
16
            <xsl:value-of select="marc:subfield[@code='a']"/>
17
            <xsl:if test="marc:subfield[@code='b']">
18
                 <xsl:text> </xsl:text>
19
                 <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of>
20
            </xsl:if>
21
            <xsl:if test="marc:subfield[@code='c']">
22
                  <xsl:text> </xsl:text>
23
                  <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of>
24
            </xsl:if>
25
        </xsl:for-each>
26
        </xsl:if>
27
        <xsl:if test="marc:datafield[@tag=260]">
28
        <br/>
29
        <xsl:for-each select="marc:datafield[@tag=260]">
30
            <xsl:if test="marc:subfield[@code='a']">
31
                 <xsl:value-of select="marc:subfield[@code='a']"/>
32
            </xsl:if>
33
            <xsl:if test="marc:subfield[@code='b']">
34
                 <xsl:text> </xsl:text>
35
                 <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of>
36
            </xsl:if>
37
            <xsl:if test="marc:subfield[@code='c']">
38
                  <xsl:text> </xsl:text>
39
                  <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of>
40
            </xsl:if>
41
        </xsl:for-each>
42
        </xsl:if>
43
        <xsl:if test="marc:datafield[@tag=264]">
44
        <br/>
45
        <xsl:for-each select="marc:datafield[@tag=264]">
46
            <xsl:if test="marc:subfield[@code='a']">
47
                 <xsl:value-of select="marc:subfield[@code='a']"/>
48
            </xsl:if>
49
            <xsl:if test="marc:subfield[@code='b']">
50
                 <xsl:text> </xsl:text>
51
                 <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of>
52
            </xsl:if>
53
            <xsl:if test="marc:subfield[@code='c']">
54
                  <xsl:text> </xsl:text>
55
                  <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of>
56
            </xsl:if>
57
        </xsl:for-each>
58
        </xsl:if>
59
      </p>
60
    </xsl:template>
61
62
</xsl:stylesheet>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (-22 / +28 lines)
Lines 62-91 Link Here
62
        <li>
62
        <li>
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" aria-hidden="true"></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
                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="format">
66
                        <ul class="dropdown-menu pull-left" 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
                                <a class="dropdown-item" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a>
69
                                    <li><a role="menuitem" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li>
70
                            [% ELSE %]
70
                                [% ELSIF option != 'custom' %]
71
                                <a class="dropdown-item" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
71
                                <li>
72
                                    [% SWITCH option %]
72
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
73
                                        [% CASE 'bibtex' %]<span>BIBTEX</span>
73
                                        [% SWITCH option %]
74
                                        [% CASE 'endnote' %]<span>EndNote</span>
74
                                            [% CASE 'bibtex' %]BIBTEX
75
                                        [% CASE 'marcxml' %]<span>MARCXML</span>
75
                                            [% CASE 'endnote' %]EndNote
76
                                        [% CASE 'marc8' %]<span>MARC (non-Unicode/MARC-8)</span>
76
                                            [% CASE 'marcxml' %]MARCXML
77
                                        [% CASE 'utf8' %]<span>MARC (Unicode/UTF-8)</span>
77
                                            [% CASE 'marc8' %]MARC (non-Unicode/MARC-8)
78
                                        [% CASE 'marcstd' %]<span>MARC (Unicode/UTF-8, Standard)</span>
78
                                            [% CASE 'utf8' %]MARC (Unicode/UTF-8)
79
                                        [% CASE 'mods' %]<span>MODS (XML)</span>
79
                                            [% CASE 'marcstd' %]MARC (Unicode/UTF-8, Standard)
80
                                        [% CASE 'ris' %]<span>RIS</span>
80
                                            [% CASE 'mods' %]MODS (XML)
81
                                        [% CASE 'isbd' %]<span>ISBD</span>
81
                                            [% CASE 'ris' %]RIS
82
                                            [% CASE 'isbd' %]ISBD
83
                                        [% END %]
84
                                    </a>
85
                                </li>
86
                                [% ELSE %]
87
                                    [% 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>
82
                                    [% END %]
89
                                    [% END %]
83
                                </a>
90
                                [% END %]
84
                            [% END %]
91
                            [% END %]
85
                        [% END %]
92
                        </ul>
86
                    </div> <!-- /.dropdown-menu -->
93
                </div>
87
                </div> <!-- /.dropdown -->
94
            </div>
88
            </div> <!-- /#export -->
89
        </li>
95
        </li>
90
    [% END %]
96
    [% END %]
91
97
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt (+3 lines)
Lines 20-25 Link Here
20
                                [% FOREACH csv_profile IN csv_profiles %]
20
                                [% FOREACH csv_profile IN csv_profiles %]
21
                                    <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
21
                                    <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
22
                                [% END %]
22
                                [% END %]
23
                                [% FOREACH xsl_export IN xsl_exports %]
24
                                    <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option>
25
                                [% END %]
23
                            </select>
26
                            </select>
24
                            <fieldset class="action">
27
                            <fieldset class="action">
25
                                <input type="hidden" name="bib_list" value="[% bib_list | html %]" />
28
                                <input type="hidden" name="bib_list" value="[% bib_list | html %]" />
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt (+3 lines)
Lines 70-75 Link Here
70
                                            [% FOREACH csv_profile IN csv_profiles %]
70
                                            [% FOREACH csv_profile IN csv_profiles %]
71
                                            <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
71
                                            <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
72
                                            [% END %]
72
                                            [% END %]
73
                                            [% FOREACH xsl_export IN xsl_exports %]
74
                                                <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option>
75
                                            [% END %]
73
                                        </select>
76
                                        </select>
74
                                        <span class="required">Required</span>
77
                                        <span class="required">Required</span>
75
                                    </fieldset>
78
                                    </fieldset>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport/MARC21_simple_export.xsl (+62 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet version="1.0"
3
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
   xmlns:marc="http://www.loc.gov/MARC21/slim"
5
   title="Simple Export">
6
<xsl:output method="html" encoding="UTF-8"/>
7
8
    <xsl:template match="/">
9
      <xsl:apply-templates/>
10
    </xsl:template>
11
12
    <xsl:template match="marc:record">
13
      <p>
14
        <xsl:if test="marc:datafield[@tag=245]">
15
        <xsl:for-each select="marc:datafield[@tag=245]">
16
            <xsl:value-of select="marc:subfield[@code='a']"/>
17
            <xsl:if test="marc:subfield[@code='b']">
18
                 <xsl:text> </xsl:text>
19
                 <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of>
20
            </xsl:if>
21
            <xsl:if test="marc:subfield[@code='c']">
22
                  <xsl:text> </xsl:text>
23
                  <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of>
24
            </xsl:if>
25
        </xsl:for-each>
26
        </xsl:if>
27
        <xsl:if test="marc:datafield[@tag=260]">
28
        <br/>
29
        <xsl:for-each select="marc:datafield[@tag=260]">
30
            <xsl:if test="marc:subfield[@code='a']">
31
                 <xsl:value-of select="marc:subfield[@code='a']"/>
32
            </xsl:if>
33
            <xsl:if test="marc:subfield[@code='b']">
34
                 <xsl:text> </xsl:text>
35
                 <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of>
36
            </xsl:if>
37
            <xsl:if test="marc:subfield[@code='c']">
38
                  <xsl:text> </xsl:text>
39
                  <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of>
40
            </xsl:if>
41
        </xsl:for-each>
42
        </xsl:if>
43
        <xsl:if test="marc:datafield[@tag=264]">
44
        <br/>
45
        <xsl:for-each select="marc:datafield[@tag=264]">
46
            <xsl:if test="marc:subfield[@code='a']">
47
                 <xsl:value-of select="marc:subfield[@code='a']"/>
48
            </xsl:if>
49
            <xsl:if test="marc:subfield[@code='b']">
50
                 <xsl:text> </xsl:text>
51
                 <xsl:value-of select="marc:subfield[@code='b']"></xsl:value-of>
52
            </xsl:if>
53
            <xsl:if test="marc:subfield[@code='c']">
54
                  <xsl:text> </xsl:text>
55
                  <xsl:value-of select="marc:subfield[@code='c']"></xsl:value-of>
56
            </xsl:if>
57
        </xsl:for-each>
58
        </xsl:if>
59
      </p>
60
    </xsl:template>
61
62
</xsl:stylesheet>
(-)a/opac/opac-detail.pl (+3 lines)
Lines 104-109 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
104
    }
104
    }
105
);
105
);
106
106
107
#### ADD CUSTOM XSLT
108
$template->param(filesOptions => CustomXSLTExportList(1));
109
107
my @all_items = GetItemsInfo($biblionumber);
110
my @all_items = GetItemsInfo($biblionumber);
108
if( $specific_item ) {
111
if( $specific_item ) {
109
    @all_items = grep { $_->{itemnumber} == $query->param('itemnumber') } @all_items;
112
    @all_items = grep { $_->{itemnumber} == $query->param('itemnumber') } @all_items;
(-)a/opac/opac-downloadcart.pl (+8 lines)
Lines 27-32 use C4::Biblio qw( GetFrameworkCode GetISBDView GetMarcBiblio ); Link Here
27
use C4::Output qw( output_html_with_http_headers );
27
use C4::Output qw( output_html_with_http_headers );
28
use C4::Record;
28
use C4::Record;
29
use C4::Ris qw( marc2ris );
29
use C4::Ris qw( marc2ris );
30
use C4::XSLT;
31
30
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
31
use Koha::RecordProcessor;
33
use Koha::RecordProcessor;
32
34
Lines 115-125 if ($bib_list && $format) { Link Here
115
                $extension = "txt";
117
                $extension = "txt";
116
                $type      = "text/plain";
118
                $type      = "text/plain";
117
            }
119
            }
120
            elsif ($format =~ /^xsl\.(.*)$/) {
121
                $output .= XSLTParse4Display($biblio, $record, 'OPACXSLTCustomExport', 1, undef, undef, $1, '');
122
            }
118
        }
123
        }
119
    }
124
    }
120
125
121
    # If it was a CSV export we change the format after the export so the file extension is fine
126
    # If it was a CSV export we change the format after the export so the file extension is fine
122
    $format = "csv" if ($format =~ m/^\d+$/);
127
    $format = "csv" if ($format =~ m/^\d+$/);
128
    $format = "html" if ($format =~ /^xsl\./);
123
129
124
    print $query->header(
130
    print $query->header(
125
                               -type => ($type) ? $type : 'application/octet-stream',
131
                               -type => ($type) ? $type : 'application/octet-stream',
Lines 139-143 if ($bib_list && $format) { Link Here
139
        ),
145
        ),
140
        bib_list => $bib_list,
146
        bib_list => $bib_list,
141
    );
147
    );
148
    $template->param(bib_list => $bib_list);
149
    $template->param(xsl_exports => CustomXSLTExportList());
142
    output_html_with_http_headers $query, $cookie, $template->output;
150
    output_html_with_http_headers $query, $cookie, $template->output;
143
}
151
}
(-)a/opac/opac-downloadshelf.pl (-2 / +8 lines)
Lines 26-31 use C4::Biblio qw( GetFrameworkCode GetISBDView GetMarcBiblio ); 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;
30
29
use Koha::CsvProfiles;
31
use Koha::CsvProfiles;
30
use Koha::RecordProcessor;
32
use Koha::RecordProcessor;
31
use Koha::Virtualshelves;
33
use Koha::Virtualshelves;
Lines 123-135 if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { Link Here
123
                    });
125
                    });
124
                    $extension = "txt";
126
                    $extension = "txt";
125
                    $type      = "text/plain";
127
                    $type      = "text/plain";
126
                }
128
                }elsif ($format =~ /^xsl\.(.*)$/){
129
                         $output .= XSLTParse4Display($biblionumber, $record, 'XSLTCustomExport', 1, undef, undef, $1, '', 1);
130
                    }
127
            }
131
            }
128
        }
132
        }
129
133
130
        # If it was a CSV export we change the format after the export so the file extension is fine
134
        # If it was a CSV export we change the format after the export so the file extension is fine
131
        $format = "csv" if ($format =~ m/^\d+$/);
135
        $format = "csv" if ($format =~ m/^\d+$/);
132
136
        $format = "html" if ($format =~ /^xsl\./);
133
        print $query->header(
137
        print $query->header(
134
                                   -type => ($type) ? $type : 'application/octet-stream',
138
                                   -type => ($type) ? $type : 'application/octet-stream',
135
            -'Content-Transfer-Encoding' => 'binary',
139
            -'Content-Transfer-Encoding' => 'binary',
Lines 155-160 if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { Link Here
155
            ),
159
            ),
156
            shelf => $shelf,
160
            shelf => $shelf,
157
        );
161
        );
162
        $template->param(xsl_exports => CustomXSLTExportList());
163
        $template->param( shelf => $shelf );
158
        output_html_with_http_headers $query, $cookie, $template->output;
164
        output_html_with_http_headers $query, $cookie, $template->output;
159
    }
165
    }
160
166
(-)a/opac/opac-export.pl (+11 lines)
Lines 31-36 use C4::Biblio qw( Link Here
31
use CGI qw ( -utf8 );
31
use CGI qw ( -utf8 );
32
use C4::Auth;
32
use C4::Auth;
33
use C4::Ris qw( marc2ris );
33
use C4::Ris qw( marc2ris );
34
use C4::XSLT;
35
34
use Koha::RecordProcessor;
36
use Koha::RecordProcessor;
35
37
36
my $query = CGI->new;
38
my $query = CGI->new;
Lines 136-141 elsif ( $format =~ /isbd/ ) { Link Here
136
    });
138
    });
137
    $format = 'isbd';
139
    $format = 'isbd';
138
}
140
}
141
elsif ($format =~ /html/ ) {
142
    if ($biblionumber){
143
        my $xslFile = $query->param("file");
144
        $marc = C4::Biblio::GetMarcBiblio({biblionumber => $biblionumber});
145
        my @hiddenitems;
146
147
        $marc = XSLTParse4Display($biblionumber, $marc, 'OPACXSLTCustomExport', 1, \@hiddenitems, undef, $xslFile, undef);
148
    }
149
}
139
else {
150
else {
140
    $error= "Format $format is not supported.";
151
    $error= "Format $format is not supported.";
141
}
152
}
(-)a/t/XSLT.t (-2 / +1 lines)
Lines 75-79 is(find_and_slurp($dir, 'nope', 'fr-FR'), 'Theme prog, language en', 'Fell ba Link Here
75
75
76
my $matching_string = q{<syspref name="singleBranchMode">0</syspref>};
76
my $matching_string = q{<syspref name="singleBranchMode">0</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 a value of 0');
79
(-)a/t/db_dependent/XSLT.t (-1 / +22 lines)
Lines 155-161 subtest 'buildKohaItemsNamespace status tests' => sub { Link Here
155
    t::lib::Mocks::mock_preference('UseRecalls', 0);
155
    t::lib::Mocks::mock_preference('UseRecalls', 0);
156
156
157
};
157
};
158
158
subtest  'CustomXSLTExportList: Caching' => sub {
159
    plan tests => 1;
160
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
161
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
162
    my $list = C4::XSLT::CustomXSLTExportList(1);
163
    push @$list, { nonsense => 1 };
164
    $cache->set_in_cache('CustomXSLTExportListOPAC', $list );
165
    my $n = @$list;
166
    $list = C4::XSLT::CustomXSLTExportList(1);
167
    is( @$list, $n, 'This list comes from the cache and that is fine' );
168
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
169
};
170
subtest 'CustomXSLTExportList: Check export options' => sub {
171
    plan tests => 2;
172
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
173
    my $list = C4::XSLT::CustomXSLTExportList(1);
174
    is( $list>0, 1, 'We expect at least one result: simple export' );
175
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
176
    t::lib::Mocks::mock_preference('OpacExportOptions', 'dc');
177
    $list = C4::XSLT::CustomXSLTExportList(1);
178
    is( @$list, 0, 'We expect an empty list now' );
179
};
159
$schema->storage->txn_rollback;
180
$schema->storage->txn_rollback;
160
181
161
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
182
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
(-)a/virtualshelves/downloadshelf.pl (-1 / +6 lines)
Lines 26-31 use C4::Biblio qw( GetMarcBiblio ); 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;
30
29
31
30
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
31
use Koha::Virtualshelves;
33
use Koha::Virtualshelves;
Lines 80-91 if ($shelfid && $format) { Link Here
80
                    elsif ($format eq 'bibtex') {
82
                    elsif ($format eq 'bibtex') {
81
                        $output .= marc2bibtex($record, $biblionumber);
83
                        $output .= marc2bibtex($record, $biblionumber);
82
                    }
84
                    }
85
                    elsif ($format =~ /^xsl\.(.*)$/){
86
                        $output .= XSLTParse4Display($biblionumber, $record, 'XSLTCustomExport', 1, undef, ,'',$1,'');
87
                    }
83
                }
88
                }
84
            }
89
            }
85
90
86
            # If it was a CSV export we change the format after the export so the file extension is fine
91
            # If it was a CSV export we change the format after the export so the file extension is fine
87
            $format = "csv" if ($format =~ m/^\d+$/);
92
            $format = "csv" if ($format =~ m/^\d+$/);
88
93
            $format = "html" if ($format =~ /^xsl\./);
89
            print $query->header(
94
            print $query->header(
90
            -type => 'application/octet-stream',
95
            -type => 'application/octet-stream',
91
            -'Content-Transfer-Encoding' => 'binary',
96
            -'Content-Transfer-Encoding' => 'binary',
(-)a/virtualshelves/shelves.pl (-1 / +1 lines)
Lines 362-367 $template->param( Link Here
362
    public   => $public,
362
    public   => $public,
363
    print    => scalar $query->param('print') || 0,
363
    print    => scalar $query->param('print') || 0,
364
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' })->as_list ],
364
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' })->as_list ],
365
    xsl_exports => CustomXSLTExportList()
365
);
366
);
366
367
367
output_html_with_http_headers $query, $cookie, $template->output;
368
output_html_with_http_headers $query, $cookie, $template->output;
368
- 

Return to bug 17385