Bugzilla – Attachment 12254 Details for
Bug 7401
Show shelving location facet instead of branch facet when only 1 branch configured
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 7401 - Shelving Location facet
SIGNED-OFF-Bug-7401---Shelving-Location-facet.patch (text/plain), 8.96 KB, created by
Owen Leonard
on 2012-09-14 20:04:04 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 7401 - Shelving Location facet
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2012-09-14 20:04:04 UTC
Size:
8.96 KB
patch
obsolete
>From e216043dfe8afd1b404c2f9ced9c62735c2bda63 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 16 Feb 2012 12:09:44 -0500 >Subject: [PATCH] [SIGNED-OFF] Bug 7401 - Shelving Location facet >Content-Type: text/plain; charset="utf-8" > >This patch enables the shelving location facet as an >alternative to the branches fact in two situations: >A) SingleBranchMode is enabled >B) There is only one branch in the branches table > >Test Plan: >1) Catalog multiple items with different shelving locations. >2) Test enable by enabling SingleBranchMode >3) Test enable by deleting all but one branch > >Based on initial patch by Ian Walls. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Tested cases 2) and 3) successfully in OPAC and staff client >--- > C4/Branch.pm | 10 ++++ > C4/Koha.pm | 50 +++++++++++++------- > C4/Search.pm | 11 +++-- > .../intranet-tmpl/prog/en/includes/facets.inc | 1 + > .../opac-tmpl/prog/en/includes/opac-facets.inc | 1 + > opac/opac-search.pl | 2 +- > 6 files changed, 54 insertions(+), 21 deletions(-) > >diff --git a/C4/Branch.pm b/C4/Branch.pm >index 1959a3d..dcd4ef7 100644 >--- a/C4/Branch.pm >+++ b/C4/Branch.pm >@@ -46,6 +46,7 @@ BEGIN { > &DelBranchCategory > &CheckCategoryUnique > &mybranch >+ &GetBranchesCount > ); > @EXPORT_OK = qw( &onlymine &mybranch get_branch_code_from_name ); > } >@@ -580,6 +581,15 @@ sub get_branch_code_from_name { > return $sth->fetchrow_array; > } > >+sub GetBranchesCount { >+ my $dbh = C4::Context->dbh(); >+ my $query = "SELECT COUNT(*) AS branches_count FROM branches"; >+ my $sth = $dbh->prepare( $query ); >+ $sth->execute(); >+ my $row = $sth->fetchrow_hashref(); >+ return $row->{'branches_count'}; >+} >+ > 1; > __END__ > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index c23a3b0..4d98fd5 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -24,7 +24,7 @@ use strict; > #use warnings; FIXME - Bug 2505 > > use C4::Context; >- >+use C4::Branch qw(GetBranchesCount); > use Memoize; > use DateTime; > use DateTime::Format::MySQL; >@@ -714,14 +714,23 @@ sub getFacets { > tags => [ qw/ 225a / ], > sep => ', ', > }, >- ]; >- my $library_facet = { >- idx => 'branch', >- label => 'Libraries', >- tags => [ qw/ 995b / ], >- expanded => '1', >- }; >- push @$facets, $library_facet unless C4::Context->preference("singleBranchMode"); >+ ]; >+ >+ my $library_facet; >+ unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) { >+ $library_facet = { >+ idx => 'branch', >+ label => 'Libraries', >+ tags => [ qw/ 995b / ], >+ }; >+ } else { >+ $library_facet = { >+ idx => 'location', >+ label => 'Location', >+ tags => [ qw/ 995c / ], >+ }; >+ } >+ push( @$facets, $library_facet ); > } > else { > $facets = [ >@@ -768,15 +777,22 @@ sub getFacets { > sep => ', ', > }, > ]; >+ > my $library_facet; >- $library_facet = { >- idx => 'branch', >- label => 'Libraries', >- tags => [ qw/ 952b / ], >- sep => ', ', >- expanded => '1', >- }; >- push @$facets, $library_facet unless C4::Context->preference("singleBranchMode"); >+ unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) { >+ $library_facet = { >+ idx => 'branch', >+ label => 'Libraries', >+ tags => [ qw / 952b / ], >+ }; >+ } else { >+ $library_facet = { >+ idx => 'location', >+ label => 'Location', >+ tags => [ qw / 952c / ], >+ }; >+ } >+ push( @$facets, $library_facet ); > } > return $facets; > } >diff --git a/C4/Search.pm b/C4/Search.pm >index 91bfbb0..0e09511 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -301,8 +301,8 @@ See verbse embedded documentation. > sub getRecords { > my ( > $koha_query, $simple_query, $sort_by_ref, $servers_ref, >- $results_per_page, $offset, $expanded_facet, $branches,$itemtypes, >- $query_type, $scan >+ $results_per_page, $offset, $expanded_facet, $branches, >+ $itemtypes, $query_type, $scan, $opac > ) = @_; > > my @servers = @$servers_ref; >@@ -568,6 +568,11 @@ sub getRecords { > } > } > >+ # also, if it's a location code, use the name instead of the code >+ if ( $link_value =~ /location/ ) { >+ $facet_label_value = GetKohaAuthorisedValueLib('LOC', $one_facet, $opac); >+ } >+ > # but we're down with the whole label being in the link's title. > push @this_facets_array, { > facet_count => $facets_counter->{$link_value}->{$one_facet}, >@@ -575,7 +580,7 @@ sub getRecords { > facet_title_value => $one_facet, > facet_link_value => $facet_link_value, > type_link_value => $link_value, >- }; >+ } if ( $facet_label_value ); > } > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >index 5cf6a7f..1731bed 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >@@ -17,6 +17,7 @@ > [% IF ( facets_loo.type_label_Series ) %]Series[% END %] > [% IF ( facets_loo.type_label_ItemTypes ) %]Item types[% END %] > [% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %] >+[% IF ( facets_loo.type_label_Location ) %]Locations[% END %] > <ul> > [% FOREACH facet IN facets_loo.facets %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by %][% END %]&limit=[% facet.type_link_value %]:[% facet.facet_link_value %]" title="[% facet.facet_title_value %]">[% facet.facet_label_value %]</a> [% IF ( displayFacetCount ) %]([% facet.facet_count %])[% END %]</li>[% END %][% IF ( facets_loo.expandable ) %] > <li class="showmore"><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by %][% END %][% IF ( offset ) %]&offset=[% offset %][% END %]&expand=[% facets_loo.expand %]#[% facets_loo.type_id %]">Show more</a></li> >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc b/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc >index d9e4577..082f846 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc >@@ -18,6 +18,7 @@ > [% UNLESS ( singleBranchMode ) %] > [% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %] > [% END %] >+[% IF ( facets_loo.type_label_Location ) %]Locations[% END %] > <ul> > [% FOREACH facet IN facets_loo.facets %]<li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by %][% END %]&limit=[% facet.type_link_value %]:[% facet.facet_link_value %]" title="[% facet.facet_title_value |html %]">[% facet.facet_label_value %]</a> [% IF ( displayFacetCount ) %]([% facet.facet_count %])[% END %]</li>[% END %][% IF ( facets_loo.expandable ) %] > <li class="showmore"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by %][% END %][% IF ( offset ) %]&offset=[% offset %][% END %]&expand=[% facets_loo.expand %]#[% facets_loo.type_id %]">Show more</a></li> >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 216de2f..95aa510 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -499,7 +499,7 @@ elsif (C4::Context->preference('NoZebra')) { > $pasarParams .= '&simple_query=' . $simple_query; > $pasarParams .= '&query_type=' . $query_type if ($query_type); > eval { >- ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan); >+ ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan,1); > }; > } > # This sorts the facets into alphabetical order >-- >1.7.9.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 7401
:
7040
|
7700
|
7741
|
8188
|
8189
|
10154
|
10210
|
10756
|
10817
|
10877
|
12241
|
12253
| 12254