Moving limit from the options to the normal paging params. This fixes a few notice errors.

This commit is contained in:
mark_story 2010-12-19 13:15:04 -05:00
parent 176d5520f6
commit cc2d8e2fec
4 changed files with 6 additions and 11 deletions

View file

@ -195,6 +195,7 @@ class PaginatorComponent extends Component {
'nextPage' => ($count > ($page * $limit)),
'pageCount' => $pageCount,
'order' => $order,
'limit' => $limit,
'options' => Set::diff($options, $defaults),
'paramType' => $options['paramType']
);

View file

@ -525,9 +525,9 @@ class PaginatorHelper extends AppHelper {
}
$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'];
}

View file

@ -306,6 +306,8 @@ class PaginatorTest extends CakeTestCase {
$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);

View file

@ -1966,18 +1966,10 @@ class PaginatorHelperTest extends CakeTestCase {
'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'
),
)
);