mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
642b45a008
commit
c405d3ad6b
2 changed files with 12 additions and 16 deletions
|
@ -432,7 +432,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
),
|
),
|
||||||
$options);
|
$options);
|
||||||
|
|
||||||
$params = $this->params($options['model']);
|
$params = am(array('page'=> 1), $this->params($options['model']));
|
||||||
unset($options['model']);
|
unset($options['model']);
|
||||||
|
|
||||||
if ($params['pageCount'] <= 1) {
|
if ($params['pageCount'] <= 1) {
|
||||||
|
@ -458,29 +458,25 @@ class PaginatorHelper extends AppHelper {
|
||||||
$end = $params['pageCount'];
|
$end = $params['pageCount'];
|
||||||
}
|
}
|
||||||
$start = $params['page'] - ($modulus - ($end - $params['page']));
|
$start = $params['page'] - ($modulus - ($end - $params['page']));
|
||||||
|
|
||||||
if ($start <= 1) {
|
if ($start <= 1) {
|
||||||
$start = 1;
|
$start = 1;
|
||||||
$end = $params['page'] + ($modulus - $params['page']) + 1;
|
$end = $params['page'] + ($modulus - $params['page']) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = $start; $i < $params['page']; $i++) {
|
for ($i = $start; $i < $params['page']; $i++) {
|
||||||
$out .= $this->link($i, am($options['url'], array('page' => $i)), $options);
|
$out .= $this->link($i, am($options['url'], array('page' => $i)), $options) . $separator;
|
||||||
$out .= $separator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$out .= $params['page'];
|
$out .= $params['page'] . $separator;
|
||||||
$out .= $separator;
|
|
||||||
|
|
||||||
$start = $params['page'] + 1;
|
$start = $params['page'] + 1;
|
||||||
|
for ($i = $start; $i < $end; $i++) {
|
||||||
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' => $i)), $options);
|
|
||||||
$out .= $separator;
|
|
||||||
}
|
}
|
||||||
|
$out .= $this->link($i, am($options['url'], array('page' => $end)), $options);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for ($i = 1; $i < $params['pageCount']; $i++) {
|
for ($i = 1; $i < $params['pageCount']; $i++) {
|
||||||
if (isset($params['page']) && $i == $params['page']) {
|
if ($i == $params['page']) {
|
||||||
$out .= $i . $separator;
|
$out .= $i . $separator;
|
||||||
} else {
|
} else {
|
||||||
$out .= $this->link($i, am($options['url'], array('page' => $i)), $options) . $separator;
|
$out .= $this->link($i, am($options['url'], array('page' => $i)), $options) . $separator;
|
||||||
|
|
|
@ -68,7 +68,7 @@ class PaginatorTest extends UnitTestCase {
|
||||||
$this->paginator->Ajax->Html =& new HtmlHelper();
|
$this->paginator->Ajax->Html =& new HtmlHelper();
|
||||||
$this->paginator->Ajax->Javascript =& new JavascriptHelper();
|
$this->paginator->Ajax->Javascript =& new JavascriptHelper();
|
||||||
$this->paginator->Ajax->Form =& new FormHelper();
|
$this->paginator->Ajax->Form =& new FormHelper();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function testHasPrevious() {
|
function testHasPrevious() {
|
||||||
|
@ -97,9 +97,9 @@ class PaginatorTest extends UnitTestCase {
|
||||||
|
|
||||||
$result = $this->paginator->sort('date');
|
$result = $this->paginator->sort('date');
|
||||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:date\/direction:desc"\s*>Date<\/a>$/', $result);
|
$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'));
|
$result = $this->paginator->numbers(array('modulus'=> '2', 'url'=> array('controller'=>'projects', 'action'=>'sort'),'update'=>'list'));
|
||||||
$this->assertPattern('/\/projects\/sort\/page:1/', $result);
|
$this->assertPattern('/\/projects\/sort\/page:2/', $result);
|
||||||
$this->assertPattern('/<script type="text\/javascript">Event.observe/', $result);
|
$this->assertPattern('/<script type="text\/javascript">Event.observe/', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue