Bugzilla – Attachment 42742 Details for
Bug 14715
Results per page setting for catalog search in staff client and OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14715: syspref for results per page options
Bug-14715-syspref-for-results-per-page-options.patch (text/plain), 9.58 KB, created by
Martin Stenberg
on 2015-09-21 16:51:24 UTC
(
hide
)
Description:
Bug 14715: syspref for results per page options
Filename:
MIME Type:
Creator:
Martin Stenberg
Created:
2015-09-21 16:51:24 UTC
Size:
9.58 KB
patch
obsolete
>From 844bfdbebff97e5f76b259d0369a400e0e9250d0 Mon Sep 17 00:00:00 2001 >From: Martin Stenberg <martin@xinxidi.net> >Date: Mon, 21 Sep 2015 18:45:52 +0200 >Subject: [PATCH] Bug 14715: syspref for results per page options > >Remove the "all" option. > >Add syspref [OPAC]numSearchResultsPerPage for specifying options for numbers of >results per page including [OPAC]numSearchResults. >--- > catalogue/search.pl | 10 ++++++++++ > .../prog/en/modules/admin/preferences/searching.pref | 10 ++++++++++ > .../intranet-tmpl/prog/en/modules/catalogue/results.tt | 15 +++++++++------ > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 17 +++++++++-------- > opac/opac-search.pl | 8 ++++++++ > 5 files changed, 46 insertions(+), 14 deletions(-) > >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 11703a6..6fd8f00 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -150,6 +150,7 @@ use C4::Members qw(GetMember); > use C4::VirtualShelves; > use URI::Escape; > use POSIX qw(ceil floor); >+use String::Random; > use C4::Branch; # GetBranches > use C4::Search::History; > >@@ -473,6 +474,14 @@ 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 $page = $cgi->param('page') || 1; > my $offset = $results_per_page != 'all' ? ($page-1)*$results_per_page : 0; >@@ -616,6 +625,7 @@ for (my $i=0;$i<@servers;$i++) { > } > $template->param(stopwords_removed => "@$stopwords_removed") if $stopwords_removed; > $template->param(results_per_page => $results_per_page == $hits ? 'all' : $results_per_page); >+ $template->param(results_per_page_options => \@results_per_page_options); > # must define a value for size if not present in DB > # in order to avoid problems generated by the default size value in TT > foreach my $line (@newresults) { >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 8b04d39..0afc333 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 >@@ -148,6 +148,11 @@ Searching: > - pref: numSearchResults > class: integer > - results per page in the staff client. >+ - 'Include options for showing' >+ - pref: numSearchResultsPerPage >+ class: text >+ default: "10,20,40,60,80,100" >+ - results per page. > - > - By default, sort search results in the OPAC by > - pref: OPACdefaultSortField >@@ -190,6 +195,11 @@ Searching: > - pref: OPACnumSearchResults > class: integer > - results per page in the OPAC. >+ - 'Include options for showing' >+ - pref: numSearchResultsPerPage >+ class: text >+ default: "10,20,40,60,80,100" >+ - results per page. > - > - "Show facets for" > - pref: DisplayLibraryFacets >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 735e41a..3d14956 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -306,15 +306,18 @@ var holdForPatron = function () { > </select> > <!-- RESORT END --> > <!-- RESULTS_PER_PAGE START --> >+ [% IF results_per_page_options %] > <label for="results_per_page">Results per page: </label> > <select id="results_per_page" name="results_per_page"> >- <option value="20" [% 'SELECTED' IF results_per_page == '20' %]>20</option> >- <option value="40" [% 'SELECTED' IF results_per_page == '40' %]>40</option> >- <option value="60" [% 'SELECTED' IF results_per_page == '60' %]>60</option> >- <option value="80" [% 'SELECTED' IF results_per_page == '80' %]>80</option> >- <option value="100" [% 'SELECTED' IF results_per_page == '100' %]>100</option> >- <option value="all" [% 'SELECTED' IF results_per_page == 'all' %]>all</option> >+ [% FOREACH res_option IN results_per_page_options %] >+ [% IF results_per_page == res_option %] >+ <option value="[% res_option %]" SELECTED>[% res_option %]</option> >+ [% ELSE %] >+ <option value="[% res_option %]">[% res_option %]</option> >+ [% END %] >+ [% END %] > </select> >+ [% END %] > <!-- RESULTS_PER_PAGE END --> > <input type="submit" value="Go" /> > </form> >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 0d0a7e1..bb0461e 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -145,17 +145,18 @@ > [% UNLESS tag %] > <div class="sort_by pull-right"> > <select id="sort_by" class="resort" name="sort_by"> [% INCLUDE 'resort_form.inc' %] </select> >- >+ [% IF results_per_page_options %] > <label for="results_per_page">Results per page: </label> > <select id="results_per_page" name="results_per_page"> >- <option value="20" [% 'SELECTED' IF results_per_page == '20' %]>20</option> >- <option value="40" [% 'SELECTED' IF results_per_page == '40' %]>40</option> >- <option value="60" [% 'SELECTED' IF results_per_page == '60' %]>60</option> >- <option value="80" [% 'SELECTED' IF results_per_page == '80' %]>80</option> >- <option value="100" [% 'SELECTED' IF results_per_page == '100' %]>100</option> >- <option value="all" [% 'SELECTED' IF results_per_page == 'all' %]>all</option> >+ [% FOREACH res_option IN results_per_page_options %] >+ [% IF results_per_page == res_option %] >+ <option value="[% res_option %]" SELECTED>[% res_option %]</option> >+ [% ELSE %] >+ <option value="[% res_option %]">[% res_option %]</option> >+ [% END %] >+ [% END %] > </select> >- >+ [% END %] > <input type="submit" class="btn btn-small clearfix" id="sortsubmit" value="Go" /> > </div> > [% END %] >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index daa1df2..0f07517 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -481,6 +481,13 @@ 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_options = grep /^\d+$/, >+ map {s/\s+//g;$_;} >+ split /,/, C4::Context->preference('OPACnumSearchResultsPerPage'); >+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 $page = $cgi->param('page') || 1; > my $offset = $results_per_page != 'all' ? ($page-1)*$results_per_page : 0; >@@ -757,6 +764,7 @@ for (my $i=0;$i<@servers;$i++) { > } > $template->param(stopwords_removed => "@$stopwords_removed") if $stopwords_removed; > $template->param(results_per_page => $results_per_page == $hits ? 'all' : $results_per_page); >+ $template->param(results_per_page_options => \@results_per_page_options); > my $hide = C4::Context->preference('OpacHiddenItems'); > $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines > my $branch = ''; >-- >2.5.0
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 14715
:
41949
|
42003
|
42742
|
42743
|
56002
|
56003
|
56004
|
56005
|
56575
|
56576
|
56577
|
56610
|
56611
|
56612
|
57870
|
61721
|
64250
|
67912
|
67913
|
68000
|
68001
|
68305
|
68327
|
75938
|
75939
|
75940
|
75941
|
78230
|
78298
|
78299
|
78300
|
78301
|
78302
|
79796
|
79797
|
79988
|
81203
|
88097
|
88102
|
88103
|
88104
|
88105
|
88106
|
88107
|
88108
|
88109
|
88126
|
88195
|
88831
|
88832
|
88833
|
88834
|
88835
|
88836
|
88837
|
88838
|
88839
|
95038
|
97004
|
98365
|
99607
|
99677
|
99684
|
99685
|
101775
|
101776
|
101777
|
101778