Bug 38096: Staff: Display 857 to detail and results pages

This work DRYs the 856 display logic to renderMARCOnlineResourceField.
This was previously written in detail and results pages.

Once this single function exists, 857 can also make use of it to be
displayed using the same logic/features already present for 856.

1) If testing k-t-d, add the test data for test plan (otherwise prep instructions below):
updatedatabase
2) Force reindex of this biblio by saving it, visit the biblio:
<staff_url>/cgi-bin/koha/catalogue/detail.pl?biblionumber=76
3) Click "Edit" -> "Edit record" -> "Save"
4) Open the following URL's, preferably on 4 different browser tabs (we're using biblio 76 for this test):
<staff_url>/cgi-bin/koha/catalogue/search.pl?q=music (first record [76] is the one we're testing)
<staff_url>/cgi-bin/koha/catalogue/detail.pl?biblionumber=76
<opac_url>/cgi-bin/koha/opac-search.pl?idx=&q=music (first record [76] is the one we're testing)
<opac_url>/cgi-bin/koha/opac-detail.pl?biblionumber=76
5) Verify that on all pages there are 3 instances of 856 (Online resources) and 3 instances of 857 (Online archive resources) with their respective link labels and URLs.
6) Click on the "Koha community no protocol" link for 856 and 857, notice the 'http://' protocol is added.
7) Change the values of OPACDisplay856uAsImage + Display856uAsImage and refresh the respective page. Verify it works as expected (respects the system preference). Note: This only applies for 856, not 857 (out of scope here).
8) Change the value of OPACURLOpenInNewWindow and click on the links before and after. Verify they respect the system preference.

If not on k-t-d and updatedatabase not available:

perl /kohadevbox/koha/installer/data/mysql/updatedatabase.pl
or
koha-shell -c "perl /kohadevbox/koha/installer/data/mysql/updatedatabase.pl" <instance_name>

If CLI not available (preparation on UI):
A) Add field 857 to the 'Default' framework
B) Edit the field:
<staff_url>/cgi-bin/koha/admin/marc_subfields_structure.pl?op=add_form&tagfield=857&frameworkcode=
C) Check the 'Editor' checkbox for subfields q, u and z (Add these if not there already)
D) Edit the record in question, visit:
<staff_url>/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=76
E) Click 'Settings' dropdown and pick 'Default' framework.
F) Add MARC data that corresponds to the following:
3 instances of 856 as below. 3 instances of 857 as below.

  <datafield tag="856" ind1="4" ind2="2">
    <subfield code="z">Koha community no protocol</subfield>
    <subfield code="u">koha-community.org/</subfield>
  </datafield>
  <datafield tag="856" ind1="4" ind2="2">
    <subfield code="z">Koha community with protocol</subfield>
    <subfield code="u">https://koha-community.org/</subfield>
  </datafield>
  <datafield tag="856" ind1="4" ind2="2">
    <subfield code="z">Koha logo image</subfield>
    <subfield code="q">jpeg</subfield>
    <subfield code="u">https://koha-community.org/files/2013/09/cropped-kohabanner3.jpg</subfield>
  </datafield>
  <datafield tag="857" ind1="4" ind2="2">
    <subfield code="z">Koha community no protocol</subfield>
    <subfield code="u">koha-community.org/</subfield>
  </datafield>
  <datafield tag="857" ind1="4" ind2="2">
    <subfield code="z">Koha community with protocol</subfield>
    <subfield code="u">https://koha-community.org/</subfield>
  </datafield>
  <datafield tag="857" ind1="4" ind2="2">
    <subfield code="z">KohaCon 2024 logo image</subfield>
    <subfield code="q">jpeg</subfield>
    <subfield code="u">https://2024.kohacon.org/wp-content/uploads/2024/01/kohacon24_fr_verticale_vert_noir.png</subfield>
  </datafield>
G) At this point you're ready to start the original test plan from step 4)

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2024-10-04 15:22:25 +00:00 committed by Lucas Gass
parent cb900b2d7b
commit 4b78e0ed3a
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
4 changed files with 87 additions and 71 deletions

View File

@ -960,45 +960,29 @@
</span>
</xsl:if>
<!-- 856 -->
<xsl:if test="marc:datafield[@tag=856]">
<xsl:if test="normalize-space(marc:datafield[@tag=856]/marc:subfield[@code='u'])">
<span class="results_summary online_resources"><span class="label">Online resources: </span>
<ul class="resource_list">
<xsl:for-each select="marc:datafield[@tag=856 and marc:subfield[@code='u']]">
<xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
<li><a>
<xsl:attribute name="href">
<xsl:call-template name="AddMissingProtocol">
<xsl:with-param name="resourceLocation" select="marc:subfield[@code='u']"/>
<xsl:with-param name="indicator1" select="@ind1"/>
<xsl:with-param name="accessMethod" select="marc:subfield[@code='2']"/>
</xsl:call-template>
<xsl:value-of select="normalize-space(marc:subfield[@code='u'])"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="($Show856uAsImage='Details' 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'])">
<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></li>
<span class="results_summary online_resources">
<span class="label">Online resources: </span>
<xsl:call-template name="renderMARCOnlineResourceField">
<xsl:with-param name="MARCOnlineResourceField">856</xsl:with-param>
<xsl:with-param name="Show856uAsImage" select="$Show856uAsImage"></xsl:with-param>
<xsl:with-param name="screen" select="'detail'"></xsl:with-param>
</xsl:call-template>
</span>
</xsl:if>
</xsl:if>
</xsl:for-each>
</ul>
<!-- 857 -->
<xsl:if test="marc:datafield[@tag=857]">
<xsl:if test="normalize-space(marc:datafield[@tag=857]/marc:subfield[@code='u'])">
<span class="results_summary online_resources">
<span class="label">Online archive resources: </span>
<xsl:call-template name="renderMARCOnlineResourceField">
<xsl:with-param name="MARCOnlineResourceField">857</xsl:with-param>
<xsl:with-param name="screen" select="'detail'"></xsl:with-param>
</xsl:call-template>
</span>
</xsl:if>
</xsl:if>

View File

@ -977,47 +977,29 @@
<xsl:with-param name="UseControlNumber" select="$UseControlNumber"/>
</xsl:call-template>
<!-- 856 -->
<xsl:if test="marc:datafield[@tag=856]">
<xsl:if test="normalize-space(marc:datafield[@tag=856]/marc:subfield[@code='u'])">
<span class="results_summary online_resources">
<span class="label">Online resources: </span>
<xsl:for-each select="marc:datafield[@tag=856 and marc:subfield[@code='u']]">
<xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
<a>
<xsl:attribute name="href">
<xsl:call-template name="AddMissingProtocol">
<xsl:with-param name="resourceLocation" select="marc:subfield[@code='u']"/>
<xsl:with-param name="indicator1" select="@ind1"/>
<xsl:with-param name="accessMethod" select="marc:subfield[@code='2']"/>
<xsl:call-template name="renderMARCOnlineResourceField">
<xsl:with-param name="MARCOnlineResourceField">856</xsl:with-param>
<xsl:with-param name="Show856uAsImage" select="$Show856uAsImage"></xsl:with-param>
<xsl:with-param name="screen" select="'results'"></xsl:with-param>
</xsl:call-template>
<xsl:value-of select="normalize-space(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>
</span>
</xsl:if>
</xsl:if>
<!-- 857 -->
<xsl:if test="marc:datafield[@tag=857]">
<xsl:if test="marc:datafield[@tag=857]/marc:subfield[@code='u']">
<span class="results_summary online_resources">
<span class="label">Online archive resources: </span>
<xsl:call-template name="renderMARCOnlineResourceField">
<xsl:with-param name="MARCOnlineResourceField">857</xsl:with-param>
<xsl:with-param name="screen" select="'results'"></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: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:if>

View File

@ -730,6 +730,55 @@
</xsl:if>
</xsl:template>
<xsl:template name="renderMARCOnlineResourceField">
<xsl:param name="MARCOnlineResourceField" />
<xsl:param name="Show856uAsImage" />
<xsl:param name="screen" />
<ul class="resource_list">
<xsl:for-each
select="marc:datafield[@tag=$MARCOnlineResourceField and marc:subfield[@code='u']]">
<xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']" /></xsl:variable>
<li><a>
<xsl:attribute name="href">
<xsl:call-template name="AddMissingProtocol">
<xsl:with-param name="resourceLocation" select="marc:subfield[@code='u']" />
<xsl:with-param name="indicator1" select="@ind1" />
<xsl:with-param name="accessMethod" select="marc:subfield[@code='2']" />
</xsl:call-template>
<xsl:value-of select="normalize-space(marc:subfield[@code='u'])"/>
</xsl:attribute>
<xsl:choose>
<xsl:when
test="(($screen='detail' and $Show856uAsImage='Details' or $Show856uAsImage='Both') or
($screen='results' and $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'])">
<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></li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template name="AddMissingProtocol">
<xsl:param name="resourceLocation"/>
<xsl:param name="indicator1"/>

View File

@ -1214,6 +1214,7 @@
<xsl:with-param name="MARCOnlineResourceField">857</xsl:with-param>
<xsl:with-param name="OPACTrackClicks" select="$OPACTrackClicks"></xsl:with-param>
<xsl:with-param name="OPACURLOpenInNewWindow" select="$OPACURLOpenInNewWindow"></xsl:with-param>
<xsl:with-param name="screen" select="results"></xsl:with-param>
</xsl:call-template>
</ul>
</div>