fix Paginator::numbers() seperator: #2685

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5360 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-06-27 15:53:38 +00:00
parent 642b45a008
commit c405d3ad6b
2 changed files with 12 additions and 16 deletions

View file

@ -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;

View file

@ -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('/<script type="text\/javascript">Event.observe/', $result);
}