Bugzilla – Attachment 14362 Details for
Bug 7441
Search results showing wrong branch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7441 - search results showing wrong branch? - Followup - Use syspref for XSLT and non-XSLT
Bug-7441---search-results-showing-wrong-branch---F.patch (text/plain), 18.42 KB, created by
Kyle M Hall (khall)
on 2013-01-02 15:08:09 UTC
(
hide
)
Description:
Bug 7441 - search results showing wrong branch? - Followup - Use syspref for XSLT and non-XSLT
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-01-02 15:08:09 UTC
Size:
18.42 KB
patch
obsolete
>From ecf674c5a64b68ea625c5e74f018ebe126eec3b6 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 2 Jan 2013 10:06:11 -0500 >Subject: [PATCH] Bug 7441 - search results showing wrong branch? - Followup - Use syspref for XSLT and non-XSLT > >--- > C4/Search.pm | 16 +++--- > C4/XSLT.pm | 2 +- > Koha/Template/Plugin/Koha.pm | 49 ++++++++++++++++++++ > installer/data/mysql/sysprefs.sql | 2 +- > installer/data/mysql/updatedatabase.pl | 4 +- > .../prog/en/modules/admin/preferences/opac.pref | 3 +- > .../opac-tmpl/prog/en/modules/opac-results.tt | 9 +++- > .../prog/en/xslt/MARC21slim2OPACResults.xsl | 10 ++-- > .../prog/en/xslt/UNIMARCslim2OPACResults.xsl | 10 ++-- > opac/opac-search.pl | 3 +- > 10 files changed, 80 insertions(+), 28 deletions(-) > create mode 100644 Koha/Template/Plugin/Koha.pm > >diff --git a/C4/Search.pm b/C4/Search.pm >index 50f7d2b..faa90cb 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1819,8 +1819,8 @@ sub searchResults { > $item->{'branchname'} = $branches{$item->{$otherbranch}}; > } > >- my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber}; >-# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item >+ my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber}; >+ # For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item > my $userenv = C4::Context->userenv; > if ( $item->{onloan} && !(C4::Members::GetHideLostItemsPreference($userenv->{'number'}) && $item->{itemlost}) ) { > $onloan_count++; >@@ -1930,12 +1930,12 @@ sub searchResults { > else { > $can_place_holds = 1; > $available_count++; >- $available_items->{$prefix}->{count}++ if $item->{$hbranch}; >- foreach (qw(branchname itemcallnumber description)) { >- $available_items->{$prefix}->{$_} = $item->{$_}; >- } >- $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} }; >- $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); >+ $available_items->{$prefix}->{count}++ if $item->{$hbranch}; >+ foreach (qw(branchname itemcallnumber description homebranch holdingbranch)) { >+ $available_items->{$prefix}->{$_} = $item->{$_}; >+ } >+ $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} }; >+ $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); > } > } > } # notforloan, item level and biblioitem level >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index 7fab3f8..d3089e0 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -188,7 +188,7 @@ sub XSLTParse4Display { > UseAuthoritiesForTracings TraceSubjectSubdivisions > Display856uAsImage OPACDisplay856uAsImage > UseControlNumber IntranetBiblioDefaultView BiblioDefaultView >- singleBranchMode OPACResultsBranchXSLT >+ singleBranchMode OPACResultsBranch > AlternateHoldingsField AlternateHoldingsSeparator / ) > { > my $sp = C4::Context->preference( $syspref ); >diff --git a/Koha/Template/Plugin/Koha.pm b/Koha/Template/Plugin/Koha.pm >new file mode 100644 >index 0000000..09bd97b >--- /dev/null >+++ b/Koha/Template/Plugin/Koha.pm >@@ -0,0 +1,49 @@ >+package Koha::Template::Plugin::Koha; >+ >+# Copyright ByWater Solutions 2013 >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Template::Plugin; >+use base qw( Template::Plugin ); >+ >+use C4::Koha; >+use C4::Context; >+ >+=pod >+ >+This plugin contains various Koha replated Template Toolkit functions >+to help streamline Koha and to move logic from the Perl code into the >+Templates when it makes sense to do so. >+ >+To use, first, include the line '[% USE Koha %]' at the top >+of the template to enable the plugin. >+ >+For example: [% IF Koha.Preference( 'MyPreference ) == 'SettingA' %] >+removes the necessity of setting a template variable in Perl code for >+each and every system preference, even if no evaluation of the setting >+is necessary. >+ >+=cut >+ >+sub Preference { >+ my ( $self, $pref ) = @_; >+ return C4::Context->preference( $pref ); >+} >+ >+1; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 85be65e..db2d1ce 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -406,4 +406,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('NotesBlacklist','','List of notes fields that should not appear in the title notes/description separator of details',NULL,'free'); > INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('SCOUserCSS', '', NULL, 'Add CSS to be included in the SCO module in an embedded <style> tag.', 'free'); > INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('SCOUserJS', '', NULL, 'Define custom javascript for inclusion in the SCO module', 'free'); >-INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('OPACResultsBranchXSLT', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice'); >+INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('OPACResultsBranch', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 25fb193..4f12fae 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -6341,8 +6341,8 @@ if ( CheckVersion($DBversion) ) { > > $DBversion = "3.11.00.XXX"; > if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >- $dbh->do("INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('OPACResultsBranchXSLT', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice')"); >- print "Upgrade to $DBversion done (Add syspref OPACResultsBranchXSLT)\n"; >+ $dbh->do("INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('OPACResultsBranch', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice')"); >+ print "Upgrade to $DBversion done (Add syspref OPACResultsBranch)\n"; > SetVersion($DBversion); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index cf4c655..85f1065 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -74,11 +74,10 @@ OPAC: > - icons for itemtype and authorized values. > - > - On search result pages displayed with XSLT stylesheets on the OPAC, show the item's >- - pref: OPACResultsBranchXSLT >+ - pref: OPACResultsBranch > choices: > holdingbranch: "holding branch" > homebranch: "home branch" >- - icons for itemtype and authorized values. > - > - pref: COinSinOPACResults > choices: >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >index 2e3ad22..ed259bd 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >@@ -1,3 +1,5 @@ >+[% USE Koha %] >+[% USE KohaBranchName %] > [% SET TagsShowEnabled = ( TagsEnabled && TagsShowOnList ) %] > [% SET TagsInputEnabled = ( opacuserlogin && TagsEnabled && TagsInputOnList ) %] > >@@ -496,9 +498,12 @@ $(document).ready(function(){ > [% IF ( singleBranchMode ) %] > [% available_items_loo.location %] > [% ELSE %] >- [% available_items_loo.branchname %] >+ [% IF Koha.Preference('OPACResultsBranch') == 'homebranch' %] >+ [% available_items_loo.homebranch | $KohaBranchName %] >+ [% ELSE %] >+ [% available_items_loo.holdingbranch | $KohaBranchName %] >+ [% END %] > [% END %] >- > [% IF ( OPACItemsResultsDisplay ) %] > [% UNLESS ( singleBranchMode ) %][% available_items_loo.location %][% END %] > [% IF ( available_items_loo.itemcallnumber ) %][<a href="/cgi-bin/koha/opac-search.pl?q=callnum:[% available_items_loo.itemcallnumber |url %]">[% available_items_loo.itemcallnumber %]</a>][% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl >index 8d8c036..294463f 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl >+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl >@@ -20,7 +20,7 @@ > <!-- Option: Display Alternate Graphic Representation (MARC 880) --> > <xsl:variable name="display880" select="boolean(marc:datafield[@tag=880])"/> > >- <xsl:variable name="OPACResultsBranchXSLT" select="marc:sysprefs/marc:syspref[@name='OPACResultsBranchXSLT']"/> >+ <xsl:variable name="OPACResultsBranch" select="marc:sysprefs/marc:syspref[@name='OPACResultsBranch']"/> > <xsl:variable name="hidelostitems" select="marc:sysprefs/marc:syspref[@name='hidelostitems']"/> > <xsl:variable name="DisplayOPACiconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayOPACiconsXSLT']"/> > <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/> >@@ -1040,7 +1040,7 @@ > </xsl:when> > <xsl:otherwise> > <xsl:choose> >- <xsl:when test="$OPACResultsBranchXSLT='homebranch'"> >+ <xsl:when test="$OPACResultsBranch='homebranch'"> > <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]"> > <xsl:value-of select="items:homebranch"/> > <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >@@ -1050,7 +1050,7 @@ > <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose> > </xsl:for-each> > </xsl:when> >- <xsl:when test="$OPACResultsBranchXSLT='holdingbranch'"> >+ <xsl:when test="$OPACResultsBranch='holdingbranch'"> > <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch-holding', concat(items:status, ' ', items:holdingbranch))[1])]"> > <xsl:value-of select="items:holdingbranch"/> > <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >@@ -1081,7 +1081,7 @@ > <xsl:variable name="reference_items" select="key('item-by-status', 'reference')"/> > > <xsl:choose> >- <xsl:when test="$OPACResultsBranchXSLT='homebranch'"> >+ <xsl:when test="$OPACResultsBranch='homebranch'"> > <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]"> > <xsl:value-of select="items:homebranch"/> > <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >@@ -1091,7 +1091,7 @@ > <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose> > </xsl:for-each> > </xsl:when> >- <xsl:when test="$OPACResultsBranchXSLT='holdingbranch'"> >+ <xsl:when test="$OPACResultsBranch='holdingbranch'"> > <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch-holding', concat(items:status, ' ', items:holdingbranch))[1])]"> > <xsl:value-of select="items:holdingbranch"/> > <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl >index 77315e1..89240fe 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl >+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl >@@ -28,7 +28,7 @@ > <xsl:variable name="isbn" > select="marc:datafield[@tag=010]/marc:subfield[@code='a']"/> > >- <xsl:variable name="OPACResultsBranchXSLT" select="marc:sysprefs/marc:syspref[@name='OPACResultsBranchXSLT']"/> >+ <xsl:variable name="OPACResultsBranch" select="marc:sysprefs/marc:syspref[@name='OPACResultsBranch']"/> > <xsl:variable name="hidelostitems" select="marc:sysprefs/marc:syspref[@name='hidelostitems']"/> > <xsl:variable name="singleBranchMode" select="marc:sysprefs/marc:syspref[@name='singleBranchMode']"/> > >@@ -147,7 +147,7 @@ > </xsl:when> > <xsl:otherwise> > <xsl:choose> >- <xsl:when test="$OPACResultsBranchXSLT='homebranch'"> >+ <xsl:when test="$OPACResultsBranch='homebranch'"> > <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]"> > <xsl:value-of select="items:homebranch"/> > <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >@@ -157,7 +157,7 @@ > <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose> > </xsl:for-each> > </xsl:when> >- <xsl:when test="$OPACResultsBranchXSLT='holdingbranch'"> >+ <xsl:when test="$OPACResultsBranch='holdingbranch'"> > <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch-holding', concat(items:status, ' ', items:holdingbranch))[1])]"> > <xsl:value-of select="items:holdingbranch"/> > <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >@@ -180,7 +180,7 @@ > <xsl:variable name="reference_items" select="key('item-by-status', 'reference')"/> > > <xsl:choose> >- <xsl:when test="$OPACResultsBranchXSLT='homebranch'"> >+ <xsl:when test="$OPACResultsBranch='homebranch'"> > <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]"> > <xsl:value-of select="items:homebranch"/> > <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >@@ -190,7 +190,7 @@ > <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose> > </xsl:for-each> > </xsl:when> >- <xsl:when test="$OPACResultsBranchXSLT='holdingbranch'"> >+ <xsl:when test="$OPACResultsBranch='holdingbranch'"> > <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch-holding', concat(items:status, ' ', items:holdingbranch))[1])]"> > <xsl:value-of select="items:holdingbranch"/> > <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if> >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 9708176..da10686 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -833,6 +833,5 @@ if (C4::Context->preference('GoogleIndicTransliteration')) { > } > > $template->{VARS}->{DidYouMean} = C4::Context->preference('OPACdidyoumean') =~ m/enable/; >- >- $template->param( borrowernumber => $borrowernumber); >+$template->param( borrowernumber => $borrowernumber); > output_with_http_headers $cgi, $cookie, $template->output, $content_type; >-- >1.7.2.5
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 7441
:
8656
|
8657
|
9700
|
9701
|
12550
|
12551
|
12552
|
12553
|
13856
|
13888
|
14229
|
14361
|
14362
|
14977
|
14978
|
14979
|
17901
|
17902
|
17903
|
17968
|
18151
|
18152
|
18153
|
18154
|
18857
|
18858
|
18859
|
18942
|
19089
|
19090
|
19091
|
19470
|
19471
|
19472
|
19473
|
19474
|
19475
|
51963
|
52746
|
52747
|
52810
|
52811
|
54058
|
54101
|
54102
|
54250