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

(-)a/C4/XSLT.pm (-2 / +32 lines)
Lines 31-36 use Koha::ItemTypes; Link Here
31
use Koha::XSLT::Base;
31
use Koha::XSLT::Base;
32
use Koha::Libraries;
32
use Koha::Libraries;
33
33
34
35
use XML::LibXML;
36
37
use Encode;
38
39
use vars qw(@ISA @EXPORT);
40
41
34
my $engine; #XSLT Handler object
42
my $engine; #XSLT Handler object
35
my %authval_per_framework;
43
my %authval_per_framework;
36
    # Cache for tagfield-tagsubfield to decode per framework.
44
    # Cache for tagfield-tagsubfield to decode per framework.
Lines 45-50 BEGIN { Link Here
45
        getAuthorisedValues4MARCSubfields
53
        getAuthorisedValues4MARCSubfields
46
        buildKohaItemsNamespace
54
        buildKohaItemsNamespace
47
        XSLTParse4Display
55
        XSLTParse4Display
56
        &CustomXSLTExportList
48
    );
57
    );
49
    $engine=Koha::XSLT::Base->new( { do_not_return_source => 1 } );
58
    $engine=Koha::XSLT::Base->new( { do_not_return_source => 1 } );
50
}
59
}
Lines 156-161 sub _get_best_default_xslt_filename { Link Here
156
    return $xslfilename;
165
    return $xslfilename;
157
}
166
}
158
167
168
=head2 get_xslt_sysprefs
169
170
    returns XML xslt sysprefs.
171
172
=cut
173
159
sub get_xslt_sysprefs {
174
sub get_xslt_sysprefs {
160
    my $sysxml = "<sysprefs>\n";
175
    my $sysxml = "<sysprefs>\n";
161
    foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow
176
    foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow
Lines 193-199 sub get_xsl_filename { Link Here
193
208
194
    my $xslfilename = C4::Context->preference($xslsyspref) || "default";
209
    my $xslfilename = C4::Context->preference($xslsyspref) || "default";
195
210
196
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
211
    if ($xslsyspref eq "XSLTCustomExport") {
212
        my $dir;
213
        $dir = C4::Context->config('intrahtdocs') .
214
            '/' . C4::Context->preference("template") .
215
            '/' . C4::Languages::getlanguage() .
216
            '/xslt/biblioexport';
217
        $xslfilename = $dir . "/" . $xslfilename;
218
    } elsif ($xslsyspref eq "OPACXSLTCustomExport") {
219
        my $dir;
220
        $dir = C4::Context->config('opachtdocs') .
221
            '/' . C4::Context->preference("opacthemes") .
222
            '/' . C4::Languages::getlanguage() .
223
            '/xslt/biblioexport';
224
        $xslfilename = $dir . "/" . $xslfilename;
225
    } elsif ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
197
226
198
        my ( $htdocs, $theme, $xslfile );
227
        my ( $htdocs, $theme, $xslfile );
199
228
Lines 266-273 sub XSLTParse4Display { Link Here
266
    }
295
    }
267
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
296
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
268
297
269
    $variables ||= {};
270
    my $biblio;
298
    my $biblio;
299
    my $variables ||= {};
300
271
    if (C4::Context->preference('OPACShowOpenURL')) {
301
    if (C4::Context->preference('OPACShowOpenURL')) {
272
        my @biblio_itemtypes;
302
        my @biblio_itemtypes;
273
        $biblio //= Koha::Biblios->find($biblionumber);
303
        $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 127-132 my $resultsarray = \@results; Link Here
127
$template->param(
130
$template->param(
128
    BIBLIO_RESULTS => $resultsarray,
131
    BIBLIO_RESULTS => $resultsarray,
129
    csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }),
132
    csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }),
133
    xsl_exports => CustomXSLTExportList(),
130
    bib_list => $bib_list,
134
    bib_list => $bib_list,
131
);
135
);
132
136
(-)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 81-86 if ( C4::Context->config('enable_plugins') ) { Link Here
81
    );
81
    );
82
}
82
}
83
83
84
##### ADD CUSTOM XSLT
85
$template->param(filesOptions => CustomXSLTExportList(0));
86
84
my $biblionumber = $query->param('biblionumber');
87
my $biblionumber = $query->param('biblionumber');
85
$biblionumber = HTML::Entities::encode($biblionumber);
88
$biblionumber = HTML::Entities::encode($biblionumber);
86
my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
89
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 285-290 OPAC: Link Here
285
                mods: MODS
285
                mods: MODS
286
                ris: RIS
286
                ris: RIS
287
                isbd: ISBD
287
                isbd: ISBD
288
                custom: XSL - Simple Export
288
        -
289
        -
289
            - pref: OpacSeparateHoldings
290
            - pref: OpacSeparateHoldings
290
              choices:
291
              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 990-997 Note that permanent location is a code, and location may be an authval. Link Here
990
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
990
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
991
        <option value="marcxml">MARCXML</option>
991
        <option value="marcxml">MARCXML</option>
992
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
992
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
993
        <option value="utf8">MARC (Unicode/UTF-8)</option>    </select>
993
        <option value="utf8">MARC (Unicode/UTF-8)</option>
994
        <input type="submit" name="save" value="Download record" /></td>
994
        [% FOREACH filesOption IN filesOptions %]
995
            <option value="[% filesOption.value | html %]">XSL -[% filesOption.filename | html %]</option>
996
        [% END %]</select>
997
        <input type="submit" name="save" value="Download Record" /></td>
995
  </tr>
998
  </tr>
996
  <tr><td>
999
  <tr><td>
997
    <input type="hidden" name="op" value="export" /><input type="hidden" name="bib" value="[% biblionumber | html %]" />
1000
    <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 57-86 Link Here
57
        <li>
57
        <li>
58
            <div id="export">
58
            <div id="export">
59
                <div class="dropdown">
59
                <div class="dropdown">
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>
60
                    <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>
61
                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="format">
61
                        <ul class="dropdown-menu pull-left" role="menu" aria-labelledby="format">
62
                        [% FOREACH option IN export_options %]
62
                            [% FOREACH option IN export_options %]
63
                            [% IF option == 'dc' %]
63
                                [% IF option == 'dc' %]
64
                                <a class="dropdown-item" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a>
64
                                    <li><a role="menuitem" href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li>
65
                            [% ELSE %]
65
                                [% ELSIF option != 'custom' %]
66
                                <a class="dropdown-item" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
66
                                <li>
67
                                    [% SWITCH option %]
67
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
68
                                        [% CASE 'bibtex' %]BIBTEX
68
                                        [% SWITCH option %]
69
                                        [% CASE 'endnote' %]EndNote
69
                                            [% CASE 'bibtex' %]BIBTEX
70
                                        [% CASE 'marcxml' %]MARCXML
70
                                            [% CASE 'endnote' %]EndNote
71
                                        [% CASE 'marc8' %]MARC (non-Unicode/MARC-8)
71
                                            [% CASE 'marcxml' %]MARCXML
72
                                        [% CASE 'utf8' %]MARC (Unicode/UTF-8)
72
                                            [% CASE 'marc8' %]MARC (non-Unicode/MARC-8)
73
                                        [% CASE 'marcstd' %]MARC (Unicode/UTF-8, Standard)
73
                                            [% CASE 'utf8' %]MARC (Unicode/UTF-8)
74
                                        [% CASE 'mods' %]MODS (XML)
74
                                            [% CASE 'marcstd' %]MARC (Unicode/UTF-8, Standard)
75
                                        [% CASE 'ris' %]RIS
75
                                            [% CASE 'mods' %]MODS (XML)
76
                                        [% CASE 'isbd' %]ISBD
76
                                            [% CASE 'ris' %]RIS
77
                                            [% CASE 'isbd' %]ISBD
78
                                        [% END %]
79
                                    </a>
80
                                </li>
81
                                [% ELSE %]
82
                                    [% FOREACH filesOption IN filesOptions %]
83
                                        <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>
77
                                    [% END %]
84
                                    [% END %]
78
                                </a>
85
                                [% END %]
79
                            [% END %]
86
                            [% END %]
80
                        [% END %]
87
                        </ul>
81
                    </div> <!-- /.dropdown-menu -->
88
                </div>
82
                </div> <!-- /.dropdown -->
89
            </div>
83
            </div> <!-- /#export -->
84
        </li>
90
        </li>
85
    [% END %]
91
    [% END %]
86
92
(-)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 103-108 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
103
    }
103
    }
104
);
104
);
105
105
106
#### ADD CUSTOM XSLT
107
$template->param(filesOptions => CustomXSLTExportList(1));
108
106
my @all_items = GetItemsInfo($biblionumber);
109
my @all_items = GetItemsInfo($biblionumber);
107
if( $specific_item ) {
110
if( $specific_item ) {
108
    @all_items = grep { $_->{itemnumber} == $query->param('itemnumber') } @all_items;
111
    @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 142-148 subtest 'buildKohaItemsNamespace status tests' => sub { Link Here
142
    my $library_name = $holdinglibrary->branchname;
142
    my $library_name = $holdinglibrary->branchname;
143
    like($xml,qr{<resultbranch>${library_name}</resultbranch>}, "Found resultbranch / holding branch" );
143
    like($xml,qr{<resultbranch>${library_name}</resultbranch>}, "Found resultbranch / holding branch" );
144
};
144
};
145
145
subtest  'CustomXSLTExportList: Caching' => sub {
146
    plan tests => 1;
147
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
148
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
149
    my $list = C4::XSLT::CustomXSLTExportList(1);
150
    push @$list, { nonsense => 1 };
151
    $cache->set_in_cache('CustomXSLTExportListOPAC', $list );
152
    my $n = @$list;
153
    $list = C4::XSLT::CustomXSLTExportList(1);
154
    is( @$list, $n, 'This list comes from the cache and that is fine' );
155
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
156
};
157
subtest 'CustomXSLTExportList: Check export options' => sub {
158
    plan tests => 2;
159
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
160
    my $list = C4::XSLT::CustomXSLTExportList(1);
161
    is( $list>0, 1, 'We expect at least one result: simple export' );
162
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
163
    t::lib::Mocks::mock_preference('OpacExportOptions', 'dc');
164
    $list = C4::XSLT::CustomXSLTExportList(1);
165
    is( @$list, 0, 'We expect an empty list now' );
166
};
146
$schema->storage->txn_rollback;
167
$schema->storage->txn_rollback;
147
168
148
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
169
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 359-364 $template->param( Link Here
359
    public   => $public,
359
    public   => $public,
360
    print    => scalar $query->param('print') || 0,
360
    print    => scalar $query->param('print') || 0,
361
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' })->as_list ],
361
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' })->as_list ],
362
    xsl_exports => CustomXSLTExportList()
362
);
363
);
363
364
364
output_html_with_http_headers $query, $cookie, $template->output;
365
output_html_with_http_headers $query, $cookie, $template->output;
365
- 

Return to bug 17385