Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixes #6507 paginator sort directions

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8239 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 56bee6e1fc511f813c181082ffb38018db180906 1 parent 4cfdd31
gwoo authored
View
3  cake/libs/view/helpers/paginator.php
@@ -226,11 +226,12 @@ function sort($title, $key = null, $options = array()) {
}
$dir = 'asc';
$sortKey = $this->sortKey($options['model']);
- $isSorted = ($sortKey === $key);
+ $isSorted = ($sortKey === $key || $sortKey === $this->defaultModel() . '.' . $key);
if ($isSorted && $this->sortDir($options['model']) === 'asc') {
$dir = 'desc';
}
+
if (is_array($title) && array_key_exists($dir, $title)) {
$title = $title[$dir];
}
View
11 cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -153,6 +153,17 @@ function testSortLinks() {
$this->Paginator->params['paging']['Article']['options']['sort'] = 'title';
$result = $this->Paginator->sort(array('asc' => 'ascending', 'desc' => 'descending'), 'title');
$this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc">descending<\/a>$/', $result);
+
+ $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->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);
}
/**
* testSortLinksUsingDotNotation method
Please sign in to comment.
Something went wrong with that request. Please try again.