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

(-)a/C4/XSLT.pm (-3 / +74 lines)
Lines 48-53 BEGIN { Link Here
48
    @ISA = qw(Exporter);
48
    @ISA = qw(Exporter);
49
    @EXPORT = qw(
49
    @EXPORT = qw(
50
        &XSLTParse4Display
50
        &XSLTParse4Display
51
        &CustomXSLTExportList
51
    );
52
    );
52
    $engine=Koha::XSLT_Handler->new( { do_not_return_source => 1 } );
53
    $engine=Koha::XSLT_Handler->new( { do_not_return_source => 1 } );
53
}
54
}
Lines 188-200 sub get_xslt_sysprefs { Link Here
188
}
189
}
189
190
190
sub XSLTParse4Display {
191
sub XSLTParse4Display {
191
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang ) = @_;
192
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $xslFile, $opac ) = @_;
192
193
193
    $sysxml ||= C4::Context->preference($xslsyspref);
194
    $sysxml ||= C4::Context->preference($xslsyspref);
194
    $xslfilename ||= C4::Context->preference($xslsyspref);
195
    $xslfilename ||= C4::Context->preference($xslsyspref);
195
    $lang ||= C4::Languages::getlanguage();
196
    $lang ||= C4::Languages::getlanguage();
196
197
197
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
198
    if ($xslFile) {
199
        my $myDir;
200
        if ($opac) {
201
            $myDir = C4::Context->config('opachtdocs') .
202
                '/' . C4::Context->preference("opacthemes") .
203
                '/' . C4::Languages::getlanguage() .
204
                '/xslt/biblioexport';
205
        } else {
206
            $myDir = C4::Context->config('intrahtdocs') .
207
                '/' . C4::Context->preference("template") .
208
                '/' . C4::Languages::getlanguage() .
209
                '/xslt/biblioexport';
210
            }
211
            $xslfilename = $myDir."/".$xslFile;
212
    }elsif( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
198
        my $htdocs;
213
        my $htdocs;
199
        my $theme;
214
        my $theme;
200
        my $xslfile;
215
        my $xslfile;
Lines 242-248 sub XSLTParse4Display { Link Here
242
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
257
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
243
    my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
258
    my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
244
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
259
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
245
246
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
260
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
247
    if ($fixamps) { # We need to correct the HTML entities that Zebra outputs
261
    if ($fixamps) { # We need to correct the HTML entities that Zebra outputs
248
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
262
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
Lines 351-356 Returns reference to XSLT handler object. Link Here
351
sub engine {
365
sub engine {
352
    return $engine;
366
    return $engine;
353
}
367
}
368
=head2 CustomXSLTExportList
369
370
 Returns list of file for custom xslt conversion
371
372
=cut
373
374
sub CustomXSLTExportList {
375
    my $opac = shift; # opac (1) vs intranet (0)
376
    my @tabFiles;
377
378
    my $myDir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
379
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
380
                      '/' . C4::Languages::getlanguage() .
381
                      '/xslt/biblioexport';
382
    my @files = <$myDir/*.xsl>;
383
    foreach my $file (@files) {
384
        if ( -f "$file" ) {
385
            local $/ = undef;
386
            open FILE, $file or die $!;
387
            my @lines = split('\n', <FILE>);
388
            close (FILE);
389
            (my $text = $file) =~ s/.*\///g;
390
            my $title = "";
391
            my $outputformat = "";
392
            ## Get title of the option
393
394
            foreach my $line (@lines){
395
                next unless $line =~ /xml/;
396
                $line =~ /title="([\w\s]+)"/;
397
                $title = $1;
398
399
                last if defined $title;
400
            }
401
            ($title = $text) =~ s/\.xsl// unless defined $title;
402
403
            ## Get output format
404
            foreach my $line (@lines){
405
                next unless $line =~ /xsl:output/;
406
                $line =~ /method="([\w\s]+)"/;
407
                $outputformat = $1;
408
409
                last if defined $outputformat;
410
            }
411
            $outputformat = "txt" if ($outputformat eq "" || $outputformat eq "text");
412
413
            my %row = (
414
                value       => $text,
415
                filename    => $title,
416
                format      => $outputformat,
417
            );
418
419
            push @tabFiles, \%row;
420
        }
421
    }
422
    return \@tabFiles;
423
}
424
354
425
355
1;
426
1;
356
427
(-)a/Koha/XSLT_Handler.pm (-1 lines)
Lines 165-171 sub transform { Link Here
165
    } else {
165
    } else {
166
        ( $xml, $filename ) = @_;
166
        ( $xml, $filename ) = @_;
167
    }
167
    }
168
169
    #Initialized yet?
168
    #Initialized yet?
170
    if ( !$self->{xslt_hash} ) {
169
    if ( !$self->{xslt_hash} ) {
171
        $self->_init;
170
        $self->_init;
(-)a/basket/basket.pl (+2 lines)
Lines 23-28 use C4::Biblio; Link Here
23
use C4::Items;
23
use C4::Items;
24
use C4::Auth;
24
use C4::Auth;
25
use C4::Output;
25
use C4::Output;
26
use C4::XSLT;
26
27
27
use Koha::AuthorisedValues;
28
use Koha::AuthorisedValues;
28
use Koha::CsvProfiles;
29
use Koha::CsvProfiles;
Lines 123-128 my $resultsarray = \@results; Link Here
123
$template->param(
124
$template->param(
124
    BIBLIO_RESULTS => $resultsarray,
125
    BIBLIO_RESULTS => $resultsarray,
125
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ],
126
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ],
127
    xsl_exports => CustomXSLTExportList(),
126
    bib_list => $bib_list,
128
    bib_list => $bib_list,
127
);
129
);
128
130
(-)a/basket/downloadcart.pl (-1 / +6 lines)
Lines 28-34 use C4::Items; Link Here
28
use C4::Output;
28
use C4::Output;
29
use C4::Record;
29
use C4::Record;
30
use C4::Ris;
30
use C4::Ris;
31
31
use C4::XSLT;
32
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
33
33
34
use utf8;
34
use utf8;
Lines 77-87 if ($bib_list && $format) { Link Here
77
            elsif ($format eq 'bibtex') {
77
            elsif ($format eq 'bibtex') {
78
                $output .= marc2bibtex($record, $biblio);
78
                $output .= marc2bibtex($record, $biblio);
79
            }
79
            }
80
            elsif ($format =~ /^xsl\.(.*)$/) {
81
                $output .= XSLTParse4Display($biblio, $record, 'Results', 1, undef, , '', $1, '', $1 );
82
            }
80
        }
83
        }
81
    }
84
    }
82
85
83
    # If it was a CSV export we change the format after the export so the file extension is fine
86
    # 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+$/);
87
    $format = "csv" if ($format =~ m/^\d+$/);
88
    $format = "html" if ($format =~ /^xsl\./);
85
89
86
    print $query->header(
90
    print $query->header(
87
	-type => 'application/octet-stream',
91
	-type => 'application/octet-stream',
Lines 91-96 if ($bib_list && $format) { Link Here
91
95
92
} else { 
96
} else { 
93
    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ]);
97
    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ]);
98
    $template->param(xsl_exports => CustomXSLTExportList());
94
    $template->param(bib_list => $bib_list); 
99
    $template->param(bib_list => $bib_list); 
95
    output_html_with_http_headers $query, $cookie, $template->output;
100
    output_html_with_http_headers $query, $cookie, $template->output;
96
}
101
}
(-)a/catalogue/detail.pl (+3 lines)
Lines 62-67 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( Link Here
62
    }
62
    }
63
);
63
);
64
64
65
##### ADD CUSTOM XSLT
66
$template->param(filesOptions => CustomXSLTExportList(0));
67
65
my $biblionumber = $query->param('biblionumber');
68
my $biblionumber = $query->param('biblionumber');
66
$biblionumber = HTML::Entities::encode($biblionumber);
69
$biblionumber = HTML::Entities::encode($biblionumber);
67
my $record       = GetMarcBiblio($biblionumber);
70
my $record       = GetMarcBiblio($biblionumber);
(-)a/catalogue/export.pl (+15 lines)
Lines 8-13 use C4::Output; Link Here
8
use C4::Biblio;
8
use C4::Biblio;
9
use CGI qw ( -utf8 );
9
use CGI qw ( -utf8 );
10
use C4::Ris;
10
use C4::Ris;
11
use C4::XSLT;
11
12
12
13
13
14
Lines 77-80 if ($op eq "export") { Link Here
77
                -attachment=>"bib-$biblionumber.$format");
78
                -attachment=>"bib-$biblionumber.$format");
78
            print $marc;
79
            print $marc;
79
        }
80
        }
81
}elsif ($op eq "exportxsl"){
82
    my $biblionumber = $query->param("bib");
83
    if ($biblionumber){
84
        my $xslFile = $query->param("file");
85
        my $marc = GetMarcBiblio($biblionumber, 1);
86
        my $format=$query->param("format")||'txt';
87
        my @hiddenitems;
88
89
        $marc = XSLTParse4Display($biblionumber, $marc, 'Results', 1, \@hiddenitems,'', $xslFile,'', $xslFile);
90
        print $query->header(
91
            -type => 'application/octet-stream',
92
            -attachment=>"bib-$biblionumber.$format");
93
        print $marc;
94
    }
80
}
95
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (+3 lines)
Lines 222-227 CAN_user_serials_create_subscription ) %] Link Here
222
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcstd&amp;op=export&amp;bib=[% biblionumber %]">MARC (Unicode/UTF-8, Standard)</a></li>
222
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcstd&amp;op=export&amp;bib=[% biblionumber %]">MARC (Unicode/UTF-8, Standard)</a></li>
223
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=mods&amp;op=export&amp;bib=[% biblionumber %]">MODS (XML)</a></li>
223
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=mods&amp;op=export&amp;bib=[% biblionumber %]">MODS (XML)</a></li>
224
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=ris&amp;op=export&amp;bib=[% biblionumber %]">RIS</a></li>
224
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=ris&amp;op=export&amp;bib=[% biblionumber %]">RIS</a></li>
225
        [% FOREACH filesOption IN filesOptions %]
226
            <li><a href="/cgi-bin/koha/catalogue/export.pl?format=[% filesOption.format %]&amp;op=exportxsl&amp;file=[% filesOption.value %]&amp;bib=[% biblionumber %]">[% filesOption.filename %]</a></li>
227
        [% END %]
225
    </ul>
228
    </ul>
226
    </div>
229
    </div>
227
230
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc (+3 lines)
Lines 49-54 Link Here
49
                    [% FOREACH csv_profile IN csv_profiles %]
49
                    [% FOREACH csv_profile IN csv_profiles %]
50
                        <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=[% csv_profile.export_format_id %]&amp;shelfid=[% shelf.shelfnumber %]">CSV - [% csv_profile.profile %]</a></li>
50
                        <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=[% csv_profile.export_format_id %]&amp;shelfid=[% shelf.shelfnumber %]">CSV - [% csv_profile.profile %]</a></li>
51
                    [% END %]
51
                    [% END %]
52
                    [% FOREACH xsl_export IN xsl_exports %]
53
                        <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=xsl.[% xsl_export.value %]&amp;shelfid=[% shelf.shelfnumber %]">XSL - [% xsl_export.filename %]</a></li>
54
                    [% END %]
52
                </ul>
55
                </ul>
53
        </div>
56
        </div>
54
        <div class="btn-group"><a class="btn btn-default btn-sm" href="#" id="sendlist"><i class="fa fa-envelope"></i> Send list</a></div>
57
        <div class="btn-group"><a class="btn btn-default btn-sm" href="#" id="sendlist"><i class="fa fa-envelope"></i> Send list</a></div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt (+3 lines)
Lines 61-66 Link Here
61
        [% FOREACH csv_profile IN csv_profiles %]
61
        [% FOREACH csv_profile IN csv_profiles %]
62
            <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=[% csv_profile.export_format_id %]&amp;bib_list=[% bib_list %]">CSV - [% csv_profile.profile %]</a></li>
62
            <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=[% csv_profile.export_format_id %]&amp;bib_list=[% bib_list %]">CSV - [% csv_profile.profile %]</a></li>
63
        [% END %]
63
        [% END %]
64
        [% FOREACH xsl_export IN xsl_exports %]
65
            <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=xsl.[% xsl_export.value %]&amp;bib_list=[% bib_list %]">XSL - [% xsl_export.filename %]</a></li>
66
        [% END %]
64
        </ul>
67
        </ul>
65
    </div>
68
    </div>
66
    <a class="btn btn-default btn-sm" href="basket.pl" id="print_cart"><i class="fa fa-print"></i> Print</a>
69
    <a class="btn btn-default btn-sm" 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 (-1 / +4 lines)
Lines 1119-1125 function verify_images() { Link Here
1119
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
1119
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
1120
        <option value="marcxml">MARCXML</option>
1120
        <option value="marcxml">MARCXML</option>
1121
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1121
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1122
        <option value="utf8">MARC (Unicode/UTF-8)</option>    </select>
1122
        <option value="utf8">MARC (Unicode/UTF-8)</option>
1123
        [% FOREACH filesOption IN filesOptions %]
1124
            <option value="[% filesOption.value %]">[% filesOption.filename %]</option>
1125
        [% END %]</select>
1123
        <input type="submit" name="save" value="Download Record" /></td>
1126
        <input type="submit" name="save" value="Download Record" /></td>
1124
  </tr>
1127
  </tr>
1125
  <tr><td>
1128
  <tr><td>
(-)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 %]">CSV - [% csv_profile.profile %]</option>
37
	    <option value="[% csv_profile.export_format_id %]">CSV - [% csv_profile.profile %]</option>
38
	    [% END %]
38
	    [% END %]
39
        [% FOREACH xsl_export IN xsl_exports %]
40
            <option value="xsl.[% xsl_export.value %]">XSL - [% xsl_export.filename %]</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-samples/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
<!-- xml 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/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
<!-- xml 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 (+3 lines)
Lines 67-72 Link Here
67
                                </li>
67
                                </li>
68
                                [% END %]
68
                                [% END %]
69
                            [% END %]
69
                            [% END %]
70
                            [% FOREACH filesOption IN filesOptions %]
71
                                <li><a role="menuitem" href="/cgi-bin/koha/opac-export.pl?format=[% filesOption.format %]&amp;op=exportxsl&amp;file=[% filesOption.value %]&amp;bib=[% biblionumber %]">[% filesOption.filename %]</a></li>
72
                            [% END %]
70
                        </ul>
73
                        </ul>
71
                </div>
74
                </div>
72
            </div>
75
            </div>
(-)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 %]">CSV - [% csv_profile.profile %]</option>
21
                                    <option value="[% csv_profile.export_format_id %]">CSV - [% csv_profile.profile %]</option>
22
                                [% END %]
22
                                [% END %]
23
                                [% FOREACH xsl_export IN xsl_exports %]
24
                                    <option value="xsl.[% xsl_export.value %]">XSL - [% xsl_export.filename %]</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 59-64 Link Here
59
                                            [% FOREACH csv_profile IN csv_profiles %]
59
                                            [% FOREACH csv_profile IN csv_profiles %]
60
                                            <option value="[% csv_profile.export_format_id |html %]">CSV - [% csv_profile.profile |html %]</option>
60
                                            <option value="[% csv_profile.export_format_id |html %]">CSV - [% csv_profile.profile |html %]</option>
61
                                            [% END %]
61
                                            [% END %]
62
                                            [% FOREACH xsl_export IN xsl_exports %]
63
                                                <option value="xsl.[% xsl_export.value %]">XSL - [% xsl_export.filename %]</option>
64
                                            [% END %]
62
                                        </select>
65
                                        </select>
63
                                        <span class="required">Required</span>
66
                                        <span class="required">Required</span>
64
                                    </fieldset>
67
                                    </fieldset>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/biblioexport-samples/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
<!-- xml 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/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
<!-- xml 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 73-78 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
73
    }
73
    }
74
);
74
);
75
75
76
##### ADD CUSTOM XSLT
77
$template->param(filesOptions => CustomXSLTExportList(1));
78
76
my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0;
79
my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0;
77
$biblionumber = int($biblionumber);
80
$biblionumber = int($biblionumber);
78
81
(-)a/opac/opac-downloadcart.pl (+6 lines)
Lines 28-33 use C4::Items; Link Here
28
use C4::Output;
28
use C4::Output;
29
use C4::Record;
29
use C4::Record;
30
use C4::Ris;
30
use C4::Ris;
31
use C4::XSLT;
31
use Koha::CsvProfiles;
32
use Koha::CsvProfiles;
32
use Koha::RecordProcessor;
33
use Koha::RecordProcessor;
33
34
Lines 97-107 if ($bib_list && $format) { Link Here
97
                $extension = "txt";
98
                $extension = "txt";
98
                $type      = "text/plain";
99
                $type      = "text/plain";
99
            }
100
            }
101
            elsif ($format =~ /^xsl\.(.*)$/) {
102
                $output .= XSLTParse4Display($biblio, $record, 'Results', 1, undef, undef, undef, undef, $1, 1);
103
            }
100
        }
104
        }
101
    }
105
    }
102
106
103
    # If it was a CSV export we change the format after the export so the file extension is fine
107
    # If it was a CSV export we change the format after the export so the file extension is fine
104
    $format = "csv" if ($format =~ m/^\d+$/);
108
    $format = "csv" if ($format =~ m/^\d+$/);
109
    $format = "html" if ($format =~ /^xsl\./);
105
110
106
    print $query->header(
111
    print $query->header(
107
                               -type => ($type) ? $type : 'application/octet-stream',
112
                               -type => ($type) ? $type : 'application/octet-stream',
Lines 112-117 if ($bib_list && $format) { Link Here
112
117
113
} else { 
118
} else { 
114
    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ]);
119
    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ]);
120
    $template->param(xsl_exports => CustomXSLTExportList());
115
    $template->param(bib_list => $bib_list); 
121
    $template->param(bib_list => $bib_list); 
116
    output_html_with_http_headers $query, $cookie, $template->output;
122
    output_html_with_http_headers $query, $cookie, $template->output;
117
}
123
}
(-)a/opac/opac-export.pl (-1 / +10 lines)
Lines 26-31 use C4::Biblio; Link Here
26
use CGI qw ( -utf8 );
26
use CGI qw ( -utf8 );
27
use C4::Auth;
27
use C4::Auth;
28
use C4::Ris;
28
use C4::Ris;
29
use C4::XSLT;
29
use Koha::RecordProcessor;
30
use Koha::RecordProcessor;
30
31
31
my $query = CGI->new;
32
my $query = CGI->new;
Lines 34-40 my $format=$query->param("format")||'utf8'; Link Here
34
my $biblionumber = $query->param("bib")||0;
35
my $biblionumber = $query->param("bib")||0;
35
$biblionumber = int($biblionumber);
36
$biblionumber = int($biblionumber);
36
my $error = q{};
37
my $error = q{};
37
38
my $include_items = ($format =~ /bibtex/) ? 0 : 1;
38
my $include_items = ($format =~ /bibtex/) ? 0 : 1;
39
my $marc = GetMarcBiblio($biblionumber, $include_items)
39
my $marc = GetMarcBiblio($biblionumber, $include_items)
40
    if $biblionumber;
40
    if $biblionumber;
Lines 103-108 elsif ( $format =~ /isbd/ ) { Link Here
103
    });
103
    });
104
    $format = 'isbd';
104
    $format = 'isbd';
105
}
105
}
106
elsif ($format =~ /html/ ) {
107
    if ($biblionumber){
108
        my $xslFile = $query->param("file");
109
        $marc = C4::Biblio::GetMarcBiblio($biblionumber);
110
        my @hiddenitems;
111
112
        $marc = XSLTParse4Display($biblionumber, $marc, 'Results', 1, \@hiddenitems, undef, undef, undef, $xslFile, 1);
113
    }
114
}
106
else {
115
else {
107
    $error= "Format $format is not supported.";
116
    $error= "Format $format is not supported.";
108
}
117
}
(-)a/virtualshelves/downloadshelf.pl (-1 / +5 lines)
Lines 28-33 use C4::Items; Link Here
28
use C4::Output;
28
use C4::Output;
29
use C4::Record;
29
use C4::Record;
30
use C4::Ris;
30
use C4::Ris;
31
use C4::XSLT;
31
32
32
use Koha::CsvProfiles;
33
use Koha::CsvProfiles;
33
use Koha::Virtualshelves;
34
use Koha::Virtualshelves;
Lines 81-92 if ($shelfid && $format) { Link Here
81
                    elsif ($format eq 'bibtex') {
82
                    elsif ($format eq 'bibtex') {
82
                        $output .= marc2bibtex($record, $biblionumber);
83
                        $output .= marc2bibtex($record, $biblionumber);
83
                    }
84
                    }
85
                    elsif ($format =~ /^xsl\.(.*)$/){
86
                        $output .= XSLTParse4Display($biblionumber, $record, 'Results', 1, undef, ,'',$1,'',$1);
87
                    }
84
                }
88
                }
85
            }
89
            }
86
90
87
            # 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
88
            $format = "csv" if ($format =~ m/^\d+$/);
92
            $format = "csv" if ($format =~ m/^\d+$/);
89
93
            $format = "html" if ($format =~ /^xsl\./);
90
            print $query->header(
94
            print $query->header(
91
            -type => 'application/octet-stream',
95
            -type => 'application/octet-stream',
92
            -'Content-Transfer-Encoding' => 'binary',
96
            -'Content-Transfer-Encoding' => 'binary',
(-)a/virtualshelves/shelves.pl (-1 / +1 lines)
Lines 325-330 $template->param( Link Here
325
    category => $category,
325
    category => $category,
326
    print    => scalar $query->param('print') || 0,
326
    print    => scalar $query->param('print') || 0,
327
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ],
327
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ],
328
    xsl_exports => CustomXSLTExportList()
328
);
329
);
329
330
330
output_html_with_http_headers $query, $cookie, $template->output;
331
output_html_with_http_headers $query, $cookie, $template->output;
331
- 

Return to bug 17385