[Piwik-svn] r180 - in trunk: . config modules modules/Archive modules/ArchiveProcessing modules/DataTable modules/DataTable/Renderer plugins/Provider

svnmaster at piwik.org svnmaster at piwik.org
Thu Jan 17 17:32:37 CET 2008


Author: matt
Date: 2008-01-17 17:32:37 +0100 (Thu, 17 Jan 2008)
New Revision: 180

Modified:
   trunk/config/global.ini.php
   trunk/index.php
   trunk/modules/Archive/Array.php
   trunk/modules/Archive/Single.php
   trunk/modules/ArchiveProcessing.php
   trunk/modules/ArchiveProcessing/Day.php
   trunk/modules/ArchiveProcessing/Period.php
   trunk/modules/ArchiveProcessing/Record.php
   trunk/modules/DataTable.php
   trunk/modules/DataTable/Renderer/Csv.php
   trunk/modules/DataTable/Renderer/Html.php
   trunk/modules/DataTable/Renderer/Json.php
   trunk/modules/DataTable/Renderer/Php.php
   trunk/modules/DataTable/Renderer/Xml.php
   trunk/modules/DataTable/Row.php
   trunk/modules/FrontController.php
   trunk/plugins/Provider/API.php
Log:
Work in progress....

Modified: trunk/config/global.ini.php
===================================================================
--- trunk/config/global.ini.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/config/global.ini.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -54,7 +54,7 @@
 [General]
 ; Time in seconds after which an archive will be computed again. 
 ; This setting is used only for today's statistics.
-time_before_archive_considered_outdated = 600
+time_before_archive_considered_outdated = 6000
 
 ; character used to automatically create categories in the "Action" "Downloads" reports
 ; for example a URL like "example.com/blog/development/first-post" will create 

Modified: trunk/index.php
===================================================================
--- trunk/index.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/index.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -22,7 +22,8 @@
 require_once PIWIK_INCLUDE_PATH . "/modules/testMinimumPhpVersion.php";
 
 
-//date_default_timezone_set('Europe/London');
+date_default_timezone_set(date_default_timezone_get());
+
 if(!defined('ENABLE_DISPATCH'))
 {
 	define('ENABLE_DISPATCH', true);	

Modified: trunk/modules/Archive/Array.php
===================================================================
--- trunk/modules/Archive/Array.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/Archive/Array.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -5,6 +5,8 @@
 class Piwik_Archive_Array extends Piwik_Archive
 {	
 	protected $archives = array();
+	protected $idArchiveToTimestamp = array();
+	protected $idArchives = array();
 	
 	
 	function __construct(Piwik_Site $oSite, $strPeriod, $strDate)
@@ -13,17 +15,33 @@
 		
 		foreach($rangePeriod->getSubperiods() as $subPeriod)
 		{
-			$archive = Piwik_Archive::build($oSite->getId(), $strPeriod, $subPeriod->getDateStart() );
+			$startDate = $subPeriod->getDateStart();
+			
+			$archive = Piwik_Archive::build($oSite->getId(), $strPeriod, $startDate );
 			$archive->prepareArchive();
 		
 			$this->archives[$archive->getIdArchive()] = $archive;
 			$this->idArchives[] = $archive->getIdArchive();
+			$this->idArchiveToTimestamp[$archive->getIdArchive()] = $startDate->getTimestamp();
 		}
 		
 		$this->inIdArchives = implode("",$this->idArchives);
+		uksort( $this->archives, array($this, 'sortArchiveByTimestamp') );
 	}
 	
+
+	protected function sortArchiveByTimestamp($a, $b)
+	{
+		return $this->idArchiveToTimestamp[$a] > $this->idArchiveToTimestamp[$b];  
+	}
 	
+	protected function getNewDataTableArray()
+	{
+		$table = new Piwik_DataTable_Array;
+		$table->setNameKey('date');
+		return $table;
+	}
+	
 	/**
 	 * Returns the value of the element $name from the current archive 
 	 * The value to be returned is a numeric value and is stored in the archive_numeric_* tables
@@ -33,7 +51,16 @@
 	 */
 	public function getNumeric( $name )
 	{
-		$table = new Piwik_DataTable_Array;
+		require_once "DataTable/Simple.php";
+		$table = $this->getNewDataTableArray();
+		
+		foreach($this->archives as $archive)
+		{
+			$numeric = $archive->getNumeric( $name ) ;
+			$subTable = new Piwik_DataTable_Simple();
+			$subTable->loadFromArray( array( $numeric ) );
+			$table->addTable($subTable, $archive->getPrettyDate());
+		}
 		return $table;
 	}
 	
@@ -49,24 +76,25 @@
 	 */
 	public function getBlob( $name )
 	{
-		$table = new Piwik_DataTable_Array;
+		require_once "DataTable/Simple.php";
+		$table = $this->getNewDataTableArray();
+		
+		foreach($this->archives as $archive)
+		{
+			$blob = $archive->getBlob( $name ) ;
+			$subTable = new Piwik_DataTable_Simple();
+			$subTable->loadFromArray( array('blob' => $blob));
+			$table->addTable($subTable, $archive->getPrettyDate());
+		}
 		return $table;
 	}
 	
 	/**
-	 * Given a list of fields defining numeric values, it will return a Piwik_DataTable_Simple 
-	 * containing one row per value.
-	 * 
-	 * For example $fields = array( 	'max_actions',
-	 *						'nb_uniq_visitors', 
-	 *						'nb_visits',
-	 *						'nb_actions', 
-	 *						'sum_visit_length',
-	 *						'bounce_count',
-	 *					); 
+	 * Given a list of fields defining numeric values, it will return a Piwik_DataTable_Array
+	 * which is an array of Piwik_DataTable_Simple, ordered by chronological order
 	 *
 	 * @param array $fields array( fieldName1, fieldName2, ...)
-	 * @return Piwik_DataTable_Simple
+	 * @return Piwik_DataTable_Array
 	 */
 	public function getDataTableFromNumeric( $fields )
 	{
@@ -109,10 +137,9 @@
 		$db = Zend_Registry::get('db');
 		
 		// date => array( 'field1' =>X, 'field2'=>Y)
-		// date2 => array( 'field1' =>X2, 'field2'=>Y2)
+		// date2 => array( 'field1' =>X2, 'field2'=>Y2)		
 		
-		$tableArray = new Piwik_DataTable_Array;
-		
+		$idarchiveToName = array();
 		foreach($queries as $table => $aIds)
 		{
 			$inIds = implode(', ', $aIds);
@@ -123,34 +150,34 @@
 
 			$values = $db->fetchAll($sql);
 			
-			$idarchiveToName = array();
 			foreach($values as $value)
 			{
 				$idarchiveToName[$value['idarchive']][$value['name']] = $value['value'];
-			}
-//			var_dump($idarchiveToName);exit;
+			}			
+		}
+		
+		// we need to take the Archives in chronological order 
+		uksort( $idarchiveToName, array($this, 'sortArchiveByTimestamp') );
+		
+//		var_dump($idarchiveToName);exit;
+		
+		$tableArray = $this->getNewDataTableArray();
+		foreach($idarchiveToName as $id => $aNameValues)
+		{
+			$strDate = $this->archives[$id]->getPrettyDate();
 			
-			foreach($idarchiveToName as $id => $aNameValues)
-			{
-				$strDate = $this->archives[$id]->getPrettyDate();
-				
-				$table = new Piwik_DataTable_Simple;
-				$table->loadFromArray($aNameValues);
-				
-//				echo $table; echo $strDate;exit;
-				$tableArray->addTable($table, $strDate);
-			}
+			$table = new Piwik_DataTable_Simple;
+			$table->loadFromArray($aNameValues);
+			
+			$tableArray->addTable($table, $strDate);
 		}
-				
 		return $tableArray;
 	}
 
 	/**
-	 * This method will build a dataTable from the blob value $name in the current archive.
+	 * Given a BLOB field name (eg. 'Referers_searchEngineByKeyword'), it will return a Piwik_DataTable_Array
+	 * which is an array of Piwik_DataTable, ordered by chronological order
 	 * 
-	 * For example $name = 'Referers_searchEngineByKeyword' will return a  Piwik_DataTable containing all the keywords
-	 * If a idSubTable is given, the method will return the subTable of $name 
-	 * 
 	 * @param string $name
 	 * @param int $idSubTable
 	 * @return Piwik_DataTable
@@ -158,7 +185,12 @@
 	 */
 	public function getDataTable( $name, $idSubTable = null )
 	{		
-		$table = new Piwik_DataTable_Array;
+		$table = $this->getNewDataTableArray();		
+		foreach($this->archives as $archive)
+		{
+			$subTable =  $archive->getDataTable( $name, $idSubTable ) ;
+			$table->addTable($subTable, $archive->getPrettyDate());
+		}
 		return $table;
 	}
 	
@@ -174,7 +206,12 @@
 	 */
 	public function getDataTableExpanded($name, $idSubTable = null)
 	{
-		$table = new Piwik_DataTable_Array;
+		$table = $this->getNewDataTableArray();
+		foreach($this->archives as $archive)
+		{
+			$subTable =  $archive->getDataTableExpanded( $name, $idSubTable ) ;
+			$table->addTable($subTable, $archive->getPrettyDate());
+		}
 		return $table;
 	}
-}
\ No newline at end of file
+}

Modified: trunk/modules/Archive/Single.php
===================================================================
--- trunk/modules/Archive/Single.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/Archive/Single.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -51,16 +51,17 @@
 			$archiveProcessing->setPeriod($this->period);
 			$IdArchive = $archiveProcessing->loadArchive();
 			
-			$this->archiveProcessing = $archiveProcessing;
-			$isThereSomeVisits = Zend_Registry::get('db')->fetchOne(
-					'SELECT value 
-					FROM '.$archiveProcessing->getTableArchiveNumericName().
-					' WHERE name = ? AND idarchive = ?', array('nb_visits',$IdArchive));
-					
-			if($isThereSomeVisits!==false)
-			{
-				$this->isThereSomeVisits = true;
-			}
+			$this->archiveProcessing = $archiveProcessing; 
+//			$isThereSomeVisits = Zend_Registry::get('db')->fetchOne(
+//					'SELECT value 
+//					FROM '.$archiveProcessing->getTableArchiveNumericName().
+//					' WHERE name = ? AND idarchive = ?', array('nb_visits',$IdArchive));
+//					
+//			if($isThereSomeVisits!==false)
+//			{
+//				$this->isThereSomeVisits = true;
+//			}
+			$this->isThereSomeVisits = $this->archiveProcessing->isThereSomeVisits;
 			$this->idArchive = $IdArchive;
 			$this->alreadyChecked = true;
 		}

Modified: trunk/modules/ArchiveProcessing/Day.php
===================================================================
--- trunk/modules/ArchiveProcessing/Day.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/ArchiveProcessing/Day.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -57,6 +57,8 @@
 		{
 			return;
 		}
+		
+		$this->isThereSomeVisits = true;
 	
 		foreach($row as $name => $value)
 		{

Modified: trunk/modules/ArchiveProcessing/Period.php
===================================================================
--- trunk/modules/ArchiveProcessing/Period.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/ArchiveProcessing/Period.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -211,8 +211,10 @@
 			'sum_visit_length',
 			'bounce_count',
 		);
-		$this->archiveNumericValuesSum($toSum);
+		$record = $this->archiveNumericValuesSum($toSum);
 		
+		$this->isThereSomeVisits = ($record['nb_visits']->value != 0);
+		
 		Piwik_PostEvent('ArchiveProcessing_Period.compute', $this);		
 	}
 }

Modified: trunk/modules/ArchiveProcessing/Record.php
===================================================================
--- trunk/modules/ArchiveProcessing/Record.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/ArchiveProcessing/Record.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -35,6 +35,7 @@
 		$this->value = $value;
 		Piwik_ArchiveProcessing_Record_Manager::getInstance()->registerRecord($this);
 	}
+	
 	public function delete()
 	{
 		Piwik_ArchiveProcessing_Record_Manager::getInstance()->unregister($this);

Modified: trunk/modules/ArchiveProcessing.php
===================================================================
--- trunk/modules/ArchiveProcessing.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/ArchiveProcessing.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -205,6 +205,7 @@
 	{
 		$this->loadArchiveProperties();
 		$this->idArchive = $this->isArchived();
+		
 		if(!$this->idArchive)
 		{
 //			Piwik::printMemoryUsage('Before loading subperiods');
@@ -222,6 +223,7 @@
 		else
 		{
 			//Piwik::log("Archive already available, id = {$this->idArchive}");
+			$this->isThereSomeVisits = true;
 		}
 		
 		return $this->idArchive;
@@ -390,21 +392,42 @@
 			$bindSQL[] = $this->maxTimestampArchive;
 		}
 			
-		$idarchive = Zend_Registry::get('db')->fetchOne("
-						SELECT idarchive
+		$results = Zend_Registry::get('db')->fetchAll("
+						SELECT idarchive, value, name
 						FROM ".$this->tableArchiveNumeric."
 						WHERE idsite = ?
 							AND date1 = ?
 							AND date2 = ?
 							AND period = ?
-							AND name = 'done'
-							AND value = ".Piwik_ArchiveProcessing::DONE_OK."
+							AND ( (name = 'done' AND value = ".Piwik_ArchiveProcessing::DONE_OK.")
+									OR name = 'nb_visits')
 							$timeStampWhere
 						ORDER BY ts_archived DESC",
 						$bindSQL
 					);
-		if(!empty($idarchive))
+		// the archive exists in the table
+		if(!empty($results))
 		{
+
+			// let's look for the more recent idarchive
+			foreach($results as $result)
+			{
+				if($result['name'] == 'done')
+				{
+					$idarchive = $result['idarchive'];
+					break;
+				}
+			}
+			// let's look for the nb_visits result for this more recent archive
+			foreach($results as $result)
+			{
+				if($result['name'] == 'nb_visits' 
+					&& $result['idarchive'] == $idarchive)
+				{
+					$this->isThereSomeVisits = ($result['value'] != 0);
+					break;
+				}
+			}
 			return $idarchive;
 		}
 		else

Modified: trunk/modules/DataTable/Renderer/Csv.php
===================================================================
--- trunk/modules/DataTable/Renderer/Csv.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/DataTable/Renderer/Csv.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -29,10 +29,13 @@
 	public $separator = ',';
 	public $exportDetail = true;
 	public $exportIdSubtable = true;
-
+	public $lineEnd = "\n";
+	
 	function __construct($table = null)
 	{
 		parent::__construct($table);
+		
+		
 	}
 	
 	function render()
@@ -47,6 +50,13 @@
 		// keep track of all the existing columns in the csv file
 		$allColumns = array();
 		
+		if($table instanceof Piwik_DataTable_Simple 
+			&& $table->getRowsCount() ==1)
+		{
+			$str = 'value' . $this->lineEnd . $table->getRowFromId(0)->getColumn('value');
+			return $this->output($str);
+		}
+		
 		foreach($table->getRows() as $row)
 		{
 			$csvRow = array();
@@ -106,7 +116,9 @@
 		
 		// specific case, we have only one column and this column wasn't named properly (indexed by a number)
 		// we don't print anything in the CSV file => an empty line
-		if(sizeof($allColumns) == 1 && reset($allColumns) && !is_string(key($allColumns))  )
+		if(sizeof($allColumns) == 1 
+			&& reset($allColumns) 
+			&& !is_string(key($allColumns))  )
 		{
 			$str .= '';
 		}
@@ -123,7 +135,7 @@
 		// we render the CSV
 		foreach($csv as $theRow)
 		{
-			$rowStr = "\n";
+			$rowStr = $this->lineEnd;
 			foreach($allColumns as $columnName => $true)
 			{
 				$rowStr .= $theRow[$columnName] . $this->separator;
@@ -134,6 +146,11 @@
 			$str .= $rowStr;
 		}
 		
+		return $this->output($str);
+	}
+	
+	protected function output( $str )
+	{
 		// silent fail otherwise unit tests fail
 		@header("Content-type: application/vnd.ms-excel");
 		@header("Content-Disposition: attachment; filename=piwik-report-export.csv");			

Modified: trunk/modules/DataTable/Renderer/Html.php
===================================================================
--- trunk/modules/DataTable/Renderer/Html.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/DataTable/Renderer/Html.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -34,6 +34,11 @@
 		{
 			return "<b><i>Empty table</i></b> <br>\n";
 		}
+		if($table instanceof Piwik_DataTable_Simple 
+			&& $table->getRowsCount() ==1)
+		{
+			$table->deleteColumn('label');
+		}
 		
 		static $depth=0;
 		$i = 1;

Modified: trunk/modules/DataTable/Renderer/Json.php
===================================================================
--- trunk/modules/DataTable/Renderer/Json.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/DataTable/Renderer/Json.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -31,8 +31,7 @@
 	protected function renderTable($table)
 	{
 		$renderer = new Piwik_DataTable_Renderer_Php($table, $serialize = false);
-		$array = $renderer->flatRender();
-		
+		$array = $renderer->flatRender();		
 		$str = json_encode($array);
 		return $str;
 	}

Modified: trunk/modules/DataTable/Renderer/Php.php
===================================================================
--- trunk/modules/DataTable/Renderer/Php.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/DataTable/Renderer/Php.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -56,17 +56,40 @@
 	 * @return array Php array representing the 'flat' version of the datatable
 	 *
 	 */
-	public function flatRender()
-	{
+	public function flatRender( $dataTable = null )
+	{
+		if(is_null($dataTable))
+		{
+			$dataTable = $this->table;
+		}
+		
+		if($dataTable instanceof Piwik_DataTable_Array)
+		{
+			$flatArray = array();
+			foreach($dataTable->getArray() as $keyName => $table)
+			{
+				$flatArray[$keyName] = $this->flatRender($table);
+			}
+			return $flatArray;
+		}
+		
 		// A DataTable_Simple is already flattened so no need to do some crazy stuff to convert it
-		if($this->table instanceof Piwik_DataTable_Simple)
+		else if($dataTable instanceof Piwik_DataTable_Simple)
 		{
-			$flatArray = $this->renderSimpleTable($this->table);
+			$flatArray = $this->renderSimpleTable($dataTable);
+			
+			// if we return only one numeric value then we print out the result in a simple <result> tag
+			// keep it simple!
+			if(count($flatArray) == 1)
+			{
+				$flatArray = current($flatArray);
+			}
+			
 		}
 		// A normal DataTable needs to be handled specifically
 		else
 		{
-			$array = $this->renderTable($this->table);
+			$array = $this->renderTable($dataTable);
 			$flatArray = array();
 			foreach($array as $row)
 			{
@@ -87,9 +110,13 @@
 		return $flatArray;
 	}
 	
-	public function render()
-	{
-		$toReturn = $this->flatRender();
+	public function render( $dataTable = null)
+	{
+		if(is_null($dataTable))
+		{
+			$dataTable = $this->table;
+		}
+		$toReturn = $this->flatRender( $dataTable );
 		return $toReturn;
 	}
 	

Modified: trunk/modules/DataTable/Renderer/Xml.php
===================================================================
--- trunk/modules/DataTable/Renderer/Xml.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/DataTable/Renderer/Xml.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -36,8 +36,7 @@
 		$renderer = new Piwik_DataTable_Renderer_Php($table, $serialize = false);
 		$array = $renderer->flatRender();
 		
-//		var_dump($array); exit;
-
+//		var_dump($array); exit;
 		
 		$options = array(
             XML_SERIALIZER_OPTION_INDENT       => '	',
@@ -45,6 +44,82 @@
 			XML_SERIALIZER_OPTION_ROOT_NAME    => 'row',
             XML_SERIALIZER_OPTION_MODE         => XML_SERIALIZER_MODE_SIMPLEXML
         );
+        $rootName = 'result';
+        
+		// case DataTable_Array
+		if($table instanceof Piwik_DataTable_Array)
+		{
+			
+			// CASE 1
+			//array
+	  		//  'day1' => string '14' (length=2)
+	  		//  'day2' => string '6' (length=1)
+			$firstTable = current($array);
+			if(!is_array( $firstTable ))
+			{
+		  		$xml = "<results>\n";
+		  		$nameDescriptionAttribute = $table->getNameKey();
+		  		foreach($array as $valueAttribute => $value)
+		  		{
+		  			$xml .= "\t<result $nameDescriptionAttribute=\"$valueAttribute\">$value</result>\n";
+		  		}
+		  		$xml .= "</results>";
+		  		return $this->output($xml);
+			}
+			
+			$subTables = $table->getArray();
+			$firstTable = current($subTables);
+			
+			// CASE 2
+			//array
+	  		//  'day1' => 
+	  		//    array
+	  		//      'nb_uniq_visitors' => string '18'
+	  		//      'nb_visits' => string '101' 
+	  		//  'day2' => 
+	  		//    array
+	  		//      'nb_uniq_visitors' => string '28' 
+	  		//      'nb_visits' => string '11' 
+			if( $firstTable instanceof Piwik_DataTable_Simple)
+			{
+		  		$xml = "<results>\n";
+				$nameDescriptionAttribute = $table->getNameKey();
+		  		foreach($array as $valueAttribute => $value)
+		  		{
+		  			$xml .= "\t<result $nameDescriptionAttribute=\"$valueAttribute\">".''."</result>\n";
+		  		}
+		  		$xml .= "</results>";
+		  		return $this->output($xml);
+			}
+			
+			// CASE 3
+			//array
+			//  'day1' => 
+			//    array
+			//      0 => 
+			//        array
+			//          'label' => string 'phpmyvisites'
+			//          'nb_unique_visitors' => int 11
+			//          'nb_visits' => int 13
+			//      1 => 
+			//        array
+			//          'label' => string 'phpmyvisits'
+			//          'nb_unique_visitors' => int 2
+			//          'nb_visits' => int 2
+			//  'day2' => 
+			//    array
+			//      0 => 
+			//        array
+			//          'label' => string 'piwik'
+			//          'nb_unique_visitors' => int 121
+			//          'nb_visits' => int 130
+			//      1 => 
+			//        array
+			//          'label' => string 'piwik bis'
+			//          'nb_unique_visitors' => int 20
+			//          'nb_visits' => int 120
+		}
+		
 		    
 		$serializer = new XML_Serializer($options);
 		
@@ -57,15 +132,20 @@
 
 		$xmlStr = $serializer->getSerializedData();
 		
-		if(get_class($table) == 'Piwik_DataTable')
+		if($table instanceof Piwik_DataTable
+			|| $table instanceof Piwik_DataTable_Array)
 		{
-			$xmlStr = "<result>\n".$xmlStr."\n</result>";
+			$xmlStr = "<$rootName>\n".$xmlStr."\n</$rootName>";
 			$xmlStr = str_replace(">\n", ">\n\t",$xmlStr);
-			$xmlStr = str_replace("\t</result>", "</result>",$xmlStr);
+			$xmlStr = str_replace("\t</$rootName>", "</$rootName>",$xmlStr);
 		}
-		
+		return $this->output($xmlStr);
+	}
+	
+	protected function output( $xml )
+	{
 		// silent fail because otherwise it throws an exception in the unit tests
 		@header('Content-type: text/xml');		
-		return $xmlStr;
+		return $xml;
 	}
 }
\ No newline at end of file

Modified: trunk/modules/DataTable/Row.php
===================================================================
--- trunk/modules/DataTable/Row.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/DataTable/Row.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -107,6 +107,10 @@
 		return $output;
 	}
 	
+	public function deleteColumn( $name )
+	{
+		unset($this->c[self::COLUMNS][$name]);
+	}
 	/**
 	 * Returns the given column
 	 * @param string Column name

Modified: trunk/modules/DataTable.php
===================================================================
--- trunk/modules/DataTable.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/DataTable.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -343,7 +343,13 @@
 		$totalCount += $this->getRowsCount();
 		return $totalCount;
 	}
-	
+	public function deleteColumn( $name )
+	{
+		foreach($this->getRows() as $row)
+		{
+			$row->deleteColumn($name);
+		}
+	}
 	public function deleteRow( $key )
 	{
 		if(!isset($this->rows[$key]))

Modified: trunk/modules/FrontController.php
===================================================================
--- trunk/modules/FrontController.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/modules/FrontController.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -102,8 +102,8 @@
 			Piwik::printQueryCount();
 		}catch(Exception $e) {}
 		
-		Piwik::printMemoryUsage();
-		Piwik::printTimer();
+//		Piwik::printMemoryUsage();
+//		Piwik::printTimer();
 //		Piwik::uninstall();
 //
 	}
@@ -220,22 +220,26 @@
 		
 //		Piwik::printMemoryUsage('Start program');
 
+		// can be used for debug purpose
 		$doNotDrop = array(
-				Piwik::prefixTable('log_visit'),
 				Piwik::prefixTable('access'),
 				Piwik::prefixTable('user'),
 				Piwik::prefixTable('site'),
-				Piwik::prefixTable('log_link_visit_action'),
-				Piwik::prefixTable('log_action'),
-				Piwik::prefixTable('log_profiling'),
 				Piwik::prefixTable('archive'),
+				
 				Piwik::prefixTable('logger_api_call'),
 				Piwik::prefixTable('logger_error'),
 				Piwik::prefixTable('logger_exception'),
 				Piwik::prefixTable('logger_message'),
+				
+				Piwik::prefixTable('log_visit'),
+				Piwik::prefixTable('log_link_visit_action'),
+				Piwik::prefixTable('log_action'),
+				Piwik::prefixTable('log_profiling'),
 		);
 		
-		Piwik::dropTables($doNotDrop);
+//		Piwik::dropTables($doNotDrop);
+
 		Piwik::createTables();
 		
 		Piwik_PluginsManager::getInstance()->installPlugins();

Modified: trunk/plugins/Provider/API.php
===================================================================
--- trunk/plugins/Provider/API.php	2008-01-17 04:58:59 UTC (rev 179)
+++ trunk/plugins/Provider/API.php	2008-01-17 16:32:37 UTC (rev 180)
@@ -36,7 +36,7 @@
 		}
 		return self::$instance;
 	}
-	
+
 	public function getProvider( $idSite, $period, $date )
 	{
 		Piwik::checkUserHasViewAccess( $idSite );
@@ -47,6 +47,19 @@
 		$dataTable->queueFilter('Piwik_DataTable_Filter_ReplaceColumnNames');
 		return $dataTable;
 	}
+	
+	/**
+	 * Example of getting a RAW BLOB
+	 *
+	 * @return blob
+	 */
+	public function getProviderBlob( $idSite, $period, $date )
+	{
+		Piwik::checkUserHasViewAccess( $idSite );
+		$archive = Piwik_Archive::build($idSite, $period, $date );
+		$dataTable = $archive->getBlob('Provider_hostnameExt');
+		return $dataTable;
+	}
 }
 
 



More information about the Piwik-svn mailing list