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:
parent
9d394e12fc
commit
df0a6a71d7
9 changed files with 109 additions and 46 deletions
|
@ -1776,8 +1776,7 @@ sub searchResults {
|
||||||
$debug && warn $marcrecord->as_formatted;
|
$debug && warn $marcrecord->as_formatted;
|
||||||
my $interface = $search_context eq 'opac' ? 'OPAC' : '';
|
my $interface = $search_context eq 'opac' ? 'OPAC' : '';
|
||||||
if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
|
if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
|
||||||
$oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, 'Results',
|
$oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $interface."XSLTResultsDisplay", 1, \@hiddenitems);
|
||||||
$search_context, 1, \@hiddenitems);
|
|
||||||
# the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
|
# the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ sub shelfpage {
|
||||||
my $biblionumber = $this_item->{'biblionumber'};
|
my $biblionumber = $this_item->{'biblionumber'};
|
||||||
my $record = GetMarcBiblio($biblionumber);
|
my $record = GetMarcBiblio($biblionumber);
|
||||||
$this_item->{XSLTBloc} =
|
$this_item->{XSLTBloc} =
|
||||||
XSLTParse4Display($biblionumber, $record, 'Results', 'opac')
|
XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay")
|
||||||
if C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac';
|
if C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac';
|
||||||
|
|
||||||
# the virtualshelfcontents table does not store these columns nor are they retrieved from the items
|
# the virtualshelfcontents table does not store these columns nor are they retrieved from the items
|
||||||
|
|
80
C4/XSLT.pm
80
C4/XSLT.pm
|
@ -3,6 +3,7 @@ package C4::XSLT;
|
||||||
# <jmf at liblime dot com>
|
# <jmf at liblime dot com>
|
||||||
# Parts Copyright Katrin Fischer 2011
|
# Parts Copyright Katrin Fischer 2011
|
||||||
# Parts Copyright ByWater Solutions 2011
|
# Parts Copyright ByWater Solutions 2011
|
||||||
|
# Parts Copyright Biblibre 2012
|
||||||
#
|
#
|
||||||
# This file is part of Koha.
|
# This file is part of Koha.
|
||||||
#
|
#
|
||||||
|
@ -32,6 +33,7 @@ use C4::Reserves;
|
||||||
use Encode;
|
use Encode;
|
||||||
use XML::LibXML;
|
use XML::LibXML;
|
||||||
use XML::LibXSLT;
|
use XML::LibXSLT;
|
||||||
|
use LWP::Simple;
|
||||||
|
|
||||||
use vars qw($VERSION @ISA @EXPORT);
|
use vars qw($VERSION @ISA @EXPORT);
|
||||||
|
|
||||||
|
@ -41,6 +43,7 @@ BEGIN {
|
||||||
@ISA = qw(Exporter);
|
@ISA = qw(Exporter);
|
||||||
@EXPORT = qw(
|
@EXPORT = qw(
|
||||||
&XSLTParse4Display
|
&XSLTParse4Display
|
||||||
|
&GetURI
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +53,19 @@ C4::XSLT - Functions for displaying XSLT-generated content
|
||||||
|
|
||||||
=head1 FUNCTIONS
|
=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
|
=head2 transformMARCXML4XSLT
|
||||||
|
|
||||||
Replaces codes with authorized values in a MARC::Record object
|
Replaces codes with authorized values in a MARC::Record object
|
||||||
|
@ -121,8 +137,39 @@ sub getAuthorisedValues4MARCSubfields {
|
||||||
my $stylesheet;
|
my $stylesheet;
|
||||||
|
|
||||||
sub XSLTParse4Display {
|
sub XSLTParse4Display {
|
||||||
my ( $biblionumber, $orig_record, $xsl_suffix, $interface, $fixamps, $hidden_items ) = @_;
|
my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_;
|
||||||
$interface = 'opac' unless $interface;
|
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
|
# grab the XML, run it through our stylesheet, push it out to the browser
|
||||||
my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
|
my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
|
||||||
#return $record->as_formatted();
|
#return $record->as_formatted();
|
||||||
|
@ -153,29 +200,20 @@ sub XSLTParse4Display {
|
||||||
# don't die when you find &, >, etc
|
# don't die when you find &, >, etc
|
||||||
$parser->recover_silently(0);
|
$parser->recover_silently(0);
|
||||||
my $source = $parser->parse_string($xmlrecord);
|
my $source = $parser->parse_string($xmlrecord);
|
||||||
unless ( $stylesheet ) {
|
unless ( $stylesheet->{$xslfilename} ) {
|
||||||
my $xslt = XML::LibXSLT->new();
|
my $xslt = XML::LibXSLT->new();
|
||||||
my $xslfile;
|
my $style_doc;
|
||||||
if ($interface eq 'intranet') {
|
if ( $xslfilename =~ /^https?:\/\// ) {
|
||||||
$xslfile = C4::Context->config('intrahtdocs') .
|
my $xsltstring = GetURI($xslfilename);
|
||||||
'/' . C4::Context->preference("template") .
|
$style_doc = $parser->parse_string($xsltstring);
|
||||||
'/' . C4::Templates::_current_language() .
|
|
||||||
'/xslt/' .
|
|
||||||
C4::Context->preference('marcflavour') .
|
|
||||||
"slim2intranet$xsl_suffix.xsl";
|
|
||||||
} else {
|
} else {
|
||||||
$xslfile = C4::Context->config('opachtdocs') .
|
use Cwd;
|
||||||
'/' . C4::Context->preference("opacthemes") .
|
$style_doc = $parser->parse_file($xslfilename);
|
||||||
'/' . C4::Templates::_current_language() .
|
|
||||||
'/xslt/' .
|
|
||||||
C4::Context->preference('marcflavour') .
|
|
||||||
"slim2OPAC$xsl_suffix.xsl";
|
|
||||||
}
|
}
|
||||||
my $style_doc = $parser->parse_file($xslfile);
|
$stylesheet->{$xslfilename} = $xslt->parse_stylesheet($style_doc);
|
||||||
$stylesheet = $xslt->parse_stylesheet($style_doc);
|
|
||||||
}
|
}
|
||||||
my $results = $stylesheet->transform($source);
|
my $results = $stylesheet->{$xslfilename}->transform($source);
|
||||||
my $newxmlrecord = $stylesheet->output_string($results);
|
my $newxmlrecord = $stylesheet->{$xslfilename}->output_string($results);
|
||||||
return $newxmlrecord;
|
return $newxmlrecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ my $marcflavour = C4::Context->preference("marcflavour");
|
||||||
# XSLT processing of some stuff
|
# XSLT processing of some stuff
|
||||||
if (C4::Context->preference("XSLTDetailsDisplay") ) {
|
if (C4::Context->preference("XSLTDetailsDisplay") ) {
|
||||||
$template->param('XSLTDetailsDisplay' =>'1',
|
$template->param('XSLTDetailsDisplay' =>'1',
|
||||||
'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail','intranet') );
|
'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "XSLTDetailsDisplay") );
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
|
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
|
||||||
|
|
|
@ -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('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
|
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES
|
||||||
('OPACXSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on OPAC','YesNo'),
|
('OPACXSLTDetailsDisplay','','','Enable XSL stylesheet control over details page display on OPAC','Free'),
|
||||||
('OPACXSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on OPAC','YesNo'),
|
('OPACXSLTResultsDisplay','','','Enable XSL stylesheet control over results page display on OPAC','Free'),
|
||||||
('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on intranet','YesNo'),
|
('XSLTDetailsDisplay','','','Enable XSL stylesheet control over details page display on intranet','Free'),
|
||||||
('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on intranet','YesNo');
|
('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('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('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');
|
INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed on damaged items', 'YesNo');
|
||||||
|
|
|
@ -5109,6 +5109,36 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
|
||||||
SetVersion ($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
|
=head1 FUNCTIONS
|
||||||
|
|
||||||
=head2 DropAllForeignKeys($table)
|
=head2 DropAllForeignKeys($table)
|
||||||
|
|
|
@ -48,17 +48,15 @@ OPAC:
|
||||||
no: Show
|
no: Show
|
||||||
- lost items on search and detail pages.
|
- lost items on search and detail pages.
|
||||||
-
|
-
|
||||||
- Show biblio records on OPAC result page
|
- 'Display OPAC results using XSLT stylesheet at: '
|
||||||
- pref: OPACXSLTResultsDisplay
|
- pref: OPACXSLTResultsDisplay
|
||||||
choices:
|
class: file
|
||||||
yes: using XSLT stylesheets.
|
- '<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.'
|
||||||
no: normally.
|
|
||||||
-
|
-
|
||||||
- Show item details pages on the OPAC
|
- 'Display OPAC details using XSLT stylesheet at: '
|
||||||
- pref: OPACXSLTDetailsDisplay
|
- pref: OPACXSLTDetailsDisplay
|
||||||
choices:
|
class: file
|
||||||
yes: using XSLT stylesheets.
|
- '<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.'
|
||||||
no: normally.
|
|
||||||
-
|
-
|
||||||
- On pages displayed with XSLT stylesheets on the OPAC,
|
- On pages displayed with XSLT stylesheets on the OPAC,
|
||||||
- pref: DisplayOPACiconsXSLT
|
- pref: DisplayOPACiconsXSLT
|
||||||
|
|
|
@ -51,17 +51,15 @@ Staff Client:
|
||||||
class: url
|
class: url
|
||||||
- for the Staff Client's favicon. (This should be a complete URL, starting with <code>http://</code>.)
|
- 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
|
- pref: XSLTResultsDisplay
|
||||||
choices:
|
class: file
|
||||||
yes: using XSLT stylesheets.
|
- '<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.'
|
||||||
no: normally.
|
|
||||||
-
|
-
|
||||||
- Show item details pages in the staff client
|
- 'Display details in the staff client using XSLT stylesheet at: '
|
||||||
- pref: XSLTDetailsDisplay
|
- pref: XSLTDetailsDisplay
|
||||||
choices:
|
class: file
|
||||||
yes: using XSLT stylesheets.
|
- '<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.'
|
||||||
no: normally.
|
|
||||||
-
|
-
|
||||||
- Use the Yahoo UI libraries
|
- Use the Yahoo UI libraries
|
||||||
- pref: yuipath
|
- pref: yuipath
|
||||||
|
|
|
@ -91,7 +91,7 @@ SetUTF8Flag($record);
|
||||||
|
|
||||||
# XSLT processing of some stuff
|
# XSLT processing of some stuff
|
||||||
if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
|
if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
|
||||||
$template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail', 'opac') );
|
$template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "OPACXSLTDetailsDisplay" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue