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

(-)a/C4/XSLT.pm (-3 / +74 lines)
Lines 46-51 BEGIN { Link Here
46
    @ISA = qw(Exporter);
46
    @ISA = qw(Exporter);
47
    @EXPORT = qw(
47
    @EXPORT = qw(
48
        &XSLTParse4Display
48
        &XSLTParse4Display
49
        &CustomXSLTExportList
49
    );
50
    );
50
    $engine=Koha::XSLT_Handler->new( { do_not_return_source => 1 } );
51
    $engine=Koha::XSLT_Handler->new( { do_not_return_source => 1 } );
51
}
52
}
Lines 186-198 sub get_xslt_sysprefs { Link Here
186
}
187
}
187
188
188
sub XSLTParse4Display {
189
sub XSLTParse4Display {
189
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang ) = @_;
190
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items, $sysxml, $xslfilename, $lang, $xslFile, $opac ) = @_;
190
191
191
    $sysxml ||= C4::Context->preference($xslsyspref);
192
    $sysxml ||= C4::Context->preference($xslsyspref);
192
    $xslfilename ||= C4::Context->preference($xslsyspref);
193
    $xslfilename ||= C4::Context->preference($xslsyspref);
193
    $lang ||= C4::Languages::getlanguage();
194
    $lang ||= C4::Languages::getlanguage();
194
195
195
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
196
    if ($xslFile) {
197
        my $myDir;
198
        if ($opac) {
199
            $myDir = C4::Context->config('opachtdocs') .
200
                '/' . C4::Context->preference("opacthemes") .
201
                '/' . C4::Languages::getlanguage() .
202
                '/xslt/biblioexport';
203
        } else {
204
            $myDir = C4::Context->config('intrahtdocs') .
205
                '/' . C4::Context->preference("template") .
206
                '/' . C4::Languages::getlanguage() .
207
                '/xslt/biblioexport';
208
            }
209
            $xslfilename = $myDir."/".$xslFile;
210
    }elsif( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
196
        my $htdocs;
211
        my $htdocs;
197
        my $theme;
212
        my $theme;
198
        my $xslfile;
213
        my $xslfile;
Lines 240-246 sub XSLTParse4Display { Link Here
240
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
255
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
241
    my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
256
    my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
242
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
257
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
243
244
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
258
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
245
    if ($fixamps) { # We need to correct the HTML entities that Zebra outputs
259
    if ($fixamps) { # We need to correct the HTML entities that Zebra outputs
246
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
260
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
Lines 345-350 Returns reference to XSLT handler object. Link Here
345
sub engine {
359
sub engine {
346
    return $engine;
360
    return $engine;
347
}
361
}
362
=head2 CustomXSLTExportList
363
364
 Returns list of file for custom xslt conversion
365
366
=cut
367
368
sub CustomXSLTExportList {
369
    my $opac = shift; # opac (1) vs intranet (0)
370
    my @tabFiles;
371
372
    my $myDir = C4::Context->config( $opac ? 'opachtdocs' : 'intrahtdocs') .
373
                      '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
374
                      '/' . C4::Languages::getlanguage() .
375
                      '/xslt/biblioexport';
376
    my @files = <$myDir/*.xsl>;
377
    foreach my $file (@files) {
378
        if ( -f "$file" ) {
379
            local $/ = undef;
380
            open FILE, $file or die $!;
381
            my @lines = split('\n', <FILE>);
382
            close (FILE);
383
            (my $text = $file) =~ s/.*\///g;
384
            my $title = "";
385
            my $outputformat = "";
386
            ## Get title of the option
387
388
            foreach my $line (@lines){
389
                next unless $line =~ /xml/;
390
                $line =~ /title="([\w\s]+)"/;
391
                $title = $1;
392
393
                last if defined $title;
394
            }
395
            ($title = $text) =~ s/\.xsl// unless defined $title;
396
397
            ## Get output format
398
            foreach my $line (@lines){
399
                next unless $line =~ /xsl:output/;
400
                $line =~ /method="([\w\s]+)"/;
401
                $outputformat = $1;
402
403
                last if defined $outputformat;
404
            }
405
            $outputformat = "txt" if ($outputformat eq "" || $outputformat eq "text");
406
407
            my %row = (
408
                value       => $text,
409
                filename    => $title,
410
                format      => $outputformat,
411
            );
412
413
            push @tabFiles, \%row;
414
        }
415
    }
416
    return \@tabFiles;
417
}
418
348
419
349
1;
420
1;
350
421
(-)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::CsvProfiles;
28
use Koha::CsvProfiles;
28
29
Lines 122-127 my $resultsarray = \@results; Link Here
122
$template->param(
123
$template->param(
123
    BIBLIO_RESULTS => $resultsarray,
124
    BIBLIO_RESULTS => $resultsarray,
124
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ],
125
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ],
126
    xsl_exports => CustomXSLTExportList(),
125
    bib_list => $bib_list,
127
    bib_list => $bib_list,
126
);
128
);
127
129
(-)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' }) ]);
97
    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]);
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 57-62 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( Link Here
57
    }
57
    }
58
);
58
);
59
59
60
##### ADD CUSTOM XSLT
61
$template->param(filesOptions => CustomXSLTExportList(0));
62
60
my $biblionumber = $query->param('biblionumber');
63
my $biblionumber = $query->param('biblionumber');
61
$biblionumber = HTML::Entities::encode($biblionumber);
64
$biblionumber = HTML::Entities::encode($biblionumber);
62
my $record       = GetMarcBiblio($biblionumber);
65
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-small" href="#" id="sendlist"><i class="fa fa-envelope"></i> Send list</a></div>
57
        <div class="btn-group"><a class="btn btn-small" 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-small" href="basket.pl" id="print_cart"><i class="fa fa-print"></i> Print</a>
69
    <a class="btn btn-small" 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 1094-1100 function verify_images() { Link Here
1094
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
1094
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option>
1095
        <option value="marcxml">MARCXML</option>
1095
        <option value="marcxml">MARCXML</option>
1096
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1096
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1097
        <option value="utf8">MARC (Unicode/UTF-8)</option>    </select>
1097
        <option value="utf8">MARC (Unicode/UTF-8)</option>
1098
        [% FOREACH filesOption IN filesOptions %]
1099
            <option value="[% filesOption.value %]">[% filesOption.filename %]</option>
1100
        [% END %]</select>
1098
        <input type="submit" name="save" value="Download Record" /></td>
1101
        <input type="submit" name="save" value="Download Record" /></td>
1099
  </tr>
1102
  </tr>
1100
  <tr><td>
1103
  <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 56-61 Link Here
56
                                </li>
56
                                </li>
57
                                [% END %]
57
                                [% END %]
58
                            [% END %]
58
                            [% END %]
59
                            [% FOREACH filesOption IN filesOptions %]
60
                                <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>
61
                            [% END %]
59
                        </ul>
62
                        </ul>
60
                </div>
63
                </div>
61
            </div>
64
            </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 69-74 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
69
    }
69
    }
70
);
70
);
71
71
72
##### ADD CUSTOM XSLT
73
$template->param(filesOptions => CustomXSLTExportList(1));
74
72
my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0;
75
my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0;
73
$biblionumber = int($biblionumber);
76
$biblionumber = int($biblionumber);
74
77
(-)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' }) ]);
119
    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]);
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 312-317 $template->param( Link Here
312
    category => $category,
312
    category => $category,
313
    print    => scalar $query->param('print') || 0,
313
    print    => scalar $query->param('print') || 0,
314
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ],
314
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ],
315
    xsl_exports => CustomXSLTExportList()
315
);
316
);
316
317
317
output_html_with_http_headers $query, $cookie, $template->output;
318
output_html_with_http_headers $query, $cookie, $template->output;
318
- 

Return to bug 17385