diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index ff458114d..9267e9241 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -432,7 +432,7 @@ class PaginatorHelper extends AppHelper { ), $options); - $params = $this->params($options['model']); + $params = am(array('page'=> 1), $this->params($options['model'])); unset($options['model']); if ($params['pageCount'] <= 1) { @@ -458,29 +458,25 @@ class PaginatorHelper extends AppHelper { $end = $params['pageCount']; } $start = $params['page'] - ($modulus - ($end - $params['page'])); - if ($start <= 1) { $start = 1; $end = $params['page'] + ($modulus - $params['page']) + 1; } - for ($i = $start; $i < $params['page']; $i++) { - $out .= $this->link($i, am($options['url'], array('page' => $i)), $options); - $out .= $separator; + $out .= $this->link($i, am($options['url'], array('page' => $i)), $options) . $separator; } - $out .= $params['page']; - $out .= $separator; + $out .= $params['page'] . $separator; $start = $params['page'] + 1; - - for ($i = $start; $i <= $end; $i++) { - $out .= $this->link($i, am($options['url'], array('page' => $i)), $options); - $out .= $separator; + for ($i = $start; $i < $end; $i++) { + $out .= $this->link($i, am($options['url'], array('page' => $i)), $options) . $separator; } + $out .= $this->link($i, am($options['url'], array('page' => $end)), $options); + } else { for ($i = 1; $i < $params['pageCount']; $i++) { - if (isset($params['page']) && $i == $params['page']) { + if ($i == $params['page']) { $out .= $i . $separator; } else { $out .= $this->link($i, am($options['url'], array('page' => $i)), $options) . $separator; diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 3419f84fc..521493a62 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -68,7 +68,7 @@ class PaginatorTest extends UnitTestCase { $this->paginator->Ajax->Html =& new HtmlHelper(); $this->paginator->Ajax->Javascript =& new JavascriptHelper(); $this->paginator->Ajax->Form =& new FormHelper(); - + } function testHasPrevious() { @@ -97,9 +97,9 @@ class PaginatorTest extends UnitTestCase { $result = $this->paginator->sort('date'); $this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:date\/direction:desc"\s*>Date<\/a>$/', $result); - - $result = $this->paginator->numbers(array('url'=> array('controller'=>'projects', 'action'=>'sort'),'update'=>'list')); - $this->assertPattern('/\/projects\/sort\/page:1/', $result); + + $result = $this->paginator->numbers(array('modulus'=> '2', 'url'=> array('controller'=>'projects', 'action'=>'sort'),'update'=>'list')); + $this->assertPattern('/\/projects\/sort\/page:2/', $result); $this->assertPattern('/