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

(-)a/C4/XSLT.pm (-1 / +26 lines)
Lines 32-37 use Koha::RecordProcessor; Link Here
32
use Koha::XSLT::Base;
32
use Koha::XSLT::Base;
33
use Koha::Libraries;
33
use Koha::Libraries;
34
use Koha::Recalls;
34
use Koha::Recalls;
35
use XML::LibXML;
36
use Encode;
37
use vars qw(@ISA @EXPORT);
38
35
39
36
my $engine;    #XSLT Handler object
40
my $engine;    #XSLT Handler object
37
41
Lines 43-48 BEGIN { Link Here
43
    @EXPORT_OK = qw(
47
    @EXPORT_OK = qw(
44
        buildKohaItemsNamespace
48
        buildKohaItemsNamespace
45
        XSLTParse4Display
49
        XSLTParse4Display
50
        &CustomXSLTExportList
46
    );
51
    );
47
    $engine = Koha::XSLT::Base->new( { do_not_return_source => 1 } );
52
    $engine = Koha::XSLT::Base->new( { do_not_return_source => 1 } );
48
}
53
}
Lines 85-90 sub _get_best_default_xslt_filename { Link Here
85
    return $xslfilename;
90
    return $xslfilename;
86
}
91
}
87
92
93
=head2 get_xslt_sysprefs
94
95
    returns XML xslt sysprefs.
96
97
=cut
98
88
sub get_xslt_sysprefs {
99
sub get_xslt_sysprefs {
89
    my $sysxml = "<sysprefs>\n";
100
    my $sysxml = "<sysprefs>\n";
90
    foreach my $syspref (
101
    foreach my $syspref (
Lines 125-131 sub get_xsl_filename { Link Here
125
136
126
    my $xslfilename = C4::Context->preference($xslsyspref) || "default";
137
    my $xslfilename = C4::Context->preference($xslsyspref) || "default";
127
138
128
    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 ) {
129
154
130
        my ( $htdocs, $theme, $xslfile );
155
        my ( $htdocs, $theme, $xslfile );
131
156
(-)a/basket/basket.pl (+4 lines)
Lines 18-23 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
use CGI qw ( -utf8 );
19
use CGI qw ( -utf8 );
20
use C4::Koha;
20
use C4::Koha;
21
21
use C4::Biblio qw(
22
use C4::Biblio qw(
22
    GetMarcSeries
23
    GetMarcSeries
23
    GetMarcSubjects
24
    GetMarcSubjects
Lines 25-30 use C4::Biblio qw( Link Here
25
);
26
);
26
use C4::Auth   qw( get_template_and_user );
27
use C4::Auth   qw( get_template_and_user );
27
use C4::Output qw( output_html_with_http_headers );
28
use C4::Output qw( output_html_with_http_headers );
29
use C4::XSLT;
30
28
31
29
use Koha::AuthorisedValues;
32
use Koha::AuthorisedValues;
30
use Koha::Biblios;
33
use Koha::Biblios;
Lines 109-114 my $resultsarray = \@results; Link Here
109
$template->param(
112
$template->param(
110
    BIBLIO_RESULTS => $resultsarray,
113
    BIBLIO_RESULTS => $resultsarray,
111
    csv_profiles   => Koha::CsvProfiles->search( { type => 'marc', used_for => 'export_records' } ),
114
    csv_profiles   => Koha::CsvProfiles->search( { type => 'marc', used_for => 'export_records' } ),
115
    xsl_exports    => CustomXSLTExportList(),
112
    bib_list       => $bib_list,
116
    bib_list       => $bib_list,
113
);
117
);
114
118
(-)a/basket/downloadcart.pl (-1 / +7 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 77-87 if ( $bib_list && $format ) { Link Here
77
            } elsif ( $format eq 'bibtex' ) {
78
            } elsif ( $format eq 'bibtex' ) {
78
                $output .= marc2bibtex( $record, $biblionumber );
79
                $output .= marc2bibtex( $record, $biblionumber );
79
            }
80
            }
81
            elsif ($format =~ /^xsl\.(.*)$/) {
82
                $output .= XSLTParse4Display($biblio, $record, 'XSLTCustomExport', 1, undef, , '', $1, '');
83
            }
80
        }
84
        }
81
    }
85
    }
82
86
83
    # If it was a CSV export we change the format after the export so the file extension is fine
87
    # If it was a CSV export we change the format after the export so the file extension is fine
84
    $format = "csv" if ( $format =~ m/^\d+$/ );
88
    $format = "csv"  if ( $format =~ m/^\d+$/ );
89
    $format = "html" if ( $format =~ /^xsl\./ );
85
90
86
    print $query->header(
91
    print $query->header(
87
        -type                        => 'application/octet-stream',
92
        -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 86-91 if ( C4::Context->config('enable_plugins') ) { Link Here
86
}
86
}
87
87
88
my $activetab    = $query->param('activetab');
88
my $activetab    = $query->param('activetab');
89
##### ADD CUSTOM XSLT
90
$template->param(filesOptions => CustomXSLTExportList(0));
91
89
my $biblionumber = $query->param('biblionumber');
92
my $biblionumber = $query->param('biblionumber');
90
$biblionumber = HTML::Entities::encode($biblionumber);
93
$biblionumber = HTML::Entities::encode($biblionumber);
91
my $biblio = Koha::Biblios->find($biblionumber);
94
my $biblio = Koha::Biblios->find($biblionumber);
(-)a/catalogue/export.pl (+16 lines)
Lines 6-11 use C4::Auth qw( get_template_and_user ); Link Here
6
use C4::Output;
6
use C4::Output;
7
use CGI     qw ( -utf8 );
7
use CGI     qw ( -utf8 );
8
use C4::Ris qw( marc2ris );
8
use C4::Ris qw( marc2ris );
9
use C4::XSLT;
10
9
11
10
my $query = CGI->new;
12
my $query = CGI->new;
11
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
13
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 79-82 if ( $op eq "export" ) { Link Here
79
        );
81
        );
80
        print $marc;
82
        print $marc;
81
    }
83
    }
84
} elsif ( $op eq "exportxsl" ) {
85
    my $biblionumber = $query->param("bib");
86
    if ($biblionumber){
87
        my $xslFile = $query->param("file");
88
        my $marc = GetMarcBiblio( { biblionumber => $biblionumber, embed_items => 1 } );
89
        my $format=$query->param("format")||'txt';
90
        my @hiddenitems;
91
92
        $marc = XSLTParse4Display($biblionumber, $marc, 'XSLTCustomExport', 1, \@hiddenitems, '', $xslFile,'');
93
        print $query->header(
94
            -type => 'application/octet-stream',
95
            -attachment=>"bib-$biblionumber.$format");
96
        print $marc;
97
    }
82
}
98
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (+3 lines)
Lines 190-195 Link Here
190
            <li><a class="dropdown-item" href="/cgi-bin/koha/catalogue/export.pl?format=marcstd&amp;op=export&amp;bib=[% biblionumber | uri %]">MARC (Unicode/UTF-8, Standard)</a></li>
190
            <li><a class="dropdown-item" href="/cgi-bin/koha/catalogue/export.pl?format=marcstd&amp;op=export&amp;bib=[% biblionumber | uri %]">MARC (Unicode/UTF-8, Standard)</a></li>
191
            <li><a class="dropdown-item" href="/cgi-bin/koha/catalogue/export.pl?format=mods&amp;op=export&amp;bib=[% biblionumber | uri %]">MODS (XML)</a></li>
191
            <li><a class="dropdown-item" href="/cgi-bin/koha/catalogue/export.pl?format=mods&amp;op=export&amp;bib=[% biblionumber | uri %]">MODS (XML)</a></li>
192
            <li><a class="dropdown-item" href="/cgi-bin/koha/catalogue/export.pl?format=ris&amp;op=export&amp;bib=[% biblionumber | uri %]">RIS</a></li>
192
            <li><a class="dropdown-item" href="/cgi-bin/koha/catalogue/export.pl?format=ris&amp;op=export&amp;bib=[% biblionumber | uri %]">RIS</a></li>
193
            [% FOREACH filesOption IN filesOptions %]
194
                <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>
195
            [% END %]
193
        </ul>
196
        </ul>
194
    </div>
197
    </div>
195
198
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc (+3 lines)
Lines 41-46 Link Here
41
                [% FOREACH csv_profile IN csv_profiles %]
41
                [% FOREACH csv_profile IN csv_profiles %]
42
                    <li><a class="dropdown-item" 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>
42
                    <li><a class="dropdown-item" 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>
43
                [% END %]
43
                [% END %]
44
                [% FOREACH xsl_export IN xsl_exports %]
45
                    <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>
46
                [% END %]
44
            </ul>
47
            </ul>
45
        </div>
48
        </div>
46
        <div class="btn-group"
49
        <div class="btn-group"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+1 lines)
Lines 306-311 OPAC: Link Here
306
                mods: MODS
306
                mods: MODS
307
                ris: RIS
307
                ris: RIS
308
                isbd: ISBD
308
                isbd: ISBD
309
                custom: XSL - Simple Export
309
        -
310
        -
310
            - pref: OpacSeparateHoldings
311
            - pref: OpacSeparateHoldings
311
              choices:
312
              choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt (+3 lines)
Lines 59-64 Link Here
59
                    [% FOREACH csv_profile IN csv_profiles %]
59
                    [% FOREACH csv_profile IN csv_profiles %]
60
                        <li><a class="dropdown-item" 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
                        <li><a class="dropdown-item" 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>
61
                    [% END %]
61
                    [% END %]
62
                    [% FOREACH xsl_export IN xsl_exports %]
63
                        <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>
64
                    [% END %]
62
                </ul>
65
                </ul>
63
            </div>
66
            </div>
64
            <a class="btn btn-default" href="basket.pl" id="print_cart"><i class="fa fa-print"></i> Print</a>
67
            <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 (+3 lines)
Lines 982-987 Link Here
982
                            <option value="marcxml">MARCXML</option>
982
                            <option value="marcxml">MARCXML</option>
983
                            <option value="marc8">MARC (non-Unicode/MARC-8)</option>
983
                            <option value="marc8">MARC (non-Unicode/MARC-8)</option>
984
                            <option value="utf8">MARC (Unicode/UTF-8)</option>
984
                            <option value="utf8">MARC (Unicode/UTF-8)</option>
985
                            [% FOREACH filesOption IN filesOptions %]
986
                                <option value="[% filesOption.value | html %]">XSL -[% filesOption.filename | html %]</option>
987
                            [% END %]
985
                        </select>
988
                        </select>
986
                        <input type="submit" name="save" class="btn btn-primary" value="Download record" />
989
                        <input type="submit" name="save" class="btn btn-primary" value="Download record" />
987
                    </td>
990
                    </td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tt (+3 lines)
Lines 42-47 Link Here
42
                            [% FOREACH csv_profile IN csv_profiles %]
42
                            [% FOREACH csv_profile IN csv_profiles %]
43
                                <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
43
                                <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
44
                            [% END %]
44
                            [% END %]
45
                            [% FOREACH xsl_export IN xsl_exports %]
46
                                <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option>
47
                            [% END %]
45
                        </select>
48
                        </select>
46
                    </li></ol
49
                    </li></ol
47
                >
50
                >
(-)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 (-6 / +11 lines)
Lines 94-105 Link Here
94
            <div id="export">
94
            <div id="export">
95
                <div class="dropdown">
95
                <div class="dropdown">
96
                    <a id="format" class="btn btn-link btn-lg dropdown-toggle" data-bs-toggle="dropdown" href="#"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Save record <b class="caret"></b></a>
96
                    <a id="format" class="btn btn-link btn-lg dropdown-toggle" data-bs-toggle="dropdown" href="#"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Save record <b class="caret"></b></a>
97
                    <div class="dropdown-menu dropdown-menu-end" aria-labelledby="format">
97
                    <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="format">
98
                        [% FOREACH option IN export_options %]
98
                        [% FOREACH option IN export_options %]
99
                            [% IF option == 'dc' %]
99
                            [% IF option == 'dc' %]
100
                                <a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#exportModal_">Dublin Core</a>
100
                                <li><a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#exportModal_">Dublin Core</a></li>
101
                            [% ELSE %]
101
                            [% ELSIF option != 'custom' %]
102
                                <a class="dropdown-item" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
102
                                <li><a class="dropdown-item" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblio.biblionumber | html %]&amp;format=[% option | html %]">
103
                                    [% SWITCH option %]
103
                                    [% SWITCH option %]
104
                                    [% CASE 'bibtex' %]
104
                                    [% CASE 'bibtex' %]
105
                                        <span>BIBTEX</span>
105
                                        <span>BIBTEX</span>
Lines 120-129 Link Here
120
                                    [% CASE 'isbd' %]
120
                                    [% CASE 'isbd' %]
121
                                        <span>ISBD</span>
121
                                        <span>ISBD</span>
122
                                    [% END %]
122
                                    [% END %]
123
                                </a>
123
                                    </a>
124
                                </li>
125
                            [% ELSE %]
126
                                [% FOREACH filesOption IN filesOptions %]
127
                                    <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>
128
                                [% END %]
124
                            [% END %]
129
                            [% END %]
125
                        [% END %]
130
                        [% END %]
126
                    </div>
131
                    </ul>
127
                    <!-- /.dropdown-menu -->
132
                    <!-- /.dropdown-menu -->
128
                </div>
133
                </div>
129
                <!-- /.dropdown -->
134
                <!-- /.dropdown -->
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt (+3 lines)
Lines 21-26 Link Here
21
                            [% FOREACH csv_profile IN csv_profiles %]
21
                            [% FOREACH csv_profile IN csv_profiles %]
22
                                <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
22
                                <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
23
                            [% END %]
23
                            [% END %]
24
                            [% FOREACH xsl_export IN xsl_exports %]
25
                                <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option>
26
                            [% END %]
24
                        </select>
27
                        </select>
25
                        <fieldset class="action">
28
                        <fieldset class="action">
26
                            <input type="hidden" name="bib_list" value="[% bib_list | html %]" />
29
                            <input type="hidden" name="bib_list" value="[% bib_list | html %]" />
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt (+3 lines)
Lines 61-66 Link Here
61
                                        [% FOREACH csv_profile IN csv_profiles %]
61
                                        [% FOREACH csv_profile IN csv_profiles %]
62
                                            <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
62
                                            <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
63
                                        [% END %]
63
                                        [% END %]
64
                                        [% FOREACH xsl_export IN xsl_exports %]
65
                                            <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option>
66
                                        [% END %]
64
                                    </select>
67
                                    </select>
65
                                    <span class="required">Required</span>
68
                                    <span class="required">Required</span>
66
                                </fieldset>
69
                                </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 102-107 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
102
    }
102
    }
103
);
103
);
104
104
105
#### ADD CUSTOM XSLT
106
$template->param(filesOptions => CustomXSLTExportList(1));
107
105
my $patron = Koha::Patrons->find($borrowernumber);
108
my $patron = Koha::Patrons->find($borrowernumber);
106
109
107
my $biblio = Koha::Biblios->find($biblionumber);
110
my $biblio = Koha::Biblios->find($biblionumber);
(-)a/opac/opac-downloadcart.pl (-1 / +9 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 (-3 / +9 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 121-133 if ( $shelf and $shelf->can_be_viewed($borrowernumber) ) { Link Here
121
                    );
123
                    );
122
                    $extension = "txt";
124
                    $extension = "txt";
123
                    $type      = "text/plain";
125
                    $type      = "text/plain";
124
                }
126
                }elsif ($format =~ /^xsl\.(.*)$/){
127
                         $output .= XSLTParse4Display($biblionumber, $record, 'XSLTCustomExport', 1, undef, undef, $1, '', 1);
128
                    }
125
            }
129
            }
126
        }
130
        }
127
131
128
        # If it was a CSV export we change the format after the export so the file extension is fine
132
        # If it was a CSV export we change the format after the export so the file extension is fine
129
        $format = "csv" if ( $format =~ m/^\d+$/ );
133
        $format = "csv"  if ( $format =~ m/^\d+$/ );
130
134
        $format = "html" if ( $format =~ /^xsl\./ );
131
        print $query->header(
135
        print $query->header(
132
            -type                        => ($type) ? $type : 'application/octet-stream',
136
            -type                        => ($type) ? $type : 'application/octet-stream',
133
            -'Content-Transfer-Encoding' => 'binary',
137
            -'Content-Transfer-Encoding' => 'binary',
Lines 153-158 if ( $shelf and $shelf->can_be_viewed($borrowernumber) ) { Link Here
153
            ),
157
            ),
154
            shelf => $shelf,
158
            shelf => $shelf,
155
        );
159
        );
160
        $template->param(xsl_exports => CustomXSLTExportList());
161
        $template->param( shelf => $shelf );
156
        output_html_with_http_headers $query, $cookie, $template->output;
162
        output_html_with_http_headers $query, $cookie, $template->output;
157
    }
163
    }
158
164
(-)a/opac/opac-export.pl (+10 lines)
Lines 30-35 use CGI qw ( -utf8 ); Link Here
30
use C4::Auth;
30
use C4::Auth;
31
use C4::Ris qw( marc2ris );
31
use C4::Ris qw( marc2ris );
32
use Koha::Biblios;
32
use Koha::Biblios;
33
use C4::XSLT;
34
33
use Koha::RecordProcessor;
35
use Koha::RecordProcessor;
34
36
35
use List::MoreUtils qw(none any);
37
use List::MoreUtils qw(none any);
Lines 151-156 if ( $format =~ /endnote/ ) { Link Here
151
        }
153
        }
152
    );
154
    );
153
    $format = 'isbd';
155
    $format = 'isbd';
156
} elsif ($format =~ /html/ ) {
157
    if ($biblionumber){
158
        my $xslFile = $query->param("file");
159
        $marc = C4::Biblio::GetMarcBiblio({biblionumber => $biblionumber});
160
        my @hiddenitems;
161
162
        $marc = XSLTParse4Display($biblionumber, $marc, 'OPACXSLTCustomExport', 1, \@hiddenitems, undef, $xslFile, undef);
163
    }
154
} else {
164
} else {
155
    $error = "Format $format is not supported.";
165
    $error = "Format $format is not supported.";
156
}
166
}
(-)a/virtualshelves/downloadshelf.pl (-2 / +7 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 77-88 if ( $shelfid && $format ) { Link Here
77
                    } elsif ( $format eq 'bibtex' ) {
79
                    } elsif ( $format eq 'bibtex' ) {
78
                        $output .= marc2bibtex( $record, $biblionumber );
80
                        $output .= marc2bibtex( $record, $biblionumber );
79
                    }
81
                    }
82
                    elsif ($format =~ /^xsl\.(.*)$/){
83
                        $output .= XSLTParse4Display($biblionumber, $record, 'XSLTCustomExport', 1, undef, ,'',$1,'');
84
                    }
80
                }
85
                }
81
            }
86
            }
82
87
83
            # 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
84
            $format = "csv" if ( $format =~ m/^\d+$/ );
89
            $format = "csv"  if ( $format =~ m/^\d+$/ );
85
90
            $format = "html" if ( $format =~ /^xsl\./ );
86
            print $query->header(
91
            print $query->header(
87
                -type                        => 'application/octet-stream',
92
                -type                        => 'application/octet-stream',
88
                -'Content-Transfer-Encoding' => 'binary',
93
                -'Content-Transfer-Encoding' => 'binary',
(-)a/virtualshelves/shelves.pl (-1 / +1 lines)
Lines 434-439 $template->param( Link Here
434
    csv_profiles   => [ Koha::CsvProfiles->search( { type => 'marc', used_for => 'export_records' } )->as_list ],
434
    csv_profiles   => [ Koha::CsvProfiles->search( { type => 'marc', used_for => 'export_records' } )->as_list ],
435
    allow_transfer => $allow_transfer,
435
    allow_transfer => $allow_transfer,
436
    allow_create_public_lists => $allow_create_public_lists,
436
    allow_create_public_lists => $allow_create_public_lists,
437
    xsl_exports => CustomXSLTExportList()
437
);
438
);
438
439
439
output_html_with_http_headers $query, $cookie, $template->output;
440
output_html_with_http_headers $query, $cookie, $template->output;
440
- 

Return to bug 17385