diff options
Diffstat (limited to 'modules')
72 files changed, 1887 insertions, 1887 deletions
diff --git a/modules/API/APIable.php b/modules/API/APIable.php index feaf139b08..1edefd771e 100755 --- a/modules/API/APIable.php +++ b/modules/API/APIable.php @@ -1,20 +1,20 @@ -<?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 + */ + + require_once "Archive.php"; /** - * 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.
+ * 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). @@ -26,7 +26,7 @@ require_once "Archive.php"; * * See the documentation on http://dev.piwik.org > API * - * @package Piwik_API
+ * @package Piwik_API * @see Piwik_API_Proxy */ diff --git a/modules/API/Proxy.php b/modules/API/Proxy.php index b8eff71d35..04a43fc4c4 100755 --- a/modules/API/Proxy.php +++ b/modules/API/Proxy.php @@ -1,24 +1,24 @@ -<?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 + */ + /** * The API Proxy receives all the API calls requests and forwards them to the given module. * * It registers all the APIable modules (@see Piwik_Apiable) * The class checks that a call to the API has the correct number of parameters. - * The proxy is a singleton that has the knowledge of every method available, their parameters and default values.
+ * The proxy is a singleton that has the knowledge of every method available, their parameters and default values. * * It can also log the performances of the API calls (time spent, parameter values, etc.) - *
+ * * @package Piwik_API */ class Piwik_API_Proxy @@ -29,18 +29,18 @@ class Piwik_API_Proxy protected $alreadyRegistered = array(); private $api = array(); -
+ // when a parameter doesn't have a default value we use this constant const NO_DEFAULT_VALUE = null; static private $instance = null; protected function __construct() {} -
- /**
- * Singleton, returns instance
- *
- * @return Piwik_API_Proxy
+ + /** + * Singleton, returns instance + * + * @return Piwik_API_Proxy */ static public function getInstance() { @@ -61,8 +61,8 @@ class Piwik_API_Proxy * - the API file must be located in plugins/ModuleName/API.php * for example plugins/Referers/API.php * - * The method will introspect the methods, their parameters, etc.
- *
+ * The method will introspect the methods, their parameters, etc. + * * @param string ModuleName eg. "UserSettings" */ public function registerClass( $fileName ) @@ -141,120 +141,120 @@ class Piwik_API_Proxy } $this->alreadyRegistered[$fileName] = true; - }
-
- /**
- * Returns the 'moduleName' part of 'Piwik_moduleName_API' classname
- *
- * @param string moduleName
- * @return string className
- */
- protected function getModuleNameFromClassName( $className )
- {
- $start = strpos($className, '_') + 1;
- return substr($className, $start , strrpos($className, '_') - $start);
- }
-
- /**
- * 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 methods such as deleteSite or deleteUser
- *
- * @param string the class
- * @param methodName the method
- * @return string|false when not possible
- */
- public function getExampleUrl($class, $methodName, $parametersToSet = array())
- {
- $knowExampleDefaultParametersValues = array(
- 'access' => 'view',
- 'idSite' => '1',
- 'userLogin' => 'test',
+ } + + /** + * Returns the 'moduleName' part of 'Piwik_moduleName_API' classname + * + * @param string moduleName + * @return string className + */ + protected function getModuleNameFromClassName( $className ) + { + $start = strpos($className, '_') + 1; + return substr($className, $start , strrpos($className, '_') - $start); + } + + /** + * 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 methods such as deleteSite or deleteUser + * + * @param string the class + * @param methodName the method + * @return string|false when not possible + */ + public function getExampleUrl($class, $methodName, $parametersToSet = array()) + { + $knowExampleDefaultParametersValues = array( + 'access' => 'view', + 'idSite' => '1', + 'userLogin' => 'test', 'password' => 'passwordExample', - 'passwordMd5ied' => 'passwordExample',
- 'email' => 'test@example.org',
-
- 'siteName' => 'new example website',
- 'urls' => 'http://example.org', // used in addSite, updateSite
-
- 'period' => 'day',
- 'date' => 'today',
+ 'passwordMd5ied' => 'passwordExample', + 'email' => 'test@example.org', + + 'siteName' => 'new example website', + 'urls' => 'http://example.org', // used in addSite, updateSite + + 'period' => 'day', + 'date' => 'today', ); foreach($parametersToSet as $name => $value) { $knowExampleDefaultParametersValues[$name] = $value; - }
-
- // no links for these method names
- $doNotPrintExampleForTheseMethods = array(
- 'deleteSite',
- 'deleteUser',
- );
-
- if(in_array($methodName,$doNotPrintExampleForTheseMethods))
- {
- return false;
- }
-
-
- // we try to give an URL example to call the API
- $aParameters = $this->getParametersList($class, $methodName);
- $moduleName = $this->getModuleNameFromClassName($class);
- $urlExample = '?module=API&method='.$moduleName.'.'.$methodName.'&';
- foreach($aParameters as $nameVariable=> $defaultValue)
- {
- // if there isn't a default value for a given parameter,
- // we need a 'know default value' or we can't generate the link
- if($defaultValue === Piwik_API_Proxy::NO_DEFAULT_VALUE)
- {
- if(isset($knowExampleDefaultParametersValues[$nameVariable]))
- {
- $exampleValue = $knowExampleDefaultParametersValues[$nameVariable];
- $urlExample .= $nameVariable . '=' . $exampleValue . '&';
- }
- else
- {
- return false;
- }
- }
-
- }
-
- return substr($urlExample,0,-1);
- }
-
- /**
- * Returns a HTML page containing help for all the successfully loaded APIs.
- *
- * For each module it will return a mini help with the method names, parameters to give,
- * links to get the result in Xml/Csv/etc
- *
- * @return string
+ } + + // no links for these method names + $doNotPrintExampleForTheseMethods = array( + 'deleteSite', + 'deleteUser', + ); + + if(in_array($methodName,$doNotPrintExampleForTheseMethods)) + { + return false; + } + + + // we try to give an URL example to call the API + $aParameters = $this->getParametersList($class, $methodName); + $moduleName = $this->getModuleNameFromClassName($class); + $urlExample = '?module=API&method='.$moduleName.'.'.$methodName.'&'; + foreach($aParameters as $nameVariable=> $defaultValue) + { + // if there isn't a default value for a given parameter, + // we need a 'know default value' or we can't generate the link + if($defaultValue === Piwik_API_Proxy::NO_DEFAULT_VALUE) + { + if(isset($knowExampleDefaultParametersValues[$nameVariable])) + { + $exampleValue = $knowExampleDefaultParametersValues[$nameVariable]; + $urlExample .= $nameVariable . '=' . $exampleValue . '&'; + } + else + { + return false; + } + } + + } + + return substr($urlExample,0,-1); + } + + /** + * Returns a HTML page containing help for all the successfully loaded APIs. + * + * For each module it will return a mini help with the method names, parameters to give, + * links to get the result in Xml/Csv/etc + * + * @return string */ public function getAllInterfaceString( $outputExampleUrls = true, $prefixUrls = '' ) { $str = ''; foreach($this->api as $class => $info) - {
+ { $moduleName = $this->getModuleNameFromClassName($class); $str .= "\n<h3>Module ".$moduleName."</h3>"; foreach($info as $methodName => $infoMethod) - {
-
+ { + $params = $this->getStrListParameters($class, $methodName); - $str .= "\n" . "- <b>$moduleName.$methodName " . $params . "</b>";
-
- $str .= '<small>';
-
- if($outputExampleUrls)
+ $str .= "\n" . "- <b>$moduleName.$methodName " . $params . "</b>"; + + $str .= '<small>'; + + if($outputExampleUrls) { // we prefix all URLs with $prefixUrls - // used when we include this output in the Piwik official documentation for example
- $exampleUrl = $this->getExampleUrl($class, $methodName);
- if($exampleUrl !== false)
+ // used when we include this output in the Piwik official documentation for example + $exampleUrl = $this->getExampleUrl($class, $methodName); + if($exampleUrl !== false) { $lastNUrls = ''; if( ereg('(&period)|(&date)',$exampleUrl)) @@ -263,23 +263,23 @@ class Piwik_API_Proxy $exampleUrlRss2 = $prefixUrls . $this->getExampleUrl($class, $methodName, array('date' => 'last5','period' => 'week',)); $lastNUrls = ", RSS of the last <a target=_blank href='$exampleUrlRss1&format=rss'>10 days</a>, <a target=_blank href='$exampleUrlRss2&format=Rss'>5 weeks</a>, XML of the <a target=_blank href='$exampleUrlRss1&format=xml'>last 10 days</a>"; - }
- $exampleUrl = $prefixUrls . $exampleUrl ;
- $str .= " [ Example in
- <a target=_blank href='$exampleUrl&format=xml'>XML</a>,
- <a target=_blank href='$exampleUrl&format=PHP&prettyDisplay=true'>PHP</a>,
- <a target=_blank href='$exampleUrl&format=JSON'>Json</a>,
+ } + $exampleUrl = $prefixUrls . $exampleUrl ; + $str .= " [ Example in + <a target=_blank href='$exampleUrl&format=xml'>XML</a>, + <a target=_blank href='$exampleUrl&format=PHP&prettyDisplay=true'>PHP</a>, + <a target=_blank href='$exampleUrl&format=JSON'>Json</a>, <a target=_blank href='$exampleUrl&format=Csv'>Csv</a>, <a target=_blank href='$exampleUrl&format=Html'>Basic html</a> - $lastNUrls
- ]";
- }
- else
- {
- $str .= " [ No example available ]";
- }
- }
- $str .= '</small>';
+ $lastNUrls + ]"; + } + else + { + $str .= " [ No example available ]"; + } + } + $str .= '</small>'; $str .= "\n<br>"; } } @@ -289,8 +289,8 @@ class Piwik_API_Proxy /** * Returns the methods $class.$name parameters (and default value if provided) as a string. * - * @param string The class name
- * @param string The method name
+ * @param string The class name + * @param string The method name * @return string For example "(idSite, period, date = 'today')" */ private function getStrListParameters($class, $name) @@ -313,8 +313,8 @@ class Piwik_API_Proxy /** * Returns the parameters names and default values for the method $name * of the class $class - *
- * @param string The class name
+ * + * @param string The class name * @param string The method name * @return array Format array( * 'testParameter' => null, // no default value @@ -328,10 +328,10 @@ class Piwik_API_Proxy } /** - * Returns the number of required parameters (parameters without default values).
- *
- * @param string The class name
- * @param string The method name
+ * Returns the number of required parameters (parameters without default values). + * + * @param string The class name + * @param string The method name * @return int The number of required parameters */ private function getNumberOfRequiredParameters($class, $name) @@ -340,10 +340,10 @@ class Piwik_API_Proxy } /** - * 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
+ * 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 */ private function isMethodAvailable( $className, $methodName) @@ -353,11 +353,11 @@ class Piwik_API_Proxy /** - * Checks that the count of the given parameters do match with the count of the required ones
- *
- * @param string The class name
- * @param string The method name
- * @param array
+ * Checks that the count of the given parameters do match with the count of the required ones + * + * @param string The class name + * @param string The method name + * @param array * @throws exception If less parameters than required were given */ private function checkNumberOfParametersMatch($className, $methodName, $parameters) @@ -374,7 +374,7 @@ class Piwik_API_Proxy /** * Checks that the class is a Singleton (presence of the getInstance() method) - *
+ * * @param string The class name * @throws exception If the class is not a Singleton */ @@ -388,8 +388,8 @@ class Piwik_API_Proxy /** * Checks that the method exists in the class - *
- * @param string The class name
+ * + * @param string The class name * @param string The method name * @throws exception If the method is not found */ @@ -406,9 +406,9 @@ class Piwik_API_Proxy * * For exemple for $module = 'Referers' it returns 'Piwik_Referers_API' * Piwik_Referers_API is the class that extends Piwik_Apiable - * and that contains the methods to be published in the API.
- *
- * @param string module name
+ * and that contains the methods to be published in the API. + * + * @param string module name * @return string class name */ protected function getClassNameFromModule($module) @@ -416,27 +416,27 @@ class Piwik_API_Proxy $class = Piwik::prefixClass($module ."_API"); return $class; } -
- /**
- * Magic method used to set a flag telling the module named currently being called
- *
- */
- public function __get($name)
- {
- self::$classCalled = $name;
- return $this;
+ + /** + * Magic method used to set a flag telling the module named currently being called + * + */ + public function __get($name) + { + self::$classCalled = $name; + return $this; } -
+ /** * Method always called when making an API request. * It checks several things before actually calling the real method on the given module. - *
- * It also logs the API calls, with the parameters values, the returned value, the performance, etc.
- * You can enable logging in config/global.ini.php (log_api_call)
- *
- * @param string The method name
- * @param array The parameters
- *
+ * + * It also logs the API calls, with the parameters values, the returned value, the performance, etc. + * You can enable logging in config/global.ini.php (log_api_call) + * + * @param string The method name + * @param array The parameters + * * @throws Piwik_Access_NoAccessException */ public function __call($methodName, $parameterValues ) diff --git a/modules/ArchiveProcessing.php b/modules/ArchiveProcessing.php index 402b99b43f..9c2204c19d 100644 --- a/modules/ArchiveProcessing.php +++ b/modules/ArchiveProcessing.php @@ -1,18 +1,18 @@ -<?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_ArchiveProcessing
- */
-
-require_once 'TablePartitioning.php';
-require_once 'ArchiveProcessing/Record.php';
+<?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_ArchiveProcessing + */ + +require_once 'TablePartitioning.php'; +require_once 'ArchiveProcessing/Record.php'; require_once 'DataTable.php'; -
+ /** * The ArchiveProcessing module is a module that reads the Piwik logs from the DB and * compute all the reports, which are then stored in the database. @@ -67,34 +67,34 @@ abstract class Piwik_ArchiveProcessing * Timestamp for the first date of the period * * @var int unix timestamp - */
- protected $timestampDateStart = null;
-
+ */ + protected $timestampDateStart = null; + /** * Starting date of the archive - *
- * @var Piwik_Date
+ * + * @var Piwik_Date */ - protected $dateStart;
+ protected $dateStart; /** * Ending date of the archive - *
- * @var Piwik_Date
+ * + * @var Piwik_Date */ - protected $dateEnd;
-
+ protected $dateEnd; + /** * Object used to generate (depending on the $dateStart) the name of the DB table to use to store numeric values - *
- * @var Piwik_TablePartitioning
+ * + * @var Piwik_TablePartitioning */ - protected $tableArchiveNumeric;
+ protected $tableArchiveNumeric; /** * Object used to generate (depending on the $dateStart) the name of the DB table to use to store numeric values - *
- * @var Piwik_TablePartitioning
+ * + * @var Piwik_TablePartitioning */ - protected $tableArchiveBlob;
+ protected $tableArchiveBlob; /** * Maximum timestamp above which a given archive is considered out of date @@ -109,25 +109,25 @@ abstract class Piwik_ArchiveProcessing * * @var int */ - public $idsite = null;
+ public $idsite = null; /** * Period of the current archive * Can be accessed by plugins (that is why it's public) * - * @var Piwik_Period
+ * @var Piwik_Period */ - public $period = null;
-
+ public $period = null; + /** * Site of the current archive * Can be accessed by plugins (that is why it's public) - *
- * @var Piwik_Site
+ * + * @var Piwik_Site */ public $site = null; -
-
+ + /** * Starting date @see Piwik_Date::toString() * @@ -179,42 +179,42 @@ abstract class Piwik_ArchiveProcessing public function __construct() { $this->debugAlwaysArchive = Zend_Registry::get('config')->Debug->always_archive_data; - }
-
-
- /**
- * Returns the Piwik_ArchiveProcessing_Day or Piwik_ArchiveProcessing_Period object
- * depending on $name period string
- *
- * @param string $name day|week|month|year
- * @return Piwik_ArchiveProcessing Piwik_ArchiveProcessing_Day|Piwik_ArchiveProcessing_Period
- */
- static function factory($name )
- {
- switch($name)
- {
- case 'day':
- require_once 'ArchiveProcessing/Day.php';
- $process = new Piwik_ArchiveProcessing_Day;
- break;
-
- case 'week':
- case 'month':
- case 'year':
- require_once 'ArchiveProcessing/Period.php';
- $process = new Piwik_ArchiveProcessing_Period;
- break;
-
- default:
- throw new Exception("Unknown period specified $name");
- break;
- }
- return $process;
- }
- - /** - * Inits the object
- *
+ } + + + /** + * Returns the Piwik_ArchiveProcessing_Day or Piwik_ArchiveProcessing_Period object + * depending on $name period string + * + * @param string $name day|week|month|year + * @return Piwik_ArchiveProcessing Piwik_ArchiveProcessing_Day|Piwik_ArchiveProcessing_Period + */ + static function factory($name ) + { + switch($name) + { + case 'day': + require_once 'ArchiveProcessing/Day.php'; + $process = new Piwik_ArchiveProcessing_Day; + break; + + case 'week': + case 'month': + case 'year': + require_once 'ArchiveProcessing/Period.php'; + $process = new Piwik_ArchiveProcessing_Period; + break; + + default: + throw new Exception("Unknown period specified $name"); + break; + } + return $process; + } + + /** + * Inits the object + * * @return void */ protected function loadArchiveProperties() @@ -233,8 +233,8 @@ abstract class Piwik_ArchiveProcessing $this->strDateStart = $this->dateStart->toString(); $this->strDateEnd = $this->dateEnd->toString(); -
- // if the current archive is a DAY and if it's today,
+ + // if the current archive is a DAY and if it's today, // we set this maxTimestampArchive that defines the lifetime value of today's archive $this->maxTimestampArchive = 0; if( $this->period->getNumberOfSubperiods() == 0 @@ -371,20 +371,20 @@ abstract class Piwik_ArchiveProcessing } - /**
- * Returns the name of the numeric table where the archive numeric values are stored
- *
- * @return string
+ /** + * Returns the name of the numeric table where the archive numeric values are stored + * + * @return string */ public function getTableArchiveNumericName() { return $this->tableArchiveNumeric->getTableName(); } -
- /**
- * Returns the name of the blob table where the archive blob values are stored
- *
- * @return string
+ + /** + * Returns the name of the blob table where the archive blob values are stored + * + * @return string */ public function getTableArchiveBlobName() { @@ -392,20 +392,20 @@ abstract class Piwik_ArchiveProcessing } - /**
- * Set the period
- *
- * @param Piwik_Period $period
+ /** + * Set the period + * + * @param Piwik_Period $period */ public function setPeriod( Piwik_Period $period ) { $this->period = $period; } - /**
- * Set the site
- *
- * @param Piwik_Site $site
+ /** + * Set the site + * + * @param Piwik_Site $site */ public function setSite( Piwik_Site $site ) { @@ -427,10 +427,10 @@ abstract class Piwik_ArchiveProcessing return $this->timestampDateStart; } - /**
- * Returns the idArchive we will use for the current archive
- *
- * @return int IdArchive to use when saving the current Archive
+ /** + * Returns the idArchive we will use for the current archive + * + * @return int IdArchive to use when saving the current Archive */ protected function loadNextIdarchive() { @@ -442,12 +442,12 @@ abstract class Piwik_ArchiveProcessing } $this->idArchive = $id + 1; - }
-
- /**
- * Inserts a record in the good table (either NUMERIC or BLOB)
- *
- * @param unknown_type $record
+ } + + /** + * Inserts a record in the good table (either NUMERIC or BLOB) + * + * @param unknown_type $record */ protected function insertRecord($record) { @@ -477,8 +477,8 @@ abstract class Piwik_ArchiveProcessing } /** - * Returns the ID of the archived subperiods.
- *
+ * Returns the ID of the archived subperiods. + * * @return array Array of the idArchive of the subperiods */ protected function loadSubperiodsArchive() @@ -498,17 +498,17 @@ abstract class Piwik_ArchiveProcessing return $periods; } -
- /**
- * Returns the idArchive if the archive is available in the database.
+ + /** + * Returns the idArchive if the archive is available in the database. * Returns false if the archive needs to be computed. * * An archive is available if * - for today, the archive was computed less than maxTimestampArchive seconds ago * - for any other day, if the archive was computed once this day was finished - * - for other periods, if the archive was computed once the period was finished
- *
- * @return int|false
+ * - for other periods, if the archive was computed once the period was finished + * + * @return int|false */ protected function isArchived() { diff --git a/modules/ArchiveProcessing/Day.php b/modules/ArchiveProcessing/Day.php index 7f3773ed75..d5b68b2139 100644 --- a/modules/ArchiveProcessing/Day.php +++ b/modules/ArchiveProcessing/Day.php @@ -1,14 +1,14 @@ -<?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_ArchiveProcessing
- */
-
+<?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_ArchiveProcessing + */ + /** * Handles the archiving process for a day. @@ -28,8 +28,8 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing */ public $isThereSomeVisits = false; - /**
- * Constructor
+ /** + * Constructor */ function __construct() { @@ -38,10 +38,10 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing } /** - * Main method to process logs for a day. The only logic done here is computing the number of visits, actions, etc.
- * 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'
- *
+ * Main method to process logs for a day. The only logic done here is computing the number of visits, actions, etc. + * 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 */ protected function compute() @@ -100,23 +100,23 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing Zend_Registry::get('db')->query(sprintf($query, $blobTable), $this->periodId); Zend_Registry::get('db')->query(sprintf($query, $numericTable), $this->periodId); } -
- /**
- * Helper function that returns a DataTable containing the $select fields / value pairs.
- * IMPORTANT: The $select must return only one row!!
- *
- * Example $select = "count(distinct( config_os )) as countDistinctOs,
- * sum( config_flash ) / count(distinct(idvisit)) as percentFlash "
- * $labelCount = "test_column_name"
- * will return a dataTable that looks like
- * label test_column_name
- * CountDistinctOs 9
- * PercentFlash 0.5676
- *
- *
- * @param string $select
- * @param string $labelCount
- * @return Piwik_DataTable
+ + /** + * Helper function that returns a DataTable containing the $select fields / value pairs. + * IMPORTANT: The $select must return only one row!! + * + * Example $select = "count(distinct( config_os )) as countDistinctOs, + * sum( config_flash ) / count(distinct(idvisit)) as percentFlash " + * $labelCount = "test_column_name" + * will return a dataTable that looks like + * label test_column_name + * CountDistinctOs 9 + * PercentFlash 0.5676 + * + * + * @param string $select + * @param string $labelCount + * @return Piwik_DataTable */ public function getSimpleDataTableFromSelect($select, $labelCount) { @@ -135,28 +135,28 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing return $table; } - /**
- * Helper function that returns common statistics for a given database field distinct values.
- *
- * The statistics returned are:
- * - number of unique visitors
- * - number of visits
- * - number of actions
- * - maximum number of action for a visit
- * - sum of the visits' length in sec
- * - count of bouncing visits (visits with one page view)
- *
- * For example if $label = 'config_os' it will return the statistics for every distinct Operating systems
- * The returned DataTable will have a row per distinct operating systems,
- * and a column per stat (nb of visits, max actions, etc)
- *
- * 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
- *
- * @param string $label Table log_visit field name to be use to compute common stats
- * @return Piwik_DataTable
+ /** + * Helper function that returns common statistics for a given database field distinct values. + * + * The statistics returned are: + * - number of unique visitors + * - number of visits + * - number of actions + * - maximum number of action for a visit + * - sum of the visits' length in sec + * - count of bouncing visits (visits with one page view) + * + * For example if $label = 'config_os' it will return the statistics for every distinct Operating systems + * The returned DataTable will have a row per distinct operating systems, + * and a column per stat (nb of visits, max actions, etc) + * + * 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 + * + * @param string $label Table log_visit field name to be use to compute common stats + * @return Piwik_DataTable */ public function getDataTableInterestForLabel( $label ) { @@ -195,14 +195,14 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing $table->loadFromArrayLabelIsKey($interest); return $table; } -
- /**
- * Generates a dataTable given a multidimensional PHP array that associates LABELS to Piwik_DataTableRows
- * This is used for the "Actions" DataTable, where a line is the aggregate of all the subtables
- * Example: the category /blog has 3 visits because it has /blog/index (2 visits) + /blog/about (1 visit)
- *
- * @param array $table
- * @return Piwik_DataTable
+ + /** + * Generates a dataTable given a multidimensional PHP array that associates LABELS to Piwik_DataTableRows + * This is used for the "Actions" DataTable, where a line is the aggregate of all the subtables + * Example: the category /blog has 3 visits because it has /blog/index (2 visits) + /blog/about (1 visit) + * + * @param array $table + * @return Piwik_DataTable */ static public function generateDataTable( $table ) { @@ -232,17 +232,17 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing return $dataTableToReturn; } -
- /**
- * Helper function that returns the serialized DataTable of the given PHP array.
- * The array must have the format of Piwik_DataTable::loadFromArrayLabelIsKey()
- * Example: array (
- * LABEL => array(col1 => X, col2 => Y),
- * LABEL2 => array(col1 => X, col2 => Y),
- * )
- *
- * @param array $array at the given format
- * @return array Array with one element: the serialized data table string
+ + /** + * Helper function that returns the serialized DataTable of the given PHP array. + * The array must have the format of Piwik_DataTable::loadFromArrayLabelIsKey() + * Example: array ( + * LABEL => array(col1 => X, col2 => Y), + * LABEL2 => array(col1 => X, col2 => Y), + * ) + * + * @param array $array at the given format + * @return array Array with one element: the serialized data table string */ public function getDataTableSerialized( $arrayLevel0 ) { @@ -252,29 +252,29 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing return $toReturn; } -
- /**
- * Helper function that returns the multiple serialized DataTable of the given PHP array.
- * The DataTable here associates a subtable to every row of the level 0 array.
- * This is used for example for search engines. Every search engine (level 0) has a subtable containing the
- * keywords.
- *
- * The $arrayLevel0 must have the format
- * Example: array (
- * LABEL => array(col1 => X, col2 => Y),
- * LABEL2 => array(col1 => X, col2 => Y),
- * )
- *
- * The $subArrayLevel1ByKey must have the format
- * Example: array(
- * LABEL => #Piwik_DataTable_ForLABEL,
- * LABEL2 => #Piwik_DataTable_ForLABEL2,
- * )
- *
- *
- * @param array $arrayLevel0
- * @param array of Piwik_DataTable $subArrayLevel1ByKey
- * @return array Array with N elements: the strings of the datatable serialized
+ + /** + * Helper function that returns the multiple serialized DataTable of the given PHP array. + * The DataTable here associates a subtable to every row of the level 0 array. + * This is used for example for search engines. Every search engine (level 0) has a subtable containing the + * keywords. + * + * The $arrayLevel0 must have the format + * Example: array ( + * LABEL => array(col1 => X, col2 => Y), + * LABEL2 => array(col1 => X, col2 => Y), + * ) + * + * The $subArrayLevel1ByKey must have the format + * Example: array( + * LABEL => #Piwik_DataTable_ForLABEL, + * LABEL2 => #Piwik_DataTable_ForLABEL2, + * ) + * + * + * @param array $arrayLevel0 + * @param array of Piwik_DataTable $subArrayLevel1ByKey + * @return array Array with N elements: the strings of the datatable serialized */ public function getDataTablesSerialized( $arrayLevel0, $subArrayLevel1ByKey) { @@ -294,11 +294,11 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing return $toReturn; } -
- /**
- * Returns an empty row containing default values for the common stat
- *
- * @return array
+ + /** + * Returns an empty row containing default values for the common stat + * + * @return array */ public function getNewInterestRow() { @@ -310,32 +310,32 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing Piwik_Archive::INDEX_BOUNCE_COUNT => 0 ); } -
-
- /**
- * Returns a Piwik_DataTable_Row containing default values for common stat,
- * plus a column 'label' with the value $label
- *
- * @param string $label
- * @return Piwik_DataTable_Row
- */
- public function getNewInterestRowLabeled( $label )
- {
- return new Piwik_DataTable_Row(
- array(
- Piwik_DataTable_Row::COLUMNS => array( 'label' => $label)
- + $this->getNewInterestRow()
- )
- );
- }
-
- /**
- * Adds the given row $newRowToAdd to the existing $oldRowToUpdate passed by reference
- *
- * The rows are php arrays Name => value
- *
- * @param array $newRowToAdd
- * @param array $oldRowToUpdate
+ + + /** + * Returns a Piwik_DataTable_Row containing default values for common stat, + * plus a column 'label' with the value $label + * + * @param string $label + * @return Piwik_DataTable_Row + */ + public function getNewInterestRowLabeled( $label ) + { + return new Piwik_DataTable_Row( + array( + Piwik_DataTable_Row::COLUMNS => array( 'label' => $label) + + $this->getNewInterestRow() + ) + ); + } + + /** + * Adds the given row $newRowToAdd to the existing $oldRowToUpdate passed by reference + * + * The rows are php arrays Name => value + * + * @param array $newRowToAdd + * @param array $oldRowToUpdate */ public function updateInterestStats( $newRowToAdd, &$oldRowToUpdate) { diff --git a/modules/ArchiveProcessing/Period.php b/modules/ArchiveProcessing/Period.php index b953f8124e..83cc54ecaa 100644 --- a/modules/ArchiveProcessing/Period.php +++ b/modules/ArchiveProcessing/Period.php @@ -1,13 +1,13 @@ -<?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_ArchiveProcessing
- */
+<?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_ArchiveProcessing + */ /** * Handles the archiving process for a period diff --git a/modules/ArchiveProcessing/Record.php b/modules/ArchiveProcessing/Record.php index f512fe5419..2dba870d19 100644 --- a/modules/ArchiveProcessing/Record.php +++ b/modules/ArchiveProcessing/Record.php @@ -1,20 +1,20 @@ -<?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_ArchiveProcessing
- */
+<?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_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. * At its creation, the record registers itself to the RecordManager. diff --git a/modules/Auth.php b/modules/Auth.php index e84ed8b7b4..907f98a609 100644 --- a/modules/Auth.php +++ b/modules/Auth.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * Authentication object. * Should be reviewed and refactor to allow simple plugin overwrite @@ -33,8 +33,8 @@ class Piwik_Auth extends Zend_Auth_Adapter_DbTable $rootLogin = Zend_Registry::get('config')->superuser->login; $rootPassword = Zend_Registry::get('config')->superuser->password; $rootToken = Piwik_UsersManager_API::getTokenAuth($rootLogin,$rootPassword); -
- // echo $rootToken;
+ + // echo $rootToken; // echo "<br>". $this->_credential;exit; if($this->_identity == $rootLogin && $this->_credential == $rootToken) @@ -52,7 +52,7 @@ class Piwik_Auth extends Zend_Auth_Adapter_DbTable // of this class in the zend_registry and it should work if(is_null($this->_identity)) { - $authenticated = false;
+ $authenticated = false; if($this->_credential === $rootToken) { diff --git a/modules/Common.php b/modules/Common.php index b726671f1f..6b8b46b84d 100644 --- a/modules/Common.php +++ b/modules/Common.php @@ -1,21 +1,21 @@ -<?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_Helper
- */
-
+<?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_Helper + */ + /** * Static class providing functions used by both the CORE of Piwik and the visitor logging engine. * * This is the only external class loaded by the /piwik.php file. * This class should contain only the functions that are used in * both the CORE and the piwik.php statistics logging engine. - *
+ * * @package Piwik_Helper */ class Piwik_Common diff --git a/modules/Config.php b/modules/Config.php index 5686b62fe0..7450e93c6d 100755 --- a/modules/Config.php +++ b/modules/Config.php @@ -1,17 +1,17 @@ -<?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_Helper
- */
+<?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_Helper + */ require_once "Zend/Config/Ini.php"; -require_once "Zend/Registry.php";
-
+require_once "Zend/Registry.php"; + /** * This class is used to access configuration files values. * You can also set these values, the updated configuration files will be written at the end of the script execution. @@ -19,9 +19,9 @@ require_once "Zend/Registry.php"; * Example reading a value from the configuration file: * $minValue = Zend_Registry::get('config')->General->minimumMemoryLimit; * - * will read the value minimumMemoryLimit under the [General] section of the config file
+ * will read the value minimumMemoryLimit under the [General] section of the config file * - * @package Piwik_Helper
+ * @package Piwik_Helper */ class Piwik_Config { diff --git a/modules/Controller.php b/modules/Controller.php index d2c6f74805..f0a7e95f1b 100644 --- a/modules/Controller.php +++ b/modules/Controller.php @@ -1,20 +1,20 @@ -<?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
- */
-
-/**
+<?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 + */ + +/** * Parent class of all plugins Controllers (located in /plugins/PluginName/Controller.php * It defines some helper functions controllers can use. - *
- * @package Piwik
- */
+ * + * @package Piwik + */ abstract class Piwik_Controller { /** diff --git a/modules/Cookie.php b/modules/Cookie.php index 9ba2e46d1b..9ad3680e25 100644 --- a/modules/Cookie.php +++ b/modules/Cookie.php @@ -1,21 +1,21 @@ -<?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_Helper
- */
-
+<?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_Helper + */ + /** * Simple class to handle the cookies: * - read a cookie values * - edit an existing cookie and save it * - create a new cookie, set values, expiration date, etc. and save it - *
+ * * @package Piwik_Helper */ class Piwik_Cookie diff --git a/modules/DataFiles/Browsers.php b/modules/DataFiles/Browsers.php index 863114f8d3..96a379fb4e 100644 --- a/modules/DataFiles/Browsers.php +++ b/modules/DataFiles/Browsers.php @@ -1,14 +1,14 @@ -<?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_UserSettings
- */
-
+<?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_UserSettings + */ + /** * Browser list. * If you want to add a new entry, please email us at hello at piwik.org diff --git a/modules/DataFiles/Countries.php b/modules/DataFiles/Countries.php index b0503e7b11..85c46713b4 100644 --- a/modules/DataFiles/Countries.php +++ b/modules/DataFiles/Countries.php @@ -1,14 +1,14 @@ -<?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_UserCountry
- */
-
+<?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_UserCountry + */ + /** * Country code and continent database. * If you want to add a new entry, please email us at hello at piwik.org diff --git a/modules/DataFiles/OS.php b/modules/DataFiles/OS.php index 3f6199c280..9bce88e7bc 100644 --- a/modules/DataFiles/OS.php +++ b/modules/DataFiles/OS.php @@ -1,14 +1,14 @@ -<?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_UserSettings
- */
-
+<?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_UserSettings + */ + /** * Operating systems database. * If you want to add a new entry, please email us at hello at piwik.org diff --git a/modules/DataFiles/SearchEngines.php b/modules/DataFiles/SearchEngines.php index e5a9a6611c..dd28d8a79b 100644 --- a/modules/DataFiles/SearchEngines.php +++ b/modules/DataFiles/SearchEngines.php @@ -1,13 +1,13 @@ -<?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_Referers
- */
+<?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_Referers + */ /** * Search Engine database * diff --git a/modules/DataTable.php b/modules/DataTable.php index 7321bfd3b8..3a47ea2554 100644 --- a/modules/DataTable.php +++ b/modules/DataTable.php @@ -1,19 +1,19 @@ -<?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
- */
-
-require_once "DataTable/Renderer.php";
-require_once "DataTable/Renderer/Console.php";
-require_once "DataTable/Filter.php";
-require_once "DataTable/Row.php";
-require_once "DataTable/Manager.php";
+<?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 + */ + +require_once "DataTable/Renderer.php"; +require_once "DataTable/Renderer/Console.php"; +require_once "DataTable/Filter.php"; +require_once "DataTable/Row.php"; +require_once "DataTable/Manager.php"; /** * * Initial Specification @@ -395,28 +395,28 @@ class Piwik_DataTable { return $this->currentId; } -
+ /** - * Adds a new row from a PHP array data structure
+ * Adds a new row from a PHP array data structure * You should use loadFromArray for performance! * - * @param array $row, eg. array(Piwik_DataTable_Row::COLUMNS => array( 'visits' => 13, 'test' => 'toto'),)
- */
- public function addRowFromArray( $row )
- {
- $this->loadFromArray(array($row));
- }
-
- /** - * Adds a new row a PHP array data structure
+ * @param array $row, eg. array(Piwik_DataTable_Row::COLUMNS => array( 'visits' => 13, 'test' => 'toto'),) + */ + public function addRowFromArray( $row ) + { + $this->loadFromArray(array($row)); + } + + /** + * Adds a new row a PHP array data structure * You should use loadFromSimpleArray for performance! * - * @param array $row, eg. array('name' => 'google analytics', 'license' => 'commercial')
- */
- public function addRowFromSimpleArray( $row )
- {
- $this->loadFromSimpleArray(array($row));
- }
+ * @param array $row, eg. array('name' => 'google analytics', 'license' => 'commercial') + */ + public function addRowFromSimpleArray( $row ) + { + $this->loadFromSimpleArray(array($row)); + } /** * Returns the array of Piwik_DataTable_Row @@ -623,7 +623,7 @@ class Piwik_DataTable if($depth > self::MAXIMUM_DEPTH_LEVEL_ALLOWED) { throw new Exception("Maximum recursion level of ".self::MAXIMUM_DEPTH_LEVEL_ALLOWED. " reached. You have probably set a DataTable_Row with an associated DataTable which belongs already to its parent hierarchy."); - }
+ } // For each row, get the serialized row // If it is associated to a sub table, get the serialized table recursively ; @@ -642,14 +642,14 @@ class Piwik_DataTable } } // we load the current Id of the DataTable - $forcedId = $this->getId();
-
+ $forcedId = $this->getId(); + // if the datatable is the parent we force the Id at 0 (this is part of the specification) if($depth==0) { $forcedId = 0; - }
-
+ } + // we then serialize the rows and store them in the serialized dataTable $aSerializedDataTable[$forcedId] = serialize($this->rows); @@ -681,14 +681,14 @@ class Piwik_DataTable * Loads the DataTable from a PHP array data structure * * @param array Array with the following structure - * array(
+ * array( * // row1 - * array(
- * Piwik_DataTable_Row::COLUMNS => array( col1_name => value1, col2_name => value2, ...),
- * Piwik_DataTable_Row::DETAILS => array( detail1_name => value1, ...), // see Piwik_DataTable_Row
- *
- * ),
- *
+ * array( + * Piwik_DataTable_Row::COLUMNS => array( col1_name => value1, col2_name => value2, ...), + * Piwik_DataTable_Row::DETAILS => array( detail1_name => value1, ...), // see Piwik_DataTable_Row + * + * ), + * * // row2 * array( ... ), * @@ -706,90 +706,90 @@ class Piwik_DataTable $this->addRow($row); } - }
-
- /**
- * Loads the data from a simple php array.
- * Basically maps a simple multidimensional php array to a DataTable.
- * Not recursive (if a row contains a php array itself, it won't be loaded)
- *
- * @param array Array with the simple structure:
- * array(
- * array( col1_name => valueA, col2_name => valueC, ...),
- * array( col1_name => valueB, col2_name => valueD, ...),
- * )
- */
- public function loadFromSimpleArray( $array )
- {
- // we define an exception we may throw if at one point we notice that we cannot handle the data structure
- $e = new Exception(" Data structure returned is not convertible in the requested format.".
- " Try to call this method with the parameters '&format=original&serialize=1'".
- "; you will get the original php data structure serialized.".
- " The data structure looks like this: \n \$data = " . var_export($array, true) . "; ");
-
-
- // first pass to see if the array has the structure
- // array(col1_name => val1, col2_name => val2, etc.)
- // with val* that are never arrays (only strings/numbers/bool/etc.)
- // if we detect such a "simple" data structure we convert it to a row with the correct columns' names
+ } + + /** + * Loads the data from a simple php array. + * Basically maps a simple multidimensional php array to a DataTable. + * Not recursive (if a row contains a php array itself, it won't be loaded) + * + * @param array Array with the simple structure: + * array( + * array( col1_name => valueA, col2_name => valueC, ...), + * array( col1_name => valueB, col2_name => valueD, ...), + * ) + */ + public function loadFromSimpleArray( $array ) + { + // we define an exception we may throw if at one point we notice that we cannot handle the data structure + $e = new Exception(" Data structure returned is not convertible in the requested format.". + " Try to call this method with the parameters '&format=original&serialize=1'". + "; you will get the original php data structure serialized.". + " The data structure looks like this: \n \$data = " . var_export($array, true) . "; "); + + + // first pass to see if the array has the structure + // array(col1_name => val1, col2_name => val2, etc.) + // with val* that are never arrays (only strings/numbers/bool/etc.) + // if we detect such a "simple" data structure we convert it to a row with the correct columns' names $rowBuilt = array(); $thisIsNotThatSimple = false; -
- foreach($array as $columnName => $columnValue )
- {
- if(is_array($columnValue) || is_object($columnValue))
- {
- $thisIsNotThatSimple = true;
- break;
- }
- $rowBuilt += array($columnName => $columnValue );
+ + foreach($array as $columnName => $columnValue ) + { + if(is_array($columnValue) || is_object($columnValue)) + { + $thisIsNotThatSimple = true; + break; + } + $rowBuilt += array($columnName => $columnValue ); + } + + if($thisIsNotThatSimple === false) + { + $this->addRow( new Piwik_DataTable_Row( array( Piwik_DataTable_Row::COLUMNS => $rowBuilt ) ) ); + // we have converted our simple array to one single row + // => we exit the method as the job is now finished + return; + } + + + foreach($array as $key => $row) + { + // stuff that looks like a line + if(is_array($row)) + { + /** + * We make sure we can convert this PHP array without losing information. + * We are able to convert only simple php array (no strings keys, no sub arrays, etc.) + * + */ + + // if the key is a string it means that some information was contained in this key. + // it cannot be lost during the conversion. Because we are not able to handle properly + // this key, we throw an explicit exception. + if(is_string($key)) + { + throw $e; + } + // if any of the sub elements of row is an array we cannot handle this data structure... + foreach($row as $subRow) + { + if(is_array($subRow)) + { + throw $e; + } + } + + + $row = new Piwik_DataTable_Row( array( Piwik_DataTable_Row::COLUMNS => $row ) ); + } + // other (string, numbers...) => we build a line from this value + else + { + $row = new Piwik_DataTable_Row( array( Piwik_DataTable_Row::COLUMNS => array($key => $row)) ); + } + $this->addRow($row); } -
- if($thisIsNotThatSimple === false)
- {
- $this->addRow( new Piwik_DataTable_Row( array( Piwik_DataTable_Row::COLUMNS => $rowBuilt ) ) );
- // we have converted our simple array to one single row
- // => we exit the method as the job is now finished
- return;
- }
-
-
- foreach($array as $key => $row)
- {
- // stuff that looks like a line
- if(is_array($row))
- {
- /**
- * We make sure we can convert this PHP array without losing information.
- * We are able to convert only simple php array (no strings keys, no sub arrays, etc.)
- *
- */
-
- // if the key is a string it means that some information was contained in this key.
- // it cannot be lost during the conversion. Because we are not able to handle properly
- // this key, we throw an explicit exception.
- if(is_string($key))
- {
- throw $e;
- }
- // if any of the sub elements of row is an array we cannot handle this data structure...
- foreach($row as $subRow)
- {
- if(is_array($subRow))
- {
- throw $e;
- }
- }
-
-
- $row = new Piwik_DataTable_Row( array( Piwik_DataTable_Row::COLUMNS => $row ) );
- }
- // other (string, numbers...) => we build a line from this value
- else
- {
- $row = new Piwik_DataTable_Row( array( Piwik_DataTable_Row::COLUMNS => array($key => $row)) );
- }
- $this->addRow($row);
- }
} /** diff --git a/modules/DataTable/Filter.php b/modules/DataTable/Filter.php index 561e3c3baa..4bd93267c3 100644 --- a/modules/DataTable/Filter.php +++ b/modules/DataTable/Filter.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * A filter is applied instantly to a given DataTable and can * - remove rows diff --git a/modules/DataTable/Filter/AddConstantDetail.php b/modules/DataTable/Filter/AddConstantDetail.php index 340779ed38..9452c29678 100644 --- a/modules/DataTable/Filter/AddConstantDetail.php +++ b/modules/DataTable/Filter/AddConstantDetail.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * Add a new detail column to the table. * diff --git a/modules/DataTable/Filter/ColumnCallbackAddDetail.php b/modules/DataTable/Filter/ColumnCallbackAddDetail.php index b604734484..38773f4a9b 100644 --- a/modules/DataTable/Filter/ColumnCallbackAddDetail.php +++ b/modules/DataTable/Filter/ColumnCallbackAddDetail.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * Add a new 'detail' column to the table based on the value resulting diff --git a/modules/DataTable/Filter/ColumnCallbackDeleteRow.php b/modules/DataTable/Filter/ColumnCallbackDeleteRow.php index df2c244f0b..8367d67b44 100644 --- a/modules/DataTable/Filter/ColumnCallbackDeleteRow.php +++ b/modules/DataTable/Filter/ColumnCallbackDeleteRow.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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. * diff --git a/modules/DataTable/Filter/ColumnCallbackReplace.php b/modules/DataTable/Filter/ColumnCallbackReplace.php index d15dc72b1c..6bdeb73545 100644 --- a/modules/DataTable/Filter/ColumnCallbackReplace.php +++ b/modules/DataTable/Filter/ColumnCallbackReplace.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * Replace a column value with a new value resulting * from the function called with the column's value diff --git a/modules/DataTable/Filter/DetailCallbackAddDetail.php b/modules/DataTable/Filter/DetailCallbackAddDetail.php index d2a6bf0c31..6bd62c65e9 100644 --- a/modules/DataTable/Filter/DetailCallbackAddDetail.php +++ b/modules/DataTable/Filter/DetailCallbackAddDetail.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * Add a new detail to the table based on the value resulting * from a callback function with the parameter being another detail's value diff --git a/modules/DataTable/Filter/Empty.php b/modules/DataTable/Filter/Empty.php index 476e234ed4..e15f74063f 100644 --- a/modules/DataTable/Filter/Empty.php +++ b/modules/DataTable/Filter/Empty.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * Filter template. * You can use it if you want to create a new filter. diff --git a/modules/DataTable/Filter/ExcludeLowPopulation.php b/modules/DataTable/Filter/ExcludeLowPopulation.php index 33117e5a2c..7523bcd293 100644 --- a/modules/DataTable/Filter/ExcludeLowPopulation.php +++ b/modules/DataTable/Filter/ExcludeLowPopulation.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 that have a $columnToFilter value less than the $minimumValue * diff --git a/modules/DataTable/Filter/Limit.php b/modules/DataTable/Filter/Limit.php index 7fcada2096..8dea88945d 100644 --- a/modules/DataTable/Filter/Limit.php +++ b/modules/DataTable/Filter/Limit.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 from the table that are not in the offset,offset+limit range * diff --git a/modules/DataTable/Filter/Pattern.php b/modules/DataTable/Filter/Pattern.php index 5505da98e5..8ffae09c84 100644 --- a/modules/DataTable/Filter/Pattern.php +++ b/modules/DataTable/Filter/Pattern.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 the given $columnToFilter do not contain the $patternToSearch * This filter is to be used on columns containing strings. diff --git a/modules/DataTable/Filter/PatternRecursive.php b/modules/DataTable/Filter/PatternRecursive.php index 50921b12a5..cb875b5326 100644 --- a/modules/DataTable/Filter/PatternRecursive.php +++ b/modules/DataTable/Filter/PatternRecursive.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 * - the given $columnToFilter do not contain the $patternToSearch @@ -40,7 +40,7 @@ class Piwik_DataTable_Filter_PatternRecursive extends Piwik_DataTable_Filter { $table = $this->table; } - $rows = $table->getRows();
+ $rows = $table->getRows(); foreach($rows as $key => $row) { diff --git a/modules/DataTable/Filter/ReplaceColumnNames.php b/modules/DataTable/Filter/ReplaceColumnNames.php index 2b33bc04aa..4296128511 100644 --- a/modules/DataTable/Filter/ReplaceColumnNames.php +++ b/modules/DataTable/Filter/ReplaceColumnNames.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * This filter replaces column names using a mapping table that maps from the old name to the new name. * diff --git a/modules/DataTable/Filter/Sort.php b/modules/DataTable/Filter/Sort.php index be69d05c60..2807d46733 100644 --- a/modules/DataTable/Filter/Sort.php +++ b/modules/DataTable/Filter/Sort.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * Sort the DataTable based on the value of column $columnToSort ordered by $order. * Possible to specify a natural sorting (see php.net/natsort for details) @@ -93,10 +93,10 @@ class Piwik_DataTable_Filter_Sort extends Piwik_DataTable_Filter $value = $row->getColumn($this->columnToSort); if($value === false) - {
- // we don't throw the exception because we sometimes export a DataTable without a column labelled '2'
- // and when the generic filters tries to sort by default using this column 2, this shouldnt raise an exception...
- //throw new Exception("The column to sort by '".$this->columnToSort."' is unknown in the row ". implode(array_keys($row->getColumns()), ','));
+ { + // we don't throw the exception because we sometimes export a DataTable without a column labelled '2' + // and when the generic filters tries to sort by default using this column 2, this shouldnt raise an exception... + //throw new Exception("The column to sort by '".$this->columnToSort."' is unknown in the row ". implode(array_keys($row->getColumns()), ',')); return; } diff --git a/modules/DataTable/Manager.php b/modules/DataTable/Manager.php index 81d1229d01..7f59e831d9 100644 --- a/modules/DataTable/Manager.php +++ b/modules/DataTable/Manager.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * The DataTable_Manager registers all the instanciated DataTable and provides an * easy way to access them. This is used to store all the DataTable during the archiving process. diff --git a/modules/DataTable/Renderer.php b/modules/DataTable/Renderer.php index 12e0c34d2f..5cf6622ae3 100644 --- a/modules/DataTable/Renderer.php +++ b/modules/DataTable/Renderer.php @@ -1,22 +1,22 @@ -<?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
- */
-
+<?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 + */ + /** * A DataTable Renderer can produce an output given a DataTable object. * All new Renderers must be copied in DataTable/Renderer and added to the factory() method. * To use a renderer, simply do: * $render = new Piwik_DataTable_Renderer_Xml( $myTable ); * echo $render; - *
- * @package Piwik_DataTable
+ * + * @package Piwik_DataTable * @subpackage Piwik_DataTable_Renderer */ abstract class Piwik_DataTable_Renderer @@ -70,24 +70,24 @@ abstract class Piwik_DataTable_Renderer /** * Returns the DataTable associated to the output format $name - *
+ * * @throws exception If the renderer is unknown * @return Piwik_DataTable_Renderer */ static public function factory( $name ) { $name = ucfirst(strtolower($name)); - $path = PIWIK_INCLUDE_PATH . "/modules/DataTable/Renderer/".$name.".php";
- $className = 'Piwik_DataTable_Renderer_' . $name;
-
- if( Piwik_Common::isValidFilename($name)
- && is_file($path)
- )
- {
- require_once $path;
- return new $className;
- }
- else
+ $path = PIWIK_INCLUDE_PATH . "/modules/DataTable/Renderer/".$name.".php"; + $className = 'Piwik_DataTable_Renderer_' . $name; + + if( Piwik_Common::isValidFilename($name) + && is_file($path) + ) + { + require_once $path; + return new $className; + } + else { throw new Exception("Renderer format '$name' not valid. Try 'xml' or 'json' or 'csv' or 'html' or 'php' or 'original' instead."); } diff --git a/modules/DataTable/Renderer/Console.php b/modules/DataTable/Renderer/Console.php index b092ef94b9..97d0f114c2 100644 --- a/modules/DataTable/Renderer/Console.php +++ b/modules/DataTable/Renderer/Console.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * Simple output * diff --git a/modules/DataTable/Renderer/Csv.php b/modules/DataTable/Renderer/Csv.php index ea4c7920a1..0e00028904 100644 --- a/modules/DataTable/Renderer/Csv.php +++ b/modules/DataTable/Renderer/Csv.php @@ -1,30 +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$
- *
- * @package Piwik_DataTable
- */
-
-require_once "DataTable/Renderer/Php.php";
+<?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 + */ + +require_once "DataTable/Renderer/Php.php"; /** * CSV export - *
- * When rendered using the default settings, a CSV report has the following characteristics:
- * The first record contains headers for all the columns in the report.
- * All rows have the same number of columns.
- * The default field delimiter string is a comma (,).
- * Formatting and layout are ignored.
+ * + * When rendered using the default settings, a CSV report has the following characteristics: + * The first record contains headers for all the columns in the report. + * All rows have the same number of columns. + * The default field delimiter string is a comma (,). + * Formatting and layout are ignored. * * Note that CSV output doesn't handle recursive dataTable. It will output only the first parent level of the tables. * * @package Piwik_DataTable - * @subpackage Piwik_DataTable_Renderer
+ * @subpackage Piwik_DataTable_Renderer * - */
+ */ class Piwik_DataTable_Renderer_Csv extends Piwik_DataTable_Renderer { diff --git a/modules/DataTable/Renderer/Html.php b/modules/DataTable/Renderer/Html.php index a80230a137..2ef404653c 100644 --- a/modules/DataTable/Renderer/Html.php +++ b/modules/DataTable/Renderer/Html.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * Simple HTML output * Works with recursive DataTable (when a row can be associated with a subDataTable). diff --git a/modules/DataTable/Renderer/Json.php b/modules/DataTable/Renderer/Json.php index 2a91b754e4..158fa8dae8 100644 --- a/modules/DataTable/Renderer/Json.php +++ b/modules/DataTable/Renderer/Json.php @@ -1,15 +1,15 @@ -<?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
- */
-
-require_once "DataTable/Renderer/Php.php";
+<?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 + */ + +require_once "DataTable/Renderer/Php.php"; /** * JSON export. Using the php 5.2 feature json_encode. * Works with recursive DataTable (when a row can be associated with a subDataTable). @@ -37,7 +37,7 @@ class Piwik_DataTable_Renderer_Json extends Piwik_DataTable_Renderer if(!is_array($array)) { $array = array('value' => $array); - }
+ } $str = json_encode($array); return $str; } diff --git a/modules/DataTable/Renderer/Php.php b/modules/DataTable/Renderer/Php.php index 50aa9df284..7d80ed23e4 100644 --- a/modules/DataTable/Renderer/Php.php +++ b/modules/DataTable/Renderer/Php.php @@ -1,18 +1,18 @@ -<?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
- */
-
+<?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 + */ + /** * Returns the equivalent PHP array for a given DataTable. - * You can specify in the constructor if you want the serialized version.
- * Please note that by default it will produce a flat version of the array.
+ * You can specify in the constructor if you want the serialized version. + * Please note that by default it will produce a flat version of the array. * See the method flatRender() for details. @see flatRender(); * * Works with recursive DataTable (when a row can be associated with a subDataTable). @@ -44,23 +44,23 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer } return $data; } -
- /**
- * Produces a flat php array from the DataTable, putting "columns" and "details" on the same level.
- *
- * For example, when a originalRender() would be
- * array( 'columns' => array( 'col1_name' => value1, 'col2_name' => value2 ),
- * 'details' => array( 'detail1_name' => value_detail) )
- *
- * a flatRender() is
- * array( 'col1_name' => value1,
- * 'col2_name' => value2,
- * 'detail1_name' => value_detail )
- *
- * @return array Php array representing the 'flat' version of the datatable
- *
- */
- public function flatRender( $dataTable = null, $doRenderSubTablesIfAvailable = true )
+ + /** + * Produces a flat php array from the DataTable, putting "columns" and "details" on the same level. + * + * For example, when a originalRender() would be + * array( 'columns' => array( 'col1_name' => value1, 'col2_name' => value2 ), + * 'details' => array( 'detail1_name' => value_detail) ) + * + * a flatRender() is + * array( 'col1_name' => value1, + * 'col2_name' => value2, + * 'detail1_name' => value_detail ) + * + * @return array Php array representing the 'flat' version of the datatable + * + */ + public function flatRender( $dataTable = null, $doRenderSubTablesIfAvailable = true ) { if(is_null($dataTable)) { @@ -78,10 +78,10 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer $this->serialize = $serializeSave; } } -
- // A DataTable_Simple is already flattened so no need to do some crazy stuff to convert it
- else if($dataTable instanceof Piwik_DataTable_Simple)
- {
+ + // A DataTable_Simple is already flattened so no need to do some crazy stuff to convert it + else if($dataTable instanceof Piwik_DataTable_Simple) + { $flatArray = $this->renderSimpleTable($dataTable); // if we return only one numeric value then we print out the result in a simple <result> tag @@ -90,22 +90,22 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer { $flatArray = current($flatArray); } -
- }
- // A normal DataTable needs to be handled specifically
- else
- {
+ + } + // A normal DataTable needs to be handled specifically + else + { $array = $this->renderTable($dataTable, $doRenderSubTablesIfAvailable); - $flatArray = $this->flattenArray($array);
- }
-
- if($this->serialize)
- {
- $flatArray = serialize($flatArray);
- }
-
- return $flatArray;
- }
+ $flatArray = $this->flattenArray($array); + } + + if($this->serialize) + { + $flatArray = serialize($flatArray); + } + + return $flatArray; + } protected function flattenArray($array) { @@ -124,13 +124,13 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer $flatArray[] = $newRow; } return $flatArray; - }
- public function render( $dataTable = null)
+ } + public function render( $dataTable = null) { if(is_null($dataTable)) { $dataTable = $this->table; - }
+ } $toReturn = $this->flatRender( $dataTable ); if( false !== Piwik_Common::getRequestVar('prettyDisplay', false) ) @@ -140,9 +140,9 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer $toReturn = unserialize($toReturn); } $toReturn = "<pre>" . var_export($toReturn, true ) . "</pre>"; - }
- return $toReturn;
- }
+ } + return $toReturn; + } public function originalRender() { @@ -162,7 +162,7 @@ class Piwik_DataTable_Renderer_Php extends Piwik_DataTable_Renderer return $array; } -
+ protected function renderTable($table, $doRenderSubTablesIfAvailable = true) { diff --git a/modules/DataTable/Renderer/Xml.php b/modules/DataTable/Renderer/Xml.php index ec6f6cff06..1792b33261 100644 --- a/modules/DataTable/Renderer/Xml.php +++ b/modules/DataTable/Renderer/Xml.php @@ -1,15 +1,15 @@ -<?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
- */
-
-require_once "DataTable/Renderer/Php.php";
+<?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 + */ + +require_once "DataTable/Renderer/Php.php"; /** * XML export of a given DataTable. * See the tests cases for more information about the XML format (/tests/modules/DataTable/Renderer.test.php) diff --git a/modules/DataTable/Row.php b/modules/DataTable/Row.php index 329d8600ab..11c110f254 100644 --- a/modules/DataTable/Row.php +++ b/modules/DataTable/Row.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * A DataTable is composed of rows. * @@ -21,8 +21,8 @@ * IMPORTANT: Make sure that the column named 'label' contains at least one non-numeric character. * Otherwise the method addDataTable() or sumRow() would fail because they would consider * the 'label' as being a numeric column to sum. - *
- * @package Piwik_DataTable
+ * + * @package Piwik_DataTable * @subpackage Piwik_DataTable_Row * */ @@ -99,28 +99,28 @@ class Piwik_DataTable_Row * Applys a basic rendering to the Row and returns the output * * @return string characterizing the row. Example: - 1 ['label' => 'piwik', 'nb_uniq_visitors' => 1685, 'nb_visits' => 1861, 'nb_actions' => 2271, 'max_actions' => 13, 'sum_visit_length' => 920131, 'bounce_count' => 1599] [] [idsubtable = 1375] - */
- public function __toString()
- {
- $columns = array();
- foreach($this->getColumns() as $column => $value)
- {
- if(is_string($value)) $value = "'$value'";
- $columns[] = "'$column' => $value";
- }
- $columns = implode(", ", $columns);
- $details=array();
-
- foreach($this->getDetails() as $detail => $value)
- {
- if(is_string($value)) $value = "'$value'";
- $details[] = "'$detail' => $value";
- }
- $details = implode(", ", $details);
- $output = "# [".$columns."] [".$details."] [idsubtable = "
- . $this->getIdSubDataTable()."]<br>\n";
- return $output;
- }
+ */ + public function __toString() + { + $columns = array(); + foreach($this->getColumns() as $column => $value) + { + if(is_string($value)) $value = "'$value'"; + $columns[] = "'$column' => $value"; + } + $columns = implode(", ", $columns); + $details=array(); + + foreach($this->getDetails() as $detail => $value) + { + if(is_string($value)) $value = "'$value'"; + $details[] = "'$detail' => $value"; + } + $details = implode(", ", $details); + $output = "# [".$columns."] [".$details."] [idsubtable = " + . $this->getIdSubDataTable()."]<br>\n"; + return $output; + } /** * Deletes the given column diff --git a/modules/DataTable/Row/DataTableSummary.php b/modules/DataTable/Row/DataTableSummary.php index 8f34a79655..011014bd1b 100644 --- a/modules/DataTable/Row/DataTableSummary.php +++ b/modules/DataTable/Row/DataTableSummary.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * This class creates a row from a given DataTable. * The row contains diff --git a/modules/DataTable/Simple.php b/modules/DataTable/Simple.php index d369d48fe0..08e5d0f0d0 100644 --- a/modules/DataTable/Simple.php +++ b/modules/DataTable/Simple.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * The DataTable_Simple is used to provide an easy way to create simple DataGrid. * A DataTable_Simple actually is a DataTable with 2 columns: 'label' and 'value'. diff --git a/modules/Date.php b/modules/Date.php index d455350188..2a54c13c51 100644 --- a/modules/Date.php +++ b/modules/Date.php @@ -1,18 +1,18 @@ -<?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_Helper
- */
-
+<?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_Helper + */ + /** * Date object widely used in Piwik. - *
- * //TODO remove factory OR constructor! cant have both
+ * + * //TODO remove factory OR constructor! cant have both * @package Piwik_Helper */ class Piwik_Date @@ -215,7 +215,7 @@ class Piwik_Date return $this->getTimestamp(); } return date($part, $this->getTimestamp()); - }
+ } /** * Adds days to the existing date object. diff --git a/modules/ErrorHandler.php b/modules/ErrorHandler.php index 9859791651..fdd3b63380 100755 --- a/modules/ErrorHandler.php +++ b/modules/ErrorHandler.php @@ -1,23 +1,23 @@ -<?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_Helper
- */
+<?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_Helper + */ require_once "Zend/Registry.php"; if(!defined('E_STRICT')) define('E_STRICT', 2048); if(!defined('E_RECOVERABLE_ERROR')) define('E_RECOVERABLE_ERROR', 4096); if(!defined('E_EXCEPTION')) define('E_EXCEPTION', 8192); -
+ /** - * Error handler used to display nicely errors in Piwik
- *
+ * Error handler used to display nicely errors in Piwik + * * @package Piwik_Helper */ function Piwik_ErrorHandler($errno, $errstr, $errfile, $errline) diff --git a/modules/ExceptionHandler.php b/modules/ExceptionHandler.php index edfb684f42..7cebb85908 100644 --- a/modules/ExceptionHandler.php +++ b/modules/ExceptionHandler.php @@ -1,19 +1,19 @@ -<?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_Helper
- */
+<?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_Helper + */ require_once "modules/Piwik.php"; -
+ /** - * Exception handler used to display nicely exceptions in Piwik
- *
+ * Exception handler used to display nicely exceptions in Piwik + * * @package Piwik_Helper */ function Piwik_ExceptionHandler(Exception $exception) diff --git a/modules/Form.php b/modules/Form.php index 2a82abe7c7..de7f85220d 100644 --- a/modules/Form.php +++ b/modules/Form.php @@ -1,24 +1,24 @@ -<?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_Helper
- */
-
+<?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_Helper + */ + require_once "HTML/QuickForm.php"; require_once "HTML/QuickForm/Renderer/ArraySmarty.php"; -
-/**
+ +/** * Parent class for forms to be included in Smarty * * For an example, @see Piwik_Login_Form - *
- * @package Piwik_Helper
+ * + * @package Piwik_Helper */ abstract class Piwik_Form extends HTML_QuickForm { diff --git a/modules/Log.php b/modules/Log.php index f5ebd037e3..c6abaf6c5c 100755 --- a/modules/Log.php +++ b/modules/Log.php @@ -1,13 +1,13 @@ -<?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_Log
- */
+<?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_Log + */ Zend_Loader::loadClass('Zend_Log'); Zend_Loader::loadClass('Zend_Log_Formatter_Interface'); @@ -15,11 +15,11 @@ Zend_Loader::loadClass('Zend_Log_Writer_Stream'); Zend_Loader::loadClass('Zend_Log_Writer_Db'); Zend_Loader::loadClass('Piwik_Common'); -
-/**
- *
- *
- * @package Piwik_Log
+ +/** + * + * + * @package Piwik_Log */ abstract class Piwik_Log extends Zend_Log { @@ -116,11 +116,11 @@ abstract class Piwik_Log extends Zend_Log } } -
-/**
- *
- *
- * @package Piwik_Log
+ +/** + * + * + * @package Piwik_Log */ class Piwik_Log_Formatter_FileFormatter implements Zend_Log_Formatter_Interface { diff --git a/modules/Log/APICall.php b/modules/Log/APICall.php index a14df78221..a4d4c1a754 100644 --- a/modules/Log/APICall.php +++ b/modules/Log/APICall.php @@ -1,15 +1,15 @@ -<?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_Log
- * @subpackage Piwik_Log_APICall
- */
-
+<?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_Log + * @subpackage Piwik_Log_APICall + */ + /** * Class used to log all the API Calls information (class / method / parameters / returned value / time spent) * diff --git a/modules/Log/Error.php b/modules/Log/Error.php index f4346efe1f..af018a8ade 100644 --- a/modules/Log/Error.php +++ b/modules/Log/Error.php @@ -1,15 +1,15 @@ -<?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_Log
- * @subpackage Piwik_Log_Error
- */
-
+<?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_Log + * @subpackage Piwik_Log_Error + */ + /** * Class used to log an error event. * diff --git a/modules/Log/Exception.php b/modules/Log/Exception.php index e5a47e827f..a08dc92f28 100644 --- a/modules/Log/Exception.php +++ b/modules/Log/Exception.php @@ -1,16 +1,16 @@ -<?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_Log
- * @subpackage Piwik_Log_Exception
- */
+<?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_Log + * @subpackage Piwik_Log_Exception + */ require_once "Log.php"; -
+ /** * Class used to log an exception event. * Displays the exception with a user friendly error message, suggests to get support from piwik.org diff --git a/modules/Log/Message.php b/modules/Log/Message.php index 07f19c442a..96cfd308a4 100644 --- a/modules/Log/Message.php +++ b/modules/Log/Message.php @@ -1,15 +1,15 @@ -<?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_Log
- * @subpackage Piwik_Log_Message
- */
-
+<?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_Log + * @subpackage Piwik_Log_Message + */ + /** * Class used to log a standard message event. * diff --git a/modules/LogStats.php b/modules/LogStats.php index db124735b3..4cf63ebbef 100644 --- a/modules/LogStats.php +++ b/modules/LogStats.php @@ -1,14 +1,14 @@ -<?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_LogStats
- */
-
+<?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_LogStats + */ + /** * Class used by the logging script piwik.php called by the javascript tag. * Handles the visitor & his/her actions on the website, saves the data in the DB, saves information in the cookie, etc. @@ -38,9 +38,9 @@ * We could also imagine a batch system that would read a log file every 5min, * and which prepares the file containg the rows to insert, then we load DATA INFILE * - *
- * Configuration options for the statsLogEngine module:
- * - use_cookie ; defines if we try to get/set a cookie to help recognize a unique visitor
+ * + * Configuration options for the statsLogEngine module: + * - use_cookie ; defines if we try to get/set a cookie to help recognize a unique visitor * * @package Piwik_LogStats */ diff --git a/modules/LogStats/Config.php b/modules/LogStats/Config.php index fc53b58b2e..a81a78e83d 100644 --- a/modules/LogStats/Config.php +++ b/modules/LogStats/Config.php @@ -1,14 +1,14 @@ -<?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_LogStats
- */
-
+<?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_LogStats + */ + /** * Simple class to access the configuration file * diff --git a/modules/LogStats/Generator.php b/modules/LogStats/Generator.php index 13c90a8e70..1ca8b8cec7 100644 --- a/modules/LogStats/Generator.php +++ b/modules/LogStats/Generator.php @@ -1,13 +1,13 @@ -<?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_LogStats
- */
+<?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_LogStats + */ /** * Class used to generate fake visits. diff --git a/modules/LogStats/Visit.php b/modules/LogStats/Visit.php index 8fa9ce43ce..475cdce845 100644 --- a/modules/LogStats/Visit.php +++ b/modules/LogStats/Visit.php @@ -1,14 +1,14 @@ -<?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_LogStats
- */
-
+<?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_LogStats + */ + /** * Class used to handle a Visit. * A visit is either NEW or KNOWN. @@ -27,8 +27,8 @@ class Piwik_LogStats_Visit { protected $cookieLog = null; protected $visitorInfo = array(); - protected $userSettingsInformation = null;
-
+ protected $userSettingsInformation = null; + function __construct( $db ) { @@ -584,34 +584,34 @@ class Piwik_LogStats_Visit */ private function getRefererInformation() { - // default values for the referer_* fields
+ // default values for the referer_* fields $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_DIRECT_ENTRY; $this->nameRefererAnalyzed = ''; - $this->keywordRefererAnalyzed = '';
-
+ $this->keywordRefererAnalyzed = ''; + // get the urls and parse them $refererUrl = Piwik_Common::getRequestVar( 'urlref', '', 'string'); $currentUrl = Piwik_Common::getRequestVar( 'url', '', 'string'); $this->refererUrlParse = @parse_url($refererUrl); $this->currentUrlParse = @parse_url($currentUrl); -
- // if we have a referer available we try to detect something interesting
+ + // if we have a referer available we try to detect something interesting // otherwise it's defaulted to "the visitor is a direct entry" if( !empty($this->refererUrlParse['host']) ) { $this->refererHost = $this->refererUrlParse['host']; - if( !$this->detectRefererSearchEngine()
- && !$this->detectRefererNewsletter()
- && !$this->detectRefererPartner()
- && !$this->detectRefererCampaign()
- && !$this->detectRefererDirectEntry()
- )
- {
- // Normal website referer
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_WEBSITE;
- $this->nameRefererAnalyzed = $this->refererHost;
+ if( !$this->detectRefererSearchEngine() + && !$this->detectRefererNewsletter() + && !$this->detectRefererPartner() + && !$this->detectRefererCampaign() + && !$this->detectRefererDirectEntry() + ) + { + // Normal website referer + $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_WEBSITE; + $this->nameRefererAnalyzed = $this->refererHost; } } @@ -624,153 +624,153 @@ class Piwik_LogStats_Visit return $refererInformation; } -
- /*
- * Search engine detection
- */
- private function detectRefererSearchEngine()
- {
- /*
- * A referer is a search engine if the URL's host is in the SearchEngines array
- * and if we found the keyword in the URL.
- *
- * For example if someone comes from http://www.google.com/partners.html this will not
- * be counted as a search engines, but as a website referer from google.com (because the
- * keyword couldn't be found in the URL)
- */
- require PIWIK_DATAFILES_INCLUDE_PATH . "/SearchEngines.php";
-
- if(array_key_exists($this->refererHost, $GLOBALS['Piwik_SearchEngines']))
- {
- // which search engine ?
- $searchEngineName = $GLOBALS['Piwik_SearchEngines'][$this->refererHost][0];
- $variableName = $GLOBALS['Piwik_SearchEngines'][$this->refererHost][1];
-
- // if there is a query, there may be a keyword...
- if(isset($this->refererUrlParse['query']))
- {
- $query = $this->refererUrlParse['query'];
-
- // search for keywords now &vname=keyword
- $key = trim(strtolower(Piwik_Common::getParameterFromQueryString($query, $variableName)));
-
- if((function_exists('iconv'))
- && (isset($GLOBALS['Piwik_SearchEngines'][$this->refererHost][2])))
- {
- $charset = trim($GLOBALS['Piwik_SearchEngines'][$this->refererHost][2]);
-
- if(!empty($charset))
- {
- $key = htmlspecialchars(
- @iconv( $charset,
+ + /* + * Search engine detection + */ + private function detectRefererSearchEngine() + { + /* + * A referer is a search engine if the URL's host is in the SearchEngines array + * and if we found the keyword in the URL. + * + * For example if someone comes from http://www.google.com/partners.html this will not + * be counted as a search engines, but as a website referer from google.com (because the + * keyword couldn't be found in the URL) + */ + require PIWIK_DATAFILES_INCLUDE_PATH . "/SearchEngines.php"; + + if(array_key_exists($this->refererHost, $GLOBALS['Piwik_SearchEngines'])) + { + // which search engine ? + $searchEngineName = $GLOBALS['Piwik_SearchEngines'][$this->refererHost][0]; + $variableName = $GLOBALS['Piwik_SearchEngines'][$this->refererHost][1]; + + // if there is a query, there may be a keyword... + if(isset($this->refererUrlParse['query'])) + { + $query = $this->refererUrlParse['query']; + + // search for keywords now &vname=keyword + $key = trim(strtolower(Piwik_Common::getParameterFromQueryString($query, $variableName))); + + if((function_exists('iconv')) + && (isset($GLOBALS['Piwik_SearchEngines'][$this->refererHost][2]))) + { + $charset = trim($GLOBALS['Piwik_SearchEngines'][$this->refererHost][2]); + + if(!empty($charset)) + { + $key = htmlspecialchars( + @iconv( $charset, 'utf-8//TRANSLIT', - //TODO testthis fnction exists!! use upgrade.php
- htmlspecialchars_decode($key, Piwik_Common::HTML_ENCODING_QUOTE_STYLE))
- , Piwik_Common::HTML_ENCODING_QUOTE_STYLE);
- }
- }
-
-
- if(!empty($key))
- {
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_SEARCH_ENGINE;
- $this->nameRefererAnalyzed = $searchEngineName;
- $this->keywordRefererAnalyzed = $key;
-
- return true;
- }
- }
- }
- }
-
- /*
- * Newsletter analysis
- */
- private function detectRefererNewsletter()
- {
- if(isset($this->currentUrlParse['query']))
- {
- $newsletterVariableName = Piwik_LogStats_Config::getInstance()->LogStats['newsletter_var_name'];
- $newsletterVar = Piwik_Common::getParameterFromQueryString( $this->currentUrlParse['query'], $newsletterVariableName);
-
- if(!empty($newsletterVar))
- {
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_NEWSLETTER;
- $this->nameRefererAnalyzed = $newsletterVar;
-
- return true;
- }
- }
- }
-
- /*
- * Partner analysis
- */
- private function detectRefererPartner()
- {
- if(isset($this->currentUrlParse['query']))
- {
- $partnerVariableName = Piwik_LogStats_Config::getInstance()->LogStats['partner_var_name'];
- $partnerVar = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $partnerVariableName);
-
- if(!empty($partnerVar))
- {
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_PARTNER;
- $this->nameRefererAnalyzed = $partnerVar;
-
- return true;
- }
- }
- }
-
- /*
- * Campaign analysis
- */
- private function detectRefererCampaign()
- {
- if(isset($this->currentUrlParse['query']))
- {
- $campaignVariableName = Piwik_LogStats_Config::getInstance()->LogStats['campaign_var_name'];
- $campaignName = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignVariableName);
-
- if( !empty($campaignName))
- {
- $campaignKeywordVariableName = Piwik_LogStats_Config::getInstance()->LogStats['campaign_keyword_var_name'];
- $campaignKeyword = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignKeywordVariableName);
-
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_CAMPAIGN;
- $this->nameRefererAnalyzed = $campaignName;
-
- if(!empty($campaignKeyword))
- {
- $this->keywordRefererAnalyzed = $campaignKeyword;
- }
-
- return true;
- }
- }
- }
-
- /*
- * Direct entry (referer host is similar to current host)
- * And we have previously tried to detect the newsletter/partner/campaign variables in the URL
- * so it can only be a direct access
- */
-
- private function detectRefererDirectEntry()
- {
- if(isset($this->currentUrlParse['host']))
- {
- $currentHost = $this->currentUrlParse['host'];
-
- if($currentHost == $this->refererHost)
- {
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_DIRECT_ENTRY;
-
- return true;
- }
- }
-
+ //TODO testthis fnction exists!! use upgrade.php + htmlspecialchars_decode($key, Piwik_Common::HTML_ENCODING_QUOTE_STYLE)) + , Piwik_Common::HTML_ENCODING_QUOTE_STYLE); + } + } + + + if(!empty($key)) + { + $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_SEARCH_ENGINE; + $this->nameRefererAnalyzed = $searchEngineName; + $this->keywordRefererAnalyzed = $key; + + return true; + } + } + } + } + + /* + * Newsletter analysis + */ + private function detectRefererNewsletter() + { + if(isset($this->currentUrlParse['query'])) + { + $newsletterVariableName = Piwik_LogStats_Config::getInstance()->LogStats['newsletter_var_name']; + $newsletterVar = Piwik_Common::getParameterFromQueryString( $this->currentUrlParse['query'], $newsletterVariableName); + + if(!empty($newsletterVar)) + { + $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_NEWSLETTER; + $this->nameRefererAnalyzed = $newsletterVar; + + return true; + } + } + } + + /* + * Partner analysis + */ + private function detectRefererPartner() + { + if(isset($this->currentUrlParse['query'])) + { + $partnerVariableName = Piwik_LogStats_Config::getInstance()->LogStats['partner_var_name']; + $partnerVar = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $partnerVariableName); + + if(!empty($partnerVar)) + { + $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_PARTNER; + $this->nameRefererAnalyzed = $partnerVar; + + return true; + } + } + } + + /* + * Campaign analysis + */ + private function detectRefererCampaign() + { + if(isset($this->currentUrlParse['query'])) + { + $campaignVariableName = Piwik_LogStats_Config::getInstance()->LogStats['campaign_var_name']; + $campaignName = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignVariableName); + + if( !empty($campaignName)) + { + $campaignKeywordVariableName = Piwik_LogStats_Config::getInstance()->LogStats['campaign_keyword_var_name']; + $campaignKeyword = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignKeywordVariableName); + + $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_CAMPAIGN; + $this->nameRefererAnalyzed = $campaignName; + + if(!empty($campaignKeyword)) + { + $this->keywordRefererAnalyzed = $campaignKeyword; + } + + return true; + } + } + } + + /* + * Direct entry (referer host is similar to current host) + * And we have previously tried to detect the newsletter/partner/campaign variables in the URL + * so it can only be a direct access + */ + + private function detectRefererDirectEntry() + { + if(isset($this->currentUrlParse['host'])) + { + $currentHost = $this->currentUrlParse['host']; + + if($currentHost == $this->refererHost) + { + $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_DIRECT_ENTRY; + + return true; + } + } + } /** * Returns a MD5 of all the configuration settings diff --git a/modules/Period.php b/modules/Period.php index 90d94bb707..f967aa0ff1 100644 --- a/modules/Period.php +++ b/modules/Period.php @@ -1,14 +1,14 @@ -<?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_Helper
- */
-
+<?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_Helper + */ + /** * Creating a new Piwik_Period subclass: * @@ -19,8 +19,8 @@ * } * that checks whether the subperiods have already been computed. * This is for performance improvements, computing the subperiods is done a per demand basis. - *
- *
+ * + * * @package Piwik_Helper */ abstract class Piwik_Period @@ -60,11 +60,11 @@ abstract class Piwik_Period break; } } -
- /**
- * Returns the first day of the period
- *
- * @return Piwik_Date First day of the period
+ + /** + * Returns the first day of the period + * + * @return Piwik_Date First day of the period */ public function getDateStart() { @@ -85,11 +85,11 @@ abstract class Piwik_Period } return $currentPeriod->getDate(); } -
- /**
- * Returns the last day of the period ; can be a date in the future
- *
- * @return Piwik_Date Last day of the period
+ + /** + * Returns the last day of the period ; can be a date in the future + * + * @return Piwik_Date Last day of the period */ public function getDateEnd() { @@ -114,7 +114,7 @@ abstract class Piwik_Period public function getId() { return Piwik::$idPeriods[$this->getLabel()]; - }
+ } public function getLabel() { @@ -124,11 +124,11 @@ abstract class Piwik_Period /** * * @return Piwik_Date - */
- protected function getDate()
- {
- return $this->date;
- }
+ */ + protected function getDate() + { + return $this->date; + } protected function checkInputDate($date) { @@ -380,10 +380,10 @@ class Piwik_Period_Range extends Piwik_Period return $range; } } -
-/**
- *
- * @package Piwik_Period
+ +/** + * + * @package Piwik_Period */ class Piwik_Period_Day extends Piwik_Period { @@ -425,10 +425,10 @@ class Piwik_Period_Day extends Piwik_Period } -
-/**
- *
- * @package Piwik_Period
+ +/** + * + * @package Piwik_Period */ class Piwik_Period_Week extends Piwik_Period { @@ -468,10 +468,10 @@ class Piwik_Period_Week extends Piwik_Period } } -
-/**
- *
- * @package Piwik_Period
+ +/** + * + * @package Piwik_Period */ class Piwik_Period_Month extends Piwik_Period { @@ -518,11 +518,11 @@ class Piwik_Period_Month extends Piwik_Period return ( date("m") > $this->date->get("m") && date("Y") == $year) || date("Y") > $year; } -}
-
-/**
- *
- * @package Piwik_Period
+} + +/** + * + * @package Piwik_Period */ class Piwik_Period_Year extends Piwik_Period { diff --git a/modules/Piwik.php b/modules/Piwik.php index 2bf043a301..8a21d2ab59 100755 --- a/modules/Piwik.php +++ b/modules/Piwik.php @@ -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
- */
+<?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 + */ require_once "Config.php"; require_once "Zend/Db.php"; require_once "Zend/Db/Table.php"; require_once "Log.php"; require_once "PluginsManager.php"; -
-/**
+ +/** * Main piwik helper class. * Contains static functions you can call from the plugins. - *
- * @package Piwik
+ * + * @package Piwik */ class Piwik { @@ -107,17 +107,17 @@ class Piwik return $resultCheck; } - static public function getJavascriptCode($idSite, $piwikUrl, $actionName = "''")
- {
- $jsTag = file_get_contents( PIWIK_INCLUDE_PATH . "/modules/LogStats/javascriptTag.tpl");
- $jsTag = nl2br(htmlentities($jsTag));
- $jsTag = str_replace('{$actionName}', $actionName, $jsTag);
- $jsTag = str_replace('{$idSite}', $idSite, $jsTag);
+ static public function getJavascriptCode($idSite, $piwikUrl, $actionName = "''") + { + $jsTag = file_get_contents( PIWIK_INCLUDE_PATH . "/modules/LogStats/javascriptTag.tpl"); + $jsTag = nl2br(htmlentities($jsTag)); + $jsTag = str_replace('{$actionName}', $actionName, $jsTag); + $jsTag = str_replace('{$idSite}', $idSite, $jsTag); $jsTag = str_replace('{$piwikUrl}', $piwikUrl, $jsTag); $jsTag = str_replace('{$hrefTitle}', Piwik::getRandomTitle(), $jsTag); -
- return $jsTag;
- }
+ + return $jsTag; + } static public function getMemoryLimitValue() { @@ -177,15 +177,15 @@ class Piwik ); exit; } -
- /**
- * Computes the division of i1 by i2. If either i1 or i2 are not number, or if i2 has a value of zero
- * we return 0 to avoid the division by zero.
- *
- * @param numeric $i1
- * @param numeric $i2
- * @return numeric The result of the division or zero
- */
+ + /** + * Computes the division of i1 by i2. If either i1 or i2 are not number, or if i2 has a value of zero + * we return 0 to avoid the division by zero. + * + * @param numeric $i1 + * @param numeric $i2 + * @return numeric The result of the division or zero + */ static public function secureDiv( $i1, $i2 ) { if ( is_numeric($i1) && is_numeric($i2) && floatval($i2) != 0) @@ -737,8 +737,8 @@ class Piwik // at this point we have only the piwik tables which is good // but we still miss the piwik generated tables (using the class Piwik_TablePartitioning) - $allArchiveNumeric = $db->fetchCol("SHOW TABLES LIKE '".$prefixTables."archive_numeric%'");
- $allArchiveBlob = $db->fetchCol("SHOW TABLES LIKE '".$prefixTables."archive_blob%'");
+ $allArchiveNumeric = $db->fetchCol("SHOW TABLES LIKE '".$prefixTables."archive_numeric%'"); + $allArchiveBlob = $db->fetchCol("SHOW TABLES LIKE '".$prefixTables."archive_blob%'"); $allTablesReallyInstalled = array_merge($tablesInstalled, $allArchiveNumeric, $allArchiveBlob); @@ -849,8 +849,8 @@ class Piwik } Zend_Registry::set($loggerType, $logger); } - }
-
+ } + static public function createConfigObject( $pathConfigFile = null ) { @@ -887,21 +887,21 @@ class Piwik static public function isValidEmailString( $email ) { return (preg_match('/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9_.-]+\.[a-zA-Z]{2,4}$/', $email) > 0); - }
-
- /**
- * Creates an entry in the User table for the "anonymous" user.
- *
- * @return void
+ } + + /** + * Creates an entry in the User table for the "anonymous" user. + * + * @return void */ - static public function createAnonymousUser()
- {
- // The anonymous user is the user that is assigned by default
- // note that the token_auth value is anonymous, which is assigned by default as well in the Login plugin
- $db = Zend_Registry::get('db');
- $db->query("INSERT INTO ". Piwik::prefixTable("user") . "
- VALUES ( 'anonymous', '', 'anonymous', 'anonymous@example.org', 'anonymous', CURRENT_TIMESTAMP );" );
- }
+ static public function createAnonymousUser() + { + // The anonymous user is the user that is assigned by default + // note that the token_auth value is anonymous, which is assigned by default as well in the Login plugin + $db = Zend_Registry::get('db'); + $db->query("INSERT INTO ". Piwik::prefixTable("user") . " + VALUES ( 'anonymous', '', 'anonymous', 'anonymous@example.org', 'anonymous', CURRENT_TIMESTAMP );" ); + } static public function createTablesIndex() { diff --git a/modules/Plugin.php b/modules/Plugin.php index 2d65794598..8b44be2864 100644 --- a/modules/Plugin.php +++ b/modules/Plugin.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * Abstract class to define a Piwik_Plugin. @@ -63,15 +63,15 @@ abstract class Piwik_Plugin * Returns the plugin details */ abstract function getInformation(); -
- /**
- * Returns the plugin name
- */
- public function getName()
- {
- $info = $this->getInformation();
- return $info['name'];
- }
+ + /** + * Returns the plugin name + */ + public function getName() + { + $info = $this->getInformation(); + return $info['name']; + } /** * Returns the list of hooks registered with the methods names diff --git a/modules/PluginsManager.php b/modules/PluginsManager.php index f7bbc87cf6..7dcbe6ca02 100644 --- a/modules/PluginsManager.php +++ b/modules/PluginsManager.php @@ -1,41 +1,41 @@ -<?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
- */
-
+<?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 + */ + require_once "Plugin.php"; require_once "Event/Dispatcher.php"; -
-/**
- * Plugin specification for a statistics logging plugin
- *
- * A plugin that display data in the Piwik Interface is very different from a plugin
- * that will save additional data in the database during the statistics logging.
- * These two types of plugins don't have the same requirements at all. Therefore a plugin
- * that saves additional data in the database during the stats logging process will have a different
- * structure.
- *
- * A plugin for logging data has to focus on performance and therefore has to stay as simple as possible.
- * For input data, it is strongly advised to use the Piwik methods available in Piwik_Common
- *
- * Things that can be done with such a plugin:
- * - having a dependency with a list of other plugins
- * - have an install step that would prepare the plugin environment
- * - install could add columns to the tables
- * - install could create tables
- * - register to hooks at several points in the logging process
- * - register to hooks in other plugins
- * - generally a plugin method can modify data (filter) and add/remove data
- *
- *
- * @package Piwik
+ +/** + * Plugin specification for a statistics logging plugin + * + * A plugin that display data in the Piwik Interface is very different from a plugin + * that will save additional data in the database during the statistics logging. + * These two types of plugins don't have the same requirements at all. Therefore a plugin + * that saves additional data in the database during the stats logging process will have a different + * structure. + * + * A plugin for logging data has to focus on performance and therefore has to stay as simple as possible. + * For input data, it is strongly advised to use the Piwik methods available in Piwik_Common + * + * Things that can be done with such a plugin: + * - having a dependency with a list of other plugins + * - have an install step that would prepare the plugin environment + * - install could add columns to the tables + * - install could create tables + * - register to hooks at several points in the logging process + * - register to hooks in other plugins + * - generally a plugin method can modify data (filter) and add/remove data + * + * + * @package Piwik */ class Piwik_PluginsManager { @@ -413,14 +413,14 @@ class Piwik_PluginsManager } } unset($this->loadedPlugins[$plugin->getName()]); - }
- public function unloadPlugins()
- {
- $pluginsLoaded = $this->getLoadedPlugins();
- foreach($pluginsLoaded as $plugin)
- {
- $this->unloadPlugin($plugin);
- }
+ } + public function unloadPlugins() + { + $pluginsLoaded = $this->getLoadedPlugins(); + foreach($pluginsLoaded as $plugin) + { + $this->unloadPlugin($plugin); + } } } diff --git a/modules/Site.php b/modules/Site.php index e82abc335a..791e1e42d6 100644 --- a/modules/Site.php +++ b/modules/Site.php @@ -1,14 +1,14 @@ -<?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_Site
- */
-
+<?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_Site + */ + /** * * @package Piwik_Site diff --git a/modules/SmartyPlugins/function.url.php b/modules/SmartyPlugins/function.url.php index 0ec8c63829..b4bce46934 100644 --- a/modules/SmartyPlugins/function.url.php +++ b/modules/SmartyPlugins/function.url.php @@ -1,13 +1,13 @@ -<?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 SmartyPlugins
- */
+<?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 SmartyPlugins + */ require_once "Url.php"; @@ -17,11 +17,11 @@ require_once "Url.php"; * * Examples: * <pre> - * {url module="API"} will rewrite the URL modifying the module GET parameter
- * {url module="API" method="getKeywords"} will rewrite the URL modifying the parameters module=API method=getKeywords
- * </pre>
- *
- * @see Piwik_Url::getCurrentQueryStringWithParametersModified()
+ * {url module="API"} will rewrite the URL modifying the module GET parameter + * {url module="API" method="getKeywords"} will rewrite the URL modifying the parameters module=API method=getKeywords + * </pre> + * + * @see Piwik_Url::getCurrentQueryStringWithParametersModified() * @param $name=$value of the parameters to modify in the generated URL * @return string Something like index.php?module=X&action=Y */ diff --git a/modules/SmartyPlugins/modifier.sumtime.php b/modules/SmartyPlugins/modifier.sumtime.php index 3126946cdc..49a55d69de 100644 --- a/modules/SmartyPlugins/modifier.sumtime.php +++ b/modules/SmartyPlugins/modifier.sumtime.php @@ -1,13 +1,13 @@ -<?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 SmartyPlugins
- */
+<?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 SmartyPlugins + */ /** * Returns a string that displays the number of days and hours from a number of seconds diff --git a/modules/Timer.php b/modules/Timer.php index fa0ad4d044..0bbc4bf323 100644 --- a/modules/Timer.php +++ b/modules/Timer.php @@ -1,16 +1,16 @@ -<?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_Helper
- */
-
+<?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_Helper + */ + +/** + * * @package Piwik_Helper */ class Piwik_Timer diff --git a/modules/Translate.php b/modules/Translate.php index 65abd385c9..9bb5400a3a 100644 --- a/modules/Translate.php +++ b/modules/Translate.php @@ -1,14 +1,14 @@ -<?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
- */
-
+<?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 + */ + /** * * @package Piwik @@ -49,24 +49,24 @@ class Piwik_Translate // we could check that no string overlap here $GLOBALS['Piwik_translations'] = array_merge($GLOBALS['Piwik_translations'], $translation); } -
- /**
- * Enter description here...
- *
+ + /** + * Enter description here... + * * @return string the language filename prefix, eg "en" for english - * @throws exception if the language set in the config file is not a valid filename
+ * @throws exception if the language set in the config file is not a valid filename */ public function getLanguageToLoad() { $language = Zend_Registry::get('config')->Language->current; -
+ if( Piwik_Common::isValidFilename($language)) { - return $language;
- }
- else
- {
- throw new Exception("The language selected ('$language') is not a valid language file ");
+ return $language; + } + else + { + throw new Exception("The language selected ('$language') is not a valid language file "); } } } diff --git a/modules/Url.php b/modules/Url.php index 0fe28761ac..8667c6283f 100644 --- a/modules/Url.php +++ b/modules/Url.php @@ -1,18 +1,18 @@ -<?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_Helper
- */
-
-/**
- * @package Piwik_Helper
- *
- */
+<?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_Helper + */ + +/** + * @package Piwik_Helper + * + */ class Piwik_Url { static function getArrayFromCurrentQueryString() @@ -21,7 +21,7 @@ class Piwik_Url $queryString = htmlspecialchars($queryString); $urlValues = Piwik_Common::getArrayFromQueryString($queryString); return $urlValues; - }
+ } static function getCurrentQueryStringWithParametersModified( $params ) { @@ -32,15 +32,15 @@ class Piwik_Url $urlValues[$key] = $value; } - $query = http_build_query($urlValues);
-
- if(strlen($query) > 0)
- {
- return '?'.$query;
- }
- else
- {
- return '';
+ $query = http_build_query($urlValues); + + if(strlen($query) > 0) + { + return '?'.$query; + } + else + { + return ''; } } diff --git a/modules/View.php b/modules/View.php index ac64056611..e81bf8445a 100644 --- a/modules/View.php +++ b/modules/View.php @@ -1,22 +1,22 @@ -<?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_Visualization
- */
-
+<?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_Visualization + */ + require_once 'Smarty/Smarty.class.php'; -require_once "iView.php";
-
-/**
- *
- * @package Piwik_Visualization
- *
+require_once "iView.php"; + +/** + * + * @package Piwik_Visualization + * */ class Piwik_View implements Piwik_iView { @@ -36,34 +36,34 @@ class Piwik_View implements Piwik_iView foreach($smConf as $key => $value) { $this->smarty->$key = $value; - }
+ } - $this->smarty->template_dir = $this->getCorrectPath( $smConf->template_dir->toArray() );
- $this->smarty->plugins_dir = $this->getCorrectPath( $smConf->plugins_dir->toArray() );
- $this->smarty->compile_dir = $this->getCorrectPath( $smConf->compile_dir );
- $this->smarty->cache_dir = $this->getCorrectPath( $smConf->cache_dir );
+ $this->smarty->template_dir = $this->getCorrectPath( $smConf->template_dir->toArray() ); + $this->smarty->plugins_dir = $this->getCorrectPath( $smConf->plugins_dir->toArray() ); + $this->smarty->compile_dir = $this->getCorrectPath( $smConf->compile_dir ); + $this->smarty->cache_dir = $this->getCorrectPath( $smConf->cache_dir ); $this->smarty->load_filter('output','trimwhitespace'); // global value accessible to all templates: the piwik base URL for the current request $this->piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName(); - }
-
- protected function getCorrectPath( $path )
- {
- if(is_array($path))
- {
- foreach($path as &$dir)
- {
- $dir = PIWIK_INCLUDE_PATH . '/' . $dir ;
- }
- return $path;
- }
- else
- {
- return PIWIK_INCLUDE_PATH . '/' . $path;
- }
+ } + + protected function getCorrectPath( $path ) + { + if(is_array($path)) + { + foreach($path as &$dir) + { + $dir = PIWIK_INCLUDE_PATH . '/' . $dir ; + } + return $path; + } + else + { + return PIWIK_INCLUDE_PATH . '/' . $path; + } } /** diff --git a/modules/ViewDataTable/Cloud.php b/modules/ViewDataTable/Cloud.php index fbb831301d..3764b8d2fa 100644 --- a/modules/ViewDataTable/Cloud.php +++ b/modules/ViewDataTable/Cloud.php @@ -1,22 +1,22 @@ -<?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_ViewDataTable
- */
-
-require_once "Visualization/Cloud.php";
-
-/**
+<?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_ViewDataTable + */ + +require_once "Visualization/Cloud.php"; + +/** * Reads the requested DataTable from the API, and prepares the data to give * to Piwik_Visualization_Cloud that will display the tag cloud (via the template cloud.tpl). - *
- * @package Piwik_ViewDataTable
- *
+ * + * @package Piwik_ViewDataTable + * */ class Piwik_ViewDataTable_Cloud extends Piwik_ViewDataTable { diff --git a/modules/ViewDataTable/GenerateGraphData.php b/modules/ViewDataTable/GenerateGraphData.php index 09f1446371..03ea3f9b1e 100644 --- a/modules/ViewDataTable/GenerateGraphData.php +++ b/modules/ViewDataTable/GenerateGraphData.php @@ -1,15 +1,15 @@ -<?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_ViewDataTable
- */
-
-/**
+<?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_ViewDataTable + */ + +/** * Reads data from the API and prepares data to give to the renderer Piwik_Visualization_Chart. * This class is used to generate the data for the FLASH charts. It is given as a parameter of the SWF file. * You can set the number of elements to appear in the graph using: setGraphLimit(); @@ -25,9 +25,9 @@ * return $this->renderView($view, $fetch); * } * </pre> - *
- * @package Piwik_ViewDataTable
- *
+ * + * @package Piwik_ViewDataTable + * */ abstract class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable { @@ -47,29 +47,29 @@ abstract class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable * Number of elements to display in the graph. * * @var int - */
- protected $graphLimit = 5;
+ */ + protected $graphLimit = 5; /** * Sets the number max of elements to display (number of pie slice, vertical bars, etc.) * If the data has more elements than $limit then the last part of the data will be the sum of all the remaining data. * * @param int $limit - */
- function setGraphLimit( $limit )
- {
- $this->graphLimit = $limit;
- }
+ */ + function setGraphLimit( $limit ) + { + $this->graphLimit = $limit; + } /** * Returns numbers of elemnts to display in the graph * * @return int - */
- function getGraphLimit()
- {
- return $this->graphLimit;
+ */ + function getGraphLimit() + { + return $this->graphLimit; } -
+ public function main() { if($this->mainAlreadyExecuted) @@ -77,12 +77,12 @@ abstract class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable return; } $this->mainAlreadyExecuted = true; -
+ $this->setLimit(-1); -
- // we load the data with the filters applied
+ + // we load the data with the filters applied $this->loadDataTableFromAPI(); - $this->dataTable->queueFilter('Piwik_DataTable_Filter_AddSummaryRow',array($this->getGraphLimit()));
+ $this->dataTable->queueFilter('Piwik_DataTable_Filter_AddSummaryRow',array($this->getGraphLimit())); // echo $this->dataTable; $this->dataAvailable = $this->dataTable->getRowsCount() != 0; @@ -133,7 +133,7 @@ abstract class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable // var_dump($data);exit; return $data; } -}
+} /** * Piwik_ViewDataTable_GenerateGraphData for the Evolution graph (eg. Last 30 days visits) using Piwik_Visualization_ChartEvolution @@ -161,26 +161,26 @@ class Piwik_ViewDataTable_GenerateGraphData_ChartEvolution extends Piwik_ViewDat * * @package Piwik_ViewDataTable * - */
-class Piwik_ViewDataTable_GenerateGraphData_ChartPie extends Piwik_ViewDataTable_GenerateGraphData
-{
- function __construct()
- {
- require_once "Visualization/ChartPie.php";
- $this->view = new Piwik_Visualization_ChartPie;
- }
-}
+ */ +class Piwik_ViewDataTable_GenerateGraphData_ChartPie extends Piwik_ViewDataTable_GenerateGraphData +{ + function __construct() + { + require_once "Visualization/ChartPie.php"; + $this->view = new Piwik_Visualization_ChartPie; + } +} /** - * Piwik_ViewDataTable_GenerateGraphData for the vertical bar graph, using Piwik_Visualization_ChartVerticalBar
- *
- * @package Piwik_ViewDataTable
- *
- */
-class Piwik_ViewDataTable_GenerateGraphData_ChartVerticalBar extends Piwik_ViewDataTable_GenerateGraphData
-{
- function __construct()
- {
- require_once "Visualization/ChartVerticalBar.php";
- $this->view = new Piwik_Visualization_ChartVerticalBar;
- }
+ * Piwik_ViewDataTable_GenerateGraphData for the vertical bar graph, using Piwik_Visualization_ChartVerticalBar + * + * @package Piwik_ViewDataTable + * + */ +class Piwik_ViewDataTable_GenerateGraphData_ChartVerticalBar extends Piwik_ViewDataTable_GenerateGraphData +{ + function __construct() + { + require_once "Visualization/ChartVerticalBar.php"; + $this->view = new Piwik_Visualization_ChartVerticalBar; + } } diff --git a/modules/ViewDataTable/Graph.php b/modules/ViewDataTable/Graph.php index debad0edd6..c96f465aa5 100644 --- a/modules/ViewDataTable/Graph.php +++ b/modules/ViewDataTable/Graph.php @@ -1,20 +1,20 @@ -<?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_ViewDataTable
- */
-
-/**
+<?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_ViewDataTable + */ + +/** * This class generates the HTML code to embed to flash graphs in the page. * It doesn't call the API but simply prints the html snippet. - *
- * @package Piwik_ViewDataTable
- *
+ * + * @package Piwik_ViewDataTable + * */ abstract class Piwik_ViewDataTable_Graph extends Piwik_ViewDataTable { @@ -74,7 +74,7 @@ abstract class Piwik_ViewDataTable_Graph extends Piwik_ViewDataTable $this->id = $this->getUniqIdTable(); $view->graphType = $this->graphType; - $this->parametersToModify['action'] = $this->currentControllerAction;
+ $this->parametersToModify['action'] = $this->currentControllerAction; $url = Piwik_Url::getCurrentQueryStringWithParametersModified($this->parametersToModify); $view->jsInvocationTag = $this->getFlashInvocationCode($url); $view->urlData = $url; @@ -87,7 +87,7 @@ abstract class Piwik_ViewDataTable_Graph extends Piwik_ViewDataTable $view->javascriptVariablesToSet = $this->getJavascriptVariablesToSet(); $view->showFooter = $this->getShowFooter(); $this->view = $view; - }
+ } protected function getFlashInvocationCode( $url = 'libs/open-flash-chart/data-files/nodata.txt', $use_swfobject = true ) { @@ -165,32 +165,32 @@ class Piwik_ViewDataTable_Graph_ChartEvolution extends Piwik_ViewDataTable_Graph $this->setParametersToModify(array('date' => 'last30')); $this->doNotShowFooter(); } -}
-/**
+} +/** * Generates HTML embed for the Pie chart - *
- * @package Piwik_ViewDataTable
- *
- */
-class Piwik_ViewDataTable_Graph_ChartPie extends Piwik_ViewDataTable_Graph
-{
- function __construct()
- {
- $this->valueParameterViewDataTable = 'generateDataChartPie';
- }
-}
-
-/**
+ * + * @package Piwik_ViewDataTable + * + */ +class Piwik_ViewDataTable_Graph_ChartPie extends Piwik_ViewDataTable_Graph +{ + function __construct() + { + $this->valueParameterViewDataTable = 'generateDataChartPie'; + } +} + +/** * * Generates HTML embed for the vertical bar chart - *
- * @package Piwik_ViewDataTable
- *
- */
-class Piwik_ViewDataTable_Graph_ChartVerticalBar extends Piwik_ViewDataTable_Graph
-{
- function __construct()
- {
- $this->valueParameterViewDataTable = 'generateDataChartVerticalBar';
- }
-}
+ * + * @package Piwik_ViewDataTable + * + */ +class Piwik_ViewDataTable_Graph_ChartVerticalBar extends Piwik_ViewDataTable_Graph +{ + function __construct() + { + $this->valueParameterViewDataTable = 'generateDataChartVerticalBar'; + } +} diff --git a/modules/Visualization/Chart.php b/modules/Visualization/Chart.php index 16cd5bc4dd..d45cd2d373 100644 --- a/modules/Visualization/Chart.php +++ b/modules/Visualization/Chart.php @@ -1,22 +1,22 @@ -<?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_Visualization
- */
-
+<?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_Visualization + */ + require_once "Visualization/OpenFlashChart.php"; -
-/**
+ +/** * Generates the data in the Open Flash Chart format, from the given data. * Uses Open flash chart PHP library @see Piwik_Visualization_OpenFlashChart - *
- * @package Piwik_Visualization
- */
+ * + * @package Piwik_Visualization + */ abstract class Piwik_Visualization_Chart extends Piwik_Visualization_OpenFlashChart { @@ -60,7 +60,7 @@ abstract class Piwik_Visualization_Chart extends Piwik_Visualization_OpenFlashCh function prepareData() { - $label = $data = array();
+ $label = $data = array(); // var_dump($this->dataGraph); exit; $max = 0; foreach($this->dataGraph as $row) diff --git a/modules/Visualization/Cloud.php b/modules/Visualization/Cloud.php index aa12efaa43..2a8924f5db 100644 --- a/modules/Visualization/Cloud.php +++ b/modules/Visualization/Cloud.php @@ -1,22 +1,22 @@ -<?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_Visualization
- */
-
-
+<?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_Visualization + */ + + /** * Generates a tag cloud from a given data array. - * The generated tag cloud can be in PHP format, or in HTML.
+ * The generated tag cloud can be in PHP format, or in HTML. * * Inspired from Derek Harvey (www.derekharvey.co.uk) - *
- * @package Piwik_Visualization
+ * + * @package Piwik_Visualization */ class Piwik_Visualization_Cloud { diff --git a/modules/Visualization/OpenFlashChart.php b/modules/Visualization/OpenFlashChart.php index ec4db36487..c4d7d986b3 100644 --- a/modules/Visualization/OpenFlashChart.php +++ b/modules/Visualization/OpenFlashChart.php @@ -1,27 +1,27 @@ -<?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$
+<?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_Visualization + * @subpackage OFC + */ + +require_once "iView.php"; + + +/** + * Original class provided by Open Flash Chart * * @package Piwik_Visualization - * @subpackage OFC
- */
-
-require_once "iView.php";
- -
-/**
- * Original class provided by Open Flash Chart
- *
- * @package Piwik_Visualization
- */
-abstract class Piwik_Visualization_OpenFlashChart implements Piwik_iView
-{
- function __construct()
- {
+ */ +abstract class Piwik_Visualization_OpenFlashChart implements Piwik_iView +{ + function __construct() + { $this->data_sets = array(); diff --git a/modules/iView.php b/modules/iView.php index 42003b4a72..c35edafa50 100644 --- a/modules/iView.php +++ b/modules/iView.php @@ -1,20 +1,20 @@ -<?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: APIable.php 162 2008-01-14 04:27:21Z matt $
- *
- * @package Piwik_Visualization
- */
-
-/**
+<?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: APIable.php 162 2008-01-14 04:27:21Z matt $ + * + * @package Piwik_Visualization + */ + +/** * Piwik_ViewDataTable must create a $view attribute which implements this interface. - *
- * @package Piwik_Visualization
- */
-interface Piwik_iView
+ * + * @package Piwik_Visualization + */ +interface Piwik_iView { /** * Outputs the data. @@ -22,6 +22,6 @@ interface Piwik_iView * * @return mixed * - */
- function render();
+ */ + function render(); }
\ No newline at end of file diff --git a/modules/testMinimumPhpVersion.php b/modules/testMinimumPhpVersion.php index 00e6f1dd4f..6203a81b61 100644 --- a/modules/testMinimumPhpVersion.php +++ b/modules/testMinimumPhpVersion.php @@ -1,31 +1,31 @@ -<?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: Common.php 168 2008-01-14 05:26:43Z matt $
- *
- * @package Piwik
- */
-
-/**
- * This file is executed before anything else. It checks the minimum Php version required to run Piwik.
- * This is done here because on PHP4 piwik would output an error directly.
- * Let's try to be user friendly :)
- *
- * @package Piwik
- */
-
-// we prefix the global variables
-$piwik_minimumPhpVersion = '5.1.3';
-$piwik_currentVersion = phpversion();
-
-if( version_compare($piwik_minimumPhpVersion , $piwik_currentVersion ) >= 0 )
-{
- $piwik_errorMessage = "<p><b>To run Piwik you need at least PHP version $piwik_minimumPhpVersion </b></p>
- <p>Unfortunately it seems your webserver is using PHP version $piwik_currentVersion. </p>
- <p>Please try to update your PHP version, Piwik is really worth it! Nowadays most web hosts
+<?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: Common.php 168 2008-01-14 05:26:43Z matt $ + * + * @package Piwik + */ + +/** + * This file is executed before anything else. It checks the minimum Php version required to run Piwik. + * This is done here because on PHP4 piwik would output an error directly. + * Let's try to be user friendly :) + * + * @package Piwik + */ + +// we prefix the global variables +$piwik_minimumPhpVersion = '5.1.3'; +$piwik_currentVersion = phpversion(); + +if( version_compare($piwik_minimumPhpVersion , $piwik_currentVersion ) >= 0 ) +{ + $piwik_errorMessage = "<p><b>To run Piwik you need at least PHP version $piwik_minimumPhpVersion </b></p> + <p>Unfortunately it seems your webserver is using PHP version $piwik_currentVersion. </p> + <p>Please try to update your PHP version, Piwik is really worth it! Nowadays most web hosts support PHP $piwik_minimumPhpVersion. </p>"; } @@ -89,7 +89,7 @@ function Piwik_ExitWithMessage($message) if(isset($piwik_errorMessage)) { - Piwik_ExitWithMessage($piwik_errorMessage);
+ Piwik_ExitWithMessage($piwik_errorMessage); } |