[Piwik-svn] r395 - in trunk: . modules modules/API modules/Archive modules/ArchiveProcessing modules/ArchiveProcessing/Record modules/DataFiles modules/DataTable modules/DataTable/Filter modules/DataTable/Renderer modules/ViewDataTable plugins/Actions plugins/Provider plugins/Referers plugins/UserCountry plugins/UserSettings plugins/VisitTime plugins/VisitorInterest tests/modules/DataTable
svnmaster at piwik.org
svnmaster at piwik.org
Sat Mar 22 00:36:04 CET 2008
Author: matt
Date: 2008-03-22 00:35:59 +0100 (Sat, 22 Mar 2008)
New Revision: 395
Added:
trunk/modules/ArchiveProcessing/Record/
trunk/modules/ArchiveProcessing/Record/Blob.php
trunk/modules/ArchiveProcessing/Record/BlobArray.php
trunk/modules/ArchiveProcessing/Record/Manager.php
trunk/modules/ArchiveProcessing/Record/Numeric.php
trunk/modules/DataTable/Filter/ColumnCallbackDeleteRow.php
Removed:
trunk/modules/DataTable/Filter/ColumnCallback.php
Modified:
trunk/TODO
trunk/modules/API/APIable.php
trunk/modules/API/Proxy.php
trunk/modules/API/Request.php
trunk/modules/Archive.php
trunk/modules/Archive/Array.php
trunk/modules/Archive/Single.php
trunk/modules/ArchiveProcessing/Day.php
trunk/modules/ArchiveProcessing/Period.php
trunk/modules/ArchiveProcessing/Record.php
trunk/modules/DataFiles/Browsers.php
trunk/modules/DataFiles/Countries.php
trunk/modules/DataFiles/OS.php
trunk/modules/DataFiles/SearchEngines.php
trunk/modules/DataTable/Array.php
trunk/modules/DataTable/Filter.php
trunk/modules/DataTable/Filter/AddConstantDetail.php
trunk/modules/DataTable/Filter/AddSummaryRow.php
trunk/modules/DataTable/Filter/ColumnCallbackAddDetail.php
trunk/modules/DataTable/Filter/DetailCallbackAddDetail.php
trunk/modules/DataTable/Filter/Empty.php
trunk/modules/DataTable/Filter/ExcludeLowPopulation.php
trunk/modules/DataTable/Filter/Limit.php
trunk/modules/DataTable/Filter/Pattern.php
trunk/modules/DataTable/Filter/PatternRecursive.php
trunk/modules/DataTable/Filter/ReplaceColumnNames.php
trunk/modules/DataTable/Renderer/Xml.php
trunk/modules/ViewDataTable.php
trunk/modules/ViewDataTable/Cloud.php
trunk/modules/ViewDataTable/GenerateGraphData.php
trunk/modules/ViewDataTable/Html.php
trunk/plugins/Actions/API.php
trunk/plugins/Actions/Actions.php
trunk/plugins/Actions/Controller.php
trunk/plugins/Provider/Provider.php
trunk/plugins/Referers/Referers.php
trunk/plugins/UserCountry/UserCountry.php
trunk/plugins/UserSettings/UserSettings.php
trunk/plugins/VisitTime/API.php
trunk/plugins/VisitTime/VisitTime.php
trunk/plugins/VisitorInterest/VisitorInterest.php
trunk/tests/modules/DataTable/Renderer.test.php
Log:
- fix #146 Column nb_visits already in the array
thanks to all for your help! :)
- refs #33 working on this...
- split the Record_* classes into several files
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/TODO 2008-03-21 23:35:59 UTC (rev 395)
@@ -11,8 +11,6 @@
error RSS Feed only used on DataTable_Array http://piwik.org/demo/?module=API&method=Referers.getKeywords&idSite=1&period=week&date=yesterday&format=rss&filter_limit=30&filter_sort_column=3
NOT CLEAR MESSAGE
-label th not posiionned properly on IE6
-
documenter const VISIT_STANDARD_LENGTH = 1800; when writing plugin and need to test stats log
CHANGES DONE TO LIBRARIES
Modified: trunk/modules/API/APIable.php
===================================================================
--- trunk/modules/API/APIable.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/API/APIable.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -15,15 +15,29 @@
* This class is the parent class of all the modules that can be called using the API Proxy.
* For example a plugin "Provider" can publish its API by creating a file plugins/Provider/API.php
* that is extending this Piwik_Apiable class.
- *
* All the Piwik_Apiable classes are read and loaded by the Piwik_API_Proxy class.
+ * The public methods of this class are published in the API and are then callable using the API module.
+ * The parameters of the function are read directly from the GET request (they must have the same name).
*
+ * For example
+ * public function helloWorld($text) { return "hello " . $text; }
+ * call be called using
+ * ?module=API&method=PluginName.helloWorld&text=world!
+ *
+ * See the documentation on http://dev.piwik.org > API
+ *
* @package Piwik_API
* @see Piwik_API_Proxy
*/
abstract class Piwik_Apiable
{
+ /**
+ * This array contains the name of the methods of the class we don't want to publish in the API.
+ * By default only public methods are published. Names of public methods in this array won't be published.
+ *
+ * @var array of strings
+ */
static public $methodsNotToPublish = array();
protected function __construct()
@@ -31,10 +45,7 @@
}
/**
- * Register a public method as "not to be published in the API".
- * Sometimes methods have to be marked as public to be used by other classes but
- * we don't want these methods to be called from outside the application using the API.
- *
+ * @see self::$methodsNotToPublish
* @param string Method name not to be published
*/
protected function doNotPublishMethod( $methodName )
Modified: trunk/modules/API/Proxy.php
===================================================================
--- trunk/modules/API/Proxy.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/API/Proxy.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -24,7 +24,10 @@
class Piwik_API_Proxy
{
static $classCalled = null;
+
+ // array of already registered modules names
protected $alreadyRegistered = array();
+
private $api = array();
// when a parameter doesn't have a default value we use this constant
@@ -60,7 +63,7 @@
*
* The method will introspect the methods, their parameters, etc.
*
- * @param string ModuleName
+ * @param string ModuleName eg. "UserSettings"
*/
public function registerClass( $fileName )
{
@@ -155,7 +158,7 @@
/**
* Returns a string containing links to examples on how to call a given method on a given API
* It will export links to XML, CSV, HTML, JSON, PHP, etc.
- * It will not export links for method such as deleteSite or deleteUser
+ * It will not export links for methods such as deleteSite or deleteUser
*
* @param string the class
* @param methodName the method
@@ -283,8 +286,7 @@
}
/**
- * Returns the methods $class.$name parameters (and default value if provided)
- * as a string.
+ * Returns the methods $class.$name parameters (and default value if provided) as a string.
*
* @param string The class name
* @param string The method name
@@ -337,9 +339,8 @@
}
/**
- * Returns true if the method is found in the API
+ * Returns true if the method is found in the API of the given class name.
*
- *
* @param string The class name
* @param string The method name
* @return bool
@@ -355,7 +356,7 @@
*
* @param string The class name
* @param string The method name
- * @param array
+ * @param array
* @throws exception If less parameters than required were given
*/
private function checkNumberOfParametersMatch($className, $methodName, $parameters)
Modified: trunk/modules/API/Request.php
===================================================================
--- trunk/modules/API/Request.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/API/Request.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -1,25 +1,25 @@
-<?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$
- *
- *
- * @package Piwik_API
- */
-
+<?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$
+ *
+ *
+ * @package Piwik_API
+ */
+
/**
* An API request is the object used to make a call to the API and get the result.
* The request has the format of a normal GET request, ie. parameter_1=X¶meter_2=Y
- *
- * You can use this object from anywhere in piwik (inside plugins for example).
- * You can even call it outside of piwik using the REST API over http
- * or in a php script on the same server as piwik, by including piwik/index.php
- * (see the documentation http://dev.piwik.org/trac/wiki/API)
*
+ * You can use this object from anywhere in piwik (inside plugins for example).
+ * You can even call it outside of piwik using the REST API over http
+ * or in a php script on the same server as piwik, by including piwik/index.php
+ * (see examples in the documentation http://dev.piwik.org/trac/wiki/API)
+ *
* Example:
* $request = new Piwik_API_Request('
* method=UserSettings.getWideScreen
@@ -32,14 +32,16 @@
* ');
* $result = $request->process();
* echo $result;
- *
+ *
* @see http://dev.piwik.org/trac/wiki/API
* @package Piwik_API
*/
class Piwik_API_Request
-{
- /**
- * Constructs the request to the API, given the request url
+{
+ protected $outputFormatRequested;
+
+ /**
+ * Constructs the request to the API, given the request url
*
* @param string GET request that defines the API call (must at least contain a "method" parameter)
* Example: method=UserSettings.getWideScreen&idSite=1&date=yesterday&period=week&format=xml
@@ -60,8 +62,8 @@
// but we handle the case when an array is specified but we also want
// to look for the value in the _REQUEST
$requestArray = array_merge( $_REQUEST, $requestArray);
- }
-
+ }
+
// remove all spaces from parameters values (when calling internally the API for example)
foreach($requestArray as &$element)
{
@@ -78,7 +80,7 @@
/**
* Returns array( $class, $method) from the given string $class.$method
*
- * @return array
+ * @return array
* @throws exception if the name is invalid
*/
private function extractModuleAndMethod($parameter)
@@ -90,37 +92,36 @@
}
return $a;
}
-
- protected $outputFormatRequested;
+
/**
* Handles the request to the API.
* It first checks that the method called (parameter 'method') is available in the module (it means that the method exists and is public)
* It then reads the parameters from the request string and throws an exception if there are missing parameters.
- * It then calls the API Proxy which will call the requested method.
- *
- * @see the method handleReturnedValue() for the data post process logic
+ * It then calls the API Proxy which will call the requested method.
*
+ * @see the method handleReturnedValue() for the data post process logic
+ *
* @return mixed The data resulting from the API call
*/
public function process()
{
- try {
-
- // read the format requested for the output data
- $this->outputFormatRequested = Piwik_Common::getRequestVar('format', 'xml', 'string', $this->requestToUse);
- $this->outputFormatRequested = strtolower($this->outputFormatRequested);
+ try {
+
+ // read the format requested for the output data
+ $this->outputFormatRequested = Piwik_Common::getRequestVar('format', 'xml', 'string', $this->requestToUse);
+ $this->outputFormatRequested = strtolower($this->outputFormatRequested);
// read parameters
$moduleMethod = Piwik_Common::getRequestVar('method', null, null, $this->requestToUse);
-
+
list($module, $method) = $this->extractModuleAndMethod($moduleMethod);
if(!Piwik_PluginsManager::getInstance()->isPluginEnabled($module))
{
throw new Exception_PluginDeactivated($module);
}
- // call the method via the PublicAPI class
+ // call the method via the API_Proxy class
$api = Piwik_Api_Proxy::getInstance();
$api->registerClass($module);
@@ -129,97 +130,98 @@
// check method exists
$api->checkMethodExists($className, $method);
-
+
// get the list of parameters required by the method
$parameters = $api->getParametersList($className, $method);
-
+
// load the parameters from the request URL
$finalParameters = $this->getRequestParametersArray( $parameters );
-
+
// call the method
$returnedValue = call_user_func_array( array( $api->$module, $method), $finalParameters );
-
+
// post process the data
- $toReturn = $this->handleReturnedValue( $returnedValue );
-
-
- } catch(Exception $e ) {
-
- // if it is not a direct API call, we are requesting the original data structure
- // and we actually are handling this exception at the top level in the FrontController
- if($this->outputFormatRequested == 'original')
- {
- throw $e;
- }
- $message = $e->getMessage();
-
- $toReturn = $this->getExceptionOutput( $message, $this->outputFormatRequested);
-
- }
-
- return $toReturn;
- }
-
- /**
- * Returns the values of the current request
- *
- * @param array Parameters array of the method called. Contains name and default values of the required parameters
- * @return array Values of the given parameters
- * @throws exception If there is a missing parameter
- */
- protected function getRequestParametersArray( $parameters )
- {
- $finalParameters = array();
- foreach($parameters as $name => $defaultValue)
- {
- try{
- // there is a default value specified
- if($defaultValue !== Piwik_API_Proxy::NO_DEFAULT_VALUE)
- {
- $requestValue = Piwik_Common::getRequestVar($name, $defaultValue, null, $this->requestToUse);
- }
- else
- {
- $requestValue = Piwik_Common::getRequestVar($name, null, null, $this->requestToUse);
- }
- } catch(Exception $e) {
- throw new Exception("The required variable '$name' is not correct or has not been found in the API Request. Add the parameter '&$name=' (with a value) in the URL.");
- }
- $finalParameters[] = $requestValue;
- }
- return $finalParameters;
- }
-
- /**
- * This method post processes the data resulting from the API call.
- *
- *
- * - If the data resulted from the API call is a Piwik_DataTable then
- * - we apply the standard filters if the parameters have been found
- * in the URL. For example to offset,limit the Table you can add the following parameters to any API
- * call that returns a DataTable: filter_limit=10&filter_offset=20
- * - we apply the filters that have been previously queued on the DataTable
- * - we apply the renderer that generate the DataTable in a given format (XML, PHP, HTML, JSON, etc.)
- * the format can be changed using the 'format' parameter in the request.
- * Example: format=xml
- *
- * - If there is nothing returned (void) we display a standard success message
- *
- * - If there is a PHP array returned, we try to convert it to a dataTable
- * It is then possible to convert this datatable to any requested format (xml/etc)
- *
- * - If a bool is returned we convert to a string (true is displayed as 'true' false as 'false')
- *
- * - If an integer / float is returned, we simply return it
- *
- * @throws Exception If an object/resource is returned, if any of conversion fails, etc.
- *
- * @param mixed The initial returned value, before post process
- * @return mixed Usually a string, but can still be a PHP data structure if the format requested is 'original'
- */
- protected function handleReturnedValue( $returnedValue )
- {
+ $toReturn = $this->handleReturnedValue( $returnedValue );
+
+
+ } catch(Exception $e ) {
+
+ // if it is not a direct API call, we are requesting the original data structure
+ // and we actually are handling this exception at the top level in the FrontController
+ if($this->outputFormatRequested == 'original')
+ {
+ throw $e;
+ }
+ $message = $e->getMessage();
+
+ $toReturn = $this->getExceptionOutput( $message, $this->outputFormatRequested);
+
+ }
+
+ return $toReturn;
+ }
+
+ /**
+ * Returns the values of the current request
+ *
+ * @param array Parameters array of the method called. Contains name and default values of the required parameters
+ * @return array Values of the given parameters
+ * @throws exception If there is a missing parameter
+ */
+ protected function getRequestParametersArray( $parameters )
+ {
+ $finalParameters = array();
+ foreach($parameters as $name => $defaultValue)
+ {
+ try{
+ // there is a default value specified
+ if($defaultValue !== Piwik_API_Proxy::NO_DEFAULT_VALUE)
+ {
+ $requestValue = Piwik_Common::getRequestVar($name, $defaultValue, null, $this->requestToUse);
+ }
+ else
+ {
+ $requestValue = Piwik_Common::getRequestVar($name, null, null, $this->requestToUse);
+ }
+ } catch(Exception $e) {
+ throw new Exception("The required variable '$name' is not correct or has not been found in the API Request. Add the parameter '&$name=' (with a value) in the URL.");
+ }
+ $finalParameters[] = $requestValue;
+ }
+ return $finalParameters;
+ }
+
+ /**
+ * This method post processes the data resulting from the API call.
+ *
+ * - If the data resulted from the API call is a Piwik_DataTable then
+ * - we apply the standard filters if the parameters have been found
+ * in the URL. For example to offset,limit the Table you can add the following parameters to any API
+ * call that returns a DataTable: filter_limit=10&filter_offset=20
+ * - we apply the filters that have been previously queued on the DataTable
+ * @see Piwik_DataTable::queueFilter()
+ * - we apply the renderer that generate the DataTable in a given format (XML, PHP, HTML, JSON, etc.)
+ * the format can be changed using the 'format' parameter in the request.
+ * Example: format=xml
+ *
+ * - If there is nothing returned (void) we display a standard success message
+ *
+ * - If there is a PHP array returned, we try to convert it to a dataTable
+ * It is then possible to convert this datatable to any requested format (xml/etc)
+ *
+ * - If a bool is returned we convert to a string (true is displayed as 'true' false as 'false')
+ *
+ * - If an integer / float is returned, we simply return it
+ *
+ * @throws Exception If an object/resource is returned, if any of conversion fails, etc.
+ *
+ * @param mixed The initial returned value, before post process
+ * @return mixed Usually a string, but can still be a PHP data structure if the format requested is 'original'
+ */
+ protected function handleReturnedValue( $returnedValue )
+ {
$toReturn = $returnedValue;
+
// If the returned value is an object DataTable we
// apply the set of generic filters if asked in the URL
// and we render the DataTable according to the format specified in the URL
@@ -244,82 +246,82 @@
if(Piwik_Common::getRequestVar('disable_queued_filters', 'false', 'string', $this->requestToUse) == 'false')
{
$returnedValue->applyQueuedFilters();
- }
+ }
$toReturn = $this->getRenderedDataTable($returnedValue);
- }
-
- // Case nothing returned (really nothing was 'return'ed),
+ }
+
+ // Case nothing returned (really nothing was 'return'ed),
// => the operation was successful
elseif(!isset($toReturn))
{
$toReturn = $this->getStandardSuccessOutput($this->outputFormatRequested);
- }
-
- // Case an array is returned from the API call, we convert it to the requested format
- // - if calling from inside the application (format = original)
- // => the data stays unchanged (ie. a standard php array or whatever data structure)
- // - if any other format is requested, we have to convert this data structure (which we assume
- // to be an array) to a DataTable in order to apply the requested DataTable_Renderer (for example XML)
- elseif(is_array($toReturn))
- {
- if($this->outputFormatRequested == 'original')
- {
- // we handle the serialization. Because some php array have a very special structure that
- // couldn't be converted with the automatic DataTable->loadFromSimpleArray
- // the user may want to request the original PHP data structure serialized by the API
- // in case he has to setup serialize=1 in the URL
- if($this->caseRendererPHPSerialize( $defaultSerialize = 0))
- {
- $toReturn = serialize($toReturn);
- }
- }
- else
- {
- $dataTable = new Piwik_DataTable();
- $dataTable->loadFromSimpleArray($toReturn);
- $toReturn = $this->getRenderedDataTable($dataTable);
- }
- }
- // bool // integer // float // object is serialized
- // NB: null value is already handled by the isset() test above
- else
- {
- // original data structure requested, we return without process
- if( $this->outputFormatRequested == 'original' )
- {
- return $toReturn;
- }
-
- if( $toReturn === true )
- {
- $toReturn = 'true';
- }
- elseif( $toReturn === false )
- {
- $toReturn = 'false';
- }
- elseif( is_object($toReturn)
- || is_resource($toReturn)
- )
- {
- return $this->getExceptionOutput( ' The API cannot handle this data structure. You can get the data internally by directly using the class.', $this->outputFormatRequested);
+ }
+
+ // Case an array is returned from the API call, we convert it to the requested format
+ // - if calling from inside the application (format = original)
+ // => the data stays unchanged (ie. a standard php array or whatever data structure)
+ // - if any other format is requested, we have to convert this data structure (which we assume
+ // to be an array) to a DataTable in order to apply the requested DataTable_Renderer (for example XML)
+ elseif(is_array($toReturn))
+ {
+ if($this->outputFormatRequested == 'original')
+ {
+ // we handle the serialization. Because some php array have a very special structure that
+ // couldn't be converted with the automatic DataTable->loadFromSimpleArray
+ // the user may want to request the original PHP data structure serialized by the API
+ // in case he has to setup serialize=1 in the URL
+ if($this->caseRendererPHPSerialize( $defaultSerialize = 0))
+ {
+ $toReturn = serialize($toReturn);
+ }
}
+ else
+ {
+ $dataTable = new Piwik_DataTable();
+ $dataTable->loadFromSimpleArray($toReturn);
+ $toReturn = $this->getRenderedDataTable($dataTable);
+ }
+ }
+ // bool // integer // float // object is serialized
+ // NB: null value is already handled by the isset() test above
+ else
+ {
+ // original data structure requested, we return without process
+ if( $this->outputFormatRequested == 'original' )
+ {
+ return $toReturn;
+ }
+ if( $toReturn === true )
+ {
+ $toReturn = 'true';
+ }
+ elseif( $toReturn === false )
+ {
+ $toReturn = 'false';
+ }
+ elseif( is_object($toReturn)
+ || is_resource($toReturn)
+ )
+ {
+ return $this->getExceptionOutput( ' The API cannot handle this data structure. You can get the data internally by directly using the class.', $this->outputFormatRequested);
+ }
+
require_once "DataTable/Simple.php";
$dataTable = new Piwik_DataTable_Simple();
$dataTable->loadFromArray( array($toReturn) );
- $toReturn = $this->getRenderedDataTable($dataTable);
- }
+ $toReturn = $this->getRenderedDataTable($dataTable);
+ }
return $toReturn;
}
- /**
- * Returns a success $message in the requested $format
- *
- * @param string $format xml/json/php/csv
- * @param string $message
- * @return string
+ /**
+ * Returns a success $message in the requested $format
+ *
+ * @param string $format xml/json/php/csv
+ * @param string $message
+ * @return string
*/
protected function getStandardSuccessOutput($format, $message = 'ok')
{
@@ -343,28 +345,28 @@
{
$return = serialize($return);
}
- break;
-
- case 'csv':
- header("Content-type: application/vnd.ms-excel");
- header("Content-Disposition: attachment; filename=piwik-report-export.csv");
- $return = "message\n".$message;
- break;
+ break;
+ case 'csv':
+ header("Content-type: application/vnd.ms-excel");
+ header("Content-Disposition: attachment; filename=piwik-report-export.csv");
+ $return = "message\n".$message;
+ break;
+
default:
$return = 'Success:'.$message;
break;
}
return $return;
- }
-
- /**
- * Returns an error $message in the requested $format
- *
- * @param string $format xml/json/php/csv
- * @param string $message
- * @return string
+ }
+
+ /**
+ * Returns an error $message in the requested $format
+ *
+ * @param string $format xml/json/php/csv
+ * @param string $message
+ * @return string
*/
function getExceptionOutput($message, $format)
{
@@ -400,8 +402,8 @@
}
/**
- * Apply the specified renderer to the DataTable
- *
+ * Apply the specified renderer to the DataTable
+ *
* @param Piwik_DataTable
* @return string
*/
@@ -409,7 +411,7 @@
{
// Renderer
$format = Piwik_Common::getRequestVar('format', 'php', 'string', $this->requestToUse);
- $format = strtolower($format);
+ $format = strtolower($format);
// if asked for original dataStructure
if($format == 'original')
@@ -419,15 +421,15 @@
&& $dataTable->getRowsCount() == 1)
{
return $dataTable->getRowFromId(0)->getColumn('value');
- }
-
- // the original data structure can be asked as serialized.
- // but by default it's not serialized
- if($this->caseRendererPHPSerialize( $defaultSerialize = 0))
- {
-// var_export($dataTable);exit;
- $dataTable = serialize($dataTable);
}
+
+ // the original data structure can be asked as serialized.
+ // but by default it's not serialized
+ if($this->caseRendererPHPSerialize( $defaultSerialize = 0))
+ {
+// var_export($dataTable);exit;
+ $dataTable = serialize($dataTable);
+ }
return $dataTable;
}
@@ -442,12 +444,12 @@
$toReturn = $renderer->render();
return $toReturn;
}
-
- /**
- * Returns true if the user requested to serialize the output data (&serialize=1 in the request)
- *
- * @param $defaultSerializeValue Default value in case the user hasn't specified a value
- * @return bool
+
+ /**
+ * Returns true if the user requested to serialize the output data (&serialize=1 in the request)
+ *
+ * @param $defaultSerializeValue Default value in case the user hasn't specified a value
+ * @return bool
*/
protected function caseRendererPHPSerialize($defaultSerializeValue = 1)
{
@@ -461,12 +463,12 @@
return false;
}
}
-
- /**
- * Returns an array containing the information of the generic Piwik_DataTable_Filter
- * to be applied automatically to the data resulting from the API calls.
- *
- * @return array See the code for spec
+
+ /**
+ * Returns an array containing the information of the generic Piwik_DataTable_Filter
+ * to be applied automatically to the data resulting from the API calls.
+ *
+ * @return array See the code for spec
*/
public static function getGenericFiltersInformation()
{
@@ -499,9 +501,9 @@
/**
- * Apply generic filters to the DataTable object resulting from the API Call.
- * Disable this feature by setting the parameter disable_generic_filters to 1 in the API call request.
- *
+ * Apply generic filters to the DataTable object resulting from the API Call.
+ * Disable this feature by setting the parameter disable_generic_filters to 1 in the API call request.
+ *
* @param Piwik_DataTable
* @return void
*/
@@ -516,13 +518,13 @@
* 3 - Filter that keep only a subset of the results
*/
$genericFilters = Piwik_API_Request::getGenericFiltersInformation();
-
- // if the flag disable_generic_filters is defined we skip the generic filters
- if(Piwik_Common::getRequestVar('disable_generic_filters', 'false', 'string', $this->requestToUse) != 'false')
- {
- return;
- }
+ // if the flag disable_generic_filters is defined we skip the generic filters
+ if(Piwik_Common::getRequestVar('disable_generic_filters', 'false', 'string', $this->requestToUse) != 'false')
+ {
+ return;
+ }
+
foreach($genericFilters as $filterName => $parameters)
{
$filterParameters = array();
Modified: trunk/modules/Archive/Array.php
===================================================================
--- trunk/modules/Archive/Array.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/Archive/Array.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -1,18 +1,44 @@
<?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: Request.php 380 2008-03-17 14:59:24Z matt $
+ *
+ *
+ * @package Piwik_Archive
+ */
-require_once "DataTable/Array.php";
+require_once "DataTable/Simple.php";
+/**
+ * This class is used to store multiple archives, when the user requests a period's archive.
+ *
+ */
class Piwik_Archive_Array extends Piwik_Archive
{
+ // this array contains one Piwik_Archive per entry in the period
protected $archives = array();
+
+ // stores the timestamp of each archive, used to sort the archives by date
protected $idArchiveToTimestamp = array();
+
+ // array containing the id of the archives stored in this object
protected $idArchives = array();
-
+ /**
+ * Builds an array of Piwik_Archive of a given date range
+ *
+ * @param Piwik_Site $oSite
+ * @param string $strPeriod eg. 'day' 'week' etc.
+ * @param string $strDate A date range, eg. 'last10', 'previous5' or 'YYYY-MM-DD,YYYY-MM-DD'
+ */
function __construct(Piwik_Site $oSite, $strPeriod, $strDate)
{
$rangePeriod = new Piwik_Period_Range($strPeriod, $strDate);
+ // TODO fix this when aggregating data from multiple websites
// CAREFUL this class wouldnt work as is if handling archives from multiple websites
// works only when managing archives from multiples dates/periods
foreach($rangePeriod->getSubperiods() as $subPeriod)
@@ -26,12 +52,12 @@
ksort( $this->archives );
}
-
- protected function sortArchiveByTimestamp($a, $b)
- {
- return $this->idArchiveToTimestamp[$a] > $this->idArchiveToTimestamp[$b];
- }
-
+ /**
+ * Returns a newly created Piwik_DataTable_Array.
+ * The future elements of this array should be indexed by their dates (we set the index name to 'date').
+ *
+ * @return Piwik_DataTable_Array
+ */
protected function getNewDataTableArray()
{
$table = new Piwik_DataTable_Array;
@@ -39,7 +65,14 @@
return $table;
}
- protected function loadMetaData($table, $archive)
+ /**
+ * Adds metaData information to the Piwik_DataTable_Array
+ * using the information given by the Archive
+ *
+ * @param Piwik_DataTable_Array $table
+ * @param unknown_type $archive
+ */
+ protected function loadMetaData(Piwik_DataTable_Array $table, $archive)
{
$table->metaData[$archive->getPrettyDate()] = array(
'timestamp' => $archive->getTimestampStartDate(),
@@ -48,15 +81,15 @@
}
/**
- * 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
+ * Returns a DataTable_Array containing numeric values
+ * of the element $name from the archives in this Archive_Array.
*
- * @param string $name For example Referers_distinctKeywords
- * @return float|int|false False if no value with the given name
+ * @param string $name Name of the mysql table field to load eg. Referers_distinctKeywords
+ *
+ * @return Piwik_DataTable_Array containing the requested numeric value for each Archive
*/
public function getNumeric( $name )
{
- require_once "DataTable/Simple.php";
$table = $this->getNewDataTableArray();
foreach($this->archives as $archive)
@@ -73,18 +106,18 @@
}
/**
- * Returns the value of the element $name from the current archive
- *
- * The value to be returned is a blob value and is stored in the archive_numeric_* tables
- *
+ * Returns a DataTable_Array containing values
+ * of the element $name from the archives in this Archive_Array.
+ *
+ * The value to be returned are blob values (stored in the archive_numeric_* tables in the DB). *
* It can return anything from strings, to serialized PHP arrays or PHP objects, etc.
*
- * @param string $name For example Referers_distinctKeywords
- * @return mixed False if no value with the given name
+ * @param string $name Name of the mysql table field to load eg. Referers_keywordBySearchEngine
+ *
+ * @return Piwik_DataTable_Array containing the requested blob values for each Archive
*/
public function getBlob( $name )
{
- require_once "DataTable/Simple.php";
$table = $this->getNewDataTableArray();
foreach($this->archives as $archive)
@@ -103,22 +136,22 @@
* 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, ...)
+ * @param array|string $fields array( fieldName1, fieldName2, ...) Names of the mysql table fields to load
* @return Piwik_DataTable_Array
*/
public function getDataTableFromNumeric( $fields )
{
- // Simple algorithm not efficient
-// $table = new Piwik_DataTable_Array;
-// foreach($this->archives as $archive)
-// {
-// $subTable = $archive->getDataTableFromNumeric( $fields ) ;
-// $table->addTable($subTable, $archive->getPrettyDate());
-// }
-// return $table;
+ // Simple algorithm not efficient that does the same as the following code
+ /*
+ $table = new Piwik_DataTable_Array;
+ foreach($this->archives as $archive)
+ {
+ $subTable = $archive->getDataTableFromNumeric( $fields ) ;
+ $table->addTable($subTable, $archive->getPrettyDate());
+ }
+ return $table;
+ */
-// $fields = $fields[1];
- require_once "DataTable/Simple.php";
if(!is_array($fields))
{
$fields = array($fields);
@@ -200,9 +233,9 @@
* 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
*
- * @param string $name
- * @param int $idSubTable
- * @return Piwik_DataTable
+ * @param string $name Name of the mysql table field to load
+ * @param int $idSubTable optional idSubDataTable
+ * @return Piwik_DataTable_Array
* @throws exception If the value cannot be found
*/
public function getDataTable( $name, $idSubTable = null )
@@ -222,11 +255,11 @@
/**
* Same as getDataTable() except that it will also load in memory
* all the subtables for the DataTable $name.
- * You can then access the subtables by using the Piwik_DataTable_Manager getTable()
+ * You can then access the subtables by using the Piwik_DataTable_Manager::getInstance()->getTable($idSubTable);
*
- * @param string $name
- * @param int $idSubTable
- * @return Piwik_DataTable
+ * @param string $name Name of the mysql table field to load
+ * @param int $idSubTable optional idSubDataTable
+ * @return Piwik_DataTable_Array
*/
public function getDataTableExpanded($name, $idSubTable = null)
{
Modified: trunk/modules/Archive/Single.php
===================================================================
--- trunk/modules/Archive/Single.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/Archive/Single.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -1,21 +1,85 @@
<?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: Request.php 380 2008-03-17 14:59:24Z matt $
+ *
+ *
+ * @package Piwik_Archive
+ */
+
+/**
+ * This class is used to store the data of a given archive.
+ *
+ */
class Piwik_Archive_Single extends Piwik_Archive
{
+ /**
+ * The Piwik_ArchiveProcessing object used to check that the archive is available
+ * and launch the processing if the archive was not yet processed
+ *
+ * @var Piwik_ArchiveProcessing
+ */
public $archiveProcessing = null;
+
+ /**
+ * @var bool Set to true if the archive has at least 1 visit
+ */
public $isThereSomeVisits = false;
+ /**
+ * Period of this Archive
+ *
+ * @var Piwik_Period
+ */
protected $period = null;
- protected $blobCached = array();
+ /**
+ * Set to true will activate numeric value caching for this archive.
+ *
+ * @var bool
+ */
protected $cacheEnabledForNumeric = true;
+
+ /**
+ * Array of cached numeric values, used to make requests faster
+ * when requesting the same value again and again
+ *
+ * @var array of numeric
+ */
protected $numericCached = array();
+
+/**
+ * Array of cached blob, used to make requests faster when requesting the same blob again and again
+ *
+ * @var array of mixed
+ */
+ protected $blobCached = array();
+
+ /**
+ * idarchive of this Archive in the database
+ *
+ * @var int
+ */
protected $idArchive = null;
+ /**
+ * Returns the pretty date of this Archive, eg. 'Thursday 20th March 2008'
+ *
+ * @return string
+ */
public function getPrettyDate()
{
return $this->period->getPrettyString();
}
+ /**
+ * Returns the idarchive of this Archive used to index this archive in the DB
+ *
+ * @return int
+ */
public function getIdArchive()
{
return $this->idArchive;
@@ -31,6 +95,12 @@
$this->period = $period;
}
+ /**
+ * Returns the timestamp of the first date in the period for this Archive.
+ * This is used to sort archives by date when working on a Archive_Array
+ *
+ * @return int Unix timestamp
+ */
public function getTimestampStartDate()
{
if(!is_null($this->archiveProcessing))
@@ -208,7 +278,7 @@
// we edit the subtable ID so that it matches the newly table created in memory
// NB:
// we dont do that in the case we are displaying the table expanded.
- // in this case we wan't the user to see the REAL dataId in the database
+ // in this case we want the user to see the REAL dataId in the database
if($addDetailSubtableId)
{
$row->addDetail('databaseSubtableId', $row->getIdSubDataTable());
@@ -265,18 +335,38 @@
}
}
-
+ /**
+ * Returns a numeric value from this Archive, with the name '$name'
+ *
+ * @param string $name
+ * @return int|float
+ */
public function getNumeric( $name )
{
// we cast the result as float because returns false when no visitors
return (float)$this->get($name, 'numeric');
}
+
+ /**
+ * Returns a blob value from this Archive, with the name '$name'
+ * Blob values are all values except int and float.
+ *
+ * @param string $name
+ * @return mixed
+ */
public function getBlob( $name )
{
return $this->get($name, 'blob');
}
+ /**
+ * Returns a DataTable_Simple with one row per field from $fields array names.
+ *
+ * @param string|array $fields Name or array of names of Archive fields
+ *
+ * @return Piwik_DataTable_Simple
+ */
public function getDataTableFromNumeric( $fields )
{
require_once "DataTable/Simple.php";
@@ -296,6 +386,14 @@
return $table;
}
+ /**
+ * Returns a DataTable that has the name '$name' from the current Archive.
+ * If $idSubTable is specified, returns the subDataTable called '$name_$idSubTable'
+ *
+ * @param string $name
+ * @param int $idSubTable optional id SubDataTable
+ * @return Piwik_DataTable
+ */
public function getDataTable( $name, $idSubTable = null )
{
if(!is_null($idSubTable))
@@ -321,6 +419,22 @@
return $table;
}
+ /**
+ * Returns a DataTable that has the name '$name' from the current Archive.
+ * Also loads in memory all subDataTable for this DataTable.
+ *
+ * For example, if $name = 'Referers_keywordBySearchEngine' it will load all DataTable
+ * named 'Referers_keywordBySearchEngine_*' and they will be set as subDataTable to the
+ * rows. You can then go through the rows
+ * $rows = DataTable->getRows();
+ * and for each row request the subDataTable (in this case the DataTable of the keywords for each search engines)
+ * $idSubTable = $row->getIdSubDataTable();
+ * $subTable = Piwik_DataTable_Manager::getInstance()->getTable($idSubTable);
+ *
+ * @param string $name
+ * @param int $idSubTable Optional subDataTable to load instead of loading the parent DataTable
+ * @return Piwik_DataTable
+ */
public function getDataTableExpanded($name, $idSubTable = null)
{
$this->preFetchBlob($name);
Modified: trunk/modules/Archive.php
===================================================================
--- trunk/modules/Archive.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/Archive.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -131,7 +131,7 @@
* 'bounce_count',
* );
*
- * @param array $fields array( fieldName1, fieldName2, ...)
+ * @param array|string $fields array( fieldName1, fieldName2, ...)
* @return Piwik_DataTable_Simple
*/
abstract public function getDataTableFromNumeric( $fields );
Modified: trunk/modules/ArchiveProcessing/Day.php
===================================================================
--- trunk/modules/ArchiveProcessing/Day.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/ArchiveProcessing/Day.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -21,7 +21,13 @@
*/
class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing
{
+ /**
+ * If the archive has at least 1 visit, this is set to true.
+ *
+ * @var bool
+ */
public $isThereSomeVisits = false;
+
/**
* Constructor
*/
@@ -33,8 +39,8 @@
/**
* Main method to process logs for a day. The only logic done here is computing the number of visits, actions, etc.
- * All the otherreports are computed inside plugins listening to the event 'ArchiveProcessing_Day.compute'.
- * See some of the plugins for an example.
+ * All the other reports are computed inside plugins listening to the event 'ArchiveProcessing_Day.compute'.
+ * See some of the plugins for an example eg. 'Provider'
*
* @return void
*/
@@ -70,8 +76,10 @@
}
/**
- * Called at the end of the archiving process
- *
+ * Called at the end of the archiving process.
+ * Does some cleaning job in the database.
+ *
+ * @return void
*/
protected function postCompute()
{
@@ -142,7 +150,7 @@
* The returned DataTable will have a row per distinct operating systems,
* and a column per stat (nb of visits, max actions, etc)
*
- * label nb_unique_visitors nb_visits nb_actions max_actions sum_visit_length bounce_count
+ * label nb_uniq_visitors nb_visits nb_actions max_actions sum_visit_length bounce_count
* Linux 27 66 66 1 660 66
* Windows XP 12 39 39 1 390 39
* Mac OS 15 36 36 1 360 36
Modified: trunk/modules/ArchiveProcessing/Period.php
===================================================================
--- trunk/modules/ArchiveProcessing/Period.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/ArchiveProcessing/Period.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -120,11 +120,11 @@
/**
* This powerful method will compute the sum of DataTables over the period for the given fields $aRecordName.
+ * The resulting DataTable will be then added to queue of data to be recorded in the database.
* It will usually be called in a plugin that listens to the hook 'ArchiveProcessing_Period.compute'
*
- *
* For example if $aRecordName = 'UserCountry_country' the method will select all UserCountry_country DataTable for the period
- * (eg. the 31 dataTable of the last month), sum them, and create the Piwik_ArchiveProcessing_Record_Blob_Array so that
+ * (eg. the 31 dataTable of the last month), sum them, and create the Piwik_ArchiveProcessing_Record_BlobArray so that
* the resulting dataTable is AUTOMATICALLY recorded in the database.
*
*
@@ -155,7 +155,7 @@
$nameToCount[$recordName]['level0'] = $table->getRowsCount();
$nameToCount[$recordName]['recursive'] = $table->getRowsCountRecursive();
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $table->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $table->getSerialized());
}
return $nameToCount;
}
@@ -220,8 +220,10 @@
}
/**
- * Called at the end of the archiving process
- *
+ * Called at the end of the archiving process.
+ * Does some cleaning job in the database.
+ *
+ * @return void
*/
protected function postCompute()
{
Added: trunk/modules/ArchiveProcessing/Record/Blob.php
===================================================================
--- trunk/modules/ArchiveProcessing/Record/Blob.php (rev 0)
+++ trunk/modules/ArchiveProcessing/Record/Blob.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -0,0 +1,33 @@
+<?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: Record.php 180 2008-01-17 16:32:37Z matt $
+ *
+ * @package Piwik_ArchiveProcessing
+ */
+
+/**
+ * Blob record.
+ * Example: $record = new Piwik_ArchiveProcessing_Record_Blob('visitor_names', serialize(array('piwik-fan', 'php', 'stevie-vibes')));
+ * The value will be compressed before being saved in the DB.
+ *
+ * @package Piwik_ArchiveProcessing
+ * @subpackage Piwik_ArchiveProcessing_Record
+ */
+class Piwik_ArchiveProcessing_Record_Blob extends Piwik_ArchiveProcessing_Record
+{
+ public $name;
+ public $value;
+ function __construct( $name, $value)
+ {
+ $value = gzcompress($value);
+ parent::__construct( $name, $value );
+ }
+ public function __toString()
+ {
+ return $this->name ." = BLOB";//". gzuncompress($this->value);
+ }
+}
Added: trunk/modules/ArchiveProcessing/Record/BlobArray.php
===================================================================
--- trunk/modules/ArchiveProcessing/Record/BlobArray.php (rev 0)
+++ trunk/modules/ArchiveProcessing/Record/BlobArray.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -0,0 +1,63 @@
+<?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: Record.php 180 2008-01-17 16:32:37Z matt $
+ *
+ * @package Piwik_ArchiveProcessing
+ */
+
+/**
+ * Array of blob records.
+ * Useful for easily saving splited data in the DB.
+ *
+ * Example: $record = new Piwik_ArchiveProcessing_Record_BlobArray(
+ * 'veryLongBook',
+ * 0 => serialize( array( '1st chapter very long, 6MB of data we dont want to save' )),
+ * 1 => serialize( array( '2nd chapter very long, 8MB of data we dont want to save' )),
+ * 2 => serialize( array( '3rd chapter very long, 7MB of data we dont want to save' )),
+ * 3 => serialize( array( '4th chapter very long, 10MB of data we dont want to save' )),
+ * );
+ *
+ * Will be saved in the DB as
+ * veryLongBook => X
+ * veryLongBook_1 => Y
+ * veryLongBook_2 => Z
+ * veryLongBook_3 => M
+ *
+ * @package Piwik_ArchiveProcessing
+ * @subpackage Piwik_ArchiveProcessing_Record
+ */
+class Piwik_ArchiveProcessing_Record_BlobArray extends Piwik_ArchiveProcessing_Record
+{
+
+ function __construct( $name, $aValue)
+ {
+ foreach($aValue as $id => $value)
+ {
+ // for the parent Table we keep the name
+ // for example for the Table of searchEngines we keep the name 'referer_search_engine'
+ // but for the child table of 'Google' which has the ID = 9 the name would be 'referer_search_engine_9'
+ if($id == 0)
+ {
+ $newName = $name;
+ }
+ else
+ {
+ $newName = $name . '_' . $id;
+ }
+ $record = new Piwik_ArchiveProcessing_Record_Blob( $newName, $value );
+
+ }
+ }
+ public function __toString()
+ {
+ throw new Exception( 'Not valid' );
+ }
+ public function delete()
+ {
+ throw new Exception( 'Not valid' );
+ }
+}
Added: trunk/modules/ArchiveProcessing/Record/Manager.php
===================================================================
--- trunk/modules/ArchiveProcessing/Record/Manager.php (rev 0)
+++ trunk/modules/ArchiveProcessing/Record/Manager.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -0,0 +1,109 @@
+<?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: Record.php 180 2008-01-17 16:32:37Z matt $
+ *
+ * @package Piwik_ArchiveProcessing
+ */
+
+/**
+ * Every new Piwik_ArchiveProcessing_Record will be recorded to this manager when created.
+ * At the end of the archiving process, the ArchiveProcessing will getRecords() to save them in the db.
+ * This class is singleton.
+ *
+ * @package Piwik_ArchiveProcessing
+ * @subpackage Piwik_ArchiveProcessing_Record
+ */
+class Piwik_ArchiveProcessing_Record_Manager
+{
+ // array of Piwik_ArchiveProcessing_Record to be recorded in the DB
+ protected $records = array();
+
+ static private $instance = null;
+ protected function __construct()
+ {}
+
+ /**
+ * Singleton, returns instance
+ *
+ * @return Piwik_ArchiveProcessing_Record_Manager
+ */
+ static public function getInstance()
+ {
+ if (self::$instance == null)
+ {
+ $c = __CLASS__;
+ self::$instance = new $c();
+ }
+ return self::$instance;
+ }
+
+ /**
+ * Method called by Record objects to register themselves.
+ * All records registered here will be saved in the DB at the end of the archiving process.
+ * @return void
+ */
+ public function registerRecord( $record )
+ {
+ $this->records[$record->name] = $record;
+ }
+
+ /**
+ * Removes a record from the Record Manager.
+ *
+ * @return void
+ */
+ public function unregister( $deleteRecord )
+ {
+ unset($this->records[$deleteRecord->name]);
+ }
+
+ /**
+ * Returns a string containing the "name : value" of the record
+ * @return string
+ */
+ public function toString()
+ {
+ $str = '';
+ foreach($this->records as $record)
+ {
+ $str .= $record . "<br>\n";
+ }
+ return $str;
+ }
+
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->toString();
+ }
+
+ /**
+ * Returns the list of all the records that have to created in the database.
+ *
+ * @return array of Records
+ */
+ public function getRecords()
+ {
+ return $this->records;
+ }
+
+ /**
+ * Delete all records saved in the Manager.
+ * @return void
+ */
+ public function deleteAll()
+ {
+ foreach($this->records as $key => $record)
+ {
+ unset($this->records[$key]);
+ }
+ $this->records = array();
+ }
+}
+
Added: trunk/modules/ArchiveProcessing/Record/Numeric.php
===================================================================
--- trunk/modules/ArchiveProcessing/Record/Numeric.php (rev 0)
+++ trunk/modules/ArchiveProcessing/Record/Numeric.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -0,0 +1,30 @@
+<?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: Record.php 180 2008-01-17 16:32:37Z matt $
+ *
+ * @package Piwik_ArchiveProcessing
+ */
+
+/**
+ * Numeric record.
+ * Example: $record = new Piwik_ArchiveProcessing_Record_Numeric('nb_visitors_live', 15);
+ *
+ * @package Piwik_ArchiveProcessing
+ * @subpackage Piwik_ArchiveProcessing_Record
+ */
+class Piwik_ArchiveProcessing_Record_Numeric extends Piwik_ArchiveProcessing_Record
+{
+ function __construct( $name, $value)
+ {
+ parent::__construct( $name, $value );
+ }
+
+ public function __toString()
+ {
+ return $this->name ." = ". $this->value;
+ }
+}
Modified: trunk/modules/ArchiveProcessing/Record.php
===================================================================
--- trunk/modules/ArchiveProcessing/Record.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/ArchiveProcessing/Record.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -8,6 +8,12 @@
*
* @package Piwik_ArchiveProcessing
*/
+
+require_once "ArchiveProcessing/Record/Blob.php";
+require_once "ArchiveProcessing/Record/BlobArray.php";
+require_once "ArchiveProcessing/Record/Numeric.php";
+require_once "ArchiveProcessing/Record/Manager.php";
+
/**
* A Record is a tuple (name, value) to be saved in the database.
@@ -23,7 +29,6 @@
* @package Piwik_ArchiveProcessing
* @subpackage Piwik_ArchiveProcessing_Record
*/
-
abstract class Piwik_ArchiveProcessing_Record
{
public $name;
@@ -40,193 +45,11 @@
{
Piwik_ArchiveProcessing_Record_Manager::getInstance()->unregister($this);
}
+
public function __destruct()
{
}
}
-/**
- *
- * @package Piwik_ArchiveProcessing
- * @subpackage Piwik_ArchiveProcessing_Record
- */
-class Piwik_ArchiveProcessing_Record_Manager
-{
- protected $records = array();
- static private $instance = null;
- protected function __construct()
- {}
-
- static public function getInstance()
- {
- if (self::$instance == null)
- {
- $c = __CLASS__;
- self::$instance = new $c();
- }
- return self::$instance;
- }
- /**
- * Method called by Record objects to register themselves.
- * All records registered here will be saved in the DB at the end of the archiving process.
- * @return void
- */
- public function registerRecord( $record )
- {
- $this->records[$record->name] = $record;
- }
-
- /**
- * Removes a record from the Record Manager.
- *
- * @return void
- */
- public function unregister( $deleteRecord )
- {
- unset($this->records[$deleteRecord->name]);
- }
-
- /**
- * Returns a string containing the "name : value" of the record
- * @return string
- */
- public function toString()
- {
- $str = '';
- foreach($this->records as $record)
- {
- $str .= $record . "<br>\n";
- }
- return $str;
- }
-
- /**
- * @return string
- */
- public function __toString()
- {
- return $this->toString();
- }
-
- /**
- * @return array of Records
- */
- public function getRecords()
- {
- return $this->records;
- }
-
- /**
- * Delete all records saved in the Manager.
- * @return void
- */
- public function deleteAll()
- {
- foreach($this->records as $key => $record)
- {
- unset($this->records[$key]);
- }
- $this->records = array();
- }
-}
-
-/**
- * Numeric record.
- * Example: $record = new Piwik_ArchiveProcessing_Record_Numeric('nb_visitors_live', 15);
- *
- * @package Piwik_ArchiveProcessing
- * @subpackage Piwik_ArchiveProcessing_Record
- */
-class Piwik_ArchiveProcessing_Record_Numeric extends Piwik_ArchiveProcessing_Record
-{
- function __construct( $name, $value)
- {
- parent::__construct( $name, $value );
- }
-
- public function __toString()
- {
- return $this->name ." = ". $this->value;
- }
-}
-/**
- * Blob record.
- * Example: $record = new Piwik_ArchiveProcessing_Record_Blob('visitor_names', serialize(array('piwik-fan', 'php', 'stevie-vibes')));
- * The value will be compressed before being saved in the DB.
- *
- * @package Piwik_ArchiveProcessing
- * @subpackage Piwik_ArchiveProcessing_Record
- */
-class Piwik_ArchiveProcessing_Record_Blob extends Piwik_ArchiveProcessing_Record
-{
- public $name;
- public $value;
- function __construct( $name, $value)
- {
- $value = gzcompress($value);
- parent::__construct( $name, $value );
- }
- public function __toString()
- {
- return $this->name ." = BLOB";//". gzuncompress($this->value);
- }
-}
-
-
-/**
- * Array of blob records.
- * Useful for easily saving splited data in the DB.
- *
- * Example: $record = new Piwik_ArchiveProcessing_Record_Blob_Array(
- * 'veryLongBook',
- * 0 => serialize( array( '1st chapter very long, 6MB of data we dont want to save' )),
- * 1 => serialize( array( '2nd chapter very long, 8MB of data we dont want to save' )),
- * 2 => serialize( array( '3rd chapter very long, 7MB of data we dont want to save' )),
- * 3 => serialize( array( '4th chapter very long, 10MB of data we dont want to save' )),
- * );
- *
- * Will be saved in the DB as
- * veryLongBook => X
- * veryLongBook_1 => Y
- * veryLongBook_2 => Z
- * veryLongBook_3 => M
- *
- * @package Piwik_ArchiveProcessing
- * @subpackage Piwik_ArchiveProcessing_Record
- */
-class Piwik_ArchiveProcessing_Record_Blob_Array extends Piwik_ArchiveProcessing_Record
-{
-
- function __construct( $name, $aValue)
- {
- foreach($aValue as $id => $value)
- {
- // for the parent Table we keep the name
- // for example for the Table of searchEngines we keep the name 'referer_search_engine'
- // but for the child table of 'Google' which has the ID = 9 the name would be 'referer_search_engine_9'
- if($id == 0)
- {
- $newName = $name;
- }
- else
- {
- $newName = $name . '_' . $id;
- }
- $record = new Piwik_ArchiveProcessing_Record_Blob( $newName, $value );
-
- }
- }
- public function __toString()
- {
- throw new Exception( 'Not valid' );
- }
- public function delete()
- {
- throw new Exception( 'Not valid' );
- }
-}
-
-
-
Modified: trunk/modules/DataFiles/Browsers.php
===================================================================
--- trunk/modules/DataFiles/Browsers.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataFiles/Browsers.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -10,7 +10,8 @@
*/
/**
- * Browser list
+ * Browser list.
+ * If you want to add a new entry, please email us at hello at piwik.org
*
*/
if(!isset($GLOBALS['Piwik_BrowserList'] ))
Modified: trunk/modules/DataFiles/Countries.php
===================================================================
--- trunk/modules/DataFiles/Countries.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataFiles/Countries.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -10,7 +10,8 @@
*/
/**
- * Country code and continent database
+ * Country code and continent database.
+ * If you want to add a new entry, please email us at hello at piwik.org
*
*/
if(!isset($GLOBALS['Piwik_CountryList']))
Modified: trunk/modules/DataFiles/OS.php
===================================================================
--- trunk/modules/DataFiles/OS.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataFiles/OS.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -10,7 +10,8 @@
*/
/**
- * Operating systems database
+ * Operating systems database.
+ * If you want to add a new entry, please email us at hello at piwik.org
*
*/
if(!isset($GLOBALS['Piwik_Oslist']))
Modified: trunk/modules/DataFiles/SearchEngines.php
===================================================================
--- trunk/modules/DataFiles/SearchEngines.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataFiles/SearchEngines.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -8,10 +8,14 @@
*
* @package Piwik_Referers
*/
-
/**
* Search Engine database
*
+ * ======================================
+ * HOW TO ADD A SEARCH ENGINE TO THE LIST
+ * ======================================
+ * If you want to add a new entry, please email us the information + icon at hello at piwik.org
+ *
* Detail of a line:
* Url => array( SearchEngineName, VariableKeyword, [charset used by the search engine])
*
@@ -21,7 +25,6 @@
* in the plugins/Referers/images/SearchEngines directory
* using the format "mainSearchEngineUrl.png". Example: www.google.com.png
*
- * Post your new search engines by email at hello at piwik.org ; thanks!
*
*/
if(!isset($GLOBALS['Piwik_SearchEngines'] ))
Modified: trunk/modules/DataTable/Array.php
===================================================================
--- trunk/modules/DataTable/Array.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Array.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -16,31 +16,72 @@
*/
class Piwik_DataTable_Array
{
+ /**
+ * Used to store additional information about the DataTable Array.
+ * For example if the Array is used to store multiple DataTable of UserCountry,
+ * we can add the metadata of the 'idSite' they refer to, so we can access it later if necessary.
+ *
+ * @var array of mixed
+ */
+ public $metaData = array();
+
+ /**
+ * Array containing the DataTable withing this Piwik_DataTable_Array
+ *
+ * @var array of Piwik_DataTable
+ */
protected $array = array();
+
+ /**
+ * This is the label used to index the tables.
+ * For example if the tables are indexed using the timestamp of each period
+ * eg. $this->array[1045886960] = new Piwik_DataTable;
+ * the nameKey would be 'timestamp'.
+ *
+ * This label is used in the Renderer (it becomes a column name or the XML description tag)
+ *
+ * @var string
+ */
protected $nameKey = 'defaultKeyName';
+ /**
+ * Returns the nameKey string @see self::$nameKey
+ *
+ * @return string
+ */
public function getNameKey()
{
return $this->nameKey;
}
+
+ /**
+ * Set the nameKey @see self::$nameKey
+ *
+ * @param string $name
+ */
public function setNameKey($name)
{
$this->nameKey = $name;
}
+ /**
+ * Returns the number of DataTable in this DataTable_Array
+ *
+ * @return int
+ */
public function getRowsCount()
{
return count($this->array);
}
- public $metaData = array();
- public function setMetaData( $mixed )
- {
- $this->metaData[] = $mixed;
- }
- public function getMetaData( $mixed )
- {
- return $this->metaData;
- }
+
+ /**
+ * Queue a filter to the DataTable_Array will queue this filter to every DataTable of the DataTable_Array.
+ *
+ * @param string $className Filter name, eg. Piwik_DataTable_Filter_Limit
+ * @param array $parameters Filter parameters, eg. array( 50, 10 )
+ *
+ * @return void
+ */
public function queueFilter( $className, $parameters = array() )
{
foreach($this->array as $table)
@@ -49,6 +90,11 @@
}
}
+ /**
+ * Apply the filters previously queued to each of the DataTable of this DataTable_Array.
+ *
+ * @return void
+ */
public function applyQueuedFilters()
{
foreach($this->array as $table)
@@ -57,16 +103,33 @@
}
}
+ /**
+ * Returns the array of DataTable
+ *
+ * @return array of Piwik_DataTable
+ */
public function getArray()
{
return $this->array;
}
+ /**
+ * Adds a new DataTable to the DataTable_Array
+ *
+ * @param Piwik_DataTable $table
+ * @param string $label Label used to index this table in the array
+ */
public function addTable( Piwik_DataTable $table, $label )
{
$this->array[$label] = $table;
}
+ /**
+ * Returns a string output of this DataTable_Array (applying the default renderer to every DataTable
+ * of this DataTable_Array).
+ *
+ * @return string
+ */
public function __toString()
{
$renderer = new Piwik_DataTable_Renderer_Console($this);
Modified: trunk/modules/DataTable/Filter/AddConstantDetail.php
===================================================================
--- trunk/modules/DataTable/Filter/AddConstantDetail.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter/AddConstantDetail.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -10,13 +10,11 @@
*/
/**
- * Add a new detail to the table based on the value resulting
- * from a callback function with the parameter being another detail's value
+ * Add a new detail column to the table.
*
- * For example for the searchEngine we have a "details" information that gives
- * the URL of the search engine. We use this URL to add a new "details" that gives
- * the path of the logo for this search engine URL (which has the format URL.png).
-
+ * This is used to add a column containing the logo width and height of the countries flag icons.
+ * This value is fixed for all icons so we simply add the same value for all rows.
+ *
* @package Piwik_DataTable
* @subpackage Piwik_DataTable_Filter
*/
@@ -26,6 +24,7 @@
private $functionToApply;
private $detailToAdd;
+
public function __construct( $table, $detailName, $detailValue )
{
parent::__construct($table);
Modified: trunk/modules/DataTable/Filter/AddSummaryRow.php
===================================================================
--- trunk/modules/DataTable/Filter/AddSummaryRow.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter/AddSummaryRow.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -15,14 +15,21 @@
* 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, keeping the first records unchanged.
+ * 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.
+ * This row is assigned a label of 'Others'.
+ *
* @package Piwik_DataTable
* @subpackage Piwik_DataTable_Filter
*/
class Piwik_DataTable_Filter_AddSummaryRow extends Piwik_DataTable_Filter
{
+ public $labelSummaryRow = 'Others';
+
public function __construct( $table, $startRowToSummarize )
{
parent::__construct($table);
@@ -39,7 +46,7 @@
$copied = clone $this->table;
$filter = new Piwik_DataTable_Filter_Limit($copied, $this->startRowToSummarize);
$newRow = new Piwik_DataTable_Row_DataTableSummary($copied);
- $newRow->addColumn('label','Others');
+ $newRow->addColumn('label',$this->labelSummaryRow);
$filter = new Piwik_DataTable_Filter_Limit($this->table, 0, $this->startRowToSummarize);
$this->table->addRow($newRow);
}
Deleted: trunk/modules/DataTable/Filter/ColumnCallback.php
===================================================================
--- trunk/modules/DataTable/Filter/ColumnCallback.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter/ColumnCallback.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -1,44 +0,0 @@
-<?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$
- *
- * @package Piwik_DataTable
- */
-
-/**
- * Delete all rows of when a given function returns false for a given column.
- *
- * @package Piwik_DataTable
- * @subpackage Piwik_DataTable_Filter
- */
-class Piwik_DataTable_Filter_ColumnCallback extends Piwik_DataTable_Filter
-{
- private $columnToFilter;
- private $function;
-
- public function __construct( $table, $columnToFilter, $function )
- {
- parent::__construct($table);
- $this->function = $function;
- $this->columnToFilter = $columnToFilter;
- $this->filter();
- }
-
- protected function filter()
- {
- foreach($this->table->getRows() as $key => $row)
- {
- $columnValue = $row->getColumn($this->columnToFilter);
- if( $columnValue !== false
- && !call_user_func( $this->function, $columnValue))
- {
- $this->table->deleteRow($key);
- }
- }
- }
-}
-
Modified: trunk/modules/DataTable/Filter/ColumnCallbackAddDetail.php
===================================================================
--- trunk/modules/DataTable/Filter/ColumnCallbackAddDetail.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter/ColumnCallbackAddDetail.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -11,13 +11,12 @@
/**
- * Add a new column to the table based on the value resulting
+ * Add a new 'detail' column to the table based on the value resulting
* from a callback function with the parameter being another column's value
*
- * For example from the "label" column we can to create a "short label" column
- * that is a shorter version of the label.
+ * For example from the "label" column we can to create an "icon" 'detail' column
+ * with the icon URI built from the label (LINUX => UserSettings/icons/linux.png)
*
- *
* @package Piwik_DataTable
* @subpackage Piwik_DataTable_Filter
*/
Copied: trunk/modules/DataTable/Filter/ColumnCallbackDeleteRow.php (from rev 386, trunk/modules/DataTable/Filter/ColumnCallback.php)
===================================================================
--- trunk/modules/DataTable/Filter/ColumnCallbackDeleteRow.php (rev 0)
+++ trunk/modules/DataTable/Filter/ColumnCallbackDeleteRow.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -0,0 +1,44 @@
+<?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$
+ *
+ * @package Piwik_DataTable
+ */
+
+/**
+ * Delete all rows for which a given function returns false for a given column.
+ *
+ * @package Piwik_DataTable
+ * @subpackage Piwik_DataTable_Filter
+ */
+class Piwik_DataTable_Filter_ColumnCallbackDeleteRow extends Piwik_DataTable_Filter
+{
+ private $columnToFilter;
+ private $function;
+
+ public function __construct( $table, $columnToFilter, $function )
+ {
+ parent::__construct($table);
+ $this->function = $function;
+ $this->columnToFilter = $columnToFilter;
+ $this->filter();
+ }
+
+ protected function filter()
+ {
+ foreach($this->table->getRows() as $key => $row)
+ {
+ $columnValue = $row->getColumn($this->columnToFilter);
+ if( $columnValue !== false
+ && !call_user_func( $this->function, $columnValue))
+ {
+ $this->table->deleteRow($key);
+ }
+ }
+ }
+}
+
Modified: trunk/modules/DataTable/Filter/DetailCallbackAddDetail.php
===================================================================
--- trunk/modules/DataTable/Filter/DetailCallbackAddDetail.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter/DetailCallbackAddDetail.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -16,7 +16,7 @@
* For example for the searchEngine we have a "details" information that gives
* the URL of the search engine. We use this URL to add a new "details" that gives
* the path of the logo for this search engine URL (which has the format URL.png).
-
+ *
* @package Piwik_DataTable
* @subpackage Piwik_DataTable_Filter
*/
Modified: trunk/modules/DataTable/Filter/Empty.php
===================================================================
--- trunk/modules/DataTable/Filter/Empty.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter/Empty.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -10,7 +10,8 @@
*/
/**
- * Empty filter template.
+ * Filter template.
+ * You can use it if you want to create a new filter.
*
* @package Piwik_DataTable
* @subpackage Piwik_DataTable_Filter
Modified: trunk/modules/DataTable/Filter/ExcludeLowPopulation.php
===================================================================
--- trunk/modules/DataTable/Filter/ExcludeLowPopulation.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter/ExcludeLowPopulation.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -11,6 +11,7 @@
/**
* Delete all rows that have a $columnToFilter value less than the $minimumValue
+ *
* For example we delete from the countries report table all countries that have less than 3 visits.
* It is very useful to exclude noise from the reports.
* You can obviously apply this filter on a percentaged column, eg. remove all countries with the column 'percent_visits' less than 0.05
@@ -31,9 +32,10 @@
function filter()
{
- $function = array("Piwik_DataTable_Filter_ExcludeLowPopulation","excludeLowPopulation");
+ $function = array("Piwik_DataTable_Filter_ExcludeLowPopulation",
+ "excludeLowPopulation");
- $filter = new Piwik_DataTable_Filter_ColumnCallback(
+ $filter = new Piwik_DataTable_Filter_ColumnCallbackDeleteRow(
$this->table,
$this->columnToFilter,
$function
Modified: trunk/modules/DataTable/Filter/Limit.php
===================================================================
--- trunk/modules/DataTable/Filter/Limit.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter/Limit.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -19,8 +19,8 @@
class Piwik_DataTable_Filter_Limit extends Piwik_DataTable_Filter
{
/**
+ * Filter constructor.
*
- *
* @param Piwik_DataTable $table
* @param int $offset Starting row
* @param int $limit Number of rows to keep (specify -1 to keep all rows)
@@ -37,7 +37,7 @@
$this->limit = $limit;
$this->filter();
- }
+ }
protected function filter()
{
Modified: trunk/modules/DataTable/Filter/Pattern.php
===================================================================
--- trunk/modules/DataTable/Filter/Pattern.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter/Pattern.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -25,8 +25,6 @@
public function __construct( $table, $columnToFilter, $patternToSearch )
{
parent::__construct($table);
-// $patternToSearch = preg_quote($patternToSearch, '/');
-// $patternToSearch = str_replace('*','\*',$patternToSearch);
$this->patternToSearch = $patternToSearch;
$this->columnToFilter = $columnToFilter;
$this->filter();
Modified: trunk/modules/DataTable/Filter/PatternRecursive.php
===================================================================
--- trunk/modules/DataTable/Filter/PatternRecursive.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter/PatternRecursive.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -10,7 +10,13 @@
*/
/**
+ * Delete all rows for which
+ * - the given $columnToFilter do not contain the $patternToSearch
+ * - AND all the subTables associated to this row do not contain the $patternToSearch
*
+ * This filter is to be used on columns containing strings.
+ * Exemple: from the pages viewed report, keep only the rows that contain "piwik" or for which a subpage contains "piwik".
+ *
* @package Piwik_DataTable
* @subpackage Piwik_DataTable_Filter
*/
@@ -59,7 +65,8 @@
}
if( $patternNotFoundInChildren
- && !eregi($this->patternToSearch, $row->getColumn($this->columnToFilter)))
+ && (stripos($row->getColumn($this->columnToFilter), $this->patternToSearch) === false)
+ )
{
$table->deleteRow($key);
}
Modified: trunk/modules/DataTable/Filter/ReplaceColumnNames.php
===================================================================
--- trunk/modules/DataTable/Filter/ReplaceColumnNames.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter/ReplaceColumnNames.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -14,7 +14,7 @@
*
* Why this filter?
* For saving bytes in the database, you can change all the columns labels by an integer value.
- * Exemple instead of saving 10000 rows with the column name 'nb_unique_visitors' which would cost a lot of memory,
+ * Exemple instead of saving 10000 rows with the column name 'nb_uniq_visitors' which would cost a lot of memory,
* we map it to the integer 1 before saving in the DB.
* After selecting the DataTable from the DB though, you need to restore back the real names so that
* it shows nicely in the report (XML for example).
@@ -30,7 +30,7 @@
* old column name => new column name
*/
protected $mappingToApply = array(
- Piwik_Archive::INDEX_NB_UNIQ_VISITORS => 'nb_unique_visitors',
+ Piwik_Archive::INDEX_NB_UNIQ_VISITORS => 'nb_uniq_visitors',
Piwik_Archive::INDEX_NB_VISITS => 'nb_visits',
Piwik_Archive::INDEX_NB_ACTIONS => 'nb_actions',
Piwik_Archive::INDEX_MAX_ACTIONS => 'max_actions',
Modified: trunk/modules/DataTable/Filter.php
===================================================================
--- trunk/modules/DataTable/Filter.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Filter.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -39,7 +39,7 @@
abstract protected function filter();
}
-require_once "DataTable/Filter/ColumnCallback.php";
+require_once "DataTable/Filter/ColumnCallbackDeleteRow.php";
require_once "DataTable/Filter/ColumnCallbackAddDetail.php";
require_once "DataTable/Filter/ColumnCallbackReplace.php";
require_once "DataTable/Filter/DetailCallbackAddDetail.php";
Modified: trunk/modules/DataTable/Renderer/Xml.php
===================================================================
--- trunk/modules/DataTable/Renderer/Xml.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/DataTable/Renderer/Xml.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -140,24 +140,24 @@
// 0 =>
// array
// 'label' => string 'phpmyvisites'
- // 'nb_unique_visitors' => int 11
+ // 'nb_uniq_visitors' => int 11
// 'nb_visits' => int 13
// 1 =>
// array
// 'label' => string 'phpmyvisits'
- // 'nb_unique_visitors' => int 2
+ // 'nb_uniq_visitors' => int 2
// 'nb_visits' => int 2
// 'day2' =>
// array
// 0 =>
// array
// 'label' => string 'piwik'
- // 'nb_unique_visitors' => int 121
+ // 'nb_uniq_visitors' => int 121
// 'nb_visits' => int 130
// 1 =>
// array
// 'label' => string 'piwik bis'
- // 'nb_unique_visitors' => int 20
+ // 'nb_uniq_visitors' => int 20
// 'nb_visits' => int 120
if($firstTable instanceof Piwik_DataTable)
{
Modified: trunk/modules/ViewDataTable/Cloud.php
===================================================================
--- trunk/modules/ViewDataTable/Cloud.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/ViewDataTable/Cloud.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -63,7 +63,7 @@
foreach($this->dataTable->getRows() as $row)
{
$label = $row->getColumn('label');
- $value = $row->getColumn('nb_unique_visitors');
+ $value = $row->getColumn('nb_uniq_visitors');
// case no unique visitors
if($value === false)
{
Modified: trunk/modules/ViewDataTable/GenerateGraphData.php
===================================================================
--- trunk/modules/ViewDataTable/GenerateGraphData.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/ViewDataTable/GenerateGraphData.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -80,7 +80,7 @@
foreach($this->dataTable->getRows() as $row)
{
$label = $row->getColumn('label');
- $value = $row->getColumn('nb_unique_visitors');
+ $value = $row->getColumn('nb_uniq_visitors');
// case no unique visitors
if($value === false)
{
Modified: trunk/modules/ViewDataTable/Html.php
===================================================================
--- trunk/modules/ViewDataTable/Html.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/ViewDataTable/Html.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -102,7 +102,6 @@
protected function getColumnsToDisplay($phpArray)
{
-
$dataTableColumns = array();
if(count($phpArray) > 0)
{
@@ -120,13 +119,14 @@
return $dataTableColumns;
}
- protected function isColumnToDisplay( $idColumn )
+ protected function isColumnToDisplay( $idColumn, $nameColumn )
{
// we return true
// - we didn't set any column to display (means we display all the columns)
// - the column has been set as to display
if( count($this->columnsToDisplay) == 0
- || in_array($idColumn, $this->columnsToDisplay))
+ || in_array($idColumn, $this->columnsToDisplay)
+ || in_array($nameColumn, $this->columnsToDisplay))
{
return true;
}
Modified: trunk/modules/ViewDataTable.php
===================================================================
--- trunk/modules/ViewDataTable.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/modules/ViewDataTable.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -181,7 +181,7 @@
// instead of the dataTable_Simple row (label, value)
// to do it properly we'd need to
// - create a filter that removes columns
- // - apply this filter to keep only the column called nb_unique_visitors
+ // - apply this filter to keep only the column called nb_uniq_visitors
// - rename this column as 'value'
// and at this point the getcolumn('value') would have worked
// this code is executed eg. when displaying a sparkline for the last 30 days displaying the number of unique visitors coming from search engines
@@ -191,7 +191,7 @@
// another solution would be to add a method to the Referers API giving directly the integer 'visits from search engines'
// and we would build automatically the dataTable_array of datatatble_simple from these integers
// but we'd have to add this integer to be recorded during archiving etc.
- $value = $onlyRow->getColumn('nb_unique_visitors');
+ $value = $onlyRow->getColumn('nb_uniq_visitors');
}
}
Modified: trunk/plugins/Actions/API.php
===================================================================
--- trunk/plugins/Actions/API.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/plugins/Actions/API.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -54,10 +54,6 @@
{
$dataTable = $archive->getDataTable($name, $idSubtable);
}
-
-// $dataTable->queueFilter( 'Piwik_DataTable_Filter_ReplaceColumnNames',
-// array(Piwik_Actions::getColumnsMap())
-// );
return $dataTable;
}
Modified: trunk/plugins/Actions/Actions.php
===================================================================
--- trunk/plugins/Actions/Actions.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/plugins/Actions/Actions.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -182,17 +182,17 @@
$dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_LogStats_Action::TYPE_ACTION]);
$s = $dataTable->getSerialized();
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array('Actions_actions', $s);
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray('Actions_actions', $s);
$dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_LogStats_Action::TYPE_DOWNLOAD]);
$s = $dataTable->getSerialized();
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array('Actions_downloads', $s);
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray('Actions_downloads', $s);
$dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_LogStats_Action::TYPE_OUTLINK]);
$s = $dataTable->getSerialized();
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array('Actions_outlink', $s);
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray('Actions_outlink', $s);
unset($this->actionsTablesByType);
}
@@ -207,8 +207,9 @@
$split_arr = array(substr($url, 0, $matches[1][1]), substr($url, $matches[1][1]));
}
else
+ {
$split_arr = array($url);
-
+ }
return $split_arr;
}
@@ -290,7 +291,18 @@
// type is used to partition the different actions type in different table. Adding the info to the row would be a duplicate.
if($name != 'name' && $name != 'type')
{
- $currentTable->addColumn($name, $value);
+ // in some very rare case, we actually have twice the same action name with 2 different idaction
+ // this happens when 2 visitors visit the same new page at the same time, there is a SELECT and an INSERT for each new page,
+ // and in between the two the other visitor comes.
+ // here we handle the case where there is already a row for this action name, if this is the case we add the value
+ if(($alreadyValue = $currentTable->getColumn($name)) !== false)
+ {
+ $currentTable->setColumn($name, $alreadyValue+$value);
+ }
+ else
+ {
+ $currentTable->addColumn($name, $value);
+ }
}
}
@@ -316,29 +328,6 @@
return $rowsProcessed;
}
- static protected $nameToIdMapping = array(
- 'nb_visits' => 1,
- 'nb_hits' => 2,
- 'entry_nb_unique_visitor' => 3,
- 'entry_nb_visits' => 4,
- 'entry_nb_actions' => 5,
- 'entry_sum_visit_length' => 6,
- 'entry_bounce_count' => 7,
- 'exit_nb_unique_visitor' => 8,
- 'exit_nb_visits' => 9,
- 'exit_bounce_count' => 10,
- 'sum_time_spent' => 11,
-
- );
- static public function getColumnsMap()
- {
- return array_flip(self::$nameToIdMapping);
- }
-
- protected function getIdColumn( $name )
- {
- return self::$nameToIdMapping[$name];
- }
}
Modified: trunk/plugins/Actions/Controller.php
===================================================================
--- trunk/plugins/Actions/Controller.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/plugins/Actions/Controller.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -170,10 +170,6 @@
if($subTable->getRowsCount() > 0)
{
-// $filter = new Piwik_DataTable_Filter_ReplaceColumnNames(
-// $subTable,
-// Piwik_Actions::getColumnsMap()
-// );
$phpArray = $this->getArrayFromRecursiveDataTable( $subTable, $depth + 1 );
}
}
Modified: trunk/plugins/Provider/Provider.php
===================================================================
--- trunk/plugins/Provider/Provider.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/plugins/Provider/Provider.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -80,7 +80,7 @@
$recordName = 'Provider_hostnameExt';
$labelSQL = "location_provider";
$tableProvider = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableProvider->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableProvider->getSerialized());
// echo $tableProvider;
// Piwik::printMemoryUsage("End of ".get_class($this)." ");
}
Modified: trunk/plugins/Referers/Referers.php
===================================================================
--- trunk/plugins/Referers/Referers.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/plugins/Referers/Referers.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -278,24 +278,24 @@
// Piwik::printMemoryUsage("Middle of ".get_class($this)." ");
$data = $archiveProcessing->getDataTableSerialized($interestByType);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array('Referers_type', $data);
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray('Referers_type', $data);
$data = $archiveProcessing->getDataTablesSerialized($keywordBySearchEngine, $interestBySearchEngine);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array('Referers_keywordBySearchEngine', $data);
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray('Referers_keywordBySearchEngine', $data);
// var_export($data);
$data = $archiveProcessing->getDataTablesSerialized($searchEngineByKeyword, $interestByKeyword);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array('Referers_searchEngineByKeyword', $data);
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray('Referers_searchEngineByKeyword', $data);
$data = $archiveProcessing->getDataTablesSerialized($keywordByCampaign, $interestByCampaign);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array('Referers_keywordByCampaign', $data);
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray('Referers_keywordByCampaign', $data);
$data = $archiveProcessing->getDataTablesSerialized($urlByWebsite[Piwik_Common::REFERER_TYPE_WEBSITE], $interestByWebsite[Piwik_Common::REFERER_TYPE_WEBSITE]);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array('Referers_urlByWebsite', $data);
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray('Referers_urlByWebsite', $data);
$data = $archiveProcessing->getDataTablesSerialized($urlByWebsite[Piwik_Common::REFERER_TYPE_PARTNER], $interestByWebsite[Piwik_Common::REFERER_TYPE_PARTNER]);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array('Referers_urlByPartner', $data);
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray('Referers_urlByPartner', $data);
// Piwik::printMemoryUsage("End of ".get_class($this)." ");
// echo "after serialization = ". $timer;
Modified: trunk/plugins/UserCountry/UserCountry.php
===================================================================
--- trunk/plugins/UserCountry/UserCountry.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/plugins/UserCountry/UserCountry.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -62,14 +62,14 @@
$labelSQL = "location_country";
$tableCountry = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
$record = new Piwik_ArchiveProcessing_Record_Numeric('UserCountry_distinctCountries', $tableCountry->getRowsCount());
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableCountry->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableCountry->getSerialized());
// echo $tableCountry;
$recordName = 'UserCountry_continent';
$labelSQL = "location_continent";
$tableContinent = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableContinent->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableContinent->getSerialized());
// echo $tableContinent;
// Piwik::printMemoryUsage("End of ".get_class($this)." ");
}
@@ -101,7 +101,7 @@
$view->init( 'UserCountry', __FUNCTION__, "UserCountry.getCountry" );
$view->disableExcludeLowPopulation();
- $view->setColumnsToDisplay( array(0,1) );
+ $view->setColumnsToDisplay( array('label','nb_uniq_visitors') );
$view->setSortedColumn( 1 );
$view->disableSearchBox();
Modified: trunk/plugins/UserSettings/UserSettings.php
===================================================================
--- trunk/plugins/UserSettings/UserSettings.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/plugins/UserSettings/UserSettings.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -132,35 +132,35 @@
$recordName = 'UserSettings_configuration';
$labelSQL = "CONCAT(config_os, ';', config_browser_name, ';', config_resolution)";
$tableConfiguration = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableConfiguration->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableConfiguration->getSerialized());
$recordName = 'UserSettings_os';
$labelSQL = "config_os";
$tableOs = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableOs->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableOs->getSerialized());
$recordName = 'UserSettings_browser';
$labelSQL = "CONCAT(config_browser_name, ';', config_browser_version)";
$tableBrowser = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableBrowser->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableBrowser->getSerialized());
$recordName = 'UserSettings_browserType';
$tableBrowserType = $this->getTableBrowserByType($tableBrowser);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableBrowserType->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableBrowserType->getSerialized());
$recordName = 'UserSettings_resolution';
$labelSQL = "config_resolution";
$tableResolution = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
- $filter = new Piwik_DataTable_Filter_ColumnCallback($tableResolution, 'label', 'Piwik_UserSettings_keepStrlenGreater');
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableResolution->getSerialized());
+ $filter = new Piwik_DataTable_Filter_ColumnCallbackDeleteRow($tableResolution, 'label', 'Piwik_UserSettings_keepStrlenGreater');
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableResolution->getSerialized());
$recordName = 'UserSettings_wideScreen';
$tableWideScreen = $this->getTableWideScreen($tableResolution);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableWideScreen->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableWideScreen->getSerialized());
$recordName = 'UserSettings_plugin';
$tablePlugin = $this->getDataTablePlugin();
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tablePlugin->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tablePlugin->getSerialized());
// echo $tableResolution;
// echo $tableWideScreen;
Modified: trunk/plugins/VisitTime/API.php
===================================================================
--- trunk/plugins/VisitTime/API.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/plugins/VisitTime/API.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -38,7 +38,6 @@
$archive = Piwik_Archive::build($idSite, $period, $date );
$dataTable = $archive->getDataTable($name);
- //$dataTable->queueFilter('Piwik_DataTable_Filter_Sort', array('label', 'asc'));
$dataTable->queueFilter('Piwik_DataTable_Filter_ColumnCallbackReplace', array('label', 'Piwik_getTimeLabel'));
$dataTable->queueFilter('Piwik_DataTable_Filter_ReplaceColumnNames');
Modified: trunk/plugins/VisitTime/VisitTime.php
===================================================================
--- trunk/plugins/VisitTime/VisitTime.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/plugins/VisitTime/VisitTime.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -64,14 +64,14 @@
$labelSQL = "HOUR(visitor_localtime)";
$tableLocalTime = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
$this->makeSureAllHoursAreSet($tableLocalTime);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableLocalTime->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableLocalTime->getSerialized());
// echo $tableLocalTime;
$recordName = 'VisitTime_serverTime';
$labelSQL = "HOUR(visit_first_action_time)";
$tableServerTime = $archiveProcessing->getDataTableInterestForLabel($labelSQL);
$this->makeSureAllHoursAreSet($tableServerTime);
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableServerTime->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableServerTime->getSerialized());
// echo $tableServerTime;
}
Modified: trunk/plugins/VisitorInterest/VisitorInterest.php
===================================================================
--- trunk/plugins/VisitorInterest/VisitorInterest.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/plugins/VisitorInterest/VisitorInterest.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -81,11 +81,11 @@
$recordName = 'VisitorInterest_timeGap';
$tableTimegap = $this->getTableTimeGap();
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tableTimegap->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tableTimegap->getSerialized());
$recordName = 'VisitorInterest_pageGap';
$tablePagegap = $this->getTablePageGap();
- $record = new Piwik_ArchiveProcessing_Record_Blob_Array($recordName, $tablePagegap->getSerialized());
+ $record = new Piwik_ArchiveProcessing_Record_BlobArray($recordName, $tablePagegap->getSerialized());
// echo $tableTimegap;
// echo $tablePagegap;
Modified: trunk/tests/modules/DataTable/Renderer.test.php
===================================================================
--- trunk/tests/modules/DataTable/Renderer.test.php 2008-03-20 13:03:52 UTC (rev 394)
+++ trunk/tests/modules/DataTable/Renderer.test.php 2008-03-21 23:35:59 UTC (rev 395)
@@ -41,10 +41,10 @@
protected function getDataTableTest()
{
$array = array (
- array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Google', 'nb_unique_visitors' => 11, 'nb_visits' => 11, 'nb_actions' => 17, 'max_actions' => '5', 'sum_visit_length' => 517, 'bounce_count' => 9),
+ array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Google', 'nb_uniq_visitors' => 11, 'nb_visits' => 11, 'nb_actions' => 17, 'max_actions' => '5', 'sum_visit_length' => 517, 'bounce_count' => 9),
Piwik_DataTable_Row::DETAILS => array('url' => 'http://www.google.com', 'logo' => './plugins/Referers/images/searchEngines/www.google.com.png'),
),
- array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Yahoo!', 'nb_unique_visitors' => 15, 'nb_visits' => 151, 'nb_actions' => 147, 'max_actions' => '50', 'sum_visit_length' => 517, 'bounce_count' => 90),
+ array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Yahoo!', 'nb_uniq_visitors' => 15, 'nb_visits' => 151, 'nb_actions' => 147, 'max_actions' => '50', 'sum_visit_length' => 517, 'bounce_count' => 90),
Piwik_DataTable_Row::DETAILS => array('url' => 'http://www.yahoo.com', 'logo' => './plugins/Referers/images/searchEngines/www.yahoo.com.png'),
)
);
@@ -97,7 +97,7 @@
<result>
<row>
<label>Google</label>
- <nb_unique_visitors>11</nb_unique_visitors>
+ <nb_uniq_visitors>11</nb_uniq_visitors>
<nb_visits>11</nb_visits>
<nb_actions>17</nb_actions>
<max_actions>5</max_actions>
@@ -108,7 +108,7 @@
</row>
<row>
<label>Yahoo!</label>
- <nb_unique_visitors>15</nb_unique_visitors>
+ <nb_uniq_visitors>15</nb_uniq_visitors>
<nb_visits>151</nb_visits>
<nb_actions>147</nb_actions>
<max_actions>50</max_actions>
@@ -167,7 +167,7 @@
{
$dataTable = $this->getDataTableTest();
$render = new Piwik_DataTable_Renderer_Csv($dataTable);
- $expected = 'label,nb_unique_visitors,nb_visits,nb_actions,max_actions,sum_visit_length,bounce_count,detail_url,detail_logo
+ $expected = 'label,nb_uniq_visitors,nb_visits,nb_actions,max_actions,sum_visit_length,bounce_count,detail_url,detail_logo
Google,11,11,17,5,517,9,http://www.google.com,./plugins/Referers/images/searchEngines/www.google.com.png
Yahoo!,15,151,147,50,517,90,http://www.yahoo.com,./plugins/Referers/images/searchEngines/www.yahoo.com.png';
@@ -216,7 +216,7 @@
{
$dataTable = $this->getDataTableTest();
$render = new Piwik_DataTable_Renderer_Json($dataTable);
- $expected = '[{"label":"Google","nb_unique_visitors":11,"nb_visits":11,"nb_actions":17,"max_actions":"5","sum_visit_length":517,"bounce_count":9,"url":"http:\/\/www.google.com","logo":".\/plugins\/Referers\/images\/searchEngines\/www.google.com.png"},{"label":"Yahoo!","nb_unique_visitors":15,"nb_visits":151,"nb_actions":147,"max_actions":"50","sum_visit_length":517,"bounce_count":90,"url":"http:\/\/www.yahoo.com","logo":".\/plugins\/Referers\/images\/searchEngines\/www.yahoo.com.png"}]';
+ $expected = '[{"label":"Google","nb_uniq_visitors":11,"nb_visits":11,"nb_actions":17,"max_actions":"5","sum_visit_length":517,"bounce_count":9,"url":"http:\/\/www.google.com","logo":".\/plugins\/Referers\/images\/searchEngines\/www.google.com.png"},{"label":"Yahoo!","nb_uniq_visitors":15,"nb_visits":151,"nb_actions":147,"max_actions":"50","sum_visit_length":517,"bounce_count":90,"url":"http:\/\/www.yahoo.com","logo":".\/plugins\/Referers\/images\/searchEngines\/www.yahoo.com.png"}]';
$this->assertEqual( $expected,$render->render());
}
@@ -261,7 +261,7 @@
0 =>
array (
'label' => 'Google',
- 'nb_unique_visitors' => 11,
+ 'nb_uniq_visitors' => 11,
'nb_visits' => 11,
'nb_actions' => 17,
'max_actions' => '5',
@@ -273,7 +273,7 @@
1 =>
array (
'label' => 'Yahoo!',
- 'nb_unique_visitors' => 15,
+ 'nb_uniq_visitors' => 15,
'nb_visits' => 151,
'nb_actions' => 147,
'max_actions' => '50',
@@ -334,10 +334,10 @@
protected function getDataTableArrayTest()
{
$array1 = array (
- array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Google', 'nb_unique_visitors' => 11, 'nb_visits' => 11, ),
+ array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Google', 'nb_uniq_visitors' => 11, 'nb_visits' => 11, ),
Piwik_DataTable_Row::DETAILS => array('url' => 'http://www.google.com', 'logo' => './plugins/Referers/images/searchEngines/www.google.com.png'),
),
- array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Yahoo!', 'nb_unique_visitors' => 15, 'nb_visits' => 151, ),
+ array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Yahoo!', 'nb_uniq_visitors' => 15, 'nb_visits' => 151, ),
Piwik_DataTable_Row::DETAILS => array('url' => 'http://www.yahoo.com', 'logo' => './plugins/Referers/images/searchEngines/www.yahoo.com.png'),
)
);
@@ -346,10 +346,10 @@
$array2 = array (
- array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Google1', 'nb_unique_visitors' => 110, 'nb_visits' => 110,),
+ array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Google1', 'nb_uniq_visitors' => 110, 'nb_visits' => 110,),
Piwik_DataTable_Row::DETAILS => array('url' => 'http://www.google.com1', 'logo' => './plugins/Referers/images/searchEngines/www.google.com.png1'),
),
- array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Yahoo!1', 'nb_unique_visitors' => 150, 'nb_visits' => 1510,),
+ array ( Piwik_DataTable_Row::COLUMNS => array( 'label' => 'Yahoo!1', 'nb_uniq_visitors' => 150, 'nb_visits' => 1510,),
Piwik_DataTable_Row::DETAILS => array('url' => 'http://www.yahoo.com1', 'logo' => './plugins/Referers/images/searchEngines/www.yahoo.com.png1'),
)
);
@@ -430,14 +430,14 @@
<result testKey="date1">
<row>
<label>Google</label>
- <nb_unique_visitors>11</nb_unique_visitors>
+ <nb_uniq_visitors>11</nb_uniq_visitors>
<nb_visits>11</nb_visits>
<url>http://www.google.com</url>
<logo>./plugins/Referers/images/searchEngines/www.google.com.png</logo>
</row>
<row>
<label>Yahoo!</label>
- <nb_unique_visitors>15</nb_unique_visitors>
+ <nb_uniq_visitors>15</nb_uniq_visitors>
<nb_visits>151</nb_visits>
<url>http://www.yahoo.com</url>
<logo>./plugins/Referers/images/searchEngines/www.yahoo.com.png</logo>
@@ -446,14 +446,14 @@
<result testKey="date2">
<row>
<label>Google1</label>
- <nb_unique_visitors>110</nb_unique_visitors>
+ <nb_uniq_visitors>110</nb_uniq_visitors>
<nb_visits>110</nb_visits>
<url>http://www.google.com1</url>
<logo>./plugins/Referers/images/searchEngines/www.google.com.png1</logo>
</row>
<row>
<label>Yahoo!1</label>
- <nb_unique_visitors>150</nb_unique_visitors>
+ <nb_uniq_visitors>150</nb_uniq_visitors>
<nb_visits>1510</nb_visits>
<url>http://www.yahoo.com1</url>
<logo>./plugins/Referers/images/searchEngines/www.yahoo.com.png1</logo>
@@ -510,7 +510,7 @@
0 =>
array (
'label' => 'Google',
- 'nb_unique_visitors' => 11,
+ 'nb_uniq_visitors' => 11,
'nb_visits' => 11,
'url' => 'http://www.google.com',
'logo' => './plugins/Referers/images/searchEngines/www.google.com.png',
@@ -518,7 +518,7 @@
1 =>
array (
'label' => 'Yahoo!',
- 'nb_unique_visitors' => 15,
+ 'nb_uniq_visitors' => 15,
'nb_visits' => 151,
'url' => 'http://www.yahoo.com',
'logo' => './plugins/Referers/images/searchEngines/www.yahoo.com.png',
@@ -529,7 +529,7 @@
0 =>
array (
'label' => 'Google1',
- 'nb_unique_visitors' => 110,
+ 'nb_uniq_visitors' => 110,
'nb_visits' => 110,
'url' => 'http://www.google.com1',
'logo' => './plugins/Referers/images/searchEngines/www.google.com.png1',
@@ -537,7 +537,7 @@
1 =>
array (
'label' => 'Yahoo!1',
- 'nb_unique_visitors' => 150,
+ 'nb_uniq_visitors' => 150,
'nb_visits' => 1510,
'url' => 'http://www.yahoo.com1',
'logo' => './plugins/Referers/images/searchEngines/www.yahoo.com.png1',
@@ -591,7 +591,7 @@
$dataTable = $this->getDataTableArrayTest();
$render = new Piwik_DataTable_Renderer_Json($dataTable);
$rendered = $render->render();
- $expected = '{"date1":[{"label":"Google","nb_unique_visitors":11,"nb_visits":11,"url":"http:\/\/www.google.com","logo":".\/plugins\/Referers\/images\/searchEngines\/www.google.com.png"},{"label":"Yahoo!","nb_unique_visitors":15,"nb_visits":151,"url":"http:\/\/www.yahoo.com","logo":".\/plugins\/Referers\/images\/searchEngines\/www.yahoo.com.png"}],"date2":[{"label":"Google1","nb_unique_visitors":110,"nb_visits":110,"url":"http:\/\/www.google.com1","logo":".\/plugins\/Referers\/images\/searchEngines\/www.google.com.png1"},{"label":"Yahoo!1","nb_unique_visitors":150,"nb_visits":1510,"url":"http:\/\/www.yahoo.com1","logo":".\/plugins\/Referers\/images\/searchEngines\/www.yahoo.com.png1"}],"date3":[]}';
+ $expected = '{"date1":[{"label":"Google","nb_uniq_visitors":11,"nb_visits":11,"url":"http:\/\/www.google.com","logo":".\/plugins\/Referers\/images\/searchEngines\/www.google.com.png"},{"label":"Yahoo!","nb_uniq_visitors":15,"nb_visits":151,"url":"http:\/\/www.yahoo.com","logo":".\/plugins\/Referers\/images\/searchEngines\/www.yahoo.com.png"}],"date2":[{"label":"Google1","nb_uniq_visitors":110,"nb_visits":110,"url":"http:\/\/www.google.com1","logo":".\/plugins\/Referers\/images\/searchEngines\/www.google.com.png1"},{"label":"Yahoo!1","nb_uniq_visitors":150,"nb_visits":1510,"url":"http:\/\/www.yahoo.com1","logo":".\/plugins\/Referers\/images\/searchEngines\/www.yahoo.com.png1"}],"date3":[]}';
$this->assertEqual( $expected,$rendered);
}
@@ -624,7 +624,7 @@
{
$dataTable = $this->getDataTableArrayTest();
$render = new Piwik_DataTable_Renderer_Csv($dataTable);
- $expected = 'testKey,label,nb_unique_visitors,nb_visits,detail_url,detail_logo
+ $expected = 'testKey,label,nb_uniq_visitors,nb_visits,detail_url,detail_logo
date1,Google,11,11,http://www.google.com,./plugins/Referers/images/searchEngines/www.google.com.png
date1,Yahoo!,15,151,http://www.yahoo.com,./plugins/Referers/images/searchEngines/www.yahoo.com.png
date2,Google1,110,110,http://www.google.com1,./plugins/Referers/images/searchEngines/www.google.com.png1
More information about the Piwik-svn
mailing list