Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-05-13 04:48:40 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-05-13 04:48:40 +0400
commit1fbb453c4221151c64b251cbb810c0925f06c46b (patch)
tree046dd2dd05eed3ab30b56e27d2ddb7d557458aae /core/DataTable/Filter/Sort.php
parent66ece94140e682dd74057466e2703207fa010571 (diff)
refs #4706 added possibility to register a closure or a callable method to process processed metrics as late as possible and to make sure it always returns the correct value whenever it is called. Otherwise the value does not get updated in case for instance the nb_visits column changes (done in SumRow). Whenever there is a column that is not numeric and not the label column it should use a callback method instead of calculating the value directly to make sure the correct value is returend when using flat or truncate or ...
Diffstat (limited to 'core/DataTable/Filter/Sort.php')
-rw-r--r--core/DataTable/Filter/Sort.php46
1 files changed, 27 insertions, 19 deletions
diff --git a/core/DataTable/Filter/Sort.php b/core/DataTable/Filter/Sort.php
index fbef2d91b9..5844208940 100644
--- a/core/DataTable/Filter/Sort.php
+++ b/core/DataTable/Filter/Sort.php
@@ -71,21 +71,23 @@ class Sort extends BaseFilter
*/
public function numberSort($a, $b)
{
- return !isset($a->c[Row::COLUMNS][$this->columnToSort])
- && !isset($b->c[Row::COLUMNS][$this->columnToSort])
+ $valA = $a->getColumn($this->columnToSort);
+ $valB = $b->getColumn($this->columnToSort);
+ return !isset($valA)
+ && !isset($valB)
? 0
: (
- !isset($a->c[Row::COLUMNS][$this->columnToSort])
+ !isset($valA)
? 1
: (
- !isset($b->c[Row::COLUMNS][$this->columnToSort])
+ !isset($valB)
? -1
- : (($a->c[Row::COLUMNS][$this->columnToSort] != $b->c[Row::COLUMNS][$this->columnToSort]
+ : (($valA != $valB
|| !isset($a->c[Row::COLUMNS]['label']))
? ($this->sign * (
- $a->c[Row::COLUMNS][$this->columnToSort]
- < $b->c[Row::COLUMNS][$this->columnToSort]
+ $valA
+ < $valB
? -1
: 1)
)
@@ -106,16 +108,19 @@ class Sort extends BaseFilter
*/
function naturalSort($a, $b)
{
- return !isset($a->c[Row::COLUMNS][$this->columnToSort])
- && !isset($b->c[Row::COLUMNS][$this->columnToSort])
+ $valA = $a->getColumn($this->columnToSort);
+ $valB = $b->getColumn($this->columnToSort);
+
+ return !isset($valA)
+ && !isset($valB)
? 0
- : (!isset($a->c[Row::COLUMNS][$this->columnToSort])
+ : (!isset($valA)
? 1
- : (!isset($b->c[Row::COLUMNS][$this->columnToSort])
+ : (!isset($valB)
? -1
: $this->sign * strnatcasecmp(
- $a->c[Row::COLUMNS][$this->columnToSort],
- $b->c[Row::COLUMNS][$this->columnToSort]
+ $valA,
+ $valB
)
)
);
@@ -130,16 +135,19 @@ class Sort extends BaseFilter
*/
function sortString($a, $b)
{
- return !isset($a->c[Row::COLUMNS][$this->columnToSort])
- && !isset($b->c[Row::COLUMNS][$this->columnToSort])
+ $valA = $a->getColumn($this->columnToSort);
+ $valB = $b->getColumn($this->columnToSort);
+
+ return !isset($valA)
+ && !isset($valB)
? 0
- : (!isset($a->c[Row::COLUMNS][$this->columnToSort])
+ : (!isset($valA)
? 1
- : (!isset($b->c[Row::COLUMNS][$this->columnToSort])
+ : (!isset($valB)
? -1
: $this->sign *
- strcasecmp($a->c[Row::COLUMNS][$this->columnToSort],
- $b->c[Row::COLUMNS][$this->columnToSort]
+ strcasecmp($valA,
+ $valB
)
)
);