From 20460192a60e8ccc2d3f3a8e0b257859b2fec27a Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 21 Oct 2008 20:28:49 +0000 Subject: [PATCH] Search - Paginate results (#713) --- docs/changelog/7.x.x.txt | 3 ++- docs/upgrades/upgrade_7.6.1-7.6.2.pl | 13 +++++++++++-- lib/WebGUI/Asset/Wobject/Search.pm | 19 ++++++++++++++----- lib/WebGUI/i18n/English/Asset_Search.pm | 12 ++++++++++++ 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 338e7a733..a5a81765c 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -7,7 +7,8 @@ - Made Classname from control a subclass of ReadOnly. - Added query keys to WebGUI::Crud. - EMS Saved Address (#8864) - - Inclusion of UsersOnline macro into the core (#766) + - rfe: Inclusion of UsersOnline macro into the core (#766) + - rfe: Search - Paginate results (#713) - WebGUI::Crud can now automatically resolve differences between its definition and the table schema. - Fixed a limit bug in the asset discovery service. diff --git a/docs/upgrades/upgrade_7.6.1-7.6.2.pl b/docs/upgrades/upgrade_7.6.1-7.6.2.pl index b35e7bf1e..03b71e7b8 100644 --- a/docs/upgrades/upgrade_7.6.1-7.6.2.pl +++ b/docs/upgrades/upgrade_7.6.1-7.6.2.pl @@ -32,14 +32,23 @@ my $session = start(); # this line required repairManageWorkflows($session); addPreTextToThingyFields($session); updateAddressBook($session); +changeDefaultPaginationInSearch($session); addUsersOnlineMacro($session); finish($session); # this line required +#---------------------------------------------------------------------------- +sub changeDefaultPaginationInSearch { + my $session = shift; + print "\tAllow content managers to change the default pagination in the search asset... " unless $quiet; + $session->db->write("ALTER TABLE `search` ADD COLUMN `paginateAfter` INTEGER NOT NULL DEFAULT 25"); + print "DONE!\n" unless $quiet; +} + #---------------------------------------------------------------------------- sub addUsersOnlineMacro { my $session = shift; - print "\tMaking the UsersOnline macro available." unless $quiet; + print "\tMaking the UsersOnline macro available... " unless $quiet; $session->config->addToHash("macros","UsersOnline","UsersOnline"); print "DONE!\n" unless $quiet; } @@ -47,7 +56,7 @@ sub addUsersOnlineMacro { #---------------------------------------------------------------------------- sub updateAddressBook { my $session = shift; - print "\tAdding organization and email to address book." unless $quiet; + print "\tAdding organization and email to address book... " unless $quiet; my $db = $session->db; $db->write("alter table address add column organization char(255)"); $db->write("alter table address add column email char(255)"); diff --git a/lib/WebGUI/Asset/Wobject/Search.pm b/lib/WebGUI/Asset/Wobject/Search.pm index d7049a3e2..60194cba7 100644 --- a/lib/WebGUI/Asset/Wobject/Search.pm +++ b/lib/WebGUI/Asset/Wobject/Search.pm @@ -104,7 +104,15 @@ sub definition { fieldType => "yesNo", defaultValue => 0, }, - ); + paginateAfter => { + hoverHelp => $i18n->get("paginate after help"), + label => $i18n->get("paginate after"), + tab => "display", + fieldType => "integer", + defaultValue => 25, + }, + ); + push(@{$definition}, { assetName=>$i18n->get('assetName'), icon=>'search.gif', @@ -152,9 +160,9 @@ sub view { my %var; $var{'form_header' } = WebGUI::Form::formHeader($session, { - action=>$self->getUrl("doit=1") - }); - #.WebGUI::Form::hidden($self->session,{name=>"doit", value=>"1"}); + action=>$self->getUrl + }) + .WebGUI::Form::hidden($self->session,{name=>"doit", value=>"1"}); $var{'form_footer' } = WebGUI::Form::formFooter($session); $var{'form_submit' } = WebGUI::Form::submit($session, { value=>$i18n->get("search") @@ -187,7 +195,8 @@ sub view { #Set up the paginator my $p = $search->getPaginatorResultSet ( - $self->getUrl('doit=1;keywords='.$session->url->escape($keywords)) + $self->getUrl('doit=1;keywords='.$session->url->escape($keywords)), + $self->get("paginateAfter"), ); my @results = (); diff --git a/lib/WebGUI/i18n/English/Asset_Search.pm b/lib/WebGUI/i18n/English/Asset_Search.pm index a5675fdcb..e2a3c67bb 100644 --- a/lib/WebGUI/i18n/English/Asset_Search.pm +++ b/lib/WebGUI/i18n/English/Asset_Search.pm @@ -3,6 +3,18 @@ use strict; our $I18N = { ##hashref of hashes + 'paginate after' => { + message => q|Paginate After|, + lastUpdated => 0, + context => q|an asset property| + }, + + 'paginate after help' => { + message => q|The number of items to be displayed before breaking further items into additional pages.|, + lastUpdated => 0, + context => q|an asset property help| + }, + 'useContainers' => { message => q|Use container URLs in results?|, lastUpdated => 0,