Bug 4032 XSLT systempreference takes a path to file rather than YesNo

Signed-off-by: Marijana Glavica <mglavica@ffzg.hr>

I am signing it off because it doesn't break anything and I will report
another bug for language issues described in my previous comment.

Removed MySQLism backquotes
This commit is contained in:
Stéphane Delaune 2012-02-08 12:12:16 +01:00 committed by Paul Poulain
parent 9d394e12fc
commit df0a6a71d7
9 changed files with 109 additions and 46 deletions

View file

@ -1776,8 +1776,7 @@ sub searchResults {
$debug && warn $marcrecord->as_formatted;
my $interface = $search_context eq 'opac' ? 'OPAC' : '';
if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
$oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, 'Results',
$search_context, 1, \@hiddenitems);
$oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $interface."XSLTResultsDisplay", 1, \@hiddenitems);
# the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
}

View file

@ -257,7 +257,7 @@ sub shelfpage {
my $biblionumber = $this_item->{'biblionumber'};
my $record = GetMarcBiblio($biblionumber);
$this_item->{XSLTBloc} =
XSLTParse4Display($biblionumber, $record, 'Results', 'opac')
XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay")
if C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac';
# the virtualshelfcontents table does not store these columns nor are they retrieved from the items

View file

@ -3,6 +3,7 @@ package C4::XSLT;
# <jmf at liblime dot com>
# Parts Copyright Katrin Fischer 2011
# Parts Copyright ByWater Solutions 2011
# Parts Copyright Biblibre 2012
#
# This file is part of Koha.
#
@ -32,6 +33,7 @@ use C4::Reserves;
use Encode;
use XML::LibXML;
use XML::LibXSLT;
use LWP::Simple;
use vars qw($VERSION @ISA @EXPORT);
@ -41,6 +43,7 @@ BEGIN {
@ISA = qw(Exporter);
@EXPORT = qw(
&XSLTParse4Display
&GetURI
);
}
@ -50,6 +53,19 @@ C4::XSLT - Functions for displaying XSLT-generated content
=head1 FUNCTIONS
=head2 GetURI
GetURI file and returns the xslt as a string
=cut
sub GetURI {
my ($uri) = @_;
my $string;
$string = get $uri ;
return $string;
}
=head2 transformMARCXML4XSLT
Replaces codes with authorized values in a MARC::Record object
@ -121,8 +137,39 @@ sub getAuthorisedValues4MARCSubfields {
my $stylesheet;
sub XSLTParse4Display {
my ( $biblionumber, $orig_record, $xsl_suffix, $interface, $fixamps, $hidden_items ) = @_;
$interface = 'opac' unless $interface;
my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_;
my $xslfilename = C4::Context->preference($xslsyspref);
if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
if ($xslsyspref eq "XSLTDetailsDisplay") {
$xslfilename = C4::Context->config('intrahtdocs') .
'/' . C4::Context->preference("template") .
'/' . C4::Templates::_current_language() .
'/xslt/' .
C4::Context->preference('marcflavour') .
"slim2intranetDetail.xsl";
} elsif ($xslsyspref eq "XSLTResultsDisplay") {
$xslfilename = C4::Context->config('intrahtdocs') .
'/' . C4::Context->preference("template") .
'/' . C4::Templates::_current_language() .
'/xslt/' .
C4::Context->preference('marcflavour') .
"slim2intranetResults.xsl";
} elsif ($xslsyspref eq "OPACXSLTDetailsDisplay") {
$xslfilename = C4::Context->config('opachtdocs') .
'/' . C4::Context->preference("opacthemes") .
'/' . C4::Templates::_current_language() .
'/xslt/' .
C4::Context->preference('marcflavour') .
"slim2OPACDetail.xsl";
} elsif ($xslsyspref eq "OPACXSLTResultsDisplay") {
$xslfilename = C4::Context->config('opachtdocs') .
'/' . C4::Context->preference("opacthemes") .
'/' . C4::Templates::_current_language() .
'/xslt/' .
C4::Context->preference('marcflavour') .
"slim2OPACResults.xsl";
}
}
# grab the XML, run it through our stylesheet, push it out to the browser
my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
#return $record->as_formatted();
@ -153,29 +200,20 @@ sub XSLTParse4Display {
# don't die when you find &, >, etc
$parser->recover_silently(0);
my $source = $parser->parse_string($xmlrecord);
unless ( $stylesheet ) {
unless ( $stylesheet->{$xslfilename} ) {
my $xslt = XML::LibXSLT->new();
my $xslfile;
if ($interface eq 'intranet') {
$xslfile = C4::Context->config('intrahtdocs') .
'/' . C4::Context->preference("template") .
'/' . C4::Templates::_current_language() .
'/xslt/' .
C4::Context->preference('marcflavour') .
"slim2intranet$xsl_suffix.xsl";
my $style_doc;
if ( $xslfilename =~ /^https?:\/\// ) {
my $xsltstring = GetURI($xslfilename);
$style_doc = $parser->parse_string($xsltstring);
} else {
$xslfile = C4::Context->config('opachtdocs') .
'/' . C4::Context->preference("opacthemes") .
'/' . C4::Templates::_current_language() .
'/xslt/' .
C4::Context->preference('marcflavour') .
"slim2OPAC$xsl_suffix.xsl";
use Cwd;
$style_doc = $parser->parse_file($xslfilename);
}
my $style_doc = $parser->parse_file($xslfile);
$stylesheet = $xslt->parse_stylesheet($style_doc);
$stylesheet->{$xslfilename} = $xslt->parse_stylesheet($style_doc);
}
my $results = $stylesheet->transform($source);
my $newxmlrecord = $stylesheet->output_string($results);
my $results = $stylesheet->{$xslfilename}->transform($source);
my $newxmlrecord = $stylesheet->{$xslfilename}->output_string($results);
return $newxmlrecord;
}

View file

@ -85,7 +85,7 @@ my $marcflavour = C4::Context->preference("marcflavour");
# XSLT processing of some stuff
if (C4::Context->preference("XSLTDetailsDisplay") ) {
$template->param('XSLTDetailsDisplay' =>'1',
'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail','intranet') );
'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "XSLTDetailsDisplay") );
}
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );

View file

@ -219,10 +219,10 @@ INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES
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');
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES
('OPACXSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on OPAC','YesNo'),
('OPACXSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on OPAC','YesNo'),
('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on intranet','YesNo'),
('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on intranet','YesNo');
('OPACXSLTDetailsDisplay','','','Enable XSL stylesheet control over details page display on OPAC','Free'),
('OPACXSLTResultsDisplay','','','Enable XSL stylesheet control over results page display on OPAC','Free'),
('XSLTDetailsDisplay','','','Enable XSL stylesheet control over details page display on intranet','Free'),
('XSLTResultsDisplay','','','Enable XSL stylesheet control over results page display on intranet','Free');
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');
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');
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed on damaged items', 'YesNo');

View file

@ -5109,6 +5109,36 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
SetVersion ($DBversion);
}
$DBversion = "3.07.00.043";
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
my $countXSLTDetailsDisplay = 0;
my $valueXSLTDetailsDisplay = "";
my $valueXSLTResultsDisplay = "";
my $valueOPACXSLTDetailsDisplay = "";
my $valueOPACXSLTResultsDisplay = "";
#the line below test if database comes from a BibLibre's branch
$countXSLTDetailsDisplay = $dbh->do('SELECT 1 FROM systempreferences WHERE variable="IntranetXSLTDetailsDisplay"');
if ($countXSLTDetailsDisplay > 0)
{
#the two lines below will only be used to update the databases from the BibLibre's branch. They will not affect the others
$dbh->do(q|UPDATE systempreferences SET variable="XSLTDetailsDisplay" WHERE variable="IntranetXSLTDetailsDisplay"|);
$dbh->do(q|UPDATE systempreferences SET variable="XSLTResultsDisplay" WHERE variable="IntranetXSLTResultsDisplay"|);
}
else
{
$valueXSLTDetailsDisplay = "default" if (C4::Context->preference("XSLTDetailsDisplay"));
$valueXSLTResultsDisplay = "default" if (C4::Context->preference("XSLTResultsDisplay"));
$valueOPACXSLTDetailsDisplay = "default" if (C4::Context->preference("OPACXSLTDetailsDisplay"));
$valueOPACXSLTResultsDisplay = "default" if (C4::Context->preference("OPACXSLTResultsDisplay"));
$dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTDetailsDisplay\" WHERE variable='XSLTDetailsDisplay'");
$dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueXSLTResultsDisplay\" WHERE variable='XSLTResultsDisplay'");
$dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTDetailsDisplay\" WHERE variable='OPACXSLTDetailsDisplay'");
$dbh->do("UPDATE systempreferences SET type='Free', value=\"$valueOPACXSLTResultsDisplay\" WHERE variable='OPACXSLTResultsDisplay'");
}
print "XSLT systempreference takes a path to file rather than YesNo\n";
SetVersion($DBversion);
}
=head1 FUNCTIONS
=head2 DropAllForeignKeys($table)

View file

@ -48,17 +48,15 @@ OPAC:
no: Show
- lost items on search and detail pages.
-
- Show biblio records on OPAC result page
- 'Display OPAC results using XSLT stylesheet at: '
- pref: OPACXSLTResultsDisplay
choices:
yes: using XSLT stylesheets.
no: normally.
class: file
- '<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.'
-
- Show item details pages on the OPAC
- 'Display OPAC details using XSLT stylesheet at: '
- pref: OPACXSLTDetailsDisplay
choices:
yes: using XSLT stylesheets.
no: normally.
class: file
- '<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.'
-
- On pages displayed with XSLT stylesheets on the OPAC,
- pref: DisplayOPACiconsXSLT

View file

@ -51,17 +51,15 @@ Staff Client:
class: url
- for the Staff Client's favicon. (This should be a complete URL, starting with <code>http://</code>.)
-
- Show biblio records on result page in the staff client
- 'Display results in the staff client using XSLT stylesheet at: '
- pref: XSLTResultsDisplay
choices:
yes: using XSLT stylesheets.
no: normally.
class: file
- '<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.'
-
- Show item details pages in the staff client
- 'Display details in the staff client using XSLT stylesheet at: '
- pref: XSLTDetailsDisplay
choices:
yes: using XSLT stylesheets.
no: normally.
class: file
- '<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.'
-
- Use the Yahoo UI libraries
- pref: yuipath

View file

@ -91,7 +91,7 @@ SetUTF8Flag($record);
# XSLT processing of some stuff
if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
$template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail', 'opac') );
$template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "OPACXSLTDetailsDisplay" ) );
}