diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-03-28 03:42:39 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-03-28 03:42:40 +0400 |
commit | ae4b03163792f0b6e933933e5d37df87dc3fd566 (patch) | |
tree | d1d7510a9728f587d3d63ebd03e4ecf3d904838b /core/DataTable/Filter/AddSummaryRow.php | |
parent | 158c2150f5f2e13ece459b8d131244c11b763997 (diff) |
Mass conversion of all files to the newly agreed coding standard: PSR 1/2
Converting Piwik core source files, PHP, JS, TPL, CSS
More info: http://piwik.org/participate/coding-standards/
Diffstat (limited to 'core/DataTable/Filter/AddSummaryRow.php')
-rw-r--r-- | core/DataTable/Filter/AddSummaryRow.php | 123 |
1 files changed, 58 insertions, 65 deletions
diff --git a/core/DataTable/Filter/AddSummaryRow.php b/core/DataTable/Filter/AddSummaryRow.php index d9a9966022..5bb2a5e10c 100644 --- a/core/DataTable/Filter/AddSummaryRow.php +++ b/core/DataTable/Filter/AddSummaryRow.php @@ -27,70 +27,63 @@ */ class Piwik_DataTable_Filter_AddSummaryRow extends Piwik_DataTable_Filter { - /** - * Creates a new filter and set all required parameters - * - * @param Piwik_DataTable $table - * @param int $startRowToSummarize - * @param int $labelSummaryRow - * @param null $columnToSortByBeforeTruncating - * @param bool $deleteRows - */ - public function __construct($table, - $startRowToSummarize, - $labelSummaryRow = Piwik_DataTable::LABEL_SUMMARY_ROW, - $columnToSortByBeforeTruncating = null, - $deleteRows = true ) - { - parent::__construct($table); - $this->startRowToSummarize = $startRowToSummarize; - $this->labelSummaryRow = $labelSummaryRow; - $this->columnToSortByBeforeTruncating = $columnToSortByBeforeTruncating; - $this->deleteRows = $deleteRows; - } + /** + * Creates a new filter and set all required parameters + * + * @param Piwik_DataTable $table + * @param int $startRowToSummarize + * @param int $labelSummaryRow + * @param null $columnToSortByBeforeTruncating + * @param bool $deleteRows + */ + public function __construct($table, + $startRowToSummarize, + $labelSummaryRow = Piwik_DataTable::LABEL_SUMMARY_ROW, + $columnToSortByBeforeTruncating = null, + $deleteRows = true) + { + parent::__construct($table); + $this->startRowToSummarize = $startRowToSummarize; + $this->labelSummaryRow = $labelSummaryRow; + $this->columnToSortByBeforeTruncating = $columnToSortByBeforeTruncating; + $this->deleteRows = $deleteRows; + } - /** - * Adds a summary row to the given data table - * - * @param Piwik_DataTable $table - */ - public function filter($table) - { - if($table->getRowsCount() <= $this->startRowToSummarize + 1) - { - return; - } - $table->filter('Sort', - array( $this->columnToSortByBeforeTruncating, 'desc')); - - $rows = $table->getRows(); - $count = $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 = $table->getRowFromId(Piwik_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); - } - } - else - { - $newRow->sumRow($rows[$i], $enableCopyMetadata = false); - } - } - - $newRow->setColumns(array('label' => $this->labelSummaryRow) + $newRow->getColumns()); - if ($this->deleteRows) - { - $table->filter('Limit', array(0, $this->startRowToSummarize)); - } - $table->addSummaryRow($newRow); - unset($rows); - } + /** + * Adds a summary row to the given data table + * + * @param Piwik_DataTable $table + */ + public function filter($table) + { + if ($table->getRowsCount() <= $this->startRowToSummarize + 1) { + return; + } + $table->filter('Sort', + array($this->columnToSortByBeforeTruncating, 'desc')); + + $rows = $table->getRows(); + $count = $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 = $table->getRowFromId(Piwik_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); + } + } else { + $newRow->sumRow($rows[$i], $enableCopyMetadata = false); + } + } + + $newRow->setColumns(array('label' => $this->labelSummaryRow) + $newRow->getColumns()); + if ($this->deleteRows) { + $table->filter('Limit', array(0, $this->startRowToSummarize)); + } + $table->addSummaryRow($newRow); + unset($rows); + } } |