Bug 32695: Fix search strings for 775, 780, 785 and 787

In the past due to some misunderstanding of the MARC standard
we built the search links for these fields using $a and $t with
the title index. But we actually need to search $t as title
and $a as author.
This patch fixes the templates for the MARC 7xx fields:
* 775
* 780
* 785
* 787

To test:
* Ensure systme preference 'UseControlNumber' is set to don't
* Create a record with the linking fields above
* Look at the OPAC and staff interface detail views
* Verify the content of your fields shows and the links combine a+t as a title search
* Apply patch
* Verify you have nicely formatted links now

Example:
775 _ _ ‡asomeone‡ttitle775
780 0 2 ‡asomeone‡ttitle780
785 0 2 ‡asomeone‡ttitle785
787 _ _ ‡ilabel:‡ttitle787‡asomeone

Signed-off-by: Sabrina Kiehl <kiehl@mpis.mpg.de>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit b2b3d88b73)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Nick Clemens 2023-05-26 19:00:13 +00:00 committed by Fridolin Somers
parent a4cc89bf25
commit 69d8b560d9
2 changed files with 158 additions and 66 deletions

View file

@ -1321,16 +1321,29 @@
<xsl:if test="marc:datafield[@tag=775]">
<span class="results_summary other_editions"><span class="label">Other editions: </span>
<xsl:for-each select="marc:datafield[@tag=775]">
<xsl:variable name="f775">
<xsl:call-template name="chopPunctuation"><xsl:with-param name="chopString"><xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template></xsl:with-param></xsl:call-template>
<xsl:variable name="relation_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>
<xsl:if test="marc:subfield[@code='i']">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">i</xsl:with-param>
</xsl:call-template>
<xsl:text>: </xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
<a>
<xsl:choose>
@ -1338,7 +1351,7 @@
<xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate($f775, '()', ''), true())"/></xsl:attribute>
<xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="str:encode-uri($relation_query, true())" /></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="subfieldSelect">
@ -1393,20 +1406,38 @@
</span>
</xsl:if>
<xsl:variable name="f780">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
<xsl:variable name="relation_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>
<xsl:choose>
<xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
<a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
<xsl:value-of select="$f780"/>
<a>
<xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:when>
<xsl:otherwise>
<a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate($f780, '()', ''), true())"/></xsl:attribute>
<xsl:value-of select="$f780"/>
<a>
<xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="str:encode-uri($relation_query, true())" /></xsl:attribute>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:otherwise>
</xsl:choose>
@ -1463,21 +1494,38 @@
</span>
</xsl:if>
<xsl:variable name="f785">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
<xsl:variable name="relation_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>
<xsl:choose>
<xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
<a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
<xsl:value-of select="$f785"/>
<a>
<xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:when>
<xsl:otherwise>
<a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate($f785, '()', ''), true())"/></xsl:attribute>
<xsl:value-of select="$f785"/>
<a>
<xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="str:encode-uri($relation_query, true())" /></xsl:attribute>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:otherwise>
</xsl:choose>
@ -1492,21 +1540,19 @@
<span class="results_summary other_relationship_entry"><span class="label">Other related works: </span>
<xsl:for-each select="marc:datafield[@tag=787]">
<span class="other_relationship_entry">
<xsl:variable name="f787">
<xsl:call-template name="chopPunctuation"><xsl:with-param name="chopString"><xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template></xsl:with-param></xsl:call-template>
</xsl:variable>
<xsl:if test="marc:subfield[@code='i']">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">i</xsl:with-param>
</xsl:call-template>
<xsl:text>: </xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
<a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
<xsl:value-of select="$f787"/>
<a>
<xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:when>
<xsl:otherwise>
@ -1527,9 +1573,10 @@
</xsl:if>
</xsl:variable>
<a>
<xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="str:encode-uri($relation_query, true())" />
</xsl:attribute>
<xsl:value-of select="$f787"/>
<xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="str:encode-uri($relation_query, true())" /></xsl:attribute>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:otherwise>
</xsl:choose>

View file

@ -1094,21 +1094,19 @@
<span class="results_summary other_relationship_entry"><span class="label">Other related works: </span>
<xsl:for-each select="marc:datafield[@tag=787]">
<span class="other_relationship_entry">
<xsl:variable name="f787">
<xsl:call-template name="chopPunctuation"><xsl:with-param name="chopString"><xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template></xsl:with-param></xsl:call-template>
</xsl:variable>
<xsl:if test="marc:subfield[@code='i']">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">i</xsl:with-param>
</xsl:call-template>
<xsl:text>: </xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
<a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
<xsl:value-of select="$f787"/>
<a>
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:when>
<xsl:otherwise>
@ -1129,9 +1127,10 @@
</xsl:if>
</xsl:variable>
<a>
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="str:encode-uri($relation_query, true())" />
</xsl:attribute>
<xsl:value-of select="$f787"/>
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="str:encode-uri($relation_query, true())" /></xsl:attribute>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:otherwise>
</xsl:choose>
@ -1532,25 +1531,38 @@
<xsl:if test="marc:datafield[@tag=775]">
<span class="results_summary other_editions"><span class="label">Other editions: </span>
<xsl:for-each select="marc:datafield[@tag=775]">
<xsl:variable name="f775">
<xsl:call-template name="chopPunctuation"><xsl:with-param name="chopString"><xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template></xsl:with-param></xsl:call-template>
<xsl:variable name="relation_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>
<xsl:if test="marc:subfield[@code='i']">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">i</xsl:with-param>
</xsl:call-template>
<xsl:text>: </xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
<a>
<xsl:choose>
<xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate($f775, '()', ''), true())"/></xsl:attribute>
</xsl:otherwise>
<xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="str:encode-uri($relation_query, true())" /></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
@ -1604,21 +1616,38 @@
</span>
</xsl:if>
<xsl:variable name="f780">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
<xsl:variable name="relation_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>
<xsl:choose>
<xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
<a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
<xsl:value-of select="$f780"/>
<a>
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:when>
<xsl:otherwise>
<a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate($f780, '()', ''), true())"/></xsl:attribute>
<xsl:value-of select="$f780"/>
<a>
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="str:encode-uri($relation_query, true())" /></xsl:attribute>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:otherwise>
</xsl:choose>
@ -1675,21 +1704,37 @@
</span>
</xsl:if>
<xsl:variable name="f785">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
<xsl:variable name="relation_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>
<xsl:choose>
<xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
<a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
<xsl:value-of select="$f785"/>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:when>
<xsl:otherwise>
<a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=ti,phr:<xsl:value-of select="str:encode-uri(translate($f785, '()', ''), true())"/></xsl:attribute>
<xsl:value-of select="$f785"/>
<a>
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="str:encode-uri($relation_query, true())" /></xsl:attribute>
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">a_t</xsl:with-param>
</xsl:call-template>
</a>
</xsl:otherwise>
</xsl:choose>