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

(-)a/C4/XSLT.pm (-2 / +32 lines)
Lines 33-38 use Koha::XSLT::Base; Link Here
33
use Koha::Libraries;
33
use Koha::Libraries;
34
use Koha::Recalls;
34
use Koha::Recalls;
35
35
36
37
use XML::LibXML;
38
39
use Encode;
40
41
use vars qw(@ISA @EXPORT);
42
43
36
my $engine; #XSLT Handler object
44
my $engine; #XSLT Handler object
37
45
38
our (@ISA, @EXPORT_OK);
46
our (@ISA, @EXPORT_OK);
Lines 42-47 BEGIN { Link Here
42
    @EXPORT_OK = qw(
50
    @EXPORT_OK = qw(
43
        buildKohaItemsNamespace
51
        buildKohaItemsNamespace
44
        XSLTParse4Display
52
        XSLTParse4Display
53
        &CustomXSLTExportList
45
    );
54
    );
46
    $engine=Koha::XSLT::Base->new( { do_not_return_source => 1 } );
55
    $engine=Koha::XSLT::Base->new( { do_not_return_source => 1 } );
47
}
56
}
Lines 84-89 sub _get_best_default_xslt_filename { Link Here
84
    return $xslfilename;
93
    return $xslfilename;
85
}
94
}
86
95
96
=head2 get_xslt_sysprefs
97
98
    returns XML xslt sysprefs.
99
100
=cut
101
87
sub get_xslt_sysprefs {
102
sub get_xslt_sysprefs {
88
    my $sysxml = "<sysprefs>\n";
103
    my $sysxml = "<sysprefs>\n";
89
    foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow
104
    foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow
Lines 121-127 sub get_xsl_filename { Link Here
121
136
122
    my $xslfilename = C4::Context->preference($xslsyspref) || "default";
137
    my $xslfilename = C4::Context->preference($xslsyspref) || "default";
123
138
124
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
139
    if ($xslsyspref eq "XSLTCustomExport") {
140
        my $dir;
141
        $dir = C4::Context->config('intrahtdocs') .
142
            '/' . C4::Context->preference("template") .
143
            '/' . C4::Languages::getlanguage() .
144
            '/xslt/biblioexport';
145
        $xslfilename = $dir . "/" . $xslfilename;
146
    } elsif ($xslsyspref eq "OPACXSLTCustomExport") {
147
        my $dir;
148
        $dir = C4::Context->config('opachtdocs') .
149
            '/' . C4::Context->preference("opacthemes") .
150
            '/' . C4::Languages::getlanguage() .
151
            '/xslt/biblioexport';
152
        $xslfilename = $dir . "/" . $xslfilename;
153
    } elsif ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
125
154
126
        my ( $htdocs, $theme, $xslfile );
155
        my ( $htdocs, $theme, $xslfile );
127
156
Lines 206-213 sub XSLTParse4Display { Link Here
206
    }
235
    }
207
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
236
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
208
237
209
    $variables ||= {};
210
    my $biblio;
238
    my $biblio;
239
    my $variables ||= {};
240
211
    if (C4::Context->preference('OPACShowOpenURL')) {
241
    if (C4::Context->preference('OPACShowOpenURL')) {
212
        my @biblio_itemtypes;
242
        my @biblio_itemtypes;
213
        $biblio //= Koha::Biblios->find($biblionumber);
243
        $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
    GetMarcSeries
24
    GetMarcSeries
24
    GetMarcSubjects
25
    GetMarcSubjects
Lines 26-31 use C4::Biblio qw( Link Here
26
);
27
);
27
use C4::Auth qw( get_template_and_user );
28
use C4::Auth qw( get_template_and_user );
28
use C4::Output qw( output_html_with_http_headers );
29
use C4::Output qw( output_html_with_http_headers );
30
use C4::XSLT;
31
29
32
30
use Koha::AuthorisedValues;
33
use Koha::AuthorisedValues;
31
use Koha::Biblios;
34
use Koha::Biblios;
Lines 107-112 my $resultsarray = \@results; Link Here
107
$template->param(
110
$template->param(
108
    BIBLIO_RESULTS => $resultsarray,
111
    BIBLIO_RESULTS => $resultsarray,
109
    csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }),
112
    csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }),
113
    xsl_exports => CustomXSLTExportList(),
110
    bib_list => $bib_list,
114
    bib_list => $bib_list,
111
);
115
);
112
116
(-)a/basket/downloadcart.pl (+6 lines)
Lines 26-31 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
30
30
use Koha::CsvProfiles;
31
use Koha::CsvProfiles;
31
use Koha::Biblios;
32
use Koha::Biblios;
Lines 78-88 if ($bib_list && $format) { Link Here
78
            elsif ($format eq 'bibtex') {
79
            elsif ($format eq 'bibtex') {
79
                $output .= marc2bibtex($record, $biblionumber);
80
                $output .= marc2bibtex($record, $biblionumber);
80
            }
81
            }
82
            elsif ($format =~ /^xsl\.(.*)$/) {
83
                $output .= XSLTParse4Display($biblio, $record, 'XSLTCustomExport', 1, undef, , '', $1, '');
84
            }
81
        }
85
        }
82
    }
86
    }
83
87
84
    # If it was a CSV export we change the format after the export so the file extension is fine
88
    # If it was a CSV export we change the format after the export so the file extension is fine
85
    $format = "csv" if ($format =~ m/^\d+$/);
89
    $format = "csv" if ($format =~ m/^\d+$/);
90
    $format = "html" if ($format =~ /^xsl\./);
86
91
87
    print $query->header(
92
    print $query->header(
88
	-type => 'application/octet-stream',
93
	-type => 'application/octet-stream',
Lines 92-97 if ($bib_list && $format) { Link Here
92
97
93
} else { 
98
} else { 
94
    $template->param(csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }));
99
    $template->param(csv_profiles => Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }));
100
    $template->param(xsl_exports => CustomXSLTExportList());
95
    $template->param(bib_list => $bib_list); 
101
    $template->param(bib_list => $bib_list); 
96
    output_html_with_http_headers $query, $cookie, $template->output;
102
    output_html_with_http_headers $query, $cookie, $template->output;
97
}
103
}
(-)a/catalogue/detail.pl (+3 lines)
Lines 85-90 if ( C4::Context->config('enable_plugins') ) { Link Here
85
    );
85
    );
86
}
86
}
87
87
88
##### ADD CUSTOM XSLT
89
$template->param(filesOptions => CustomXSLTExportList(0));
90
88
my $biblionumber = $query->param('biblionumber');
91
my $biblionumber = $query->param('biblionumber');
89
$biblionumber = HTML::Entities::encode($biblionumber);
92
$biblionumber = HTML::Entities::encode($biblionumber);
90
my $biblio = Koha::Biblios->find( $biblionumber );
93
my $biblio = Koha::Biblios->find( $biblionumber );
(-)a/catalogue/export.pl (+16 lines)
Lines 7-12 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;
11
10
12
11
13
12
14
Lines 86-89 if ($op eq "export") { Link Here
86
                -attachment=>"$file_pre$file_id.$format");
88
                -attachment=>"$file_pre$file_id.$format");
87
            print $marc;
89
            print $marc;
88
        }
90
        }
91
}elsif ($op eq "exportxsl"){
92
    my $biblionumber = $query->param("bib");
93
    if ($biblionumber){
94
        my $xslFile = $query->param("file");
95
        my $marc = GetMarcBiblio( { biblionumber => $biblionumber, embed_items => 1 } );
96
        my $format=$query->param("format")||'txt';
97
        my @hiddenitems;
98
99
        $marc = XSLTParse4Display($biblionumber, $marc, 'XSLTCustomExport', 1, \@hiddenitems, '', $xslFile,'');
100
        print $query->header(
101
            -type => 'application/octet-stream',
102
            -attachment=>"bib-$biblionumber.$format");
103
        print $marc;
104
    }
89
}
105
}
(-)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 58-63 Link Here
58
                            [% FOREACH csv_profile IN csv_profiles %]
58
                            [% FOREACH csv_profile IN csv_profiles %]
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 %]
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>
63
                            [% END %]
61
                            </ul>
64
                            </ul>
62
                        </div>
65
                        </div>
63
                        <a class="btn btn-default" href="basket.pl" id="print_cart"><i class="fa fa-print"></i> Print</a>
66
                        <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 1065-1072 Note that permanent location is a code, and location may be an authval. Link Here
1065
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
1065
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
1066
        <option value="marcxml">MARCXML</option>
1066
        <option value="marcxml">MARCXML</option>
1067
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1067
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1068
        <option value="utf8">MARC (Unicode/UTF-8)</option>    </select>
1068
        <option value="utf8">MARC (Unicode/UTF-8)</option>
1069
        <input type="submit" name="save" value="Download record" /></td>
1069
        [% FOREACH filesOption IN filesOptions %]
1070
            <option value="[% filesOption.value | html %]">XSL -[% filesOption.filename | html %]</option>
1071
        [% END %]</select>
1072
        <input type="submit" name="save" value="Download Record" /></td>
1070
  </tr>
1073
  </tr>
1071
  <tr><td>
1074
  <tr><td>
1072
    <input type="hidden" name="op" value="export" /><input type="hidden" name="bib" value="[% biblionumber | html %]" />
1075
    <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 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 $patron = Koha::Patrons->find( $borrowernumber );
109
my $patron = Koha::Patrons->find( $borrowernumber );
107
110
108
my $biblio = Koha::Biblios->find( $biblionumber );
111
my $biblio = Koha::Biblios->find( $biblionumber );
(-)a/opac/opac-downloadcart.pl (+8 lines)
Lines 28-33 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;
32
31
use Koha::CsvProfiles;
33
use Koha::CsvProfiles;
32
use Koha::RecordProcessor;
34
use Koha::RecordProcessor;
33
35
Lines 114-124 if ($bib_list && $format) { Link Here
114
                $extension = "txt";
116
                $extension = "txt";
115
                $type      = "text/plain";
117
                $type      = "text/plain";
116
            }
118
            }
119
            elsif ($format =~ /^xsl\.(.*)$/) {
120
                $output .= XSLTParse4Display($biblio, $record, 'OPACXSLTCustomExport', 1, undef, undef, $1, '');
121
            }
117
        }
122
        }
118
    }
123
    }
119
124
120
    # If it was a CSV export we change the format after the export so the file extension is fine
125
    # If it was a CSV export we change the format after the export so the file extension is fine
121
    $format = "csv" if ($format =~ m/^\d+$/);
126
    $format = "csv" if ($format =~ m/^\d+$/);
127
    $format = "html" if ($format =~ /^xsl\./);
122
128
123
    print $query->header(
129
    print $query->header(
124
                               -type => ($type) ? $type : 'application/octet-stream',
130
                               -type => ($type) ? $type : 'application/octet-stream',
Lines 138-142 if ($bib_list && $format) { Link Here
138
        ),
144
        ),
139
        bib_list => $bib_list,
145
        bib_list => $bib_list,
140
    );
146
    );
147
    $template->param(bib_list => $bib_list);
148
    $template->param(xsl_exports => CustomXSLTExportList());
141
    output_html_with_http_headers $query, $cookie, $template->output;
149
    output_html_with_http_headers $query, $cookie, $template->output;
142
}
150
}
(-)a/opac/opac-downloadshelf.pl (-2 / +8 lines)
Lines 27-32 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;
31
30
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
31
use Koha::RecordProcessor;
33
use Koha::RecordProcessor;
32
use Koha::Virtualshelves;
34
use Koha::Virtualshelves;
Lines 122-134 if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { Link Here
122
                    });
124
                    });
123
                    $extension = "txt";
125
                    $extension = "txt";
124
                    $type      = "text/plain";
126
                    $type      = "text/plain";
125
                }
127
                }elsif ($format =~ /^xsl\.(.*)$/){
128
                         $output .= XSLTParse4Display($biblionumber, $record, 'XSLTCustomExport', 1, undef, undef, $1, '', 1);
129
                    }
126
            }
130
            }
127
        }
131
        }
128
132
129
        # If it was a CSV export we change the format after the export so the file extension is fine
133
        # If it was a CSV export we change the format after the export so the file extension is fine
130
        $format = "csv" if ($format =~ m/^\d+$/);
134
        $format = "csv" if ($format =~ m/^\d+$/);
131
135
        $format = "html" if ($format =~ /^xsl\./);
132
        print $query->header(
136
        print $query->header(
133
                                   -type => ($type) ? $type : 'application/octet-stream',
137
                                   -type => ($type) ? $type : 'application/octet-stream',
134
            -'Content-Transfer-Encoding' => 'binary',
138
            -'Content-Transfer-Encoding' => 'binary',
Lines 154-159 if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { Link Here
154
            ),
158
            ),
155
            shelf => $shelf,
159
            shelf => $shelf,
156
        );
160
        );
161
        $template->param(xsl_exports => CustomXSLTExportList());
162
        $template->param( shelf => $shelf );
157
        output_html_with_http_headers $query, $cookie, $template->output;
163
        output_html_with_http_headers $query, $cookie, $template->output;
158
    }
164
    }
159
165
(-)a/opac/opac-export.pl (+11 lines)
Lines 31-36 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;
35
34
use Koha::RecordProcessor;
36
use Koha::RecordProcessor;
35
37
36
my $query = CGI->new;
38
my $query = CGI->new;
Lines 137-142 elsif ( $format =~ /isbd/ ) { Link Here
137
    });
139
    });
138
    $format = 'isbd';
140
    $format = 'isbd';
139
}
141
}
142
elsif ($format =~ /html/ ) {
143
    if ($biblionumber){
144
        my $xslFile = $query->param("file");
145
        $marc = C4::Biblio::GetMarcBiblio({biblionumber => $biblionumber});
146
        my @hiddenitems;
147
148
        $marc = XSLTParse4Display($biblionumber, $marc, 'OPACXSLTCustomExport', 1, \@hiddenitems, undef, $xslFile, undef);
149
    }
150
}
140
else {
151
else {
141
    $error= "Format $format is not supported.";
152
    $error= "Format $format is not supported.";
142
}
153
}
(-)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 144-150 subtest 'buildKohaItemsNamespace status tests' => sub { Link Here
144
    t::lib::Mocks::mock_preference('UseRecalls', 0);
144
    t::lib::Mocks::mock_preference('UseRecalls', 0);
145
145
146
};
146
};
147
147
subtest  'CustomXSLTExportList: Caching' => sub {
148
    plan tests => 1;
149
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
150
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
151
    my $list = C4::XSLT::CustomXSLTExportList(1);
152
    push @$list, { nonsense => 1 };
153
    $cache->set_in_cache('CustomXSLTExportListOPAC', $list );
154
    my $n = @$list;
155
    $list = C4::XSLT::CustomXSLTExportList(1);
156
    is( @$list, $n, 'This list comes from the cache and that is fine' );
157
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
158
};
159
subtest 'CustomXSLTExportList: Check export options' => sub {
160
    plan tests => 2;
161
    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
162
    my $list = C4::XSLT::CustomXSLTExportList(1);
163
    is( $list>0, 1, 'We expect at least one result: simple export' );
164
    $cache->clear_from_cache('CustomXSLTExportListOPAC');
165
    t::lib::Mocks::mock_preference('OpacExportOptions', 'dc');
166
    $list = C4::XSLT::CustomXSLTExportList(1);
167
    is( @$list, 0, 'We expect an empty list now' );
168
};
148
$schema->storage->txn_rollback;
169
$schema->storage->txn_rollback;
149
170
150
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
171
subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub {
(-)a/virtualshelves/downloadshelf.pl (-1 / +6 lines)
Lines 25-30 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;
29
28
30
29
use Koha::Biblios;
31
use Koha::Biblios;
30
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
Lines 79-90 if ($shelfid && $format) { Link Here
79
                    elsif ($format eq 'bibtex') {
81
                    elsif ($format eq 'bibtex') {
80
                        $output .= marc2bibtex($record, $biblionumber);
82
                        $output .= marc2bibtex($record, $biblionumber);
81
                    }
83
                    }
84
                    elsif ($format =~ /^xsl\.(.*)$/){
85
                        $output .= XSLTParse4Display($biblionumber, $record, 'XSLTCustomExport', 1, undef, ,'',$1,'');
86
                    }
82
                }
87
                }
83
            }
88
            }
84
89
85
            # If it was a CSV export we change the format after the export so the file extension is fine
90
            # 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+$/);
91
            $format = "csv" if ($format =~ m/^\d+$/);
87
92
            $format = "html" if ($format =~ /^xsl\./);
88
            print $query->header(
93
            print $query->header(
89
            -type => 'application/octet-stream',
94
            -type => 'application/octet-stream',
90
            -'Content-Transfer-Encoding' => 'binary',
95
            -'Content-Transfer-Encoding' => 'binary',
(-)a/virtualshelves/shelves.pl (-1 / +1 lines)
Lines 385-390 $template->param( Link Here
385
    print    => scalar $query->param('print') || 0,
385
    print    => scalar $query->param('print') || 0,
386
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' })->as_list ],
386
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' })->as_list ],
387
    allow_transfer => $allow_transfer,
387
    allow_transfer => $allow_transfer,
388
    xsl_exports => CustomXSLTExportList()
388
);
389
);
389
390
390
output_html_with_http_headers $query, $cookie, $template->output;
391
output_html_with_http_headers $query, $cookie, $template->output;
391
- 

Return to bug 17385