diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-07-28 18:58:06 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2015-10-06 17:23:55 +0300 |
commit | e2c4a9946814fdfa57f02ae2b55c829ca3950820 (patch) | |
tree | e2b3f023f84ce47f358def253024e72e468af966 /core/API | |
parent | a2bd2fbedcce1e3e3542a274157dccb5beac70d4 (diff) |
support for secondary sort and faster sort
Diffstat (limited to 'core/API')
-rw-r--r-- | core/API/DataTableGenericFilter.php | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/core/API/DataTableGenericFilter.php b/core/API/DataTableGenericFilter.php index 5d4ba49422..7aa0571384 100644 --- a/core/API/DataTableGenericFilter.php +++ b/core/API/DataTableGenericFilter.php @@ -98,6 +98,9 @@ class DataTableGenericFilter array( 'filter_sort_column' => array('string'), 'filter_sort_order' => array('string', 'desc'), + $naturalSort = true, + $recursiveSort = false, + $doSortBySecondaryColumn = true )), array('Truncate', array( @@ -159,22 +162,27 @@ class DataTableGenericFilter } foreach ($filterParams as $name => $info) { - // parameter type to cast to - $type = $info[0]; - - // default value if specified, when the parameter doesn't have a value - $defaultValue = null; - if (isset($info[1])) { - $defaultValue = $info[1]; - } - - try { - $value = Common::getRequestVar($name, $defaultValue, $type, $this->request); - settype($value, $type); - $filterParameters[] = $value; - } catch (Exception $e) { - $exceptionRaised = true; - break; + if (!is_array($info)) { + // hard coded value that cannot be changed via API, see eg $naturalSort = true in 'Sort' + $filterParameters[] = $info; + } else { + // parameter type to cast to + $type = $info[0]; + + // default value if specified, when the parameter doesn't have a value + $defaultValue = null; + if (isset($info[1])) { + $defaultValue = $info[1]; + } + + try { + $value = Common::getRequestVar($name, $defaultValue, $type, $this->request); + settype($value, $type); + $filterParameters[] = $value; + } catch (Exception $e) { + $exceptionRaised = true; + break; + } } } |