Sync search result statistics with archweb

* Use archweb classes for search result statistics.
* Add some space between page numbers.
* Display current page number instead of current item range.
* Hide page numbers if the result fits into a single page.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2012-09-19 02:42:01 +02:00
parent 7c004693f7
commit 4aad42d993
4 changed files with 14 additions and 13 deletions

View file

@ -3,6 +3,10 @@
float: right; float: right;
} }
.pkglist-nav .page {
margin: 0 .25em;
}
#pkg-updates td.pkg-new { #pkg-updates td.pkg-new {
padding: 0 .5em; padding: 0 .5em;
} }

View file

@ -639,12 +639,6 @@ function pkg_search_page($SID="", $dbh=NULL) {
// figure out the results to use // figure out the results to use
$first = $_GET['O'] + 1; $first = $_GET['O'] + 1;
if (($_GET['PP'] + $_GET['O']) > $total) {
$last = $total;
} else {
$last = $_GET['PP'] + $_GET['O'];
}
# calculation of pagination links # calculation of pagination links
$per_page = ($_GET['PP'] > 0) ? $_GET['PP'] : 50; $per_page = ($_GET['PP'] > 0) ? $_GET['PP'] : 50;
$current = ceil($first / $per_page); $current = ceil($first / $per_page);

View file

@ -30,7 +30,7 @@ $orderby = array(
'd' => __('Descending') 'd' => __('Descending')
); );
$pages = array(50, 100, 250); $per_page = array(50, 100, 250);
?> ?>
<div id="pkglist-search" class="box filter-criteria"> <div id="pkglist-search" class="box filter-criteria">
@ -109,7 +109,7 @@ $pages = array(50, 100, 250);
<div> <div>
<label for="id_per_page"><?php print __("Per page"); ?></label> <label for="id_per_page"><?php print __("Per page"); ?></label>
<select name='PP'> <select name='PP'>
<?php foreach ($pages as $i): ?> <?php foreach ($per_page as $i): ?>
<?php if (isset($_REQUEST['PP']) && $_REQUEST['PP'] == $i): ?> <?php if (isset($_REQUEST['PP']) && $_REQUEST['PP'] == $i): ?>
<option value="<?php print $i; ?>" selected="selected"><?php print $i; ?></option> <option value="<?php print $i; ?>" selected="selected"><?php print $i; ?></option>
<?php else: ?> <?php else: ?>

View file

@ -11,8 +11,9 @@ if (!$result): ?>
<div class="box"><p><?php echo __("No packages matched your search criteria.") ?></p></div> <div class="box"><p><?php echo __("No packages matched your search criteria.") ?></p></div>
<?php else: ?> <?php else: ?>
<div id="pkglist-results" class="box"> <div id="pkglist-results" class="box">
<div id="pkglist-stats-top"> <div class="pkglist-stats">
<p><?php echo __('%s Packages found. Showing %s - %s', $total, $first, $last) ?></p> <p><?php echo __('%d packages found. Page %d of %d.', $total, $current, $pages) ?></p>
<?php if (count($templ_pages) > 1): ?>
<p class="pkglist-nav"> <p class="pkglist-nav">
<?php foreach ($templ_pages as $pagenr => $pagestart): ?> <?php foreach ($templ_pages as $pagenr => $pagestart): ?>
<?php if ($pagestart === false): ?> <?php if ($pagestart === false): ?>
@ -24,6 +25,7 @@ if (!$result): ?>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
</p> </p>
<?php endif; ?>
</div> </div>
<form id="pkglist-results-form" method="post" action="<?php echo get_uri('/packages/'); ?>?<?php echo htmlentities($_SERVER['QUERY_STRING']) ?>"> <form id="pkglist-results-form" method="post" action="<?php echo get_uri('/packages/'); ?>?<?php echo htmlentities($_SERVER['QUERY_STRING']) ?>">
@ -80,9 +82,9 @@ if (!$result): ?>
</tbody> </tbody>
</table> </table>
<div id="pkglist-stats-bottom"> <div class="pkglist-stats">
<p><?php echo __('%s Packages found. Showing %s - %s', $total, $first, $last) ?></p> <p><?php echo __('%d packages found. Page %d of %d.', $total, $current, $pages) ?></p>
<?php if (count($templ_pages) > 1): ?>
<p class="pkglist-nav"> <p class="pkglist-nav">
<?php foreach ($templ_pages as $pagenr => $pagestart): ?> <?php foreach ($templ_pages as $pagenr => $pagestart): ?>
<?php if ($pagestart === false): ?> <?php if ($pagestart === false): ?>
@ -94,6 +96,7 @@ if (!$result): ?>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
</p> </p>
<?php endif; ?>
</div> </div>
<?php if ($SID): ?> <?php if ($SID): ?>