Permalink
Browse files

Applying optimization patch to PaginatorHelper and test refactorings …

…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...
1 parent 9da7b6e commit 47cd941b530f0c892fb93b8a4d2311d3f5c1d5b3 @markstory markstory committed Jul 28, 2009
Showing with 404 additions and 52 deletions.
  1. +12 −18 cake/libs/view/helpers/paginator.php
  2. +392 −34 cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -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));
}
}
@@ -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));
}
}
Oops, something went wrong. Retry.

0 comments on commit 47cd941

Please sign in to comment.