/*
Render pagination buttons

@param       $items
@param int   $page
@param int   $perPage
@param       $path
@param array $componentOptions
1486
public function pagination($items, $page = 1, $perPage = 25, $path = '', array $componentOptions = [])
    {
        $items = $items instanceof Collection ? $items : Collection::make($items);

        $paginator = (new LengthAwarePaginator($items, $items->count(), (int) $perPage, (int) $page))
            ->withPath($path);

        return $paginator->render('bootstrap::render.pagination', $componentOptions);
    }
196247
public function paginate($page, $itemsOnPage = 30)
    {
        $paginator = new Paginator($this);
        return $paginator
            ->setCurrentPage($page)
            ->setItemsOnPage($itemsOnPage);
    }
799234
public function paginate($perPage = null, $columns = array('*'))
	{
		$perPage = $perPage ?: $this->model->getPerPage();
		
		$paginator = $this->connection->getPaginator();
		
		$total = $this->getPaginationCount();
		
		return $paginator->make($this->get($columns)->all(), $total, $perPage);
	}
1041954
protected function paginate($keys, $page, $perPage)
    {
        return new LengthAwarePaginator(
            $this->chunk($keys, $page, $perPage),
            count($keys),
            20,
            $page,
            [
                'path' => Paginator::resolveCurrentPath(),
                'pageName' => 'page',
            ]
        );
    }
81381
public function forPage($page, $itemsPerPage) {
        $this
            ->specificationQuery
            ->offset(($page - 1) * $itemsPerPage)
            ->limit($itemsPerPage);
        return $this;
    }
783188
public function determineChildrenPagination($perPage, HasMany $children)
    {
        if ($perPage === false)
        {
            return $children;
        }

        return is_null($perPage) ?
            $children->get() :
            $children->paginate($perPage);
    }
361135
public function addItemsPerPageSelector($items = [10, 25, 50, 100], $label = 'Item per pages:')
    {
        if ($ipp = $this->container->stickyGet('ipp')) {
            $this->ipp = $ipp;
        } else {
            $this->ipp = $items[0];
        }

        $pageLength = $this->paginator->add(['ItemsPerPageSelector', 'pageLengthItems' => $items, 'label' => $label, 'currentIpp' => $this->ipp], 'afterPaginator');
        $this->paginator->template->trySet('PaginatorType', 'ui grid');

        if ($sortBy = $this->getSortBy()) {
            $pageLength->stickyGet($this->name.'_sort', $sortBy);
        }

        $pageLength->onPageLengthSelect(function ($ipp) use ($pageLength) {
            $this->ipp = $ipp;
            $this->setModelLimitFromPaginator();
            //add ipp to quicksearch
            if ($this->quickSearch instanceof jsSearch) {
                $this->container->js(true, $this->quickSearch->js()->atkJsSearch('setUrlArgs', ['ipp', $this->ipp]));
            }
            $this->applySort();

            //return the view to reload.
            return $this->container;
        });

        return $this;
    }
360262
function renderPages($itemsCount, $itemsPerPage, $pageCount, $Descending = false, $sub_prefix='')
    {
        $prefix = empty($sub_prefix)?str_repeat('sub_', $this->sub):$sub_prefix;
        if ($itemsCount > $itemsPerPage)
        {
            $result = '<div class="admListPages">'.strPages;
            if ($Descending)
            {
                $forFrom = $pageCount;
                $forTo = 0;
                $forDelta = -1;
            }
            else
            {
                $forFrom = 1;
                $forTo = $pageCount+1;
                $forDelta = 1;
            }
            $pageIndex = arg($prefix.'pg') ? arg($prefix.'pg', 'int') : $forFrom;
            for ($i = $forFrom; $i != $forTo; $i += $forDelta)
            {
                if ($i == $pageIndex)
                {
                    $result .= '<span class="selected">&nbsp;'.$i.'&nbsp;</span>';
                }
                else
                {
                    $result .= '<a href="'.$this->url(array($prefix.'pg' => $i)).'">&nbsp;'.$i.'&nbsp;</a>';
                }
            }
            $result .= "</div>\n";
            return $result;
        }
        else
        {
            return '';
        }
    }
215611
public static function menu(array $items, $htmlOptions = array(), $depth = 0)
    {
        // todo: consider making this method protected.
        if (!empty($items)) {
            $htmlOptions['role'] = 'menu';
            $output = self::openTag('ul', $htmlOptions);
            foreach ($items as $itemOptions) {
                if (is_string($itemOptions)) {
                    if ($itemOptions == '---') {
                        $output .= self::menuDivider();
                    } else {
                        $output .= $itemOptions;
                    }
                } else {
                    if (TbArray::popValue('visible', $itemOptions, true)  === false) {
                        continue;
                    }
                    // 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, '');
                    if (TbArray::popValue('active', $itemOptions, false)) {
                        self::addCssClass('active', $itemOptions);
                    }
                    if (TbArray::popValue('disabled', $itemOptions, false)) {
                        self::addCssClass('disabled', $itemOptions);
                    }
                    if (!isset($itemOptions['linkOptions'])) {
                        $itemOptions['linkOptions'] = array();
                    }
                    $icon = TbArray::popValue('icon', $itemOptions);
                    if (!empty($icon)) {
                        $label = self::icon($icon) . ' ' . $label;
                    }
                    $items = TbArray::popValue('items', $itemOptions, array());
                    $url = TbArray::popValue('url', $itemOptions, false);
                    if (empty($items)) {
                        if (!$url) {
                            $output .= self::menuHeader($label);
                        } else {
                            $itemOptions['linkOptions']['tabindex'] = -1;
                            $output .= self::menuLink($label, $url, $itemOptions);
                        }
                    } else {
                        $output .= self::menuDropdown($label, $url, $items, $itemOptions, $depth);
                    }
                }
            }
            $output .= '</ul>';
            return $output;
        } else {
            return '';
        }
    }
1202987
protected function paginator($items, $total, $per_page, $current_page, array $options) {
        return new LengthAwarePaginator($items, $total, $per_page, $current_page, $options);
    }
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);
    }
553699
protected function renderItems($items) {
		
		foreach ($items as $i => $item) {
			if (!is_array($item)) {
				continue;
			}

			if (isset($item['visible']) && $item['visible'] === false) {
				continue;
			}

			if (!isset($item['itemOptions'])) {
				$item['itemOptions'] = array();
			}

			$classes = array('item');

			if ($i === 0) {
				$classes[] = 'active';
			}

            $classes = implode(' ', $classes);
            if (isset($item['itemOptions']['class'])) {
                $item['itemOptions']['class'] .= ' ' . $classes;
            } else {
                $item['itemOptions']['class'] = $classes;
            }

			echo CHtml::openTag('div', $item['itemOptions']);

			if (isset($item['image'])) {
				if (!isset($item['alt'])) {
					$item['alt'] = '';
				}

				if (!isset($item['imageOptions'])) {
					$item['imageOptions'] = array();
				}

                /**
                 * Is this image should be a link?
                 * @since 2.1.0
                 */
                if (isset($item['link'])) {
                    // Any kind of link options
                    if (!isset($item['linkOptions']) || !is_array($item['linkOptions'])) {
                        $item['linkOptions'] = array();
                    }

                    // URL
                    if(is_array($item['link'])) {
                        $route = isset($item['link'][0]) ? $item['link'][0] : '';
                        $item['linkOptions']['href'] = Yii::app()->createUrl($route, array_splice($item['link'], 1));
                    } else {
                        $item['linkOptions']['href'] = $item['link'];
                    }

                    // Print out 'A' tag
                    echo CHtml::openTag('a', $item['linkOptions']);
                }

				echo CHtml::image($item['image'], $item['alt'], $item['imageOptions']);

                if (isset($item['link'])) {
                    echo '</a>';
                }
			}

			if (!empty($item['caption']) && (isset($item['label']) || isset($item['caption']))) {
				if (!isset($item['captionOptions'])) {
					$item['captionOptions'] = array();
				}

				if (isset($item['captionOptions']['class'])) {
					$item['captionOptions']['class'] .= ' carousel-caption';
				} else {
					$item['captionOptions']['class'] = 'carousel-caption';
				}

				echo CHtml::openTag('div', $item['captionOptions']);

				if (isset($item['label'])) {
					echo '<h3>' . $item['label'] . '</h3>';
				}

				if (isset($item['caption'])) {
					echo '<p>' . $item['caption'] . '</p>';
				}

				echo '</div>';
			}
			echo '</div>';
		}
	}
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,
        ]);
    }
457160
public function paginate(?int $itemsPerPage = null, array $options = [])
	{
		$count = $this->paginationCount();

		$pagination = static::getPaginationFactory()->create($count, $itemsPerPage, $options);

		if($count > 0)
		{
			$results = $this->limit($pagination->limit())->offset($pagination->offset())->all();
		}
		else
		{
			$results = $this->createResultSet([]);
		}

		$results->setPagination($pagination);

		return $results;
	}
335536
private function _getPaginatorPresenter(array $items)
    {
        if (!$this->_paginate) {
            return null;
        }

        $params = Input::get();
        if (!empty($params)) {
            // There are parameters in the URL - pass them to paginator
            if (isset($params['page'])) {
                // We don't need that - paginator will add new one
                unset($params['page']);
            }
        }

        // Prepare paginator and pass it to presenter
        $paginator = new LengthAwarePaginator($items, $this->_totalItems, $this->_perPage, $this->_page, [
            'path' => Request::url(),
        ]);
        $paginator->appends($params);
        return new $this->_paginationPresenter($paginator);
    }
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;
	}
90460
public function paginate(
        $perPage = null,
        $columns = null,
        $pageName = null,
        $page = null,
        bool $lengthAware = true
    ) {
        $perPage = is_null($perPage) ? config('lego.paginator.per-page') : $perPage;
        $pageName = is_null($pageName) ? config('lego.paginator.page-name') : $pageName;
        $columns = is_null($columns) ? ['*'] : $columns;
        $page = $page ?: Request::query($pageName, 1);

        if ($lengthAware) {
            $this->paginator = $this->createLengthAwarePaginator($perPage, $columns, $pageName, $page);
        } else {
            $this->paginator = $this->createLengthNotAwarePaginator($perPage, $columns, $pageName, $page);
        }

        $this->paginator->setCollection(
            $this->paginator->getCollection()->map(function ($row) {
                return Finder::createStore($row);
            })
        );

        return $this->paginator;
    }