Recalculates $pageNumber and $totalPages

@param integer $rowCount
@return Table
172635
public function calculatePageParams($rowCount)
    {
        $this->totalPages = $this->pageSize > 0
            ? ceil($rowCount / $this->pageSize)
            : 1;
        if ($this->totalPages <= 0)
            $this->totalPages = 1;
        if ($this->pageNumber > $this->totalPages)
            $this->pageNumber = $this->totalPages;

        return $this;
    }
956581
public function setNumPerPage($count)
    {
        if (!is_numeric($count)) {
            throw new InvalidArgumentException(
                'Number Per Page must be numeric.'
            );
        }

        $count = (int)$count;
        if ($count < 0) {
            throw new InvalidArgumentException(
                'Number Per Page must be greater than zero.'
            );
        }

        $this->numPerPage = $count;
        return $this;
    }
446520
public function paginate(Query $query, $page = 1, $limit = 10, $fetchJoinCollection = false): array
    {
        $paginator = new Paginator($query, $fetchJoinCollection);
        $totalItems = $paginator->count();
        $pagesCount = ceil($totalItems / $limit);
        $paginator
            ->getQuery()
            ->setFirstResult($limit * ($page - 1))// offset
            ->setMaxResults($limit); // limit

        return [
            'meta' => [
                'page' => $page,
                'total' => $totalItems,
                'pages' => $pagesCount,
                'limit' => $limit,
            ],
            'data' => $paginator
        ];
    }
17423
protected function calculatePageRowNumberForLastLink()
    {
        $mod = $this->totalRows % $this->limit;

        return ($this->totalRows - $mod ) - ($mod == 0 ? $this->limit : 0);
    }
540032
protected function needNextPageLink($resultSetCount)
    {
        $currentResourceSet = $this->getCurrentResourceSetWrapper();
        $recursionLevel = count($this->getStack()->getSegmentNames());
        $pageSize = $currentResourceSet->getResourceSetPageSize();

        if (1 == $recursionLevel) {
            //presence of $top option affect next link for root container
            $topValueCount = $this->getRequest()->getTopOptionCount();
            if (null !== $topValueCount && ($topValueCount <= $pageSize)) {
                return false;
            }
        }
        return $resultSetCount == $pageSize;
    }
905685
function Render($rows=10)
	{
	global $ADODB_COUNTRECS;

		$this->rows = $rows;

		if ($this->db->dataProvider == 'informix') $this->db->cursorType = IFX_SCROLL;

		$savec = $ADODB_COUNTRECS;
		if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true;
		if ($this->cache)
			$rs = $this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page);
		else
			$rs = $this->db->PageExecute($this->sql,$rows,$this->curr_page);
		$ADODB_COUNTRECS = $savec;

		$this->rs = $rs;
		if (!$rs) {
			print "<h3>Query failed: $this->sql</h3>";
			return;
		}

		if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage()))
			$header = $this->RenderNav();
		else
			$header = "&nbsp;";

		$grid = $this->RenderGrid();
		$footer = $this->RenderPageCount();

		$this->RenderLayout($header,$grid,$footer);

		$rs->Close();
		$this->rs = false;
	}
332198
public function generatePageNavigation($positionCount = 0)
    {
        startProfile('generatePageNavigation');

        $pageNavigation = new StdClass();

        $pageNavigation->NrOfPages = $this->_iCntPages;
        $activePage = $this->getActPage();
        $pageNavigation->actPage = $activePage + 1;
        $url = $this->generatePageNavigationUrl();

        if ($positionCount == 0 || ($positionCount >= $pageNavigation->NrOfPages)) {
            $startNo = 2;
            $finishNo = $pageNavigation->NrOfPages;
        } else {
            $tmpVal = $positionCount - 3;
            $tmpVal2 = floor(($positionCount - 4) / 2);

            // actual page is at the start
            if ($pageNavigation->actPage <= $tmpVal) {
                $startNo = 2;
                $finishNo = $tmpVal + 1;
                // actual page is at the end
            } elseif ($pageNavigation->actPage >= $pageNavigation->NrOfPages - $tmpVal + 1) {
                $startNo = $pageNavigation->NrOfPages - $tmpVal;
                $finishNo = $pageNavigation->NrOfPages - 1;
                // actual page is in the middle
            } else {
                $startNo = $pageNavigation->actPage - $tmpVal2;
                $finishNo = $pageNavigation->actPage + $tmpVal2;
            }
        }

        if ($activePage > 0) {
            $pageNavigation->previousPage = $this->_addPageNrParam($url, $activePage - 1);
        }

        if ($activePage < $pageNavigation->NrOfPages - 1) {
            $pageNavigation->nextPage = $this->_addPageNrParam($url, $activePage + 1);
        }

        if ($pageNavigation->NrOfPages > 1) {
            for ($i = 1; $i < $pageNavigation->NrOfPages + 1; $i++) {
                if ($i == 1 || $i == $pageNavigation->NrOfPages || ($i >= $startNo && $i <= $finishNo)) {
                    $page = new stdClass();
                    $page->url = $this->_addPageNrParam($url, $i - 1);
                    $page->selected = ($i == $pageNavigation->actPage) ? 1 : 0;
                    $pageNavigation->changePage[$i] = $page;
                }
            }

            // first/last one
            $pageNavigation->firstpage = $this->_addPageNrParam($url, 0);
            $pageNavigation->lastpage = $this->_addPageNrParam($url, $pageNavigation->NrOfPages - 1);
        }

        stopProfile('generatePageNavigation');

        return $pageNavigation;
    }
209583
public function get($table, $cols, $options = array(), $distinct = false, $total_rows = false)
    {
        // Get Data
        $rows = array();
        $result = $this->select($table, $cols, $options, $distinct, $total_rows);
        while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
            $rows[] = $row;
        }
        $num = count($rows);

        // Total rows?
        if ($total_rows) {
            $result = $this->doQuery('SELECT FOUND_ROWS()');
            list ($total_rows) = $result->fetch(\PDO::FETCH_NUM);
        } else {
            $total_rows = $num;
        }

        // Return the result
        return array(
            'data' => $rows,
            'num' => $num,
            'num_all' => $total_rows,
        );
    }
1102971
public static function getTwoTablePagination(int $table1Count, int $table2Count, int $limit, int $offset = 0): array
    {
        \assert('$table1Count >= 0 && $table2Count >= 0 && $limit >= 0 && $offset >= 0');
        $offset1 = min($offset, $table1Count);
        $limit1 = min($limit, $table1Count - $offset1);
        $offset2 = min($offset - $offset1, $table2Count);
        $limit2 = min($limit - $limit1, $table2Count - $offset2);
        return [
            'limit1' => $limit1,
            'offset1' => $offset1,
            'limit2' => $limit2,
            'offset2' => $offset2,
        ];
    }
498843
protected function getDataTableInstance($instances, $model, $totalCount, $page = 1): DataTable {
		$semantic = $this->jquery->semantic ();
		$recordsPerPage = $this->recordsPerPage ( $model, $totalCount );
		if (is_numeric ( $recordsPerPage )) {
			$grpByFields = $this->getGroupByFields ();
			if (is_array ( $grpByFields )) {
				$dataTable = $semantic->dataTable ( "lv", $model, $instances );
				$dataTable->setGroupByFields ( $grpByFields );
			} else {
				$dataTable = $semantic->jsonDataTable ( "lv", $model, $instances );
			}
			$dataTable->paginate ( $page, $totalCount, $recordsPerPage, 5 );
			$dataTable->onActiveRowChange ( '$("#table-details").html("");' );
			$dataTable->onSearchTerminate ( '$("#search-query-content").html(data);$("#search-query").show();$("#table-details").html("");' );
		} else {
			$dataTable = $semantic->dataTable ( "lv", $model, $instances );
		}
		return $dataTable;
	}
282048
public static function paginate($limit = 10, $sql = '', $binding = [])
    {
        $page = request('page', 1);
        if (!is_numeric($page)) {
            $page = 1;
        }

        $offset = ($page - 1) * $limit;
        $sql .= " limit $limit offset $offset";
        $items = static::findAll($sql, $binding);
        $total = static::countAll($sql, $binding);

        return new Paginator($items, $page, $limit, $total);
    }
1321420
public function pagination(int $limit = 20, int $offset = 0, ?callable $totalQuery = null)
    {
        $query = clone $this->selectQueryInstance();

        return $query->paginate($limit, $offset, $totalQuery);
    }
485532
function RenderPageCount()
	{
		if (!$this->db->pageExecuteCountRows) return '';
		$lastPage = $this->rs->LastPageNo();
		if ($lastPage == -1) $lastPage = 1; // check for empty rs.
		if ($this->curr_page > $lastPage) $this->curr_page = 1;
		return "<font size=-1>$this->page ".$this->curr_page."/".$lastPage."</font>";
	}
393323
protected function getNextPage($totalPages, $offset, $limit)
    {
        $nextPage = ($offset / $limit) + 2;
        if ($nextPage > $totalPages) {
            return null;
        }

        return $nextPage;
    }
1170838
public function absolutePaginateCount(array $paginator, $count, $dir = null) {
		if ($dir === null) {
			$dir = 'ASC';
		}

		$currentPage = $paginator['page'];
		$pageCount = $paginator['pageCount'];
		$totalCount = $paginator['count'];
		$limit = $paginator['limit'];
		$step = isset($paginator['step']) ? $paginator['step'] : 1;

		if ($dir === 'DESC') {
			$currentCount = $count + ($pageCount - $currentPage) * $limit * $step;
			if ($currentPage != $pageCount && $pageCount > 1) {
				$currentCount -= $pageCount * $limit * $step - $totalCount;
			}
		} else {
			$currentCount = $count + ($currentPage - 1) * $limit * $step;
		}

		return $currentCount;
	}
357826
public function limitPage($page, $rowCount)
    {
        $page     = ($page > 0)     ? $page     : 1;
        $rowCount = ($rowCount > 0) ? $rowCount : 1;
        $this->_parts[self::LIMIT_COUNT]  = (int) $rowCount;
        $this->_parts[self::LIMIT_OFFSET] = (int) $rowCount * ($page - 1);
        return $this;
    }
803402
protected function jumpingBuildPagesRange(IPaginator $paginator, $pagesCountInRange)
    {
        $currentPage = $paginator->getCurrentPage();
        $pagesCount = $paginator->getPagesCount();
        $currentRange = ceil($currentPage / $pagesCountInRange);
        $ragesCount = ceil($pagesCount / $pagesCountInRange);
        if ($currentRange == 1) {
            $rangeEnd = $pagesCount < $pagesCountInRange ? $pagesCount : $pagesCountInRange;

            return range(1, $rangeEnd);
        }
        $rangeStart = ($currentRange - 1) * $pagesCountInRange + 1;
        if ($currentRange < $ragesCount) {
            return range($rangeStart, $rangeStart + $pagesCountInRange - 1);
        } else {
            return range($rangeStart, $pagesCount);
        }
    }