Bugzilla – Attachment 7040 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]
Proposed Patch
0001-ENH-7401-Shelving-Location-facet-instead-of-Librarie.patch (text/plain), 9.01 KB, created by
Ian Walls
on 2012-01-04 17:23:25 UTC
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Ian Walls
Created:
2012-01-04 17:23:25 UTC
Size:
9.01 KB
patch
obsolete
>From 5d871eebe25c9c120a42c914fdc4df989c9e191e Mon Sep 17 00:00:00 2001 >From: Ian Walls <ian.walls@bywatersolutions.com> >Date: Wed, 4 Jan 2012 12:15:02 -0500 >Subject: [PATCH] ENH 7401: Shelving Location facet instead of Libraries facet when 1 branch only > >If only a single branch has been configured in the system, it doesn't make sense to show >a Libraries facet. A facet of shelving locations within the library would be more helpful >to guide users to where to get resources > >This patch adds Location facets to both the OPAC and staff side only 1 branch is configured. >To handle the OPAC v. staff side labels for location codes, a parameter has been added to getRecord >in C4::Search. the optional $opac parameter is the last to be passed; 1 indicates OPAC, 0 or undef >for staff side. > >To test: >1. On a system with a single branch, define a shelving location with different OPAC and staff client text >2. perform a search that will retrive some items with that shelving location > a. on the OPAC side, you should get OPAC text in the facets > b. on the staff side, you should get staff text >3. Add a new branch to the system >4. Repeat the search. Should get the Libraries facet instead of the Locations facet >--- > C4/Koha.pm | 55 ++++++++++++++------ > C4/Search.pm | 11 +++- > .../intranet-tmpl/prog/en/includes/facets.inc | 1 + > .../opac-tmpl/prog/en/includes/opac-facets.inc | 2 + > opac/opac-search.pl | 2 +- > 5 files changed, 51 insertions(+), 20 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 789f674..acd0450 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -24,6 +24,7 @@ use strict; > #use warnings; FIXME - Bug 2505 > use C4::Context; > use C4::Output; >+use C4::Branch qw(GetBranchesLoop); > use URI::Split qw(uri_split); > use Memoize; > use Business::ISBN; >@@ -677,6 +678,7 @@ sub getallthemes { > > sub getFacets { > my $facets; >+ my @branchloop = GetBranchesLoop(); > if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { > $facets = [ > { >@@ -714,14 +716,24 @@ sub getFacets { > > my $library_facet; > >- $library_facet = { >- link_value => 'branch', >- label_value => 'Libraries', >- tags => [ '995', ], >- subfield => 'b', >- expanded => '1', >- }; >- push @$facets, $library_facet unless C4::Context->preference("singleBranchMode"); >+ if (@branchloop > 1) { >+ $library_facet = { >+ link_value => 'branch', >+ label_value => 'Libraries', >+ tags => [ '995', ], >+ subfield => 'b', >+ expanded => '1', >+ }; >+ } else { >+ $library_facet = { >+ link_value => 'location', >+ label_value => 'Location', >+ tags => [ '995', ], >+ subfield => 'c', >+ expanded => '1', >+ }; >+ } >+ push @$facets, $library_facet; > } > else { > $facets = [ >@@ -764,14 +776,25 @@ sub getFacets { > }, > ]; > my $library_facet; >- $library_facet = { >- link_value => 'branch', >- label_value => 'Libraries', >- tags => [ '952', ], >- subfield => 'b', >- expanded => '1', >- }; >- push @$facets, $library_facet unless C4::Context->preference("singleBranchMode"); >+ if (@branchloop > 1) { >+ $library_facet = { >+ link_value => 'branch', >+ label_value => 'Libraries', >+ tags => [ '952', ], >+ subfield => 'b', >+ expanded => '1', >+ }; >+ } else { >+ $library_facet = { >+ link_value => 'location', >+ label_value => 'Location', >+ tags => [ '952', ], >+ subfield => 'c', >+ expanded => '1', >+ }; >+ } >+ >+ push @$facets, $library_facet; > } > return $facets; > } >diff --git a/C4/Search.pm b/C4/Search.pm >index 4a8de5c..e9b9d2c 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -287,13 +287,13 @@ sub SimpleSearch { > > $koha_query, $simple_query, $sort_by_ref, $servers_ref, > $results_per_page, $offset, $expanded_facet, $branches, >- $query_type, $scan >+ $query_type, $scan, $opac > ); > > The all singing, all dancing, multi-server, asynchronous, scanning, > searching, record nabbing, facet-building > >-See verbse embedded documentation. >+See verbose embedded documentation. > > =cut > >@@ -301,7 +301,7 @@ sub getRecords { > my ( > $koha_query, $simple_query, $sort_by_ref, $servers_ref, > $results_per_page, $offset, $expanded_facet, $branches, >- $query_type, $scan >+ $query_type, $scan, $opac > ) = @_; > > my @servers = @$servers_ref; >@@ -562,6 +562,11 @@ sub getRecords { > } > } > >+ # also, if it's a location code, use the name instead of 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}, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >index a72b586..bacbfaf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc >@@ -16,6 +16,7 @@ > [% IF ( facets_loo.type_label_Places ) %]Places[% END %] > [% IF ( facets_loo.type_label_Series ) %]Series[% 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 ccb37b0..3c9dd6d 100755 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc >@@ -17,6 +17,8 @@ > [% 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 aba23a8..3b6ae4f 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -454,7 +454,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,$query_type,$scan); >+ ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan,1); > }; > } > # This sorts the facets into alphabetical order >-- >1.7.4.1 >
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