Browse Source

Bug 15851: (follow-up) Only display the analytics link when required (staff)

This patch replicates the introduced behaviour, for the admin interface.
To test, follow the test plan from the OPAC, but on the intranet.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Tomás Cohen Arazi 4 years ago
committed by Jonathan Druart
parent
commit
8da73fe428
  1. 29
      catalogue/detail.pl
  2. 42
      koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl

29
catalogue/detail.pl

@ -49,6 +49,7 @@ use Koha::ItemTypes;
use Koha::Patrons;
use Koha::Virtualshelves;
use Koha::Plugins;
use Koha::SearchEngine::Search;
my $query = CGI->new();
@ -143,12 +144,32 @@ my $lang = $xslfile ? C4::Languages::getlanguage() : undef;
my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
if ( $xslfile ) {
my $searcher = Koha::SearchEngine::Search->new(
{ index => $Koha::SearchEngine::BIBLIOS_INDEX }
);
my $cleaned_title = $biblio->title;
$cleaned_title =~ tr|/||;
my $query =
( C4::Context->preference('UseControlNumber') and $record->field('001') )
? 'rcn:'. $record->field('001')->data . ' and (bib-level:a or bib-level:b)'
: "Host-item:$cleaned_title";
my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 );
warn "Warning from simple_search_compat: $err"
if $err;
my $variables = {
show_analytics_link => $count > 0 ? 1 : 0
};
$template->param(
XSLTDetailsDisplay => '1',
XSLTBloc => XSLTParse4Display(
$biblionumber, $record, "XSLTDetailsDisplay",
1, undef, $sysxml, $xslfile, $lang
)
XSLTBloc => XSLTParse4Display(
$biblionumber, $record, "XSLTDetailsDisplay", 1,
undef, $sysxml, $xslfile, $lang,
$variables
)
);
}

42
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl

@ -320,21 +320,37 @@
</span>
</xsl:if>
<!-- Analytics -->
<xsl:if test="$leader7='s'">
<span class="results_summary analytics"><span class="label">Analytics: </span>
<a>
<!-- Analytics information -->
<xsl:variable name="leader7_class">
<xsl:choose>
<xsl:when test="$UseControlNumber = '1' and marc:controlfield[@tag=001]">
<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:otherwise>
<!--xsl:when test="$leader7='a'">analytic_mcp</xsl:when-->
<!--xsl:when test="$leader7='b'">analytic_scp</xsl:when-->
<xsl:when test="$leader7='c'">analytic_collection</xsl:when>
<xsl:when test="$leader7='d'">analytic_subunit</xsl:when>
<xsl:when test="$leader7='i'">analytic_ires</xsl:when>
<xsl:when test="$leader7='m'">analytic_monograph</xsl:when>
<xsl:when test="$leader7='s'">analytic_serial</xsl:when>
<xsl:otherwise>analytic_undefined</xsl:otherwise>
</xsl:choose>
<xsl:text>Show analytics</xsl:text>
</a>
</span>
</xsl:variable>
<xsl:variable name="show_analytics_link" select="marc:variables/marc:variable[@name='show_analytics_link']" />
<xsl:if test="$show_analytics_link='1'">
<xsl:element name="span">
<xsl:attribute name="class">results_summary analytics <xsl:value-of select="$leader7_class"/></xsl:attribute>
<span class="label">Analytics: </span>
<a>
<xsl:choose>
<xsl:when test="$UseControlNumber = '1' and marc:controlfield[@tag=001]">
<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:otherwise>
</xsl:choose>
<xsl:text>Show analytics</xsl:text>
</a>
</xsl:element>
</xsl:if>
<!-- Volumes of sets and traced series -->

Loading…
Cancel
Save