From 848926b6f4851356891e553813009467a1c2d07c Mon Sep 17 00:00:00 2001
From: Blou <blou@inlibro.com>
Date: Wed, 8 Dec 2021 16:45:29 -0500
Subject: [PATCH] Bug 15594: preserve sequence of 260 subfields in (staff)
 detail page

When ordered $a$b$a$b$c in the MARC object, 260 subfields are displayed
$a$a$b$b$c.  This goes against the standard.

This patch preserves the order.

0) create a notice with $a$b$a subfields.  In that (mixed) order.
1) Go to staff detail page and see the fields displayed as "aab"
2) apply the patch
3) validate the aba display.

Signed-off-by: David Nind <david@davidnind.com>
---
 .../en/xslt/MARC21slim2intranetDetail.xsl     | 48 +++++++++----------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl
index 6983988867..6527996af7 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl
+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl
@@ -283,42 +283,42 @@
             <xsl:when test="marc:datafield[@tag=260]">
                 <span class="results_summary publisher"><span class="label">Publication details: </span>
                     <xsl:for-each select="marc:datafield[@tag=260]">
-                        <xsl:for-each select="marc:subfield[@code='a']">
+                        <xsl:for-each select="marc:subfield">
+                        <xsl:if test="@code='a'">
                             <a>
-                                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=pl:"<xsl:value-of select="str:encode-uri(., true())"/>"</xsl:attribute>
-                                <xsl:value-of select="."/>
+                                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=pl:"<xsl:value-of select="str:encode-uri(current(), true())"/>"</xsl:attribute>
+                                <xsl:value-of select="current()"/>
                             </a>
                             <xsl:if test="position() != last()">
                                 <xsl:text> </xsl:text>
                             </xsl:if>
-                        </xsl:for-each>
-                        <xsl:text> </xsl:text>
-                        <xsl:if test="marc:subfield[@code='b']">
-                        <a>
-                            <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Provider:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='b'], true())"/>"</xsl:attribute>
-                            <xsl:call-template name="subfieldSelect">
-                                <xsl:with-param name="codes">b</xsl:with-param>
-                            </xsl:call-template>
-                        </a>
+                            <xsl:text> </xsl:text>
                         </xsl:if>
-                        <xsl:text> </xsl:text>
-                        <xsl:for-each select="marc:subfield[@code='c']">
+                        <xsl:if test="@code='b'">
                             <a>
-                                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=copydate:"<xsl:value-of select="str:encode-uri(., true())"/>"</xsl:attribute>
-                                <xsl:value-of select="."/>
+                                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Provider:"<xsl:value-of select="str:encode-uri(current(), true())"/>"</xsl:attribute>
+                                <xsl:value-of select="current()"/>
+                            </a>
+                            <xsl:text> </xsl:text>
+                        </xsl:if>
+                        <xsl:if test="@code='c'">
+                            <a>
+                                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=copydate:"<xsl:value-of select="str:encode-uri(current(), true())"/>"</xsl:attribute>
+                                <xsl:value-of select="current()"/>
                             </a>
                             <xsl:if test="position() != last()">
                                 <xsl:text> </xsl:text>
                             </xsl:if>
-                        </xsl:for-each>
-                        <xsl:text> </xsl:text>
-                        <xsl:call-template name="chopPunctuation">
-                          <xsl:with-param name="chopString">
-                            <xsl:call-template name="subfieldSelect">
-                                <xsl:with-param name="codes">g</xsl:with-param>
+                            <xsl:text> </xsl:text>
+                        </xsl:if>
+                        <xsl:if test="@code='g'">
+                            <xsl:call-template name="chopPunctuation">
+                               <xsl:with-param name="chopString">
+                                  <xsl:value-of select="current()"/>
+                               </xsl:with-param>
                             </xsl:call-template>
-                           </xsl:with-param>
-                       </xsl:call-template>
+                        </xsl:if>
+                        </xsl:for-each>
                             <xsl:choose><xsl:when test="position()=last()"><xsl:text></xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
                     </xsl:for-each>
                 </span>
-- 
2.30.2