diff options
author | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-07-12 10:31:39 +0400 |
---|---|---|
committer | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-07-12 10:31:39 +0400 |
commit | 01057779046dd67923bd34d123628ab60ed263bc (patch) | |
tree | 94353df4f7848f2de63f3eeb0c9eeed2020965c8 /core/DataTable/Filter/ExcludeLowPopulation.php | |
parent | 98e6c9b8874ffc8c18570ed4cc062cc5f0eb80c0 (diff) |
Refs #4040, #4041, move all ViewDataTable properties to the viewProperties array and allow these properties to be specified through new display metadata. Converted the Actions, Goals, UserSettings and VisitTime controllers.
Notes:
- Includes refactoring of ExcludeLowPopulation filter.
Diffstat (limited to 'core/DataTable/Filter/ExcludeLowPopulation.php')
-rw-r--r-- | core/DataTable/Filter/ExcludeLowPopulation.php | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/core/DataTable/Filter/ExcludeLowPopulation.php b/core/DataTable/Filter/ExcludeLowPopulation.php index c5d6369d6c..9f4d5c723c 100644 --- a/core/DataTable/Filter/ExcludeLowPopulation.php +++ b/core/DataTable/Filter/ExcludeLowPopulation.php @@ -21,22 +21,29 @@ */ class Piwik_DataTable_Filter_ExcludeLowPopulation extends Piwik_DataTable_Filter { - static public $minimumValue; const MINIMUM_SIGNIFICANT_PERCENTAGE_THRESHOLD = 0.02; + + /** + * The minimum value to enforce in a datatable for a specified column. Rows found with + * a value less than this are removed. + * + * @var number + */ + private $minimumValue; /** * Constructor * * @param Piwik_DataTable $table * @param string $columnToFilter column to filter - * @param number $minimumValue minimum value + * @param number|Closure $minimumValue minimum value * @param bool $minimumPercentageThreshold */ public function __construct($table, $columnToFilter, $minimumValue, $minimumPercentageThreshold = false) { parent::__construct($table); $this->columnToFilter = $columnToFilter; - + if ($minimumValue == 0) { if ($minimumPercentageThreshold === false) { $minimumPercentageThreshold = self::MINIMUM_SIGNIFICANT_PERCENTAGE_THRESHOLD; @@ -45,7 +52,8 @@ class Piwik_DataTable_Filter_ExcludeLowPopulation extends Piwik_DataTable_Filter $sumValues = array_sum($allValues); $minimumValue = $sumValues * $minimumPercentageThreshold; } - self::$minimumValue = $minimumValue; + + $this->minimumValue = $minimumValue; } /** @@ -53,23 +61,13 @@ class Piwik_DataTable_Filter_ExcludeLowPopulation extends Piwik_DataTable_Filter * * @param Piwik_DataTable $table */ - function filter($table) - { - $table->filter('ColumnCallbackDeleteRow', - array($this->columnToFilter, - array("Piwik_DataTable_Filter_ExcludeLowPopulation", "excludeLowPopulation") - ) - ); - } - - /** - * Checks whether the given value is below the defined minimum - * - * @param number $value value to check - * @return bool - */ - static public function excludeLowPopulation($value) + public function filter($table) { - return $value >= self::$minimumValue; + $minimumValue = $this->minimumValue; + $isValueHighPopulation = function ($value) use ($minimumValue) { + return $value >= $minimumValue; + }; + + $table->filter('ColumnCallbackDeleteRow', array($this->columnToFilter, $isValueHighPopulation)); } } |