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:
authorrobocoder <anthon.pang@gmail.com>2012-05-12 18:01:43 +0400
committerrobocoder <anthon.pang@gmail.com>2012-05-12 18:01:43 +0400
commitfe4218b3b6856b9c2d93ffd0888f1128a3668203 (patch)
tree50a5c1fd644f52713762c18f31c0406cf32b22a8 /core/DataTable/Filter/RangeCheck.php
parentc9765d758a03322e8e5935dfaefc359cf974376e (diff)
fixes #2962 - add RangeCheck filter
git-svn-id: http://dev.piwik.org/svn/trunk@6258 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'core/DataTable/Filter/RangeCheck.php')
-rw-r--r--core/DataTable/Filter/RangeCheck.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/core/DataTable/Filter/RangeCheck.php b/core/DataTable/Filter/RangeCheck.php
new file mode 100644
index 0000000000..44b862f9be
--- /dev/null
+++ b/core/DataTable/Filter/RangeCheck.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ * @version $Id: RangeCheck.php 5791 2012-02-09 05:58:45Z matt $
+ *
+ * @category Piwik
+ * @package Piwik
+ */
+
+/**
+ * Check range
+ *
+ * @package Piwik
+ * @subpackage Piwik_DataTable
+ */
+class Piwik_DataTable_Filter_RangeCheck extends Piwik_DataTable_Filter
+{
+ static public $minimumValue = 0.00;
+ static public $maximumValue = 100.0;
+
+ public function __construct( $table, $columnToFilter, $minimumValue, $maximum )
+ {
+ parent::__construct($table);
+
+ $this->columnToFilter = $columnToFilter;
+ self::$minimumValue = $minimumValue;
+ self::$maximumValue = $maximumValue;
+ }
+
+ public function filter($table)
+ {
+ foreach($table->getRows() as $row)
+ {
+ $value = $row->getColumn($this->columnToFilter);
+ if($value !== false)
+ {
+ if ($value < self::$minimumValue)
+ {
+ $row->setColumn($this->columnToFilter, self::$minimumValue);
+ }
+ elseif ($value > self::$maximumValue)
+ {
+ $row->setColumn($this->columnToFilter, self::$maximumValue);
+ }
+ }
+ }
+ }
+}