From 5d54d8285e8dd6a9c13422e091e9cc9c2f8f2ec1 Mon Sep 17 00:00:00 2001 From: Aaron Trevena Date: Sat, 16 Jun 2007 17:57:59 +0000 Subject: [PATCH] updated pager - now shows first last plus 10 pages git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@571 48953598-375a-da11-a14b-00016c27c3ee --- lib/Maypole/templates/factory/pager | 66 +++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/lib/Maypole/templates/factory/pager b/lib/Maypole/templates/factory/pager index 78c89fd..cd03a4f 100644 --- a/lib/Maypole/templates/factory/pager +++ b/lib/Maypole/templates/factory/pager @@ -7,42 +7,72 @@ and search views. It expects a C template argument which responds to the L interface. #%] + +[% BLOCK pager_link; %] [% -IF pager AND pager.first_page != pager.last_page; + SET label = page_num; + SET args = "?page=" _ page_num; + SET args = args _ "&order=" _ request.params.order IF request.params.order; + SET args = args _ "&o2=desc" IF request.params.o2 == "desc"; + FOR col = pager_columns; + IF request.params.$col; + SET args = args _ "&" _ col _ "=" _ request.params.$col; + SET action = "search"; + END; + END; + link(classmetadata.table, action, args, label); %] -

Pages: +[% END; %] + + +[% IF pager %] +

+Page +[% IF pager.first_page == pager.last_page; %] +1 of 1 +[% ELSE %] +[% pager.current_page %] of [% pager.last_page %]   |   [% UNLESS pager_action; SET pager_action = request.action; END; - SET begin_page = pager.current_page - 10; + UNLESS pager_columns; + SET pager_columns = classmetadata.columns.list; + END; + + SET end_page = pager.current_page + 5; + SET begin_page = pager.current_page - 5; IF begin_page < 1; - SET begin_page = pager.first_page; + SET begin_page = 1; + SET end_page = 10; END; - SET end_page = pager.current_page + 10; + IF pager.last_page < end_page; SET end_page = pager.last_page; + IF (end_page - 10) > 1; + begin_page = end_page - 10; + END; + END; + + IF begin_page > 1; + PROCESS pager_link page_num = 1, action = pager_action; END; + FOREACH num = [begin_page .. end_page]; IF num == pager.current_page; ""; num; ""; ELSE; - SET label = num; - SET args = "?page=" _ num; - SET args = args _ "&order=" _ request.params.order - IF request.params.order; - SET args = args _ "&o2=desc" - IF request.params.o2 == "desc"; - FOR col = classmetadata.columns.list; - IF request.params.$col; - SET args = args _ "&" _ col _ "=" _ request.params.$col; - SET action = "search"; - END; - END; - link(classmetadata.table, pager_action, args, label); + PROCESS pager_link page_num = num, action = pager_action; END; END; + + IF end_page < pager.last_page; + PROCESS pager_link page_num = pager.last_page, action = pager_action; + END; + +END; %]

[% END %] + -- 2.39.2