summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis@fehcom.de>2023-02-27 15:30:42 +0100
committerJannis M. Hoffmann <jannis@fehcom.de>2023-02-27 15:30:42 +0100
commitd32477f82bca6042ddccd6bbce1cc804927a89a9 (patch)
tree0f5d399ff552407d55b407b13f9bc2988c97bfa3
parenteddd009cd885093cb79e085c3499bdd52882e8b8 (diff)
Separate name space for pagination
-rw-r--r--lib/JWebmail/Plugin/Helper.pm12
-rw-r--r--templates/headers/_display_folders.html.ep2
-rw-r--r--templates/headers/_display_headers.html.ep4
-rw-r--r--templates/headers/_pagination1.html.ep10
-rw-r--r--templates/headers/_pagination2.html.ep12
5 files changed, 20 insertions, 20 deletions
diff --git a/lib/JWebmail/Plugin/Helper.pm b/lib/JWebmail/Plugin/Helper.pm
index c00ef0e..ed2c31b 100644
--- a/lib/JWebmail/Plugin/Helper.pm
+++ b/lib/JWebmail/Plugin/Helper.pm
@@ -244,7 +244,7 @@ sub _paginate {
[_clamp(0, $page_*$page_size, $total_items-1), _clamp(0, ($page_+1)*$page_size, $total_items)]
};
- my %ret = (
+ my $ret = {
total_items => $total_items,
page_size => $page_size,
@@ -256,14 +256,14 @@ sub _paginate {
this_page => $page->($current_page),
next_page => $page->($current_page+1),
last_page => $page->($total_pages-1),
- );
+ };
if ($total_items) {
- $ret{first_item} = $first_item;
- $ret{last_item} = _clamp($first_item, $first_item+$page_size-1, $total_items-1);
+ $ret->{first_item} = $first_item;
+ $ret->{last_item} = _clamp($first_item, $first_item+$page_size-1, $total_items-1);
}
- return %ret;
+ return $ret;
}
sub paginate {
@@ -277,7 +277,7 @@ sub paginate {
$start = _clamp(0, $start, max($count-1, 0));
my $end = _clamp($start, $start+$psize, max($count, 0));
- $c->stash(_paginate(
+ $c->stash(pgn => _paginate(
first_item => int($start/$psize)*$psize,
page_size => $psize,
total_items => $count,
diff --git a/templates/headers/_display_folders.html.ep b/templates/headers/_display_folders.html.ep
index 7f1612f..be5bdd9 100644
--- a/templates/headers/_display_folders.html.ep
+++ b/templates/headers/_display_folders.html.ep
@@ -21,7 +21,7 @@
</div>
<p class="pure-u-1-1 pure-u-md-1-2">
- <%= l('[_1] of [_2] messages', $this_page->[1] - $this_page->[0], $total_items) %>\
+ <%= l('[_1] of [_2] messages', $pgn->{this_page}[1] - $pgn->{this_page}[0], $pgn->{total_items}) %>\
<%= l(', [_1] new', $total_new_mails) if $total_new_mails > 0 =%>
<%= l(' - mailbox size: [_1]', print_sizes10 $total_size) if $total_size %>
</p>
diff --git a/templates/headers/_display_headers.html.ep b/templates/headers/_display_headers.html.ep
index 4dd36a1..ad60fc6 100644
--- a/templates/headers/_display_headers.html.ep
+++ b/templates/headers/_display_headers.html.ep
@@ -63,8 +63,8 @@
</thead>
<tbody>
- % foreach my $msgnum ($first_item .. $last_item) {
- % my $msg = $msgs->[$msgnum - $first_item];
+ % foreach my $msgnum ($pgn->{first_item} .. $pgn->{last_item}) {
+ % my $msg = $msgs->[$msgnum - $pgn->{first_item}];
%= tag tr => (class => $msg->{unread} ? 'new-mail' : '') => (id => $msg->{message_handle}) => begin
<td class="hide-small">
diff --git a/templates/headers/_pagination1.html.ep b/templates/headers/_pagination1.html.ep
index 0e000f9..798f79f 100644
--- a/templates/headers/_pagination1.html.ep
+++ b/templates/headers/_pagination1.html.ep
@@ -1,7 +1,7 @@
<div>
- <a href="<%= url_with->query({start => $prev_page->[0]}) %>"> ← </a>
- <a href="<%= url_with->query({start => $first_page->[0]}) %>"> ↞ </a>
- [<%= l('page [_1] of [_2]', $current_page+1, $total_pages) %>]
- <a href="<%= url_with->query({start => $last_page->[0]}) %>"> ↠ </a>
- <a href="<%= url_with->query({start => $next_page->[0]}) %>"> → </a>
+ <a href="<%= url_with->query({start => $pgn->{prev_page}[0]}) %>"> ← </a>
+ <a href="<%= url_with->query({start => $pgn->{first_page}[0]}) %>"> ↞ </a>
+ [<%= l('page [_1] of [_2]', $pgn->{current_page}+1, $pgn->{total_pages}) %>]
+ <a href="<%= url_with->query({start => $pgn->{last_page}[0]}) %>"> ↠ </a>
+ <a href="<%= url_with->query({start => $pgn->{next_page}[0]}) %>"> → </a>
</div>
diff --git a/templates/headers/_pagination2.html.ep b/templates/headers/_pagination2.html.ep
index 63e8f63..eef2abe 100644
--- a/templates/headers/_pagination2.html.ep
+++ b/templates/headers/_pagination2.html.ep
@@ -1,12 +1,12 @@
<div>
%= form_for '' => (class => 'pure-form') => begin
- <a href="<%= url_with->query({start => $first_page->[0]}) %>"><img src="/first.gif" alt="<%= l('first') . ' ' . l 'page' %>"></a>
- <a href="<%= url_with->query({start => $prev_page->[0]}) %>"><img src="/left.gif" alt="<%= l('previous') . ' ' . l 'page' %>"></a>
+ <a href="<%= url_with->query({start => $pgn->{first_page}[0]}) %>"><img src="/first.gif" alt="<%= l('first') . ' ' . l 'page' %>"></a>
+ <a href="<%= url_with->query({start => $pgn->{prev_page}[0]}) %>"><img src="/left.gif" alt="<%= l('previous') . ' ' . l 'page' %>"></a>
[
%= label_for custompage => ucfirst l 'page'
- %= number_field start => (id => 'custompage') => (size => 3) => (placeholder => $current_page+1)
+ %= number_field start => (id => 'custompage') => (size => 3) => (placeholder => $pgn->{current_page}+1)
%= l 'of'
- %= $total_pages
+ %= $pgn->{total_pages}
]
% my $h = $c->req->query_params->to_hash;
@@ -16,7 +16,7 @@
% }
% }
- <a href="<%= url_with->query({start => $next_page->[0]}) %>"><img src="/right.gif" alt="<%= l('next') . ' ' . l 'page' %>"></a>
- <a href="<%= url_with->query({start => $last_page->[0]}) %>"><img src="/last.gif" alt="<%= l('last') . ' ' . l('page') %>"></a>
+ <a href="<%= url_with->query({start => $pgn->{next_page}[0]}) %>"><img src="/right.gif" alt="<%= l('next') . ' ' . l 'page' %>"></a>
+ <a href="<%= url_with->query({start => $pgn->{last_page}[0]}) %>"><img src="/last.gif" alt="<%= l('last') . ' ' . l('page') %>"></a>
% end
</div>