Browse Source

implement pagination

main
ghost 1 year ago
parent
commit
3ffe4a8651
  1. 13
      src/public/assets/theme/default/css/common.css
  2. 4
      src/public/assets/theme/default/css/framework.css
  3. 27
      src/public/index.php

13
src/public/assets/theme/default/css/common.css

@ -78,3 +78,16 @@ header a.logo { @@ -78,3 +78,16 @@ header a.logo {
header a.logo > span {
color: #96d9a1;
}
a.button,
a.button:visited,
a.button:active,
a.button:hover,
.button {
background: #5d627d;
color: #ccc;
border: 0;
border-radius: 3px;
padding: 6px 8px;
font-size: 13px;
}

4
src/public/assets/theme/default/css/framework.css

@ -156,6 +156,10 @@ @@ -156,6 +156,10 @@
padding: 16px;
}
.margin-l-4 {
margin-left: 4px;
}
.margin-l-8 {
margin-left: 8px;
}

27
src/public/index.php

@ -76,12 +76,12 @@ else @@ -76,12 +76,12 @@ else
}
// Get index
$total = $sphinx->searchMagnetsTotal($request->query);
$response->total = $sphinx->searchMagnetsTotal($request->query);
$results = $sphinx->searchMagnets(
$request->query,
$request->page * WEBSITE_PAGINATION_LIMIT - WEBSITE_PAGINATION_LIMIT,
WEBSITE_PAGINATION_LIMIT,
$total
$response->total
);
foreach ($results as $result)
@ -413,6 +413,29 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?> @@ -413,6 +413,29 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
<?php } ?>
</div>
</div>
<?php if ($response->total > WEBSITE_PAGINATION_LIMIT) { ?>
<div class="row">
<div class="column width-100 text-right">
<?php echo sprintf(_('page %s / %s'), $request->page, ceil($response->total / WEBSITE_PAGINATION_LIMIT)) ?>
<?php if ($request->page > 1) { ?>
<a class="button margin-l-8"
href="<?php echo sprintf('%s/index.php?page=%s', WEBSITE_URL,
$request->page - 1,
$request->query ? sprintf('&query=%s', urlencode($request->query)) : false) ?>">
<?php echo _('back') ?>
</a>
<?php } ?>
<?php if ($request->page < ceil($response->total / WEBSITE_PAGINATION_LIMIT)) { ?>
<a class="button margin-l-4"
href="<?php echo sprintf('%s/index.php?page=%s', WEBSITE_URL,
$request->page + 1,
$request->query ? sprintf('&query=%s', urlencode($request->query)) : false) ?>">
<?php echo _('next') ?>
</a>
<?php } ?>
</div>
</div>
<?php } ?>
</div>
</main>
<footer>

Loading…
Cancel
Save