2 page = CGI.param('page');
3 page = page.match('^\d+$') ? page : 0; # verify page is a sane value
4 page_count = ctx.page_size == 0 ? 1 : POSIX.ceil(ctx.hit_count / ctx.page_size);
5 ctx.result_start = 1 + ctx.page_size * page;
6 ctx.result_stop = ctx.page_size * (page + 1);
7 IF ctx.result_stop > ctx.hit_count; ctx.result_stop = ctx.hit_count; END;
8 result_count = ctx.result_start;
11 <table cellpadding="0" cellspacing="0" border="0" width="100%">
18 href = mkurl('', {page => page - 1});
19 ELSE; class = class _ ' invisible'; END %]
20 <a class="[% class %]" href="[% href %]"><img src="[% ctx.media_prefix %]/images/kpac/arrow_last.png[% ctx.cache_key %]" alt="Last" /></a>
24 <td width="100%" class="nav_mid_bg">
25 <table cellpadding="0" cellspacing="0" border="0" align="center">
27 <td>[% l('Page [_1] of [_2]', '</td><td class="current_page">' _ (page + 1) _ '</td><td>', '</td><td class="total_pages">' _ page_count _ '</td>') %]</td>
33 <td class="to_top_btn">
36 IF (page + 1) < page_count;
37 href = mkurl('', {page => page + 1});
38 ELSE; class = class _ ' invisible'; END;
40 <a class="[% class %]" href="[% href %]"><img src="[% ctx.media_prefix %]/images/kpac/arrow_next.png[% ctx.cache_key %]" alt="Next" /></a>
45 <td class="to_top_btn"><a href="[% mkurl('').replace('#.*', '') %]">
46 <img src="[% ctx.media_prefix %]/images/kpac/to_top_btn.png[% ctx.cache_key %]" alt="Top" />