Skip to content

Commit

Permalink
Moving limit from the options to the normal paging params. This fixes…
Browse files Browse the repository at this point in the history
… a few notice errors.
  • Loading branch information
markstory committed Dec 19, 2010
1 parent 176d552 commit cc2d8e2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
1 change: 1 addition & 0 deletions cake/libs/controller/components/paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public function paginate($object = null, $scope = array(), $whitelist = array())
'nextPage' => ($count > ($page * $limit)),
'pageCount' => $pageCount,
'order' => $order,
'limit' => $limit,
'options' => Set::diff($options, $defaults),
'paramType' => $options['paramType']
);
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/view/helpers/paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,9 @@ public function counter($options = array()) {
}
$start = 0;
if ($paging['count'] >= 1) {
$start = (($paging['page'] - 1) * $paging['options']['limit']) + 1;
$start = (($paging['page'] - 1) * $paging['limit']) + 1;
}
$end = $start + $paging['options']['limit'] - 1;
$end = $start + $paging['limit'] - 1;
if ($paging['count'] < $end) {
$end = $paging['count'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ function testPaginate() {
$Controller->request->params['named'] = array();
$Controller->Paginator->settings = array('limit' => '-1', 'maxLimit' => 10, 'paramType' => 'named');
$Controller->Paginator->paginate('PaginatorControllerPost');

$this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['limit'], 1);
$this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['page'], 1);
$this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3);
$this->assertIdentical($Controller->params['paging']['PaginatorControllerPost']['prevPage'], false);
Expand Down
10 changes: 1 addition & 9 deletions cake/tests/cases/libs/view/helpers/paginator.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1966,18 +1966,10 @@ function testCounter() {
'prevPage' => false,
'nextPage' => true,
'pageCount' => 5,
'defaults' => array(
'limit' => 3,
'step' => 1,
'order' => array('Client.name' => 'DESC'),
'conditions' => array()
),
'limit' => 3,
'options' => array(
'page' => 1,
'limit' => 3,
'order' => array('Client.name' => 'DESC'),
'conditions' => array(),
'separator' => 'of'
),
)
);
Expand Down

0 comments on commit cc2d8e2

Please sign in to comment.