Handles the pagination.

@return \Scara\Pagination\Pagination
508418
public function paginate()
    {
        $count = count($this->_model->all());
        $this->_totalPages = ceil($count / $this->_limit);
        $page_at_offset = floor($this->_page + 1 / $this->_limit);
        $this->_offset = ($page_at_offset - 1) * $this->_limit;

        $this->_results = $this->_model->select($this->_capsule, $this->_limit, $this->_offset);

        return $this;
    }
1030915
public function getPaginationMetaData()
    {
        $pagination = [
            'count' => $this->count,
            'offset' => $this->offset,
            'limit' => $this->limit,
            'next_page_params' => $this->getNextPageParams(),
        ];

        return $pagination;
    }
872952
public function PaginatedList()
    {
        $allPosts = $this->blogPosts ?: ArrayList::create();
        $posts = PaginatedList::create($allPosts);

        // Set appropriate page size
        if ($this->PostsPerPage > 0) {
            $pageSize = $this->PostsPerPage;
        } elseif ($count = $allPosts->count()) {
            $pageSize = $count;
        } else {
            $pageSize = 99999;
        }
        $posts->setPageLength($pageSize);

        // Set current page
        $start = (int)$this->request->getVar($posts->getPaginationGetVar());
        $posts->setPageStart($start);

        return $posts;
    }
805491
private function getPaginator()
    {
        $perPage = 40;
        $page = input('page', 1);
        $itemsObj = $this->fetchEntries();
        $items = $itemsObj['items'];
        $total = $itemsObj['total'];
        $baseUrl = config('app.url') . "/admin/accounts/clients";

        // paginator
        $paginator = new LengthAwarePaginator($items->forPage($page, $perPage), count($items),
            $perPage, $page, ['path' => $baseUrl, 'originalEntries' => $total]);

        return $paginator;
    }
398786
private function getPagination()
    {
        if($this->pagination == null) {
            $this->pagination = new \Friday\Helper\Pagination();
        }
        return $this->pagination;
    }
298034
public function paginate()
    {
        $this->count = $this->query->get()->count();
        $this->limit = $this->limit ?: $this->count;
        $this->query->skip($this->offset)->take($this->limit);
    }
870701
public function handleSection() {

        if ($ClassName = $this->owner->getRequest()->param('SECTIONNAME')) {
            $sections = $this->owner->data()->Sections();
            if ($section = $sections->filter(array('ClassName' => $ClassName))->first()) {
                if ($action = $this->owner->getRequest()->param('ACTION')) {
                    return $section->getController()->$action();
                }
            }
        }
        // return $section->getController();
    }
384514
public function pagination() {
		global $post, $page, $numpages, $multipage;
		$post = $this;
		$ret = array();
		if ( $multipage ) {
			for ( $i = 1; $i <= $numpages; $i++ ) {
				$link = self::get_wp_link_page($i);
				$data = array('name' => $i, 'title' => $i, 'text' => $i, 'link' => $link);
				if ( $i == $page ) {
					$data['current'] = true;
				}
				$ret['pages'][] = $data;
			}
			$i = $page - 1;
			if ( $i ) {
				$link = self::get_wp_link_page($i);
				$ret['prev'] = array('link' => $link);
			}
			$i = $page + 1;
			if ( $i <= $numpages ) {
				$link = self::get_wp_link_page($i);
				$ret['next'] = array('link' => $link);
			}
		}
		return $ret;
	}
1053216
public function setPagination()
    {

        $total = $this->getListTotal();

        if (empty($total))
            return null;

        //Get the current page state from the request;
        $limit = $this->getListLimit();
        $current = $this->getState("currentpage", 1);
        $pages = array();

        //@TODO: Calculates the pages from a recordset or an array of results
        $pages['total'] = ceil($total / $limit);
        $pages['limit'] = $limit;

        //Get the real path to the current page
        $route = $this->container->router->getMatchedRoute();


        $pages['current'] = $route->getURLfromPathWithValues(["page" => strval($current)]);
        //Previous page link
        if (intval($current - 1) > 0):
            $pages['previous'] = $route->getURLfromPathWithValues(["page" => strval($current - 1)] );
        endif;
        //Next page link
        if (intval($current + 1) <= $pages['total']):
            $pages['next'] = $route->getURLfromPathWithValues(["page" => strval($current + 1)] );
        endif;

        //Build the pages;
        for ($i = 0; $i < $pages['total']; $i++):
            $page = $i + 1;
            $pages['pages'][] = array(
                "page_title" => strval($page),
                "page_link" => $route->getURLfromPathWithValues(["page" => $page] ),
                "page_state" => ($page == $current) ? "active" : null,
            );
        endfor;

        //Sets the pagination output;
        if (sizeof($pages['pages']) > 1)
            $this->pagination = $pages;

    }
641109
public function index()
    {
        // For single-item display only, redirect to the relevant show/edit page
        if ($this->modelInformation->single) {
            return $this->returnViewForSingleDisplay();
        }

        $this->resetStateBeforeIndexAction()
             ->checkListParents()
             ->applyListParentContext()
             ->checkActiveSort()
             ->checkScope()
             ->checkFilters()
             ->checkActivePage();

        $totalCount  = $this->getTotalCount();
        $scopeCounts = $this->getScopeCounts();

        $this->applySort()
             ->applyScope($this->modelRepository);

        $query = $this->getModelRepository()->query();

        $this->applyFilter($query)
             ->applyListParentToQuery($query);

        $records = $query->paginate($this->getActualPageSize(), ['*'], 'page', $this->getActualPage());

        // Check and whether page is out of bounds and adjust
        if ($this->getActualPage() > $records->lastPage()) {
            $records = $query->paginate($this->getActualPageSize(), ['*'], 'page', $records->lastPage());
        }

        $currentCount = method_exists($records, 'total') ? $records->total() : 0;

        return view($this->getIndexView(), [
            'moduleKey'           => $this->moduleKey,
            'routePrefix'         => $this->routePrefix,
            'permissionPrefix'    => $this->permissionPrefix,
            'model'               => $this->modelInformation,
            'records'             => $records,
            'recordReferences'    => $this->getReferenceRepository()->getReferencesForModels($records->items()),
            'totalCount'          => $totalCount,
            'currentCount'        => $currentCount,
            'listStrategies'      => $this->getListColumnStrategyInstances(),
            'sortColumn'          => $this->getActualSort(),
            'sortDirection'       => $this->getActualSortDirection(),
            'pageSize'            => $this->getActualPageSize(),
            'pageSizeOptions'     => $this->getPageSizeOptions(),
            'filterStrategies'    => $this->renderedListFilterStrategies($this->getActiveFilters()),
            'activeScope'         => $this->getActiveScope(),
            'scopeCounts'         => $scopeCounts,
            'unconditionalDelete' => $this->isUnconditionallyDeletable(),
            'defaultRowAction'    => $this->getDefaultRowActionInstance(),
            'hasActiveListParent' => (bool) $this->listParentRelation,
            'listParents'         => $this->listParents,
            'topListParentOnly'   => $this->showsTopParentsOnly(),
            'draggableOrderable'  => $this->isListOrderDraggable($totalCount, $currentCount),
            'availableExportKeys' => $this->getAvailableExportStrategyKeys(),
        ]);
    }
340079
protected function createPaginator()
    {
        $paginator = new Paginator($this->getLimit());
        $paginator = $paginator->withPage($this->getPage());

        return $paginator;
    }
681819
public function index()
    {
        $parameters = $this->request->getParameters();
        $paginator = $this->repository->getPaginatedCollection($parameters);
        return $this->paginatedResponse($paginator);
    }
12658
public function sqlPagination()
    {
        $pager = $this->pagination();
        if (!$pager instanceof DatabasePagination) {
            $pager = $this->createPagination($pager->data());
        }

        $sql = $pager->sql();
        if (strlen($sql) > 0) {
            $sql = ' '.$sql;
        }

        return $sql;
    }
17744
protected function setHeaders()
    {
        \pwf\basic\Application::$instance
            ->getResponse()
            ->setHeaders([
                'x-pagination-current-page: '.$this->getPage(),
                'x-pagination-page-count: '.$this->getPageQty(),
                'x-pagination-per-page: '.max($this->getLimit(), 1),
                'x-pagination-total-count: '.$this->count()
        ]);
        return $this;
    }
887447
public function index()
    {
        $page = $this->request->getQuery('page', 1);

        $this->paginate['order'] = ['tag' => 'ASC'];

        //Limit X4
        $this->paginate['limit'] = $this->paginate['maxLimit'] = $this->paginate['limit'] * 4;

        //Sets the cache name
        $cache = sprintf('tags_limit_%s_page_%s', $this->paginate['limit'], $page);

        //Tries to get data from the cache
        list($tags, $paging) = array_values(Cache::readMany(
            [$cache, sprintf('%s_paging', $cache)],
            $this->PostsTags->getCacheName()
        ));

        //If the data are not available from the cache
        if (empty($tags) || empty($paging)) {
            $query = $this->PostsTags->Tags->find('active');
            $tags = $this->paginate($query);

            //Writes on cache
            Cache::writeMany([
                $cache => $tags,
                sprintf('%s_paging', $cache) => $this->request->getParam('paging'),
            ], $this->PostsTags->getCacheName());
        //Else, sets the paging parameter
        } else {
            $this->request = $this->request->withParam('paging', $paging);
        }

        $this->set(compact('tags'));
    }
216345
public function currentPage()
    {
        if (isset($this->pages[self::NEXT])) {
            $page = $this->pages[self::NEXT] - 1;
        } else {
            $page = $this->pages[self::PREV] + 1;
        }

        return $page;
    }
487307
public function render()
    {
        $params = $this->toArray();
        $params['collection'] = $this->getDisplay()->getCollection();
        $params['pagination'] = null;

        if ($params['collection'] instanceof \Illuminate\Contracts\Pagination\Paginator) {
            if (class_exists('Illuminate\Pagination\BootstrapThreePresenter')) {
                $params['pagination'] = (new \Illuminate\Pagination\BootstrapThreePresenter($params['collection']))->render();
            } else {
                $params['pagination'] = $params['collection']->render();
            }
        }

        return app('sleeping_owl.template')->view($this->getView(), $params)->render();
    }