Separate previous, pages and next buttons.

This commit is contained in:
Keir Nellyer 2016-02-25 18:29:38 +00:00
parent 1c7d48575f
commit af8ad218be

View File

@ -221,7 +221,6 @@ function parseDateTime($dateTime, $timezone)
return DateTime::createFromFormat(jsonDateTimeFormat, $dateTime, $timezone); return DateTime::createFromFormat(jsonDateTimeFormat, $dateTime, $timezone);
} }
/**
/** /**
* Converts an interval to minutes, days or months, depending on the size. * Converts an interval to minutes, days or months, depending on the size.
* *
@ -250,28 +249,48 @@ function approximateHumanInterval($interval)
return $humanString; return $humanString;
} }
function echoPageNavigation($page, $maxPage) /**
* @param int $page
* @return string
*/
function htmlPreviousLink($page)
{ {
$previous = $page != 0; $html = '';
$next = $page != $maxPage;
if ($previous) if ($page != 0)
{ {
$vars = $_GET; $vars = $_GET;
$vars['page'] = $page - 1; $vars['page'] = $page - 1;
echo '<a href=?' . http_build_query($vars) . '>Previous</a>&emsp;'; $html = '<a href=?' . http_build_query($vars) . '>Previous</a>';
} }
echo ' ' . htmlPageNumbers($page, $maxPage) . ' '; return $html;
}
if ($next) /**
* @param int $page
* @param int $maxPage
* @return string
*/
function htmlNextLink($page, $maxPage)
{
$html = '';
if ($page < $maxPage)
{ {
$vars = $_GET; $vars = $_GET;
$vars['page'] = $page + 1; $vars['page'] = $page + 1;
echo '&emsp;<a href=?' . http_build_query($vars) . '>Next</a>'; $html = '<a href=?' . http_build_query($vars) . '>Next</a>&emsp;';
} }
return $html;
} }
/**
* @param int $page
* @param int $maxPage
* @return string
*/
function htmlPageNumbers($page, $maxPage) function htmlPageNumbers($page, $maxPage)
{ {
$html = ''; $html = '';
@ -442,7 +461,13 @@ if ($validIdentifier)
<?php } ?> <?php } ?>
</div> </div>
<div> <div>
<?php echoPageNavigation($page, $maxPage) ?> <?php
// TODO separate these into 3 divs aligned bottom-centre
// this ensures these links are in the same place every time
echo htmlPreviousLink($page);
echo htmlPageNumbers($page, $maxPage);
echo htmlNextLink($page, $maxPage);
?>
</div> </div>
</div> </div>
<div id="users" class="col-lg-5"> <div id="users" class="col-lg-5">