Updates CSS and redesigns pagination
parent
82fb01384f
commit
35def007ca
|
|
@ -1,81 +1,96 @@
|
|||
|
||||
<div class="text-center">
|
||||
<div class="pagination">
|
||||
<?php
|
||||
/**
|
||||
* Pagination helper
|
||||
* @param string $url Base URL for pagination links
|
||||
* @param int $browse_page Current page number
|
||||
* @param int $page_count Total number of pages
|
||||
*/
|
||||
function renderPagination($url, $browse_page = 1, $page_count = 1) {
|
||||
$param = '';
|
||||
if (isset($_REQUEST['id'])) {
|
||||
$param .= '&id=' . htmlspecialchars($_REQUEST['id']);
|
||||
}
|
||||
// calls
|
||||
if (isset($_REQUEST['name'])) {
|
||||
$param .= '&name=' . htmlspecialchars($_REQUEST['name']);
|
||||
}
|
||||
if (isset($_REQUEST['ip'])) {
|
||||
$param .= '&ip=' . htmlspecialchars($_REQUEST['ip']);
|
||||
if (isset($_REQUEST['invitees'])) {
|
||||
$param .= '&invitees=' . htmlspecialchars($_REQUEST['invitees']);
|
||||
}
|
||||
if (isset($_REQUEST['event'])) {
|
||||
$param .= '&event=' . htmlspecialchars($_REQUEST['event']);
|
||||
if (isset($_REQUEST['description'])) {
|
||||
$param .= '&description=' . htmlspecialchars($_REQUEST['description']);
|
||||
}
|
||||
if (isset($_REQUEST['filter'])) {
|
||||
$param .= '&filter=' . htmlspecialchars($_REQUEST['filter']);
|
||||
}
|
||||
// contacts
|
||||
if (isset($_REQUEST['name'])) {
|
||||
$param .= '&name=' . htmlspecialchars($_REQUEST['name']);
|
||||
}
|
||||
if (isset($_REQUEST['phone'])) {
|
||||
$param .= '&phone=' . htmlspecialchars($_REQUEST['phone']);
|
||||
}
|
||||
if (isset($_REQUEST['email'])) {
|
||||
$param .= '&email=' . htmlspecialchars($_REQUEST['email']);
|
||||
}
|
||||
// messages
|
||||
if (isset($_REQUEST['from'])) {
|
||||
$param .= '&from=' . htmlspecialchars($_REQUEST['from']);
|
||||
}
|
||||
if (isset($_REQUEST['to'])) {
|
||||
$param .= '&to=' . htmlspecialchars($_REQUEST['to']);
|
||||
}
|
||||
if (isset($_REQUEST['subject'])) {
|
||||
$param .= '&subject=' . htmlspecialchars($_REQUEST['subject']);
|
||||
}
|
||||
// notifications
|
||||
if (isset($_REQUEST['message'])) {
|
||||
$param .= '&message=' . htmlspecialchars($_REQUEST['message']);
|
||||
}
|
||||
// time period
|
||||
if (isset($_REQUEST['from_time'])) {
|
||||
$param .= '&from_time=' . htmlspecialchars($from_time);
|
||||
$param .= '&from_time=' . htmlspecialchars($_REQUEST['from_time']);
|
||||
}
|
||||
if (isset($_REQUEST['until_time'])) {
|
||||
$param .= '&until_time=' . htmlspecialchars($until_time);
|
||||
$param .= '&until_time=' . htmlspecialchars($_REQUEST['until_time']);
|
||||
}
|
||||
|
||||
$max_visible_pages = 10;
|
||||
$step_pages = 10;
|
||||
|
||||
echo '<div class="tm-pagination text-center"><div class="pagination">';
|
||||
|
||||
if ($browse_page > 1) {
|
||||
echo '<span><a href="' . htmlspecialchars($url) . '&p=1">first</a></span>';
|
||||
echo '<a class="pagination-link" href="' . htmlspecialchars($url) . '&p=1' . $param . '">first</a>';
|
||||
echo '<a class="pagination-link" href="' . htmlspecialchars($url) . '&p=' . ($browse_page - 1) . $param . '">«</a>';
|
||||
} else {
|
||||
echo '<span>first</span>';
|
||||
echo '<span class="pagination-link disabled">first</span>';
|
||||
echo '<span class="pagination-link disabled">«</span>';
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $page_count; $i++) {
|
||||
// always show the first, last, step pages (10, 20, 30, etc.),
|
||||
// and the pages close to the current one
|
||||
if (
|
||||
$i === 1 || // first page
|
||||
$i === $page_count || // last page
|
||||
$i === $browse_page || // current page
|
||||
$i === $browse_page -1 ||
|
||||
$i === $browse_page +1 ||
|
||||
$i === $browse_page -2 ||
|
||||
$i === $browse_page +2 ||
|
||||
($i % $step_pages === 0 && $i > $max_visible_pages) // the step pages - 10, 20, etc.
|
||||
) {
|
||||
if ($i === $browse_page) {
|
||||
// current page, no link
|
||||
if ($browse_page > 1) {
|
||||
echo '<span><a href="' . htmlspecialchars($app_root) . '?platform=' . htmlspecialchars($platform_id) . '&page=' . htmlspecialchars($page) . $param . '&p=' . (htmlspecialchars($browse_page) -1) . '"><<</a></span>';
|
||||
} else {
|
||||
echo '<span><<</span>';
|
||||
}
|
||||
echo '[' . htmlspecialchars($i) . ']';
|
||||
// and pages around current page
|
||||
if ($i == 1 || $i == $page_count ||
|
||||
$i % $step_pages == 0 ||
|
||||
abs($i - $browse_page) < $max_visible_pages / 2) {
|
||||
|
||||
if ($browse_page < $page_count) {
|
||||
echo '<span><a href="' . htmlspecialchars($app_root) . '?platform=' . htmlspecialchars($platform_id) . '&page=' . htmlspecialchars($page) . $param . '&p=' . (htmlspecialchars($browse_page) +1) . '">>></a></span>';
|
||||
if ($i == $browse_page) {
|
||||
echo '<span class="pagination-link active">' . $i . '</span>';
|
||||
} else {
|
||||
echo '<span>>></span>';
|
||||
echo '<a class="pagination-link" href="' . htmlspecialchars($url) . '&p=' . $i . $param . '">' . $i . '</a>';
|
||||
}
|
||||
} else {
|
||||
// other pages
|
||||
echo '<span><a href="' . htmlspecialchars($app_root) . '?platform=' . htmlspecialchars($platform_id) . '&page=' . htmlspecialchars($page) . $param . '&p=' . htmlspecialchars($i) . '">[' . htmlspecialchars($i) . ']</a></span>';
|
||||
}
|
||||
// show ellipses between distant pages
|
||||
} elseif (
|
||||
$i === $browse_page -3 ||
|
||||
$i === $browse_page +3
|
||||
) {
|
||||
echo '<span>...</span>';
|
||||
} elseif ($i == 2 || $i == $page_count - 1 ||
|
||||
($i > $browse_page + $max_visible_pages / 2 && $i % $step_pages == 1) ||
|
||||
($i < $browse_page - $max_visible_pages / 2 && $i % $step_pages == $step_pages - 1)) {
|
||||
echo '<span class="pagination-link pagination-ellipsis disabled">...</span>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($browse_page < $page_count) {
|
||||
echo '<span><a href="' . htmlspecialchars($app_root) . '?platform=' . htmlspecialchars($platform_id) . '&page=' . htmlspecialchars($page) . $param . '&p=' . (htmlspecialchars($page_count)) . '">last</a></span>';
|
||||
echo '<a class="pagination-link" href="' . htmlspecialchars($url) . '&p=' . ($browse_page + 1) . $param . '">»</a>';
|
||||
echo '<a class="pagination-link" href="' . htmlspecialchars($url) . '&p=' . $page_count . $param . '">last</a>';
|
||||
} else {
|
||||
echo '<span>last</span>';
|
||||
echo '<span class="pagination-link disabled">»</span>';
|
||||
echo '<span class="pagination-link disabled">last</span>';
|
||||
}
|
||||
|
||||
echo '</div></div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue