Bugzilla – Attachment 137248 Details for
Bug 31106
Error searching for analytics in detail view
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31106: Fix links generated in XSLTs
Bug-31106-Fix-links-generated-in-XSLTs.patch (text/plain), 11.64 KB, created by
David Nind
on 2022-07-06 20:27:02 UTC
(
hide
)
Description:
Bug 31106: Fix links generated in XSLTs
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-07-06 20:27:02 UTC
Size:
11.64 KB
patch
obsolete
>From c037c6cd4f1ed1f3d6b84c08292ea8c505d2c1a0 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 4 Jul 2022 21:09:05 -0300 >Subject: [PATCH] Bug 31106: Fix links generated in XSLTs >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch addresses the case of links that are generated on the XSLT >side, those linking to and from host records using 773$t and 773$a. > >To test: >1. Pick a bibliographic record (I chose 'Unconditional' from the sample > data >2. Add " and ? to the title statement. I changed it to > 'Uncond"itional?¿' >3. Add a child record to it >4. Open the detail page for the host record >=> FAIL: It doesn't show the 'Show analytics' link >5. Repeat 4 for the same record, in the OPAC >=> FAIL: It doesn't show the 'Show analytics' link >6. Apply this patch >7. Repeat 4 and 5. >=> SUCCESS: Links are shown! >8. Follow the links >=> SUCCESS: The links take you to the right resultset! >9. Go to the child record, and notice the link back to the parent works > :-D >10. Sign off :-D > >Sponsored-by: Theke Solutions > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../en/xslt/MARC21slim2intranetDetail.xsl | 28 ++++++++++++++++-- > .../prog/en/xslt/MARC21slimUtils.xsl | 29 +++++++++++++++++++ > .../en/xslt/MARC21slim2OPACDetail.xsl | 28 ++++++++++++++++-- > .../bootstrap/en/xslt/MARC21slimUtils.xsl | 29 +++++++++++++++++++ > 4 files changed, 110 insertions(+), 4 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >index 88f60ae598..acaf38a650 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >@@ -215,7 +215,14 @@ > <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=rcn:<xsl:value-of select="str:encode-uri(marc:controlfield[@tag=001], true())"/>+AND+(bib-level:a+OR+bib-level:b)</xsl:attribute> > </xsl:when> > <xsl:otherwise> >- <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Host-item:(<xsl:value-of select="str:encode-uri(translate(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/', ''), true())"/>)</xsl:attribute> >+ <xsl:variable name="title_query"> >+ <xsl:text>Host-item:(</xsl:text> >+ <xsl:call-template name="quote_search_term"> >+ <xsl:with-param name="term"><xsl:value-of select="marc:datafield[@tag=245]/marc:subfield[@code='a']"/></xsl:with-param> >+ </xsl:call-template> >+ <xsl:text>)</xsl:text> >+ </xsl:variable> >+ <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="str:encode-uri($title_query, true())"/></xsl:attribute> > </xsl:otherwise> > </xsl:choose> > <xsl:text>Show analytics</xsl:text> >@@ -1083,8 +1090,25 @@ > </a> > </xsl:when> > <xsl:otherwise> >+ <xsl:variable name="host_query"> >+ <xsl:text>ti,phr:(</xsl:text> >+ <xsl:call-template name="quote_search_term"> >+ <xsl:with-param name="term"><xsl:value-of select="marc:subfield[@code='t']"/></xsl:with-param> >+ </xsl:call-template> >+ <xsl:text>)</xsl:text> >+ <xsl:if test="marc:subfield[@code='a']"> >+ <xsl:text> AND au:(</xsl:text> >+ <xsl:call-template name="quote_search_term"> >+ <xsl:with-param name="term"> >+ <xsl:value-of select="marc:subfield[@code='a']"/> >+ </xsl:with-param> >+ </xsl:call-template> >+ <xsl:text>)</xsl:text> >+ </xsl:if> >+ </xsl:variable> > <a> >- <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate(marc:subfield[@code='t'], '()', ''), true())"/><xsl:if test="marc:subfield[@code='a']">+AND+au:<xsl:value-of select="str:encode-uri(translate(marc:subfield[@code='a'], '()', ''), true())"/></xsl:if></xsl:attribute> >+ <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="str:encode-uri($host_query, true())" /> >+ </xsl:attribute> > <xsl:value-of select="$f773"/> > </a> > </xsl:otherwise> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl >index dfc9cc0186..e3271c85b5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl >@@ -578,6 +578,35 @@ > </xsl:if> > </xsl:template> > >+ <xsl:template name="quote_search_term"> >+ <xsl:param name="term" /> >+ <xsl:text>"</xsl:text> >+ <xsl:call-template name="escape_quotes"> >+ <xsl:with-param name="text"> >+ <xsl:value-of select="$term"/> >+ </xsl:with-param> >+ </xsl:call-template> >+ <xsl:text>"</xsl:text> >+ </xsl:template> >+ >+ <xsl:template name="escape_quotes"> >+ <xsl:param name="text"/> >+ <xsl:choose> >+ <xsl:when test="contains($text, '"')"> >+ <xsl:variable name="before" select="substring-before($text,'"')"/> >+ <xsl:variable name="next" select="substring-after($text,'"')"/> >+ <xsl:value-of select="$before"/> >+ <xsl:text>\"</xsl:text> >+ <xsl:call-template name="escape_quotes"> >+ <xsl:with-param name="text" select="$next"/> >+ </xsl:call-template> >+ </xsl:when> >+ <xsl:otherwise> >+ <xsl:value-of select="$text"/> >+ </xsl:otherwise> >+ </xsl:choose> >+ </xsl:template> >+ > </xsl:stylesheet> > > <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp. >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >index 8f02316945..31781fd07b 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACDetail.xsl >@@ -257,7 +257,14 @@ > <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=rcn:<xsl:value-of select="str:encode-uri(marc:controlfield[@tag=001], true())"/>+AND+(bib-level:a+OR+bib-level:b)</xsl:attribute> > </xsl:when> > <xsl:otherwise> >- <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Host-item:(<xsl:value-of select="str:encode-uri(translate(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/', ''), true())"/>)</xsl:attribute> >+ <xsl:variable name="title_query"> >+ <xsl:text>Host-item:(</xsl:text> >+ <xsl:call-template name="quote_search_term"> >+ <xsl:with-param name="term"><xsl:value-of select="marc:datafield[@tag=245]/marc:subfield[@code='a']"/></xsl:with-param> >+ </xsl:call-template> >+ <xsl:text>)</xsl:text> >+ </xsl:variable> >+ <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="str:encode-uri($title_query, true())"/></xsl:attribute> > </xsl:otherwise> > </xsl:choose> > <xsl:text>Show analytics</xsl:text> >@@ -1230,8 +1237,25 @@ > </a> > </xsl:when> > <xsl:otherwise> >+ <xsl:variable name="host_query"> >+ <xsl:text>ti,phr:(</xsl:text> >+ <xsl:call-template name="quote_search_term"> >+ <xsl:with-param name="term"><xsl:value-of select="marc:subfield[@code='t']"/></xsl:with-param> >+ </xsl:call-template> >+ <xsl:text>)</xsl:text> >+ <xsl:if test="marc:subfield[@code='a']"> >+ <xsl:text> AND au:(</xsl:text> >+ <xsl:call-template name="quote_search_term"> >+ <xsl:with-param name="term"> >+ <xsl:value-of select="marc:subfield[@code='a']"/> >+ </xsl:with-param> >+ </xsl:call-template> >+ <xsl:text>)</xsl:text> >+ </xsl:if> >+ </xsl:variable> > <a> >- <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate(marc:subfield[@code='t'], '()', ''), true())"/><xsl:if test="marc:subfield[@code='a']">+AND+au:<xsl:value-of select="str:encode-uri(translate(marc:subfield[@code='a'], '()', ''), true())"/></xsl:if></xsl:attribute> >+ <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="str:encode-uri($host_query, true())" /> >+ </xsl:attribute> > <xsl:value-of select="$f773"/> > </a> > </xsl:otherwise> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl >index 105da508c7..b734afd754 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl >@@ -542,6 +542,35 @@ > </xsl:if> > </xsl:template> > >+ <xsl:template name="quote_search_term"> >+ <xsl:param name="term" /> >+ <xsl:text>"</xsl:text> >+ <xsl:call-template name="escape_quotes"> >+ <xsl:with-param name="text"> >+ <xsl:value-of select="$term"/> >+ </xsl:with-param> >+ </xsl:call-template> >+ <xsl:text>"</xsl:text> >+ </xsl:template> >+ >+ <xsl:template name="escape_quotes"> >+ <xsl:param name="text"/> >+ <xsl:choose> >+ <xsl:when test="contains($text, '"')"> >+ <xsl:variable name="before" select="substring-before($text,'"')"/> >+ <xsl:variable name="next" select="substring-after($text,'"')"/> >+ <xsl:value-of select="$before"/> >+ <xsl:text>\"</xsl:text> >+ <xsl:call-template name="escape_quotes"> >+ <xsl:with-param name="text" select="$next"/> >+ </xsl:call-template> >+ </xsl:when> >+ <xsl:otherwise> >+ <xsl:value-of select="$text"/> >+ </xsl:otherwise> >+ </xsl:choose> >+ </xsl:template> >+ > </xsl:stylesheet> > > <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp. >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31106
:
137183
|
137184
|
137185
|
137237
|
137238
|
137239
|
137246
|
137247
|
137248
|
137831
|
137832
|
137833