Skip to content

Commit

Permalink
Applying optimization patch to PaginatorHelper and test refactorings …
Browse files Browse the repository at this point in the history
…to PaginatorHelper test case. Thanks Phally. Fixes #6526

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8259 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
markstory committed Jul 28, 2009
1 parent 9da7b6e commit 47cd941
Show file tree
Hide file tree
Showing 2 changed files with 404 additions and 52 deletions.
30 changes: 12 additions & 18 deletions cake/libs/view/helpers/paginator.php
Expand Up @@ -491,15 +491,12 @@ function numbers($options = array()) {
$end = $params['page'] + ($modulus - $params['page']) + 1;
}

if ($first) {
if ($start > (int)$first) {
if ($start == $first + 1) {
$out .= $this->first($first, array('tag' => $tag, 'after' => $separator, 'separator' => $separator));
} else {
$out .= $this->first($first, array('tag' => $tag, 'separator' => $separator));
}
} elseif ($start == 2) {
$out .= $this->Html->tag($tag, $this->link(1, array('page' => 1), $options)) . $separator;
if ($first && $start > 1) {
$offset = ($start <= (int)$first) ? $start - 1 : $first;
if ($offset < $start - 1) {
$out .= $this->first($offset, array('tag' => $tag, 'separator' => $separator));
} else {
$out .= $this->first($offset, array('tag' => $tag, 'after' => $separator, 'separator' => $separator));
}
}

Expand All @@ -525,15 +522,12 @@ function numbers($options = array()) {

$out .= $after;

if ($last) {
if ($end <= $params['pageCount'] - (int)$last) {
if ($end + 1 == $params['pageCount']) {
$out .= $this->last($last, array('tag' => $tag, 'before' => $separator, 'separator' => $separator));
} else {
$out .= $this->last($last, array('tag' => $tag, 'separator' => $separator));
}
} elseif ($end == $params['pageCount'] - 1) {
$out .= $separator . $this->Html->tag($tag, $this->link($params['pageCount'], array('page' => $params['pageCount']), $options));
if ($last && $end < $params['pageCount']) {
$offset = ($params['pageCount'] < $end + (int)$last) ? $params['pageCount'] - $end : $last;
if ($offset <= $last && $params['pageCount'] - $end > $offset) {
$out .= $this->last($offset, array('tag' => $tag, 'separator' => $separator));
} else {
$out .= $this->last($offset, array('tag' => $tag, 'before' => $separator, 'separator' => $separator));
}
}

Expand Down

0 comments on commit 47cd941

Please sign in to comment.