From 7ae7dbcdfe9d3776780648349a6de28c4cf6e1b2 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Date: Thu, 17 Mar 2011 14:08:11 +0100 Subject: [PATCH] [UPDATED] 5643: Few new template routines in MARC21slim2OPACResults.xsl Content-Type: text/plain; charset="utf-8" This patch only rearranges code and adds a new routine. Koha behavior does NOT change. New template routine ShowCallNumber added. Can be used in customization. New templates routines ShowELocation and ShowAvailable only contain moved code. Rebased on March 17. --- .../prog/en/xslt/MARC21slim2OPACResults.xsl | 308 +++++++++++--------- 1 files changed, 175 insertions(+), 133 deletions(-) diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl index 39eddd7..cfd62aa 100644 --- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl @@ -19,10 +19,7 @@ <!-- Option: Display Alternate Graphic Representation (MARC 880) --> <xsl:variable name="display880" select="boolean(marc:datafield[@tag=880])"/> - <xsl:variable name="hidelostitems" select="marc:sysprefs/marc:syspref[@name='hidelostitems']"/> <xsl:variable name="DisplayOPACiconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayOPACiconsXSLT']"/> - <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="leader" select="marc:leader"/> <xsl:variable name="leader6" select="substring($leader,7,1)"/> <xsl:variable name="leader7" select="substring($leader,8,1)"/> @@ -900,143 +897,188 @@ </xsl:for-each> </span> </xsl:if> - <xsl:if test="marc:datafield[@tag=856]"> - <span class="results_summary"> - <span class="label">Online Access: </span> - <xsl:for-each select="marc:datafield[@tag=856]"> - <xsl:if test="$OPACURLOpenInNewWindow='0'"> - <a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute> - <xsl:choose> - <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'])"> - <xsl:choose> - <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> - </xsl:when> - </xsl:choose> - </a> - </xsl:if> - <xsl:if test="$OPACURLOpenInNewWindow='1'"> - <a target='_blank'><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute> - <xsl:choose> - <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'])"> - <xsl:choose> - <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> + + <xsl:call-template name="ShowELocation"/> + + <!-- Remove surrouding comments to show call number too --> + <!-- + <xsl:call-template name="ShowCallNumber"/> + --> + + <xsl:call-template name="ShowAvailable"/> + </xsl:template> + <!-- end of match marc:record --> + + + <xsl:template name="ShowELocation"> + <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/> + <xsl:variable name="URLLinkText" select="marc:sysprefs/marc:syspref[@name='URLLinkText']"/> + <xsl:if test="marc:datafield[@tag=856]"> + <span class="results_summary"> + <span class="label">Online Access: </span> + <xsl:for-each select="marc:datafield[@tag=856]"> + <xsl:if test="$OPACURLOpenInNewWindow='0'"> + <a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute> + <xsl:choose> + <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'])"> + <xsl:choose> + <xsl:when test="$URLLinkText!=''"> + <xsl:value-of select="$URLLinkText"/> </xsl:when> - </xsl:choose> - </a> - </xsl:if> - <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> - <span class="results_summary"> - <span class="label">Availability: </span> + <xsl:otherwise> + <xsl:text>Click here to access online</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + </xsl:choose> + </a> + </xsl:if> + <xsl:if test="$OPACURLOpenInNewWindow='1'"> + <a target='_blank'><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute> <xsl:choose> - <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" + <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'])"> + <xsl:choose> + <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> + </xsl:when> + </xsl:choose> + </a> + </xsl:if> + <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> + </xsl:template> + + <xsl:template name="ShowAvailable"> + <xsl:variable name="hidelostitems" select="marc:sysprefs/marc:syspref[@name='hidelostitems']"/> + <span class="results_summary"> + <span class="label">Availability: </span> + <xsl:choose> + <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: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: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" + <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: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', '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 order'))>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:if test="count(key('item-by-status', 'On order'))>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:template name="ShowCallNumber"> + <span class="results_summary"> + <span class="label">Call Number: </span> + <xsl:for-each select="marc:datafield[@tag=952]/marc:subfield[@code='o']"> + <xsl:value-of select="."/> + <xsl:choose> + <xsl:when test="position()=last()"></xsl:when> + <xsl:otherwise>, </xsl:otherwise> + </xsl:choose> + </xsl:for-each> + </span> </xsl:template> <xsl:template name="nameABCDQ"> -- 1.6.0.6