Bootstrap\View\Helper\BootstrapPaginatorHelper::numbers PHP Метод

numbers() публичный Метод

Get pagination link list.
public numbers ( array $options = [] )
$options array Options for link element Extra options: - size small/normal/large (default normal)
    public function numbers(array $options = [])
    {
        $defaults = ['before' => null, 'after' => null, 'model' => $this->defaultModel(), 'modulus' => 8, 'first' => null, 'last' => null, 'url' => [], 'prev' => null, 'next' => null, 'class' => '', 'size' => false];
        $options += $defaults;
        $options = $this->addClass($options, 'pagination');
        switch ($options['size']) {
            case 'small':
                $options = $this->addClass($options, 'pagination-sm');
                break;
            case 'large':
                $options = $this->addClass($options, 'pagination-lg');
                break;
        }
        unset($options['size']);
        $options['before'] .= $this->Html->tag('ul', null, ['class' => $options['class']]);
        $options['after'] = '</ul>' . $options['after'];
        unset($options['class']);
        $params = (array) $this->params($options['model']) + ['page' => 1];
        if ($params['pageCount'] <= 1) {
            return false;
        }
        $templater = $this->templater();
        if (isset($options['templates'])) {
            $templater->push();
            $method = is_string($options['templates']) ? 'load' : 'add';
            $templater->{$method}($options['templates']);
        }
        $first = $prev = $next = $last = '';
        /* Previous and Next buttons (addition from standard PaginatorHelper). */
        if ($options['prev']) {
            $title = $options['prev'];
            $opts = [];
            if (is_array($title)) {
                $title = $title['title'];
                unset($options['prev']['title']);
                $opts = $options['prev'];
            }
            $prev = $this->prev($title, $opts);
        }
        unset($options['prev']);
        if ($options['next']) {
            $title = $options['next'];
            $opts = [];
            if (is_array($title)) {
                $title = $title['title'];
                unset($options['next']['title']);
                $opts = $options['next'];
            }
            $next = $this->next($title, $opts);
        }
        unset($options['next']);
        /* Custom First and Last. */
        list($start, $end) = $this->_getNumbersStartAndEnd($params, $options);
        if ($options['last']) {
            $ellipsis = isset($options['ellipsis']) ? $options['ellipsis'] : is_int($options['last']);
            $ellipsis = $ellipsis ? $templater->format('ellipsis', []) : '';
            $last = $this->_lastNumber($ellipsis, $params, $end, $options);
        }
        if ($options['first']) {
            $ellipsis = isset($options['ellipsis']) ? $options['ellipsis'] : is_int($options['first']);
            $ellipsis = $ellipsis ? $templater->format('ellipsis', []) : '';
            $first = $this->_firstNumber($ellipsis, $params, $start, $options);
        }
        unset($options['ellipsis']);
        $before = is_int($options['first']) ? $prev . $first : $first . $prev;
        $after = is_int($options['last']) ? $last . $next : $next . $last;
        $options['before'] = $options['before'] . $before;
        $options['after'] = $after . $options['after'];
        $options['first'] = $options['last'] = false;
        if ($options['modulus'] !== false && $params['pageCount'] > $options['modulus']) {
            $out = $this->_modulusNumbers($templater, $params, $options);
        } else {
            $out = $this->_numbers($templater, $params, $options);
        }
        if (isset($options['templates'])) {
            $templater->pop();
        }
        return $out;
    }