small refactor to Controller::paginate handling of sort direction

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7369 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-07-27 15:55:19 +00:00
parent 9b857e9f36
commit 460b219810

View file

@ -919,13 +919,15 @@ class Controller extends Object {
$options['limit'] = $options['show'];
}
if (isset($options['sort']) && isset($options['direction'])) {
if (!in_array(strtolower($options['direction']), array('asc', 'desc'))) {
$options['direction'] = 'asc';
if (isset($options['sort'])) {
$direction = null;
if (isset($options['direction'])) {
$direction = strtolower($options['direction']);
}
$options['order'] = array($options['sort'] => $options['direction']);
} elseif (isset($options['sort'])) {
$options['order'] = array($options['sort'] => 'asc');
if ($direction != 'asc' && $direction != 'desc') {
$direction = 'asc';
}
$options['order'] = array($options['sort'] => $direction);
}
if (!empty($options['order']) && is_array($options['order'])) {