diff --git a/web/html/css/arch.css b/web/html/css/arch.css index c3ed3aa8..09b22407 100644 --- a/web/html/css/arch.css +++ b/web/html/css/arch.css @@ -328,19 +328,19 @@ blockquote.code { text-decoration: none; } -#pages { margin: 5px; } -#pages .page_num { +.page_nav { + margin: 5px 0; +} +.page_nav .page_num { border: 1px solid #ddd; padding: 2px; color: #0771a6; } - -#pages .page_num:hover { +.page_nav .page_num:hover { border: 1px solid #8faecd; color: #333; } - -#pages #page_sel { +.page_nav .page_sel { border: 1px solid #8faecd; padding: 2px; color: #333; diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 2f693216..f5591f33 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -559,6 +559,32 @@ function pkg_search_page($SID="") { if ($total > 1 || $total == 0) { + # calculation of pagination links + $per_page = ($_GET['PP'] > 0) ? $_GET['PP'] : 25; + $current = ceil($first / $per_page); + $pages = ceil($total / $per_page); + $templ_pages = array(); + + if ($current > 1) { + $templ_pages[__('First')] = 0; + $templ_pages[__('Previous')] = ($current - 2) * $per_page; + } + + if ($current - 5 > 1) + $templ_pages["..."] = false; + + for ($i = max($current - 5, 1); $i <= min($pages, $current + 5); $i++) { + $templ_pages[$i] = ($i - 1) * $per_page; + } + + if ($current + 5 < $pages) + $templ_pages["... "] = false; + + if ($current < $pages) { + $templ_pages[__('Next')] = $current * $per_page; + $templ_pages[__('Last')] = ($pages - 1) * $per_page; + } + include('pkg_search_form.php'); include('pkg_search_results.php'); } 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++) {