blob: dd6261df6a5e68ee8e39d904819018d5d1e663cb (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<?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$
*/
/**
* Delete all rows from the table that are not in the offset,offset+limit range
*
* @package Piwik_DataTable
* @subpackage Piwik_DataTable_Filter
*/
class Piwik_DataTable_Filter_Limit extends Piwik_DataTable_Filter
{
public function __construct( $table, $offset, $limit )
{
parent::__construct($table);
$this->offset = $offset;
$this->limit = $limit;
$this->filter();
}
protected function filter()
{
$table = $this->table;
$rowsCount = $table->getRowsCount();
// we have to delete
// - from 0 to offset
// at this point the array has offset less elements
// - from limit to the end
$table->deleteRowsOffset( 0, $this->offset );
if( $this->limit > 0 )
{
$table->deleteRowsOffset( $this->limit );
}
}
}
|