Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Applying patch from 'kuja' to give default class names to links gener…

…ated by Paginator::sort().

Fixes #6239
  • Loading branch information...
commit 4f2d4156634c219726e012e9dd7008fd989641b2 1 parent 38a4b61
Mark Story markstory authored
13 cake/libs/view/helpers/paginator.php
View
@@ -237,10 +237,17 @@ function sort($title, $key = null, $options = array()) {
$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];
}
12 cake/tests/cases/libs/view/helpers/paginator.test.php
View
@@ -152,7 +152,7 @@ function testSortLinks() {
$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 @@ function testSortLinks() {
$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 @@ function testSortLinks() {
$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 @@ function testSortLinksUsingDotNotation() {
$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 @@ function testSortLinksUsingDotNotation() {
$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'
);
Please sign in to comment.
Something went wrong with that request. Please try again.