[Piwik-svn] r519 - in trunk: modules modules/DataTable modules/DataTable/Filter modules/DataTable/Renderer modules/DataTable/Row plugins/Actions plugins/Referers tests/modules

svnmaster at piwik.org svnmaster at piwik.org
Mon Jun 9 03:59:25 CEST 2008


Author: matt
Date: 2008-06-09 03:59:24 +0200 (Mon, 09 Jun 2008)
New Revision: 519

Added:
   trunk/modules/DataTable/Filter/ReplaceSummaryRowLabel.php
Modified:
   trunk/modules/DataTable.php
   trunk/modules/DataTable/Filter.php
   trunk/modules/DataTable/Filter/AddConstantMetadata.php
   trunk/modules/DataTable/Filter/AddSummaryRow.php
   trunk/modules/DataTable/Filter/ExcludeLowPopulation.php
   trunk/modules/DataTable/Filter/PatternRecursive.php
   trunk/modules/DataTable/Filter/ReplaceColumnNames.php
   trunk/modules/DataTable/Filter/Sort.php
   trunk/modules/DataTable/Manager.php
   trunk/modules/DataTable/Renderer.php
   trunk/modules/DataTable/Renderer/Csv.php
   trunk/modules/DataTable/Renderer/Html.php
   trunk/modules/DataTable/Renderer/Php.php
   trunk/modules/DataTable/Renderer/Rss.php
   trunk/modules/DataTable/Renderer/Xml.php
   trunk/modules/DataTable/Row.php
   trunk/modules/DataTable/Row/DataTableSummary.php
   trunk/modules/DataTable/Simple.php
   trunk/plugins/Actions/API.php
   trunk/plugins/Referers/API.php
   trunk/tests/modules/DataTable.test.php
Log:
- fixing bug in sum algorithm when there is a summary row.

Modified: trunk/modules/DataTable/Filter/AddConstantMetadata.php
===================================================================
--- trunk/modules/DataTable/Filter/AddConstantMetadata.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Filter/AddConstantMetadata.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -24,7 +24,6 @@
 	private $functionToApply;
 	private $metadataToAdd;
 	
-	
 	public function __construct( $table, $metadataName, $metadataValue )
 	{
 		parent::__construct($table);

Modified: trunk/modules/DataTable/Filter/AddSummaryRow.php
===================================================================
--- trunk/modules/DataTable/Filter/AddSummaryRow.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Filter/AddSummaryRow.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -1,32 +1,32 @@
 <?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: Limit.php 168 2008-01-14 05:26:43Z matt $
- * 
+ *
  * @package Piwik_DataTable
  */
 
 /**
- * Add a new row to the table containing a summary 
+ * Add a new row to the table containing a summary
  * of the rows from StartRowToSummarize to EndRowToSummarize.
  * It then deletes the rows from StartRowToSummarize to EndRowToSummarize.
  * The new row created has a label = 'other'
- * 
- * This filter is useful to build a more compact view of a table, 
+ *
+ * This filter is useful to build a more compact view of a table,
  * keeping the first records unchanged.
- * 
- * For example we use this for the pie chart, to build the last pie part 
- * which is the sum of all the remaining data after the top 5 data. 
+ *
+ * For example we use this for the pie chart, to build the last pie part
+ * which is the sum of all the remaining data after the top 5 data.
  * This row is assigned a label of 'Others'.
- * 
+ *
  * @package Piwik_DataTable
- * @subpackage Piwik_DataTable_Filter 
+ * @subpackage Piwik_DataTable_Filter
  */
 class Piwik_DataTable_Filter_AddSummaryRow extends Piwik_DataTable_Filter
-{	
+{
 	public $labelSummaryRow = Piwik_DataTable::LABEL_SUMMARY_ROW;
 
 	public function __construct( $table, $startRowToSummarize, $columnToSortByBeforeTruncating = Piwik_Archive::INDEX_NB_VISITS )
@@ -34,7 +34,7 @@
 		parent::__construct($table);
 		$this->startRowToSummarize = $startRowToSummarize;
 		$this->columnToSortByBeforeTruncating = $columnToSortByBeforeTruncating;
-		
+
 		if($table->getRowsCount() > $startRowToSummarize + 1)
 		{
 			$this->filter();
@@ -54,14 +54,14 @@
 			{
 				// 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); 
+				$newRow->sumRow($summaryRow);
 			}
 			else
 			{
 				$newRow->sumRow($rows[$i]);
 			}
 		}
-		$newRow->addColumn('label',$this->labelSummaryRow);
+		$newRow->addColumn('label', $this->labelSummaryRow);
 		$filter = new Piwik_DataTable_Filter_Limit($this->table, 0, $this->startRowToSummarize);
 		$this->table->addSummaryRow($newRow);
 	}

Modified: trunk/modules/DataTable/Filter/ExcludeLowPopulation.php
===================================================================
--- trunk/modules/DataTable/Filter/ExcludeLowPopulation.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Filter/ExcludeLowPopulation.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -40,7 +40,6 @@
 												$this->columnToFilter, 
 												$function
 											);
-		
 	}
 	
 	static public function excludeLowPopulation($value)

Modified: trunk/modules/DataTable/Filter/PatternRecursive.php
===================================================================
--- trunk/modules/DataTable/Filter/PatternRecursive.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Filter/PatternRecursive.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -31,7 +31,6 @@
 		$this->patternToSearch = $patternToSearch;//preg_quote($patternToSearch);
 		$this->columnToFilter = $columnToFilter;
 		$this->filter();
-//		echo $this->table; exit;
 	}
 	
 	protected function filter( $table = null )

Modified: trunk/modules/DataTable/Filter/ReplaceColumnNames.php
===================================================================
--- trunk/modules/DataTable/Filter/ReplaceColumnNames.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Filter/ReplaceColumnNames.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -27,7 +27,7 @@
 class Piwik_DataTable_Filter_ReplaceColumnNames extends Piwik_DataTable_Filter
 {
 	/*
-	 * old column name => new column name
+	 * Old column name => new column name
 	 */
 	protected $mappingToApply = array(
 				Piwik_Archive::INDEX_NB_UNIQ_VISITORS 	=> 'nb_uniq_visitors',

Added: trunk/modules/DataTable/Filter/ReplaceSummaryRowLabel.php
===================================================================
--- trunk/modules/DataTable/Filter/ReplaceSummaryRowLabel.php	                        (rev 0)
+++ trunk/modules/DataTable/Filter/ReplaceSummaryRowLabel.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -0,0 +1,42 @@
+<?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: ReplaceColumnNames.php 482 2008-05-18 17:22:35Z matt $
+ * 
+ * @package Piwik_DataTable
+ */
+
+/**
+ * 
+ * @package Piwik_DataTable
+ * @subpackage Piwik_DataTable_Filter 
+ */
+class Piwik_DataTable_Filter_ReplaceSummaryRowLabel extends Piwik_DataTable_Filter
+{
+	public function __construct( $table, $newLabel = null)
+	{
+		parent::__construct($table);
+		if(is_null($newLabel))
+		{
+			$newLabel = Piwik_Translate('General_Others');
+		}
+		$this->newLabel = $newLabel;
+		$this->filter();
+	}
+	
+	protected function filter()
+	{
+		foreach($this->table->getRows() as $row)
+		{
+			if($row->getColumn('label') === Piwik_DataTable::LABEL_SUMMARY_ROW)
+			{
+				$row->setColumn('label', $this->newLabel);
+				break;
+			}
+		}
+	}
+}
+

Modified: trunk/modules/DataTable/Filter/Sort.php
===================================================================
--- trunk/modules/DataTable/Filter/Sort.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Filter/Sort.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -106,7 +106,6 @@
 		}
 		else
 		{
-			
 			if($this->naturalSort)
 			{
 				$methodToUse = "naturalSort";
@@ -115,9 +114,7 @@
 			{
 				$methodToUse = "sortString";
 			}
-
 		}
-		
 		$this->table->sort( array($this,$methodToUse) );
 	}
 }

Modified: trunk/modules/DataTable/Filter.php
===================================================================
--- trunk/modules/DataTable/Filter.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Filter.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -55,3 +55,4 @@
 require_once "DataTable/Filter/ReplaceColumnNames.php";
 require_once "DataTable/Filter/Sort.php";
 require_once "DataTable/Filter/AddSummaryRow.php";
+require_once "DataTable/Filter/ReplaceSummaryRowLabel.php";

Modified: trunk/modules/DataTable/Manager.php
===================================================================
--- trunk/modules/DataTable/Manager.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Manager.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -19,9 +19,6 @@
 class Piwik_DataTable_Manager
 {
 	static private $instance = null;
-	protected function __construct()
-	{}
-	
 	/**
 	 * Returns instance
 	 *
@@ -36,6 +33,7 @@
 		}
 		return self::$instance;
 	}
+	
 	/**
 	 * Array used to store the DataTable
 	 *
@@ -84,7 +82,6 @@
 	
 	public function deleteTable( $id )
 	{
-//		echo "d $id ; ";
 		if(isset($this->tables[$id]))
 		{
 			$this->tables[$id] = null;

Modified: trunk/modules/DataTable/Renderer/Csv.php
===================================================================
--- trunk/modules/DataTable/Renderer/Csv.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Renderer/Csv.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -56,12 +56,9 @@
 	 */
 	public $exportIdSubtable = true;
 	
-	
 	function __construct($table = null)
 	{
 		parent::__construct($table);
-		
-		
 	}
 	
 	function render()
@@ -71,7 +68,6 @@
 	
 	protected function renderTable($table)
 	{
-		
 		if($table instanceof Piwik_DataTable_Array)
 		{
 			$str = $header = '';
@@ -97,7 +93,6 @@
 					$str .= "\n" .  implode("\n", $returned);
 				}
 			}
-//				var_dump($header);exit;
 			if(!empty($header))
 			{
 				$str = $prefixColumns . $header . $str;

Modified: trunk/modules/DataTable/Renderer/Html.php
===================================================================
--- trunk/modules/DataTable/Renderer/Html.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Renderer/Html.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -47,13 +47,11 @@
 		{
 			$out = $this->renderDataTable($table);
 		}
-		
 		return $out;
 	}	
 	
 	protected function renderDataTable($table)
 	{
-	
 		if($table->getRowsCount() == 0)
 		{
 			return "<b><i>Empty table</i></b> <br>\n";
@@ -78,7 +76,6 @@
 		 * 		subtable here
 		 */
 		$allColumns = array();
-//		echo $table;
 		foreach($table->getRows() as $row)
 		{
 			foreach($row->getColumns() as $column => $value)
@@ -122,15 +119,6 @@
 			$i++;
 		}
 		
-		/*
-		// to keep the same columns order as the columns labelled with strings
-		ksort($allColumns);
-		//replace the label first
-		if(isset($allColumns['label']))
-		{
-			$allColumns = array_merge(array('label'=>true),$allColumns);
-		}
-		*/
 		$allColumns['_metadata'] = $someMetadata;
 		$allColumns['_idSubtable'] = $someIdSubTable;
 		$html = "\n";
@@ -169,7 +157,6 @@
 			
 			if(isset($row['_subtable']))
 			{
-//				echo ".".$row['_subtable'];exit;
 				$html .= "<tr>
 						<td class=l{$row['_subtable']['depth']} colspan=$colspan>{$row['_subtable']['html']}</td></tr>";
 			}

Modified: trunk/modules/DataTable/Renderer/Php.php
===================================================================
--- trunk/modules/DataTable/Renderer/Php.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Renderer/Php.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -160,7 +160,6 @@
 		{
 			$array = serialize($array);
 		}
-		
 		return $array;
 	}
 	
@@ -195,12 +194,10 @@
 	protected function renderSimpleTable($table)
 	{
 		$array = array();
-
 		foreach($table->getRows() as $row)
 		{
 			$array[$row->getColumn('label')] = $row->getColumn('value');
 		}
-		
 		return $array;
 	}
 }
\ No newline at end of file

Modified: trunk/modules/DataTable/Renderer/Rss.php
===================================================================
--- trunk/modules/DataTable/Renderer/Rss.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Renderer/Rss.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -121,7 +121,6 @@
 		 * 		subtable here
 		 */
 		$allColumns = array();
-//		echo $table;
 		foreach($table->getRows() as $row)
 		{
 			foreach($row->getColumns() as $column => $value)
@@ -131,16 +130,6 @@
 			}
 			$i++;
 		}
-		
-		/*
-		// to keep the same columns order as the columns labelled with strings
-		ksort($allColumns);
-		//replace the label first
-		if(isset($allColumns['label']))
-		{
-			$allColumns = array_merge(array('label'=>true),$allColumns);
-		}
-		*/
 		$html = "\n";
 		$html .= "<table border=1 width=70%>";
 		$html .= "\n<tr>";
@@ -174,10 +163,7 @@
 			
 		}
 		$html .= "\n\n</table>";
-		
 		return $html;
 	}
 }
 
-
-

Modified: trunk/modules/DataTable/Renderer/Xml.php
===================================================================
--- trunk/modules/DataTable/Renderer/Xml.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Renderer/Xml.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -42,7 +42,6 @@
 	{
 		$array = $this->getArrayFromDataTable($table);
 		
-		// case DataTable_Array
 		if($table instanceof Piwik_DataTable_Array)
 		{
 			$out = $this->renderDataTableArray($table, $array, $prefixLines);
@@ -75,7 +74,6 @@
 			{
 				$out = $array;
 			}
-		
 			if($returnOnlyDataTableXml)
 			{
 				return $out;
@@ -156,7 +154,6 @@
 			$nameDescriptionAttribute = $table->getKeyName();
 	  		foreach($array as $valueAttribute => $dataTableSimple)
 	  		{
-//	  			var_dump($dataTableSimple);exit;
 	  			if(count($dataTableSimple) == 0)
 				{
 					$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\" />\n";
@@ -205,7 +202,6 @@
 			$nameDescriptionAttribute = $table->getKeyName();
 			foreach($array as $keyName => $arrayForSingleDate)
 			{
-//				var_dump($arrayForSingleDate);exit;
 				$dataTableOut = $this->renderDataTable( $arrayForSingleDate, $prefixLines . "\t" );
 				if(empty($dataTableOut))
 				{

Modified: trunk/modules/DataTable/Renderer.php
===================================================================
--- trunk/modules/DataTable/Renderer.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Renderer.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -90,8 +90,7 @@
 		$className = 'Piwik_DataTable_Renderer_' . $name;
 		
 		if( Piwik_Common::isValidFilename($name)
-			&& Zend_Loader::isReadable($path)
-		)
+			&& Zend_Loader::isReadable($path) )
 		{
 			require_once $path;
 			return new $className;			

Modified: trunk/modules/DataTable/Row/DataTableSummary.php
===================================================================
--- trunk/modules/DataTable/Row/DataTableSummary.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Row/DataTableSummary.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -31,4 +31,3 @@
 		}
 	}
 }
-

Modified: trunk/modules/DataTable/Row.php
===================================================================
--- trunk/modules/DataTable/Row.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Row.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -402,4 +402,3 @@
 }
 
 require_once "Row/DataTableSummary.php";
-

Modified: trunk/modules/DataTable/Simple.php
===================================================================
--- trunk/modules/DataTable/Simple.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable/Simple.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -59,5 +59,3 @@
 		return $row->getColumn('value');
 	}
 }
-
-

Modified: trunk/modules/DataTable.php
===================================================================
--- trunk/modules/DataTable.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/modules/DataTable.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -14,13 +14,9 @@
 require_once "DataTable/Filter.php";
 require_once "DataTable/Row.php";
 require_once "DataTable/Manager.php";
+
 /**
  * 
- * Initial Specification 
- * ---------------------------------------------------------
- * CAREFUL: It may be outdated as I have not reviewed it yet
- * ---------------------------------------------------------
- * 
  * ---- DataTable
  * A DataTable is a data structure used to store complex tables of data.
  * 
@@ -37,8 +33,8 @@
  * ---- DataTable_Row
  * A DataTableRow in the table is defined by
  * - multiple columns (a label, multiple values, ...)
- * - metadata
- * - [a sub DataTable associated to this row]
+ * - optional metadata
+ * - optional - a sub DataTable associated to this row
  * 
  * Simple row example:
  * - columns = array(   'label' => 'Firefox', 
@@ -121,6 +117,20 @@
  * $XMLstring = $xmlOutput->getOutput();
  * 
  * 
+ * ---- Other (ideas)
+ * We can also imagine building a DataTable_Compare which would take 2 DataTable that have the same
+ * structure and would compare them, by computing the percentages of differences, etc.
+ * 
+ * For example 
+ * DataTable1 = [ keyword1, 1550 visits]
+ * 				[ keyword2, 154 visits ]
+ * DataTable2 = [ keyword1, 1004 visits ]
+ * 				[ keyword3, 659 visits ]
+ * DataTable_Compare = result of comparison of table1 with table2
+ * 						[ keyword1, +154% ]
+ * 						[ keyword2, +1000% ]
+ * 						[ keyword3, -430% ]
+ * 
  * @see Piwik_DataTable_Row A Piwik_DataTable is composed of Piwik_DataTable_Row
  * 
  * @package Piwik
@@ -323,11 +333,16 @@
 		{
 			$labelToLookFor = $row->getColumn('label');
 			$rowFound = $this->getRowFromLabel( $labelToLookFor );
-			
-			// the row with this label not found
 			if($rowFound === false)
 			{
-				$this->addRow( $row );
+				if( $labelToLookFor === self::LABEL_SUMMARY_ROW )
+				{
+					$this->addSummaryRow($row );
+				}
+				else
+				{
+					$this->addRow( $row );
+				}
 			}
 			else
 			{
@@ -388,7 +403,6 @@
 				$this->rowsIndexByLabel[$label] = $id;
 			}
 		}
-		
 		$this->indexNotUpToDate = false;
 	}
 	
@@ -423,6 +437,11 @@
 		$this->indexNotUpToDate = true;
 	}
 	
+	/**
+	 * Sets the summary row (a dataTable can have only one summary row)
+	 *
+	 * @param Piwik_DataTable_Row $row
+	 */
 	public function addSummaryRow( Piwik_DataTable_Row $row )
 	{
 		$this->summaryRow = $row;
@@ -982,39 +1001,17 @@
 			{
 				$cleanRow[Piwik_DataTable_Row::DATATABLE_ASSOCIATED] = $subtablePerLabel[$label];
 			}
-			
 			$this->addRow( new Piwik_DataTable_Row($cleanRow) );
 		}
 	}
 	
-
-	
 	/**
 	 * At destruction we try to free memory
 	 * But php doesn't give us much control on this
 	 */
 	public function __destruct()
 	{
-//		static $c = 0;
-//		$c++;
-//		echo " k ".$this->getId();
 		unset($this->rows);
 	}
 	
 }
-
-/**
- * ---- Other
- * We can also imagine building a DataTable_Compare which would take 2 DataTable that have the same
- * structure and would compare them, by computing the percentages of differences, etc.
- * 
- * For example 
- * DataTable1 = [ keyword1, 1550 visits]
- * 				[ keyword2, 154 visits ]
- * DataTable2 = [ keyword1, 1004 visits ]
- * 				[ keyword3, 659 visits ]
- * DataTable_Compare = result of comparison of table1 with table2
- * 						[ keyword1, +154% ]
- * 						[ keyword2, +1000% ]
- * 						[ keyword3, -430% ]
- */

Modified: trunk/plugins/Actions/API.php
===================================================================
--- trunk/plugins/Actions/API.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/plugins/Actions/API.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -49,7 +49,8 @@
 		else
 		{
 			$dataTable = $archive->getDataTable($name, $idSubtable);
-		}
+		}
+		$dataTable->queueFilter('Piwik_DataTable_Filter_ReplaceSummaryRowLabel');
 		return $dataTable;
 	}
 	

Modified: trunk/plugins/Referers/API.php
===================================================================
--- trunk/plugins/Referers/API.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/plugins/Referers/API.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -42,6 +42,7 @@
 			$dataTable = $archive->getDataTable($name, $idSubtable);
 		}
 		$dataTable->queueFilter('Piwik_DataTable_Filter_ReplaceColumnNames');
+		$dataTable->queueFilter('Piwik_DataTable_Filter_ReplaceSummaryRowLabel');
 		return $dataTable;
 	}
 	

Modified: trunk/tests/modules/DataTable.test.php
===================================================================
--- trunk/tests/modules/DataTable.test.php	2008-06-09 00:44:10 UTC (rev 518)
+++ trunk/tests/modules/DataTable.test.php	2008-06-09 01:59:24 UTC (rev 519)
@@ -729,48 +729,6 @@
 	  	$this->assertTrue( Piwik_DataTable::isEqual($table1, $tableExpected) );
 	}
 	
-	protected function getDataTable1ForTest()
-	{
-		$idcol = Piwik_DataTable_Row::COLUMNS;
-		
-		$rows = array(
-	  		array( $idcol => array('label'=>'google', 'visits' => 1)),
-	  		array( $idcol => array('label'=>'ask', 'visits' => 2)),
-	  		array( $idcol => array('label'=>'123', 'visits' => 2)),
-  		);	  	
-	 	$table = new Piwik_DataTable;
-	  	$table->loadFromArray( $rows );
-	  	return $table;
-	}
-
-	protected function getDataTable2ForTest()
-	{
-		$rows = $this->getRowsDataTable2ForTest();	
-	 	$table = new Piwik_DataTable;
-	  	$table->loadFromArray( $rows );
-	  	return $table;
-	}
-
-	protected function getRowsDataTable2ForTest()
-	{
-		$rows = array(
-	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>'test', 'visits' => 1)),
-	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>' google ', 'visits' => 3)),
-	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>'123a', 'visits' => 2)),
-  		);
-  		return $rows;	  	
-	}
-	
-	protected function getRowsDataTable1ForTest()
-	{
-		$rows = array(
-	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>'google', 'visits' => 1)),
-	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>'ask', 'visits' => 2)),
-	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>'123', 'visits' => 2)),
-  		);
-  		return $rows;	  	
-	}
-	
 	/**
      * add 2 datatable with some common rows 
      */
@@ -783,6 +741,7 @@
 	  		array( $idcol => array('label'=>'google', 'visits' => 1)),
 	  		array( $idcol => array('label'=>'ask', 'visits' => 2)),
 	  		array( $idcol => array('label'=>'123', 'visits' => 2)),
+	  		Piwik_DataTable::ID_SUMMARY_ROW => array( $idcol => array('label'=>Piwik_DataTable::LABEL_SUMMARY_ROW, 'visits' => 7))
   		);	  	
 	 	$table = new Piwik_DataTable;
 	  	$table->loadFromArray( $rows );
@@ -805,6 +764,7 @@
 	  		array( $idcol => array('label'=>'123', 'visits' => 4)),
 	  		array( $idcol => array('label'=>'test', 'visits' => 1)),
 	  		array( $idcol => array('label'=>' google ', 'visits' => 5)),
+	  		Piwik_DataTable::ID_SUMMARY_ROW => array( $idcol  => array('label'=>Piwik_DataTable::LABEL_SUMMARY_ROW, 'visits' => 7))
   		);	  	
 	  	$tableExpected = new Piwik_DataTable;
 	  	$tableExpected->loadFromArray( $rowsExpected );
@@ -823,6 +783,7 @@
 	  		array( $idcol => array('label'=>'google', 'visits' => 1)),
 	  		array( $idcol => array('label'=>'ask', 'visits' => 2)),
 	  		array( $idcol => array('label'=>'123', 'visits' => 2)),
+	  		Piwik_DataTable::ID_SUMMARY_ROW => array( $idcol  => array('label'=>Piwik_DataTable::LABEL_SUMMARY_ROW, 'visits' => 7))
   		);	  	
 	 	$table = new Piwik_DataTable;
 	  	$table->loadFromArray( $rows );
@@ -832,6 +793,7 @@
 	  		array( $idcol => array('label'=>'google', 'visits' => -1)),
 	  		array( $idcol => array('label'=>'ask', 'visits' => 0)),
 	  		array( $idcol => array('label'=>'123', 'visits' => 1.5)),
+	  		Piwik_DataTable::ID_SUMMARY_ROW => array( $idcol  => array('label'=>Piwik_DataTable::LABEL_SUMMARY_ROW, 'visits' => 8))
   		);	  	
 	 	$table2 = new Piwik_DataTable;
 	  	$table2->loadFromArray( $rows2 );
@@ -842,6 +804,7 @@
 	  		array( $idcol => array('label'=>'google', 'visits' => 0)),
 	  		array( $idcol => array('label'=>'ask', 'visits' => 2)),
 	  		array( $idcol => array('label'=>'123', 'visits' => 3.5)),
+	  		Piwik_DataTable::ID_SUMMARY_ROW => array( $idcol  => array('label'=>Piwik_DataTable::LABEL_SUMMARY_ROW, 'visits' => 15))
   		);	  	
 	  	$tableExpected = new Piwik_DataTable;
 	  	$tableExpected->loadFromArray( $rowsExpected );
@@ -852,7 +815,6 @@
 	/**
 	 * test add 2 different tables to the same table
 	 */
-	 
     public function test_addDataTable2times()
 	{
 	 
@@ -862,6 +824,7 @@
 	  		array( $idcol => array('label'=>'google', 'visits' => 1)),
 	  		array( $idcol => array('label'=>'ask', 'visits' => 0)),
 	  		array( $idcol => array('label'=>'123', 'visits' => 2)),
+	  		Piwik_DataTable::ID_SUMMARY_ROW => array( $idcol  => array('label'=>Piwik_DataTable::LABEL_SUMMARY_ROW, 'visits' => 1))
   		);	  	
 	 	$table = new Piwik_DataTable;
 	  	$table->loadFromArray( $rows );
@@ -880,6 +843,7 @@
 	  		array( $idcol => array('label'=>'google2', 'visits' => -1)),
 	  		array( $idcol => array('label'=>'ask', 'visits' => -10)),
 	  		array( $idcol => array('label'=>'123ab', 'visits' => 1.5)),
+	  		Piwik_DataTable::ID_SUMMARY_ROW => array( $idcol  => array('label'=>Piwik_DataTable::LABEL_SUMMARY_ROW, 'visits' => 3))
   		);	  	
 	 	$table3 = new Piwik_DataTable;
 	  	$table3->loadFromArray( $rows3 );
@@ -895,6 +859,7 @@
 	  		array( $idcol => array('label'=>'google2', 'visits' => -2)),
 	  		array( $idcol => array('label'=>'123456', 'visits' => 1.5)),
 	  		array( $idcol => array('label'=>'123ab', 'visits' => 1.5)),
+	  		Piwik_DataTable::ID_SUMMARY_ROW => array( $idcol  => array('label'=>Piwik_DataTable::LABEL_SUMMARY_ROW, 'visits' => 4))
   		);
 	  	$tableExpected = new Piwik_DataTable;
 	  	$tableExpected->loadFromArray( $rowsExpected );
@@ -902,5 +867,43 @@
 	  	$this->assertTrue( Piwik_DataTable::isEqual($table, $tableExpected) );
 	}
 	
+	protected function getDataTable1ForTest()
+	{
+		$rows = $this->getRowsDataTable1ForTest();
+	 	$table = new Piwik_DataTable;
+	  	$table->loadFromArray( $rows );
+	  	return $table;
+	}
 
+	protected function getDataTable2ForTest()
+	{
+		$rows = $this->getRowsDataTable2ForTest();	
+	 	$table = new Piwik_DataTable;
+	  	$table->loadFromArray( $rows );
+	  	return $table;
+	}
+	
+	protected function getRowsDataTable1ForTest()
+	{
+		$rows = array(
+	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>'google', 'visits' => 1)),
+	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>'ask', 'visits' => 2)),
+	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>'123', 'visits' => 2)),
+	  		Piwik_DataTable::ID_SUMMARY_ROW => array( Piwik_DataTable_Row::COLUMNS  => array('label'=>Piwik_DataTable::LABEL_SUMMARY_ROW, 'visits' => 4))
+	  		
+  		);
+  		return $rows;	  	
+	}
+
+	protected function getRowsDataTable2ForTest()
+	{
+		$rows = array(
+	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>'test', 'visits' => 1)),
+	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>' google ', 'visits' => 3)),
+	  		array( Piwik_DataTable_Row::COLUMNS => array('label'=>'123a', 'visits' => 2)),
+  		);
+  		return $rows;	  	
+	}
+	
+
 }
\ No newline at end of file



More information about the Piwik-svn mailing list