MINOR move sort column&direction into their own vars, otherwise, canSortBy(Date DESC) will always return false, since DESC is not part of the column name. (from r96411)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@98137 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-02-04 03:47:59 +00:00
parent 298735506a
commit 962dae2dc7

View File

@ -486,12 +486,13 @@ JS
}
if(!empty($_REQUEST['ctf'][$this->Name()]['sort'])) {
$sort = $_REQUEST['ctf'][$this->Name()]['sort'];
$column = $_REQUEST['ctf'][$this->Name()]['sort'];
$dir = 'ASC';
if(!empty($_REQUEST['ctf'][$this->Name()]['dir'])) {
$dir = $_REQUEST['ctf'][$this->Name()]['dir'];
if(strtoupper(trim($dir)) == 'DESC') $sort .= ' DESC';
if(strtoupper(trim($dir)) == 'DESC') $dir = 'DESC';
}
if($query->canSortBy($sort)) $query->orderby = $sort;
if($query->canSortBy($column)) $query->orderby = $column.' '.$dir;
}
return $query;