From 460b2198107bdec770edd52ddb102fd9c169cafc Mon Sep 17 00:00:00 2001 From: gwoo Date: Sun, 27 Jul 2008 15:55:19 +0000 Subject: [PATCH] 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 --- cake/libs/controller/controller.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 0130b298a..5889a2975 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -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'])) {