diff options
author | mattpiwik <matthieu.aubry@gmail.com> | 2008-12-08 17:08:24 +0300 |
---|---|---|
committer | mattpiwik <matthieu.aubry@gmail.com> | 2008-12-08 17:08:24 +0300 |
commit | 93ac4b09d9f0b2deec4ea0fa56d8fe4b5bc08437 (patch) | |
tree | 00a6cb5a31bdd30706ae5e7959d78993308d9181 | |
parent | 40cf751bf1d592900feb3684c567fbe148d9e97f (diff) |
- cleaning the API/ code
- deleting class Api_Apiable concept not used anymore
git-svn-id: http://dev.piwik.org/svn/trunk@826 59fd770c-687e-43c8-a1e3-f5a4ff64c105
-rw-r--r-- | core/API/APIable.php | 54 | ||||
-rw-r--r-- | core/API/DocumentationGenerator.php | 162 | ||||
-rw-r--r-- | core/API/Proxy.php | 253 | ||||
-rw-r--r-- | core/API/Request.php | 2 | ||||
-rw-r--r-- | core/FrontController.php | 3 | ||||
-rw-r--r-- | core/Piwik.php | 20 | ||||
-rw-r--r-- | core/Timer.php | 34 | ||||
-rw-r--r-- | core/iView.php | 2 | ||||
-rw-r--r-- | misc/TODO | 7 | ||||
-rw-r--r-- | plugins/API/Controller.php | 8 | ||||
-rw-r--r-- | plugins/Actions/API.php | 2 | ||||
-rw-r--r-- | plugins/Actions/Actions.php | 12 | ||||
-rw-r--r-- | plugins/DBStats/API.php | 35 | ||||
-rw-r--r-- | plugins/ExampleAPI/API.php | 2 | ||||
-rw-r--r-- | plugins/LanguagesManager/API.php | 2 | ||||
-rw-r--r-- | plugins/Provider/API.php | 2 | ||||
-rw-r--r-- | plugins/Referers/API.php | 2 | ||||
-rwxr-xr-x | plugins/SitesManager/API.php | 4 | ||||
-rw-r--r-- | plugins/UserCountry/API.php | 2 | ||||
-rw-r--r-- | plugins/UserSettings/API.php | 2 | ||||
-rwxr-xr-x | plugins/UsersManager/API.php | 4 | ||||
-rw-r--r-- | plugins/VisitFrequency/API.php | 2 | ||||
-rw-r--r-- | plugins/VisitTime/API.php | 2 | ||||
-rw-r--r-- | plugins/VisitorInterest/API.php | 2 | ||||
-rw-r--r-- | plugins/VisitsSummary/API.php | 2 |
25 files changed, 292 insertions, 330 deletions
diff --git a/core/API/APIable.php b/core/API/APIable.php deleted file mode 100644 index c05f47d3d2..0000000000 --- a/core/API/APIable.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/** - * Piwik - Open source web analytics - * - * @link http://piwik.org - * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later - * @version $Id: APIable.php 482 2008-05-18 17:22:35Z matt $ - * - * @package Piwik_API - */ -require_once 'Archive.php'; - -/** - * This class is the parent class of all the plugins that can be called using the API Proxy. - * For example a plugin "Provider" can publish its API by creating a file plugins/Provider/API.php - * that is extending this Piwik_Apiable class. - * All the Piwik_Apiable classes are read and loaded by the Piwik_API_Proxy class. - * The public methods of this class are published in the API and are then callable using the API module. - * The parameters of the function are read directly from the GET request (they must have the same name). - * - * For example - * public function helloWorld($text) { return "hello " . $text; } - * call be called using - * ?module=API&method=PluginName.helloWorld&text=world! - * - * See the documentation on http://dev.piwik.org > API - * - * @package Piwik_API - * @see Piwik_API_Proxy - */ - -abstract class Piwik_Apiable -{ - /** - * This array contains the name of the methods of the class we don't want to publish in the API. - * By default only public methods are published. Names of public methods in this array won't be published. - * - * @var array of strings - */ - static public $methodsNotToPublish = array(); - - /** - * @see self::$methodsNotToPublish - * @param string Method name not to be published - */ - protected function doNotPublishMethod( $methodName ) - { - if(!method_exists($this, $methodName)) - { - throw new Exception("The method $methodName doesn't exist so it can't be added to the list of the methods not to be published in the API."); - } - $this->methodsNotToPublish[] = $methodName; - } -} diff --git a/core/API/DocumentationGenerator.php b/core/API/DocumentationGenerator.php new file mode 100644 index 0000000000..ad6018ab51 --- /dev/null +++ b/core/API/DocumentationGenerator.php @@ -0,0 +1,162 @@ +<?php + +class Piwik_API_DocumentationGenerator +{ + /** + * 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 = ''; + $token_auth = "&token_auth=" . Piwik::getCurrentUserTokenAuth(); + $parametersToSet = array( + 'idSite' => Piwik_Common::getRequestVar('idSite', 1, 'int'), + 'period' => Piwik_Common::getRequestVar('period', 'day', 'string'), + 'date' => Piwik_Common::getRequestVar('date', 'today', 'string') + ); + + foreach(Piwik_API_Proxy::getInstance()->getMetadata() as $class => $info) + { + $moduleName = Piwik_API_Proxy::getInstance()->getModuleNameFromClassName($class); + $str .= "\n<h2 id='$moduleName'>Module ".$moduleName."</h2>"; + + foreach($info as $methodName => $infoMethod) + { + $params = $this->getStrListParameters($class, $methodName); + $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 + $str .= "<span class=\"example\">"; + $exampleUrl = $this->getExampleUrl($class, $methodName, $parametersToSet); + if($exampleUrl !== false) + { + $lastNUrls = ''; + if( ereg('(&period)|(&date)',$exampleUrl)) + { + $exampleUrlRss1 = $prefixUrls . $this->getExampleUrl($class, $methodName, $parametersToSet + array('date' => 'last10')) ; + $exampleUrlRss2 = $prefixUrls . $this->getExampleUrl($class, $methodName, $parametersToSet + array('date' => 'last5','period' => 'week',)); + $lastNUrls = ", RSS of the last <a target=_blank href='$exampleUrlRss1&format=rss$token_auth'>10 days</a>, <a target=_blank href='$exampleUrlRss2&format=Rss'>5 weeks</a>, + XML of the <a target=_blank href='$exampleUrlRss1&format=xml$token_auth'>last 10 days</a>"; + } + $exampleUrl = $prefixUrls . $exampleUrl ; + $str .= " [ Example in + <a target=_blank href='$exampleUrl&format=xml$token_auth'>XML</a>, + <a target=_blank href='$exampleUrl&format=PHP&prettyDisplay=true$token_auth'>PHP</a>, + <a target=_blank href='$exampleUrl&format=JSON$token_auth'>Json</a>, + <a target=_blank href='$exampleUrl&format=Csv$token_auth'>Csv</a>, + <a target=_blank href='$exampleUrl&format=Html$token_auth'>Basic html</a> + $lastNUrls + ]"; + } + else + { + $str .= " [ No example available ]"; + } + $str .= "</span>"; + } + $str .= '</small>'; + $str .= "\n<br>"; + } + } + return $str; + } + + + /** + * 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 + */ + protected function getExampleUrl($class, $methodName, $parametersToSet = array()) + { + $knowExampleDefaultParametersValues = array( + 'access' => 'view', + 'userLogin' => 'test', + 'password' => 'passwordExample', + 'passwordMd5ied' => 'passwordExample', + 'email' => 'test@example.org', + + 'siteName' => 'new example website', + 'urls' => 'http://example.org', // used in addSite, updateSite + + 'languageCode' => 'fr', + ); + + 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 = Piwik_API_Proxy::getInstance()->getParametersList($class, $methodName); + $moduleName = Piwik_API_Proxy::getInstance()->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 the methods $class.$name parameters (and default value if provided) as a string. + * + * @param string The class name + * @param string The method name + * @return string For example "(idSite, period, date = 'today')" + */ + protected function getStrListParameters($class, $name) + { + $aParameters = Piwik_API_Proxy::getInstance()->getParametersList($class, $name); + $asParameters = array(); + foreach($aParameters as $nameVariable=> $defaultValue) + { + $str = $nameVariable; + if($defaultValue !== Piwik_API_Proxy::NO_DEFAULT_VALUE) + { + $str .= " = '$defaultValue'"; + } + $asParameters[] = $str; + } + $sParameters = implode(", ", $asParameters); + return "($sParameters)"; + } +} diff --git a/core/API/Proxy.php b/core/API/Proxy.php index 41f7191b4c..d42a69e218 100644 --- a/core/API/Proxy.php +++ b/core/API/Proxy.php @@ -13,7 +13,6 @@ /** * The API Proxy receives all the API calls requests and forwards them to the given module. * - * It registers all the APIable plugins (@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. * @@ -28,14 +27,13 @@ class Piwik_API_Proxy // array of already registered plugins names protected $alreadyRegistered = array(); - private $api = array(); + private $metadataArray = 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() - {} + protected function __construct() {} /** * Singleton, returns instance @@ -52,11 +50,15 @@ class Piwik_API_Proxy return self::$instance; } + public function getMetadata() + { + return $this->metadataArray; + } + /** * Registers the API information of a given module. * * The module to be registered must be - * - extending the Piwik_Apiable class * - a singleton (providing a getInstance() method) * - the API file must be located in plugins/ModuleName/API.php * for example plugins/Referers/API.php @@ -74,15 +76,9 @@ class Piwik_API_Proxy $this->includeApiFile($moduleName); $class = $this->getClassNameFromModule($moduleName); + $this->checkClassIsSingleton($class); $rClass = new ReflectionClass($class); - if(!$rClass->isSubclassOf(new ReflectionClass("Piwik_Apiable"))) - { - throw new Exception("To publish its public methods in the API, the class '$class' must be a subclass of 'Piwik_Apiable'."); - } - - $this->checkClassIsSingleton($class); - foreach($rClass->getMethods() as $method) { $this->loadMethodMetadata($class, $method); @@ -173,7 +169,36 @@ class Piwik_API_Proxy return $returnedValue; } - protected function includeApiFile($fileName) + /** + * Returns the 'moduleName' part of 'Piwik_moduleName_API' classname + * + * @param string moduleName + * @return string className + */ + public function getModuleNameFromClassName( $className ) + { + $start = strpos($className, '_') + 1; + return substr($className, $start , strrpos($className, '_') - $start); + } + + /** + * Returns the parameters names and default values for the method $name + * of the class $class + * + * @param string The class name + * @param string The method name + * @return array Format array( + * 'testParameter' => null, // no default value + * 'life' => 42, // default value = 42 + * 'date' => 'yesterday', + * ); + */ + public function getParametersList($class, $name) + { + return $this->metadataArray[$class][$name]['parameters']; + } + + private function includeApiFile($fileName) { $potentialPaths = array( "plugins/". $fileName ."/API.php", ); @@ -194,7 +219,7 @@ class Piwik_API_Proxy } } - protected function loadMethodMetadata($class, $method) + private function loadMethodMetadata($class, $method) { // use this trick to read the static attribute of the class // $class::$methodsNotToPublish doesn't work @@ -222,196 +247,9 @@ class Piwik_API_Proxy $aParameters[$nameVariable] = $defaultValue; } - $this->api[$class][$name]['parameters'] = $aParameters; - $this->api[$class][$name]['numberOfRequiredParameters'] = $method->getNumberOfRequiredParameters(); - } - } - - /** - * 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', - 'userLogin' => 'test', - 'password' => 'passwordExample', - 'passwordMd5ied' => 'passwordExample', - 'email' => 'test@example.org', - - 'siteName' => 'new example website', - 'urls' => 'http://example.org', // used in addSite, updateSite - - 'languageCode' => 'fr', - ); - - 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; - } - } - + $this->metadataArray[$class][$name]['parameters'] = $aParameters; + $this->metadataArray[$class][$name]['numberOfRequiredParameters'] = $method->getNumberOfRequiredParameters(); } - - 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 = ''; - $token_auth = "&token_auth=" . Piwik::getCurrentUserTokenAuth(); - $parametersToSet = array( - 'idSite' => Piwik_Common::getRequestVar('idSite', 1, 'int'), - 'period' => Piwik_Common::getRequestVar('period', 'day', 'string'), - 'date' => Piwik_Common::getRequestVar('date', 'today', 'string') - ); - - foreach($this->api as $class => $info) - { - $moduleName = $this->getModuleNameFromClassName($class); - $str .= "\n<h2 id='$moduleName'>Module ".$moduleName."</h2>"; - - foreach($info as $methodName => $infoMethod) - { - $params = $this->getStrListParameters($class, $methodName); - $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 - $str .= "<span class=\"example\">"; - $exampleUrl = $this->getExampleUrl($class, $methodName, $parametersToSet); - if($exampleUrl !== false) - { - $lastNUrls = ''; - if( ereg('(&period)|(&date)',$exampleUrl)) - { - $exampleUrlRss1 = $prefixUrls . $this->getExampleUrl($class, $methodName, $parametersToSet + array('date' => 'last10')) ; - $exampleUrlRss2 = $prefixUrls . $this->getExampleUrl($class, $methodName, $parametersToSet + array('date' => 'last5','period' => 'week',)); - $lastNUrls = ", RSS of the last <a target=_blank href='$exampleUrlRss1&format=rss$token_auth'>10 days</a>, <a target=_blank href='$exampleUrlRss2&format=Rss'>5 weeks</a>, - XML of the <a target=_blank href='$exampleUrlRss1&format=xml$token_auth'>last 10 days</a>"; - } - $exampleUrl = $prefixUrls . $exampleUrl ; - $str .= " [ Example in - <a target=_blank href='$exampleUrl&format=xml$token_auth'>XML</a>, - <a target=_blank href='$exampleUrl&format=PHP&prettyDisplay=true$token_auth'>PHP</a>, - <a target=_blank href='$exampleUrl&format=JSON$token_auth'>Json</a>, - <a target=_blank href='$exampleUrl&format=Csv$token_auth'>Csv</a>, - <a target=_blank href='$exampleUrl&format=Html$token_auth'>Basic html</a> - $lastNUrls - ]"; - } - else - { - $str .= " [ No example available ]"; - } - $str .= "</span>"; - } - $str .= '</small>'; - $str .= "\n<br>"; - } - } - return $str; - } - - /** - * Returns the methods $class.$name parameters (and default value if provided) as a string. - * - * @param string The class name - * @param string The method name - * @return string For example "(idSite, period, date = 'today')" - */ - private function getStrListParameters($class, $name) - { - $aParameters = $this->getParametersList($class, $name); - $asParameters = array(); - foreach($aParameters as $nameVariable=> $defaultValue) - { - $str = $nameVariable; - if($defaultValue !== Piwik_API_Proxy::NO_DEFAULT_VALUE) - { - $str .= " = '$defaultValue'"; - } - $asParameters[] = $str; - } - $sParameters = implode(", ", $asParameters); - return "($sParameters)"; - } - - /** - * Returns the parameters names and default values for the method $name - * of the class $class - * - * @param string The class name - * @param string The method name - * @return array Format array( - * 'testParameter' => null, // no default value - * 'life' => 42, // default value = 42 - * 'date' => 'yesterday', - * ); - */ - public function getParametersList($class, $name) - { - return $this->api[$class][$name]['parameters']; } /** @@ -423,7 +261,7 @@ class Piwik_API_Proxy */ private function getNumberOfRequiredParameters($class, $name) { - return $this->api[$class][$name]['numberOfRequiredParameters']; + return $this->metadataArray[$class][$name]['numberOfRequiredParameters']; } /** @@ -435,7 +273,7 @@ class Piwik_API_Proxy */ private function isMethodAvailable( $className, $methodName) { - return isset($this->api[$className][$methodName]); + return isset($this->metadataArray[$className][$methodName]); } /** @@ -474,13 +312,12 @@ class Piwik_API_Proxy * Returns the API class name given the module name. * * 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. + * Piwik_Referers_API contains the methods to be published in the API. * * @param string module name * @return string class name */ - protected function getClassNameFromModule($module) + private function getClassNameFromModule($module) { $class = Piwik::prefixClass($module ."_API"); return $class; diff --git a/core/API/Request.php b/core/API/Request.php index 09c96a2de1..55404c5a2f 100644 --- a/core/API/Request.php +++ b/core/API/Request.php @@ -128,7 +128,7 @@ class Piwik_API_Request $toReturn = $response->getResponse($returnedValue); } catch(Exception $e ) { - return $response->getResponseException( $e ); + $toReturn = $response->getResponseException( $e ); } return $toReturn; } diff --git a/core/FrontController.php b/core/FrontController.php index fcbba59e26..591693c453 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -23,11 +23,12 @@ require_once "Zend/Auth/Adapter/DbTable.php"; */ require_once "Timer.php"; require_once "core/Piwik.php"; -require_once "API/APIable.php"; require_once "Access.php"; require_once "Auth.php"; require_once "API/Proxy.php"; require_once "Site.php"; +require_once "Date.php"; +require_once "DataTable.php"; require_once "Translate.php"; require_once "Mail.php"; require_once "Url.php"; diff --git a/core/Piwik.php b/core/Piwik.php index 3a0e0ce40c..998d6da08b 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -57,7 +57,7 @@ class Piwik Piwik::createHtAccess($path); } } - + /** * Checks that the directories Piwik needs write access are actually writable * Displays a nice error page if permissions are missing on some directories @@ -399,6 +399,23 @@ class Piwik } } + static public function getPrettySizeFromBytes($size) + { + $bytes = array('','K','M','G','T'); + foreach($bytes as $val) + { + if($size > 1024) + { + $size = $size / 1024; + } + else + { + break; + } + } + return round($size, 1)." ".$val; + } + static public function isPhpCliMode() { return in_array(substr(php_sapi_name(), 0, 3), array('cgi', 'cli')); @@ -584,6 +601,7 @@ class Piwik visit_entry_idaction INTEGER(11) NOT NULL, visit_total_actions SMALLINT(5) UNSIGNED NOT NULL, visit_total_time SMALLINT(5) UNSIGNED NOT NULL, + visit_goal_converted TINYINT(1) NOT NULL, referer_type INTEGER UNSIGNED NULL, referer_name VARCHAR(70) NULL, referer_url TEXT NOT NULL, diff --git a/core/Timer.php b/core/Timer.php index 8e71b41ba5..783dcff6ea 100644 --- a/core/Timer.php +++ b/core/Timer.php @@ -15,36 +15,48 @@ */ class Piwik_Timer { - private $m_Start; + private $timerStart; + private $memoryStart; public function __construct() { - $this->m_Start = 0.0; $this->init(); } - private function getMicrotime() - { - list($micro_seconds, $seconds) = explode(" ", microtime()); - return ((float)$micro_seconds + (float)$seconds); - } - public function init() { - $this->m_Start = $this->getMicrotime(); + $this->timerStart = $this->getMicrotime(); + $this->memoryStart = $this->getMemoryUsage(); } public function getTime($decimals = 2) { - return number_format($this->getMicrotime() - $this->m_Start, $decimals, '.', ''); + return number_format($this->getMicrotime() - $this->timerStart, $decimals, '.', ''); } + public function getTimeMs($decimals = 2) { - return number_format(1000*($this->getMicrotime() - $this->m_Start), $decimals, '.', ''); + return number_format(1000*($this->getMicrotime() - $this->timerStart), $decimals, '.', ''); } + public function getMemoryLeak() + { + return "Memory delta: ".Piwik::getPrettySizeFromBytes($this->getMemoryUsage() - $this->memoryStart); + } + public function __toString() { return "Time elapsed: ". $this->getTime() ."s"; } + + private function getMicrotime() + { + list($micro_seconds, $seconds) = explode(" ", microtime()); + return ((float)$micro_seconds + (float)$seconds); + } + + private function getMemoryUsage() + { + return memory_get_usage(); + } } diff --git a/core/iView.php b/core/iView.php index c35edafa50..82bb01bcd3 100644 --- a/core/iView.php +++ b/core/iView.php @@ -4,7 +4,7 @@ * * @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 $ + * @version $Id$ * * @package Piwik_Visualization */ @@ -1,5 +1,9 @@ Following up show all columns new UI element ==== +- pages columns: first should be unique page views, sorted by unique pageviews +- exclude all population doesn't work for actions +- post 29 There seems not to be a way to export the pages information widget. I wanted to download the entry pages to see where my visitors entered my site from, but there is no option to do so. + $("td img", domElem).attr("src") is undefined [Break on this error] var plusDetected = $('td img', domElem).attr('src').indexOf('plus') >= 0; datatable.js (line 907) @@ -16,6 +20,8 @@ when clicking MINUS on actions - set custom truncation limit per datatable type (simple VS allColumns, and subtable) ->bug display subtable icon is cut (see truncation limit) - Blog post! +- cron should return errors when token doesn't have any website + Test page ========== - prepare a page with all use cases in iframes? @@ -39,7 +45,6 @@ UI fixes + adjustements - WRONG::: 147 sites Internet différents (utilisant 147 différentes adresses) - see also #421 -check phpmyvisites piwik analytics sur delicious check analytics books high priority features diff --git a/plugins/API/Controller.php b/plugins/API/Controller.php index 60602f585e..2b21cd9883 100644 --- a/plugins/API/Controller.php +++ b/plugins/API/Controller.php @@ -10,7 +10,7 @@ */ require_once "API/Request.php"; - +require_once "API/DocumentationGenerator.php"; /** * @@ -27,7 +27,8 @@ class Piwik_API_Controller extends Piwik_Controller public function listAllMethods() { $this->init(); - echo Piwik_API_Proxy::getInstance()->getAllInterfaceString( $outputExampleUrls = true, $prefixUrls = Piwik_Common::getRequestVar('prefixUrl', '') ); + $ApiDocumentation = new Piwik_API_DocumentationGenerator(); + echo $ApiDocumentation->getAllInterfaceString( $outputExampleUrls = true, $prefixUrls = Piwik_Common::getRequestVar('prefixUrl', '') ); } public function listAllAPI() @@ -35,7 +36,8 @@ class Piwik_API_Controller extends Piwik_Controller $view = new Piwik_View("API/templates/listAllAPI.tpl"); $this->setGeneralVariablesView($view); $view->countLoadedAPI = $this->init(); - $view->list_api_methods_with_links = Piwik_API_Proxy::getInstance()->getAllInterfaceString(); + $ApiDocumentation = new Piwik_API_DocumentationGenerator(); + $view->list_api_methods_with_links = $ApiDocumentation->getAllInterfaceString(); echo $view->render(); } diff --git a/plugins/Actions/API.php b/plugins/Actions/API.php index 42996b7a53..57c3afa6fe 100644 --- a/plugins/Actions/API.php +++ b/plugins/Actions/API.php @@ -18,7 +18,7 @@ require_once "Actions.php"; * * @package Piwik_Actions */ -class Piwik_Actions_API extends Piwik_Apiable +class Piwik_Actions_API { static private $instance = null; diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php index 40e167bd38..0972d00e46 100644 --- a/plugins/Actions/Actions.php +++ b/plugins/Actions/Actions.php @@ -190,13 +190,13 @@ class Piwik_Actions extends Piwik_Plugin $maximumRowsInDataTableLevelZero = 200; $maximumRowsInSubDataTable = 50; -
- $dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_Tracker_Action::TYPE_ACTION]);
- $s = $dataTable->getSerialized( $maximumRowsInDataTableLevelZero, $maximumRowsInSubDataTable );
+ + $dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_Tracker_Action::TYPE_ACTION]); + $s = $dataTable->getSerialized( $maximumRowsInDataTableLevelZero, $maximumRowsInSubDataTable ); $record = new Piwik_ArchiveProcessing_Record_BlobArray('Actions_actions', $s);
-
- $dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_Tracker_Action::TYPE_DOWNLOAD]);
- $s = $dataTable->getSerialized( $maximumRowsInDataTableLevelZero, $maximumRowsInSubDataTable );
+ + $dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_Tracker_Action::TYPE_DOWNLOAD]); + $s = $dataTable->getSerialized($maximumRowsInDataTableLevelZero, $maximumRowsInSubDataTable ); $record = new Piwik_ArchiveProcessing_Record_BlobArray('Actions_downloads', $s);
$dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_Tracker_Action::TYPE_OUTLINK]);
diff --git a/plugins/DBStats/API.php b/plugins/DBStats/API.php index b041b9a227..9fa169157f 100644 --- a/plugins/DBStats/API.php +++ b/plugins/DBStats/API.php @@ -13,7 +13,7 @@ * * @package Piwik_DBStats_API */ -class Piwik_DBStats_API extends Piwik_Apiable +class Piwik_DBStats_API { static private $instance = null; static public function getInstance() @@ -44,23 +44,6 @@ class Piwik_DBStats_API extends Piwik_Apiable return $status; } - static private function get_size($size) - { - $bytes = array('','K','M','G','T'); - foreach($bytes as $val) - { - if($size > 1024) - { - $size = $size / 1024; - } - else - { - break; - } - } - return round($size, 1)." ".$val; - } - static public function getTableStatus($table, $field = '') { Piwik::checkUserIsSuperUser(); @@ -92,16 +75,16 @@ class Piwik_DBStats_API extends Piwik_Apiable $total['Index_length'] += $t['Index_length']; $total['Rows'] += $t['Rows']; - $t['Total_length'] = self::get_size($t['Index_length']+$t['Data_length']); - $t['Data_length'] = self::get_size($t['Data_length']); - $t['Index_length'] = self::get_size($t['Index_length']); - $t['Rows'] = self::get_size($t['Rows']); + $t['Total_length'] = Piwik::getPrettySizeFromBytes($t['Index_length']+$t['Data_length']); + $t['Data_length'] = Piwik::getPrettySizeFromBytes($t['Data_length']); + $t['Index_length'] = Piwik::getPrettySizeFromBytes($t['Index_length']); + $t['Rows'] = Piwik::getPrettySizeFromBytes($t['Rows']); $tables[] = $t; } - $total['Total_length'] = self::get_size($total['Data_length']+$total['Index_length']); - $total['Data_length'] = self::get_size($total['Data_length']); - $total['Index_length'] = self::get_size($total['Index_length']); - $total['TotalRows'] = self::get_size($total['Rows']); + $total['Total_length'] = Piwik::getPrettySizeFromBytes($total['Data_length']+$total['Index_length']); + $total['Data_length'] = Piwik::getPrettySizeFromBytes($total['Data_length']); + $total['Index_length'] = Piwik::getPrettySizeFromBytes($total['Index_length']); + $total['TotalRows'] = Piwik::getPrettySizeFromBytes($total['Rows']); $tables['Total'] = $total; return $tables; diff --git a/plugins/ExampleAPI/API.php b/plugins/ExampleAPI/API.php index 8a6d19af96..40e0924cf2 100644 --- a/plugins/ExampleAPI/API.php +++ b/plugins/ExampleAPI/API.php @@ -20,7 +20,7 @@ * * @package Piwik_ExamplePlugin */ -class Piwik_ExampleAPI_API extends Piwik_Apiable +class Piwik_ExampleAPI_API { static private $instance = null; static public function getInstance() diff --git a/plugins/LanguagesManager/API.php b/plugins/LanguagesManager/API.php index 20411a7021..edb5d1aa7b 100644 --- a/plugins/LanguagesManager/API.php +++ b/plugins/LanguagesManager/API.php @@ -2,7 +2,7 @@ /** * @package Piwik_LanguagesManager */ -class Piwik_LanguagesManager_API extends Piwik_Apiable +class Piwik_LanguagesManager_API { static private $instance = null; static public function getInstance() diff --git a/plugins/Provider/API.php b/plugins/Provider/API.php index 7f7c83f569..eafea2151e 100644 --- a/plugins/Provider/API.php +++ b/plugins/Provider/API.php @@ -14,7 +14,7 @@ require_once "Provider/functions.php"; * * @package Piwik_Provider */ -class Piwik_Provider_API extends Piwik_Apiable +class Piwik_Provider_API { static private $instance = null; diff --git a/plugins/Referers/API.php b/plugins/Referers/API.php index 8a5b8b5bca..5df0dfe834 100644 --- a/plugins/Referers/API.php +++ b/plugins/Referers/API.php @@ -15,7 +15,7 @@ require_once "Referers/functions.php"; * * @package Piwik_Referers */ -class Piwik_Referers_API extends Piwik_Apiable +class Piwik_Referers_API { static private $instance = null; static public function getInstance() diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php index cfd4e8b0c7..6ff1ff9a8b 100755 --- a/plugins/SitesManager/API.php +++ b/plugins/SitesManager/API.php @@ -13,7 +13,7 @@ * * @package Piwik_SitesManager */ -class Piwik_SitesManager_API extends Piwik_Apiable +class Piwik_SitesManager_API { static private $instance = null; static public function getInstance() @@ -26,8 +26,6 @@ class Piwik_SitesManager_API extends Piwik_Apiable return self::$instance; } - static public $methodsNotToPublish = array(); - /** * Returns the javascript tag for the given idSite. * This tag must be included on every page to be tracked by Piwik diff --git a/plugins/UserCountry/API.php b/plugins/UserCountry/API.php index 404dc0cbc4..6c6f00c857 100644 --- a/plugins/UserCountry/API.php +++ b/plugins/UserCountry/API.php @@ -15,7 +15,7 @@ require_once "UserCountry/functions.php"; * * @package Piwik_UserCountry */ -class Piwik_UserCountry_API extends Piwik_Apiable +class Piwik_UserCountry_API { static private $instance = null; static public function getInstance() diff --git a/plugins/UserSettings/API.php b/plugins/UserSettings/API.php index c31f941ced..d283c83870 100644 --- a/plugins/UserSettings/API.php +++ b/plugins/UserSettings/API.php @@ -16,7 +16,7 @@ require_once "UserSettings/functions.php"; /** * @package Piwik_UserSettings */ -class Piwik_UserSettings_API extends Piwik_Apiable +class Piwik_UserSettings_API { static private $instance = null; static public function getInstance() diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php index 46024d1295..235562c11c 100755 --- a/plugins/UsersManager/API.php +++ b/plugins/UsersManager/API.php @@ -13,7 +13,7 @@ * * @package Piwik_UsersManager */ -class Piwik_UsersManager_API extends Piwik_Apiable +class Piwik_UsersManager_API { static private $instance = null; static public function getInstance() @@ -26,8 +26,6 @@ class Piwik_UsersManager_API extends Piwik_Apiable return self::$instance; } - static public $methodsNotToPublish = array(); - /** * Returns the list of all the users * diff --git a/plugins/VisitFrequency/API.php b/plugins/VisitFrequency/API.php index c1e92bcc01..06acc4090f 100644 --- a/plugins/VisitFrequency/API.php +++ b/plugins/VisitFrequency/API.php @@ -13,7 +13,7 @@ * * @package Piwik_VisitFrequency */ -class Piwik_VisitFrequency_API extends Piwik_Apiable +class Piwik_VisitFrequency_API { static private $instance = null; static public function getInstance() diff --git a/plugins/VisitTime/API.php b/plugins/VisitTime/API.php index 86fe3d6224..47dc678216 100644 --- a/plugins/VisitTime/API.php +++ b/plugins/VisitTime/API.php @@ -14,7 +14,7 @@ * * @package Piwik_VisitTime */ -class Piwik_VisitTime_API extends Piwik_Apiable +class Piwik_VisitTime_API { static private $instance = null; static public function getInstance() diff --git a/plugins/VisitorInterest/API.php b/plugins/VisitorInterest/API.php index fc2af110ff..2903c3eabf 100644 --- a/plugins/VisitorInterest/API.php +++ b/plugins/VisitorInterest/API.php @@ -14,7 +14,7 @@ * * @package Piwik_VisitorInterest */ -class Piwik_VisitorInterest_API extends Piwik_Apiable +class Piwik_VisitorInterest_API { static private $instance = null; static public function getInstance() diff --git a/plugins/VisitsSummary/API.php b/plugins/VisitsSummary/API.php index 72df24bfbf..5424ad8c2a 100644 --- a/plugins/VisitsSummary/API.php +++ b/plugins/VisitsSummary/API.php @@ -12,7 +12,7 @@ /** * @package Piwik_VisitsSummary */ -class Piwik_VisitsSummary_API extends Piwik_Apiable +class Piwik_VisitsSummary_API { static private $instance = null; static public function getInstance() |