diff options
author | PyroPeter <abi1789@googlemail.com> | 2011-02-16 18:48:09 +0100 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2011-02-17 18:54:26 +0100 |
commit | 1fdecbd5a45ef631562a11937d870e4c8cf619b0 (patch) | |
tree | 3c0f027576576d31ca6666a503c55f6f5078db5b /web/template | |
parent | 0de4ce61be3000cb110e538c61c194c429239579 (diff) | |
download | aur-1fdecbd5a45ef631562a11937d870e4c8cf619b0.tar.gz aur-1fdecbd5a45ef631562a11937d870e4c8cf619b0.tar.xz |
pkg_search_results: rewrite of pagination
* Most of the PHP-code was moved to pkgfuncs.php to keep the template simple.
Signed-off-by: PyroPeter <abi1789@googlemail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/template')
-rw-r--r-- | web/template/pkg_search_results.php | 77 |
1 files changed, 14 insertions, 63 deletions
diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php index 4830ca85..68ba89a4 100644 --- a/web/template/pkg_search_results.php +++ b/web/template/pkg_search_results.php @@ -113,73 +113,24 @@ for ($i = 0; $row = mysql_fetch_assoc($result); $i++) { </td> <td align='right'> - <span class='f4'><span class='blue'> - <?php print __("Showing results %s - %s of %s", $first, $last, $total) ?> - </span></span> - <br /> - - <div id="pages"> - <?php - if ($_GET['O'] > 0): - $O = $_GET['O'] - $_GET['PP']; - - if ($_GET['O'] < $_GET['PP']) { - $O = 0; - } - ?> - <a class="page_num" href="packages.php?<?php print mkurl("O=0") ?>"><?php echo __('First') ?></a> - <a class="page_num" href="packages.php?<?php print mkurl("O=$O") ?>"><?php echo __('Previous') ?></a> - <?php endif; ?> - - <?php - if ($_GET['PP'] > 0) { - $pages = ceil($total / $_GET['PP']); - } - - if ($pages > 1) { - if ($_GET['O'] > 0) { - $currentpage = ceil(($_GET['O'] + 1) / $_GET['PP']); - } - else { - $currentpage = 1; - } - - $morepages = $currentpage + 5; - - print (($currentpage-5) > 1) ? '...' : ''; - - # Display links for more search results. - for ($i = ($currentpage - 5); $i <= $morepages && $i <= $pages; $i++) { - if ($i < 1) { - $i = 1; - } - - $pagestart = ($i - 1) * $_GET['PP']; - - if ($i <> $currentpage) : - ?> - <a class="page_num" href="packages.php?<?php print mkurl('O=' . ($pagestart)) ?>"><?php echo $i ?></a> - <?php else : echo "<span id=\"page_sel\">$i</span>"; - endif; - } - - print ($pages > $morepages) ? '...' : ''; - ?> - - <?php if ($total - $_GET['PP'] - $_GET['O'] > 0): ?> - <a class="page_num" href='packages.php?<?php print mkurl('O=' . ($_GET['O'] + $_GET['PP'])) ?>'><?php echo __('Next') ?></a> - <a class="page_num" href='packages.php?<?php print mkurl('O=' . ($total - $_GET['PP'])) ?>'><?php echo __('Last') ?></a> - <?php endif; ?> - + <div class="f4 blue"> + <?php print __("Showing results %s - %s of %s", $first, $last, $total) ?> + </div> + <div class="page_nav"> + <?php foreach($templ_pages as $pagenr => $pagestart) { ?> + <?php if ($pagestart === false) { ?> + <?php echo $pagenr ?> + <?php } else if ($pagestart + 1 == $first) { ?> + <span class="page_sel"><?php echo $pagenr ?></span> + <?php } else { ?> + <a class="page_num" href="packages.php?<?php print mkurl('O=' . ( $pagestart)) ?>"><?php echo $pagenr ?></a> + <?php } ?> + <?php } ?> </div> - </td> </tr> -<?php - } -} -?> +<?php } ?> </table> </div> </form> |