From 3b1924498c51c71dce5c8aec2d615b1ef7109a1f Mon Sep 17 00:00:00 2001 From: Julian Maurice <julian.maurice@biblibre.com> Date: Thu, 31 Jul 2014 11:09:29 +0200 Subject: [PATCH] Bug 8995: Add OpenURL link to OPAC bootstrap XSLT files --- .../bootstrap/en/xslt/MARC21slim2OPACDetail.xsl | 58 +++++++++++++++++++ .../bootstrap/en/xslt/MARC21slim2OPACResults.xsl | 60 +++++++++++++++++++- .../bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl | 59 +++++++++++++++++++ .../bootstrap/en/xslt/UNIMARCslim2OPACResults.xsl | 58 +++++++++++++++++++ 4 files changed, 234 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl index fdd5421..ea19f58 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl @@ -982,6 +982,64 @@ </xsl:for-each> </xsl:if> + <!-- OpenURL --> + <xsl:variable name="OPACShowOpenURL" select="marc:sysprefs/marc:syspref[@name='OPACShowOpenURL']" /> + <xsl:variable name="OpenURLResolverURL" select="marc:sysprefs/marc:syspref[@name='OpenURLResolverURL']" /> + <xsl:variable name="OpenURLImageLocation" select="marc:sysprefs/marc:syspref[@name='OpenURLImageLocation']" /> + <xsl:variable name="OpenURLText" select="marc:sysprefs/marc:syspref[@name='OpenURLText']" /> + <xsl:variable name="COinS" select="marc:variables/marc:variable[@name='COinS']" /> + + <xsl:if test="$OPACShowOpenURL = 1 and $OpenURLResolverURL != '' and $COinS != ''"> + <xsl:variable name="openurltext"> + <xsl:choose> + <xsl:when test="$OpenURLText != ''"> + <xsl:value-of select="$OpenURLText" /> + </xsl:when> + <xsl:otherwise> + <xsl:text>OpenURL</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="openurlimagelocation"> + <xsl:choose> + <xsl:when test="starts-with($OpenURLImageLocation, 'http://') or starts-with($OpenURLImageLocation, 'https://')"> + <xsl:value-of select="$OpenURLImageLocation" /> + </xsl:when> + <xsl:when test="$OpenURLImageLocation != ''"> + <xsl:text>/opac-tmpl/prog/images/</xsl:text> + <xsl:value-of select="$OpenURLImageLocation" /> + </xsl:when> + </xsl:choose> + </xsl:variable> + + <span class="results_summary"><a> + <xsl:attribute name="href"> + <xsl:value-of select="$OpenURLResolverURL" /> + <xsl:text>?</xsl:text> + <xsl:value-of select="$COinS" /> + </xsl:attribute> + <xsl:attribute name="title"> + <xsl:value-of select="$openurltext" /> + </xsl:attribute> + <xsl:attribute name="class"> + <xsl:text>OpenURL</xsl:text> + </xsl:attribute> + <xsl:choose> + <xsl:when test="$openurlimagelocation != ''"> + <img> + <xsl:attribute name="src"> + <xsl:value-of select="$openurlimagelocation" /> + </xsl:attribute> + </img> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$openurltext" /> + </xsl:otherwise> + </xsl:choose> + </a></span> + </xsl:if> + <!-- End of OpenURL --> + </xsl:element> </xsl:template> diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl index ea6af38..67b0d30 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl @@ -438,8 +438,66 @@ </xsl:for-each> </xsl:if> </a> - <p> + <!-- OpenURL --> + <xsl:variable name="OPACShowOpenURL" select="marc:sysprefs/marc:syspref[@name='OPACShowOpenURL']" /> + <xsl:variable name="OpenURLResolverURL" select="marc:sysprefs/marc:syspref[@name='OpenURLResolverURL']" /> + <xsl:variable name="OpenURLImageLocation" select="marc:sysprefs/marc:syspref[@name='OpenURLImageLocation']" /> + <xsl:variable name="OpenURLText" select="marc:sysprefs/marc:syspref[@name='OpenURLText']" /> + <xsl:variable name="COinS" select="marc:variables/marc:variable[@name='COinS']" /> + + <xsl:if test="$OPACShowOpenURL = 1 and $OpenURLResolverURL != '' and $COinS != ''"> + <xsl:variable name="openurltext"> + <xsl:choose> + <xsl:when test="$OpenURLText != ''"> + <xsl:value-of select="$OpenURLText" /> + </xsl:when> + <xsl:otherwise> + <xsl:text>OpenURL</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="openurlimagelocation"> + <xsl:choose> + <xsl:when test="starts-with($OpenURLImageLocation, 'http://') or starts-with($OpenURLImageLocation, 'https://')"> + <xsl:value-of select="$OpenURLImageLocation" /> + </xsl:when> + <xsl:when test="$OpenURLImageLocation != ''"> + <xsl:text>/opac-tmpl/prog/images/</xsl:text> + <xsl:value-of select="$OpenURLImageLocation" /> + </xsl:when> + </xsl:choose> + </xsl:variable> + + <span class="results_summary"><a> + <xsl:attribute name="href"> + <xsl:value-of select="$OpenURLResolverURL" /> + <xsl:text>?</xsl:text> + <xsl:value-of select="$COinS" /> + </xsl:attribute> + <xsl:attribute name="title"> + <xsl:value-of select="$openurltext" /> + </xsl:attribute> + <xsl:attribute name="class"> + <xsl:text>OpenURL</xsl:text> + </xsl:attribute> + <xsl:choose> + <xsl:when test="$openurlimagelocation != ''"> + <img> + <xsl:attribute name="src"> + <xsl:value-of select="$openurlimagelocation" /> + </xsl:attribute> + </img> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$openurltext" /> + </xsl:otherwise> + </xsl:choose> + </a></span> + </xsl:if> + <!-- End of OpenURL --> + + <p> <!-- Author Statement: Alternate Graphic Representation (MARC 880) --> <xsl:if test="$display880"> <xsl:call-template name="m880Select"> diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl index f7d1984..b07abb0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl @@ -438,6 +438,65 @@ </xsl:for-each> </span> </xsl:if> + + <!-- OpenURL --> + <xsl:variable name="OPACShowOpenURL" select="marc:sysprefs/marc:syspref[@name='OPACShowOpenURL']" /> + <xsl:variable name="OpenURLResolverURL" select="marc:sysprefs/marc:syspref[@name='OpenURLResolverURL']" /> + <xsl:variable name="OpenURLImageLocation" select="marc:sysprefs/marc:syspref[@name='OpenURLImageLocation']" /> + <xsl:variable name="OpenURLText" select="marc:sysprefs/marc:syspref[@name='OpenURLText']" /> + <xsl:variable name="COinS" select="marc:variables/marc:variable[@name='COinS']" /> + + <xsl:if test="$OPACShowOpenURL = 1 and $OpenURLResolverURL != '' and $COinS != ''"> + <xsl:variable name="openurltext"> + <xsl:choose> + <xsl:when test="$OpenURLText != ''"> + <xsl:value-of select="$OpenURLText" /> + </xsl:when> + <xsl:otherwise> + <xsl:text>OpenURL</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="openurlimagelocation"> + <xsl:choose> + <xsl:when test="starts-with($OpenURLImageLocation, 'http://') or starts-with($OpenURLImageLocation, 'https://')"> + <xsl:value-of select="$OpenURLImageLocation" /> + </xsl:when> + <xsl:when test="$OpenURLImageLocation != ''"> + <xsl:text>/opac-tmpl/prog/images/</xsl:text> + <xsl:value-of select="$OpenURLImageLocation" /> + </xsl:when> + </xsl:choose> + </xsl:variable> + + <span class="results_summary"><a> + <xsl:attribute name="href"> + <xsl:value-of select="$OpenURLResolverURL" /> + <xsl:text>?</xsl:text> + <xsl:value-of select="$COinS" /> + </xsl:attribute> + <xsl:attribute name="title"> + <xsl:value-of select="$openurltext" /> + </xsl:attribute> + <xsl:attribute name="class"> + <xsl:text>OpenURL</xsl:text> + </xsl:attribute> + <xsl:choose> + <xsl:when test="$openurlimagelocation != ''"> + <img> + <xsl:attribute name="src"> + <xsl:value-of select="$openurlimagelocation" /> + </xsl:attribute> + </img> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$openurltext" /> + </xsl:otherwise> + </xsl:choose> + </a></span> + </xsl:if> + <!-- End of OpenURL --> + </xsl:template> <xsl:template name="nameABCDQ"> diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACResults.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACResults.xsl index 5c9c88e..4956b27 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACResults.xsl @@ -77,6 +77,64 @@ </xsl:for-each> </xsl:if> + <!-- OpenURL --> + <xsl:variable name="OPACShowOpenURL" select="marc:sysprefs/marc:syspref[@name='OPACShowOpenURL']" /> + <xsl:variable name="OpenURLResolverURL" select="marc:sysprefs/marc:syspref[@name='OpenURLResolverURL']" /> + <xsl:variable name="OpenURLImageLocation" select="marc:sysprefs/marc:syspref[@name='OpenURLImageLocation']" /> + <xsl:variable name="OpenURLText" select="marc:sysprefs/marc:syspref[@name='OpenURLText']" /> + <xsl:variable name="COinS" select="marc:variables/marc:variable[@name='COinS']" /> + + <xsl:if test="$OPACShowOpenURL = 1 and $OpenURLResolverURL != '' and $COinS != ''"> + <xsl:variable name="openurltext"> + <xsl:choose> + <xsl:when test="$OpenURLText != ''"> + <xsl:value-of select="$OpenURLText" /> + </xsl:when> + <xsl:otherwise> + <xsl:text>OpenURL</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="openurlimagelocation"> + <xsl:choose> + <xsl:when test="starts-with($OpenURLImageLocation, 'http://') or starts-with($OpenURLImageLocation, 'https://')"> + <xsl:value-of select="$OpenURLImageLocation" /> + </xsl:when> + <xsl:when test="$OpenURLImageLocation != ''"> + <xsl:text>/opac-tmpl/prog/images/</xsl:text> + <xsl:value-of select="$OpenURLImageLocation" /> + </xsl:when> + </xsl:choose> + </xsl:variable> + + <span class="results_summary"><a> + <xsl:attribute name="href"> + <xsl:value-of select="$OpenURLResolverURL" /> + <xsl:text>?</xsl:text> + <xsl:value-of select="$COinS" /> + </xsl:attribute> + <xsl:attribute name="title"> + <xsl:value-of select="$openurltext" /> + </xsl:attribute> + <xsl:attribute name="class"> + <xsl:text>OpenURL</xsl:text> + </xsl:attribute> + <xsl:choose> + <xsl:when test="$openurlimagelocation != ''"> + <img> + <xsl:attribute name="src"> + <xsl:value-of select="$openurlimagelocation" /> + </xsl:attribute> + </img> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$openurltext" /> + </xsl:otherwise> + </xsl:choose> + </a></span> + </xsl:if> + <!-- End of OpenURL --> + <xsl:call-template name="tag_title"> <xsl:with-param name="tag">454</xsl:with-param> <xsl:with-param name="label">Translation of</xsl:with-param> -- 1.7.10.4