Adding XSLTreultsFilename and XSLTDetailFilename
authorHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Fri, 14 May 2010 23:28:46 +0000 (01:28 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Fri, 14 May 2010 23:31:54 +0000 (01:31 +0200)
Thos two system preferences enables the librarian to choose an xslt different from the one provided in Koha

C4/Search.pm
C4/XSLT.pm
installer/data/mysql/en/mandatory/sysprefs.sql
installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
installer/data/mysql/updatedatabase30.pl
kohaversion.pl
opac/opac-detail.pl

index af4fadf..cadab26 100644 (file)
@@ -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
index 0cfabe2..5374521 100644 (file)
@@ -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);
index 723a936..2a811e6 100644 (file)
@@ -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');
index 5917986..070e7e6 100644 (file)
@@ -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');
index 7512662..abdbc76 100644 (file)
@@ -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)
 
index 9e1d68a..1f3148a 100644 (file)
@@ -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
index 5940fb0..bf2ef9f 100755 (executable)
@@ -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