startRowToSummarize = $startRowToSummarize; $this->labelSummaryRow = $labelSummaryRow; $this->columnToSortByBeforeTruncating = $columnToSortByBeforeTruncating; if($table->getRowsCount() > $startRowToSummarize + 1) { $this->filter(); } } protected function filter() { $this->table->filter('Sort', array( $this->columnToSortByBeforeTruncating, 'desc')); $rows = $this->table->getRows(); $count = $this->table->getRowsCount(); $newRow = new Piwik_DataTable_Row(); for($i = $this->startRowToSummarize; $i < $count; $i++) { if(!isset($rows[$i])) { // case when the last row is a summary row, it is not indexed by $cout but by Piwik_DataTable::ID_SUMMARY_ROW $summaryRow = $this->table->getRowFromId(Piwik_DataTable::ID_SUMMARY_ROW); $newRow->sumRow($summaryRow); } else { $newRow->sumRow($rows[$i]); } } $newRow->setColumns(array('label' => $this->labelSummaryRow) + $newRow->getColumns()); $this->table->filter('Limit', array(0, $this->startRowToSummarize)); $this->table->addSummaryRow($newRow); unset($rows); } }