diff options
author | diosmosis <benakamoorthi@fastmail.fm> | 2013-10-22 08:44:25 +0400 |
---|---|---|
committer | diosmosis <benakamoorthi@fastmail.fm> | 2013-10-22 09:57:54 +0400 |
commit | 66add89b764c709869c1b4976a4a447a4e61be4c (patch) | |
tree | c6b33350775bdda2ec2ce16953bb92dad68c80c9 /core/DataTable/Filter/AddSummaryRow.php | |
parent | a10eb83bfc85221b0afaedccfae881a55639d782 (diff) |
Refs #4200, change function of AddSummaryRow and move logic to Truncate filter.
Diffstat (limited to 'core/DataTable/Filter/AddSummaryRow.php')
-rw-r--r-- | core/DataTable/Filter/AddSummaryRow.php | 44 |
1 files changed, 5 insertions, 39 deletions
diff --git a/core/DataTable/Filter/AddSummaryRow.php b/core/DataTable/Filter/AddSummaryRow.php index 371b6df1fe..a050e31e1a 100644 --- a/core/DataTable/Filter/AddSummaryRow.php +++ b/core/DataTable/Filter/AddSummaryRow.php @@ -41,17 +41,10 @@ class AddSummaryRow extends Filter * @param null $columnToSortByBeforeTruncating * @param bool $deleteRows */ - public function __construct($table, - $startRowToSummarize, - $labelSummaryRow = DataTable::LABEL_SUMMARY_ROW, - $columnToSortByBeforeTruncating = null, - $deleteRows = true) + public function __construct($table, $labelSummaryRow = DataTable::LABEL_SUMMARY_ROW) { parent::__construct($table); - $this->startRowToSummarize = $startRowToSummarize; $this->labelSummaryRow = $labelSummaryRow; - $this->columnToSortByBeforeTruncating = $columnToSortByBeforeTruncating; - $this->deleteRows = $deleteRows; } /** @@ -61,35 +54,8 @@ class AddSummaryRow extends Filter */ public function filter($table) { - $table->filter('Sort', - array($this->columnToSortByBeforeTruncating, 'desc')); - - if ($table->getRowsCount() <= $this->startRowToSummarize + 1) { - return; - } - - $rows = $table->getRows(); - $count = $table->getRowsCount(); - $newRow = new 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 DataTable::ID_SUMMARY_ROW - $summaryRow = $table->getRowFromId(DataTable::ID_SUMMARY_ROW); - - //FIXME: I'm not sure why it could return false, but it was reported in: http://forum.piwik.org/read.php?2,89324,page=1#msg-89442 - if ($summaryRow) { - $newRow->sumRow($summaryRow, $enableCopyMetadata = false, $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME)); - } - } else { - $newRow->sumRow($rows[$i], $enableCopyMetadata = false, $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME)); - } - } - - $newRow->setColumns(array('label' => $this->labelSummaryRow) + $newRow->getColumns()); - if ($this->deleteRows) { - $table->filter('Limit', array(0, $this->startRowToSummarize)); - } - $table->addSummaryRow($newRow); - unset($rows); + $row = new DataTableSummaryRow($table); + $row->setColumn('label', $this->labelSummaryRow); + $table->addSummaryRow($row); } -} +}
\ No newline at end of file |