mirror of
https://github.com/sorenpeter/timeline.git
synced 2025-12-16 03:17:01 +00:00
Pagnation navigation added
This commit is contained in:
parent
8b133883d4
commit
a46d88a3c0
2 changed files with 52 additions and 1 deletions
|
|
@ -22,7 +22,7 @@ require_once('libs/twtxt.php');
|
||||||
require_once('libs/hash.php');
|
require_once('libs/hash.php');
|
||||||
require_once('libs/Parsedown.php');
|
require_once('libs/Parsedown.php');
|
||||||
|
|
||||||
const TWTS_PER_PAGE = 50;
|
const TWTS_PER_PAGE = 10;
|
||||||
|
|
||||||
// TODO: Move twts per page to config.ini
|
// TODO: Move twts per page to config.ini
|
||||||
// Add a fallback if the number is invalid (it should be between 1 and 999)
|
// Add a fallback if the number is invalid (it should be between 1 and 999)
|
||||||
|
|
@ -156,6 +156,7 @@ if (!empty($_GET['hash'])) {
|
||||||
$twts = array_reverse($twts, true);
|
$twts = array_reverse($twts, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pagnation
|
||||||
$page = 1;
|
$page = 1;
|
||||||
if (!empty($_GET['page'])) {
|
if (!empty($_GET['page'])) {
|
||||||
$page = intval($_GET['page']);
|
$page = intval($_GET['page']);
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,56 @@
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<?php }
|
<?php }
|
||||||
|
|
||||||
|
// Pagnation
|
||||||
|
/*
|
||||||
|
|
||||||
|
TODO: Merge with code in base.php / make new pagnation.php
|
||||||
|
TODO: Make pagnation work with profile views
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$page_url = $_SERVER['REQUEST_URI'];
|
||||||
|
//echo $page_url."<hr>";
|
||||||
|
|
||||||
|
if (!empty($_GET['page'])) {
|
||||||
|
|
||||||
|
if (preg_match('/\?page=/', $page_url)) {
|
||||||
|
//echo "cotains ?page= so reuse that<hr>";
|
||||||
|
$page_url = preg_replace('/\?page=\d*/', "", $page_url) . '?page=';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('/&page=/', $page_url)) {
|
||||||
|
echo "cotains &page= so reuse that<hr>";
|
||||||
|
$page_url = preg_replace('/&page=\d*/', "", $page_url) . '&page=';
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (!preg_match('/(\?|&)/', $page_url)) {
|
||||||
|
//echo "No param, so use ?page<hr>";
|
||||||
|
$page_url = $page_url . '?page=';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!preg_match('/(\?|&)page/', $page_url)) {
|
||||||
|
//echo "other param than _page, so use &page<hr>";
|
||||||
|
$page_url = $page_url . '&page=';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<center><p>
|
||||||
|
<?php if ($page > 1) { ?>
|
||||||
|
<a href="<?= $page_url . $page-1 ?>">Prev</a>
|
||||||
|
<?php } else { ?>
|
||||||
|
<span style="color: var(--disabled);">Prev</span>
|
||||||
|
<?php } ?>
|
||||||
|
<strong> <?= $page ?> </strong>
|
||||||
|
<a href="<?= $page_url . $page+1 ?>">Next</a>
|
||||||
|
</p></center>
|
||||||
|
|
||||||
|
<?php
|
||||||
require_once 'libs/session.php';
|
require_once 'libs/session.php';
|
||||||
|
|
||||||
if (!hasValidSession()) {
|
if (!hasValidSession()) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue