atom feed3 messages in org.koha.lists.koha-patches[Koha-patches] [PATCH 1/3] (bug #3042...
FromSent OnAttachments
Henri-Damien LAURENTFeb 5, 2010 4:59 am 
Henri-Damien LAURENTFeb 5, 2010 4:59 am 
Henri-Damien LAURENTFeb 5, 2010 4:59 am 
Subject:[Koha-patches] [PATCH 1/3] (bug #3042) Changing XSLT sysprefs to take filename
From:Henri-Damien LAURENT (henr@biblibre.com)
Date:Feb 5, 2010 4:59:53 am
List:org.koha.lists.koha-patches

This change system preferences for XSLT management bumps kohaversion to 3.01.6.111 If you are using Koha in a non devel mode AND use XSLT, then you HAVE TO adapt
the system preference to point to your htdocs

WARNINGS : - tested with UNIMARC XSL - donot test the presence of the file, if file absent, then BOOM - XSL CANNOT be different for intranet and OPAC for result lists. - Adds a new system preference XSLTIntranetDetailsDisplay

--- C4/Search.pm | 6 +- C4/XSLT.pm | 47 ++++++++++++-------- catalogue/detail.pl | 2 +- installer/data/mysql/en/mandatory/sysprefs.sql | 5 +- .../1-Obligatoire/unimarc_standard_systemprefs.sql | 8 ++- installer/data/mysql/updatedatabase.pl | 8 +++ kohaversion.pl | 2 +- opac/opac-detail.pl | 2 +- 8 files changed, 50 insertions(+), 30 deletions(-)

diff --git a/C4/Search.pm b/C4/Search.pm index 7e147f1..9ba76c5 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1349,10 +1349,9 @@ Format results in a form suitable for passing to the
template # IMO this subroutine is pretty messy still -- it's responsible for # building the HTML output for the template sub searchResults { - my ( $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults,
$hidelostitems ) = @_; + my ( $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults )
= @_; my $dbh = C4::Context->dbh; my @newresults; - #Build branchnames hash #find branchname #get branch information..... @@ -1653,9 +1652,10 @@ sub searchResults { use C4::Charset; SetUTF8Flag($marcrecord); $debug && warn $marcrecord->as_formatted; + # FIXME : This needs some work in order to be more flexible : Can not
use a result list for intranet different from OPAC if (C4::Context->preference("XSLTResultsDisplay") && !$scan) { $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display( - $oldbiblio->{biblionumber}, $marcrecord, 'Results' ); + $oldbiblio->{biblionumber}, $marcrecord,
C4::Context->preference("XSLTResultsDisplay") ); }

# last check for norequest : if itemtype is notforloan, it can't be
reserved either, whatever the items diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 1c7184a..22ce07d 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -29,6 +29,7 @@ use C4::Circulation; use Encode; use XML::LibXML; use XML::LibXSLT; +use LWP::Simple;

use vars qw($VERSION @ISA @EXPORT);

@@ -38,6 +39,7 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw( &XSLTParse4Display + &GetURI ); }

@@ -47,6 +49,19 @@ C4::XSLT - Functions for displaying XSLT-generated content

=head1 FUNCTIONS

+=head1 GetURI + +=head2 GetURI file and returns the xslt as a string + +=cut + +sub GetURI { + my ($uri) = @_; + my $string; + $string = get $uri ; + return $string; +} + =head1 transformMARCXML4XSLT

=head2 replaces codes with authorized values in a MARC::Record object @@ -118,15 +133,13 @@ sub getAuthorisedValues4MARCSubfields { my $stylesheet;

sub XSLTParse4Display { - my ( $biblionumber, $orig_record, $xsl_suffix, $interface ) = @_; - $interface = 'opac' unless $interface; + my ( $biblionumber, $orig_record, $xslfilename ) = @_; # grab the XML, run it through our stylesheet, push it out to the browser my $record = transformMARCXML4XSLT($biblionumber, $orig_record); #return $record->as_formatted(); my $itemsxml = buildKohaItemsNamespace($biblionumber); my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); my $sysxml = "<sysprefs>\n"; - warn $xmlrecord; foreach my $syspref ( qw/OPACURLOpenInNewWindow DisplayOPACiconsXSLT
URLLinkText/ ) { $sysxml .= "<syspref name=\"$syspref\">" . C4::Context->preference( $syspref ) . @@ -140,25 +153,21 @@ 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') . - "/prog/en/xslt/" . - C4::Context->preference('marcflavour') . - "slim2intranet$xsl_suffix.xsl"; - } else { - $xslfile = C4::Context->config('opachtdocs') . - "/prog/en/xslt/" . - C4::Context->preference('marcflavour') . - "slim2OPAC$xsl_suffix.xsl"; + my $style_doc; + if ($xslfilename=~/http:/){ + my $xsltstring=GetURI($xslfilename); + $style_doc = $parser->parse_string($xsltstring); + } + else { + 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; }

diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 1a17752..436d782 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -61,7 +61,7 @@ my $record = GetMarcBiblio($biblionumber); # XSLT processing of some stuff if (C4::Context->preference("XSLTDetailsDisplay") ) { $template->param('XSLTDetailsDisplay' =>'1', - 'XSLTBloc' => XSLTParse4Display($biblionumber, $record,
'Detail','intranet') ); + 'XSLTBloc' => XSLTParse4Display($biblionumber, $record,
C4::Context->preference('IntranetXSLTDetailsDisplay')) ); }

# some useful variables for enhanced content; diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql
b/installer/data/mysql/en/mandatory/sysprefs.sql index 7efe2be..95e5cd4 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -211,8 +211,8 @@ 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 -('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page
display on OPAC WARNING: MARC21 Only','YesNo'), -('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page
display on OPAC WARNING: MARC21 Only','YesNo'); +('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page
display on OPAC exemple :
../koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl','Textarea'), +('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page
display on OPAC exemple :
../koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl','Textarea'); 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'); @@ -275,3 +275,4 @@ INSERT INTO `systempreferences`
(variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES ('RoutingListAddReserves','1','If ON the patrons on routing lists are
automatically added to holds on the issue.','','YesNo'); INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES ( 'OpacAddMastheadLibraryPulldown', '0', '', 'Adds a pulldown menu to
select the library to search on the opac masthead.', 'YesNo' ); INSERT INTO systempreferences VALUES ('ImageLimit',5,'','Limit images stored in
the database by the Patron Card image manager to this number.','Integer'); +INSERT INTO systempreferences set
value='../koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2IntranetDetails.xsl',type='Free',
variable='IntranetXSLTResultsDisplay'; diff --git
a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql index 810c81b..2eb2885 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql @@ -213,8 +213,10 @@ INSERT INTO `systempreferences`
(variable,value,options,explanation,type) VALUES ('TagsShowOnList', '6','','Nombre de tags à afficher sur la page de
résultat, 0 désactivant l\'affichage.','Integer');

INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('OPACShelfBrowser','1','','Active le parcours des rayonnages sur la page
de détail','YesNo'); -INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('XSLTDetailsDisplay','0','','Activer la feuille XSL pour l''affichage des
notices détaillées','YesNo'); -INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('XSLTResultsDisplay','0','','Activer la feuille XSL pour l''affichage des
listes de résultat','YesNo'); +INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('XSLTDetailsDisplay','','','Permet l''utilisation de feuilles de style
XSLT pour l''affichage détaillé de notice exemple :
../koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl','Free'); +INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('XSLTResultsDisplay','','','Permet l''utilisation de Feuilles de style
XSLT pour l''affichage des listes de résultat exemple :
../koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl','Free'); +INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('IntranetXSLTDetailsDisplay','','','Activer la feuille XSL pour
l''affichage des notices détaillées','Free'); +INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('IntranetXSLTResultsDisplay','','','Activer la feuille XSL pour
l''affichage des listes de résultat','Free'); INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Définit quel champ
est utilisé pour la limitation par type de document dans la recherche
avancée','Choice'); INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('AllowOnShelfHolds', '0', '', 'Autorise les réservations de documents en
rayon.', 'YesNo'); INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('AllowHoldsOnDamagedItems', '1', '', 'Autorise les réservations de
documents déclarés endommagés', 'YesNo'); @@ -278,4 +280,4 @@ INSERT INTO `systempreferences`
(variable,value,options,explanation,type) VALUES INSERT INTO systempreferences VALUES ('ImageLimit',5,'','Limiter le nombre
d''images stockées en base pour la photo Lecteur à cette taille.','Integer'); INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES ('OPACPatronDetails','1','Si désactivé, l''affichage détaillé des
données adhérents est désactivé à l''OPAC.','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES ('OPACFinesTab','1','Si désactivé, l''onglet Amende est désactivé à
l''OPAC.','','YesNo'); - +INSERT INTO systempreferences set
value='../koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2IntranetDetails.xsl',type='Free',
variable='IntranetXSLTResultsDisplay'; diff --git a/installer/data/mysql/updatedatabase.pl
b/installer/data/mysql/updatedatabase.pl index c0dc925..083596a 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -3390,6 +3390,14 @@ if (C4::Context->preference("Version") <
TransformToNum($DBversion)) { print "Upgrade done (mark DBrev for 3.2-alpha release)\n"; SetVersion ($DBversion); } +$DBversion = "3.01.00.112"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("UPDATE systempreferences set
value='../koha-tmpl/opac-tmpl/prog/en/xslt/".C4::Context->preference('marcflavour')."slim2OPACDetail.xsl',type='Free'
where variable='XSLTDetailsDisplay' AND value=1;"); + $dbh->do("UPDATE systempreferences set
value='../koha-tmpl/opac-tmpl/prog/en/xslt/".C4::Context->preference('marcflavour')."slim2OPACResults.xsl',type='Free'
where variable='XSLTResultsDisplay' AND value=1;"); + $dbh->do("INSERT INTO systempreferences set
value='../koha-tmpl/intranet-tmpl/prog/en/xslt/".C4::Context->preference('marcflavour')."slim2IntranetDetails.xsl',type='Free',
variable='IntranetXSLTResultsDisplay';"); + print "Upgrade to $DBversion done (Improve XSLT)\n"; + SetVersion ($DBversion); +}

=item DropAllForeignKeys($table)

diff --git a/kohaversion.pl b/kohaversion.pl index 45747e6..5cfd314 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict;

sub kohaversion { - our $VERSION = '3.01.00.111'; + our $VERSION = '3.01.00.112'; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 9af15a8..83e1b1e 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -74,7 +74,7 @@ $template->param( biblionumber => $biblionumber ); # XSLT processing of some stuff if (C4::Context->preference("XSLTDetailsDisplay") ) { $template->param( - 'XSLTBloc' => XSLTParse4Display($biblionumber, $record,
'Detail'),'opac' ); + 'XSLTBloc' => XSLTParse4Display($biblionumber, $record,
C4::Context->preference("XSLTDetailsDisplay")) ); }

$template->param('OPACShowCheckoutName' =>
C4::Context->preference("OPACShowCheckoutName") );