Beispiel #1
0
 /**
  * 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);
 }
	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);
				$newRow->sumRow($summaryRow);
			}
			else
			{
				$newRow->sumRow($rows[$i]);
			}
		}
		
		$newRow->setColumns(array('label' => $this->labelSummaryRow) + $newRow->getColumns());
		$table->filter('Limit', array(0, $this->startRowToSummarize));
		$table->addSummaryRow($newRow);
		unset($rows);
	}
Beispiel #3
0
 public function getCompetitionDatatable()
 {
     $dataTable = new Piwik_DataTable();
     $row1 = new Piwik_DataTable_Row();
     $row1->setColumns(array('name' => 'piwik', 'license' => 'GPL'));
     $dataTable->addRow($row1);
     $dataTable->addRowFromSimpleArray(array('name' => 'google analytics', 'license' => 'commercial'));
     return $dataTable;
 }
Beispiel #4
0
 /**
  * Returns a custom data table.
  * This data table will be converted to all available formats 
  * when requested in the API request.
  * 
  * @return Piwik_DataTable
  */
 public function getCompetitionDatatable()
 {
     $dataTable = new Piwik_DataTable();
     $row1 = new Piwik_DataTable_Row();
     $row1->setColumns(array('name' => 'piwik', 'license' => 'GPL'));
     // Rows Metadata is useful to store non stats data for example (logos, urls, etc.)
     // When printed out, they are simply merged with columns
     $row1->setMetadata('logo', 'logo.png');
     $dataTable->addRow($row1);
     $dataTable->addRowFromSimpleArray(array('name' => 'google analytics', 'license' => 'commercial'));
     return $dataTable;
 }