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

(-)a/C4/Search.pm (-4 / +2 lines)
Lines 1781-1788 sub searchResults { Link Here
1781
	$debug && warn $marcrecord->as_formatted;
1781
	$debug && warn $marcrecord->as_formatted;
1782
	my $interface = $search_context eq 'opac' ? 'OPAC' : '';
1782
	my $interface = $search_context eq 'opac' ? 'OPAC' : '';
1783
	if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
1783
	if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
1784
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, 'Results',
1784
            $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $interface."XSLTResultsDisplay", 1);
1785
                                                                $search_context, 1);
1786
	    # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
1785
	    # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
1787
        }
1786
        }
1788
1787
Lines 1850-1857 sub searchResults { Link Here
1850
            $oldbiblio->{XSLTResultsRecord}
1849
            $oldbiblio->{XSLTResultsRecord}
1851
              = XSLTParse4Display($oldbiblio->{biblionumber},
1850
              = XSLTParse4Display($oldbiblio->{biblionumber},
1852
                                  $marcrecord,
1851
                                  $marcrecord,
1853
                                  'Results',
1852
                                  "OPACXSLTResultsDisplay",
1854
                                  $search_context,
1855
                                  1, # clean up the problematic ampersand entities that Zebra outputs
1853
                                  1, # clean up the problematic ampersand entities that Zebra outputs
1856
                                  \@hiddenitems
1854
                                  \@hiddenitems
1857
                                );
1855
                                );
(-)a/C4/VirtualShelves/Page.pm (-1 / +1 lines)
Lines 208-214 sub shelfpage ($$$$$) { Link Here
208
                    my $biblionumber = $this_item->{'biblionumber'};
208
                    my $biblionumber = $this_item->{'biblionumber'};
209
                    my $record = GetMarcBiblio($biblionumber);
209
                    my $record = GetMarcBiblio($biblionumber);
210
                    $this_item->{XSLTBloc} =
210
                    $this_item->{XSLTBloc} =
211
                        XSLTParse4Display($biblionumber, $record, 'Results', 'opac')
211
                        XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay")
212
                            if C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac';
212
                            if C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac';
213
213
214
                    # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
214
                    # 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 84-90 my $marcflavour = C4::Context->preference("marcflavour"); Link Here
84
# XSLT processing of some stuff
84
# XSLT processing of some stuff
85
if (C4::Context->preference("XSLTDetailsDisplay") ) {
85
if (C4::Context->preference("XSLTDetailsDisplay") ) {
86
    $template->param('XSLTDetailsDisplay' =>'1',
86
    $template->param('XSLTDetailsDisplay' =>'1',
87
        'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail','intranet') );
87
        'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "XSLTDetailsDisplay") );
88
}
88
}
89
89
90
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
90
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
(-)a/installer/data/mysql/sysprefs.sql (-4 / +4 lines)
Lines 218-227 INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES Link Here
218
218
219
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');
219
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
220
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES
221
('OPACXSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on OPAC','YesNo'),
221
('OPACXSLTDetailsDisplay','','','Enable XSL stylesheet control over details page display on OPAC','Free'),
222
('OPACXSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on OPAC','YesNo'),
222
('OPACXSLTResultsDisplay','','','Enable XSL stylesheet control over results page display on OPAC','Free'),
223
('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on intranet','YesNo'),
223
('XSLTDetailsDisplay','','','Enable XSL stylesheet control over details page display on intranet','Free'),
224
('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on intranet','YesNo');
224
('XSLTResultsDisplay','','','Enable XSL stylesheet control over results page display on intranet','Free');
225
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');
225
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('AllowOnShelfHolds', '0', '', 'Allow hold requests to be placed on items that are not on loan', 'YesNo');
226
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('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed on damaged items', 'YesNo');
227
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 4663-4668 ENDOFRENEWAL Link Here
4663
    print "Upgrade to $DBversion done (Added a system preference to allow renewal of Patron account either from todays date or from existing expiry date in the patrons account.)\n";
4663
    print "Upgrade to $DBversion done (Added a system preference to allow renewal of Patron account either from todays date or from existing expiry date in the patrons account.)\n";
4664
    SetVersion($DBversion);
4664
    SetVersion($DBversion);
4665
}
4665
}
4666
4667
$DBversion = "XXX";
4668
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4669
    my $countXSLTDetailsDisplay = 0;
4670
    my $valueXSLTDetailsDisplay = "";
4671
    my $valueXSLTResultsDisplay = "";
4672
    my $valueOPACXSLTDetailsDisplay = "";
4673
    my $valueOPACXSLTResultsDisplay = "";
4674
    #the line below test if database comes from a BibLibre's branch
4675
    $countXSLTDetailsDisplay = $dbh->do('SELECT 1 FROM `systempreferences` WHERE `variable`="IntranetXSLTDetailsDisplay"');
4676
    if ($countXSLTDetailsDisplay > 0)
4677
    {
4678
        #the two lines below will only be used to update the databases from the BibLibre's branch. They will not affect the others
4679
        $dbh->do(q|UPDATE `systempreferences` SET `variable`="XSLTDetailsDisplay" WHERE `variable`="IntranetXSLTDetailsDisplay"|);
4680
        $dbh->do(q|UPDATE `systempreferences` SET `variable`="XSLTResultsDisplay" WHERE `variable`="IntranetXSLTResultsDisplay"|);
4681
    }
4682
    else
4683
    {
4684
        $valueXSLTDetailsDisplay = "default" if (C4::Context->preference("XSLTDetailsDisplay"));
4685
        $valueXSLTResultsDisplay = "default" if (C4::Context->preference("XSLTResultsDisplay"));
4686
        $valueOPACXSLTDetailsDisplay = "default" if (C4::Context->preference("OPACXSLTDetailsDisplay"));
4687
        $valueOPACXSLTResultsDisplay = "default" if (C4::Context->preference("OPACXSLTResultsDisplay"));
4688
        $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTDetailsDisplay\" WHERE variable='XSLTDetailsDisplay'");
4689
        $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTResultsDisplay\" WHERE variable='XSLTResultsDisplay'");
4690
        $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTDetailsDisplay\" WHERE variable='OPACXSLTDetailsDisplay'");
4691
        $dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTResultsDisplay\" WHERE variable='OPACXSLTResultsDisplay'");
4692
    }
4693
    print "XSLT systempreference takes a path to file rather than YesNo\n";
4694
    SetVersion($DBversion);
4695
}
4666
=head1 FUNCTIONS
4696
=head1 FUNCTIONS
4667
4697
4668
=head2 DropAllForeignKeys($table)
4698
=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 79-85 SetUTF8Flag($record); Link Here
79
79
80
# XSLT processing of some stuff
80
# XSLT processing of some stuff
81
if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
81
if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
82
    $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail', 'opac') );
82
    $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "OPACXSLTDetailsDisplay" ) );
83
}
83
}
84
84
85
85
86
- 

Return to bug 4032