Returns an array with the keys "pages", "current", "numberOfPages", "nextPage" & "previousPage"

@return array
350730
protected function buildPagination()
    {
        $this->calculateDisplayRange();
        $pages = array();
        for ($i = $this->displayRangeStart; $i <= $this->displayRangeEnd; $i++) {
            $pages[] = array('number' => $i, 'isCurrent' => ($i === $this->currentPage));
        }
        $pagination = array(
            'pages' => $pages,
            'current' => $this->currentPage,
            'numberOfPages' => $this->numberOfPages,
            'displayRangeStart' => $this->displayRangeStart,
            'displayRangeEnd' => $this->displayRangeEnd,
            'hasLessPages' => $this->displayRangeStart > 2,
            'hasMorePages' => $this->displayRangeEnd + 1 < $this->numberOfPages
        );
        if ($this->currentPage < $this->numberOfPages) {
            $pagination['nextPage'] = $this->currentPage + 1;
        }
        if ($this->currentPage > 1) {
            $pagination['previousPage'] = $this->currentPage - 1;
        }
        return $pagination;
    }
641401
public function getNextPageParams()
    {
        $limit = $this->limit <= 0 ? $this->count : $this->limit;
        $next_url = $this->offset_key
            . $this->offset
            . $this->limit_key
            . $limit;

        if ($this->count <= ($this->offset + $limit)) {
           return false;
        }

        if ($this->count >= $limit) {
            $next_url = $this->offset_key
                . ($this->offset + $limit)
                . $this->limit_key
                . $limit;
        }

        return $next_url;
    }
1179415
public function getBody()
    {

        return [
            'meta' => [
                'type' => $this->pageModel->getType(),
                'paginated' => true,
                'total' => (int)$this->pageModel->getTotal(),
                'page' => (int)$this->pageModel->getCurrentPage(),
                'pageSize' => (int)$this->pageModel->getPageSize(),
                'numberOfPages' => (int)$this->pageModel->numberOfPages(),
                'lastPage' => (bool)$this->pageModel->lastPage()
            ],
            'data' => $this->pageModel->getResults()
        ];
    }
1138558
protected function createPageLinks()
    {
        if (($pageCount = $this->getPageCount()) <= 1) {
            return array();
        }

        list($beginPage, $endPage) = $this->getPageRange();

        $currentPage = $this->getCurrentPage(false); // currentPage is calculated in getPageRange()
        $links = array();

        // first page
        if (!$this->hideFirstAndLast) {
            $links[] = $this->createPageLink($this->firstPageLabel, 0, $currentPage <= 0, false);
        }

        // prev page
        if (($page = $currentPage - 1) < 0) {
            $page = 0;
        }

        $links[] = $this->createPageLink($this->prevPageLabel, $page, $currentPage <= 0, false);

        // internal pages
        for ($i = $beginPage; $i <= $endPage; ++$i) {
            $links[] = $this->createPageLink($i + 1, $i, false, $i == $currentPage);
        }

        // next page
        if (($page = $currentPage + 1) >= $pageCount - 1) {
            $page = $pageCount - 1;
        }

        $links[] = $this->createPageLink($this->nextPageLabel, $page, $currentPage >= $pageCount - 1, false);

        // last page
        if (!$this->hideFirstAndLast) {
            $links[] = $this->createPageLink(
                $this->lastPageLabel,
                $pageCount - 1,
                $currentPage >= $pageCount - 1,
                false
            );
        }

        return $links;
    }
171721
public function getResults()
    {
        $skip = ($this->page-1)*$this->limit;
        
        $cursor = $this->getCursor();
        $cursor->skip($skip);

        $results = array();
        $i = 0;

        while($cursor->valid() && $cursor->current() && $i++ < $this->limit) {

            $object = new $this->modelName();
            $object->writeAttributes($cursor->current());

            $pseudoCursor = new \stdClass();
            foreach ($object as $key => $value) {
                $pseudoCursor->$key = $value;
            }

            $results[] = $pseudoCursor;
            $cursor->skip();
        }

        return $results;
    }
820953
public function getItemsPerPageList()
	{
		if (empty($this->items_per_page_list)) {
			$this->setItemsPerPageList([10, 20, 50], true);
		}

		$list = array_flip($this->items_per_page_list);

		foreach ($list as $key => $value) {
			$list[$key] = $key;
		}

		if (array_key_exists('all', $list)) {
			$list['all'] = $this->getTranslator()->translate('ublaboo_datagrid.all');
		}

		return $list;
	}
432359
public function getPagesAsOptions()
    {
        $pages = [];
        $publishedPages = $this->repo->all();

        foreach ($publishedPages as $page) {
            $pages[$page->title] = $page->id;
        }

        return $pages;
    }
1358098
public function getRelatedPages()
    {
        $pages = ArrayList::create();

        foreach ($this->Sets() as $documentSet) {
            /** @var DocumentSet $documentSet */
            $pages->add($documentSet->Page());
        }
        $pages->removeDuplicates();

        $this->extend('updateRelatedPages', $pages);

        return $pages;
    }
341153
protected function getListPage()
    {
        $id = $this->getParam(0);

        if (!isset($id)) {
            return $this->page->getList(array('limit' => $this->getLimit()));
        }

        if (!is_numeric($id)) {
            $this->errorAndExit($this->text('Invalid argument'));
        }

        if ($this->getParam('user')) {
            return $this->page->getList(array('user_id' => $id, 'limit' => $this->getLimit()));
        }

        if ($this->getParam('category')) {
            return $this->page->getList(array('category_id' => $id, 'limit' => $this->getLimit()));
        }

        if ($this->getParam('store')) {
            return $this->page->getList(array('store_id' => $id, 'limit' => $this->getLimit()));
        }

        $result = $this->page->get($id);

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        return array($result);
    }
104392
public function toArray()
	{
		return array(
			'total' => $this->total, 'per_page' => $this->perPage,
			'current_page' => $this->currentPage, 'last_page' => $this->lastPage,
			'from' => $this->from, 'to' => $this->to, 'data' => $this->getCollection()->toArray(),
		);
	}
1021405
protected function getPagesArrayText()
    {
        if (empty($this->pages)) {
            return Builder::getArray(array(0 => ''), true);
        }
        $pages = array();
        foreach ($this->pages as $page) {
            $pages[$page->getPageNumber()] = $page->getControl()
                                                  ->getId();
        }
        return Builder::getArray($pages, true);
    }
142092
protected function getPages(): array
    {
        $pages = [];

        $pages['previous_page'] = $this->pagerfanta->hasPreviousPage() ?
            $this->generateUrl($this->pagerfanta->getPreviousPage()) :
            false;

        $pages['first_page'] = $this->startPage > 1 ? $this->generateUrl(1) : false;
        $pages['mobile_first_page'] = $this->pagerfanta->getCurrentPage() > 2 ? $this->generateUrl(1) : false;

        $pages['second_page'] = $this->startPage === 3 ? $this->generateUrl(2) : false;

        $pages['separator_before'] = $this->startPage > 3;

        $middlePages = [];
        for ($i = $this->startPage, $end = $this->endPage; $i <= $end; ++$i) {
            $middlePages[$i] = $this->generateUrl($i);
        }

        $pages['middle_pages'] = $middlePages;

        $pages['separator_after'] = $this->endPage < $this->pagerfanta->getNbPages() - 2;

        $pages['second_to_last_page'] = $this->endPage === $this->pagerfanta->getNbPages() - 2 ?
            $this->generateUrl($this->pagerfanta->getNbPages() - 1) :
            false;

        $pages['last_page'] = $this->pagerfanta->getNbPages() > $this->endPage ?
            $this->generateUrl($this->pagerfanta->getNbPages()) :
            false;

        $pages['mobile_last_page'] = $this->pagerfanta->getCurrentPage() < $this->pagerfanta->getNbPages() - 1 ?
            $this->generateUrl($this->pagerfanta->getNbPages()) :
            false;

        $pages['next_page'] = $this->pagerfanta->hasNextPage() ?
            $this->generateUrl($this->pagerfanta->getNextPage()) :
            false;

        return $pages;
    }
623269
public function getTotalPages()
    {
        // Pages before
        $pages = ceil(($this->getFirstShown() - 1) / $this->getItemsPerPage());

        // Current page
        $pages++;

        // Pages after
        $pages += ceil(($this->getTotalRecords() - $this->getLastShown()) / $this->getItemsPerPage());

        return (int) $pages;
    }
831787
protected function getKeyAsArray()
    {
        $result = [];
        if ( ! empty( $this->compositeKey )) {
            foreach ($this->compositeKey as $key) {
                $result[$key] = $this->{$key};
            }
        } else {
            $result[$this->getKeyName()] = $this->getKey();
        }

        return $result;
    }
312781
private function getPagesSeeds()
    {
        return [
            [
                'name'        => 'Pages - List all pages',
                'description' => 'Allow to list all pages.',
                'slug'        => PagesPolicy::PERMISSION_LIST,
            ],
            [
                'name'        => 'Pages - View a page',
                'description' => 'Allow to display a page.',
                'slug'        => PagesPolicy::PERMISSION_SHOW,
            ],
            [
                'name'        => 'Pages - Create a page',
                'description' => 'Allow to create a page.',
                'slug'        => PagesPolicy::PERMISSION_CREATE,
            ],
            [
                'name'        => 'Pages - Update a page',
                'description' => 'Allow to update a page.',
                'slug'        => PagesPolicy::PERMISSION_UPDATE,
            ],
            [
                'name'        => 'Pages - Delete a page',
                'description' => 'Allow to delete a page.',
                'slug'        => PagesPolicy::PERMISSION_DELETE,
            ],
        ];
    }
815820
public function getCurrentPageAncestry()
    {
        $ancestry = ViewTools::singleton()->convertClass(
            ClassTools::singleton()->getObjectAncestry($this->getCurrentPageClass(), Page::class, true)
        );
        
        return ViewTools::singleton()->array2att($ancestry);
    }
851038
public function getLimits()
    {
        $totalPages = $this->getTotalPages();

        $this->currentPage = ($this->currentPage > $totalPages) ? $totalPages : $this->currentPage;

        $dLimit = ($this->currentPage - 1) * $this->itemsPerPage;

        return array($dLimit, $this->itemsPerPage);
    }