/** * Returns a set of numbers for the paged result set * uses a modulus to decide how many numbers to show on each side of the current page (default: 8). * * `$this->Paginator->numbers(['first' => 2, 'last' => 2]);` * * Using the first and last options you can create links to the beginning and end of the page set. * * ### Options * * - `before` Content to be inserted before the numbers, but after the first links. * - `after` Content to be inserted after the numbers, but before the last links. * - `model` Model to create numbers for, defaults to PaginatorHelper::defaultModel() * - `modulus` how many numbers to include on either side of the current page, defaults to 8. * - `first` Whether you want first links generated, set to an integer to define the number of 'first' * links to generate. * - `last` Whether you want last links generated, set to an integer to define the number of 'last' * links to generate. * - `templates` An array of templates, or template file name containing the templates you'd like to * use when generating the numbers. The helper's original templates will be restored once * numbers() is done. * * The generated number links will include the 'ellipsis' template when the `first` and `last` options * and the number of pages exceed the modulus. For example if you have 25 pages, and use the first/last * options and a modulus of 8, ellipsis content will be inserted after the first and last link sets. * * @param array $options Options for the numbers. * @return string numbers string. * @link http://book.cakephp.org/3.0/en/views/helpers/paginator.html#creating-page-number-links */ public function numbers(array $options = []) { if (is_string($options)) { $options = ['size' => $options]; } if (!isset($options['class'])) { $options['class'] = 'pagination'; } $options += ['class' => $options['class'], 'after' => '</ul>', 'size' => null]; $options['class'] = implode(' ', (array) $options['class']); if (!empty($options['size'])) { $options['class'] .= " {$class}-{$options['size']}"; } $options += ['before' => '<ul class="' . $options['class'] . '">']; unset($options['class'], $options['size']); if (isset($options['prev'])) { if ($options['prev'] === true) { $options['prev'] = $this->config('labels.prev'); } $options['before'] .= $this->prev($options['prev'], ['escape' => false]); } if (isset($options['next'])) { if ($options['next'] === true) { $options['next'] = $this->config('labels.next'); } $options['after'] = $this->next($options['next'], ['escape' => false]) . $options['after']; } return parent::numbers($options); }
/** * * Get pagination link list. * * @param $options Options for link element * * Extra options: * - size small/normal/large (default normal) * **/ public function numbers(array $options = array()) { $class = 'pagination'; if (isset($options['class'])) { $class .= ' ' . $options['class']; unset($options['class']); } if (isset($options['size'])) { switch ($options['size']) { case 'small': $class .= ' pagination-sm'; break; case 'large': $class .= ' pagination-lg'; break; } unset($options['size']); } $options['before'] = '<ul class="' . $class . '">'; $options['after'] = '</ul>'; if (isset($options['prev'])) { $options['before'] .= $this->prev($options['prev']); } if (isset($options['next'])) { $options['after'] = $this->next($options['next']) . $options['after']; } return parent::numbers($options); }
/** * Paginator Widget * * @param array $options Options * @return string Markup */ public function numbers(array $options = []) { $options = Hash::merge(['first' => 1, 'last' => 1], $options); parent::templates(['ellipsis' => '<li class="disabled"><a>...</a></li>']); $pagination = ''; $pagination .= parent::prev('«', ['escape' => false]); $pagination .= parent::numbers($options); $pagination .= parent::next('»', ['escape' => false]); $counter = parent::counter(['format' => '{{count}} Einträge']); $ret = sprintf('<nav><ul class="pagination">%s<li class="counter"><a>%s</a></li></ul></nav>', $pagination, $counter); return $ret; }
/** * Generates a "previous" link for a set of paged records * @param string $title Title for the link * @param array $options Options for pagination link * @return string A "previous" link or a disabled link */ public function prev($title = '<< Previous', array $options = []) { $options = $this->optionsDefaults(['escape' => false], $options); list($title, $options) = $this->addIconToText($title, $options); return parent::prev($title, $options); }