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

(-)a/C4/Search.pm (-2 / +1 lines)
Lines 1776-1783 sub searchResults { Link Here
1776
	$debug && warn $marcrecord->as_formatted;
1776
	$debug && warn $marcrecord->as_formatted;
1777
	my $interface = $search_context eq 'opac' ? 'OPAC' : '';
1777
	my $interface = $search_context eq 'opac' ? 'OPAC' : '';
1778
	if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
1778
	if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
1779
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, 'Results',
1779
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $interface."XSLTResultsDisplay", 1, \@hiddenitems);
1780
                                                                $search_context, 1, \@hiddenitems);
1781
	    # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
1780
	    # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
1782
        }
1781
        }
1783
1782
(-)a/C4/VirtualShelves/Page.pm (-1 / +1 lines)
Lines 257-263 sub shelfpage { Link Here
257
                    my $biblionumber = $this_item->{'biblionumber'};
257
                    my $biblionumber = $this_item->{'biblionumber'};
258
                    my $record = GetMarcBiblio($biblionumber);
258
                    my $record = GetMarcBiblio($biblionumber);
259
                    $this_item->{XSLTBloc} =
259
                    $this_item->{XSLTBloc} =
260
                        XSLTParse4Display($biblionumber, $record, 'Results', 'opac')
260
                        XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay")
261
                            if C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac';
261
                            if C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac';
262
262
263
                    # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
263
                    # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
(-)a/C4/XSLT.pm (-21 / +59 lines)
Lines 3-8 package C4::XSLT; Link Here
3
# <jmf at liblime dot com>
3
# <jmf at liblime dot com>
4
# Parts Copyright Katrin Fischer 2011
4
# Parts Copyright Katrin Fischer 2011
5
# Parts Copyright ByWater Solutions 2011
5
# Parts Copyright ByWater Solutions 2011
6
# Parts Copyright Biblibre 2012
6
#
7
#
7
# This file is part of Koha.
8
# This file is part of Koha.
8
#
9
#
Lines 32-37 use C4::Reserves; Link Here
32
use Encode;
33
use Encode;
33
use XML::LibXML;
34
use XML::LibXML;
34
use XML::LibXSLT;
35
use XML::LibXSLT;
36
use LWP::Simple;
35
37
36
use vars qw($VERSION @ISA @EXPORT);
38
use vars qw($VERSION @ISA @EXPORT);
37
39
Lines 41-46 BEGIN { Link Here
41
    @ISA = qw(Exporter);
43
    @ISA = qw(Exporter);
42
    @EXPORT = qw(
44
    @EXPORT = qw(
43
        &XSLTParse4Display
45
        &XSLTParse4Display
46
        &GetURI
44
    );
47
    );
45
}
48
}
46
49
Lines 50-55 C4::XSLT - Functions for displaying XSLT-generated content Link Here
50
53
51
=head1 FUNCTIONS
54
=head1 FUNCTIONS
52
55
56
=head2 GetURI
57
58
GetURI file and returns the xslt as a string
59
60
=cut
61
62
sub GetURI {
63
    my ($uri) = @_;
64
    my $string;
65
    $string = get $uri ;
66
    return $string;
67
}
68
53
=head2 transformMARCXML4XSLT
69
=head2 transformMARCXML4XSLT
54
70
55
Replaces codes with authorized values in a MARC::Record object
71
Replaces codes with authorized values in a MARC::Record object
Lines 121-128 sub getAuthorisedValues4MARCSubfields { Link Here
121
my $stylesheet;
137
my $stylesheet;
122
138
123
sub XSLTParse4Display {
139
sub XSLTParse4Display {
124
    my ( $biblionumber, $orig_record, $xsl_suffix, $interface, $fixamps, $hidden_items ) = @_;
140
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_;
125
    $interface = 'opac' unless $interface;
141
    my $xslfilename = C4::Context->preference($xslsyspref);
142
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
143
        if ($xslsyspref eq "XSLTDetailsDisplay") {
144
            $xslfilename = C4::Context->config('intrahtdocs') .
145
                        '/' . C4::Context->preference("template") .
146
                        '/' . C4::Templates::_current_language() .
147
                        '/xslt/' .
148
                        C4::Context->preference('marcflavour') .
149
                        "slim2intranetDetail.xsl";
150
        } elsif ($xslsyspref eq "XSLTResultsDisplay") {
151
            $xslfilename = C4::Context->config('intrahtdocs') .
152
                        '/' . C4::Context->preference("template") .
153
                        '/' . C4::Templates::_current_language() .
154
                        '/xslt/' .
155
                        C4::Context->preference('marcflavour') .
156
                        "slim2intranetResults.xsl";
157
        } elsif ($xslsyspref eq "OPACXSLTDetailsDisplay") {
158
            $xslfilename = C4::Context->config('opachtdocs') .
159
                        '/' . C4::Context->preference("opacthemes") .
160
                        '/' . C4::Templates::_current_language() .
161
                        '/xslt/' .
162
                        C4::Context->preference('marcflavour') .
163
                        "slim2OPACDetail.xsl";
164
        } elsif ($xslsyspref eq "OPACXSLTResultsDisplay") {
165
            $xslfilename = C4::Context->config('opachtdocs') .
166
                        '/' . C4::Context->preference("opacthemes") .
167
                        '/' . C4::Templates::_current_language() .
168
                        '/xslt/' .
169
                        C4::Context->preference('marcflavour') .
170
                        "slim2OPACResults.xsl";
171
        }
172
    }
126
    # grab the XML, run it through our stylesheet, push it out to the browser
173
    # grab the XML, run it through our stylesheet, push it out to the browser
127
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
174
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
128
    #return $record->as_formatted();
175
    #return $record->as_formatted();
Lines 153-181 sub XSLTParse4Display { Link Here
153
    # don't die when you find &, >, etc
200
    # don't die when you find &, >, etc
154
    $parser->recover_silently(0);
201
    $parser->recover_silently(0);
155
    my $source = $parser->parse_string($xmlrecord);
202
    my $source = $parser->parse_string($xmlrecord);
156
    unless ( $stylesheet ) {
203
    unless ( $stylesheet->{$xslfilename} ) {
157
        my $xslt = XML::LibXSLT->new();
204
        my $xslt = XML::LibXSLT->new();
158
        my $xslfile;
205
        my $style_doc;
159
        if ($interface eq 'intranet') {
206
        if ( $xslfilename =~ /^https?:\/\// ) {
160
            $xslfile = C4::Context->config('intrahtdocs') . 
207
            my $xsltstring = GetURI($xslfilename);
161
                      '/' . C4::Context->preference("template") . 
208
            $style_doc = $parser->parse_string($xsltstring);
162
                      '/' . C4::Templates::_current_language() .
163
                      '/xslt/' .
164
                      C4::Context->preference('marcflavour') .
165
                      "slim2intranet$xsl_suffix.xsl";
166
        } else {
209
        } else {
167
            $xslfile = C4::Context->config('opachtdocs') . 
210
            use Cwd;
168
                      '/' . C4::Context->preference("opacthemes") . 
211
            $style_doc = $parser->parse_file($xslfilename);
169
                      '/' . C4::Templates::_current_language() .
170
                      '/xslt/' .
171
                      C4::Context->preference('marcflavour') .
172
                      "slim2OPAC$xsl_suffix.xsl";
173
        }
212
        }
174
        my $style_doc = $parser->parse_file($xslfile);
213
        $stylesheet->{$xslfilename} = $xslt->parse_stylesheet($style_doc);
175
        $stylesheet = $xslt->parse_stylesheet($style_doc);
176
    }
214
    }
177
    my $results = $stylesheet->transform($source);
215
    my $results      = $stylesheet->{$xslfilename}->transform($source);
178
    my $newxmlrecord = $stylesheet->output_string($results);
216
    my $newxmlrecord = $stylesheet->{$xslfilename}->output_string($results);
179
    return $newxmlrecord;
217
    return $newxmlrecord;
180
}
218
}
181
219
(-)a/catalogue/detail.pl (-1 / +1 lines)
Lines 85-91 my $marcflavour = C4::Context->preference("marcflavour"); Link Here
85
# XSLT processing of some stuff
85
# XSLT processing of some stuff
86
if (C4::Context->preference("XSLTDetailsDisplay") ) {
86
if (C4::Context->preference("XSLTDetailsDisplay") ) {
87
    $template->param('XSLTDetailsDisplay' =>'1',
87
    $template->param('XSLTDetailsDisplay' =>'1',
88
        'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail','intranet') );
88
        'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "XSLTDetailsDisplay") );
89
}
89
}
90
90
91
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
91
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
(-)a/installer/data/mysql/sysprefs.sql (-4 / +4 lines)
Lines 219-228 INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES Link Here
219
219
220
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('OPACShelfBrowser','1','','Enable/disable Shelf Browser on item details page. WARNING: this feature is very resource consuming on collections with large numbers of items.','YesNo');
220
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('OPACShelfBrowser','1','','Enable/disable Shelf Browser on item details page. WARNING: this feature is very resource consuming on collections with large numbers of items.','YesNo');
221
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES
221
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES
222
('OPACXSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on OPAC','YesNo'),
222
('OPACXSLTDetailsDisplay','','','Enable XSL stylesheet control over details page display on OPAC','Free'),
223
('OPACXSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on OPAC','YesNo'),
223
('OPACXSLTResultsDisplay','','','Enable XSL stylesheet control over results page display on OPAC','Free'),
224
('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on intranet','YesNo'),
224
('XSLTDetailsDisplay','','','Enable XSL stylesheet control over details page display on intranet','Free'),
225
('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on intranet','YesNo');
225
('XSLTResultsDisplay','','','Enable XSL stylesheet control over results page display on intranet','Free');
226
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice');
226
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice');
227
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowOnShelfHolds', '0', '', 'Allow hold requests to be placed on items that are not on loan', 'YesNo');
227
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowOnShelfHolds', '0', '', 'Allow hold requests to be placed on items that are not on loan', 'YesNo');
228
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed on damaged items', 'YesNo');
228
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed on damaged items', 'YesNo');
(-)a/installer/data/mysql/updatedatabase.pl (+30 lines)
Lines 5036-5041 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5036
    SetVersion($DBversion);
5036
    SetVersion($DBversion);
5037
}
5037
}
5038
5038
5039
$DBversion = "XXX";
5040
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5041
    my $countXSLTDetailsDisplay = 0;
5042
    my $valueXSLTDetailsDisplay = "";
5043
    my $valueXSLTResultsDisplay = "";
5044
    my $valueOPACXSLTDetailsDisplay = "";
5045
    my $valueOPACXSLTResultsDisplay = "";
5046
    #the line below test if database comes from a BibLibre's branch
5047
    $countXSLTDetailsDisplay = $dbh->do('SELECT 1 FROM systempreferences WHERE variable="IntranetXSLTDetailsDisplay"');
5048
    if ($countXSLTDetailsDisplay > 0)
5049
    {
5050
        #the two lines below will only be used to update the databases from the BibLibre's branch. They will not affect the others
5051
        $dbh->do(q|UPDATE systempreferences SET variable="XSLTDetailsDisplay" WHERE variable="IntranetXSLTDetailsDisplay"|);
5052
        $dbh->do(q|UPDATE systempreferences SET variable="XSLTResultsDisplay" WHERE variable="IntranetXSLTResultsDisplay"|);
5053
    }
5054
    else
5055
    {
5056
        $valueXSLTDetailsDisplay = "default" if (C4::Context->preference("XSLTDetailsDisplay"));
5057
        $valueXSLTResultsDisplay = "default" if (C4::Context->preference("XSLTResultsDisplay"));
5058
        $valueOPACXSLTDetailsDisplay = "default" if (C4::Context->preference("OPACXSLTDetailsDisplay"));
5059
        $valueOPACXSLTResultsDisplay = "default" if (C4::Context->preference("OPACXSLTResultsDisplay"));
5060
        $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTDetailsDisplay\" WHERE variable='XSLTDetailsDisplay'");
5061
        $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTResultsDisplay\" WHERE variable='XSLTResultsDisplay'");
5062
        $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTDetailsDisplay\" WHERE variable='OPACXSLTDetailsDisplay'");
5063
        $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTResultsDisplay\" WHERE variable='OPACXSLTResultsDisplay'");
5064
    }
5065
    print "XSLT systempreference takes a path to file rather than YesNo\n";
5066
    SetVersion($DBversion);
5067
}
5068
5039
=head1 FUNCTIONS
5069
=head1 FUNCTIONS
5040
5070
5041
=head2 DropAllForeignKeys($table)
5071
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-8 / +6 lines)
Lines 48-64 OPAC: Link Here
48
                  no: Show
48
                  no: Show
49
            - lost items on search and detail pages.
49
            - lost items on search and detail pages.
50
        -
50
        -
51
            - Show biblio records on OPAC result page
51
            - 'Display OPAC results using XSLT stylesheet at: '
52
            - pref: OPACXSLTResultsDisplay
52
            - pref: OPACXSLTResultsDisplay
53
              choices:
53
              class: file
54
                  yes: using XSLT stylesheets.
54
            - '<br />Options:<br />- leave empty for "no xslt"<br />- enter "default" for the default one<br />- put a path to define a xslt file<br />- put an URL for an external specific stylesheet.'
55
                  no: normally.
56
        -
55
        -
57
            - Show item details pages on the OPAC
56
            - 'Display OPAC details using XSLT stylesheet at: '
58
            - pref: OPACXSLTDetailsDisplay
57
            - pref: OPACXSLTDetailsDisplay
59
              choices:
58
              class: file
60
                  yes: using XSLT stylesheets.
59
            - '<br />Options:<br />- leave empty for "no xslt"<br />- enter "default" for the default one<br />- put a path to define a xslt file<br />- put an URL for an external specific stylesheet.'
61
                  no: normally.
62
        -
60
        -
63
            - On pages displayed with XSLT stylesheets on the OPAC,
61
            - On pages displayed with XSLT stylesheets on the OPAC,
64
            - pref: DisplayOPACiconsXSLT
62
            - pref: DisplayOPACiconsXSLT
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref (-8 / +6 lines)
Lines 51-67 Staff Client: Link Here
51
              class: url
51
              class: url
52
            - for the Staff Client's favicon. (This should be a complete URL, starting with <code>http://</code>.)
52
            - for the Staff Client's favicon. (This should be a complete URL, starting with <code>http://</code>.)
53
        -
53
        -
54
            - Show biblio records on result page in the staff client
54
            - 'Display results in the staff client using XSLT stylesheet at: '
55
            - pref: XSLTResultsDisplay
55
            - pref: XSLTResultsDisplay
56
              choices:
56
              class: file
57
                  yes: using XSLT stylesheets.
57
            - '<br />Options:<br />- leave empty for "no xslt"<br />- enter "default" for the default one<br />- put a path to define a xslt file<br />- put an URL for an external specific stylesheet.'
58
                  no: normally.
59
        -
58
        -
60
            - Show item details pages in the staff client
59
            - 'Display details in the staff client using XSLT stylesheet at: '
61
            - pref: XSLTDetailsDisplay
60
            - pref: XSLTDetailsDisplay
62
              choices:
61
              class: file
63
                  yes: using XSLT stylesheets.
62
            - '<br />Options:<br />- leave empty for "no xslt"<br />- enter "default" for the default one<br />- put a path to define a xslt file<br />- put an URL for an external specific stylesheet.'
64
                  no: normally.
65
        -
63
        -
66
            - Use the Yahoo UI libraries
64
            - Use the Yahoo UI libraries
67
            - pref: yuipath
65
            - pref: yuipath
(-)a/opac/opac-detail.pl (-2 / +1 lines)
Lines 92-98 SetUTF8Flag($record); Link Here
92
92
93
# XSLT processing of some stuff
93
# XSLT processing of some stuff
94
if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
94
if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
95
    $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail', 'opac') );
95
    $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "OPACXSLTDetailsDisplay" ) );
96
}
96
}
97
97
98
98
99
- 

Return to bug 4032