From 665d13d46d8f5348f8cdeb08551f68b039e4dcbb Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 11 Jun 2018 02:47:52 +0000 Subject: [PATCH] Bug 14715: [FOLLOW-UP] Rebase and fix up I noticed that the two sysprefs initially created with this patch weren't really being used, so I removed them. Instead I've added two new sysprefs: numSearchResultsDropdown OPACnumSearchResultsDropdown that control whether the dropdown shows or not. Otherwise the defaults in numSearchResults and OPACnumSearchResults are used to decide number of search results per page. When testing: Run updatedatabase.pl Test with values in numSearchResults and OPACnumSearchResults. Use original test plan in Comment 12 but test with the dropdown sysprefs off and on. Sponsored-by: Region Halland Signed-off-by: Cab Vinton --- catalogue/search.pl | 13 ++++--------- .../atomicupdate/bug_14715-searchresults_syspref.sql | 2 -- .../bug_14715_-_results_per_page_dropdown_sysprefs.sql | 3 +++ .../prog/en/modules/admin/preferences/searching.pref | 16 ++++++++++++++++ .../intranet-tmpl/prog/en/modules/catalogue/results.tt | 4 +++- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt | 5 +++-- opac/opac-search.pl | 7 +++++-- 7 files changed, 34 insertions(+), 16 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_14715-searchresults_syspref.sql create mode 100644 installer/data/mysql/atomicupdate/bug_14715_-_results_per_page_dropdown_sysprefs.sql diff --git a/catalogue/search.pl b/catalogue/search.pl index 7d7c7dbb94..dfc3eb9c7b 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -148,7 +148,6 @@ use C4::Koha; use URI::Escape; use POSIX qw(ceil floor); use C4::Search::History; -use String::Random; use Koha::ItemTypes; use Koha::Library::Groups; use Koha::Patrons; @@ -445,14 +444,10 @@ for (my $ii = 0; $ii < @operands; ++$ii) # Params that can only have one value my $scan = $params->{'scan'}; my $count = C4::Context->preference('numSearchResults') || 20; -my @results_per_page_options = grep /^\d+$/, - map {s/\s+//g;$_;} - split /,/, C4::Context->preference('numSearchResultsPerPage'); -push(@results_per_page_options, $count); -@results_per_page_options = do { my %seen; grep { !$seen{$_}++ } @results_per_page_options }; -@results_per_page_options = sort {$a <=> $b} @results_per_page_options; - -my $results_per_page = $params->{'results_per_page'} || $cgi->cookie("results_per_page") || $count; +my $results_per_page = $count; +if ( C4::Context->preference('numSearchResultsDropdown') ){ + $results_per_page = $params->{'results_per_page'} || $cgi->cookie("results_per_page"); +} my $page = $cgi->param('page') || 1; my $offset = $params->{'offset'} || 0; $offset = 0 if $offset < 0; diff --git a/installer/data/mysql/atomicupdate/bug_14715-searchresults_syspref.sql b/installer/data/mysql/atomicupdate/bug_14715-searchresults_syspref.sql deleted file mode 100644 index 4cc263a42b..0000000000 --- a/installer/data/mysql/atomicupdate/bug_14715-searchresults_syspref.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES ('OPACnumSearchResultsPerPage', '10,20,40,60,80,100', NULL, 'Option list of number of results per page to show in OPAC search results','YesNo'); -INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES ('numSearchResultsPerPage', '10,20,40,60,80,100', NULL, 'Option list of number of results per page to show in staff client search results','YesNo'); diff --git a/installer/data/mysql/atomicupdate/bug_14715_-_results_per_page_dropdown_sysprefs.sql b/installer/data/mysql/atomicupdate/bug_14715_-_results_per_page_dropdown_sysprefs.sql new file mode 100644 index 0000000000..ef97362647 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_14715_-_results_per_page_dropdown_sysprefs.sql @@ -0,0 +1,3 @@ +INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES +('OPACnumSearchResultsDropdown', 0, NULL, 'Option list of number of results per page to show in OPAC search results','YesNo'), +('numSearchResultsDropdown', 0, NULL, 'Option list of number of results per page to show in staff client search results','YesNo'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index ad28e82ce9..e9a3934b10 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -132,6 +132,22 @@ Searching: - 'the operator "phr" in the callnumber and standard number staff client searches' Results Display: - + - pref: numSearchResultsDropdown + type: boolean + default: no + choices: + yes: Show + no: "Don't show" + - results per page dropdown on staff client search results. + - + - pref: OPACnumSearchResultsDropdown + type: boolean + default: no + choices: + yes: Show + no: "Don't show" + - results per page dropdown on OPAC search results. + - - By default, sort search results in the staff client by - pref: defaultSortField default: relevance diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index 0a6e10f4a8..64a7bd4094 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -14,7 +14,6 @@ [% ELSE %] [% SET DetailPage="detail.pl" %] [% END %] -<<<<<<< HEAD [% INCLUDE 'doc-head-open.inc' %] Koha › Catalog › [% IF ( searchdesc ) %]Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %] with limit(s): '[% limit_desc | html %]'[% END %][% ELSE %]You did not specify any search criteria[% END %] [% INCLUDE 'doc-head-close.inc' %] @@ -76,14 +75,17 @@ + [% IF Koha.Preference('numSearchResultsDropdown') %] + [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 97ee9571e4..92264ca769 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -147,16 +147,17 @@ [% UNLESS tag %]
- + [% IF Koha.Preference('OPACnumSearchResultsDropdown') %] - + [% END %]
[% END %] diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 161c9cee89..c95e774c10 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -519,7 +519,10 @@ if ($params->{'limit-yr'}) { my $scan = $params->{'scan'}; my $count = C4::Context->preference('OPACnumSearchResults') || 20; my $countRSS = C4::Context->preference('numSearchRSSResults') || 50; -my $results_per_page = $params->{'results_per_page'} || $cgi->cookie("results_per_page") || $count; +my $results_per_page = $count; +if ( C4::Context->preference('OPACnumSearchResultsDropdown') ){ + $results_per_page = $params->{'results_per_page'} || $cgi->cookie("results_per_page"); +} my $page = $cgi->param('page') || 1; my $offset = $params->{'offset'} || 0; $offset = 0 if $offset < 0; @@ -596,7 +599,7 @@ if ($tag) { # FIXME: No facets for tags search. } elsif ($build_grouped_results) { eval { - ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$query_type,$scan); + ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$query_type,$scan); }; } else { $pasarParams .= '&query=' . uri_escape_utf8($query); -- 2.11.0