mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Applying patch from 'kuja' to give default class names to links generated by Paginator::sort().
Fixes #6239
This commit is contained in:
parent
38a4b619e6
commit
4f2d415663
2 changed files with 16 additions and 9 deletions
|
@ -237,10 +237,17 @@ class PaginatorHelper extends AppHelper {
|
|||
$sortKey = $this->sortKey($options['model']);
|
||||
$isSorted = ($sortKey === $key || $sortKey === $this->defaultModel() . '.' . $key);
|
||||
|
||||
if ($isSorted && $this->sortDir($options['model']) === 'asc') {
|
||||
$dir = 'desc';
|
||||
if ($isSorted) {
|
||||
if ($this->sortDir($options['model']) === 'asc') {
|
||||
$dir = 'desc';
|
||||
}
|
||||
$class = $dir === 'asc' ? 'desc' : 'asc';
|
||||
if (!empty($options['class'])) {
|
||||
$options['class'] .= $class;
|
||||
} else {
|
||||
$options['class'] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($title) && array_key_exists($dir, $title)) {
|
||||
$title = $title[$dir];
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->sort('date');
|
||||
$expected = array(
|
||||
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:date/direction:desc'),
|
||||
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:date/direction:desc', 'class' => 'asc'),
|
||||
'Date',
|
||||
'/a'
|
||||
);
|
||||
|
@ -181,7 +181,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->params['paging']['Article']['options']['sort'] = 'title';
|
||||
$result = $this->Paginator->sort(array('asc' => 'ascending', 'desc' => 'descending'), 'title');
|
||||
$expected = array(
|
||||
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:desc'),
|
||||
'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:desc', 'class' => 'asc'),
|
||||
'descending',
|
||||
'/a'
|
||||
);
|
||||
|
@ -190,13 +190,13 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$this->Paginator->params['paging']['Article']['options']['sort'] = null;
|
||||
$result = $this->Paginator->sort('title');
|
||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc">Title<\/a>$/', $result);
|
||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
|
||||
|
||||
|
||||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$this->Paginator->params['paging']['Article']['options']['sort'] = null;
|
||||
$result = $this->Paginator->sort('title');
|
||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc">Title<\/a>$/', $result);
|
||||
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,7 +216,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
|
||||
$result = $this->Paginator->sort('Title','Article.title');
|
||||
$expected = array(
|
||||
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:asc'),
|
||||
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:asc', 'class' => 'desc'),
|
||||
'Title',
|
||||
'/a'
|
||||
);
|
||||
|
@ -225,7 +225,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
|
||||
$result = $this->Paginator->sort('Title','Article.title');
|
||||
$expected = array(
|
||||
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:desc'),
|
||||
'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:desc', 'class' => 'asc'),
|
||||
'Title',
|
||||
'/a'
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue