Bug 14716: Fix more unencoded url parameters.
[koha-ffzg.git] / koha-tmpl / intranet-tmpl / prog / en / xslt / UNIMARCslimUtils.xsl
index ad1650d..48d50c5 100644 (file)
@@ -2,7 +2,12 @@
 
 <!DOCTYPE stylesheet [<!ENTITY nbsp "&#160;" >]>
 
-<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:stylesheet version="1.0"
+  xmlns:marc="http://www.loc.gov/MARC21/slim"
+  xmlns:items="http://www.koha-community.org/items"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:str="http://exslt.org/strings"
+  exclude-result-prefixes="marc items str">
 
   <xsl:template name="datafield">
     <xsl:param name="tag"/>
                <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
                <xsl:param name="subdivCodes"/>
                <xsl:param name="subdivDelimiter"/>
+    <xsl:param name="urlencode"/>
                <xsl:variable name="str">
                        <xsl:for-each select="marc:subfield">
                                <xsl:if test="contains($codes, @code)">
                                </xsl:if>
                        </xsl:for-each>
                </xsl:variable>
-               <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
+    <xsl:choose>
+      <xsl:when test="$urlencode=1">
+        <xsl:value-of select="str:encode-uri(substring($str,1,string-length($str)-string-length($delimeter)), true())"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
+      </xsl:otherwise>
+    </xsl:choose>
        </xsl:template>
 
        <xsl:template name="buildSpaces">
                </xsl:if>
        </xsl:template>
 
+  <xsl:template name="buildBiblioDefaultViewURL">
+      <xsl:param name="IntranetBiblioDefaultView"/>
+      <xsl:choose>
+          <xsl:when test="$IntranetBiblioDefaultView='normal'">
+              <xsl:text>/cgi-bin/koha/catalogue/detail.pl?biblionumber=</xsl:text>
+          </xsl:when>
+          <xsl:when test="$IntranetBiblioDefaultView='isbd'">
+              <xsl:text>/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=</xsl:text>
+          </xsl:when>
+          <xsl:when test="$IntranetBiblioDefaultView='labeled_marc'">
+              <xsl:text>/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=</xsl:text>
+          </xsl:when>
+          <xsl:when test="$IntranetBiblioDefaultView='marc'">
+              <xsl:text>/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=</xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+              <xsl:text>/cgi-bin/koha/catalogue/detail.pl?biblionumber=</xsl:text>
+          </xsl:otherwise>
+      </xsl:choose>
+  </xsl:template>
+
        <xsl:template name="chopSpecialCharacters">
         <xsl:param name="title" />
         <xsl:variable name="ntitle"
           <a>
             <xsl:choose>
               <xsl:when test="marc:subfield[@code=9]">
-                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
+                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/></xsl:attribute>
               </xsl:when>
               <xsl:otherwise>
-                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=su:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
+                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=su:<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/></xsl:attribute>
               </xsl:otherwise>
             </xsl:choose>
             <xsl:call-template name="chopPunctuation">
             <a>
               <xsl:choose>
                 <xsl:when test="marc:subfield[@code=9]">
-                  <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
+                  <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/></xsl:attribute>
                 </xsl:when>
                 <xsl:otherwise>
-                  <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='b']"/></xsl:attribute>
+                  <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=au:<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='b']"/></xsl:attribute>
                 </xsl:otherwise>
               </xsl:choose>
               <xsl:if test="marc:subfield[@code='a']">