From 955d066eeccd86cb73d2cbabdb86e0d885646762 Mon Sep 17 00:00:00 2001
From: Hector Castro <hector.hecaxmmx@gmail.com>
Date: Tue, 1 Sep 2015 11:07:07 -0600
Subject: [PATCH] Bug 14304 - RDA: Display link in XSLT for 264 field to
 reflect Zebra indexing

This patch add display link in XSLT for 264 for bug 14198 and reflect the Zebra indexing.

Test plan
1) Follow test plan for bug 14198
2) Apply the bug 14198
3) Do a search by pv: or pb:
4) Look that there no display link for 264 field.
5) Apply the patch
6) In a like maner of step 3 and 4, check out the new link for 264 field.
7) Check out the display link in OPAC and staff clint

Sponsored-by: Universidad de El Salvador
---
 .../prog/en/xslt/MARC21slim2intranetDetail.xsl        |    8 ++++++--
 .../prog/en/xslt/MARC21slim2intranetResults.xsl       |    4 +++-
 .../intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl    |   17 ++++++++++++++++-
 .../bootstrap/en/xslt/MARC21slim2OPACDetail.xsl       |    8 ++++++--
 .../bootstrap/en/xslt/MARC21slim2OPACResults.xsl      |    4 +++-
 .../opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl   |   17 ++++++++++++++++-
 6 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl
index c24a2d0..58b27a8 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl
+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl
@@ -341,13 +341,17 @@
             </xsl:for-each>
             <xsl:if test="marc:datafield[@tag=264]">
                 <xsl:text>; </xsl:text>
-                <xsl:call-template name="showRDAtag264"/>
+            <xsl:call-template name="showRDAtag264">
+                <xsl:with-param name="show_url">1</xsl:with-param>
+            </xsl:call-template>
             </xsl:if>
         </span>
         </xsl:when>
         <xsl:when test="marc:datafield[@tag=264]">
             <span class="results_summary">
-                <xsl:call-template name="showRDAtag264"/>
+            <xsl:call-template name="showRDAtag264">
+                <xsl:with-param name="show_url">1</xsl:with-param>
+            </xsl:call-template>
             </span>
         </xsl:when>
         </xsl:choose>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl
index e913ce5..67e03b6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl
+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl
@@ -806,7 +806,9 @@
     </xsl:when>
     <xsl:when test="marc:datafield[@tag=264]">
         <span class="results_summary">
-            <xsl:call-template name="showRDAtag264"/>
+            <xsl:call-template name="showRDAtag264">
+                <xsl:with-param name="show_url">0</xsl:with-param>
+            </xsl:call-template>
         </span>
     </xsl:when>
     </xsl:choose>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl
index 4e799de..b5fc8a4 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl
+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl
@@ -217,6 +217,7 @@
          Publisher-latest or Publisher or 'Other'-latest or 'Other'
          The preferred tag is saved in the fav variable and passed to a
          helper named-template -->
+        <xsl:param name="show_url"/>
         <xsl:choose>
             <xsl:when test="marc:datafield[@tag=264 and @ind1=3 and @ind2=1]">
             <!-- ind1==3 means latest change -->
@@ -224,6 +225,7 @@
               <xsl:variable name="fav" select="marc:datafield[@tag=264 and @ind1=3 and @ind2=1][1]"/>
               <xsl:call-template name="showRDAtag264helper">
                 <xsl:with-param name="field" select="$fav"/>
+                <xsl:with-param name="url" select="$show_url"/>
               </xsl:call-template>
             </xsl:when>
 
@@ -231,6 +233,7 @@
               <xsl:variable name="fav" select="marc:datafield[@tag=264 and @ind2=1][last()]"/>
               <xsl:call-template name="showRDAtag264helper">
                 <xsl:with-param name="field" select="$fav"/>
+                <xsl:with-param name="url" select="$show_url"/>
               </xsl:call-template>
             </xsl:when>
 
@@ -238,6 +241,7 @@
               <xsl:variable name="fav" select="marc:datafield[@tag=264 and @ind1=3][1]"/>
               <xsl:call-template name="showRDAtag264helper">
                 <xsl:with-param name="field" select="$fav"/>
+                <xsl:with-param name="url" select="$show_url"/>
               </xsl:call-template>
             </xsl:when>
 
@@ -245,12 +249,14 @@
               <xsl:variable name="fav" select="marc:datafield[@tag=264][last()]"/>
               <xsl:call-template name="showRDAtag264helper">
                 <xsl:with-param name="field" select="$fav"/>
+                <xsl:with-param name="url" select="$show_url"/>
               </xsl:call-template>
             </xsl:otherwise>
         </xsl:choose>
     </xsl:template>
     <xsl:template name="showRDAtag264helper">
         <xsl:param name="field"/>
+        <xsl:param name="url"/>
         <xsl:variable name="ind2" select="$field/@ind2"/>
         <xsl:choose>
             <xsl:when test="$ind2='0'">
@@ -268,7 +274,16 @@
         </xsl:choose>
         <xsl:value-of select="$field/marc:subfield[@code='a']"/>
         <xsl:text> </xsl:text>
-        <xsl:value-of select="$field/marc:subfield[@code='b']"/>
+        <xsl:choose>
+            <xsl:when test="$url='1'">
+                <a href="/cgi-bin/koha/catalogue/search.pl?q=pv:{$field/marc:subfield[@code='b']}">
+                    <xsl:value-of select="$field/marc:subfield[@code='b']"/>
+                </a>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="$field/marc:subfield[@code='b']"/>
+            </xsl:otherwise>
+        </xsl:choose>
         <xsl:text> </xsl:text>
         <xsl:value-of select="$field/marc:subfield[@code='c']"/>
     </xsl:template>
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl
index dcfc521..1e788ba 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl
@@ -371,13 +371,17 @@
             </xsl:for-each>
             <xsl:if test="marc:datafield[@tag=264]">
                 <xsl:text>; </xsl:text>
-                <xsl:call-template name="showRDAtag264"/>
+            <xsl:call-template name="showRDAtag264">
+                <xsl:with-param name="show_url">1</xsl:with-param>
+            </xsl:call-template>
             </xsl:if>
         </span>
         </xsl:when>
         <xsl:when test="marc:datafield[@tag=264]">
             <span class="results_summary">
-                <xsl:call-template name="showRDAtag264"/>
+            <xsl:call-template name="showRDAtag264">
+                <xsl:with-param name="show_url">1</xsl:with-param>
+            </xsl:call-template>
             </span>
         </xsl:when>
         </xsl:choose>
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl
index 4623dff..e78be89 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl
@@ -956,7 +956,9 @@
         </xsl:when>
         <xsl:when test="marc:datafield[@tag=264]">
             <span class="results_summary">
-                <xsl:call-template name="showRDAtag264"/>
+            <xsl:call-template name="showRDAtag264">
+                <xsl:with-param name="show_url">0</xsl:with-param>
+            </xsl:call-template>
             </span>
         </xsl:when>
     </xsl:choose>
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl
index 4f7efed..82c2f75 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl
@@ -215,6 +215,7 @@
          Publisher-latest or Publisher or 'Other'-latest or 'Other'
          The preferred tag is saved in the fav variable and passed to a
          helper named-template -->
+        <xsl:param name="show_url"/>
         <xsl:choose>
             <xsl:when test="marc:datafield[@tag=264 and @ind1=3 and @ind2=1]">
             <!-- ind1==3 means latest change -->
@@ -222,6 +223,7 @@
               <xsl:variable name="fav" select="marc:datafield[@tag=264 and @ind1=3 and @ind2=1][1]"/>
               <xsl:call-template name="showRDAtag264helper">
                 <xsl:with-param name="field" select="$fav"/>
+                <xsl:with-param name="url" select="$show_url"/>
               </xsl:call-template>
             </xsl:when>
 
@@ -229,6 +231,7 @@
               <xsl:variable name="fav" select="marc:datafield[@tag=264 and @ind2=1][last()]"/>
               <xsl:call-template name="showRDAtag264helper">
                 <xsl:with-param name="field" select="$fav"/>
+                <xsl:with-param name="url" select="$show_url"/>
               </xsl:call-template>
             </xsl:when>
 
@@ -236,6 +239,7 @@
               <xsl:variable name="fav" select="marc:datafield[@tag=264 and @ind1=3][1]"/>
               <xsl:call-template name="showRDAtag264helper">
                 <xsl:with-param name="field" select="$fav"/>
+                <xsl:with-param name="url" select="$show_url"/>
               </xsl:call-template>
             </xsl:when>
 
@@ -243,12 +247,14 @@
               <xsl:variable name="fav" select="marc:datafield[@tag=264][last()]"/>
               <xsl:call-template name="showRDAtag264helper">
                 <xsl:with-param name="field" select="$fav"/>
+                <xsl:with-param name="url" select="$show_url"/>
               </xsl:call-template>
             </xsl:otherwise>
         </xsl:choose>
     </xsl:template>
     <xsl:template name="showRDAtag264helper">
         <xsl:param name="field"/>
+        <xsl:param name="url"/>
         <xsl:variable name="ind2" select="$field/@ind2"/>
         <xsl:choose>
             <xsl:when test="$ind2='0'">
@@ -266,7 +272,16 @@
         </xsl:choose>
         <xsl:value-of select="$field/marc:subfield[@code='a']"/>
         <xsl:text> </xsl:text>
-        <xsl:value-of select="$field/marc:subfield[@code='b']"/>
+        <xsl:choose>
+            <xsl:when test="$url='1'">
+                <a href="/cgi-bin/koha/opac-search.pl?q=pv:{$field/marc:subfield[@code='b']}">
+                    <xsl:value-of select="$field/marc:subfield[@code='b']"/>
+                </a>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="$field/marc:subfield[@code='b']"/>
+            </xsl:otherwise>
+        </xsl:choose>
         <xsl:text> </xsl:text>
         <xsl:value-of select="$field/marc:subfield[@code='c']"/>
     </xsl:template>
-- 
1.7.10.4