From 758bfba1ee3ea990e3f5d4ccca65a2cf8ea0123c Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Sat, 15 May 2010 01:28:46 +0200 Subject: [PATCH] Adding XSLTreultsFilename and XSLTDetailFilename Thos two system preferences enables the librarian to choose an xslt different from the one provided in Koha --- C4/Search.pm | 2 +- C4/XSLT.pm | 12 +++++++++++- installer/data/mysql/en/mandatory/sysprefs.sql | 7 +++++-- .../1-Obligatoire/unimarc_standard_systemprefs.sql | 7 +++++-- installer/data/mysql/updatedatabase30.pl | 11 +++++++++++ kohaversion.pl | 2 +- opac/opac-detail.pl | 2 +- 7 files changed, 35 insertions(+), 8 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index af4fadff63..cadab261e2 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1676,7 +1676,7 @@ sub searchResults { # XSLT processing of some stuff if (C4::Context->preference("XSLTResultsDisplay") && !$scan) { $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display( - $oldbiblio->{biblionumber}, $marcrecord, C4::Context->preference("XSLTResultsDisplay") ); + $oldbiblio->{biblionumber}, $marcrecord, 'Results' ); } # 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 0cfabe2bc5..5374521e1b 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -133,7 +133,8 @@ sub getAuthorisedValues4MARCSubfields { my $stylesheet; sub XSLTParse4Display { - my ( $biblionumber, $orig_record, $xslfilename ) = @_; + my ( $biblionumber, $orig_record, $type ) = @_; + my $xslfilename=C4::Context->preference("XSLT$type"."Filename")||_buildfilename($type); # grab the XML, run it through our stylesheet, push it out to the browser my $record = transformMARCXML4XSLT($biblionumber, $orig_record); #return $record->as_formatted(); @@ -174,6 +175,15 @@ sub XSLTParse4Display { return $newxmlrecord; } + +sub _buildfilename{ + my $type=shift; + return C4::Context->config('opachtdocs') . + "/prog/en/xslt/" . + C4::Context->preference('marcflavour') . + "slim2OPAC$type.xsl"; +} + sub buildKohaItemsNamespace { my ($biblionumber) = @_; my @items = C4::Items::GetItemsInfo($biblionumber); diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index 723a936d0a..2a811e6d64 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -204,8 +204,11 @@ 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 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'); +('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on OPAC','YesNo'), +('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on OPAC','YesNo'); +INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES +('XSLTDetailFilename','','','Enable XSL stylesheet control over details page display on OPAC exemple : ../koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl','Textarea'), +('XSLTResultsFilename','','','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 59179868db..070e7e6c25 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,11 @@ 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','','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 +('XSLTDetailsDisplay','0','','Active l''affichage détaillé OPAC par la feuille de style XSL stylesheet','YesNo'), +('XSLTResultsDisplay','0','','Active l''affichage liste de résultat OPAC par la feuille de style XSLT','YesNo'); +INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('XSLTDetailFilename','','','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('XSLTResultsFilename','','','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 75126620c2..abdbc767df 100644 --- a/installer/data/mysql/updatedatabase30.pl +++ b/installer/data/mysql/updatedatabase30.pl @@ -757,6 +757,17 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.00.06.010"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT systempreferences set value='../koha-tmpl/opac-tmpl/prog/en/xslt/".C4::Context->preference('marcflavour')."slim2OPACDetails.xsl',type='Free', variable='XSLTDetailsFilename' ;"); + $dbh->do("INSERT systempreferences set value='../koha-tmpl/opac-tmpl/prog/en/xslt/".C4::Context->preference('marcflavour')."slim2OPACResults.xsl',type='Free', variable='XSLTResultsFilename' ;"); + $dbh->do("UPDATE systempreferences set value=(LENGTH(value)>0),type='YesNo' where variable='XSLTDetailsDisplay';"); + $dbh->do("UPDATE systempreferences set value=(LENGTH(value)>0),type='YesNo' where variable='XSLTResultsDisplay';"); + print "Upgrade to $DBversion done (Improvements to XSLT Support)\n"; + SetVersion ($DBversion); +} + + =item DropAllForeignKeys($table) diff --git a/kohaversion.pl b/kohaversion.pl index 9e1d68a6d2..1f3148a1ef 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = '3.00.06.009'; + our $VERSION = '3.00.06.010'; # 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 5940fb0c93..bf2ef9ff14 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -71,7 +71,7 @@ $template->param( biblionumber => $biblionumber ); # XSLT processing of some stuff if (C4::Context->preference("XSLTDetailsDisplay") ) { $template->param( - 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, C4::Context->preference("XSLTDetailsDisplay")) ); + 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail') ); } # change back when ive fixed request.pl -- 2.39.5