Bugzilla – Attachment 1791 Details for
Bug 4032
XSLT systempreference should take a path to file rather than YesNo
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch proposed
0001-bug-3042-Changing-XSLT-sysprefs-to-take-filename.patch (text/plain), 10.60 KB, created by
Chris Cormack
on 2010-01-07 09:14:00 UTC
(
hide
)
Description:
patch proposed
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2010-01-07 09:14:00 UTC
Size:
10.60 KB
patch
obsolete
>From dc446be1cab3129575fc57b380d1639df469621d Mon Sep 17 00:00:00 2001 >From: Henri-Damien LAURENT <henridamien.laurent@biblibre.com> >Date: Wed, 6 Jan 2010 22:27:29 +0100 >Subject: [3.0.x] (bug #3042) Changing XSLT sysprefs to take filename > >This change system preferences for XSLT management >bumps kohaversion to 3.0.6.03 >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. >--- > C4/Search.pm | 4 +- > C4/XSLT.pm | 40 +++++++++++++++----- > installer/data/mysql/en/mandatory/sysprefs.sql | 4 +- > .../1-Obligatoire/unimarc_standard_systemprefs.sql | 4 +- > installer/data/mysql/updatedatabase30.pl | 9 ++++ > kohaversion.pl | 2 +- > opac/opac-detail.pl | 2 +- > 7 files changed, 47 insertions(+), 18 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 8a62a40..43d21cc 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1338,7 +1338,6 @@ sub searchResults { > my ( $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults ) = @_; > my $dbh = C4::Context->dbh; > my @newresults; >- > #Build branchnames hash > #find branchname > #get branch information..... >@@ -1672,9 +1671,10 @@ sub searchResults { > } > > # XSLT processing of some stuff >+ # 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 1073a2d..cd53e31 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -26,6 +26,7 @@ use C4::Circulation; > use Encode; > use XML::LibXML; > use XML::LibXSLT; >+use LWP::Simple; > > use strict; > >@@ -37,6 +38,7 @@ BEGIN { > @ISA = qw(Exporter); > @EXPORT = qw( > &XSLTParse4Display >+ &GetURI > ); > } > >@@ -46,6 +48,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,7 +133,7 @@ sub getAuthorisedValues4MARCSubfields { > my $stylesheet; > > sub XSLTParse4Display { >- my ( $biblionumber, $orig_record, $xsl_suffix ) = @_; >+ 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(); >@@ -129,17 +144,22 @@ sub XSLTParse4Display { > # don't die when you find &, >, etc > $parser->recover_silently(1); > my $source = $parser->parse_string($xmlrecord); >- unless ( $stylesheet ) { >+ unless ( $stylesheet->{$xslfilename} ) { > my $xslt = XML::LibXSLT->new(); >- my $xslfile = C4::Context->config('opachtdocs') . >- "/prog/en/xslt/" . >- C4::Context->preference('marcflavour') . >- "slim2OPAC$xsl_suffix.xsl"; >- my $style_doc = $parser->parse_file($xslfile); >- $stylesheet = $xslt->parse_stylesheet($style_doc); >+ my $style_doc; >+ if ($xslfilename=~/http:/){ >+ my $xsltstring=GetURI($xslfilename); >+ $style_doc = $parser->parse_string($xsltstring); >+ } >+ else { >+ use Cwd; >+ warn getcwd; >+ $style_doc = $parser->parse_file($xslfilename); >+ } >+ $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/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql >index a2a4aba..f9ad18a 100644 >--- a/installer/data/mysql/en/mandatory/sysprefs.sql >+++ b/installer/data/mysql/en/mandatory/sysprefs.sql >@@ -204,8 +204,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'); >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 8bca312..32628b8 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 >@@ -206,8 +206,8 @@ 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','','Enable XSL stylesheet control over details page display on OPAC WARNING: MARC21 Only','YesNo'); >-INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('XSLTResultsDisplay','0','','Permet l''utilisation de Feuilles de style XSLT pour l''affichage des listes de résultat (MARC21)','YesNo'); >+INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('XSLTDetailsDisplay','0','','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','Textarea'); >+INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('XSLTResultsDisplay','0','','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','Textarea'); > INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Détermine quel index utiliser lors des recherches par type de document','Choice'); > INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowOnShelfHolds', '0', '', 'Permet la réservation d''exemplaires non disponibles', 'YesNo'); > INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AllowHoldsOnDamagedItems', '1', '', 'Permet les réservations sur des exemplaires endommagés', 'YesNo'); >diff --git a/installer/data/mysql/updatedatabase30.pl b/installer/data/mysql/updatedatabase30.pl >index c3247ed..4df69dc 100644 >--- a/installer/data/mysql/updatedatabase30.pl >+++ b/installer/data/mysql/updatedatabase30.pl >@@ -705,6 +705,15 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { > SetVersion ($DBversion); > } > >+$DBversion = "3.00.06.003"; >+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' 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' where variable='XSLTResultsDisplay' AND value=1;"); >+ print "Upgrade to $DBversion done (Improve XSLT)\n"; >+ SetVersion ($DBversion); >+} >+ >+ > =item DropAllForeignKeys($table) > > Drop all foreign keys of the table $table >diff --git a/kohaversion.pl b/kohaversion.pl >index fa25945..e8ea8e7 100644 >--- a/kohaversion.pl >+++ b/kohaversion.pl >@@ -10,7 +10,7 @@ > use strict; > > sub kohaversion { >- our $VERSION = '3.00.05.003'; >+ our $VERSION = '3.00.06.003'; > # 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 7febfa0..817c203 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -70,7 +70,7 @@ $template->param( biblionumber => $biblionumber ); > # XSLT processing of some stuff > if (C4::Context->preference("XSLTDetailsDisplay") ) { > $template->param( >- 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail') ); >+ 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, C4::Context->preference("XSLTDetailsDisplay")) ); > } > > # change back when ive fixed request.pl >-- >1.6.3.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 4032
:
1791
|
7451
|
7452
|
7499
|
7901
|
8421
|
8622