Updates CSS and redesigns pagination
parent
82fb01384f
commit
35def007ca
|
|
@ -1,81 +1,96 @@
|
||||||
|
|
||||||
<div class="text-center">
|
|
||||||
<div class="pagination">
|
|
||||||
<?php
|
<?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 = '';
|
$param = '';
|
||||||
if (isset($_REQUEST['id'])) {
|
// calls
|
||||||
$param .= '&id=' . htmlspecialchars($_REQUEST['id']);
|
|
||||||
}
|
|
||||||
if (isset($_REQUEST['name'])) {
|
if (isset($_REQUEST['name'])) {
|
||||||
$param .= '&name=' . htmlspecialchars($_REQUEST['name']);
|
$param .= '&name=' . htmlspecialchars($_REQUEST['name']);
|
||||||
}
|
}
|
||||||
if (isset($_REQUEST['ip'])) {
|
if (isset($_REQUEST['invitees'])) {
|
||||||
$param .= '&ip=' . htmlspecialchars($_REQUEST['ip']);
|
$param .= '&invitees=' . htmlspecialchars($_REQUEST['invitees']);
|
||||||
}
|
}
|
||||||
if (isset($_REQUEST['event'])) {
|
if (isset($_REQUEST['description'])) {
|
||||||
$param .= '&event=' . htmlspecialchars($_REQUEST['event']);
|
$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'])) {
|
if (isset($_REQUEST['from_time'])) {
|
||||||
$param .= '&from_time=' . htmlspecialchars($from_time);
|
$param .= '&from_time=' . htmlspecialchars($_REQUEST['from_time']);
|
||||||
}
|
}
|
||||||
if (isset($_REQUEST['until_time'])) {
|
if (isset($_REQUEST['until_time'])) {
|
||||||
$param .= '&until_time=' . htmlspecialchars($until_time);
|
$param .= '&until_time=' . htmlspecialchars($_REQUEST['until_time']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$max_visible_pages = 10;
|
$max_visible_pages = 10;
|
||||||
$step_pages = 10;
|
$step_pages = 10;
|
||||||
|
|
||||||
|
echo '<div class="tm-pagination text-center"><div class="pagination">';
|
||||||
|
|
||||||
if ($browse_page > 1) {
|
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 {
|
} 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++) {
|
for ($i = 1; $i <= $page_count; $i++) {
|
||||||
// always show the first, last, step pages (10, 20, 30, etc.),
|
// always show the first, last, step pages (10, 20, 30, etc.),
|
||||||
// and the pages close to the current one
|
// and pages around current page
|
||||||
if (
|
if ($i == 1 || $i == $page_count ||
|
||||||
$i === 1 || // first page
|
$i % $step_pages == 0 ||
|
||||||
$i === $page_count || // last page
|
abs($i - $browse_page) < $max_visible_pages / 2) {
|
||||||
$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) . ']';
|
|
||||||
|
|
||||||
if ($browse_page < $page_count) {
|
if ($i == $browse_page) {
|
||||||
echo '<span><a href="' . htmlspecialchars($app_root) . '?platform=' . htmlspecialchars($platform_id) . '&page=' . htmlspecialchars($page) . $param . '&p=' . (htmlspecialchars($browse_page) +1) . '">>></a></span>';
|
echo '<span class="pagination-link active">' . $i . '</span>';
|
||||||
} else {
|
} else {
|
||||||
echo '<span>>></span>';
|
echo '<a class="pagination-link" href="' . htmlspecialchars($url) . '&p=' . $i . $param . '">' . $i . '</a>';
|
||||||
}
|
}
|
||||||
} else {
|
} elseif ($i == 2 || $i == $page_count - 1 ||
|
||||||
// other pages
|
($i > $browse_page + $max_visible_pages / 2 && $i % $step_pages == 1) ||
|
||||||
echo '<span><a href="' . htmlspecialchars($app_root) . '?platform=' . htmlspecialchars($platform_id) . '&page=' . htmlspecialchars($page) . $param . '&p=' . htmlspecialchars($i) . '">[' . htmlspecialchars($i) . ']</a></span>';
|
($i < $browse_page - $max_visible_pages / 2 && $i % $step_pages == $step_pages - 1)) {
|
||||||
}
|
echo '<span class="pagination-link pagination-ellipsis disabled">...</span>';
|
||||||
// show ellipses between distant pages
|
|
||||||
} elseif (
|
|
||||||
$i === $browse_page -3 ||
|
|
||||||
$i === $browse_page +3
|
|
||||||
) {
|
|
||||||
echo '<span>...</span>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($browse_page < $page_count) {
|
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 {
|
} 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