Koha/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl
Doug Dearden 6c7f964c27 Bug 5738 Display 856u As Image
Add an option to the OPAC to display the URI that is stored in the 856u field
as an image instead of a text link.  This would be implemented in the OPAC XSLT
style sheets for the Results and Details pages, and would require that the
corresponding OPAC XSLT option be set.

This enhancement is designed to enable the staff to catalog images, then have
them appear on the resulting pages in the OPAC when searching.  Clicking on the
image would open it full size.  If the image option is in use, then the default
link text would be disabled.  Custom text would still appear if entered in the
"URLLinkText" option.

Add system preference "Display856uAsImage" with options of Results page,
Details page, Both Results and Details pages, Neither Results or Details page.

Notes for documentation manager:
There are two system preferences added for this enhancement:
OPACDisplay856uAsImage and Display856uAsImage.  These appear on the OPAC and
Staff Client screens under the System Preferences.

The preference can be set to one of four options:

Both Details and Results pages
Details page only
Neither Details or Results pages
Results page only

In addition to this option being set, the corresponding XSLT option must be
turned on. Also, the corresponding 856q field must have a valid MIME image
extension (e.g., "jpg") or MIME image type (i.e. starting with "image/"), or the
generic indicator "img" entered in the field.

As of 14 March 2011 the UNIMARC xslt display files also require a "0" in the
second indicator location of the 856u field for the links to be activated.  This
is not true for the MARC21 display files.

When all of the requirements are met, an image file will be displayed instead of
the standard link text. Clicking on the image will open it in the same way as
clicking on the link text.

Rebased and three original patches squashed into one on 30 March 2011 by Jared
Camins-Esakov.

Signed-off-by: Jared Camins-Esakov <jcamins@bywatersolutions.com>
Signed-off-by: Doug Dearden <dearden@sarsf.org>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
2011-04-01 13:38:14 +13:00

212 lines
9.5 KiB
XML
Executable file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE stylesheet [<!ENTITY nbsp "&#160;" >]>
<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"
exclude-result-prefixes="marc items">
<xsl:import href="UNIMARCslimUtils.xsl"/>
<xsl:output method = "xml" indent="yes" omit-xml-declaration = "yes" />
<xsl:key name="item-by-status" match="items:item" use="items:status"/>
<xsl:key name="item-by-status-and-branch" match="items:item" use="concat(items:status, ' ', items:homebranch)"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="marc:record">
<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:variable name="leader7" select="substring($leader,8,1)"/>
<xsl:variable name="biblionumber"
select="marc:datafield[@tag=090]/marc:subfield[@code='a']"/>
<xsl:variable name="isbn"
select="marc:datafield[@tag=010]/marc:subfield[@code='a']"/>
<xsl:variable name="hidelostitems" select="marc:sysprefs/marc:syspref[@name='hidelostitems']"/>
<xsl:if test="marc:datafield[@tag=200]">
<xsl:for-each select="marc:datafield[@tag=200]">
<xsl:variable name="title" select="marc:subfield[@code='a']"/>
<xsl:variable name="ntitle"
select="translate($title, '&#x0098;&#x009C;','')"/>
<div>
<xsl:call-template name="addClassRtl" />
<span class="results_summary">
<span class="label"/>
<a>
<xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="$biblionumber"/></xsl:attribute>
<xsl:value-of select="$ntitle" />
</a>
<xsl:if test="marc:subfield[@code='e']">
<xsl:text> : </xsl:text>
<xsl:for-each select="marc:subfield[@code='e']">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:if>
<xsl:if test="marc:subfield[@code='b']">
<xsl:text> [</xsl:text>
<xsl:value-of select="marc:subfield[@code='b']"/>
<xsl:text>]</xsl:text>
</xsl:if>
<xsl:if test="marc:subfield[@code='f']">
<xsl:text> / </xsl:text>
<xsl:value-of select="marc:subfield[@code='f']"/>
</xsl:if>
<xsl:if test="marc:subfield[@code='g']">
<xsl:text> ; </xsl:text>
<xsl:value-of select="marc:subfield[@code='g']"/>
</xsl:if>
</span>
</div>
</xsl:for-each>
</xsl:if>
<xsl:call-template name="tag_4xx" />
<xsl:call-template name="tag_210" />
<xsl:call-template name="tag_215" />
<span class="results_summary">
<span class="label">Availability: </span>
<xsl:choose>
<xsl:when test="marc:datafield[@tag=856]">
<xsl:for-each select="marc:datafield[@tag=856]">
<xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
<xsl:choose>
<xsl:when test="@ind2=0">
<a>
<xsl:attribute name="href">
<xsl:value-of select="marc:subfield[@code='u']"/>
</xsl:attribute>
<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="height">100</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="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@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: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">
<span class="available">
<b><xsl:text>Copies available for loan: </xsl:text></b>
<xsl:variable name="available_items" select="key('item-by-status', 'available')"/>
<xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
<xsl:value-of select="items:homebranch"/>
<xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]
</xsl:if>
<xsl:text> (</xsl:text>
<xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
<xsl:text>)</xsl:text>
<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>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="count(key('item-by-status', 'reference'))>0">
<span class="available">
<b><xsl:text>Copies available for reference: </xsl:text></b>
<xsl:variable name="reference_items"
select="key('item-by-status', 'reference')"/>
<xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
<xsl:value-of select="items:homebranch"/>
<xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
<xsl:text> (</xsl:text>
<xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
<xsl:text>)</xsl:text>
<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>
</xsl:when>
</xsl:choose>
<xsl:if test="count(key('item-by-status', 'Checked out'))>0">
<span class="unavailable">
<xsl:text>Checked out (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'Checked out'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="count(key('item-by-status', 'Withdrawn'))>0">
<span class="unavailable">
<xsl:text>Withdrawn (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'Withdrawn'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="$hidelostitems='0' and count(key('item-by-status', 'Lost'))>0">
<span class="unavailable">
<xsl:text>Lost (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'Lost'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="count(key('item-by-status', 'Damaged'))>0">
<span class="unavailable">
<xsl:text>Damaged (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'Damaged'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="count(key('item-by-status', 'On Orangemanr'))>0">
<span class="unavailable">
<xsl:text>On order (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'On order'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="count(key('item-by-status', 'In transit'))>0">
<span class="unavailable">
<xsl:text>In transit (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'In transit'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="count(key('item-by-status', 'Waiting'))>0">
<span class="unavailable">
<xsl:text>On hold (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'Waiting'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
</span>
</xsl:template>
</xsl:stylesheet>