The MARC21slim2OPACDetail.xsl and MARC21slim2OPACResults.xsl XSLT stylesheets 
do not obey any of the OPAC sysprefs, OPACURLOpenInNewWindow, URLLinkText, or a 
new one added for Bug 3545, DisplayOPACiconsXSLT.  Modified C4/XSLT.pm based on 
code written by Fréric Demians (thanks!) to pass the values of the sysprefs to 
the .xsl files.  Modified the .xsl files to implement them.  If the respective 
sysprefs are set, the OPAC results and display pages will/will not display the 
format/material type/audience icons, will/will not open URLs in new browser 
windows, and will/will not use the text entered in URLLinkText as generic link 
text when there is no value in the 856 subfield y, 3, or z.  (Note that if 
subfields y, 3, or z do contain text, the first match is what will be 
displayed.)
---
 C4/XSLT.pm                                         |    9 +++
 admin/systempreferences.pl                         |    1 +
 installer/data/mysql/en/mandatory/sysprefs.sql     |    1 +
 .../1-Obligatoire/unimarc_standard_systemprefs.sql |    1 +
 .../ru-RU/mandatory/system_preferences_optimal.sql |    1 +
 installer/data/mysql/updatedatabase.pl             |    8 ++
 .../prog/en/xslt/MARC21slim2OPACDetail.xsl         |   70 +++++++++++++++-----
 .../prog/en/xslt/MARC21slim2OPACResults.xsl        |   47 +++++++++++--
 8 files changed, 112 insertions(+), 26 deletions(-)

diff --git a/C4/XSLT.pm b/C4/XSLT.pm
index 76e7ea7..f230c2c 100644
--- a/C4/XSLT.pm
+++ b/C4/XSLT.pm
@@ -125,6 +125,15 @@ sub XSLTParse4Display {
     my $itemsxml  = buildKohaItemsNamespace($biblionumber);
     my $xmlrecord = $record->as_xml();
     $xmlrecord =~ s/\<\/record\>/$itemsxml\<\/record\>/;
+    my $sysxml = "<sysprefs>\n";
+    foreach my $syspref ( qw/OPACURLOpenInNewWindow DisplayOPACiconsXSLT 
URLLinkText/ ) {
+        $sysxml .= "<syspref name=\"$syspref\">" .
+                   C4::Context->preference( $syspref ) .
+                   "</syspref>\n";
+    }
+    $sysxml .= "</sysprefs>\n";
+    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
+
     my $parser = XML::LibXML->new();
     # don't die when you find &, >, etc
     $parser->recover_silently(1);
diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl
index bb73d42..73db28a 100755
--- a/admin/systempreferences.pl
+++ b/admin/systempreferences.pl
@@ -310,6 +310,7 @@ $tabsysprefs{URLLinkText}                = "OPAC";
 $tabsysprefs{OPACShelfBrowser}           = "OPAC";
 $tabsysprefs{OPACDisplayRequestPriority} = "OPAC";
 $tabsysprefs{OPACAllowHoldDateInFuture}  = "OPAC";
+$tabsysprefs{DisplayOPACiconsXSLT}      = "OPAC";
 
 # OPAC
 $tabsysprefs{SearchMyLibraryFirst} = "OPAC";
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql 
b/installer/data/mysql/en/mandatory/sysprefs.sql
index 1921948..f7c4d80 100644
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -250,3 +250,4 @@ INSERT INTO systempreferences 
(variable,value,explanation,options,type)VALUES('F
 INSERT INTO systempreferences 
(variable,value,options,explanation,type)VALUES('SpineLabelFormat', 
'<itemcallnumber><copynumber>', '30|10', 'This preference defines the format 
for the quick spine label printer. Just list the fields you would like to see 
in the order you would like to see them, surrounded by <>, for example 
<itemcallnumber>.', 'Textarea');
 INSERT INTO systempreferences 
(variable,value,options,explanation,type)VALUES('SpineLabelAutoPrint', '0', '', 
'If this setting is turned on, a print dialog will automatically pop up for the 
quick spine label printer.', 'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) 
VALUES('AWSPrivateKey','','See:  http://aws.amazon.com.  Note that this is 
required after 2009/08/15 in order to retrieve any enhanced content other than 
book covers from Amazon.','','free');
+INSERT INTO systempreferences 
(variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', 
'', 'If ON, displays the format, audience, type icons in XSLT MARC21 results 
and display pages.', '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 d08415f..155514e 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
@@ -252,3 +252,4 @@ INSERT INTO systempreferences 
(variable,value,explanation,options,type)VALUES('F
 INSERT INTO systempreferences 
(variable,value,options,explanation,type)VALUES('SpineLabelFormat', 
'<itemcallnumber><copynumber>', '30|10', 'This preference defines the format 
for the quick spine label printer. Just list the fields you would like to see 
in the order you would like to see them, surrounded by <>, for example 
<itemcallnumber>.', 'Textarea');
 INSERT INTO systempreferences 
(variable,value,options,explanation,type)VALUES('SpineLabelAutoPrint', '0', '', 
'If this setting is turned on, a print dialog will automatically pop up for the 
quick spine label printer.', 'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) 
VALUES('AWSPrivateKey','','Voir:  http://aws.amazon.com. Notez que cela est 
nécessaire après le 15 Aout 2009 pour pouvoir utiliser les webservices Amazon 
autre que les couvertures de livre.','','free');
+INSERT INTO systempreferences 
(variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', 
'', 'Si activé, affiche le format, le type de public et les icônes de type en 
XSLT (MARC21)).', 'YesNo');
diff --git 
a/installer/data/mysql/ru-RU/mandatory/system_preferences_optimal.sql 
b/installer/data/mysql/ru-RU/mandatory/system_preferences_optimal.sql
index da8b906..61318c0 100644
--- a/installer/data/mysql/ru-RU/mandatory/system_preferences_optimal.sql
+++ b/installer/data/mysql/ru-RU/mandatory/system_preferences_optimal.sql
@@ -237,3 +237,4 @@ INSERT INTO `systempreferences` 
(variable,value,options,explanation,type) VALUES
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('AllowRenewalLimitOverride', '0', 'if ON, allows renewal limits to be 
overridden on the circulation screen',NULL,'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('MergeAuthoritiesOnUpdate', '1', 'if ON, Updating authorities will 
automatically updates biblios',NULL,'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('AllowNotForLoanOverride', '0', 'if ON, enables the librarian to choose 
when they want to check out a notForLoan regular item',NULL,'YesNo');
+INSERT INTO systempreferences 
(variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', 
'', 'If ON, displays the format, audience, type icons in XSLT MARC21 results 
and display pages.', 'YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl 
b/installer/data/mysql/updatedatabase.pl
index f81acaa..ea49de9 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -2503,6 +2503,14 @@ if (C4::Context->preference("Version") < 
TransformToNum($DBversion)) {
     print "Upgrade to $DBversion done (added AWSPrivateKey syspref - note that 
if you use enhanced content from Amazon, this should be set right away.)";
 }
 
+$DBversion = '3.01.00.042';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences 
(variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', 
'', 'If ON, displays the format, audience, type icons in XSLT MARC21 results 
and display pages.', 'YesNo')");
+    SetVersion ($DBversion);
+    print "Upgrade to $DBversion done (added DisplayOPACiconsXSLT sysprefs)\n";
+}
+
+
 =item DropAllForeignKeys($table)
 
   Drop all foreign keys of the table $table
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl 
b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl
index 2e18e44..60e6e84 100644
--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl
+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl
@@ -12,6 +12,9 @@
     </xsl:template>
 
     <xsl:template match="marc:record">
+    <xsl:variable name="DisplayOPACiconsXSLT" 
select="marc:sysprefs/marc:syspr...@name='DisplayOPACiconsXSLT']"/>
+    <xsl:variable name="OPACURLOpenInNewWindow" 
select="marc:sysprefs/marc:syspr...@name='OPACURLOpenInNewWindow']"/>
+    <xsl:variable name="URLLinkText" 
select="marc:sysprefs/marc:syspr...@name='URLLinkText']"/>
         <xsl:variable name="leader" select="marc:leader"/>
         <xsl:variable name="leader6" select="substring($leader,7,1)"/>
         <xsl:variable name="leader7" select="substring($leader,8,1)"/>
@@ -131,13 +134,14 @@
         <span class="view"><a id="ISBDview" 
href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber={marc:datafie...@tag=999]/marc:subfie...@code='c']}">Card
 View (ISBD)</a></span>
         </div> 
 
-
+   <xsl:if test="$DisplayOPACiconsXSLT!='0'">
         <xsl:if test="$materialTypeCode!=''">
         <span class="results_summary"><span class="label">Type: </span>
         <xsl:element name="img"><xsl:attribute 
name="src">/opac-tmpl/prog/famfamfam/<xsl:value-of 
select="$materialTypeCode"/>.png</xsl:attribute><xsl:attribute 
name="alt"></xsl:attribute></xsl:element>
         <xsl:value-of select="$materialTypeLabel"/>
         </span>
         </xsl:if>
+   </xsl:if>
         <xsl:if test="marc:datafie...@tag=440 or @tag=490]">
         <span class="results_summary"><span class="label">Series: </span>
         <xsl:for-each select="marc:datafie...@tag=440]">
@@ -305,23 +309,53 @@
         <xsl:if test="marc:datafie...@tag=856]">
         <span class="results_summary"><span class="label">Online Resources: 
</span>
         <xsl:for-each select="marc:datafie...@tag=856]">
-            <a><xsl:attribute name="href"><xsl:value-of 
select="marc:subfie...@code='u']"/></xsl:attribute>
-        <xsl:choose>
-            <xsl:when test="marc:subfie...@code='y' or @code='3' or 
@code='z']">
-                    <xsl:call-template name="subfieldSelect">
-                        <xsl:with-param name="codes">y3z</xsl:with-param>
-                    </xsl:call-template>
-            </xsl:when>
-        <xsl:when test="not(marc:subfie...@code='y']) and 
not(marc:subfie...@code='3']) and not(marc:subfie...@code='z'])">
-        Click here to access online
-        </xsl:when>
-        </xsl:choose>
-        </a>
-            <xsl:choose>
-            <xsl:when test="position()=last()"></xsl:when>
-            <xsl:otherwise> | </xsl:otherwise>
-            </xsl:choose>
-            
+                            <xsl:if test="$OPACURLOpenInNewWindow='0'">
+                                   <a><xsl:attribute name="href"><xsl:value-of 
select="marc:subfie...@code='u']"/></xsl:attribute>
+                                    <xsl:choose>
+                                    <xsl:when test="marc:subfie...@code='y' or 
@code='3' or @code='z']">
+                                        <xsl:call-template 
name="subfieldSelect">
+                                        <xsl:with-param 
name="codes">y3z</xsl:with-param>
+                                        </xsl:call-template>
+                                    </xsl:when>
+                                    <xsl:when 
test="not(marc:subfie...@code='y']) and not(marc:subfie...@code='3']) and 
not(marc:subfie...@code='z'])">
+                                        <xsl:choose>
+                                        <xsl:when test="$URLLinkText!=''">
+                                                <xsl:value-of 
select="$URLLinkText"/>
+                                        </xsl:when>
+                                        <xsl:otherwise>
+                                                <xsl:text>Click here to access 
online</xsl:text>
+                                        </xsl:otherwise>
+                                        </xsl:choose>
+                                    </xsl:when>
+                                    </xsl:choose>
+                                    </a>
+                              </xsl:if>
+                            <xsl:if test="$OPACURLOpenInNewWindow='1'">
+                                   <a target='_blank'><xsl:attribute 
name="href"><xsl:value-of select="marc:subfie...@code='u']"/></xsl:attribute>
+                                    <xsl:choose>
+                                    <xsl:when test="marc:subfie...@code='y' or 
@code='3' or @code='z']">
+                                        <xsl:call-template 
name="subfieldSelect">
+                                        <xsl:with-param 
name="codes">y3z</xsl:with-param>
+                                        </xsl:call-template>
+                                    </xsl:when>
+                                    <xsl:when 
test="not(marc:subfie...@code='y']) and not(marc:subfie...@code='3']) and 
not(marc:subfie...@code='z'])">
+                                        <xsl:choose>
+                                        <xsl:when test="$URLLinkText!=''">
+                                                <xsl:value-of 
select="$URLLinkText"/>
+                                        </xsl:when>
+                                        <xsl:otherwise>
+                                                <xsl:text>Click here to access 
online</xsl:text>
+                                        </xsl:otherwise>
+                                        </xsl:choose>
+                                    </xsl:when>
+                                    </xsl:choose>
+                                    </a>
+                              </xsl:if>
+                                    <xsl:choose>
+                                    <xsl:when 
test="position()=last()"><xsl:text>  </xsl:text></xsl:when>
+                                    <xsl:otherwise> | </xsl:otherwise>
+                                    </xsl:choose>
+
         </xsl:for-each>
         </span>
         </xsl:if>
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl 
b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
index c28ce17..919f66a 100644
--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
@@ -14,6 +14,9 @@
             <xsl:apply-templates/>
     </xsl:template>
     <xsl:template match="marc:record">
+    <xsl:variable name="DisplayOPACiconsXSLT" 
select="marc:sysprefs/marc:syspr...@name='DisplayOPACiconsXSLT']"/>
+    <xsl:variable name="OPACURLOpenInNewWindow" 
select="marc:sysprefs/marc:syspr...@name='OPACURLOpenInNewWindow']"/>
+    <xsl:variable name="URLLinkText" 
select="marc:sysprefs/marc:syspr...@name='URLLinkText']"/>
         <xsl:variable name="leader" select="marc:leader"/>
         <xsl:variable name="leader6" select="substring($leader,7,1)"/>
         <xsl:variable name="leader7" select="substring($leader,8,1)"/>
@@ -460,6 +463,7 @@
        </span>
     </xsl:if>
 
+<xsl:if test="$DisplayOPACiconsXSLT!='0'">
     <span class="results_summary">
     <xsl:if test="$typeOf008!=''">
         <span class="label">Type: </span>
@@ -796,6 +800,7 @@
             </xsl:choose>
     </xsl:if>
        </span>
+</xsl:if>
 
     <xsl:if test="marc:datafie...@tag=260]">
        <span class="results_summary">
@@ -817,7 +822,6 @@
                     </xsl:call-template>
             </xsl:for-each>
        </span>
-
     </xsl:if>
 
     <span class="results_summary">
@@ -825,9 +829,29 @@
                                <xsl:choose>
                         <xsl:when test="marc:datafie...@tag=856]">
                             <xsl:for-each select="marc:datafie...@tag=856]">
-                                <xsl:choose>
-                                    <xsl:when test="@ind2=0">
-                                    <a><xsl:attribute 
name="href"><xsl:value-of select="marc:subfie...@code='u']"/></xsl:attribute>
+                            <xsl:if test="$OPACURLOpenInNewWindow='0'">
+                                   <a><xsl:attribute name="href"><xsl:value-of 
select="marc:subfie...@code='u']"/></xsl:attribute>
+                                    <xsl:choose>
+                                    <xsl:when test="marc:subfie...@code='y' or 
@code='3' or @code='z']">
+                                        <xsl:call-template 
name="subfieldSelect">                        
+                                        <xsl:with-param 
name="codes">y3z</xsl:with-param>                    
+                                        </xsl:call-template>
+                                    </xsl:when>
+                                    <xsl:when 
test="not(marc:subfie...@code='y']) and not(marc:subfie...@code='3']) and 
not(marc:subfie...@code='z'])">
+                                       <xsl:choose>
+                                       <xsl:when test="$URLLinkText!=''">
+                                               <xsl:value-of 
select="$URLLinkText"/>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:text>Click here to access 
online</xsl:text>
+                                       </xsl:otherwise>
+                                       </xsl:choose>
+                                    </xsl:when>
+                                    </xsl:choose>
+                                    </a>
+                              </xsl:if>
+                            <xsl:if test="$OPACURLOpenInNewWindow='1'">
+                                   <a target='_blank'><xsl:attribute 
name="href"><xsl:value-of select="marc:subfie...@code='u']"/></xsl:attribute>
                                     <xsl:choose>
                                     <xsl:when test="marc:subfie...@code='y' or 
@code='3' or @code='z']">
                                         <xsl:call-template 
name="subfieldSelect">                        
@@ -835,19 +859,26 @@
                                         </xsl:call-template>
                                     </xsl:when>
                                     <xsl:when 
test="not(marc:subfie...@code='y']) and not(marc:subfie...@code='3']) and 
not(marc:subfie...@code='z'])">
-                                    Click here to access online
+                                       <xsl:choose>
+                                       <xsl:when test="$URLLinkText!=''">
+                                               <xsl:value-of 
select="$URLLinkText"/>
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:text>Click here to access 
online</xsl:text>
+                                       </xsl:otherwise>
+                                       </xsl:choose>
                                     </xsl:when>
                                     </xsl:choose>
                                     </a>
+                              </xsl:if>
                                     <xsl:choose>
-                                    <xsl:when 
test="position()=last()"></xsl:when>
+                                    <xsl:when 
test="position()=last()"><xsl:text>  </xsl:text></xsl:when>
                                     <xsl:otherwise> | </xsl:otherwise>
                                     </xsl:choose>
-                                    </xsl:when> 
-                                </xsl:choose>
                             </xsl:for-each>
                         </xsl:when>
 
+
                                   <xsl:when test="count(key('item-by-status', 
'available'))=0 and count(key('item-by-status', 'reference'))=0">No copies 
available
                                   </xsl:when>
                    <xsl:when test="count(key('item-by-status', 
'available'))>0">
-- 
1.5.6.5

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches

Reply via email to