Bug 14025: Fix 865u-links in the OPAC for NORMARC
authorMagnus Enger <magnus@enger.priv.no>
Wed, 29 Apr 2015 19:28:50 +0000 (21:28 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Tue, 26 May 2015 13:42:07 +0000 (10:42 -0300)
The display of links found in 856$u for NORMARC has not been keeping up with
the one for MARC21, and several sysprefs have not been implemented. This
patch tries to fix that.

Affected sysprefs:
- OPACURLOpenInNewWindow
- URLLinkText
- OPACDisplay856uAsImage
- OPACTrackClicks

To test:
- Make sure you have a record with a URL in 856$u and marcflavor = NORMARC.
  (It does not have to be a full NORMARC setup or a NORMARC record, just make
  sure you are viewing the record through the NORMARC XSLT files.)
- View the record both in a result list and in detail view
- Check that the 4 involved sysprefs affect the display in the expected ways

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Tested on NORMARC setup and XSLTs
Works as described, each syspref works
No koha-qa errors

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Since it only affects NORMAC, I trust in Magnus :)
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
koha-tmpl/opac-tmpl/bootstrap/en/xslt/NORMARCslim2OPACDetail.xsl
koha-tmpl/opac-tmpl/bootstrap/en/xslt/NORMARCslim2OPACResults.xsl

index 01d56af..4d1785b 100644 (file)
         </xsl:variable>
         <xsl:variable name="DisplayOPACiconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayOPACiconsXSLT']"/>
         <xsl:variable name="theme" select="marc:sysprefs/marc:syspref[@name='opacthemes']"/>
-
+        <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/>
+        <xsl:variable name="URLLinkText" select="marc:sysprefs/marc:syspref[@name='URLLinkText']"/>
+        <xsl:variable name="Show856uAsImage" select="marc:sysprefs/marc:syspref[@name='OPACDisplay856uAsImage']"/>
+        <xsl:variable name="OPACTrackClicks" select="marc:sysprefs/marc:syspref[@name='TrackClicks']"/>
         <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)"/>
+        <xsl:variable name="biblionumber" select="marc:datafield[@tag=999]/marc:subfield[@code='c']"/>
         <xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/>
         <xsl:variable name="field019b" select="marc:datafield[@tag=019]/marc:subfield[@code='b']"/>
         <xsl:variable name="typeOf008">
             </span>
         </xsl:if>
 
+<!-- Image processing code added here, takes precedence over text links including y3z text   -->
         <xsl:if test="marc:datafield[@tag=856]">
-        <span class="results_summary"><span class="label">Nettbasert ressurs: </span>
+        <span class="results_summary online_resources"><span class="label">Online resources: </span>
         <xsl:for-each select="marc:datafield[@tag=856]">
-            <a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
-        <xsl:choose>
+            <xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
+           <a property="url">
+           <xsl:choose>
+             <xsl:when test="$OPACTrackClicks='track'">
+               <xsl:attribute name="href">/cgi-bin/koha/tracklinks.pl?uri=<xsl:value-of select="marc:subfield[@code='u']"/>;biblionumber=<xsl:value-of select="$biblionumber"/></xsl:attribute>
+             </xsl:when>
+             <xsl:when test="$OPACTrackClicks='anonymous'">
+               <xsl:attribute name="href">/cgi-bin/koha/tracklinks.pl?uri=<xsl:value-of select="marc:subfield[@code='u']"/>;biblionumber=<xsl:value-of select="$biblionumber"/></xsl:attribute>
+             </xsl:when>
+             <xsl:otherwise>
+                <xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
+             </xsl:otherwise>
+           </xsl:choose>
+            <xsl:if test="$OPACURLOpenInNewWindow='1'">
+                <xsl:attribute name="target">_blank</xsl:attribute>
+            </xsl:if>
+            <xsl:choose>
+            <xsl:when test="($Show856uAsImage='Details' or $Show856uAsImage='Both') and (substring($SubqText,1,6)='image/' or $SubqText='img' or $SubqText='bmp' or $SubqText='cod' or $SubqText='gif' or $SubqText='ief' or $SubqText='jpe' or $SubqText='jpeg' or $SubqText='jpg' or $SubqText='jfif' or $SubqText='png' or $SubqText='svg' or $SubqText='tif' or $SubqText='tiff' or $SubqText='ras' or $SubqText='cmx' or $SubqText='ico' or $SubqText='pnm' or $SubqText='pbm' or $SubqText='pgm' or $SubqText='ppm' or $SubqText='rgb' or $SubqText='xbm' or $SubqText='xpm' or $SubqText='xwd')">
+                <xsl:element name="img"><xsl:attribute name="src"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute><xsl:attribute name="alt"><xsl:value-of select="marc:subfield[@code='y']"/></xsl:attribute><xsl:attribute name="style">height:100px</xsl:attribute></xsl:element><xsl:text></xsl:text>
+            </xsl:when>
             <xsl:when test="marc:subfield[@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:call-template name="subfieldSelect">
+                    <xsl:with-param name="codes">y3z</xsl:with-param>
+                </xsl:call-template>
             </xsl:when>
-        <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
-        Klikk her for tilgang
-        </xsl:when>
-        </xsl:choose>
-        </a>
+            <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>
+            </a>
             <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:for-each>
index 52597bb..163b3aa 100644 (file)
     <xsl:variable name="UseControlNumber" select="marc:sysprefs/marc:syspref[@name='UseControlNumber']"/>
     <xsl:variable name="DisplayOPACiconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayOPACiconsXSLT']"/>
     <xsl:variable name="singleBranchMode" select="marc:sysprefs/marc:syspref[@name='singleBranchMode']"/>
+    <xsl:variable name="OPACTrackClicks" select="marc:sysprefs/marc:syspref[@name='TrackClicks']"/>
+    <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/>
+    <xsl:variable name="URLLinkText" select="marc:sysprefs/marc:syspref[@name='URLLinkText']"/>
+    <xsl:variable name="Show856uAsImage" select="marc:sysprefs/marc:syspref[@name='OPACDisplay856uAsImage']"/>
 
         <xsl:variable name="leader" select="marc:leader"/>
         <xsl:variable name="leader6" select="substring($leader,7,1)"/>
 
     </xsl:if>
 
+<!-- Links found in 856$u. This is copied verbatim from MARC21 detail view and should be identical to code in NORMARC detail view (except for $Show856uAsImage='Results'). -->
+        <xsl:if test="marc:datafield[@tag=856]">
+        <span class="results_summary online_resources"><span class="label">Online resources: </span>
+        <xsl:for-each select="marc:datafield[@tag=856]">
+            <xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
+           <a property="url">
+           <xsl:choose>
+             <xsl:when test="$OPACTrackClicks='track'">
+               <xsl:attribute name="href">/cgi-bin/koha/tracklinks.pl?uri=<xsl:value-of select="marc:subfield[@code='u']"/>;biblionumber=<xsl:value-of select="$biblionumber"/></xsl:attribute>
+             </xsl:when>
+             <xsl:when test="$OPACTrackClicks='anonymous'">
+               <xsl:attribute name="href">/cgi-bin/koha/tracklinks.pl?uri=<xsl:value-of select="marc:subfield[@code='u']"/>;biblionumber=<xsl:value-of select="$biblionumber"/></xsl:attribute>
+             </xsl:when>
+             <xsl:otherwise>
+                <xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
+             </xsl:otherwise>
+           </xsl:choose>
+            <xsl:if test="$OPACURLOpenInNewWindow='1'">
+                <xsl:attribute name="target">_blank</xsl:attribute>
+            </xsl:if>
+            <xsl:choose>
+            <xsl:when test="($Show856uAsImage='Results' or $Show856uAsImage='Both') and (substring($SubqText,1,6)='image/' or $SubqText='img' or $SubqText='bmp' or $SubqText='cod' or $SubqText='gif' or $SubqText='ief' or $SubqText='jpe' or $SubqText='jpeg' or $SubqText='jpg' or $SubqText='jfif' or $SubqText='png' or $SubqText='svg' or $SubqText='tif' or $SubqText='tiff' or $SubqText='ras' or $SubqText='cmx' or $SubqText='ico' or $SubqText='pnm' or $SubqText='pbm' or $SubqText='pgm' or $SubqText='ppm' or $SubqText='rgb' or $SubqText='xbm' or $SubqText='xpm' or $SubqText='xwd')">
+                <xsl:element name="img"><xsl:attribute name="src"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute><xsl:attribute name="alt"><xsl:value-of select="marc:subfield[@code='y']"/></xsl:attribute><xsl:attribute name="style">height:100px</xsl:attribute></xsl:element><xsl:text></xsl:text>
+            </xsl:when>
+            <xsl:when test="marc:subfield[@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="$URLLinkText!=''">
+                <xsl:value-of select="$URLLinkText"/>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:text>Click here to access online</xsl:text>
+            </xsl:otherwise>
+            </xsl:choose>
+            </a>
+            <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>
+<!-- End of links found in 856$u -->
+
 <span class="results_summary">
                         <span class="label">Availability: </span>
                         <xsl:choose>