/** * Prepara e retorna/imprime os controles de navegação * * O primeiro parâmetro corresponde a uma referência a classe PaginatorHelper * instanciada pelo controlador, enquanto o segundo parâmetro é um array com as opções * de saída. * * * @param PaginatorHelper $paginator * @param array $options Possui dois índices reconhecidos: * - 'return' do tipo bool, se true faz o método retornar o resultado ao invés de imprimir. * Valor padrão é false * - 'filters' do tipo array que contém as condições para a paginação, acrescido de todos * os parâmetros passados via url */ public function controls(&$paginator, $options = array()) { $this->_paginator =& $paginator; if (!empty($options['filters']) && is_array($options['filters'])) { $filters['url'] = array_merge($options['filters'], $this->params['pass']); } else { $filters['url'] = $this->params['pass']; } $options = Set::merge($filters, $this->_paginator->options); $this->_paginator->options($options); $out = $this->_paginator->first('<< ' . __d('r_search', 'first', true), array(), null, array('class' => 'disabled')) . $this->_paginator->prev(__d('r_search', 'previous', true), array(), null, array('class' => 'disabled')) . $this->_paginator->numbers(array('separator' => '')) . $this->_paginator->next(__d('r_search', 'next', true), array(), null, array('class' => 'disabled')) . $this->_paginator->last(__d('r_search', 'last', true) . ' >>', array(), null, array('class' => 'disabled')); if (isset($options['return']) && $options['return'] === true) { return $out; } else { echo $out; } }
/** * Changes output for some Bootstrap-styled list items * @param array $options * @return mixed|string */ public function numbers($options = array()) { $output = parent::numbers($options); // get the current page number, and create a link with it $current = $this->current(); $currentLink = $this->link($current, array('page' => $current)); // if you're using cake pre 2.1 you cannot change the current class with // the options array, so it will always be "current" $find = "<li class=\"current\">{$current}</li>"; $replace = "<li class=\"active\">{$currentLink}</li>"; $output = str_replace($find, $replace, $output); return $output; }
public function numbers($options = array()) { $defaults = array('tag' => 'li', 'before' => null, 'after' => null, 'model' => $this->defaultModel(), 'class' => null, 'modulus' => 4, 'separator' => false, 'first' => null, 'last' => null, 'ellipsis' => '<li class="disabled"><a href="#">…</a></li>', 'currentClass' => 'current'); $options += $defaults; $return = parent::numbers($options); return preg_replace('@<li class="current">(.*?)</li>@', '<li class="current disabled"><a href="#">\\1</a></li>', $return); }
/** * Returns a set of numbers for the paged result set - Different Defaults * @see /cake/libs/view/helpers/PaginatorHelper#numbers($options = array()) */ function numbers($options = array()) { $defaults = array('tag' => 'span', 'before' => null, 'after' => null, 'model' => $this->defaultModel(), 'modulus' => '8', 'separator' => '', 'first' => null, 'last' => null); $options += $defaults; return parent::numbers($options); }
/** * @param array $options * @return mixed */ public function numbers($options = array()) { $defaults = array('tag' => 'li', 'before' => null, 'after' => null, 'model' => $this->defaultModel(), 'class' => null, 'modulus' => 6, 'separator' => false, 'first' => 1, 'last' => 1, 'ellipsis' => '<li class="unavailable"><a>…</a></li>', 'currentClass' => 'current', 'currentTag' => 'a'); $options += $defaults; return parent::numbers($options); }
/** * Get pagination link list. * * @param $options Options for link element * * Extra options: * - alignment left/center/right (default center) * - size mini/small/normal/large (default normal) */ public function numbers($options = []) { $default = ['tag' => 'li', 'currentTag' => 'a', 'separator' => '', 'currentClass' => GA_ACTIVE, 'disabledTag' => 'a', 'size' => 'normal', 'alignment' => 'center', 'before' => '', 'after' => '']; $options = array_merge($default, $options); $size = $options['size']; unset($options['size']); $alignment = $options['alignment']; unset($options['alignment']); $class = GA_PAGINATION; if ($size !== 'normal') { $class .= ' ' . GA_PAGINATION . '-' . $size; } if ($alignment !== 'left') { $class .= ' ' . GA_PAGINATION . '-' . $alignment; if ($alignment === 'center') { $class .= 'ed'; } } 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($options = array()) { $default = array('tag' => 'li', 'currentTag' => 'a', 'separator' => '', 'currentClass' => 'active', 'disabledTag' => 'a', 'size' => 'normal'); $options = array_merge($default, $options); $size = $options['size']; unset($options['size']); $class = 'pagination'; if (isset($options['ulClass'])) { $class .= ' ' . $options['ulClass']; unset($options['ulClass']); } switch ($size) { case 'small': $class .= ' pagination-sm'; break; case 'large': $class .= ' pagination-lg'; break; } $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); }
public function numbers($options = []) { $defaults = ['separator' => '', 'tag' => 'li', 'currentTag' => 'a']; $options = Hash::merge($defaults, $options); return parent::numbers($options); }
/** * ページNoリンク * @param PaginatorHelper $paginator * @return string */ private static function getPaginatorLinkNumbers(PaginatorHelper $paginator) { $options = array('separator' => ''); return $paginator->numbers($options); }