blob: 78ac7739797fa8cd6fe3a2e30b1da0b020d9c1a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?php
/**
* Delete all rows of when a given function returns false for a given column
*/
class Piwik_DataTable_Filter_ColumnCallback extends Piwik_DataTable_Filter
{
private $columnToFilter;
private $function;
public function __construct( $table, $columnToFilter, $function )
{
parent::__construct($table);
$this->function = $function;
$this->columnToFilter = $columnToFilter;
$this->filter();
}
protected function filter()
{
foreach($this->table->getRows() as $key => $row)
{
if( !call_user_func( $this->function, $row->getColumn($this->columnToFilter)))
{
$this->table->deleteRow($key);
}
}
}
}
|