mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
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:
parent
9b857e9f36
commit
460b219810
1 changed files with 8 additions and 6 deletions
|
@ -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'])) {
|
||||
|
|
Loading…
Add table
Reference in a new issue