20 $pagesCount = intval($itemsCount / $pageSize);
21 if ($itemsCount <= $pageSize || $pagesCount < 2) {
25 $currentPage = intval($offset / $pageSize) + 1;
26 $lastPage = intval($itemsCount / $pageSize) + 1;
28 $minPage = min(1, ceil($currentPage - $linksCount / 2));
29 $maxPage = max($lastPage, floor($currentPage + $linksCount / 2));
32 if ($currentPage > 1) {
33 $str .=
'<a href="' . $xoops->url(str_replace(
'%s', $offset - $pageSize,
$url)) .
'">Previous</a>';
35 for (
$i = $minPage;
$i <= $maxPage;
$i++) {
36 $tgt = htmlspecialchars($xoops->url(str_replace(
'%s', (
$i - 1) * $pageSize,
$url)), ENT_QUOTES);
37 $str .=
"<a href='$tgt'>$i</a>";
39 if ($currentPage < $lastPage) {
40 $str .=
'<a href="' . $xoops->url(str_replace(
'%s', $offset + $pageSize,
$url)) .
'">Next</a>';
42 $class = @!empty($class) ? htmlspecialchars($class, ENT_QUOTES) :
'pagenav';
44 $str =
"<div class='{$class}'>{$str}</div>";