Initializes a LengthAwarePaginator instance

@param array|object $items
@param int          $resultsPerPage Define how many items we want to be visible in each page

@return LengthAwarePaginator
491436
public function LengthAwarePaginator($items, $resultsPerPage = 4)
    {
        //Get current page form url e.g. &page=6
        $currentPage = LengthAwarePaginator::resolveCurrentPage();

        //Create a new Laravel collection from data
        $collection = new Collection($items);

        //Slice the collection to get the items to display in current page
        $currentPageSearchResults = $collection->slice(($currentPage - 1) * $resultsPerPage, $resultsPerPage) -> all();

        //Create our paginator and pass it to the view
        return new LengthAwarePaginator($currentPageSearchResults, count($collection), $resultsPerPage);
    }
1372396
public function simplePaginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
    {
        $page = $page ?: Paginator::resolveCurrentPage($pageName);

        $perPage = $perPage ?: $this->model->getPerPage();

        // Next we will set the limit and offset for this query so that when we get the
        // results we get the proper section of results. Then, we'll create the full
        // paginator instances for these results with the given page and per page.
        $this->skip(($page - 1) * $perPage)->take($perPage + 1);

        return $this->simplePaginator($this->get($columns), $perPage, $page, [
            'path' => Paginator::resolveCurrentPath(),
            'pageName' => $pageName,
        ]);
    }
1121137
public function setData($totalItems, $currentPage, $itemsPerPage = 12, $maxPages = 10)
    {
        $this->totalItems = $totalItems;
        $this->currentPage = $currentPage;
        $this->itemsPerPage = $itemsPerPage;

//        if ($maxPages < 3) {
//            throw new \InvalidArgumentException('Max pages has to be more than 3.');
//        }
        $this->maxPages = $maxPages;

        $this->numPages = (int) ceil($this->totalItems/$this->itemsPerPage);
    }
1277725
public function setItemsPerPage( $items_per_page )
	{
		if ( !is_int( $items_per_page ) )
		{
			trigger_error( 'Pagination setItemsPerPage: Items per page must be an integer.' );
			return false;
		}

		if ( $items_per_page <= 0 )
		{
			trigger_error( 'Pagination setItemsPerPage: Items per page must be a positive integer.' );
			return false;
		}

		$this->items_per_page = $items_per_page;
	}
595956
public function paginate($page = 1, $perPage = 15)
    {
        if ($this->paginatorCreator) {
            return call_user_func($this->paginatorCreator, $page, $perPage);
        }

        $all = iterator_to_array($this->getIterator());

        return array_slice($all, ($page-1)*$perPage, $perPage);
    }
81381
public function forPage($page, $itemsPerPage) {
        $this
            ->specificationQuery
            ->offset(($page - 1) * $itemsPerPage)
            ->limit($itemsPerPage);
        return $this;
    }
717044
protected function countPageCount($sectionId, $itemsPerPage)
    {
        /* @var Gallery_Entity_Table_Image $table */
        $table = ORM::getTable(Eresus_Plugin_Registry::getInstance()->load('gallery'), 'Image');
        return ceil($table->countInSection($sectionId) / $itemsPerPage);
    }
280250
public function paginate($perPage = null, $pageName = 'page', $page = null)
    {
        $engine = $this->engine();

        $page = $page ?: Paginator::resolveCurrentPage($pageName);

        $perPage = $perPage ?: $this->model->getPerPage();

        $results = $this->model->newCollection($engine->map(
            $this, $rawResults = $engine->paginate($this, $perPage, $page), $this->model
        )->all());

        $paginator = (new LengthAwarePaginator($results, $engine->getTotalCount($rawResults), $perPage, $page, [
            'path' => Paginator::resolveCurrentPath(),
            'pageName' => $pageName,
        ]));

        return $paginator->appends('query', $this->query);
    }
937521
public function paginate($perPage = 15, $columns = array('*'))
	{
		$paginator = $this->connection->getPaginator();

		if (isset($this->groups))
		{
			return $this->groupedPaginate($paginator, $perPage, $columns);
		}
		else
		{
			return $this->ungroupedPaginate($paginator, $perPage, $columns);
		}
	}
1325919
public function paginate($page, $perPage = null)
    {
        $page = (int)$page;
        if ($page < 1) {
            $page = 1;
        }
        
        if ($perPage === null) {
            if (!$perPage = $this->select->getRawState('limit')) {
                throw new Exception\InvalidArgumentException(
                    "No per page passed and no limit is set"
                );
            }
        }
        
        $modelClass = $this->modelClass;
        $paginator  = new Paginator($this->select, $modelClass::adapter());
        $items      = $paginator->getItems(($page - 1) * $perPage, $perPage);
        $collection = $this->buildCollection($items->toArray());
        
        $collection->setPage($page);
        $collection->setPerPage($perPage);
        $collection->setPaginator($paginator);
        
        return $collection;
    }
817462
protected function simplePaginator($items, $perPage, $currentPage, $options)
    {
        return Container::getInstance()->makeWith(Paginator::class, compact(
            'items', 'perPage', 'currentPage', 'options'
        ));
    }
154567
public function make(array $items, $total, $perPage)
	{
		$paginator = new Paginator($this, $items, $total, $perPage);

		return $paginator->setupPaginationContext();
	}
34601
public function pagination($perPage = 15)
    {

        $currentPageFinder = Paginator::getCurrentPageFinder();
        $pathFinder = Paginator::getRequestPathFinder();


        $pagination = new Paginator($perPage, call_user_func($currentPageFinder), [
            'pageName' => 'page',
            'path' => call_user_func($pathFinder),
        ]);

        $pagination->setMode(Paginator::MODE_STANDART);
        $count = $this->build()->rowCount();

        $pagination->count($count);

        return $pagination;
    }
944868
public static function paginated($perPage, $item = [], $options = [], $query = null)
    {
        $request = new Request();

        if (is_null($query)) {
            $query = 'page';
        }

        if (!count($item)) {
            $item = static::all();
        }

        $currentPage = $request->input($query, null);
        if (is_null($currentPage)) {
            $currentPage = 1;
        }

        $collection = new Collection($item);
        $currentPageResults = $collection->slice(($currentPage - 1) * $perPage, $perPage)->all();

        if (!isset($options['path'])) {
            $options['path'] = $request->path();
        }

        return new Paginator(
            $currentPageResults, count($collection), $perPage, $currentPage, $options
        );
    }
696408
public static function pagination(array $items, $htmlOptions = array())
    {
        if (!empty($items)) {
            self::addCssClass('pagination', $htmlOptions);
            $size = TbArray::popValue('size', $htmlOptions);
            if (!empty($size)) {
                self::addCssClass('pagination-' . $size, $htmlOptions);
            }
            $align = TbArray::popValue('align', $htmlOptions);
            if (!empty($align)) {
                self::addCssClass('pagination-' . $align, $htmlOptions);
            }
            $listOptions = TbArray::popValue('listOptions', $htmlOptions, array());
            $output = self::openTag('div', $htmlOptions);
            $output .= self::openTag('ul', $listOptions);
            foreach ($items as $itemOptions) {
                // todo: consider removing the support for htmlOptions.
                $options = TbArray::popValue('htmlOptions', $itemOptions, array());
                if (!empty($options)) {
                    $itemOptions = TbArray::merge($options, $itemOptions);
                }
                $label = TbArray::popValue('label', $itemOptions, '');
                $url = TbArray::popValue('url', $itemOptions, false);
                $output .= self::paginationLink($label, $url, $itemOptions);
            }
            $output .= '</ul></div>';
            return $output;
        }
        return '';
    }
783188
public function determineChildrenPagination($perPage, HasMany $children)
    {
        if ($perPage === false)
        {
            return $children;
        }

        return is_null($perPage) ?
            $children->get() :
            $children->paginate($perPage);
    }
1010826
private function getOverflowItems(ResultSet $resultSet): Generator
    {
        $includedPositions = [];
        foreach ($resultSet->getResults() as $result) {
            if ($result->getItem() instanceof ManualItem) {
                $includedPositions[] = $result->getItem()->getCollectionItem()->getPosition();
            }

            if ($result->getSubItem() instanceof ManualItem) {
                $includedPositions[] = $result->getSubItem()->getCollectionItem()->getPosition();
            }
        }

        foreach ($resultSet->getCollection()->getItems() as $item) {
            if (!in_array($item->getPosition(), $includedPositions, true)) {
                yield $item;
            }
        }
    }