diff --git a/core/API/DataTableManipulator.php b/core/API/DataTableManipulator.php
index 1fce679f95a..e93c1f5c87d 100644
--- a/core/API/DataTableManipulator.php
+++ b/core/API/DataTableManipulator.php
@@ -14,7 +14,7 @@
use Piwik\DataTable\Row;
use Piwik\Period\Range;
use Piwik\DataTable;
-use Piwik_API_API;
+use Piwik\Plugins\API\API;
use Piwik\API\Proxy;
use Piwik\API\ResponseBuilder;
@@ -126,7 +126,7 @@ protected function loadSubtable($dataTable, $row)
}
}
- $class = 'Piwik_' . $this->apiModule . '_API';
+ $class = Request::getClassNameAPI( $this->apiModule );
$method = $this->getApiMethodForSubtable();
$this->manipulateSubtableRequest($request);
@@ -166,7 +166,7 @@ protected abstract function manipulateSubtableRequest(&$request);
private function getApiMethodForSubtable()
{
if (!$this->apiMethodForSubtable) {
- $meta = Piwik_API_API::getInstance()->getMetadata('all', $this->apiModule, $this->apiMethod);
+ $meta = API::getInstance()->getMetadata('all', $this->apiModule, $this->apiMethod);
if (isset($meta[0]['actionToLoadSubTables'])) {
$this->apiMethodForSubtable = $meta[0]['actionToLoadSubTables'];
} else {
diff --git a/core/API/DocumentationGenerator.php b/core/API/DocumentationGenerator.php
index ae1b1557bfa..50362fc60ba 100644
--- a/core/API/DocumentationGenerator.php
+++ b/core/API/DocumentationGenerator.php
@@ -33,9 +33,9 @@ public function __construct()
{
$plugins = PluginsManager::getInstance()->getLoadedPluginsName();
foreach ($plugins as $plugin) {
- $plugin = Common::unprefixClass($plugin);
try {
- Proxy::getInstance()->registerClass('Piwik_' . $plugin . '_API');
+ $className = Request::getClassNameAPI($plugin);
+ Proxy::getInstance()->registerClass($className);
} catch (Exception $e) {
}
}
diff --git a/core/API/Proxy.php b/core/API/Proxy.php
index e3861facb1e..981452f41f8 100644
--- a/core/API/Proxy.php
+++ b/core/API/Proxy.php
@@ -88,7 +88,7 @@ public function getMetadata()
*
* The method will introspect the methods, their parameters, etc.
*
- * @param string $className ModuleName eg. "Piwik_UserSettings_API"
+ * @param string $className ModuleName eg. "API"
*/
public function registerClass($className)
{
@@ -146,7 +146,7 @@ public function getCountRegisteredClasses()
* 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 $className The class name (eg. Piwik_Referers_API)
+ * @param string $className The class name (eg. API)
* @param string $methodName The method name
* @param array $parametersRequest The parameters pairs (name=>value)
*
@@ -186,16 +186,14 @@ public function call($className, $methodName, $parametersRequest)
$returnedValue = call_user_func_array(array($object, $methodName), $finalParameters);
// allow plugins to manipulate the value
- if (substr($className, 0, 6) == 'Piwik_' && substr($className, -4) == '_API') {
- $pluginName = substr($className, 6, -4);
- Piwik_PostEvent('API.Proxy.processReturnValue', array(
- &$returnedValue,
- array('className' => $className,
- 'module' => $pluginName,
- 'action' => $methodName,
- 'parameters' => &$parametersRequest)
- ));
- }
+ $pluginName = $this->getModuleNameFromClassName($className);
+ Piwik_PostEvent('API.Proxy.processReturnValue', array(
+ &$returnedValue,
+ array('className' => $className,
+ 'module' => $pluginName,
+ 'action' => $methodName,
+ 'parameters' => &$parametersRequest)
+ ));
// Restore the request
$_GET = $saveGET;
@@ -242,12 +240,12 @@ public function getParametersList($class, $name)
/**
* Returns the 'moduleName' part of 'Piwik_moduleName_API' classname
*
- * @param string $className "Piwik_Referers_API"
+ * @param string $className "API"
* @return string "Referers"
*/
public function getModuleNameFromClassName($className)
{
- return str_replace(array('Piwik_', '_API'), '', $className);
+ return str_replace(array('\\Piwik\\Plugins\\', '\\API'), '', $className);
}
/**
@@ -308,9 +306,9 @@ private function getRequestParametersArray($requiredParameters, $parametersReque
}
/**
- * Includes the class Piwik_UserSettings_API by looking up plugins/UserSettings/API.php
+ * Includes the class API by looking up plugins/UserSettings/API.php
*
- * @param string $fileName api class name eg. "Piwik_UserSettings_API"
+ * @param string $fileName api class name eg. "API"
* @throws Exception
*/
private function includeApiFile($fileName)
@@ -403,7 +401,7 @@ private function isMethodAvailable($className, $methodName)
private function checkClassIsSingleton($className)
{
if (!method_exists($className, "getInstance")) {
- throw new Exception("Objects that provide an API must be Singleton and have a 'static public function getInstance()' method.");
+ throw new Exception("$className that provide an API must be Singleton and have a 'static public function getInstance()' method.");
}
}
}
diff --git a/core/API/Request.php b/core/API/Request.php
index 91d664af56b..f627dd5f0bf 100644
--- a/core/API/Request.php
+++ b/core/API/Request.php
@@ -149,12 +149,12 @@ public function process()
if (!PluginsManager::getInstance()->isPluginActivated($module)) {
throw new PluginDeactivatedException($module);
}
- $moduleClass = "Piwik_" . $module . "_API";
+ $apiClassName = $this->getClassNameAPI($module);
self::reloadAuthUsingTokenAuth($this->request);
// call the method
- $returnedValue = Proxy::getInstance()->call($moduleClass, $method, $this->request);
+ $returnedValue = Proxy::getInstance()->call($apiClassName, $method, $this->request);
$toReturn = $response->getResponse($returnedValue, $module, $method);
} catch (Exception $e) {
@@ -163,6 +163,11 @@ public function process()
return $toReturn;
}
+ static public function getClassNameAPI($module)
+ {
+ return "\\Piwik\\Plugins\\$module\\API";
+ }
+
/**
* If the token_auth is found in the $request parameter,
* the current session will be authenticated using this token_auth.
diff --git a/core/Access.php b/core/Access.php
index 7f1f89c6167..48660808126 100644
--- a/core/Access.php
+++ b/core/Access.php
@@ -212,7 +212,7 @@ protected function reloadAccessSuperUser()
$this->isSuperUser = true;
try {
- $allSitesId = \Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $allSitesId = Plugins\SitesManager\API::getInstance()->getAllSitesId();
} catch(\Exception $e) {
$allSitesId = array();
}
diff --git a/core/AssetManager.php b/core/AssetManager.php
index ed64a1121bd..df3448126e7 100644
--- a/core/AssetManager.php
+++ b/core/AssetManager.php
@@ -133,7 +133,7 @@ private static function prepareMergedCssFile()
// Disable Merged Assets ==> Check on each request if file needs re-compiling
if ($mergedCssAlreadyGenerated
- && $isDevelopingPiwik
+ && !$isDevelopingPiwik
) {
$pathMerged = self::getAbsoluteMergedFileLocation(self::MERGED_CSS_FILE);
$f = fopen($pathMerged, 'r');
diff --git a/core/Common.php b/core/Common.php
index 0fbf8f8ddf9..2a1bae68d92 100644
--- a/core/Common.php
+++ b/core/Common.php
@@ -15,7 +15,7 @@
use Piwik\Tracker;
use Piwik\Tracker\Cache;
use Piwik\PluginsManager;
-use Piwik_UserCountry_LocationProvider_Default;
+use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider;
/**
* Static class providing functions used by both the CORE of Piwik and the visitor Tracking engine.
@@ -28,8 +28,6 @@
*/
class Common
{
- const CLASSES_PREFIX = 'Piwik_';
-
/**
* Const used to map the referer type to an integer in the log_visit table
*/
@@ -1554,26 +1552,10 @@ public static function getCurrentLocationProviderId()
{
$cache = Cache::getCacheGeneral();
return empty($cache['currentLocationProviderId'])
- ? Piwik_UserCountry_LocationProvider_Default::ID
+ ? DefaultProvider::ID
: $cache['currentLocationProviderId'];
}
- /**
- * Unprefix class name (if needed)
- *
- * @param string $class
- * @return string
- */
- public static function unprefixClass($class)
- {
- $lenPrefix = strlen(self::CLASSES_PREFIX);
- if (!strncmp($class, self::CLASSES_PREFIX, $lenPrefix)) {
- return substr($class, $lenPrefix);
- }
- return $class;
- }
-
-
/**
* Mark orphaned object for garbage collection
*
diff --git a/core/Controller.php b/core/Controller.php
index 9c1fe1519b0..dd122579bdb 100644
--- a/core/Controller.php
+++ b/core/Controller.php
@@ -21,13 +21,13 @@
use Piwik\Access;
use Piwik\Date;
use Piwik\Site;
-use Piwik_API_API;
+use Piwik\Plugins\API\API;
use Piwik\API\Request;
use Piwik\FrontController;
-use Piwik_LanguagesManager;
-use Piwik_SitesManager_API;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
use Piwik\Url;
-use Piwik_UsersManager_API;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
use Piwik\View;
use Piwik\ViewDataTable;
use Piwik\ViewDataTable\GenerateGraphHTML\ChartEvolution;
@@ -81,8 +81,9 @@ public function __construct()
protected function init()
{
- $aPluginName = explode('_', get_class($this));
- $this->pluginName = $aPluginName[1];
+ $aPluginName = explode('\\', get_class($this));
+ $this->pluginName = $aPluginName[2];
+
$date = Common::getRequestVar('date', 'yesterday', 'string');
try {
$this->idSite = Common::getRequestVar('idSite', false, 'int');
@@ -202,7 +203,7 @@ protected function getLastUnitGraphAcrossPlugins($currentModuleName, $currentCon
$idSite = Common::getRequestVar('idSite');
$period = Common::getRequestVar('period');
$date = Common::getRequestVar('date');
- $meta = Piwik_API_API::getInstance()->getReportMetadata($idSite, $period, $date);
+ $meta = API::getInstance()->getReportMetadata($idSite, $period, $date);
$columns = array_merge($columnsToDisplay, $selectableColumns);
$translations = array();
@@ -423,8 +424,8 @@ protected function setGeneralVariablesView($view)
$view->startDate = $dateStart;
$view->endDate = $dateEnd;
- $language = Piwik_LanguagesManager::getLanguageForSession();
- $view->language = !empty($language) ? $language : Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ $language = LanguagesManager::getLanguageForSession();
+ $view->language = !empty($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
$view->config_action_url_category_delimiter = Config::getInstance()->General['action_url_category_delimiter'];
@@ -447,10 +448,10 @@ protected function setBasicVariablesView($view)
$view->isSuperUser = Access::getInstance()->isSuperUser();
$view->hasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
$view->isCustomLogo = Config::getInstance()->branding['use_custom_logo'];
- $view->logoHeader = Piwik_API_API::getInstance()->getHeaderLogoUrl();
- $view->logoLarge = Piwik_API_API::getInstance()->getLogoUrl();
- $view->logoSVG = Piwik_API_API::getInstance()->getSVGLogoUrl();
- $view->hasSVGLogo = Piwik_API_API::getInstance()->hasSVGLogo();
+ $view->logoHeader = API::getInstance()->getHeaderLogoUrl();
+ $view->logoLarge = API::getInstance()->getLogoUrl();
+ $view->logoSVG = API::getInstance()->getSVGLogoUrl();
+ $view->hasSVGLogo = API::getInstance()->hasSVGLogo();
$view->enableFrames = Config::getInstance()->General['enable_framed_pages']
|| @Config::getInstance()->General['enable_framed_logins'];
@@ -669,7 +670,7 @@ protected function getDefaultWebsiteId()
$defaultWebsiteId = false;
// User preference: default website ID to load
- $defaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
+ $defaultReport = UsersManagerAPI::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), UsersManagerAPI::PREFERENCE_DEFAULT_REPORT);
if (is_numeric($defaultReport)) {
$defaultWebsiteId = $defaultReport;
}
@@ -680,7 +681,7 @@ protected function getDefaultWebsiteId()
return $defaultWebsiteId;
}
- $sitesId = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
+ $sitesId = SitesManagerAPI::getInstance()->getSitesIdWithAtLeastViewAccess();
if (!empty($sitesId)) {
return $sitesId[0];
}
@@ -695,7 +696,7 @@ protected function getDefaultWebsiteId()
protected function getDefaultDate()
{
// NOTE: a change in this function might mean a change in plugins/UsersManager/javascripts/usersSettings.js as well
- $userSettingsDate = Piwik_UsersManager_API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE);
+ $userSettingsDate = UsersManagerAPI::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), UsersManagerAPI::PREFERENCE_DEFAULT_REPORT_DATE);
if ($userSettingsDate == 'yesterday') {
return $userSettingsDate;
}
@@ -715,7 +716,7 @@ protected function getDefaultDate()
*/
protected function getDefaultPeriod()
{
- $userSettingsDate = Piwik_UsersManager_API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE);
+ $userSettingsDate = UsersManagerAPI::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), UsersManagerAPI::PREFERENCE_DEFAULT_REPORT_DATE);
if ($userSettingsDate === false) {
return Config::getInstance()->General['default_period'];
}
diff --git a/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php b/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php
index 92ad07185c5..d22c61a83fb 100644
--- a/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php
+++ b/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php
@@ -22,7 +22,7 @@
* You can also specify the precision of the percentage value to be displayed (defaults to 0, eg "11%")
*
* Usage:
- * $nbVisits = Piwik_VisitsSummary_API::getInstance()->getVisits($idSite, $period, $date);
+ * $nbVisits = API::getInstance()->getVisits($idSite, $period, $date);
* $dataTable->queueFilter('ColumnCallbackAddColumnPercentage', array('nb_visits', 'nb_visits_percentage', $nbVisits, 1));
*
* @package Piwik
diff --git a/core/DataTable/Renderer.php b/core/DataTable/Renderer.php
index bdec4b87ca6..0cefcc5f29a 100644
--- a/core/DataTable/Renderer.php
+++ b/core/DataTable/Renderer.php
@@ -299,7 +299,7 @@ protected function getApiMetaData()
$this->apiMetaData = false;
}
- $api = \Piwik_API_API::getInstance();
+ $api = \Piwik\Plugins\API\API::getInstance();
$meta = $api->getMetadata($this->idSite, $apiModule, $apiAction);
if (is_array($meta[0])) {
$meta = $meta[0];
diff --git a/core/Db/Schema.php b/core/Db/Schema.php
index 9064a6a9087..4a86ce97638 100644
--- a/core/Db/Schema.php
+++ b/core/Db/Schema.php
@@ -116,7 +116,7 @@ public static function getSchemas($adapterName)
$schemas = array();
foreach ($schemaNames as $schemaName) {
- $className = 'Piwik_Db_Schema_' . $schemaName;
+ $className = __NAMESPACE__ . '\\Schema\\' . $schemaName;
if (call_user_func(array($className, 'isAvailable'))) {
$schemas[] = $schemaName;
}
diff --git a/core/FrontController.php b/core/FrontController.php
index fc33f3eae25..5837256a556 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -99,7 +99,7 @@ public function dispatch($module = null, $action = null, $parameters = null)
throw new PluginDeactivatedException($module);
}
- $controllerClassName = 'Piwik_' . $module . '_Controller';
+ $controllerClassName = $this->getClassNameController( $module );
// FrontController's autoloader
if (!class_exists($controllerClassName, false)) {
@@ -110,7 +110,9 @@ public function dispatch($module = null, $action = null, $parameters = null)
require_once $moduleController; // prefixed by PIWIK_INCLUDE_PATH
}
- $controller = new $controllerClassName();
+ $class = $this->getClassNameController($module);
+ /** @var $controller Controller */
+ $controller = new $class;
if ($action === false) {
$action = $controller->getDefaultAction();
}
@@ -135,6 +137,11 @@ public function dispatch($module = null, $action = null, $parameters = null)
}
}
+ protected function getClassNameController($module)
+ {
+ return "\\Piwik\\Plugins\\$module\\Controller";
+ }
+
/**
* Often plugins controller display stuff using echo/print.
* Using this function instead of dispatch() returns the output string form the actions calls.
diff --git a/core/Loader.php b/core/Loader.php
index fc913112e93..927fbdc797f 100644
--- a/core/Loader.php
+++ b/core/Loader.php
@@ -46,7 +46,13 @@ protected static function getClassFileName($class)
return $class;
}
- $vendorPrefixToRemove = 'Piwik/';
+ $class = self::removePrefix($class, 'Piwik/');
+ $class = self::removePrefix($class, 'Plugins/');
+ return $class;
+ }
+
+ protected static function removePrefix($class, $vendorPrefixToRemove)
+ {
if (strpos($class, $vendorPrefixToRemove) === 0) {
return substr($class, strlen($vendorPrefixToRemove));
}
diff --git a/core/Menu/MenuAbstract.php b/core/Menu/MenuAbstract.php
index 5bb4adb39cb..a0fa8c4c2ba 100644
--- a/core/Menu/MenuAbstract.php
+++ b/core/Menu/MenuAbstract.php
@@ -11,7 +11,7 @@
namespace Piwik\Menu;
use Piwik\Common;
-use Piwik_SitesManager_API;
+use Piwik\Plugins\SitesManager\API;
/**
* @package Piwik_Menu
@@ -60,7 +60,7 @@ public function add($menuName, $subMenuName, $url, $displayedForCurrentUser, $or
if ($displayedForCurrentUser) {
// make sure the idSite value used is numeric (hack-y fix for #3426)
if (!is_numeric(Common::getRequestVar('idSite', false))) {
- $idSites = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
+ $idSites = API::getInstance()->getSitesIdWithAtLeastViewAccess();
$url['idSite'] = reset($idSites);
}
diff --git a/core/Period.php b/core/Period.php
index 3c04d543081..f846ef60065 100644
--- a/core/Period.php
+++ b/core/Period.php
@@ -19,16 +19,6 @@
use Piwik\Period\Year;
/**
- * Creating a new Period subclass:
- *
- * Every overloaded method must start with the code
- * if(!$this->subperiodsProcessed)
- * {
- * $this->generate();
- * }
- * 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
* @subpackage Period
*/
@@ -174,6 +164,7 @@ public function getDateStart()
return $this->getDate();
}
$periods = $this->getSubperiods();
+ /** @var $currentPeriod Period */
$currentPeriod = $periods[0];
while ($currentPeriod->getNumberOfSubperiods() > 0) {
$periods = $currentPeriod->getSubperiods();
@@ -196,6 +187,7 @@ public function getDateEnd()
return $this->getDate();
}
$periods = $this->getSubperiods();
+ /** @var $currentPeriod Period */
$currentPeriod = $periods[count($periods) - 1];
while ($currentPeriod->getNumberOfSubperiods() > 0) {
$periods = $currentPeriod->getSubperiods();
diff --git a/core/Piwik.php b/core/Piwik.php
index de54f033ad7..7dff9430aa7 100644
--- a/core/Piwik.php
+++ b/core/Piwik.php
@@ -24,7 +24,7 @@
use Piwik\Tracker\Cache;
use Piwik\Tracker\GoalManager;
use Piwik\Url;
-use Piwik_UsersManager_API;
+use Piwik\Plugins\UsersManager\API;
use Piwik\View;
use Piwik\Log\ScreenFormatter;
use Zend_Registry;
@@ -1572,7 +1572,7 @@ static public function getKnownSegmentsToArchiveForSite($idSite)
static public function getCurrentUserEmail()
{
if (!Piwik::isUserIsSuperUser()) {
- $user = Piwik_UsersManager_API::getInstance()->getUser(Piwik::getCurrentUserLogin());
+ $user = API::getInstance()->getUser(Piwik::getCurrentUserLogin());
return $user['email'];
}
return self::getSuperUserEmail();
diff --git a/core/Plugin.php b/core/Plugin.php
index 578d38c5f5c..756d4ae4f3c 100644
--- a/core/Plugin.php
+++ b/core/Plugin.php
@@ -48,7 +48,8 @@ class Plugin
public function __construct($pluginName = false)
{
if (empty($pluginName)) {
- $pluginName = Common::unprefixClass(get_class($this));
+ $pluginName = explode('\\', get_class($this));
+ $pluginName = end($pluginName);
}
$this->pluginName = $pluginName;
@@ -162,7 +163,7 @@ final public function isTheme()
/**
* Returns the plugin's base class name without the "Piwik_" prefix,
- * e.g., "UserCountry" when the plugin class is "Piwik_UserCountry"
+ * e.g., "UserCountry" when the plugin class is "UserCountry"
*
* @return string
*/
diff --git a/core/PluginsArchiver.php b/core/PluginsArchiver.php
index dd49ba37e7c..eb3b24592d2 100644
--- a/core/PluginsArchiver.php
+++ b/core/PluginsArchiver.php
@@ -36,8 +36,8 @@ abstract public function archivePeriod();
// todo: review this concept, each plugin should somehow maintain the list of report names they generate
public function shouldArchive()
{
- $pluginName = Common::unprefixClass(get_class($this));
- $pluginName = str_replace("_Archiver", "", $pluginName);
+ $className = get_class($this);
+ $pluginName = str_replace(array("\\Piwik\\Plugins\\", "\\Archiver"), "", $className);
return $this->getProcessor()->shouldProcessReportsForPlugin($pluginName);
}
diff --git a/core/PluginsManager.php b/core/PluginsManager.php
index 0626db36a37..b4af8fbac07 100644
--- a/core/PluginsManager.php
+++ b/core/PluginsManager.php
@@ -399,13 +399,13 @@ public function postLoadPlugins()
}
/**
- * Returns an array containing the plugins class names (eg. 'Piwik_UserCountry' and NOT 'UserCountry')
+ * Returns an array containing the plugins class names (eg. 'UserCountry' and NOT 'UserCountry')
*
* @return array
*/
public function getLoadedPluginsName()
{
- return array_map('get_class', $this->getLoadedPlugins());
+ return array_keys($this->getLoadedPlugins());
}
/**
@@ -460,7 +460,7 @@ private function reloadPlugins()
/**
* Loads the plugin filename and instantiates the plugin with the given name, eg. UserCountry
- * Do NOT give the class name ie. Piwik_UserCountry, but give the plugin name ie. UserCountry
+ * Do NOT give the class name ie. UserCountry, but give the plugin name ie. UserCountry
*
* @param string $pluginName
* @throws \Exception
@@ -488,7 +488,7 @@ public function loadPlugin($pluginName)
protected function makePluginClass($pluginName)
{
$pluginFileName = sprintf("%s/%s.php", $pluginName, $pluginName);
- $pluginClassName = sprintf('Piwik_%s', $pluginName);
+ $pluginClassName = $pluginName;
if (!Common::isValidFilename($pluginName)) {
throw new \Exception(sprintf("The plugin filename '%s' is not a valid filename", $pluginFileName));
@@ -504,10 +504,11 @@ protected function makePluginClass($pluginName)
require_once $path;
- if (!class_exists($pluginClassName, false)) {
+ $namespacedClass = $this->getClassNamePlugin($pluginName);
+ if(!class_exists($namespacedClass, false)) {
throw new \Exception("The class $pluginClassName couldn't be found in the file '$path'");
}
- $newPlugin = new $pluginClassName();
+ $newPlugin = new $namespacedClass;
if (!($newPlugin instanceof Plugin)) {
throw new \Exception("The plugin $pluginClassName in the file $path must inherit from Plugin.");
@@ -515,6 +516,15 @@ protected function makePluginClass($pluginName)
return $newPlugin;
}
+ protected function getClassNamePlugin($pluginName)
+ {
+ $className = $pluginName;
+ if($pluginName == 'API') {
+ $className = 'Plugin';
+ }
+ return "\\Piwik\\Plugins\\$pluginName\\$className";
+ }
+
/**
* Unload plugin
*
@@ -663,6 +673,7 @@ private function installPluginIfNecessary(Plugin $plugin)
// is the plugin already installed or is it the first time we activate it?
$pluginsInstalled = $this->getInstalledPluginsName();
+
if (!in_array($pluginName, $pluginsInstalled)) {
$this->installPlugin($plugin);
$pluginsInstalled[] = $pluginName;
diff --git a/core/ReportRenderer.php b/core/ReportRenderer.php
index d2d51f1425f..f7249352097 100644
--- a/core/ReportRenderer.php
+++ b/core/ReportRenderer.php
@@ -17,7 +17,7 @@
use Piwik\DataTable;
use Piwik\Loader;
use Piwik\API\Request;
-use Piwik_ImageGraph_API;
+use Piwik\Plugins\ImageGraph\API;
/**
* A Report Renderer produces user friendly renderings of any given Piwik report.
@@ -122,7 +122,7 @@ abstract public function renderFrontPage($reportTitle, $prettyDate, $description
* Render the provided report.
* Multiple calls to this method before calling outputRendering appends each report content.
*
- * @param array $processedReport @see Piwik_API_API::getProcessedReport()
+ * @param array $processedReport @see API::getProcessedReport()
*/
abstract public function renderReport($processedReport);
@@ -235,7 +235,7 @@ public static function getStaticGraph($reportMetadata, $width, $height, $evoluti
}
$requestGraph = $imageGraphUrl .
- '&outputType=' . Piwik_ImageGraph_API::GRAPH_OUTPUT_PHP .
+ '&outputType=' . API::GRAPH_OUTPUT_PHP .
'&format=original&serialize=0' .
'&filter_truncate=' .
'&width=' . $width .
diff --git a/core/ReportRenderer/Html.php b/core/ReportRenderer/Html.php
index e1d30734c4f..cb8d33faa03 100644
--- a/core/ReportRenderer/Html.php
+++ b/core/ReportRenderer/Html.php
@@ -13,7 +13,7 @@
use Piwik\Piwik;
use Piwik\View;
use Piwik\ReportRenderer;
-use Piwik_API_API;
+use Piwik\Plugins\API\API;
/**
*
@@ -121,7 +121,7 @@ private function assignCommonParameters(View $view)
$view->assign("reportTableRowTextSize", self::REPORT_TABLE_ROW_TEXT_SIZE);
$view->assign("reportBackToTopTextSize", self::REPORT_BACK_TO_TOP_TEXT_SIZE);
$view->assign("currentPath", Piwik::getPiwikUrl());
- $view->assign("logoHeader", Piwik_API_API::getInstance()->getHeaderLogoUrl());
+ $view->assign("logoHeader", API::getInstance()->getHeaderLogoUrl());
}
public function renderReport($processedReport)
diff --git a/core/ReportRenderer/Pdf.php b/core/ReportRenderer/Pdf.php
index 192a7f91330..c3ab722e27c 100644
--- a/core/ReportRenderer/Pdf.php
+++ b/core/ReportRenderer/Pdf.php
@@ -13,7 +13,7 @@
use Piwik\Common;
use Piwik\TCPDF;
use Piwik\ReportRenderer;
-use Piwik_API_API;
+use Piwik\Plugins\API\API;
/**
* @see libs/tcpdf
@@ -166,7 +166,7 @@ public function renderFrontPage($reportTitle, $prettyDate, $description, $report
$this->TCPDF->Bookmark(Piwik_Translate('PDFReports_FrontPage'));
// logo
- $this->TCPDF->Image(Piwik_API_API::getInstance()->getLogoUrl(true), $this->logoImagePosition[0], $this->logoImagePosition[1], 180 / $factor = 2, 0, $type = '', $link = '', $align = '', $resize = false, $dpi = 300);
+ $this->TCPDF->Image(API::getInstance()->getLogoUrl(true), $this->logoImagePosition[0], $this->logoImagePosition[1], 180 / $factor = 2, 0, $type = '', $link = '', $align = '', $resize = false, $dpi = 300);
$this->TCPDF->Ln(8);
// report title
diff --git a/core/ScheduledTask.php b/core/ScheduledTask.php
index 8d9c368c54d..5262e7cbc38 100644
--- a/core/ScheduledTask.php
+++ b/core/ScheduledTask.php
@@ -66,7 +66,7 @@ class ScheduledTask
function __construct($_objectInstance, $_methodName, $_methodParameter, $_scheduledTime, $_priority = self::NORMAL_PRIORITY)
{
- $this->className = get_class($_objectInstance);
+ $this->className = $this->getClassNameFromInstance($_objectInstance);
if ($_priority < self::HIGHEST_PRIORITY || $_priority > self::LOWEST_PRIORITY) {
throw new Exception("Invalid priority for ScheduledTask '$this->className.$_methodName': $_priority");
@@ -79,6 +79,13 @@ function __construct($_objectInstance, $_methodName, $_methodParameter, $_schedu
$this->priority = $_priority;
}
+ protected function getClassNameFromInstance($_objectInstance)
+ {
+ $namespaced = get_class($_objectInstance);
+ $class = explode('\\', $namespaced);
+ return end($class);
+ }
+
/**
* Return the object instance on which the method should be executed
* @return string
diff --git a/core/Segment.php b/core/Segment.php
index cfc82c86e70..8687362a56b 100644
--- a/core/Segment.php
+++ b/core/Segment.php
@@ -12,7 +12,7 @@
use Exception;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik_API_API;
+use Piwik\Plugins\API\API;
use Piwik\SegmentExpression;
/**
@@ -90,7 +90,7 @@ public function isEmpty()
protected function getCleanedExpression($expression)
{
if (empty($this->availableSegments)) {
- $this->availableSegments = Piwik_API_API::getInstance()->getSegmentsMetadata($this->idSites, $_hideImplementationData = false);
+ $this->availableSegments = API::getInstance()->getSegmentsMetadata($this->idSites, $_hideImplementationData = false);
}
$name = $expression[0];
@@ -121,7 +121,7 @@ protected function getCleanedExpression($expression)
$value = call_user_func($segment['sqlFilter'], $value, $segment['sqlSegment'], $matchType, $name);
// sqlFilter-callbacks might return arrays for more complex cases
- // e.g. see Piwik_Actions::getIdActionFromSegment()
+ // e.g. see Actions::getIdActionFromSegment()
if (is_array($value)
&& isset($value['SQL'])
) {
diff --git a/core/Site.php b/core/Site.php
index b0824e77eee..eb13215e342 100644
--- a/core/Site.php
+++ b/core/Site.php
@@ -12,7 +12,7 @@
namespace Piwik;
use Exception;
use Piwik\Date;
-use Piwik_SitesManager_API;
+use Piwik\Plugins\SitesManager\API;
/**
*
@@ -37,7 +37,7 @@ function __construct($idsite)
{
$this->id = (int)$idsite;
if (!isset(self::$infoSites[$this->id])) {
- self::$infoSites[$this->id] = Piwik_SitesManager_API::getInstance()->getSiteFromId($this->id);
+ self::$infoSites[$this->id] = API::getInstance()->getSiteFromId($this->id);
}
}
@@ -215,7 +215,7 @@ function isSiteSearchEnabled()
static public function getIdSitesFromIdSitesString($ids, $_restrictSitesToLogin = false)
{
if ($ids === 'all') {
- return Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess($_restrictSitesToLogin);
+ return API::getInstance()->getSitesIdWithAtLeastViewAccess($_restrictSitesToLogin);
}
if (!is_array($ids)) {
@@ -256,7 +256,7 @@ static protected function getFor($idsite, $field)
$idsite = (int)$idsite;
if (!isset(self::$infoSites[$idsite])) {
- self::$infoSites[$idsite] = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
+ self::$infoSites[$idsite] = API::getInstance()->getSiteFromId($idsite);
}
return self::$infoSites[$idsite][$field];
diff --git a/core/Tracker/Cache.php b/core/Tracker/Cache.php
index 1e6423d8f6b..7319818e412 100644
--- a/core/Tracker/Cache.php
+++ b/core/Tracker/Cache.php
@@ -15,7 +15,7 @@
use Piwik\Piwik;
use Piwik\CacheFile;
use Piwik\Tracker;
-use Piwik_UserCountry_LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider;
/**
* Simple cache mechanism used in Tracker to avoid requesting settings from mysql on every request
@@ -104,7 +104,7 @@ static public function getCacheGeneral()
$cacheContent = array(
'isBrowserTriggerEnabled' => Rules::isBrowserTriggerEnabled(),
'lastTrackerCronRun' => Piwik_GetOption('lastTrackerCronRun'),
- 'currentLocationProviderId' => Piwik_UserCountry_LocationProvider::getCurrentProviderId(),
+ 'currentLocationProviderId' => LocationProvider::getCurrentProviderId(),
);
self::setCacheGeneral($cacheContent);
return $cacheContent;
diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php
index 668d23fa1e6..e52e89424a3 100644
--- a/core/Tracker/Request.php
+++ b/core/Tracker/Request.php
@@ -8,7 +8,7 @@
use Piwik\IP;
use Piwik\Tracker;
use Piwik\Tracker\Cache;
-use Piwik_UserCountry_LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider;
/**
* Piwik - Open source web analytics
@@ -27,6 +27,8 @@ class Request
*/
protected $params;
+ protected $forcedVisitorId = false;
+
public function __construct($params, $tokenAuth = false)
{
if (!is_array($params)) {
@@ -434,7 +436,9 @@ public function getIp()
public function setForceIp($ip)
{
- $this->enforcedIp = $ip;
+ if(!empty($ip)) {
+ $this->enforcedIp = $ip;
+ }
}
public function setForceDateTime($dateTime)
@@ -442,12 +446,16 @@ public function setForceDateTime($dateTime)
if (!is_numeric($dateTime)) {
$dateTime = strtotime($dateTime);
}
- $this->timestamp = $dateTime;
+ if(!empty($dateTime)) {
+ $this->timestamp = $dateTime;
+ }
}
public function setForcedVisitorId($visitorId)
{
- $this->forcedVisitorId = $visitorId;
+ if(!empty($visitorId)) {
+ $this->forcedVisitorId = $visitorId;
+ }
}
public function getForcedVisitorId()
@@ -463,11 +471,11 @@ public function enrichLocation($location)
// check for location override query parameters (ie, lat, long, country, region, city)
$locationOverrideParams = array(
- 'country' => array('string', Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY),
- 'region' => array('string', Piwik_UserCountry_LocationProvider::REGION_CODE_KEY),
- 'city' => array('string', Piwik_UserCountry_LocationProvider::CITY_NAME_KEY),
- 'lat' => array('float', Piwik_UserCountry_LocationProvider::LATITUDE_KEY),
- 'long' => array('float', Piwik_UserCountry_LocationProvider::LONGITUDE_KEY),
+ 'country' => array('string', LocationProvider::COUNTRY_CODE_KEY),
+ 'region' => array('string', LocationProvider::REGION_CODE_KEY),
+ 'city' => array('string', LocationProvider::CITY_NAME_KEY),
+ 'lat' => array('float', LocationProvider::LATITUDE_KEY),
+ 'long' => array('float', LocationProvider::LONGITUDE_KEY),
);
foreach ($locationOverrideParams as $queryParamName => $info) {
list($type, $locationResultKey) = $info;
diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php
index 3590b4c3194..91219363397 100644
--- a/core/Tracker/Visit.php
+++ b/core/Tracker/Visit.php
@@ -32,7 +32,7 @@ function handle();
use Piwik\Tracker\Referrer;
use Exception;
use Piwik\Tracker\VisitExcluded;
-use Piwik_UserCountry_LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider;
use UserAgentParser;
/**
@@ -504,7 +504,7 @@ static private function cleanupVisitTotalTime($t)
* Returns the location of the visitor, based on the visitor's IP and browser language.
*
* @param string $browserLang
- * @return array See Piwik_UserCountry_LocationProvider::getLocation for more info.
+ * @return array See LocationProvider::getLocation for more info.
*/
private function getVisitorLocation($browserLang)
{
@@ -525,19 +525,19 @@ private function getVisitorLocation($browserLang)
/**
* Sets visitor info array with location info.
*
- * @param array $location See Piwik_UserCountry_LocationProvider::getLocation for more info.
+ * @param array $location See LocationProvider::getLocation for more info.
*/
private function updateVisitInfoWithLocation($location)
{
static $logVisitToLowerLocationMapping = array(
- 'location_country' => Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY,
+ 'location_country' => LocationProvider::COUNTRY_CODE_KEY,
);
static $logVisitToLocationMapping = array(
- 'location_region' => Piwik_UserCountry_LocationProvider::REGION_CODE_KEY,
- 'location_city' => Piwik_UserCountry_LocationProvider::CITY_NAME_KEY,
- 'location_latitude' => Piwik_UserCountry_LocationProvider::LATITUDE_KEY,
- 'location_longitude' => Piwik_UserCountry_LocationProvider::LONGITUDE_KEY,
+ 'location_region' => LocationProvider::REGION_CODE_KEY,
+ 'location_city' => LocationProvider::CITY_NAME_KEY,
+ 'location_latitude' => LocationProvider::LATITUDE_KEY,
+ 'location_longitude' => LocationProvider::LONGITUDE_KEY,
);
foreach ($logVisitToLowerLocationMapping as $column => $locationKey) {
@@ -553,17 +553,17 @@ private function updateVisitInfoWithLocation($location)
}
// if the location has provider/organization info, set it
- if (!empty($location[Piwik_UserCountry_LocationProvider::ISP_KEY])) {
- $providerValue = $location[Piwik_UserCountry_LocationProvider::ISP_KEY];
+ if (!empty($location[LocationProvider::ISP_KEY])) {
+ $providerValue = $location[LocationProvider::ISP_KEY];
// if the org is set and not the same as the isp, add it to the provider value
- if (!empty($location[Piwik_UserCountry_LocationProvider::ORG_KEY])
- && $location[Piwik_UserCountry_LocationProvider::ORG_KEY] != $providerValue
+ if (!empty($location[LocationProvider::ORG_KEY])
+ && $location[LocationProvider::ORG_KEY] != $providerValue
) {
- $providerValue .= ' - ' . $location[Piwik_UserCountry_LocationProvider::ORG_KEY];
+ $providerValue .= ' - ' . $location[LocationProvider::ORG_KEY];
}
- } else if (!empty($location[Piwik_UserCountry_LocationProvider::ORG_KEY])) {
- $providerValue = $location[Piwik_UserCountry_LocationProvider::ORG_KEY];
+ } else if (!empty($location[LocationProvider::ORG_KEY])) {
+ $providerValue = $location[LocationProvider::ORG_KEY];
}
if (isset($providerValue)) {
diff --git a/core/Twig.php b/core/Twig.php
index 5a316c65ce0..ae79b90e89d 100644
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -11,6 +11,7 @@
namespace Piwik;
use Exception;
+use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\AssetManager;
@@ -230,7 +231,6 @@ private function addPluginNamespaces(Twig_Loader_Filesystem $loader)
{
$plugins = PluginsManager::getInstance()->getLoadedPluginsName();
foreach ($plugins as $name) {
- $name = Common::unprefixClass($name);
$path = sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, $name);
if (is_dir($path)) {
$loader->addPath(PIWIK_INCLUDE_PATH . '/plugins/' . $name . '/templates', $name);
diff --git a/core/UpdateCheck.php b/core/UpdateCheck.php
index 2c301246765..29261f8341d 100644
--- a/core/UpdateCheck.php
+++ b/core/UpdateCheck.php
@@ -14,7 +14,7 @@
use Piwik\Config;
use Piwik\Common;
use Piwik\Http;
-use Piwik_SitesManager_API;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Url;
use Piwik\Version;
@@ -55,7 +55,7 @@ public static function check($force = false, $interval = null)
'php_version' => PHP_VERSION,
'url' => Url::getCurrentUrlWithoutQueryString(),
'trigger' => Common::getRequestVar('module', '', 'string'),
- 'timezone' => Piwik_SitesManager_API::getInstance()->getDefaultTimezone(),
+ 'timezone' => API::getInstance()->getDefaultTimezone(),
);
$url = Config::getInstance()->General['api_service_url']
diff --git a/core/Updater.php b/core/Updater.php
index 740bb2e031b..b6b13de4c67 100644
--- a/core/Updater.php
+++ b/core/Updater.php
@@ -138,6 +138,7 @@ public function getSqlQueriesToExecute()
private function getUpdateClassName($componentName, $fileVersion)
{
+ ////unprefixClass TODOA FIXME
$suffix = strtolower(str_replace(array('-', '.'), '_', $fileVersion));
if ($componentName == 'core') {
return 'Piwik_Updates_' . $suffix;
diff --git a/core/Updates/0.2.34.php b/core/Updates/0.2.34.php
index 785627f8752..5ad44f5268e 100644
--- a/core/Updates/0.2.34.php
+++ b/core/Updates/0.2.34.php
@@ -9,6 +9,7 @@
* @package Updates
*/
use Piwik\Piwik;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Tracker\Cache;
use Piwik\Updates;
@@ -21,7 +22,7 @@ static function update($schema = 'Myisam')
{
// force regeneration of cache files following #648
Piwik::setUserIsSuperUser();
- $allSiteIds = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $allSiteIds = API::getInstance()->getAllSitesId();
Cache::regenerateCacheWebsiteAttributes($allSiteIds);
}
}
diff --git a/core/Updates/0.6.2.php b/core/Updates/0.6.2.php
index 74bbe6b6b62..af541713a23 100644
--- a/core/Updates/0.6.2.php
+++ b/core/Updates/0.6.2.php
@@ -9,6 +9,7 @@
* @package Updates
*/
use Piwik\Piwik;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Tracker\Cache;
use Piwik\Updates;
@@ -39,7 +40,7 @@ static function update()
// force regeneration of cache files
Piwik::setUserIsSuperUser();
- $allSiteIds = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $allSiteIds = API::getInstance()->getAllSitesId();
Cache::regenerateCacheWebsiteAttributes($allSiteIds);
}
}
diff --git a/core/Updates/1.8.3-b1.php b/core/Updates/1.8.3-b1.php
index 84d9ce56d54..f217635ebca 100644
--- a/core/Updates/1.8.3-b1.php
+++ b/core/Updates/1.8.3-b1.php
@@ -9,6 +9,7 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Plugins\PDFReports\PDFReports;
use Piwik\Updater;
use Piwik\Updates;
use Piwik\Db;
@@ -78,11 +79,11 @@ static function update()
$parameters = array();
if (!is_null($additional_emails)) {
- $parameters[Piwik_PDFReports::ADDITIONAL_EMAILS_PARAMETER] = preg_split('/,/', $additional_emails);
+ $parameters[PDFReports::ADDITIONAL_EMAILS_PARAMETER] = preg_split('/,/', $additional_emails);
}
- $parameters[Piwik_PDFReports::EMAIL_ME_PARAMETER] = is_null($email_me) ? Piwik_PDFReports::EMAIL_ME_PARAMETER_DEFAULT_VALUE : (bool)$email_me;
- $parameters[Piwik_PDFReports::DISPLAY_FORMAT_PARAMETER] = $display_format;
+ $parameters[PDFReports::EMAIL_ME_PARAMETER] = is_null($email_me) ? PDFReports::EMAIL_ME_PARAMETER_DEFAULT_VALUE : (bool)$email_me;
+ $parameters[PDFReports::DISPLAY_FORMAT_PARAMETER] = $display_format;
Db::query(
'INSERT INTO `' . Common::prefixTable('report') . '` SET
@@ -94,9 +95,9 @@ static function update()
$idsite,
$login,
$description,
- is_null($period) ? Piwik_PDFReports::DEFAULT_PERIOD : $period,
- Piwik_PDFReports::EMAIL_TYPE,
- is_null($format) ? Piwik_PDFReports::DEFAULT_REPORT_FORMAT : $format,
+ is_null($period) ? PDFReports::DEFAULT_PERIOD : $period,
+ PDFReports::EMAIL_TYPE,
+ is_null($format) ? PDFReports::DEFAULT_REPORT_FORMAT : $format,
Common::json_encode(preg_split('/,/', $reports)),
Common::json_encode($parameters),
$ts_created,
diff --git a/core/View.php b/core/View.php
index e765791b72f..9d221c9d9cb 100644
--- a/core/View.php
+++ b/core/View.php
@@ -20,8 +20,8 @@
use Piwik\UpdateCheck;
use Piwik\Twig;
use Piwik\QuickForm2;
-use Piwik_SitesManager_API;
-use Piwik_UsersManager_API;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
use Piwik\View\ViewInterface;
use Twig_Environment;
use Zend_Registry;
@@ -110,7 +110,7 @@ public function render()
$count = Piwik::getWebsitesCountToDisplay();
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess($count);
+ $sites = SitesManagerAPI::getInstance()->getSitesWithAtLeastViewAccess($count);
usort($sites, create_function('$site1, $site2', 'return strcasecmp($site1["name"], $site2["name"]);'));
$this->sites = $sites;
$this->url = Common::sanitizeInputValue(Url::getCurrentUrl());
@@ -128,7 +128,7 @@ public function render()
$this->loginModule = Piwik::getLoginPluginName();
- $user = Piwik_UsersManager_API::getInstance()->getUser($userLogin);
+ $user = UsersManagerAPI::getInstance()->getUser($userLogin);
$this->userAlias = $user['alias'];
} catch (Exception $e) {
// can fail, for example at installation (no plugin loaded yet)
diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php
index 386d41e6cb5..e6ee1289be7 100644
--- a/core/ViewDataTable.php
+++ b/core/ViewDataTable.php
@@ -13,6 +13,7 @@
use Piwik\Config;
use Piwik\Metrics;
use Piwik\Period;
+use Piwik\API\Request;
use Piwik\Period\Range;
use Piwik\Piwik;
use Piwik\Common;
@@ -22,7 +23,7 @@
use Piwik\Site;
use Piwik\ViewDataTable\Properties;
use Piwik\ViewDataTable\VisualizationPropertiesProxy;
-use Piwik_API_API;
+use Piwik\Plugins\API\API;
/**
* This class is used to load (from the API) and customize the output of a given DataTable.
@@ -610,7 +611,7 @@ protected function loadDataTableFromAPI()
$requestArray = $this->getRequestArray();
// we make the request to the API
- $request = new API\Request($requestArray);
+ $request = new Request($requestArray);
// and get the DataTable structure
$dataTable = $request->process();
@@ -699,13 +700,13 @@ protected function postDataTableLoadedFromAPI()
if (!$this->areGenericFiltersDisabled()) {
// Second, generic filters (Sort, Limit, Replace Column Names, etc.)
$requestArray = $this->getRequestArray();
- $request = API\Request::getRequestArrayFromString($requestArray);
+ $request = Request::getRequestArrayFromString($requestArray);
if ($this->viewProperties['enable_sort'] === false) {
$request['filter_sort_column'] = $request['filter_sort_order'] = '';
}
- $genericFilter = new API\DataTableGenericFilter($request);
+ $genericFilter = new \Piwik\API\DataTableGenericFilter($request);
$genericFilter->filter($this->dataTable);
}
@@ -815,7 +816,7 @@ protected function getRequestArray()
}
}
- $segment = \Piwik\API\Request::getRawSegmentFromRequest();
+ $segment = Request::getRawSegmentFromRequest();
if(!empty($segment)) {
$requestArray['segment'] = $segment;
}
@@ -848,7 +849,7 @@ protected function getJavascriptVariablesToSet()
// build javascript variables to set
$javascriptVariablesToSet = array();
- $genericFilters = API\DataTableGenericFilter::getGenericFiltersInformation();
+ $genericFilters = \Piwik\API\DataTableGenericFilter::getGenericFiltersInformation();
foreach ($genericFilters as $filter) {
foreach ($filter as $filterVariableName => $filterInfo) {
// if there is a default value for this filter variable we set it
@@ -938,7 +939,7 @@ protected function getJavascriptVariablesToSet()
}
}
- $rawSegment = \Piwik\API\Request::getRawSegmentFromRequest();
+ $rawSegment = Request::getRawSegmentFromRequest();
if(!empty($rawSegment)) {
$javascriptVariablesToSet['segment'] = $rawSegment;
}
@@ -982,7 +983,7 @@ private function loadDocumentation()
{
$this->viewProperties['metrics_documentation'] = array();
- $report = Piwik_API_API::getInstance()->getMetadata(0, $this->currentControllerName, $this->currentControllerAction);
+ $report = API::getInstance()->getMetadata(0, $this->currentControllerName, $this->currentControllerAction);
$report = $report[0];
if (isset($report['metricsDocumentation'])) {
@@ -1096,8 +1097,9 @@ public function hasReportBeenPurged()
$reportYear = $reportDate->toString('Y');
$reportMonth = $reportDate->toString('m');
- if (class_exists('Piwik_PrivacyManager')
- && \Piwik_PrivacyManager::shouldReportBePurged($reportYear, $reportMonth)
+ //TODOA
+ if (class_exists('Piwik\Plugins\PrivacyManager\PrivacyManager')
+ && Plugins\PrivacyManager\PrivacyManager::shouldReportBePurged($reportYear, $reportMonth)
) {
return true;
}
@@ -1117,7 +1119,7 @@ public function hasReportBeenPurged()
private function getBaseReportUrl($module, $action, $queryParams = array())
{
$params = array_merge($queryParams, array('module' => $module, 'action' => $action));
- return API\Request::getCurrentUrlWithoutGenericFilters($params);
+ return Request::getCurrentUrlWithoutGenericFilters($params);
}
/**
@@ -1131,9 +1133,10 @@ private function getBaseReportUrl($module, $action, $queryParams = array())
*/
static public function renderReport($pluginName, $apiAction, $fetch = true)
{
- $apiClassName = 'Piwik_' . $pluginName . '_API';
- if (!method_exists($apiClassName::getInstance(), $apiAction)) {
- throw new \Exception("Invalid action name '$apiAction' for '$pluginName' plugin.");
+ //TODOA
+ $namespacedApiClassName = "\\Piwik\\Plugins\\$pluginName\\API";
+ if (!method_exists($namespacedApiClassName::getInstance(), $apiAction)) {
+ throw new \Exception("$namespacedApiClassName Invalid action name '$apiAction' for '$pluginName' plugin.");
}
$view = self::factory(null, $pluginName.'.'.$apiAction);
@@ -1263,4 +1266,4 @@ private function setPropertyDefaults($defaultValues)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/core/ViewDataTable/HtmlTable/Goals.php b/core/ViewDataTable/HtmlTable/Goals.php
index 414e78d6bac..88f3ab4b1a9 100644
--- a/core/ViewDataTable/HtmlTable/Goals.php
+++ b/core/ViewDataTable/HtmlTable/Goals.php
@@ -15,7 +15,7 @@
use Piwik\Site;
use Piwik\ViewDataTable\HtmlTable;
use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal;
-use Piwik_Goals_API;
+use Piwik\Plugins\Goals\API;
/**
* @package Piwik
@@ -197,7 +197,7 @@ protected function overrideViewProperties()
$goals = array();
$idSite = $this->getIdSite();
if ($idSite) {
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
$ecommerceGoal = array(
'idgoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER,
diff --git a/misc/cron/archive.php b/misc/cron/archive.php
index 1f63c26ebf5..cf6d2a5e448 100644
--- a/misc/cron/archive.php
+++ b/misc/cron/archive.php
@@ -6,6 +6,8 @@
use Piwik\Date;
use Piwik\FrontController;
use Piwik\Http;
+use Piwik\Plugins\CoreAdminHome\API as CoreAdminHomeAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
use Piwik\Version;
use Piwik\Url;
use Piwik\Timer;
@@ -327,13 +329,13 @@ public function run()
// Remove this website from the list of websites to be invalidated
// since it's now just been re-processing the reports, job is done!
if ($websiteIsOldDataInvalidate) {
- $websiteIdsInvalidated = Piwik_CoreAdminHome_API::getWebsiteIdsToInvalidate();
+ $websiteIdsInvalidated = CoreAdminHomeAPI::getWebsiteIdsToInvalidate();
if (count($websiteIdsInvalidated)) {
$found = array_search($idsite, $websiteIdsInvalidated);
if ($found !== false) {
unset($websiteIdsInvalidated[$found]);
// $this->log("Websites left to invalidate: " . implode(", ", $websiteIdsInvalidated));
- Piwik_SetOption(Piwik_CoreAdminHome_API::OPTION_INVALIDATED_IDSITES, serialize($websiteIdsInvalidated));
+ Piwik_SetOption(CoreAdminHomeAPI::OPTION_INVALIDATED_IDSITES, serialize($websiteIdsInvalidated));
}
}
}
@@ -394,8 +396,8 @@ public function run()
private function initSegmentsToArchive()
{
-// Fetching segments to process
- $this->segments = Piwik_CoreAdminHome_API::getInstance()->getKnownSegmentsToArchive();
+ // Fetching segments to process
+ $this->segments = CoreAdminHomeAPI::getInstance()->getKnownSegmentsToArchive();
if (empty($this->segments)) $this->segments = array();
if (!empty($this->segments)) {
$this->log("- Will pre-process " . count($this->segments) . " Segments for each website and each period: " . implode(", ", $this->segments));
@@ -720,7 +722,7 @@ private function initStateFromParameters()
// Fetching websites to process
private function initWebsitesToProcess()
{
- $this->allWebsites = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $this->allWebsites = SitesManagerAPI::getInstance()->getAllSitesId();
if ($this->shouldArchiveAllWebsites) {
$this->websites = $this->allWebsites;
@@ -734,7 +736,7 @@ private function initWebsitesToProcess()
. Piwik::getPrettyTimeFromSeconds($this->firstRunActiveWebsitesWithTraffic, true, false)
);
}
- $this->websites = Piwik_SitesManager_API::getInstance()->getSitesIdWithVisits($timestampActiveTraffic);
+ $this->websites = SitesManagerAPI::getInstance()->getSitesIdWithVisits($timestampActiveTraffic);
$websiteIds = !empty($this->websites) ? ", IDs: " . implode(", ", $this->websites) : "";
$prettySeconds = Piwik::getPrettyTimeFromSeconds(empty($this->timeLastCompleted)
? $this->firstRunActiveWebsitesWithTraffic
@@ -747,7 +749,7 @@ private function initWebsitesToProcess()
// 2) All websites that had reports in the past invalidated recently
// eg. when using Python log import script
- $this->idSitesInvalidatedOldReports = Piwik_CoreAdminHome_API::getWebsiteIdsToInvalidate();
+ $this->idSitesInvalidatedOldReports = CoreAdminHomeAPI::getWebsiteIdsToInvalidate();
$this->idSitesInvalidatedOldReports = array_intersect($this->idSitesInvalidatedOldReports, $this->allWebsites);
if (count($this->idSitesInvalidatedOldReports) > 0) {
@@ -758,7 +760,7 @@ private function initWebsitesToProcess()
// 3) Also process all other websites which days have finished since the last run.
// This ensures we process the previous day/week/month/year that just finished, even if there was no new visit
- $uniqueTimezones = Piwik_SitesManager_API::getInstance()->getUniqueSiteTimezones();
+ $uniqueTimezones = SitesManagerAPI::getInstance()->getUniqueSiteTimezones();
$timezoneToProcess = array();
foreach ($uniqueTimezones as &$timezone) {
$processedDateInTz = Date::factory((int)$timestampActiveTraffic, $timezone);
@@ -769,7 +771,7 @@ private function initWebsitesToProcess()
}
}
- $websiteDayHasFinishedSinceLastRun = Piwik_SitesManager_API::getInstance()->getSitesIdFromTimezones($timezoneToProcess);
+ $websiteDayHasFinishedSinceLastRun = SitesManagerAPI::getInstance()->getSitesIdFromTimezones($timezoneToProcess);
$websiteDayHasFinishedSinceLastRun = array_diff($websiteDayHasFinishedSinceLastRun, $this->websites);
$this->websiteDayHasFinishedSinceLastRun = $websiteDayHasFinishedSinceLastRun;
if (count($websiteDayHasFinishedSinceLastRun) > 0) {
diff --git a/misc/others/geoipUpdateRows.php b/misc/others/geoipUpdateRows.php
index b0ffb11d7c5..d0392c9f3b2 100755
--- a/misc/others/geoipUpdateRows.php
+++ b/misc/others/geoipUpdateRows.php
@@ -5,6 +5,9 @@
use Piwik\FrontController;
use Piwik\IP;
use Piwik\Db;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Php;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Pecl;
ini_set("memory_limit", "512M");
error_reporting(E_ALL | E_NOTICE);
@@ -120,7 +123,7 @@ function geoipUpdateError($message)
$displayNotes = $start == 0;
// try getting the pecl location provider
-$provider = new Piwik_UserCountry_LocationProvider_GeoIp_Pecl();
+$provider = new Pecl();
if (!$provider->isAvailable()) {
if ($displayNotes) {
Piwik::log("[note] The GeoIP PECL extension is not installed.");
@@ -146,7 +149,7 @@ function geoipUpdateError($message)
Piwik::log("[note] Falling back to PHP API. This may become too slow for you. If so, you can read this link on how to install the PECL extension: http://piwik.org/faq/how-to/#faq_164");
}
- $provider = new Piwik_UserCountry_LocationProvider_GeoIp_Php();
+ $provider = new Php();
if (!$provider->isAvailable()) {
if ($displayNotes) {
Piwik::log("[note] The GeoIP PHP API is not available. This means you do not have a GeoIP location database in your ./misc directory. The database must be named either GeoIP.dat or GeoIPCity.dat based on the type of database it is.");
@@ -173,11 +176,11 @@ function geoipUpdateError($message)
}
// perform update
-$logVisitFieldsToUpdate = array('location_country' => Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY,
- 'location_region' => Piwik_UserCountry_LocationProvider::REGION_CODE_KEY,
- 'location_city' => Piwik_UserCountry_LocationProvider::CITY_NAME_KEY,
- 'location_latitude' => Piwik_UserCountry_LocationProvider::LATITUDE_KEY,
- 'location_longitude' => Piwik_UserCountry_LocationProvider::LONGITUDE_KEY);
+$logVisitFieldsToUpdate = array('location_country' => LocationProvider::COUNTRY_CODE_KEY,
+ 'location_region' => LocationProvider::REGION_CODE_KEY,
+ 'location_city' => LocationProvider::CITY_NAME_KEY,
+ 'location_latitude' => LocationProvider::LATITUDE_KEY,
+ 'location_longitude' => LocationProvider::LONGITUDE_KEY);
if ($displayNotes) {
Piwik::log("\n$count rows to process in " . Common::prefixTable('log_visit')
@@ -208,9 +211,9 @@ function geoipUpdateError($message)
$ip = IP::N2P($row['location_ip']);
$location = $provider->getLocation(array('ip' => $ip));
- if (!empty($location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY])) {
- $location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY] =
- strtolower($location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY]);
+ if (!empty($location[LocationProvider::COUNTRY_CODE_KEY])) {
+ $location[LocationProvider::COUNTRY_CODE_KEY] =
+ strtolower($location[LocationProvider::COUNTRY_CODE_KEY]);
}
$row['location_country'] = strtolower($row['location_country']);
diff --git a/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php b/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php
index e9c6b324496..69154a4b133 100644
--- a/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php
+++ b/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php
@@ -4,6 +4,7 @@
use Piwik\Piwik;
use Piwik\Common;
use Piwik\FrontController;
+use Piwik\Plugins\SitesManager\API;
exit;
@@ -19,7 +20,7 @@
Piwik::setUserIsSuperUser();
$count = 100;
for ($i = 0; $i <= $count; $i++) {
- $id = Piwik_SitesManager_API::getInstance()->addSite(Common::getRandomString(), 'http://piwik.org');
+ $id = API::getInstance()->addSite(Common::getRandomString(), 'http://piwik.org');
$t = new PiwikTracker($id, 'http://localhost/trunk/piwik.php');
echo $id . "
";
}
diff --git a/plugins/API/API.php b/plugins/API/API.php
index d1ea3c6eb84..7058bdb0ce3 100644
--- a/plugins/API/API.php
+++ b/plugins/API/API.php
@@ -8,6 +8,8 @@
* @category Piwik_Plugins
* @package Piwik_API
*/
+namespace Piwik\Plugins\API;
+
use Piwik\API\Request;
use Piwik\API\Proxy;
use Piwik\DataTable\Filter\ColumnDelete;
@@ -20,55 +22,10 @@
use Piwik\DataTable;
use Piwik\Tracker\GoalManager;
use Piwik\Version;
-use Piwik\Plugin;
use Piwik\Translate;
require_once PIWIK_INCLUDE_PATH . '/core/Config.php';
-/**
- * @package Piwik_API
- */
-class Piwik_API extends Plugin
-{
- /**
- * @see Piwik_Plugin::getListHooksRegistered
- */
- public function getListHooksRegistered()
- {
- return array(
- 'AssetManager.getCssFiles' => 'getCssFiles',
- 'TopMenu.add' => 'addTopMenu',
- );
- }
-
- public function addTopMenu()
- {
- $apiUrlParams = array('module' => 'API', 'action' => 'listAllAPI', 'segment' => false);
- $tooltip = Piwik_Translate('API_TopLinkTooltip');
-
- Piwik_AddTopMenu('General_API', $apiUrlParams, true, 7, $isHTML = false, $tooltip);
-
- $this->addTopMenuMobileApp();
- }
-
- protected function addTopMenuMobileApp()
- {
- if (empty($_SERVER['HTTP_USER_AGENT'])) {
- return;
- }
- require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php';
- $os = UserAgentParser::getOperatingSystem($_SERVER['HTTP_USER_AGENT']);
- if ($os && in_array($os['id'], array('AND', 'IPD', 'IPA', 'IPH'))) {
- Piwik_AddTopMenu('Piwik Mobile App', array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
- }
- }
-
- public function getCssFiles(&$cssFiles)
- {
- $cssFiles[] = "plugins/API/stylesheets/listAllAPI.less";
- }
-}
-
/**
* This API is the Metadata API: it gives information about all other available APIs methods, as well as providing
* human readable and more complete outputs than normal API methods.
@@ -87,12 +44,12 @@ public function getCssFiles(&$cssFiles)
*
* @package Piwik_API
*/
-class Piwik_API_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_API_API
+ * @return \Piwik\Plugins\API\API
*/
static public function getInstance()
{
@@ -230,7 +187,7 @@ public function getSegmentsMetadata($idSites = array(), $_hideImplementationData
'acceptedValues' => implode(", ", self::$visitEcommerceStatus)
. '. ' . Piwik_Translate('General_EcommerceVisitStatusEg', '"&segment=visitEcommerceStatus==ordered,visitEcommerceStatus==orderedThenAbandonedCart"'),
'sqlSegment' => 'log_visit.visit_goal_buyer',
- 'sqlFilter' => array('Piwik_API_API', 'getVisitEcommerceStatus'),
+ 'sqlFilter' => __NAMESPACE__ . '\API::getVisitEcommerceStatus',
);
$segments[] = array(
@@ -268,7 +225,7 @@ public function getSegmentsMetadata($idSites = array(), $_hideImplementationData
static public function getVisitEcommerceStatusFromId($id)
{
if (!isset(self::$visitEcommerceStatus[$id])) {
- throw new Exception("Unexpected ECommerce status value ");
+ throw new \Exception("Unexpected ECommerce status value ");
}
return self::$visitEcommerceStatus[$id];
}
@@ -280,7 +237,7 @@ static public function getVisitEcommerceStatus($status)
{
$id = array_search($status, self::$visitEcommerceStatus);
if ($id === false) {
- throw new Exception("Invalid 'visitEcommerceStatus' segment value");
+ throw new \Exception("Invalid 'visitEcommerceStatus' segment value");
}
return $id;
}
@@ -396,8 +353,8 @@ public function getMetadata($idSite, $apiModule, $apiAction, $apiParameters = ar
$period = false, $date = false, $hideMetricsDoc = false, $showSubtableReports = false)
{
Translate::getInstance()->reloadLanguage($language);
- $reporter = new Piwik_API_ProcessedReport();
- $metadata = $reporter->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $language, $period, $date, $hideMetricsDoc, $showSubtableReports);
+ $reporter = new ProcessedReport();
+ $metadata = $reporter->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $language, $period, $date, $hideMetricsDoc, $showSubtableReports);
return $metadata;
}
@@ -415,8 +372,8 @@ public function getMetadata($idSite, $apiModule, $apiAction, $apiParameters = ar
public function getReportMetadata($idSites = '', $period = false, $date = false, $hideMetricsDoc = false,
$showSubtableReports = false)
{
- $reporter = new Piwik_API_ProcessedReport();
- $metadata = $reporter->getReportMetadata($idSites, $period, $date, $hideMetricsDoc, $showSubtableReports);
+ $reporter = new ProcessedReport();
+ $metadata = $reporter->getReportMetadata($idSites, $period, $date, $hideMetricsDoc, $showSubtableReports);
return $metadata;
}
@@ -424,8 +381,8 @@ public function getProcessedReport($idSite, $period, $date, $apiModule, $apiActi
$apiParameters = false, $idGoal = false, $language = false,
$showTimer = true, $hideMetricsDoc = false, $idSubtable = false, $showRawMetrics = false)
{
- $reporter = new Piwik_API_ProcessedReport();
- $processed = $reporter->getProcessedReport( $idSite, $period, $date, $apiModule, $apiAction, $segment,
+ $reporter = new ProcessedReport();
+ $processed = $reporter->getProcessedReport($idSite, $period, $date, $apiModule, $apiAction, $segment,
$apiParameters, $idGoal, $language, $showTimer, $hideMetricsDoc, $idSubtable, $showRawMetrics);
return $processed;
@@ -446,7 +403,7 @@ public function get($idSite, $period, $date, $segment = false, $columns = false)
// find out which columns belong to which plugin
$columnsByPlugin = array();
- $meta = Piwik_API_API::getInstance()->getReportMetadata($idSite, $period, $date);
+ $meta = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite, $period, $date);
foreach ($meta as $reportMeta) {
// scan all *.get reports
if ($reportMeta['action'] == 'get'
@@ -472,7 +429,7 @@ public function get($idSite, $period, $date, $segment = false, $columns = false)
$params = compact('idSite', 'period', 'date', 'segment', 'idGoal');
foreach ($columnsByPlugin as $plugin => $columns) {
// load the data
- $className = 'Piwik_' . $plugin . '_API';
+ $className = Request::getClassNameAPI($plugin);
$params['columns'] = implode(',', $columns);
$dataTable = Proxy::getInstance()->call($className, 'get', $params);
// make sure the table has all columns
@@ -549,7 +506,7 @@ private function mergeDataTables($table1, $table2)
*/
public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label = false, $segment = false, $column = false, $language = false, $idGoal = false, $legendAppendMetric = true, $labelUseAbsoluteUrl = true)
{
- $rowEvolution = new Piwik_API_RowEvolution();
+ $rowEvolution = new RowEvolution();
return $rowEvolution->getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label, $segment, $column,
$language, $idGoal, $legendAppendMetric, $labelUseAbsoluteUrl);
}
@@ -603,12 +560,12 @@ public function getSuggestedValuesForSegment($segmentName, $idSite)
$startDate = Date::now()->subDay(60)->toString();
$requestLastVisits = "method=Live.getLastVisitsDetails
- &idSite=$idSite
- &period=range
- &date=$startDate,today
- &format=original
- &serialize=0
- &flat=1";
+ &idSite=$idSite
+ &period=range
+ &date=$startDate,today
+ &format=original
+ &serialize=0
+ &flat=1";
// Select non empty fields only
// Note: this optimization has only a very minor impact
@@ -663,3 +620,53 @@ protected function doesSegmentNeedActionsData($segmentName)
return $doesSegmentNeedActionsInfo;
}
}
+
+/**
+ * @package Piwik_API
+ */
+class Plugin extends \Piwik\Plugin
+{
+ public function __construct()
+ {
+ // this class is named 'Plugin', manually set the 'API' plugin
+ parent::__construct($pluginName = 'API');
+ }
+
+ /**
+ * @see Piwik_Plugin::getListHooksRegistered
+ */
+ public function getListHooksRegistered()
+ {
+ return array(
+ 'AssetManager.getCssFiles' => 'getCssFiles',
+ 'TopMenu.add' => 'addTopMenu',
+ );
+ }
+
+ public function addTopMenu()
+ {
+ $apiUrlParams = array('module' => 'API', 'action' => 'listAllAPI', 'segment' => false);
+ $tooltip = Piwik_Translate('API_TopLinkTooltip');
+
+ Piwik_AddTopMenu('General_API', $apiUrlParams, true, 7, $isHTML = false, $tooltip);
+
+ $this->addTopMenuMobileApp();
+ }
+
+ protected function addTopMenuMobileApp()
+ {
+ if (empty($_SERVER['HTTP_USER_AGENT'])) {
+ return;
+ }
+ require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php';
+ $os = \UserAgentParser::getOperatingSystem($_SERVER['HTTP_USER_AGENT']);
+ if ($os && in_array($os['id'], array('AND', 'IPD', 'IPA', 'IPH'))) {
+ Piwik_AddTopMenu('Piwik Mobile App', array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
+ }
+ }
+
+ public function getCssFiles(&$cssFiles)
+ {
+ $cssFiles[] = "plugins/API/stylesheets/listAllAPI.less";
+ }
+}
\ No newline at end of file
diff --git a/plugins/API/Controller.php b/plugins/API/Controller.php
index ed4addae2cb..ac8e31ac848 100644
--- a/plugins/API/Controller.php
+++ b/plugins/API/Controller.php
@@ -8,19 +8,21 @@
* @category Piwik_Plugins
* @package Piwik_API
*/
+namespace Piwik\Plugins\API;
+
use Piwik\API\DocumentationGenerator;
use Piwik\API\Request;
use Piwik\API\Proxy;
use Piwik\Config;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\API\API;
use Piwik\View;
/**
*
* @package Piwik_API
*/
-class Piwik_API_Controller extends Controller
+class Controller extends \Piwik\Controller
{
function index()
{
@@ -51,7 +53,7 @@ public function listAllAPI()
public function listSegments()
{
- $segments = Piwik_API_API::getInstance()->getSegmentsMetadata($this->idSite);
+ $segments = API::getInstance()->getSegmentsMetadata($this->idSite);
$tableDimensions = $tableMetrics = '';
$customVariables = 0;
@@ -98,7 +100,6 @@ public function listSegments()
}
}
-
if ($segment['type'] == 'dimension') {
$tableDimensions .= $output;
} else {
diff --git a/plugins/API/ProcessedReport.php b/plugins/API/ProcessedReport.php
index b30a3d79018..8e46cec774b 100644
--- a/plugins/API/ProcessedReport.php
+++ b/plugins/API/ProcessedReport.php
@@ -1,4 +1,16 @@
loadRowEvolutionDataFromAPI($idSite, $period, $date, $apiModule, $apiAction, $labels, $segment, $idGoal);
if (empty($labels)) {
@@ -273,8 +275,8 @@ private function getRowEvolutionMetaData($idSite, $period, $date, $apiModule, $a
if (!empty($idGoal) && $idGoal > 0) {
$apiParameters = array('idGoal' => $idGoal);
}
- $reportMetadata = Piwik_API_API::getInstance()->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $language,
- $period, $date, $hideMetricsDoc = false, $showSubtableReports = true);
+ $reportMetadata = API::getInstance()->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $language,
+ $period, $date, $hideMetricsDoc = false, $showSubtableReports = true);
if (empty($reportMetadata)) {
throw new Exception("Requested report $apiModule.$apiAction for Website id=$idSite "
@@ -463,17 +465,14 @@ private function getMultiRowEvolution($dataTable, $metadata, $apiModule, $apiAct
private function getRowEvolutionRowFromLabelIdx($table, $labelIdx)
{
$labelIdx = (int)$labelIdx;
- foreach ($table->getRows() as $row)
- {
- if ($row->getMetadata(LabelFilter::FLAG_IS_ROW_EVOLUTION) === $labelIdx)
- {
+ foreach ($table->getRows() as $row) {
+ if ($row->getMetadata(LabelFilter::FLAG_IS_ROW_EVOLUTION) === $labelIdx) {
return $row;
}
}
return false;
}
-
/**
* Returns a prettier, more comprehensible version of a row evolution label
* for display.
diff --git a/plugins/Actions/API.php b/plugins/Actions/API.php
index 263e3e4a6b6..1804ca4a07c 100644
--- a/plugins/Actions/API.php
+++ b/plugins/Actions/API.php
@@ -6,15 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Actions
+ * @package Actions
*/
+namespace Piwik\Plugins\Actions;
+
+use Exception;
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
use Piwik\DataTable;
+use Piwik\Plugins\Actions\Actions;
use Piwik\Tracker\Action;
+use Piwik\Plugins\Actions\Archiver;
+use Piwik\Plugins\Actions\ArchivingHelper;
+use Piwik\Plugins\CustomVariables\API as CustomVariablesAPI;
/**
* The Actions API lets you request reports for all your Visitor Actions: Page URLs, Page titles (Piwik Events),
@@ -28,14 +35,14 @@
* and an outlink via "getOutlink".
*
* Note: pageName, pageUrl, outlinkUrl, downloadUrl parameters must be URL encoded before you call the API.
- * @package Piwik_Actions
+ * @package Actions
*/
-class Piwik_Actions_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_Actions_API
+ * @return \Piwik\Plugins\Actions\API
*/
static public function getInstance()
{
@@ -60,7 +67,7 @@ public function get($idSite, $period, $date, $segment = false, $columns = false)
Piwik::checkUserHasViewAccess($idSite);
$archive = Archive::build($idSite, $period, $date, $segment);
- $metrics = Piwik_Actions_Archiver::$actionsAggregateMetrics;
+ $metrics = Archiver::$actionsAggregateMetrics;
$metrics['Actions_avg_time_generation'] = 'avg_time_generation';
// get requested columns
@@ -89,13 +96,13 @@ public function get($idSite, $period, $date, $segment = false, $columns = false)
}
if ($avgGenerationTimeRequested) {
- $tempColumns[] = Piwik_Actions_Archiver::METRIC_SUM_TIME_RECORD_NAME;
- $tempColumns[] = Piwik_Actions_Archiver::METRIC_HITS_TIMED_RECORD_NAME;
+ $tempColumns[] = Archiver::METRIC_SUM_TIME_RECORD_NAME;
+ $tempColumns[] = Archiver::METRIC_HITS_TIMED_RECORD_NAME;
$columns = array_merge($columns, $tempColumns);
$columns = array_unique($columns);
- $nameReplace[Piwik_Actions_Archiver::METRIC_SUM_TIME_RECORD_NAME] = 'sum_time_generation';
- $nameReplace[Piwik_Actions_Archiver::METRIC_HITS_TIMED_RECORD_NAME] = 'nb_hits_with_time_generation';
+ $nameReplace[Archiver::METRIC_SUM_TIME_RECORD_NAME] = 'sum_time_generation';
+ $nameReplace[Archiver::METRIC_HITS_TIMED_RECORD_NAME] = 'nb_hits_with_time_generation';
}
$table = $archive->getDataTableFromNumeric($columns);
@@ -327,8 +334,8 @@ public function getSiteSearchNoResultKeywords($idSite, $period, $date, $segment
*/
public function getSiteSearchCategories($idSite, $period, $date, $segment = false)
{
- Piwik_Actions::checkCustomVariablesPluginEnabled();
- $customVariables = Piwik_CustomVariables_API::getInstance()->getCustomVariables($idSite, $period, $date, $segment, $expanded = false, $_leavePiwikCoreVariables = true);
+ Actions::checkCustomVariablesPluginEnabled();
+ $customVariables = CustomVariablesAPI::getInstance()->getCustomVariables($idSite, $period, $date, $segment, $expanded = false, $_leavePiwikCoreVariables = true);
$customVarNameToLookFor = Action::CVAR_KEY_SEARCH_CATEGORY;
@@ -347,7 +354,7 @@ public function getSiteSearchCategories($idSite, $period, $date, $segment = fals
if ($row) {
$dateRewrite = $customVariableTableForDate->metadata['period']->getDateStart()->toString();
$idSubtable = $row->getIdSubDataTable();
- $categories = Piwik_CustomVariables_API::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $dateRewrite, $idSubtable, $segment);
+ $categories = CustomVariablesAPI::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $dateRewrite, $idSubtable, $segment);
$dataTable->addTable($categories, $key);
}
}
@@ -356,7 +363,7 @@ public function getSiteSearchCategories($idSite, $period, $date, $segment = fals
$row = $customVariables->getRowFromLabel($customVarNameToLookFor);
if ($row) {
$idSubtable = $row->getIdSubDataTable();
- $dataTable = Piwik_CustomVariables_API::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment);
+ $dataTable = CustomVariablesAPI::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment);
}
}
$this->filterActionsDataTable($dataTable);
@@ -383,8 +390,8 @@ protected function getFilterPageDatatableSearch($callBackParameters, $search, $a
$searchedString = $search;
}
}
- Piwik_Actions_ArchivingHelper::reloadConfig();
- $searchTree = Piwik_Actions_ArchivingHelper::getActionExplodedNames($searchedString, $actionType);
+ ArchivingHelper::reloadConfig();
+ $searchTree = ArchivingHelper::getActionExplodedNames($searchedString, $actionType);
}
if ($table === false) {
@@ -405,7 +412,6 @@ protected function getFilterPageDatatableSearch($callBackParameters, $search, $a
return $newTableArray;
}
-
}
return $this->doFilterPageDatatableSearch($callBackParameters, $table, $searchTree);
diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php
index fdd116c6716..665e0511f11 100644
--- a/plugins/Actions/Actions.php
+++ b/plugins/Actions/Actions.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Actions
+ * @package Actions
*/
+namespace Piwik\Plugins\Actions;
+
use Piwik\API\Request;
use Piwik\ArchiveProcessor;
use Piwik\Piwik;
@@ -15,7 +17,6 @@
use Piwik\Tracker\Action;
use Piwik\ViewDataTable;
use Piwik\WidgetsList;
-use Piwik\Plugin;
use Piwik\SegmentExpression;
use Piwik\Db;
use Piwik\Site;
@@ -25,18 +26,18 @@
*
* Reports about the page views, the outlinks and downloads.
*
- * @package Piwik_Actions
+ * @package Actions
*/
-class Piwik_Actions extends Plugin
+class Actions extends \Piwik\Plugin
{
const ACTIONS_REPORT_ROWS_DISPLAY = 100;
-
+
private $columnTranslations;
-
+
public function __construct()
{
parent::__construct();
-
+
$this->columnTranslations = array(
'nb_hits' => Piwik_Translate('General_ColumnPageviews'),
'nb_visits' => Piwik_Translate('General_ColumnUniquePageviews'),
@@ -63,7 +64,7 @@ public function getListHooksRegistered()
);
return $hooks;
}
-
+
public function getSegmentsMetadata(&$segments)
{
$sqlFilter = array($this, 'getIdActionFromSegment');
@@ -211,7 +212,7 @@ public function getReportMetadata(&$reports)
'nb_uniq_outlinks' => Piwik_Translate('Actions_ColumnUniqueOutlinks'),
'nb_searches' => Piwik_Translate('Actions_ColumnSearches'),
'nb_keywords' => Piwik_Translate('Actions_ColumnSiteSearchKeywords'),
- 'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTime'),
+ 'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTime'),
),
'metricsDocumentation' => array(
'nb_pageviews' => Piwik_Translate('General_ColumnPageviewsDocumentation'),
@@ -221,7 +222,7 @@ public function getReportMetadata(&$reports)
'nb_outlinks' => Piwik_Translate('Actions_ColumnClicksDocumentation'),
'nb_uniq_outlinks' => Piwik_Translate('Actions_ColumnUniqueClicksDocumentation'),
'nb_searches' => Piwik_Translate('Actions_ColumnSearchesDocumentation'),
- 'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTimeDocumentation'),
+ 'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTimeDocumentation'),
// 'nb_keywords' => Piwik_Translate('Actions_ColumnSiteSearchKeywords'),
),
'processedMetrics' => false,
@@ -581,16 +582,16 @@ protected function isSiteSearchEnabled()
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_Actions_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_Actions_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
@@ -631,20 +632,20 @@ protected function guessActionTypeFromSegment($segmentName)
public function getReportDisplayProperties(&$properties)
{
$properties['Actions.getPageUrls'] = $this->getDisplayPropertiesForPageUrls();
- $properties['Actions.getEntryPageUrls'] = $this->getDisplayPropertiesForEntryPageUrls();
- $properties['Actions.getExitPageUrls'] = $this->getDisplayPropertiesForExitPageUrls();
- $properties['Actions.getSiteSearchKeywords'] = $this->getDisplayPropertiesForSiteSearchKeywords();
- $properties['Actions.getSiteSearchNoResultKeywords'] = $this->getDisplayPropertiesForSiteSearchNoResultKeywords();
- $properties['Actions.getSiteSearchCategories'] = $this->getDisplayPropertiesForSiteSearchCategories();
- $properties['Actions.getPageUrlsFollowingSiteSearch'] = $this->getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch(false);
- $properties['Actions.getPageTitlesFollowingSiteSearch'] = $this->getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch(true);
- $properties['Actions.getPageTitles'] = $this->getDisplayPropertiesForGetPageTitles();
- $properties['Actions.getEntryPageTitles'] = $this->getDisplayPropertiesForGetEntryPageTitles();
- $properties['Actions.getExitPageTitles'] = $this->getDisplayPropertiesForGetExitPageTitles();
- $properties['Actions.getDownloads'] = $this->getDisplayPropertiesForGetDownloads();
- $properties['Actions.getOutlinks'] = $this->getDisplayPropertiesForGetOutlinks();
+ $properties['Actions.getEntryPageUrls'] = $this->getDisplayPropertiesForEntryPageUrls();
+ $properties['Actions.getExitPageUrls'] = $this->getDisplayPropertiesForExitPageUrls();
+ $properties['Actions.getSiteSearchKeywords'] = $this->getDisplayPropertiesForSiteSearchKeywords();
+ $properties['Actions.getSiteSearchNoResultKeywords'] = $this->getDisplayPropertiesForSiteSearchNoResultKeywords();
+ $properties['Actions.getSiteSearchCategories'] = $this->getDisplayPropertiesForSiteSearchCategories();
+ $properties['Actions.getPageUrlsFollowingSiteSearch'] = $this->getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch(false);
+ $properties['Actions.getPageTitlesFollowingSiteSearch'] = $this->getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch(true);
+ $properties['Actions.getPageTitles'] = $this->getDisplayPropertiesForGetPageTitles();
+ $properties['Actions.getEntryPageTitles'] = $this->getDisplayPropertiesForGetEntryPageTitles();
+ $properties['Actions.getExitPageTitles'] = $this->getDisplayPropertiesForGetExitPageTitles();
+ $properties['Actions.getDownloads'] = $this->getDisplayPropertiesForGetDownloads();
+ $properties['Actions.getOutlinks'] = $this->getDisplayPropertiesForGetOutlinks();
}
-
+
private function addBaseDisplayProperties(&$result)
{
$result['datatable_css_class'] = 'dataTableActions';
@@ -654,34 +655,34 @@ private function addBaseDisplayProperties(&$result)
$result['show_all_views_icons'] = false;
$result['show_table_all_columns'] = false;
$result['filter_limit'] = self::ACTIONS_REPORT_ROWS_DISPLAY;
-
+
// if the flat parameter is not provided, make sure it is set to 0 in the URL,
// so users can see that they can set it to 1 (see #3365)
$result['custom_parameters'] = array('flat' => 0);
-
+
if (ViewDataTable::shouldLoadExpanded()) {
$result['show_expanded'] = true;
-
+
$result['filters'][] = function ($dataTable) {
- Piwik_Actions::setDataTableRowLevels($dataTable);
+ Actions::setDataTableRowLevels($dataTable);
};
}
-
+
return $result;
}
-
+
public static function setDataTableRowLevels($dataTable, $level = 0)
{
foreach ($dataTable->getRows() as $row) {
- $row->setMetadata('css_class', 'level'.$level);
-
+ $row->setMetadata('css_class', 'level' . $level);
+
$subtable = $row->getSubtable();
if ($subtable) {
self::setDataTableRowLevels($subtable, $level + 1);
}
}
}
-
+
private function addExcludeLowPopDisplayProperties(&$result)
{
if (Common::getRequestVar('enable_filter_excludelowpop', '0', 'string') != '0') {
@@ -691,60 +692,60 @@ private function addExcludeLowPopDisplayProperties(&$result)
$visitsInfo = Piwik_VisitsSummary_Controller::getVisitsSummary()->getFirstRow();
$nbActions = $visitsInfo->getColumn('nb_actions');
$nbActionsLowPopulationThreshold = floor(0.02 * $nbActions);
-
+
// we remove 1 to make sure some actions/downloads are displayed in the case we have a very few of them
// and each of them has 1 or 2 hits...
return min($visitsInfo->getColumn('max_actions') - 1, $nbActionsLowPopulationThreshold - 1);
};
}
}
-
+
private function addPageDisplayProperties(&$result)
{
// add common translations
$result['translations'] += array(
- 'nb_hits' => Piwik_Translate('General_ColumnPageviews'),
- 'nb_visits' => Piwik_Translate('General_ColumnUniquePageviews'),
- 'avg_time_on_page' => Piwik_Translate('General_ColumnAverageTimeOnPage'),
- 'bounce_rate' => Piwik_Translate('General_ColumnBounceRate'),
- 'exit_rate' => Piwik_Translate('General_ColumnExitRate'),
+ 'nb_hits' => Piwik_Translate('General_ColumnPageviews'),
+ 'nb_visits' => Piwik_Translate('General_ColumnUniquePageviews'),
+ 'avg_time_on_page' => Piwik_Translate('General_ColumnAverageTimeOnPage'),
+ 'bounce_rate' => Piwik_Translate('General_ColumnBounceRate'),
+ 'exit_rate' => Piwik_Translate('General_ColumnExitRate'),
'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTime'),
);
-
+
// prettify avg_time_on_page column
$getPrettyTimeFromSeconds = '\Piwik\Piwik::getPrettyTimeFromSeconds';
$result['filters'][] = array('ColumnCallbackReplace', array('avg_time_on_page', $getPrettyTimeFromSeconds));
-
+
// prettify avg_time_generation column
$avgTimeCallback = function ($time) {
return $time ? Piwik::getPrettyTimeFromSeconds($time, true, true, false) : "-";
};
$result['filters'][] = array('ColumnCallbackReplace', array('avg_time_generation', $avgTimeCallback));
-
+
// add avg_generation_time tooltip
$tooltipCallback = function ($hits, $min, $max) {
if (!$hits) {
return false;
}
-
+
return Piwik_Translate("Actions_AvgGenerationTimeTooltip", array(
- $hits,
- "
",
- Piwik::getPrettyTimeFromSeconds($min),
- Piwik::getPrettyTimeFromSeconds($max)
- ));
+ $hits,
+ "
",
+ Piwik::getPrettyTimeFromSeconds($min),
+ Piwik::getPrettyTimeFromSeconds($max)
+ ));
};
$result['filters'][] = array('ColumnCallbackAddMetadata',
- array(
- array('nb_hits_with_time_generation', 'min_time_generation', 'max_time_generation'),
- 'avg_time_generation_tooltip',
- $tooltipCallback
- )
+ array(
+ array('nb_hits_with_time_generation', 'min_time_generation', 'max_time_generation'),
+ 'avg_time_generation_tooltip',
+ $tooltipCallback
+ )
);
-
+
$this->addExcludeLowPopDisplayProperties($result);
}
-
+
public function getDisplayPropertiesForPageUrls()
{
$result = array(
@@ -752,26 +753,26 @@ public function getDisplayPropertiesForPageUrls()
'columns_to_display' => array('label', 'nb_hits', 'nb_visits', 'bounce_rate',
'avg_time_on_page', 'exit_rate', 'avg_time_generation'),
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
-
+
public function getDisplayPropertiesForEntryPageUrls()
{
// link to the page, not just the report, but only if not a widget
$widget = Common::getRequestVar('widget', false);
$reportUrl = Request::getCurrentUrlWithoutGenericFilters(array(
- 'module' => 'Actions',
- 'action' => $widget === false ? 'indexEntryPageUrls' : 'getEntryPageUrls'
- ));
-
+ 'module' => 'Actions',
+ 'action' => $widget === false ? 'indexEntryPageUrls' : 'getEntryPageUrls'
+ ));
+
$result = array(
- 'translations' => array('label' => Piwik_Translate('Actions_ColumnEntryPageURL'),
+ 'translations' => array('label' => Piwik_Translate('Actions_ColumnEntryPageURL'),
'entry_bounce_count' => Piwik_Translate('General_ColumnBounces'),
- 'entry_nb_visits' => Piwik_Translate('General_ColumnEntrances')),
+ 'entry_nb_visits' => Piwik_Translate('General_ColumnEntrances')),
'columns_to_display' => array('label', 'entry_nb_visits', 'entry_bounce_count', 'bounce_rate'),
'filter_sort_column' => 'entry_nb_visits',
'filter_sort_order' => 'desc',
@@ -781,24 +782,24 @@ public function getDisplayPropertiesForEntryPageUrls()
),
'self_url' => $reportUrl
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
-
+
public function getDisplayPropertiesForExitPageUrls()
{
// link to the page, not just the report, but only if not a widget
$widget = Common::getRequestVar('widget', false);
$reportUrl = Request::getCurrentUrlWithoutGenericFilters(array(
- 'module' => 'Actions',
- 'action' => $widget === false ? 'indexExitPageUrls' : 'getExitPageUrls'
- ));
-
+ 'module' => 'Actions',
+ 'action' => $widget === false ? 'indexExitPageUrls' : 'getExitPageUrls'
+ ));
+
$result = array(
- 'translations' => array('label' => Piwik_Translate('Actions_ColumnExitPageURL'),
+ 'translations' => array('label' => Piwik_Translate('Actions_ColumnExitPageURL'),
'exit_nb_visits' => Piwik_Translate('General_ColumnExits')),
'columns_to_display' => array('label', 'exit_nb_visits', 'nb_visits', 'exit_rate'),
'filter_sort_column' => 'exit_nb_visits',
@@ -809,13 +810,13 @@ public function getDisplayPropertiesForExitPageUrls()
),
'self_url' => $reportUrl,
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
-
+
private function addSiteSearchDisplayProperties(&$result)
{
$result['translations'] += array(
@@ -826,16 +827,16 @@ private function addSiteSearchDisplayProperties(&$result)
$result['show_bar_chart'] = false;
$result['show_table_all_columns'] = false;
}
-
+
public function getDisplayPropertiesForSiteSearchKeywords()
{
$result = array(
'translations' => array('label' => Piwik_Translate('Actions_ColumnSearchKeyword')),
'columns_to_display' => array('label', 'nb_visits', 'nb_pages_per_search', 'exit_rate'),
);
-
+
$this->addSiteSearchDisplayProperties($result);
-
+
return $result;
}
@@ -845,9 +846,9 @@ public function getDisplayPropertiesForSiteSearchNoResultKeywords()
'translations' => array('label', Piwik_Translate('Actions_ColumnNoResultKeyword')),
'columns_to_display' => array('label', 'nb_visits', 'exit_rate')
);
-
+
$this->addSiteSearchDisplayProperties($result);
-
+
return $result;
}
@@ -870,12 +871,12 @@ public function getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch($i
{
$title = $isTitle ? Piwik_Translate('Actions_WidgetPageTitlesFollowingSearch')
: Piwik_Translate('Actions_WidgetPageUrlsFollowingSearch');
-
+
$relatedReports = array(
'Actions.getPageTitlesFollowingSiteSearch' => Piwik_Translate('Actions_WidgetPageTitlesFollowingSearch'),
- 'Actions.getPageUrlsFollowingSiteSearch' => Piwik_Translate('Actions_WidgetPageUrlsFollowingSearch'),
+ 'Actions.getPageUrlsFollowingSiteSearch' => Piwik_Translate('Actions_WidgetPageUrlsFollowingSearch'),
);
-
+
$result = array(
'translations' => array(
'label' => Piwik_Translate('General_ColumnDestinationPage'),
@@ -889,10 +890,10 @@ public function getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch($i
'title' => $title,
'relatedReports' => $relatedReports
);
-
+
$this->addExcludeLowPopDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
@@ -901,10 +902,10 @@ public function getDisplayPropertiesForGetPageTitles()
// link to the page, not just the report, but only if not a widget
$widget = Common::getRequestVar('widget', false);
$reportUrl = Request::getCurrentUrlWithoutGenericFilters(array(
- 'module' => 'Actions',
- 'action' => $widget === false ? 'indexPageTitles' : 'getPageTitles'
- ));
-
+ 'module' => 'Actions',
+ 'action' => $widget === false ? 'indexPageTitles' : 'getPageTitles'
+ ));
+
$result = array(
'translations' => array('label' => Piwik_Translate('Actions_ColumnPageName')),
'columns_to_display' => array('label', 'nb_hits', 'nb_visits', 'bounce_rate',
@@ -916,10 +917,10 @@ public function getDisplayPropertiesForGetPageTitles()
),
'self_url' => $reportUrl
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
@@ -927,7 +928,7 @@ public function getDisplayPropertiesForGetEntryPageTitles()
{
$entryPageUrlAction =
Common::getRequestVar('widget', false) === false ? 'indexEntryPageUrls' : 'getEntryPageUrls';
-
+
$result = array(
'translations' => array(
'label' => Piwik_Translate('Actions_ColumnEntryPageTitle'),
@@ -941,10 +942,10 @@ public function getDisplayPropertiesForGetEntryPageTitles()
"Actions.$entryPageUrlAction" => Piwik_Translate('Actions_SubmenuPagesEntry')
),
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
@@ -952,7 +953,7 @@ public function getDisplayPropertiesForGetExitPageTitles()
{
$exitPageUrlAction =
Common::getRequestVar('widget', false) === false ? 'indexExitPageUrls' : 'getExitPageUrls';
-
+
$result = array(
'translations' => array(
'label' => Piwik_Translate('Actions_ColumnExitPageTitle'),
@@ -965,10 +966,10 @@ public function getDisplayPropertiesForGetExitPageTitles()
"Actions.$exitPageUrlAction" => Piwik_Translate('Actions_SubmenuPagesExit'),
),
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
@@ -983,9 +984,9 @@ public function getDisplayPropertiesForGetDownloads()
'columns_to_display' => array('label', 'nb_visits', 'nb_hits'),
'show_exclude_low_population' => false
);
-
+
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
@@ -1000,9 +1001,9 @@ public function getDisplayPropertiesForGetOutlinks()
'columns_to_display' => array('label', 'nb_visits', 'nb_hits'),
'show_exclude_low_population' => false
);
-
+
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
}
diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php
index f3dfa31138b..c177a73ffea 100644
--- a/plugins/Actions/Archiver.php
+++ b/plugins/Actions/Archiver.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Actions
+ * @package Actions
*/
+namespace Piwik\Plugins\Actions;
+
use Piwik\Config;
use Piwik\DataTable\Manager;
use Piwik\DataTable\Row\DataTableSummaryRow;
@@ -16,13 +18,14 @@
use Piwik\RankingQuery;
use Piwik\PluginsArchiver;
use Piwik\Tracker\Action;
+use Piwik\Plugins\Actions\ArchivingHelper;
/**
* Class encapsulating logic to process Day/Period Archiving for the Actions reports
*
- * @package Piwik_Actions
+ * @package Actions
*/
-class Piwik_Actions_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const DOWNLOADS_RECORD_NAME = 'Actions_downloads';
const OUTLINKS_RECORD_NAME = 'Actions_outlink';
@@ -42,15 +45,15 @@ class Piwik_Actions_Archiver extends PluginsArchiver
const METRIC_KEYWORDS_RECORD_NAME = 'Actions_nb_keywords';
/* Metrics in use by the API Actions.get */
- public static $actionsAggregateMetrics = array(
- self::METRIC_PAGEVIEWS_RECORD_NAME => 'nb_pageviews',
- self::METRIC_UNIQ_PAGEVIEWS_RECORD_NAME => 'nb_uniq_pageviews',
- self::METRIC_DOWNLOADS_RECORD_NAME => 'nb_downloads',
- self::METRIC_UNIQ_DOWNLOADS_RECORD_NAME => 'nb_uniq_downloads',
- self::METRIC_OUTLINKS_RECORD_NAME => 'nb_outlinks',
- self::METRIC_UNIQ_OUTLINKS_RECORD_NAME => 'nb_uniq_outlinks',
- self::METRIC_SEARCHES_RECORD_NAME => 'nb_searches',
- self::METRIC_KEYWORDS_RECORD_NAME => 'nb_keywords',
+ public static $actionsAggregateMetrics = array(
+ self::METRIC_PAGEVIEWS_RECORD_NAME => 'nb_pageviews',
+ self::METRIC_UNIQ_PAGEVIEWS_RECORD_NAME => 'nb_uniq_pageviews',
+ self::METRIC_DOWNLOADS_RECORD_NAME => 'nb_downloads',
+ self::METRIC_UNIQ_DOWNLOADS_RECORD_NAME => 'nb_uniq_downloads',
+ self::METRIC_OUTLINKS_RECORD_NAME => 'nb_outlinks',
+ self::METRIC_UNIQ_OUTLINKS_RECORD_NAME => 'nb_uniq_outlinks',
+ self::METRIC_SEARCHES_RECORD_NAME => 'nb_searches',
+ self::METRIC_KEYWORDS_RECORD_NAME => 'nb_keywords',
);
public static $actionTypes = array(
@@ -93,24 +96,24 @@ public function archiveDay()
$rankingQueryLimit = self::getRankingQueryLimit();
// FIXME: This is a quick fix for #3482. The actual cause of the bug is that
- // the site search & performance metrics additions to
- // Piwik_Actions_ArchivingHelper::updateActionsTableWithRowQuery expect every
+ // the site search & performance metrics additions to
+ // ArchivingHelper::updateActionsTableWithRowQuery expect every
// row to have 'type' data, but not all of the SQL queries that are run w/o
// ranking query join on the log_action table and thus do not select the
// log_action.type column.
- //
+ //
// NOTES: Archiving logic can be generalized as follows:
// 0) Do SQL query over log_link_visit_action & join on log_action to select
// some metrics (like visits, hits, etc.)
// 1) For each row, cache the action row & metrics. (This is done by
- // updateActionsTableWithRowQuery for result set rows that have
+ // updateActionsTableWithRowQuery for result set rows that have
// name & type columns.)
// 2) Do other SQL queries for metrics we can't put in the first query (like
// entry visits, exit vists, etc.) w/o joining log_action.
// 3) For each row, find the cached row by idaction & add the new metrics to
// it. (This is done by updateActionsTableWithRowQuery for result set rows
// that DO NOT have name & type columns.)
- //
+ //
// The site search & performance metrics additions expect a 'type' all the time
// which breaks the original pre-rankingquery logic. Ranking query requires a
// join, so the bug is only seen when ranking query is disabled.
@@ -118,7 +121,7 @@ public function archiveDay()
$rankingQueryLimit = 100000;
}
- Piwik_Actions_ArchivingHelper::reloadConfig();
+ ArchivingHelper::reloadConfig();
$this->initActionsTables();
$this->archiveDayActions($rankingQueryLimit);
@@ -159,7 +162,7 @@ private function initActionsTables()
$this->actionsTablesByType = array();
foreach (self::$actionTypes as $type) {
$dataTable = new DataTable();
- $dataTable->setMaximumAllowedRows(Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero);
+ $dataTable->setMaximumAllowedRows(ArchivingHelper::$maximumRowsInDataTableLevelZero);
if ($type == Action::TYPE_ACTION_URL
|| $type == Action::TYPE_ACTION_NAME
@@ -271,7 +274,6 @@ protected function archiveDayQueryProcess($select, $from, $where, $orderBy, $gro
// to the outer select. therefore, $segment needs to know about it.
$select = sprintf($select, $sprintfField);
-
// get query with segmentation
$query = $this->getLogAggregator()->generateQuery($select, $from, $where, $groupBy, $orderBy);
@@ -285,7 +287,7 @@ protected function archiveDayQueryProcess($select, $from, $where, $orderBy, $gro
// get result
$resultSet = $this->getLogAggregator()->getDb()->query($querySql, $query['bind']);
- $modified = Piwik_Actions_ArchivingHelper::updateActionsTableWithRowQuery($resultSet, $sprintfField, $this->actionsTablesByType);
+ $modified = ArchivingHelper::updateActionsTableWithRowQuery($resultSet, $sprintfField, $this->actionsTablesByType);
return $modified;
}
@@ -435,7 +437,7 @@ protected function archiveDayActionsTime($rankingQueryLimit)
*/
protected function recordDayReports()
{
- Piwik_Actions_ArchivingHelper::clearActionsCache();
+ ArchivingHelper::clearActionsCache();
$this->recordPageUrlsReports();
$this->recordDownloadsReports();
@@ -450,12 +452,12 @@ protected function recordPageUrlsReports()
$this->recordDataTable($dataTable, self::PAGE_URLS_RECORD_NAME);
$records = array(
- self::METRIC_PAGEVIEWS_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_NB_HITS)),
+ self::METRIC_PAGEVIEWS_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_NB_HITS)),
self::METRIC_UNIQ_PAGEVIEWS_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_NB_VISITS)),
- self::METRIC_SUM_TIME_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_SUM_TIME_GENERATION)),
- self::METRIC_HITS_TIMED_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION))
+ self::METRIC_SUM_TIME_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_SUM_TIME_GENERATION)),
+ self::METRIC_HITS_TIMED_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION))
);
- $this->getProcessor()->insertNumericRecords( $records );
+ $this->getProcessor()->insertNumericRecords($records);
}
/**
@@ -470,7 +472,7 @@ protected function getDataTable($typeId)
protected function recordDataTable($dataTable, $recordName)
{
self::deleteInvalidSummedColumnsFromDataTable($dataTable);
- $s = $dataTable->getSerialized(Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero, Piwik_Actions_ArchivingHelper::$maximumRowsInSubDataTable, Piwik_Actions_ArchivingHelper::$columnToSortByBeforeTruncation);
+ $s = $dataTable->getSerialized(ArchivingHelper::$maximumRowsInDataTableLevelZero, ArchivingHelper::$maximumRowsInSubDataTable, ArchivingHelper::$columnToSortByBeforeTruncation);
$this->getProcessor()->insertBlobRecord($recordName, $s);
}
@@ -566,15 +568,15 @@ protected function deleteUnusedColumnsFromKeywordsDataTable($dataTable)
public function archivePeriod()
{
- Piwik_Actions_ArchivingHelper::reloadConfig();
+ ArchivingHelper::reloadConfig();
$dataTableToSum = array(
self::PAGE_TITLES_RECORD_NAME,
self::PAGE_URLS_RECORD_NAME,
);
$this->getProcessor()->aggregateDataTableReports($dataTableToSum,
- Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero,
- Piwik_Actions_ArchivingHelper::$maximumRowsInSubDataTable,
- Piwik_Actions_ArchivingHelper::$columnToSortByBeforeTruncation,
+ ArchivingHelper::$maximumRowsInDataTableLevelZero,
+ ArchivingHelper::$maximumRowsInSubDataTable,
+ ArchivingHelper::$columnToSortByBeforeTruncation,
self::$actionColumnAggregationOperations,
self::$invalidSummedColumnNameToRenamedNameFromPeriodArchive
);
@@ -586,9 +588,9 @@ public function archivePeriod()
);
$aggregation = null;
$nameToCount = $this->getProcessor()->aggregateDataTableReports($dataTableToSum,
- Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero,
- Piwik_Actions_ArchivingHelper::$maximumRowsInSubDataTable,
- Piwik_Actions_ArchivingHelper::$columnToSortByBeforeTruncation,
+ ArchivingHelper::$maximumRowsInDataTableLevelZero,
+ ArchivingHelper::$maximumRowsInSubDataTable,
+ ArchivingHelper::$columnToSortByBeforeTruncation,
$aggregation,
self::$invalidSummedColumnNameToRenamedNameFromPeriodArchive
);
diff --git a/plugins/Actions/ArchivingHelper.php b/plugins/Actions/ArchivingHelper.php
index 8c95ae629f5..e66cf73a979 100644
--- a/plugins/Actions/ArchivingHelper.php
+++ b/plugins/Actions/ArchivingHelper.php
@@ -6,29 +6,33 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Actions
+ * @package Actions
*/
+namespace Piwik\Plugins\Actions;
+
+use PDOStatement;
use Piwik\Config;
use Piwik\DataTable\Row;
use Piwik\Metrics;
use Piwik\DataTable;
use Piwik\Tracker\Action;
+use Zend_Db_Statement;
/**
* This static class provides:
* - logic to parse/cleanup Action names,
* - logic to efficiently process aggregate the array data during Archiving
*
- * @package Piwik_Actions
+ * @package Actions
*/
-class Piwik_Actions_ArchivingHelper
+class ArchivingHelper
{
const OTHERS_ROW_KEY = '';
/**
- * FIXME See FIXME related to this function at Piwik_Actions_Archiver::archiveDay.
- *
+ * FIXME See FIXME related to this function at Archiver::archiveDay.
+ *
* @param Zend_Db_Statement|PDOStatement $query
* @param string|bool $fieldQueried
* @param array $actionsTablesByType
@@ -91,7 +95,6 @@ static public function updateActionsTableWithRowQuery($query, $fieldQueried, & $
}
}
-
if (is_null($actionRow)) {
continue;
}
@@ -226,7 +229,6 @@ static public function reloadConfig()
DataTable::setMaximumDepthLevelAllowedAtLeast(self::getSubCategoryLevelLimit() + 1);
}
-
/**
* The default row is used when archiving, if data is inconsistent in the DB,
* there could be pages that have exit/entry hits, but don't yet
@@ -242,11 +244,11 @@ static private function getDefaultRow()
// but this action was not properly recorded when it was hit in the first place
// so we add this fake row information to make sure there is a nb_hits, etc. column for every action
$row = new Row(array(
- Row::COLUMNS => array(
- Metrics::INDEX_NB_VISITS => 1,
- Metrics::INDEX_NB_UNIQ_VISITORS => 1,
- Metrics::INDEX_PAGE_NB_HITS => 1,
- )));
+ Row::COLUMNS => array(
+ Metrics::INDEX_NB_VISITS => 1,
+ Metrics::INDEX_NB_UNIQ_VISITORS => 1,
+ Metrics::INDEX_PAGE_NB_HITS => 1,
+ )));
}
return $row;
}
@@ -287,7 +289,7 @@ protected static function getActionRow($actionName, $actionType, $urlPrefix = nu
/**
* Explodes action name into an array of elements.
*
- * NOTE: before calling this function make sure Piwik_Actions_ArchivingHelper::reloadConfig(); is called
+ * NOTE: before calling this function make sure ArchivingHelper::reloadConfig(); is called
*
* for downloads:
* we explode link http://piwik.org/some/path/piwik.zip into an array( 'piwik.org', '/some/path/piwik.zip' );
@@ -357,7 +359,6 @@ static public function getActionExplodedNames($name, $type, $urlPrefix = null)
$categoryDelimiter = self::$actionUrlCategoryDelimiter;
}
-
if ($isUrl) {
$urlFragment = Action::processUrlFragment($urlFragment);
if (!empty($urlFragment)) {
@@ -504,8 +505,8 @@ private static function getDefaultRowColumns()
private static function createSummaryRow()
{
return new Row(array(
- Row::COLUMNS =>
- array('label' => DataTable::LABEL_SUMMARY_ROW) + self::getDefaultRowColumns()
- ));
+ Row::COLUMNS =>
+ array('label' => DataTable::LABEL_SUMMARY_ROW) + self::getDefaultRowColumns()
+ ));
}
}
diff --git a/plugins/Actions/Controller.php b/plugins/Actions/Controller.php
index 9ce7800197f..e6342352f65 100644
--- a/plugins/Actions/Controller.php
+++ b/plugins/Actions/Controller.php
@@ -6,23 +6,24 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Actions
+ * @package Actions
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\Actions;
+
use Piwik\ViewDataTable;
use Piwik\View;
/**
* Actions controller
*
- * @package Piwik_Actions
+ * @package Actions
*/
-class Piwik_Actions_Controller extends Controller
+class Controller extends \Piwik\Controller
{
- //
+ //
// Actions that render whole pages
- //
-
+ //
+
public function indexPageUrls($fetch = false)
{
return View::singleReport(
@@ -80,16 +81,16 @@ public function indexOutlinks($fetch = false)
Piwik_Translate('Actions_SubmenuOutlinks'),
$this->getOutlinks(true), $fetch);
}
-
- //
+
+ //
// Actions that render individual reports
- //
-
+ //
+
public function getPageUrls($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
}
-
+
public function getEntryPageUrls($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
diff --git a/plugins/Alerts/README.md b/plugins/Alerts/README.md
deleted file mode 100644
index 292963a7012..00000000000
--- a/plugins/Alerts/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Alerts
-
-
diff --git a/plugins/Annotations/API.php b/plugins/Annotations/API.php
index b165f1ba01a..cf0b9de7bf5 100755
--- a/plugins/Annotations/API.php
+++ b/plugins/Annotations/API.php
@@ -6,13 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Annotations
+ * @package Annotations
*/
+namespace Piwik\Plugins\Annotations;
+
+use Exception;
use Piwik\Period;
use Piwik\Period\Range;
use Piwik\Piwik;
use Piwik\Date;
+use Piwik\Plugins\Annotations\AnnotationList;
use Piwik\ViewDataTable;
+
/**
* @see plugins/Annotations/AnnotationList.php
*/
@@ -22,16 +27,16 @@
* API for annotations plugin. Provides methods to create, modify, delete & query
* annotations.
*
- * @package Piwik_Annotations
+ * @package Annotations
*/
-class Piwik_Annotations_API
+class API
{
static private $instance = null;
/**
* Returns this API's singleton instance.
*
- * @return Piwik_Annotations_API
+ * @return \Piwik\Plugins\Annotations\API
*/
static public function getInstance()
{
@@ -47,7 +52,7 @@ static public function getInstance()
* @param string $idSite The site ID to add the annotation to.
* @param string $date The date the annotation is attached to.
* @param string $note The text of the annotation.
- * @param int $starred Either 0 or 1. Whether the annotation should be starred.
+ * @param int $starred Either 0 or 1. Whether the annotation should be starred.
* @return array Returns an array of two elements. The first element (indexed by
* 'annotation') is the new annotation. The second element (indexed
* by 'idNote' is the new note's ID).
@@ -59,7 +64,7 @@ public function add($idSite, $date, $note, $starred = 0)
$this->checkUserCanAddNotesFor($idSite);
// add, save & return a new annotation
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
$newAnnotation = $annotations->add($idSite, $date, $note, $starred);
$annotations->save($idSite);
@@ -95,7 +100,7 @@ public function save($idSite, $idNote, $date = null, $note = null, $starred = nu
$this->checkDateIsValid($date, $canBeNull = true);
// get the annotations for the site
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
// check permissions
$this->checkUserCanModifyOrDelete($idSite, $annotations->get($idSite, $idNote));
@@ -123,7 +128,7 @@ public function delete($idSite, $idNote)
{
$this->checkSingleIdSite($idSite, $extraMessage = "Note: Cannot delete multiple notes.");
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
// check permissions
$this->checkUserCanModifyOrDelete($idSite, $annotations->get($idSite, $idNote));
@@ -152,7 +157,7 @@ public function get($idSite, $idNote)
Piwik::checkUserHasViewAccess($idSite);
// get single annotation
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
return $annotations->get($idSite, $idNote);
}
@@ -180,7 +185,7 @@ public function getAll($idSite, $date = false, $period = 'day', $lastN = false)
{
Piwik::checkUserHasViewAccess($idSite);
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
// if date/period are supplied, determine start/end date for search
list($startDate, $endDate) = self::getDateRangeForPeriod($date, $period, $lastN);
@@ -232,7 +237,7 @@ public function getAnnotationCountForDates($idSite, $date, $period, $lastN = fal
$dates[] = $startDate;
// get annotations for the site
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
// create result w/ 0-counts
$result = array();
@@ -290,7 +295,7 @@ private function checkUserCanModifyOrDelete($idSite, $annotation)
*/
private static function checkUserCanAddNotesFor($idSite)
{
- if (!Piwik_Annotations_AnnotationList::canUserAddNotesFor($idSite)) {
+ if (!AnnotationList::canUserAddNotesFor($idSite)) {
throw new Exception("The current user is not allowed to add notes for site #$idSite.");
}
}
@@ -301,7 +306,7 @@ private static function checkUserCanAddNotesFor($idSite)
*
* @param string|bool $date The start date of the period (or the date range of a range
* period).
- * @param string $period The period type ('day', 'week', 'month', 'year' or 'range').
+ * @param string $period The period type ('day', 'week', 'month', 'year' or 'range').
* @param bool|int $lastN Whether to include the last N periods in the range or not.
* Ignored if period == range.
*
diff --git a/plugins/Annotations/AnnotationList.php b/plugins/Annotations/AnnotationList.php
index 0f5ba42ae91..75b4d95df13 100755
--- a/plugins/Annotations/AnnotationList.php
+++ b/plugins/Annotations/AnnotationList.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Annotations
+ * @package Annotations
*/
+namespace Piwik\Plugins\Annotations;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Date;
use Piwik\Site;
@@ -17,7 +20,7 @@
* at once.
*
* Example use:
- * $annotations = new Piwik_Annotations_AnnotationList($idSites = "1,2,5");
+ * $annotations = new AnnotationList($idSites = "1,2,5");
* $annotation = $annotations->get($idSite = 1, $idNote = 4);
* // do stuff w/ annotation
* $annotations->update($idSite = 2, $idNote = 4, $note = "This is the new text.");
@@ -27,9 +30,9 @@
* an annotation for the same site, it's possible one of their changes will
* never get made (as it will be overwritten by the other's).
*
- * @package Piwik_Annotations
+ * @package Annotations
*/
-class Piwik_Annotations_AnnotationList
+class AnnotationList
{
const ANNOTATION_COLLECTION_OPTION_SUFFIX = '_annotations';
diff --git a/plugins/Annotations/Annotations.php b/plugins/Annotations/Annotations.php
index 5b29ec48b5b..3b756314c95 100755
--- a/plugins/Annotations/Annotations.php
+++ b/plugins/Annotations/Annotations.php
@@ -6,17 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Annotations
+ * @package Annotations
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\Annotations;
/**
* Annotations plugins. Provides the ability to attach text notes to
* dates for each sites. Notes can be viewed, modified, deleted or starred.
*
- * @package Piwik_Annotations
+ * @package Annotations
*/
-class Piwik_Annotations extends Plugin
+class Annotations extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/Annotations/Controller.php b/plugins/Annotations/Controller.php
index 739ec5deebb..00a927fe6db 100755
--- a/plugins/Annotations/Controller.php
+++ b/plugins/Annotations/Controller.php
@@ -6,19 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Annotations
+ * @package Annotations
*/
+namespace Piwik\Plugins\Annotations;
+
use Piwik\API\Request;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\Annotations\AnnotationList;
+use Piwik\Plugins\Annotations\API;
use Piwik\View;
/**
* Controller for the Annotations plugin.
*
- * @package Piwik_Annotations
+ * @package Annotations
*/
-class Piwik_Annotations_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
* Controller action that returns HTML displaying annotations for a site and
@@ -68,7 +71,7 @@ public function getAnnotationManager($fetch = false, $date = false, $period = fa
$view->period = $period;
$view->lastN = $lastN;
- list($startDate, $endDate) = Piwik_Annotations_API::getDateRangeForPeriod($date, $period, $lastN);
+ list($startDate, $endDate) = API::getDateRangeForPeriod($date, $period, $lastN);
$view->startDate = $startDate->toString();
$view->endDate = $endDate->toString();
@@ -76,7 +79,7 @@ public function getAnnotationManager($fetch = false, $date = false, $period = fa
$view->startDatePretty = $startDate->getLocalized($dateFormat);
$view->endDatePretty = $endDate->getLocalized($dateFormat);
- $view->canUserAddNotes = Piwik_Annotations_AnnotationList::canUserAddNotesFor($idSite);
+ $view->canUserAddNotes = AnnotationList::canUserAddNotesFor($idSite);
if ($fetch) {
return $view->render();
diff --git a/plugins/AnonymizeIP/AnonymizeIP.php b/plugins/AnonymizeIP/AnonymizeIP.php
index 79af7308a5e..ba0e2c22307 100644
--- a/plugins/AnonymizeIP/AnonymizeIP.php
+++ b/plugins/AnonymizeIP/AnonymizeIP.php
@@ -6,19 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_AnonymizeIP
+ * @package AnonymizeIP
*/
+namespace Piwik\Plugins\AnonymizeIP;
+
use Piwik\Config;
use Piwik\Common;
use Piwik\Version;
-use Piwik\Plugin;
/**
* Anonymize visitor IP addresses to comply with the privacy laws/guidelines in countries, such as Germany.
*
- * @package Piwik_AnonymizeIP
+ * @package AnonymizeIP
*/
-class Piwik_AnonymizeIP extends Plugin
+class AnonymizeIP extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getInformation
diff --git a/plugins/CoreAdminHome/API.php b/plugins/CoreAdminHome/API.php
index 2768708ef57..71444288e38 100644
--- a/plugins/CoreAdminHome/API.php
+++ b/plugins/CoreAdminHome/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
+namespace Piwik\Plugins\CoreAdminHome;
+
+use Exception;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Period;
use Piwik\Period\Week;
@@ -20,14 +23,14 @@
use Piwik\Db;
/**
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
-class Piwik_CoreAdminHome_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_CoreAdminHome_API
+ * @return \Piwik\Plugins\CoreAdminHome\API
*/
static public function getInstance()
{
@@ -103,7 +106,6 @@ public function invalidateArchivedReports($idSites, $dates)
}
}
-
// If using the feature "Delete logs older than N days"...
$logsAreDeletedBeforeThisDate = Config::getInstance()->Deletelogs['delete_logs_schedule_lowest_interval'];
$logsDeleteEnabled = Config::getInstance()->Deletelogs['delete_logs_enable'];
@@ -188,7 +190,7 @@ public function invalidateArchivedReports($idSites, $dates)
Db::query($query, $bind);
// Force to re-process data for these websites in the next archive.php cron run
- $invalidatedIdSites = Piwik_CoreAdminHome_API::getWebsiteIdsToInvalidate();
+ $invalidatedIdSites = self::getWebsiteIdsToInvalidate();
$invalidatedIdSites = array_merge($invalidatedIdSites, $idSites);
$invalidatedIdSites = array_unique($invalidatedIdSites);
$invalidatedIdSites = array_values($invalidatedIdSites);
diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php
index 9e040b552cc..c70ad355014 100644
--- a/plugins/CoreAdminHome/Controller.php
+++ b/plugins/CoreAdminHome/Controller.php
@@ -6,12 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
+namespace Piwik\Plugins\CoreAdminHome;
+
+use Exception;
use Piwik\API\ResponseBuilder;
use Piwik\ArchiveProcessor\Rules;
use Piwik\Config;
-use Piwik\Controller\Admin;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Nonce;
@@ -19,12 +21,15 @@
use Piwik\View;
use Piwik\Url;
use Piwik\Site;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Piwik\Plugins\LanguagesManager\API as LanguagesManagerAPI;
+use Piwik\Plugins\SitesManager\API;
/**
*
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
-class Piwik_CoreAdminHome_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
const LOGO_HEIGHT = 300;
const LOGO_SMALL_HEIGHT = 100;
@@ -66,7 +71,8 @@ public function generalSettings()
$directoryWritable = is_writable(PIWIK_DOCUMENT_ROOT . '/misc/user/');
$logoFilesWriteable = is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo.png')
&& is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo.svg')
- && is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo-header.png');;
+ && is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo-header.png');
+ ;
$view->logosWriteable = ($logoFilesWriteable || $directoryWritable) && ini_get('file_uploads') == 1;
$trustedHosts = array();
@@ -76,7 +82,7 @@ public function generalSettings()
$view->trustedHosts = $trustedHosts;
}
- $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
$this->setBasicVariablesView($view);
echo $view->render();
}
@@ -140,7 +146,7 @@ public function trackingCodeGenerator()
$this->setBasicVariablesView($view);
$view->topMenu = Piwik_GetTopMenu();
- $viewableIdSites = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
+ $viewableIdSites = API::getInstance()->getSitesIdWithAtLeastViewAccess();
$defaultIdSite = reset($viewableIdSites);
$view->idSite = Common::getRequestVar('idSite', $defaultIdSite, 'int');
@@ -148,7 +154,7 @@ public function trackingCodeGenerator()
$view->defaultReportSiteName = Site::getNameFor($view->idSite);
$view->defaultSiteRevenue = Piwik::getCurrency($view->idSite);
- $allUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($view->idSite);
+ $allUrls = API::getInstance()->getSiteUrlsFromId($view->idSite);
if (isset($allUrls[1])) {
$aliasUrl = $allUrls[1];
} else {
@@ -160,9 +166,9 @@ public function trackingCodeGenerator()
$view->defaultReportSiteDomain = @parse_url($mainUrl, PHP_URL_HOST);
// get currencies for each viewable site
- $view->currencySymbols = Piwik_SitesManager_API::getInstance()->getCurrencySymbols();
+ $view->currencySymbols = API::getInstance()->getCurrencySymbols();
- $view->serverSideDoNotTrackEnabled = \Piwik_PrivacyManager_Controller::isDntSupported();
+ $view->serverSideDoNotTrackEnabled = \Piwik\Plugins\PrivacyManager\Controller::isDntSupported();
echo $view->render();
}
@@ -185,9 +191,9 @@ public function optOut()
$view = new View('@CoreAdminHome/optOut');
$view->trackVisits = $trackVisits;
$view->nonce = Nonce::getNonce('Piwik_OptOut', 3600);
- $view->language = Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($language)
+ $view->language = LanguagesManagerAPI::getInstance()->isLanguageAvailable($language)
? $language
- : Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ : LanguagesManager::getLanguageCodeForCurrentUser();
echo $view->render();
}
diff --git a/plugins/CoreAdminHome/CoreAdminHome.php b/plugins/CoreAdminHome/CoreAdminHome.php
index c3517d88702..607df942467 100644
--- a/plugins/CoreAdminHome/CoreAdminHome.php
+++ b/plugins/CoreAdminHome/CoreAdminHome.php
@@ -6,22 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
+namespace Piwik\Plugins\CoreAdminHome;
+
use Piwik\DataAccess\ArchiveSelector;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Piwik;
use Piwik\Date;
use Piwik\ScheduledTask;
-use Piwik\Plugin;
use Piwik\Db;
use Piwik\ScheduledTime\Daily;
/**
*
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
-class Piwik_CoreAdminHome extends Plugin
+class CoreAdminHome extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -91,7 +92,6 @@ function addMenu()
array('module' => 'CoreAdminHome', 'action' => 'trackingCodeGenerator'),
Piwik::isUserHasSomeAdminAccess(),
$order = 4);
-
}
function purgeOutdatedArchives()
diff --git a/plugins/CoreHome/Controller.php b/plugins/CoreHome/Controller.php
index 15ff5f7d48c..8af95e64490 100644
--- a/plugins/CoreHome/Controller.php
+++ b/plugins/CoreHome/Controller.php
@@ -6,26 +6,30 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
+namespace Piwik\Plugins\CoreHome;
+
+use Exception;
use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
use Piwik\AssetManager;
-use Piwik\Controller;
use Piwik\FrontController;
use Piwik\View;
use Piwik\Url;
use Piwik\UpdateCheck;
use Piwik\Site;
-
+use Piwik_CoreHome_DataTableRowAction_MultiRowEvolution;
+use Piwik_CoreHome_DataTableRowAction_RowEvolution;
+use Piwik\Plugins\UsersManager\API;
/**
*
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
-class Piwik_CoreHome_Controller extends Controller
+class Controller extends \Piwik\Controller
{
function getDefaultAction()
{
@@ -34,7 +38,7 @@ function getDefaultAction()
function redirectToCoreHomeIndex()
{
- $defaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
+ $defaultReport = API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), API::PREFERENCE_DEFAULT_REPORT);
$module = 'CoreHome';
$action = 'index';
@@ -128,7 +132,6 @@ public function getJs()
Piwik::serveStaticFile($jsMergedFile, "application/javascript; charset=UTF-8");
}
-
// --------------------------------------------------------
// ROW EVOLUTION
// The following methods render the popover that shows the
@@ -219,7 +222,7 @@ public function getPromoVideo()
$view->promoVideoUrl = 'http://www.youtube.com/watch?v=OslfF_EH81g';
echo $view->render();
}
-
+
/**
* Redirects the user to a paypal so they can donate to Piwik.
*/
@@ -234,9 +237,9 @@ public function redirectToPaypal()
unset($parameters[$name]);
}
}
-
- $url = "https://www.paypal.com/cgi-bin/webscr?".Url::getQueryStringFromParameters($parameters);
-
+
+ $url = "https://www.paypal.com/cgi-bin/webscr?" . Url::getQueryStringFromParameters($parameters);
+
header("Location: $url");
exit;
}
diff --git a/plugins/CoreHome/CoreHome.php b/plugins/CoreHome/CoreHome.php
index 003cf6ee912..afb6744bf3c 100644
--- a/plugins/CoreHome/CoreHome.php
+++ b/plugins/CoreHome/CoreHome.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\CoreHome;
+
use Piwik\WidgetsList;
/**
*
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
-class Piwik_CoreHome extends Plugin
+class CoreHome extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -80,5 +81,4 @@ public function getJsFiles(&$jsFiles)
$jsFiles[] = "plugins/CoreHome/javascripts/promo.js";
$jsFiles[] = "plugins/CoreHome/javascripts/color_manager.js";
}
-
}
diff --git a/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php b/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php
index 1bdf33debe2..c2a75061479 100644
--- a/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php
+++ b/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
use Piwik\Common;
use Piwik\ViewDataTable;
@@ -14,7 +14,7 @@
/**
* MULTI ROW EVOLUTION
* The class handles the popover that shows the evolution of a multiple rows in a data table
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
class Piwik_CoreHome_DataTableRowAction_MultiRowEvolution
extends Piwik_CoreHome_DataTableRowAction_RowEvolution
diff --git a/plugins/CoreHome/DataTableRowAction/RowEvolution.php b/plugins/CoreHome/DataTableRowAction/RowEvolution.php
index 63e76f04a98..37e6e524396 100644
--- a/plugins/CoreHome/DataTableRowAction/RowEvolution.php
+++ b/plugins/CoreHome/DataTableRowAction/RowEvolution.php
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
use Piwik\API\ResponseBuilder;
use Piwik\API\Request;
@@ -21,7 +21,7 @@
/**
* ROW EVOLUTION
* The class handles the popover that shows the evolution of a singe row in a data table
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
class Piwik_CoreHome_DataTableRowAction_RowEvolution
{
diff --git a/plugins/CorePluginsAdmin/Controller.php b/plugins/CorePluginsAdmin/Controller.php
index c1156cce999..0237c26a81c 100644
--- a/plugins/CorePluginsAdmin/Controller.php
+++ b/plugins/CorePluginsAdmin/Controller.php
@@ -6,9 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CorePluginsAdmin
+ * @package CorePluginsAdmin
*/
-use Piwik\Controller\Admin;
+namespace Piwik\Plugins\CorePluginsAdmin;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Config;
@@ -17,9 +18,9 @@
/**
*
- * @package Piwik_CorePluginsAdmin
+ * @package CorePluginsAdmin
*/
-class Piwik_CorePluginsAdmin_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
function extend()
{
@@ -141,7 +142,7 @@ public function uninstall($redirectAfter = true)
{
$pluginName = $this->initPluginModification();
$uninstalled = \Piwik\PluginsManager::getInstance()->uninstallPlugin($pluginName);
- if(!$uninstalled) {
+ if (!$uninstalled) {
$path = Common::getPathToPiwikRoot() . '/plugins/' . $pluginName . '/';
$messagePermissions = Piwik::getErrorMessageMissingPermissions($path);
diff --git a/plugins/CorePluginsAdmin/CorePluginsAdmin.php b/plugins/CorePluginsAdmin/CorePluginsAdmin.php
index fe4e9d87807..6116300ce20 100644
--- a/plugins/CorePluginsAdmin/CorePluginsAdmin.php
+++ b/plugins/CorePluginsAdmin/CorePluginsAdmin.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CorePluginsAdmin
+ * @package CorePluginsAdmin
*/
+namespace Piwik\Plugins\CorePluginsAdmin;
+
use Piwik\Piwik;
-use Piwik\Plugin;
/**
*
- * @package Piwik_CorePluginsAdmin
+ * @package CorePluginsAdmin
*/
-class Piwik_CorePluginsAdmin extends Plugin
+class CorePluginsAdmin extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php
index efc492417b7..7cb89e9e300 100644
--- a/plugins/CoreUpdater/Controller.php
+++ b/plugins/CoreUpdater/Controller.php
@@ -6,14 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreUpdater
+ * @package CoreUpdater
*/
+namespace Piwik\Plugins\CoreUpdater;
+
+use Exception;
use Piwik\API\Request;
use Piwik\ArchiveProcessor\Rules;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\Http;
use Piwik\Updater;
use Piwik\View;
@@ -21,12 +23,15 @@
use Piwik\UpdateCheck;
use Piwik\Unzip;
use Piwik\View\OneClickDone;
+use Piwik\Plugins\CoreUpdater\CoreUpdater;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Updater_UpdateErrorException;
/**
*
- * @package Piwik_CoreUpdater
+ * @package CoreUpdater
*/
-class Piwik_CoreUpdater_Controller extends Controller
+class Controller extends \Piwik\Controller
{
const CONFIG_FILE_BACKUP = '/config/global.ini.auto-backup-before-update.php';
const PATH_TO_EXTRACT_LATEST_VERSION = '/tmp/latest/';
@@ -232,7 +237,7 @@ public function index()
{
$language = Common::getRequestVar('language', '');
if (!empty($language)) {
- Piwik_LanguagesManager::setLanguageForSession($language);
+ LanguagesManager::setLanguageForSession($language);
}
$this->runUpdaterAndExit();
}
@@ -240,7 +245,7 @@ public function index()
protected function runUpdaterAndExit()
{
$updater = new Updater();
- $componentsWithUpdateFile = Piwik_CoreUpdater::getComponentUpdates($updater);
+ $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater);
if (empty($componentsWithUpdateFile)) {
Piwik::redirectToModule('CoreHome');
}
diff --git a/plugins/CoreUpdater/CoreUpdater.php b/plugins/CoreUpdater/CoreUpdater.php
index 7e4d2497a5e..20f3f5c0ae9 100644
--- a/plugins/CoreUpdater/CoreUpdater.php
+++ b/plugins/CoreUpdater/CoreUpdater.php
@@ -6,21 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreUpdater
+ * @package CoreUpdater
*/
+namespace Piwik\Plugins\CoreUpdater;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\FrontController;
use Piwik\Updater;
use Piwik\Version;
use Piwik\UpdateCheck;
-use Piwik\Plugin;
/**
*
- * @package Piwik_CoreUpdater
+ * @package CoreUpdater
*/
-class Piwik_CoreUpdater extends Plugin
+class CoreUpdater extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -69,7 +71,7 @@ public function dispatch()
&& $action == 'saveLanguage')
) {
if (FrontController::shouldRethrowException()) {
- throw new Exception("Piwik and/or some plugins have been upgraded to a new version. \n".
+ throw new Exception("Piwik and/or some plugins have been upgraded to a new version. \n" .
"--> Please run the update process first. See documentation: http://piwik.org/docs/update/ \n");
} else {
Piwik::redirectToModule('CoreUpdater');
diff --git a/plugins/CustomVariables/API.php b/plugins/CustomVariables/API.php
index fb3e88456ee..21bdca1f55d 100644
--- a/plugins/CustomVariables/API.php
+++ b/plugins/CustomVariables/API.php
@@ -6,25 +6,28 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
+namespace Piwik\Plugins\CustomVariables;
+
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Date;
use Piwik\DataTable;
use Piwik\Tracker\Action;
+use Piwik\Plugins\CustomVariables\Archiver;
/**
* The Custom Variables API lets you access reports for your Custom Variables names and values.
*
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
-class Piwik_CustomVariables_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_CustomVariables_API
+ * @return \Piwik\Plugins\CustomVariables\API
*/
static public function getInstance()
{
@@ -46,7 +49,7 @@ static public function getInstance()
*/
protected function getDataTable($idSite, $period, $date, $segment, $expanded, $idSubtable)
{
- $dataTable = Archive::getDataTableFromArchive(Piwik_CustomVariables_Archiver::CUSTOM_VARIABLE_RECORD_NAME, $idSite, $period, $date, $segment, $expanded, $idSubtable);
+ $dataTable = Archive::getDataTableFromArchive(Archiver::CUSTOM_VARIABLE_RECORD_NAME, $idSite, $period, $date, $segment, $expanded, $idSubtable);
$dataTable->filter('Sort', array(Metrics::INDEX_NB_ACTIONS, 'desc', $naturalSort = false, $expanded));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ColumnDelete', 'nb_uniq_visitors');
@@ -111,7 +114,7 @@ public function getCustomVariablesValuesFromNameId($idSite, $period, $date, $idS
$dataTable->renameColumn('price_viewed', 'price');
}
$dataTable->queueFilter('ColumnCallbackReplace', array('label', create_function('$label', '
- return $label == Piwik_CustomVariables_Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED
+ return $label == \\Piwik\\Plugins\\CustomVariables\\Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED
? "' . Piwik_Translate('General_NotDefined', Piwik_Translate('CustomVariables_ColumnCustomVariableValue')) . '"
: $label;')));
return $dataTable;
diff --git a/plugins/CustomVariables/Archiver.php b/plugins/CustomVariables/Archiver.php
index e26bb0a254b..d4d3cb7884b 100644
--- a/plugins/CustomVariables/Archiver.php
+++ b/plugins/CustomVariables/Archiver.php
@@ -1,24 +1,27 @@
getSelectAveragePrice() );
+ if (in_array($slot, array(3, 4, 5))) {
+ $additionalSelects = array($this->getSelectAveragePrice());
}
$query = $this->getLogAggregator()->queryActionsByDimension($dimensions, $where, $additionalSelects);
$this->aggregateFromActions($query, $keyField, $valueField);
@@ -106,7 +109,6 @@ protected function cleanCustomVarValue($value)
return self::LABEL_CUSTOM_VALUE_NOT_DEFINED;
}
-
protected function aggregateFromActions($query, $keyField, $valueField)
{
while ($row = $query->fetch()) {
@@ -171,10 +173,9 @@ protected function aggregateActionByKeyAndValue($key, $value, $row)
protected static function isReservedKey($key)
{
- return in_array($key, Piwik_CustomVariables_API::getReservedCustomVariableKeys());
+ return in_array($key, API::getReservedCustomVariableKeys());
}
-
protected function aggregateFromConversions($query, $keyField, $valueField)
{
if ($query === false) {
@@ -190,7 +191,7 @@ protected function aggregateFromConversions($query, $keyField, $valueField)
protected function removeVisitsMetricsFromActionsAggregate()
{
- $dataArray = &$this->dataArray->getDataArray();
+ $dataArray = & $this->dataArray->getDataArray();
foreach ($dataArray as $key => &$row) {
if (!self::isReservedKey($key)
&& DataArray::isRowActions($row)
diff --git a/plugins/CustomVariables/Controller.php b/plugins/CustomVariables/Controller.php
index 5607e2c630e..da88d4e66e5 100644
--- a/plugins/CustomVariables/Controller.php
+++ b/plugins/CustomVariables/Controller.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\CustomVariables;
+
use Piwik\ViewDataTable;
use Piwik\View;
/**
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
-class Piwik_CustomVariables_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index($fetch = false)
{
diff --git a/plugins/CustomVariables/CustomVariables.php b/plugins/CustomVariables/CustomVariables.php
index 30ebb6b5808..45bc3fa14b5 100644
--- a/plugins/CustomVariables/CustomVariables.php
+++ b/plugins/CustomVariables/CustomVariables.php
@@ -6,17 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
+namespace Piwik\Plugins\CustomVariables;
+
use Piwik\ArchiveProcessor;
+use Piwik\Plugins\CustomVariables\Archiver;
use Piwik\Tracker;
-use Piwik\Plugin;
use Piwik\WidgetsList;
/**
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
-class Piwik_CustomVariables extends Plugin
+class CustomVariables extends \Piwik\Plugin
{
public function getInformation()
{
@@ -137,16 +139,16 @@ public function getReportsWithGoalMetrics(&$dimensions)
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_CustomVariables_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_CustomVariables_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
@@ -164,26 +166,26 @@ private function getDisplayPropertiesForGetCustomVariables()
array('', ''));
return array(
- 'columns_to_display' => array('label', 'nb_actions', 'nb_visits'),
- 'filter_sort_column' => 'nb_actions',
- 'filter_sort_order' => 'desc',
- 'show_goals' => true,
+ 'columns_to_display' => array('label', 'nb_actions', 'nb_visits'),
+ 'filter_sort_column' => 'nb_actions',
+ 'filter_sort_order' => 'desc',
+ 'show_goals' => true,
'subtable_controller_action' => 'getCustomVariablesValuesFromNameId',
- 'translations' => array('label' => Piwik_Translate('CustomVariables_ColumnCustomVariableName')),
- 'show_footer_message' => $footerMessage
+ 'translations' => array('label' => Piwik_Translate('CustomVariables_ColumnCustomVariableName')),
+ 'show_footer_message' => $footerMessage
);
}
private function getDisplayPropertiesForGetCustomVariablesValuesFromNameId()
{
return array(
- 'columns_to_display' => array('label', 'nb_actions', 'nb_visits'),
- 'filter_sort_column' => 'nb_actions',
- 'filter_sort_order' => 'desc',
- 'show_goals' => true,
- 'show_search' => false,
+ 'columns_to_display' => array('label', 'nb_actions', 'nb_visits'),
+ 'filter_sort_column' => 'nb_actions',
+ 'filter_sort_order' => 'desc',
+ 'show_goals' => true,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('CustomVariables_ColumnCustomVariableValue'))
+ 'translations' => array('label' => Piwik_Translate('CustomVariables_ColumnCustomVariableValue'))
);
}
}
diff --git a/plugins/DBStats/API.php b/plugins/DBStats/API.php
index 46b3666c025..11788d19a11 100644
--- a/plugins/DBStats/API.php
+++ b/plugins/DBStats/API.php
@@ -6,11 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DBStats
+ * @package DBStats
*/
+namespace Piwik\Plugins\DBStats;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\DataTable;
+use Piwik\Plugins\DBStats\MySQLMetadataProvider;
/**
* @see plugins/DBStats/MySQLMetadataProvider.php
@@ -20,9 +23,9 @@
/**
* DBStats API is used to request the overall status of the Mysql tables in use by Piwik.
*
- * @package Piwik_DBStats
+ * @package DBStats
*/
-class Piwik_DBStats_API
+class API
{
/** Singleton instance of this class. */
static private $instance = null;
@@ -48,7 +51,7 @@ static public function getInstance()
*/
public function __construct()
{
- $this->metadataProvider = new Piwik_DBStats_MySQLMetadataProvider();
+ $this->metadataProvider = new MySQLMetadataProvider();
}
/**
@@ -57,7 +60,7 @@ public function __construct()
public function resetTableStatuses()
{
Piwik::checkUserIsSuperUser();
- self::getInstance()->metadataProvider = new Piwik_DBStats_MySQLMetadataProvider();
+ self::getInstance()->metadataProvider = new MySQLMetadataProvider();
}
/**
@@ -169,8 +172,7 @@ public function getMetricDataSummaryByYear()
$dataTable = $this->getMetricDataSummary();
- $getTableYear = array('Piwik_DBStats_API', 'getArchiveTableYear');
- $dataTable->filter('GroupBy', array('label', $getTableYear));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\API::getArchiveTableYear'));
return $dataTable;
}
@@ -199,8 +201,7 @@ public function getReportDataSummaryByYear()
$dataTable = $this->getReportDataSummary();
- $getTableYear = array('Piwik_DBStats_API', 'getArchiveTableYear');
- $dataTable->filter('GroupBy', array('label', $getTableYear));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\API::getArchiveTableYear'));
return $dataTable;
}
diff --git a/plugins/DBStats/Controller.php b/plugins/DBStats/Controller.php
index 51f2a00ae6b..941b095f811 100644
--- a/plugins/DBStats/Controller.php
+++ b/plugins/DBStats/Controller.php
@@ -6,18 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DBStats
+ * @package DBStats
*/
-use Piwik\Controller\Admin;
+namespace Piwik\Plugins\DBStats;
+
use Piwik\Piwik;
+use Piwik\Plugins\DBStats\API;
use Piwik\ViewDataTable;
use Piwik\View;
/**
- *
- * @package Piwik_DBStats
+ * @package DBStats
*/
-class Piwik_DBStats_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
/**
* Returns the index for this plugin. Shows every other report defined by this plugin,
@@ -38,7 +39,7 @@ public function index()
$view->reportDataSummary = $this->getReportDataSummary(true);
$view->adminDataSummary = $this->getAdminDataSummary(true);
- list($siteCount, $userCount, $totalSpaceUsed) = Piwik_DBStats_API::getInstance()->getGeneralInformation();
+ list($siteCount, $userCount, $totalSpaceUsed) = API::getInstance()->getGeneralInformation();
$view->siteCount = Piwik::getPrettyNumber($siteCount);
$view->userCount = Piwik::getPrettyNumber($userCount);
$view->totalSpaceUsed = Piwik::getPrettySizeFromBytes($totalSpaceUsed);
diff --git a/plugins/DBStats/DBStats.php b/plugins/DBStats/DBStats.php
index def12d84a44..433f682c9fe 100644
--- a/plugins/DBStats/DBStats.php
+++ b/plugins/DBStats/DBStats.php
@@ -6,20 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DBStats
+ * @package DBStats
*/
+namespace Piwik\Plugins\DBStats;
+
use Piwik\Piwik;
use Piwik\Date;
use Piwik\Common;
+use Piwik\Plugins\DBStats\API;
use Piwik\ScheduledTask;
-use Piwik\Plugin;
use Piwik\ScheduledTime\Weekly;
/**
*
- * @package Piwik_DBStats
+ * @package DBStats
*/
-class Piwik_DBStats extends Plugin
+class DBStats extends \Piwik\Plugin
{
const TIME_OF_LAST_TASK_RUN_OPTION = 'dbstats_time_of_last_cache_task_run';
@@ -65,7 +67,7 @@ public function getScheduledTasks(&$tasks)
*/
public function cacheDataByArchiveNameReports()
{
- $api = Piwik_DBStats_API::getInstance();
+ $api = API::getInstance();
$api->getIndividualReportsSummary(true);
$api->getIndividualMetricsSummary(true);
@@ -147,7 +149,7 @@ private function getDisplayPropertiesForGetMetricDataSummary()
$result['title'] = Piwik_Translate('DBStats_MetricTables');
$result['relatedReports'] = array(
- 'DBStats.getMetricDataSummaryByYear' => Piwik_Translate('DBStats_MetricDataByYear')
+ 'DBStats.getMetricDataSummaryByYear' => Piwik_Translate('DBStats_MetricDataByYear')
);
return $result;
@@ -161,8 +163,8 @@ private function getDisplayPropertiesForGetMetricDataSummaryByYear()
$result['translations']['label'] = Piwik_Translate('CoreHome_PeriodYear');
$result['title'] = Piwik_Translate('DBStats_MetricDataByYear');
- $result['relatedReports'] = array(
- 'DBStats.getMetricDataSummary' => Piwik_Translate('DBStats_MetricTables')
+ $result['relatedReports'] = array(
+ 'DBStats.getMetricDataSummary' => Piwik_Translate('DBStats_MetricTables')
);
return $result;
@@ -191,7 +193,7 @@ private function getDisplayPropertiesForGetReportDataSummaryByYear()
$result['translations']['label'] = Piwik_Translate('CoreHome_PeriodYear');
$result['title'] = Piwik_Translate('DBStats_ReportDataByYear');
$result['relatedReports'] = array(
- 'DBStats.getReportDataSummary' => Piwik_Translate('DBStats_ReportTables')
+ 'DBStats.getReportDataSummary' => Piwik_Translate('DBStats_ReportTables')
);
return $result;
@@ -202,7 +204,7 @@ private function getDisplayPropertiesForGetIndividualReportsSummary()
$result = array();
$this->addBaseDisplayProperties($result);
$viewDataTable = $this->addPresentationFilters($result, $addTotalSizeColumn = false, $addPercentColumn = false,
- $sizeColumns = array('estimated_size'));
+ $sizeColumns = array('estimated_size'));
$result['filter_sort_order'] = 'asc';
$result['translations']['label'] = Piwik_Translate('General_Report');
@@ -222,7 +224,7 @@ private function getDisplayPropertiesForGetIndividualMetricsSummary()
$result = array();
$this->addBaseDisplayProperties($result);
$this->addPresentationFilters($result, $addTotalSizeColumn = false, $addPercentColumn = false,
- $sizeColumns = array('estimated_size'));
+ $sizeColumns = array('estimated_size'));
$result['filter_sort_order'] = 'asc';
$result['translations']['label'] = Piwik_Translate('General_Metric');
@@ -279,7 +281,7 @@ private function addPresentationFilters(&$properties, $addTotalSizeColumn = true
};
$properties['filters'][] = array('ColumnCallbackAddColumn',
- array(array('data_size', 'index_size'), 'total_size', $getTotalTableSize), $isPriority = true);
+ array(array('data_size', 'index_size'), 'total_size', $getTotalTableSize), $isPriority = true);
$sizeColumns[] = 'total_size';
}
@@ -299,9 +301,9 @@ private function addPresentationFilters(&$properties, $addTotalSizeColumn = true
&& $addTotalSizeColumn
) {
$properties['filters'][] = array('ColumnCallbackAddColumnPercentage',
- array('percent_total', 'total_size', 'total_size', $quotientPrecision = 0,
- $shouldSkipRows = false, $getDivisorFromSummaryRow = true),
- $isPriority = true
+ array('percent_total', 'total_size', 'total_size', $quotientPrecision = 0,
+ $shouldSkipRows = false, $getDivisorFromSummaryRow = true),
+ $isPriority = true
);
$properties['filter_sort_column'] = 'percent_total';
diff --git a/plugins/DBStats/MySQLMetadataProvider.php b/plugins/DBStats/MySQLMetadataProvider.php
index d47713cf301..4e39d508875 100755
--- a/plugins/DBStats/MySQLMetadataProvider.php
+++ b/plugins/DBStats/MySQLMetadataProvider.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DBStats
+ * @package DBStats
*/
+namespace Piwik\Plugins\DBStats;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Config;
use Piwik\DataTable;
use Piwik\Db;
-
/**
* Utility class that provides general information about databases, including the size of
* the entire database, the size and row count of each table and the size and row count
@@ -23,7 +25,7 @@
* This class will cache the table information it retrieves from the database. In order to
* issue a new query instead of using this cache, you must create a new instance of this type.
*/
-class Piwik_DBStats_MySQLMetadataProvider
+class MySQLMetadataProvider
{
/**
* Cached MySQL table statuses. So we won't needlessly re-issue SHOW TABLE STATUS queries.
diff --git a/plugins/Dashboard/API.php b/plugins/Dashboard/API.php
index dd879797395..1330eacef6a 100644
--- a/plugins/Dashboard/API.php
+++ b/plugins/Dashboard/API.php
@@ -5,21 +5,22 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
* @category Piwik_Plugins
- * @package Piwik_Dashboard
+ * @package Dashboard
*/
+namespace Piwik\Plugins\Dashboard;
+
use Piwik\Piwik;
use Piwik\WidgetsList;
-
/**
* This API is the Dashboard API: it gives information about dashboards.
*
* @package Piwik_API
*/
-class Piwik_Dashboard_API
+class API
{
/**
- * @var Piwik_Dashboard_API
+ * @var \Piwik\Plugins\Dashboard\API
*/
static private $instance = null;
@@ -27,11 +28,11 @@ class Piwik_Dashboard_API
public function __construct()
{
- $this->dashboard = new Piwik_Dashboard();
+ $this->dashboard = new Dashboard();
}
/**
- * @return Piwik_Dashboard_API
+ * @return \Piwik\Plugins\Dashboard\API
*/
static public function getInstance()
{
@@ -83,7 +84,7 @@ private function getDefaultDashboard()
*/
private function getUserDashboards()
{
- $userLogin = Piwik::getCurrentUserLogin();
+ $userLogin = Piwik::getCurrentUserLogin();
$userDashboards = $this->dashboard->getAllDashboards($userLogin);
$dashboards = array();
@@ -91,10 +92,9 @@ private function getUserDashboards()
foreach ($userDashboards as $userDashboard) {
if ($this->hasDashboardColumns($userDashboard)) {
- $widgets = $this->getExistingWidgetsWithinDashboard($userDashboard);
+ $widgets = $this->getExistingWidgetsWithinDashboard($userDashboard);
$dashboards[] = $this->buildDashboard($userDashboard, $widgets);
}
-
}
return $dashboards;
@@ -111,8 +111,8 @@ private function getExistingWidgetsWithinDashboard($dashboard)
foreach ($column as $widget) {
if ($this->widgetIsNotHidden($widget) && $this->widgetExists($widget)) {
- $module = $widget->parameters->module;
- $action = $widget->parameters->action;
+ $module = $widget->parameters->module;
+ $action = $widget->parameters->action;
$widgets[] = array('module' => $module, 'action' => $action);
}
diff --git a/plugins/Dashboard/Controller.php b/plugins/Dashboard/Controller.php
index 7ffe0dc79e3..bded95b33e5 100644
--- a/plugins/Dashboard/Controller.php
+++ b/plugins/Dashboard/Controller.php
@@ -5,12 +5,14 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
* @category Piwik_Plugins
- * @package Piwik_Dashboard
+ * @package Dashboard
*/
+namespace Piwik\Plugins\Dashboard;
+
use Piwik\DataTable\Renderer\Json;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\Dashboard\Dashboard;
use Piwik\Session\SessionNamespace;
use Piwik\View;
use Piwik\Db;
@@ -19,12 +21,12 @@
/**
* Dashboard Controller
*
- * @package Piwik_Dashboard
+ * @package Dashboard
*/
-class Piwik_Dashboard_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
- * @var Piwik_Dashboard
+ * @var Dashboard
*/
private $dashboard;
@@ -32,7 +34,7 @@ protected function init()
{
parent::init();
- $this->dashboard = new Piwik_Dashboard();
+ $this->dashboard = new Dashboard();
}
protected function _getDashboardView($template)
@@ -96,7 +98,7 @@ public function resetLayout()
$layout = $this->dashboard->getDefaultLayout();
$idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
if (Piwik::isUserIsAnonymous()) {
- $session = new SessionNamespace("Piwik_Dashboard");
+ $session = new SessionNamespace("Dashboard");
$session->dashboardLayout = $layout;
$session->setExpirationSeconds(1800);
} else {
@@ -161,15 +163,15 @@ public function removeDashboard()
public function getAllDashboards()
{
$this->checkTokenInUrl();
-
+
if (Piwik::isUserIsAnonymous()) {
Json::sendHeaderJSON();
echo '[]';
-
+
return;
}
- $login = Piwik::getCurrentUserLogin();
+ $login = Piwik::getCurrentUserLogin();
$dashboards = $this->dashboard->getAllDashboards($login);
Json::sendHeaderJSON();
@@ -260,7 +262,7 @@ public function saveLayout()
$idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
$name = Common::getRequestVar('name', '', 'string');
if (Piwik::isUserIsAnonymous()) {
- $session = new SessionNamespace("Piwik_Dashboard");
+ $session = new SessionNamespace("Dashboard");
$session->dashboardLayout = $layout;
$session->setExpirationSeconds(1800);
} else {
@@ -298,14 +300,13 @@ protected function getLayout($idDashboard)
{
if (Piwik::isUserIsAnonymous()) {
- $session = new SessionNamespace("Piwik_Dashboard");
+ $session = new SessionNamespace("Dashboard");
if (!isset($session->dashboardLayout)) {
return $this->dashboard->getDefaultLayout();
}
$layout = $session->dashboardLayout;
-
} else {
$layout = $this->dashboard->getLayoutForUser(Piwik::getCurrentUserLogin(), $idDashboard);
}
@@ -335,7 +336,6 @@ protected function getAvailableLayouts()
array(25, 25, 25, 25)
);
}
-
}
diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php
index 13d25ee9cbd..58618e05b4e 100644
--- a/plugins/Dashboard/Dashboard.php
+++ b/plugins/Dashboard/Dashboard.php
@@ -6,19 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Dashboard
+ * @package Dashboard
*/
+namespace Piwik\Plugins\Dashboard;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Plugin;
use Piwik\Site;
use Piwik\Db;
use Piwik\WidgetsList;
+use Zend_Registry;
/**
- * @package Piwik_Dashboard
+ * @package Dashboard
*/
-class Piwik_Dashboard extends Plugin
+class Dashboard extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/DevicesDetection/API.php b/plugins/DevicesDetection/API.php
index 1800849fcf6..250919c5658 100644
--- a/plugins/DevicesDetection/API.php
+++ b/plugins/DevicesDetection/API.php
@@ -1,5 +1,4 @@
getDataTable('DevicesDetection_types', $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getDeviceTypeLabel'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getDeviceTypeLabel'));
$dataTable->filter('ColumnCallbackReplace', array('label', 'ucfirst'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getDeviceTypeLogo'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getDeviceTypeLogo'));
return $dataTable;
}
@@ -81,8 +83,8 @@ public function getType($idSite, $period, $date, $segment = false)
public function getBrand($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_brands', $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getDeviceBrandLabel'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_GetBrandLogo'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getDeviceBrandLabel'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrandLogo'));
return $dataTable;
}
@@ -97,7 +99,7 @@ public function getBrand($idSite, $period, $date, $segment = false)
public function getModel($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_models', $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getModelName'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getModelName'));
return $dataTable;
}
@@ -112,8 +114,8 @@ public function getModel($idSite, $period, $date, $segment = false)
public function getOsFamilies($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_os', $idSite, $period, $date, $segment);
- $dataTable->filter('GroupBy', array('label', 'Piwik_getOSFamilyFullNameExtended'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getOsFamilyLogoExtended'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getOSFamilyFullNameExtended'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsFamilyLogoExtended'));
return $dataTable;
}
@@ -128,15 +130,15 @@ public function getOsFamilies($idSite, $period, $date, $segment = false)
public function getOsVersions($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_osVersions', $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getOsLogoExtended'));
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getOsFullNameExtended'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsLogoExtended'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getOsFullNameExtended'));
return $dataTable;
}
/**
* Gets datatable displaying number of visits by Browser family (eg. Firefox, InternetExplorer)
- * @param int $idSite
+ * @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
@@ -145,8 +147,8 @@ public function getOsVersions($idSite, $period, $date, $segment = false)
public function getBrowserFamilies($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_browsers', $idSite, $period, $date, $segment);
- $dataTable->filter('GroupBy', array('label', 'Piwik_getBrowserFamilyFullNameExtended'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getBrowserFamilyLogoExtended'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserFamilyFullNameExtended'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowserFamilyLogoExtended'));
return $dataTable;
}
@@ -161,9 +163,8 @@ public function getBrowserFamilies($idSite, $period, $date, $segment = false)
public function getBrowserVersions($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_browserVersions', $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getBrowserLogoExtended'));
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getBrowserNameExtended'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowserLogoExtended'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getBrowserNameExtended'));
return $dataTable;
}
-
}
\ No newline at end of file
diff --git a/plugins/DevicesDetection/Archiver.php b/plugins/DevicesDetection/Archiver.php
index 73a66fb67d3..58b1df2cca9 100644
--- a/plugins/DevicesDetection/Archiver.php
+++ b/plugins/DevicesDetection/Archiver.php
@@ -6,13 +6,15 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DevicesDetection
+ * @package DevicesDetection
*/
+namespace Piwik\Plugins\DevicesDetection;
+
use Piwik\Metrics;
use Piwik\PluginsArchiver;
-class Piwik_DevicesDetection_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const DEVICE_TYPE_RECORD_NAME = 'DevicesDetection_types';
const DEVICE_BRAND_RECORD_NAME = 'DevicesDetection_brands';
@@ -32,16 +34,16 @@ class Piwik_DevicesDetection_Archiver extends PluginsArchiver
public function archiveDay()
{
- $this->aggregateByLabel( self::DEVICE_TYPE_FIELD, self::DEVICE_TYPE_RECORD_NAME);
- $this->aggregateByLabel( self::DEVICE_BRAND_FIELD, self::DEVICE_BRAND_RECORD_NAME);
- $this->aggregateByLabel( self::DEVICE_MODEL_FIELD, self::DEVICE_MODEL_RECORD_NAME);
- $this->aggregateByLabel( self::OS_FIELD, self::OS_RECORD_NAME);
- $this->aggregateByLabel( self::OS_VERSION_FIELD, self::OS_VERSION_RECORD_NAME);
- $this->aggregateByLabel( self::BROWSER_FIELD, self::BROWSER_RECORD_NAME);
- $this->aggregateByLabel( self::BROWSER_VERSION_DIMENSION, self::BROWSER_VERSION_RECORD_NAME);
+ $this->aggregateByLabel(self::DEVICE_TYPE_FIELD, self::DEVICE_TYPE_RECORD_NAME);
+ $this->aggregateByLabel(self::DEVICE_BRAND_FIELD, self::DEVICE_BRAND_RECORD_NAME);
+ $this->aggregateByLabel(self::DEVICE_MODEL_FIELD, self::DEVICE_MODEL_RECORD_NAME);
+ $this->aggregateByLabel(self::OS_FIELD, self::OS_RECORD_NAME);
+ $this->aggregateByLabel(self::OS_VERSION_FIELD, self::OS_VERSION_RECORD_NAME);
+ $this->aggregateByLabel(self::BROWSER_FIELD, self::BROWSER_RECORD_NAME);
+ $this->aggregateByLabel(self::BROWSER_VERSION_DIMENSION, self::BROWSER_VERSION_RECORD_NAME);
}
- private function aggregateByLabel( $labelSQL, $recordName)
+ private function aggregateByLabel($labelSQL, $recordName)
{
$metrics = $this->getProcessor()->getMetricsForDimension($labelSQL);
$table = $this->getProcessor()->getDataTableFromDataArray($metrics);
diff --git a/plugins/DevicesDetection/Controller.php b/plugins/DevicesDetection/Controller.php
index 189729e81e7..ac0beb50d48 100644
--- a/plugins/DevicesDetection/Controller.php
+++ b/plugins/DevicesDetection/Controller.php
@@ -1,12 +1,4 @@
"[Beta Plugin] " . Piwik_Translate("DevicesDetection_description"),
- 'author' => 'Piwik and Clearcode.cc',
+ 'description' => "[Beta Plugin] " . Piwik_Translate("DevicesDetection_description"),
+ 'author' => 'Piwik and Clearcode.cc',
'author_homepage' => 'http://clearcode.cc',
- 'version' => '1.12-b6',
+ 'version' => '1.12-b6',
);
}
-
/**
* @see Piwik_Plugin::getListHooksRegistered
*/
public function getListHooksRegistered()
{
return array(
- 'ArchiveProcessing_Day.compute' => "archiveDay",
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'Menu.add' => 'addMenu',
- 'Tracker.newVisitorInformation' => 'parseMobileVisitData',
- 'WidgetsList.add' => 'addWidgets',
- 'API.getReportMetadata' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ArchiveProcessing_Day.compute' => "archiveDay",
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'Menu.add' => 'addMenu',
+ 'Tracker.newVisitorInformation' => 'parseMobileVisitData',
+ 'WidgetsList.add' => 'addWidgets',
+ 'API.getReportMetadata' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
}
@@ -155,7 +158,6 @@ public function addWidgets()
}
}
-
/**
* Get segments meta data
*/
@@ -187,12 +189,12 @@ public function getReportMetadata(&$reports)
continue;
$report = array(
- 'category' => Piwik_Translate($category),
- 'name' => Piwik_Translate($name),
- 'module' => $apiModule,
- 'action' => $apiAction,
+ 'category' => Piwik_Translate($category),
+ 'name' => Piwik_Translate($name),
+ 'module' => $apiModule,
+ 'action' => $apiAction,
'dimension' => Piwik_Translate($columnName),
- 'order' => $i++
+ 'order' => $i++
);
$translation = $name . 'Documentation';
@@ -201,7 +203,6 @@ public function getReportMetadata(&$reports)
$report['documentation'] = $translated;
}
-
$reports[] = $report;
}
}
@@ -223,7 +224,7 @@ public function install()
Db::exec($q2);
}
} catch (Exception $e) {
- if (!Zend_Registry::get('db')->isErrNo($e, '1060')) {
+ if (!Zend_Registry::get('db')->isErrNo($e, '1060')) {
throw $e;
}
}
@@ -254,16 +255,16 @@ public function parseMobileVisitData(&$visitorInfo, $extraInfo)
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_DevicesDetection_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_DevicesDetection_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
@@ -287,70 +288,70 @@ public function getReportDisplayProperties(&$properties)
private function getDisplayPropertiesForGetType()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelTypes"))
+ 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelTypes"))
);
}
private function getDisplayPropertiesForGetBrand()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrands"))
+ 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrands"))
);
}
private function getDisplayPropertiesForGetModel()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelModels"))
+ 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelModels"))
);
}
private function getDisplayPropertiesForGetOsFamilies()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelSystemFamily")),
- 'title' => Piwik_Translate('DeviceDetection_OperatingSystemFamilies'),
- 'relatedReports' => $this->getOsRelatedReports()
+ 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelSystemFamily")),
+ 'title' => Piwik_Translate('DeviceDetection_OperatingSystemFamilies'),
+ 'relatedReports' => $this->getOsRelatedReports()
);
}
private function getDisplayPropertiesForGetOsVersions()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelSystemVersion")),
- 'title' => Piwik_Translate('DeviceDetection_OperatingSystemVersions'),
- 'relatedReports' => $this->getOsRelatedReports()
+ 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelSystemVersion")),
+ 'title' => Piwik_Translate('DeviceDetection_OperatingSystemVersions'),
+ 'relatedReports' => $this->getOsRelatedReports()
);
}
private function getDisplayPropertiesForGetBrowserFamilies()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrowserFamily")),
- 'title' => Piwik_Translate('DevicesDetection_BrowsersFamily'),
- 'relatedReports' => $this->getBrowserRelatedReports()
+ 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrowserFamily")),
+ 'title' => Piwik_Translate('DevicesDetection_BrowsersFamily'),
+ 'relatedReports' => $this->getBrowserRelatedReports()
);
}
private function getDisplayPropertiesForGetBrowserVersions()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrowserVersion")),
- 'relatedReports' => $this->getBrowserRelatedReports()
+ 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrowserVersion")),
+ 'relatedReports' => $this->getBrowserRelatedReports()
);
}
diff --git a/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php b/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php
index d078305d978..a8ec8e22042 100644
--- a/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php
+++ b/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php
@@ -7,7 +7,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DevicesDetection
+ * @package DevicesDetection
*/
//yml parser
require_once(PIWIK_INCLUDE_PATH.'/libs/spyc.php');
diff --git a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/browsers.yml b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/browsers.yml
index 9ab3bc4c1cf..351aa7f2681 100644
--- a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/browsers.yml
+++ b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/browsers.yml
@@ -5,7 +5,7 @@
# @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
#
# @category Piwik_Plugins
-# @package Piwik_DevicesDetection
+# @package DevicesDetection
###############
# SeaMonkey
diff --git a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/mobiles.yml b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/mobiles.yml
index d9a2a22f886..46ae6b9c975 100644
--- a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/mobiles.yml
+++ b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/mobiles.yml
@@ -5,7 +5,7 @@
# @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
#
# @category Piwik_Plugins
-# @package Piwik_DevicesDetection
+# @package DevicesDetection
###############
# HTC
diff --git a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml
index 71b85f987f7..918a00487d3 100644
--- a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml
+++ b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml
@@ -5,7 +5,7 @@
# @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
#
# @category Piwik_Plugins
-# @package Piwik_DevicesDetection
+# @package DevicesDetection
###############
##########
diff --git a/plugins/DevicesDetection/functions.php b/plugins/DevicesDetection/functions.php
index 4819cd69742..92a4b3e84ee 100644
--- a/plugins/DevicesDetection/functions.php
+++ b/plugins/DevicesDetection/functions.php
@@ -1,5 +1,4 @@
$family) {
if (in_array($label, $family)) {
@@ -29,7 +33,7 @@ function Piwik_getBrowserFamilyFullNameExtended($label)
return Piwik_Translate('General_Unknown');
}
-function Piwik_getBrowserFamilyLogoExtended($label)
+function getBrowserFamilyLogoExtended($label)
{
if (array_key_exists($label, UserAgentParserEnhanced::$browserFamilies)) {
$path = 'plugins/UserSettings/images/browsers/' . UserAgentParserEnhanced::$browserFamilies[$label][0] . '.gif';
@@ -39,7 +43,7 @@ function Piwik_getBrowserFamilyLogoExtended($label)
return $path;
}
-function Piwik_getBrowserNameExtended($label)
+function getBrowserNameExtended($label)
{
$short = substr($label, 0, 2);
$ver = substr($label, 3, 10);
@@ -50,17 +54,17 @@ function Piwik_getBrowserNameExtended($label)
}
}
-function Piwik_getBrowserLogoExtended($label)
+function getBrowserLogoExtended($label)
{
$short = substr($label, 0, 2);
- $familyName = Piwik_getBrowserFamilyFullNameExtended($short);
- $path = Piwik_getBrowserFamilyLogoExtended($familyName);
+ $familyName = getBrowserFamilyFullNameExtended($short);
+ $path = getBrowserFamilyLogoExtended($familyName);
return $path;
}
-function Piwik_getDeviceBrandLabel($label)
+function getDeviceBrandLabel($label)
{
if (array_key_exists($label, UserAgentParserEnhanced::$deviceBrands)) {
return ucfirst(UserAgentParserEnhanced::$deviceBrands[$label]);
@@ -69,7 +73,7 @@ function Piwik_getDeviceBrandLabel($label)
}
}
-function Piwik_getDeviceTypeLabel($label)
+function getDeviceTypeLabel($label)
{
if (isset(UserAgentParserEnhanced::$deviceTypes[$label])) {
return UserAgentParserEnhanced::$deviceTypes[$label];
@@ -78,7 +82,7 @@ function Piwik_getDeviceTypeLabel($label)
}
}
-function Piwik_getDeviceTypeLogo($label)
+function getDeviceTypeLogo($label)
{
$deviceTypeLogos = Array(
"Desktop" => "normal.gif",
@@ -97,7 +101,7 @@ function Piwik_getDeviceTypeLogo($label)
return $path;
}
-function Piwik_getModelName($label)
+function getModelName($label)
{
if (!$label) {
return Piwik_Translate('General_Unknown');
@@ -105,7 +109,7 @@ function Piwik_getModelName($label)
return $label;
}
-function Piwik_getOSFamilyFullNameExtended($label)
+function getOSFamilyFullNameExtended($label)
{
foreach (UserAgentParserEnhanced::$osFamilies as $name => $family) {
if (in_array($label, $family)) {
@@ -115,7 +119,7 @@ function Piwik_getOSFamilyFullNameExtended($label)
return Piwik_Translate('General_Unknown');
}
-function Piwik_getOsFamilyLogoExtended($label)
+function getOsFamilyLogoExtended($label)
{
if (array_key_exists($label, UserAgentParserEnhanced::$osFamilies)) {
$path = 'plugins/UserSettings/images/os/' . UserAgentParserEnhanced::$osFamilies[$label][0] . ".gif";
@@ -125,7 +129,7 @@ function Piwik_getOsFamilyLogoExtended($label)
return $path;
}
-function Piwik_getOsFullNameExtended($label)
+function getOsFullNameExtended($label)
{
if (!empty($label) && $label != ";") {
$os = substr($label, 0, 3);
@@ -140,10 +144,10 @@ function Piwik_getOsFullNameExtended($label)
-function Piwik_getOsLogoExtended($label)
+function getOsLogoExtended($label)
{
$short = substr($label, 0, 3);
- $familyName = Piwik_getOsFamilyFullNameExtended($short);
- $path = Piwik_getOsFamilyLogoExtended($familyName);
+ $familyName = getOsFamilyFullNameExtended($short);
+ $path = getOsFamilyLogoExtended($familyName);
return $path;
}
\ No newline at end of file
diff --git a/plugins/DoNotTrack/DoNotTrack.php b/plugins/DoNotTrack/DoNotTrack.php
index 8d9a3cf7002..1a02788a274 100644
--- a/plugins/DoNotTrack/DoNotTrack.php
+++ b/plugins/DoNotTrack/DoNotTrack.php
@@ -6,9 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DoNotTrack
+ * @package DoNotTrack
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\DoNotTrack;
+
use Piwik\Common;
use Piwik\Tracker\IgnoreCookie;
use Piwik\Tracker\Request;
@@ -18,9 +19,9 @@
* - X-Do-Not-Track header (used by AdBlockPlus and NoScript)
* - DNT header (used by Mozilla)
*
- * @package Piwik_DoNotTrack
+ * @package DoNotTrack
*/
-class Piwik_DoNotTrack extends Plugin
+class DoNotTrack extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/ExampleAPI/API.php b/plugins/ExampleAPI/API.php
index 214d73eac55..a6c012a6440 100644
--- a/plugins/ExampleAPI/API.php
+++ b/plugins/ExampleAPI/API.php
@@ -8,9 +8,11 @@
* @category Piwik_Plugins
* @package Piwik_ExampleAPI
*/
+namespace Piwik\Plugins\ExampleAPI;
+
+use Piwik\DataTable;
use Piwik\DataTable\Row;
use Piwik\Piwik;
-use Piwik\DataTable;
use Piwik\Version;
/**
@@ -19,7 +21,7 @@
* Please see the source code in in the file plugins/ExampleAPI/API.php for more documentation.
* @package Piwik_ExampleAPI
*/
-class Piwik_ExampleAPI_API
+class API
{
/**
* * This is an example of a basic API file. Each plugin can have one public API.
@@ -38,14 +40,14 @@ class Piwik_ExampleAPI_API
*
* It is highly recommended that all the plugin logic is done inside API implementations, and the
* Controller and other objects would all call the API internally using, eg.
- * Piwik_ExampleAPI_API::getInstance()->getSum(1, 2);
+ * API::getInstance()->getSum(1, 2);
*
*/
static private $instance = null;
/**
* Singleton
- * @return Piwik_ExampleAPI_API
+ * @return \Piwik\Plugins\ExampleAPI\API
*/
static public function getInstance()
{
@@ -80,11 +82,11 @@ public function getAnswerToLife()
* If used internally, the data structure can be returned untouched by using
* the API parameter 'format=original'
*
- * @return Piwik_MagicObject Will return a standard Piwik error when called from the Web APIs
+ * @return MagicObject Will return a standard Piwik error when called from the Web APIs
*/
public function getObject()
{
- return new Piwik_MagicObject();
+ return new MagicObject();
}
/**
@@ -180,9 +182,9 @@ public function getMultiArray()
/**
* Magic Object
*
- * @package Piwik_ExamplePlugin
+ * @package ExamplePlugin
*/
-class Piwik_MagicObject
+class MagicObject
{
function Incredible()
{
@@ -191,4 +193,4 @@ function Incredible()
protected $wonderful = 'magnifique';
public $great = 'formidable';
-}
+}
\ No newline at end of file
diff --git a/plugins/ExampleAPI/ExampleAPI.php b/plugins/ExampleAPI/ExampleAPI.php
deleted file mode 100644
index da1c3f4c527..00000000000
--- a/plugins/ExampleAPI/ExampleAPI.php
+++ /dev/null
@@ -1,20 +0,0 @@
-WidgetsList::add( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array()); - Adds a widget that users can add in the dashboard, or export using the Widgets link at the top of the screen. See the example in the UserCountry Plugin file or any other plugin)
';
$out .= 'Common::prefixTable("site")
= ' . Common::prefixTable("site") . '
';
-
$out .= '
User access
';
$out .= 'Piwik::getCurrentUserLogin()
= ' . Piwik::getCurrentUserLogin() . '
';
$out .= 'Piwik::isUserHasSomeAdminAccess()
= ' . self::boolToString(Piwik::isUserHasSomeAdminAccess()) . '
';
@@ -112,19 +112,19 @@ public function index()
$out .= 'At this point, we have: $fetched[\'token_auth\'] == ' . var_export($token_auth, true) . '
';
$out .= 'Example Sites information API
';
- $out .= 'Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess()
= ' . var_export(Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess(), true) . '
';
- $out .= 'Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess()
= ' . var_export(Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess(), true) . '
';
+ $out .= 'API::getInstance()->getSitesWithViewAccess()
= ' . var_export(API::getInstance()->getSitesWithViewAccess(), true) . '
';
+ $out .= 'API::getInstance()->getSitesWithAdminAccess()
= ' . var_export(API::getInstance()->getSitesWithAdminAccess(), true) . '
';
$out .= 'Example API Users information
';
$out .= 'View the list of API methods you can call on API reference
';
- $out .= 'For example you can try Piwik_UsersManager_API::getInstance()->getUsersSitesFromAccess("view");
or Piwik_UsersManager_API::getInstance()->deleteUser("userToDelete");
';
+ $out .= 'For example you can try API::getInstance()->getUsersSitesFromAccess("view");
or API::getInstance()->deleteUser("userToDelete");
';
$out .= 'Javascript in Piwik
';
$out .= 'i18n internationalization
';
$out .= 'In order to translate strings within Javascript code, you can use the javascript function _pk_translate( token );.
- The "token" parameter is the string unique key found in the translation file. For this token string to be available in Javascript, you must
suffix your token by "_js" in the language file. For example, you can add
\'Goals_AddGoal_js\' => \'Add Goal\',
in the lang/en.php file
- - You then need to instruct Piwik to load your Javascript translations for your plugin; by default, all translation strings are not loaded in Javascript for performance reasons. This can be done by calling a custom-made Twig modifier before the Javascript code requiring translations, eg.
+
- You then need to instruct Piwik to load your Javascript translations for your plugin; by default, all translation strings are not loaded in Javascript for performance reasons. This can be done by calling a custom-made Twig modifier before the Javascript code requiring translations, eg.
{loadJavascriptTranslations plugins=\'$YOUR_PLUGIN_NAME\'}
. In our previous example, the $YOUR_PLUGIN_NAME being Goals, we would write {loadJavascriptTranslations plugins=\'Goals\'}
- You can then print this string from your JS code by doing
_pk_translate(\'Goals_AddGoal_js\');
.
';
diff --git a/plugins/ExamplePlugin/ExamplePlugin.php b/plugins/ExamplePlugin/ExamplePlugin.php
index 481c324b5d8..812898291d6 100644
--- a/plugins/ExamplePlugin/ExamplePlugin.php
+++ b/plugins/ExamplePlugin/ExamplePlugin.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExamplePlugin
+ * @package ExamplePlugin
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\ExamplePlugin;
+
use Piwik\WidgetsList;
/**
*
- * @package Piwik_ExamplePlugin
+ * @package ExamplePlugin
*/
-class Piwik_ExamplePlugin extends Plugin
+class ExamplePlugin extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/ExamplePlugin/lang/en.php b/plugins/ExamplePlugin/lang/en.php
index 9be43dddeac..eaec0c99401 100644
--- a/plugins/ExamplePlugin/lang/en.php
+++ b/plugins/ExamplePlugin/lang/en.php
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExamplePlugin
+ * @package ExamplePlugin
*/
$translations = array(
diff --git a/plugins/ExampleRssWidget/Controller.php b/plugins/ExampleRssWidget/Controller.php
index aaa53a7ef16..45e5a44cdcd 100644
--- a/plugins/ExampleRssWidget/Controller.php
+++ b/plugins/ExampleRssWidget/Controller.php
@@ -6,20 +6,24 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
-use Piwik\Controller;
+
+namespace Piwik\Plugins\ExampleRssWidget;
+
+use Exception;
+use Piwik\Plugins\ExampleRssWidget\RssRenderer;
/**
*
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
-class Piwik_ExampleRssWidget_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function rssPiwik()
{
try {
- $rss = new Piwik_ExampleRssWidget_Rss('http://feeds.feedburner.com/Piwik');
+ $rss = new RssRenderer('http://feeds.feedburner.com/Piwik');
$rss->showDescription(true);
echo $rss->get();
} catch (Exception $e) {
@@ -30,7 +34,7 @@ public function rssPiwik()
public function rssChangelog()
{
try {
- $rss = new Piwik_ExampleRssWidget_Rss('http://feeds.feedburner.com/PiwikReleases');
+ $rss = new RssRenderer('http://feeds.feedburner.com/PiwikReleases');
$rss->setCountPosts(1);
$rss->showDescription(false);
$rss->showContent(true);
diff --git a/plugins/ExampleRssWidget/ExampleRssWidget.php b/plugins/ExampleRssWidget/ExampleRssWidget.php
index a23daf88ee5..868913959ef 100644
--- a/plugins/ExampleRssWidget/ExampleRssWidget.php
+++ b/plugins/ExampleRssWidget/ExampleRssWidget.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\ExampleRssWidget;
+
use Piwik\WidgetsList;
/**
*
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
-class Piwik_ExampleRssWidget extends Plugin
+class ExampleRssWidget extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/ExampleRssWidget/Rss.php b/plugins/ExampleRssWidget/RssRenderer.php
similarity index 92%
rename from plugins/ExampleRssWidget/Rss.php
rename to plugins/ExampleRssWidget/RssRenderer.php
index ee95a8a56dc..1b7baa1ba2b 100644
--- a/plugins/ExampleRssWidget/Rss.php
+++ b/plugins/ExampleRssWidget/RssRenderer.php
@@ -6,14 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
+namespace Piwik\Plugins\ExampleRssWidget;
+
+use Zend_Feed;
+use Zend_Feed_Exception;
+
/**
*
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
-class Piwik_ExampleRssWidget_Rss
+class RssRenderer
{
protected $url = null;
protected $count = 3;
diff --git a/plugins/ExampleUI/API.php b/plugins/ExampleUI/API.php
index 4fc0c513f86..d2128fa296c 100644
--- a/plugins/ExampleUI/API.php
+++ b/plugins/ExampleUI/API.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
+namespace Piwik\Plugins\ExampleUI;
+
use Piwik\Period\Range;
use Piwik\DataTable;
@@ -17,14 +19,14 @@
* The functions listed in this API are returning the data used in the Controller to draw graphs and
* display tables. See also the ExampleAPI plugin for an introduction to Piwik APIs.
*
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
-class Piwik_ExampleUI_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_ExampleUI_API
+ * @return \Piwik\Plugins\ExampleUI\API
*/
static public function getInstance()
{
diff --git a/plugins/ExampleUI/Controller.php b/plugins/ExampleUI/Controller.php
index 5660190aaaf..201610f7e7b 100644
--- a/plugins/ExampleUI/Controller.php
+++ b/plugins/ExampleUI/Controller.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
+namespace Piwik\Plugins\ExampleUI;
+
use Piwik\Common;
-use Piwik\Controller;
use Piwik\ViewDataTable;
use Piwik\View;
/**
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
-class Piwik_ExampleUI_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function dataTables()
{
@@ -122,7 +123,7 @@ public function generateSparkline()
if ($serverRequested !== false) {
$view->columns_to_display = array($serverRequested);
}
-
+
echo $view->render();
}
diff --git a/plugins/ExampleUI/ExampleUI.php b/plugins/ExampleUI/ExampleUI.php
index 4e1210cf14b..fcd6120cca4 100644
--- a/plugins/ExampleUI/ExampleUI.php
+++ b/plugins/ExampleUI/ExampleUI.php
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
/*
@@ -18,13 +18,14 @@
- without all columns icon
+ update http://piwik.org/participate/user-interface
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\ExampleUI;
+
/**
*
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
-class Piwik_ExampleUI extends Plugin
+class ExampleUI extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/Feedback/Controller.php b/plugins/Feedback/Controller.php
index 3a43559d6f9..2b80b18ad28 100644
--- a/plugins/Feedback/Controller.php
+++ b/plugins/Feedback/Controller.php
@@ -6,12 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Feedback
+ * @package Feedback
*/
+namespace Piwik\Plugins\Feedback;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\IP;
use Piwik\Mail;
use Piwik\Nonce;
@@ -21,14 +23,14 @@
/**
*
- * @package Piwik_Feedback
+ * @package Feedback
*/
-class Piwik_Feedback_Controller extends Controller
+class Controller extends \Piwik\Controller
{
function index()
{
$view = new View('@Feedback/index');
- $view->nonce = Nonce::getNonce('Piwik_Feedback.sendFeedback', 3600);
+ $view->nonce = Nonce::getNonce('Feedback.sendFeedback', 3600);
echo $view->render();
}
@@ -60,10 +62,10 @@ function sendFeedback()
if (preg_match('/https?:/i', $body)) {
throw new Exception(Piwik_TranslateException('Feedback_ExceptionNoUrls'));
}
- if (!Nonce::verifyNonce('Piwik_Feedback.sendFeedback', $nonce)) {
+ if (!Nonce::verifyNonce('Feedback.sendFeedback', $nonce)) {
throw new Exception(Piwik_TranslateException('General_ExceptionNonceMismatch'));
}
- Nonce::discardNonce('Piwik_Feedback.sendFeedback');
+ Nonce::discardNonce('Feedback.sendFeedback');
$mail = new Mail();
$mail->setFrom(Common::unsanitizeInputValue($email));
diff --git a/plugins/Feedback/Feedback.php b/plugins/Feedback/Feedback.php
index 522c09fe96d..48f8d297f40 100644
--- a/plugins/Feedback/Feedback.php
+++ b/plugins/Feedback/Feedback.php
@@ -6,15 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Feedback
+ * @package Feedback
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\Feedback;
+
/**
*
- * @package Piwik_Feedback
+ * @package Feedback
*/
-class Piwik_Feedback extends Plugin
+class Feedback extends \Piwik\Plugin
{
/**
diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php
index 3eb1a62e281..c80ade9ac35 100644
--- a/plugins/Goals/API.php
+++ b/plugins/Goals/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Goals
+ * @package Goals
*/
+namespace Piwik\Plugins\Goals;
+
+use Exception;
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
@@ -17,6 +20,8 @@
use Piwik\Db;
use Piwik\Tracker\Cache;
use Piwik\Tracker\GoalManager;
+use Piwik\Plugins\Goals\Goals;
+use Piwik\Plugins\Goals\Archiver;
/**
* Goals API lets you Manage existing goals, via "updateGoal" and "deleteGoal", create new Goals via "addGoal",
@@ -36,14 +41,14 @@
*
* See also the documentation about Tracking Goals in Piwik.
*
- * @package Piwik_Goals
+ * @package Goals
*/
-class Piwik_Goals_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_Goals_API
+ * @return \Piwik\Plugins\Goals\API
*/
static public function getInstance()
{
@@ -199,7 +204,7 @@ public function deleteGoal($idSite, $idGoal)
Piwik::checkUserHasAdminAccess($idSite);
Db::query("UPDATE " . Common::prefixTable('goal') . "
SET deleted = 1
- WHERE idsite = ?
+ WHERE idsite = ?
AND idgoal = ?",
array($idSite, $idGoal));
Db::deleteAllRows(Common::prefixTable("log_conversion"), "WHERE idgoal = ?", 100000, array($idGoal));
@@ -215,11 +220,11 @@ protected function getItems($recordName, $idSite, $period, $date, $abandonedCart
Piwik::checkUserHasViewAccess($idSite);
$recordNameFinal = $recordName;
if ($abandonedCarts) {
- $recordNameFinal = Piwik_Goals_Archiver::getItemRecordNameAbandonedCart($recordName);
+ $recordNameFinal = Archiver::getItemRecordNameAbandonedCart($recordName);
}
$archive = Archive::build($idSite, $period, $date);
$dataTable = $archive->getDataTable($recordNameFinal);
-
+
$dataTable->filter('Sort', array(Metrics::INDEX_ECOMMERCE_ITEM_REVENUE));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
@@ -238,7 +243,8 @@ protected function getItems($recordName, $idSite, $period, $date, $abandonedCart
$dataTable->queueFilter('ColumnDelete', array('price'));
// Enrich the datatable with Product/Categories views, and conversion rates
- $customVariables = Piwik_CustomVariables_API::getInstance()->getCustomVariables($idSite, $period, $date, $segment = false, $expanded = false, $_leavePiwikCoreVariables = true);
+ $customVariables = \Piwik\Plugins\CustomVariables\API::getInstance()->getCustomVariables($idSite, $period, $date, $segment = false, $expanded = false,
+ $_leavePiwikCoreVariables = true);
$mapping = array(
'Goals_ItemsSku' => '_pks',
'Goals_ItemsName' => '_pkn',
@@ -295,16 +301,15 @@ protected function renameNotDefinedRow($dataTable, $notDefinedStringPretty)
}
return;
}
- $rowNotDefined = $dataTable->getRowFromLabel(Piwik_CustomVariables_Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED);
+ $rowNotDefined = $dataTable->getRowFromLabel(\Piwik\Plugins\CustomVariables\Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED);
if ($rowNotDefined) {
$rowNotDefined->setColumn('label', $notDefinedStringPretty);
}
}
-
protected function enrichItemsDataTableWithItemsViewMetrics($dataTable, $idSite, $period, $date, $idSubtable)
{
- $ecommerceViews = Piwik_CustomVariables_API::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment = false, $_leavePriceViewedColumn = true);
+ $ecommerceViews = \Piwik\Plugins\CustomVariables\API::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment = false, $_leavePriceViewedColumn = true);
// For Product names and SKU reports, and for Category report
// Use the Price (tracked on page views)
@@ -385,7 +390,7 @@ public function get($idSite, $period, $date, $segment = false, $idGoal = false,
$idGoal = self::convertSpecialGoalIds($idGoal);
if (empty($columns)) {
- $columns = Piwik_Goals::getGoalColumns($idGoal);
+ $columns = Goals::getGoalColumns($idGoal);
if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
$columns[] = 'avg_order_revenue';
}
@@ -399,7 +404,7 @@ public function get($idSite, $period, $date, $segment = false, $idGoal = false,
}
$columnsToSelect = array();
foreach ($columns as &$columnName) {
- $columnsToSelect[] = Piwik_Goals_Archiver::getRecordName($columnName, $idGoal);
+ $columnsToSelect[] = Archiver::getRecordName($columnName, $idGoal);
}
$dataTable = $archive->getDataTableFromNumeric($columnsToSelect);
@@ -447,7 +452,7 @@ protected function getNumeric($idSite, $period, $date, $segment, $toFetch)
*/
public function getConversions($idSite, $period, $date, $segment = false, $idGoal = false)
{
- return $this->getNumeric($idSite, $period, $date, $segment, Piwik_Goals_Archiver::getRecordName('nb_conversions', $idGoal));
+ return $this->getNumeric($idSite, $period, $date, $segment, Archiver::getRecordName('nb_conversions', $idGoal));
}
/**
@@ -455,7 +460,7 @@ public function getConversions($idSite, $period, $date, $segment = false, $idGoa
*/
public function getNbVisitsConverted($idSite, $period, $date, $segment = false, $idGoal = false)
{
- return $this->getNumeric($idSite, $period, $date, $segment, Piwik_Goals_Archiver::getRecordName('nb_visits_converted', $idGoal));
+ return $this->getNumeric($idSite, $period, $date, $segment, Archiver::getRecordName('nb_visits_converted', $idGoal));
}
/**
@@ -463,7 +468,7 @@ public function getNbVisitsConverted($idSite, $period, $date, $segment = false,
*/
public function getConversionRate($idSite, $period, $date, $segment = false, $idGoal = false)
{
- return $this->getNumeric($idSite, $period, $date, $segment, Piwik_Goals_Archiver::getRecordName('conversion_rate', $idGoal));
+ return $this->getNumeric($idSite, $period, $date, $segment, Archiver::getRecordName('conversion_rate', $idGoal));
}
/**
@@ -471,7 +476,7 @@ public function getConversionRate($idSite, $period, $date, $segment = false, $id
*/
public function getRevenue($idSite, $period, $date, $segment = false, $idGoal = false)
{
- return $this->getNumeric($idSite, $period, $date, $segment, Piwik_Goals_Archiver::getRecordName('revenue', $idGoal));
+ return $this->getNumeric($idSite, $period, $date, $segment, Archiver::getRecordName('revenue', $idGoal));
}
/**
@@ -498,7 +503,7 @@ protected function getGoalSpecificDataTable($recordName, $idSite, $period, $date
$realGoalId = $idGoal != true ? false : self::convertSpecialGoalIds($idGoal);
// get the data table
- $dataTable = $archive->getDataTable(Piwik_Goals_Archiver::getRecordName($recordName, $realGoalId), $idSubtable = null);
+ $dataTable = $archive->getDataTable(Archiver::getRecordName($recordName, $realGoalId), $idSubtable = null);
$dataTable->queueFilter('ReplaceColumnNames');
return $dataTable;
@@ -519,7 +524,7 @@ protected function getGoalSpecificDataTable($recordName, $idSite, $period, $date
public function getDaysToConversion($idSite, $period, $date, $segment = false, $idGoal = false)
{
$dataTable = $this->getGoalSpecificDataTable(
- Piwik_Goals_Archiver::DAYS_UNTIL_CONV_RECORD_NAME, $idSite, $period, $date, $segment, $idGoal);
+ Archiver::DAYS_UNTIL_CONV_RECORD_NAME, $idSite, $period, $date, $segment, $idGoal);
$dataTable->queueFilter('Sort', array('label', 'asc', true));
$dataTable->queueFilter(
@@ -543,7 +548,7 @@ public function getDaysToConversion($idSite, $period, $date, $segment = false, $
public function getVisitsUntilConversion($idSite, $period, $date, $segment = false, $idGoal = false)
{
$dataTable = $this->getGoalSpecificDataTable(
- Piwik_Goals_Archiver::VISITS_UNTIL_RECORD_NAME, $idSite, $period, $date, $segment, $idGoal);
+ Archiver::VISITS_UNTIL_RECORD_NAME, $idSite, $period, $date, $segment, $idGoal);
$dataTable->queueFilter('Sort', array('label', 'asc', true));
$dataTable->queueFilter(
diff --git a/plugins/Goals/Archiver.php b/plugins/Goals/Archiver.php
index cad582453aa..ae0cbf3b079 100644
--- a/plugins/Goals/Archiver.php
+++ b/plugins/Goals/Archiver.php
@@ -6,17 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Goals
+ * @package Goals
*/
+namespace Piwik\Plugins\Goals;
+
use Piwik\DataAccess\LogAggregator;
use Piwik\Metrics;
use Piwik\DataTable;
use Piwik\DataArray;
use Piwik\PluginsArchiver;
use Piwik\Tracker\GoalManager;
+use Piwik\Plugins\Goals\Goals;
-class Piwik_Goals_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const VISITS_UNTIL_RECORD_NAME = 'visits_until_conv';
const DAYS_UNTIL_CONV_RECORD_NAME = 'days_until_conv';
@@ -120,7 +123,7 @@ protected function archiveGeneralGoalMetrics()
unset($row['label']);
$values = array();
- foreach($conversionMetrics as $field => $statement) {
+ foreach ($conversionMetrics as $field => $statement) {
$values[$field] = $row[$field];
}
$goals->sumMetrics($idGoal, $values);
@@ -173,7 +176,7 @@ protected function getConversionsNumericMetrics(DataArray $goals)
$recordName = self::getRecordName($metricName, $idGoal);
$numericRecords[$recordName] = $value;
}
- if(!empty($array[Metrics::INDEX_GOAL_NB_VISITS_CONVERTED])) {
+ if (!empty($array[Metrics::INDEX_GOAL_NB_VISITS_CONVERTED])) {
$conversion_rate = $this->getConversionRate($array[Metrics::INDEX_GOAL_NB_VISITS_CONVERTED]);
$recordName = self::getRecordName('conversion_rate', $idGoal);
$numericRecords[$recordName] = $conversion_rate;
@@ -330,8 +333,9 @@ protected function cleanupRowGetLabel(&$row, $currentField)
}
$label = "Value not defined";
// Product Name/Category not defined"
- if (class_exists('Piwik_CustomVariables')) {
- $label = Piwik_CustomVariables_Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED;
+ //TODOA : working?
+ if (class_exists('Piwik\Plugins\CustomVariables\CustomVariables')) {
+ $label = \Piwik\Plugins\CustomVariables\Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED;
}
}
@@ -403,7 +407,7 @@ public function archivePeriod()
$fieldsToSum = array();
foreach ($goalIdsToSum as $goalId) {
- $metricsToSum = Piwik_Goals::getGoalColumns($goalId);
+ $metricsToSum = Goals::getGoalColumns($goalId);
unset($metricsToSum[array_search('conversion_rate', $metricsToSum)]);
foreach ($metricsToSum as $metricName) {
$fieldsToSum[] = self::getRecordName($metricName, $goalId);
@@ -419,13 +423,13 @@ public function archivePeriod()
// sum up the visits to conversion data table & the days to conversion data table
$this->getProcessor()->aggregateDataTableReports(array(
- self::getRecordName(self::VISITS_UNTIL_RECORD_NAME, $goalId),
- self::getRecordName(self::DAYS_UNTIL_CONV_RECORD_NAME, $goalId)));
+ self::getRecordName(self::VISITS_UNTIL_RECORD_NAME, $goalId),
+ self::getRecordName(self::DAYS_UNTIL_CONV_RECORD_NAME, $goalId)));
}
// sum up goal overview reports
$this->getProcessor()->aggregateDataTableReports(array(
- self::getRecordName(self::VISITS_UNTIL_RECORD_NAME),
- self::getRecordName(self::DAYS_UNTIL_CONV_RECORD_NAME)));
+ self::getRecordName(self::VISITS_UNTIL_RECORD_NAME),
+ self::getRecordName(self::DAYS_UNTIL_CONV_RECORD_NAME)));
}
}
\ No newline at end of file
diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php
index 17a5e38fae1..c9e10f40747 100644
--- a/plugins/Goals/Controller.php
+++ b/plugins/Goals/Controller.php
@@ -6,24 +6,28 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Goals
+ * @package Goals
*/
+namespace Piwik\Plugins\Goals;
+
+use Exception;
use Piwik\API\Request;
use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\DataTable;
-use Piwik\Controller;
use Piwik\FrontController;
use Piwik\View\ReportsByDimension;
use Piwik\ViewDataTable;
use Piwik\View;
+use Piwik\Plugins\Goals\Goals;
+use Piwik\Plugins\Referers\API as ReferersAPI;
/**
*
- * @package Piwik_Goals
+ * @package Goals
*/
-class Piwik_Goals_Controller extends Controller
+class Controller extends \Piwik\Controller
{
const CONVERSION_RATE_PRECISION = 1;
@@ -58,7 +62,7 @@ public function __construct()
{
parent::__construct();
$this->idSite = Common::getRequestVar('idSite', null, 'int');
- $this->goals = Piwik_Goals_API::getInstance()->getGoals($this->idSite);
+ $this->goals = API::getInstance()->getGoals($this->idSite);
foreach ($this->goals as &$goal) {
$goal['name'] = Common::sanitizeInputValue($goal['name']);
if (isset($goal['pattern'])) {
@@ -137,10 +141,10 @@ protected function getGoalReportView($idGoal = false)
// conversion rate for new and returning visitors
$segment = 'visitorType==returning,visitorType==returningCustomer';
- $conversionRateReturning = Piwik_Goals_API::getInstance()->getConversionRate($this->idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), $segment, $idGoal);
+ $conversionRateReturning = API::getInstance()->getConversionRate($this->idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), $segment, $idGoal);
$view->conversion_rate_returning = $this->formatConversionRate($conversionRateReturning);
$segment = 'visitorType==new';
- $conversionRateNew = Piwik_Goals_API::getInstance()->getConversionRate($this->idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), $segment, $idGoal);
+ $conversionRateNew = API::getInstance()->getConversionRate($this->idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), $segment, $idGoal);
$view->conversion_rate_new = $this->formatConversionRate($conversionRateNew);
$view->goalReportsByDimension = $this->getGoalReportsByDimensionTable(
$view->nb_conversions, isset($ecommerce), !empty($view->cart_nb_conversions));
@@ -150,7 +154,7 @@ protected function getGoalReportView($idGoal = false)
public function index()
{
$view = $this->getOverviewView();
-
+
// unsanitize goal names and other text data (not done in API so as not to break
// any other code/cause security issues)
$goals = $this->goals;
@@ -161,7 +165,7 @@ public function index()
}
}
$view->goalsJSON = Common::json_encode($goals);
-
+
$view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite);
$view->ecommerceEnabled = $this->site->isEcommerceEnabled();
$view->displayFullReport = true;
@@ -294,7 +298,6 @@ public function getEvolutionGraph($fetch = false, array $columns = array(), $idG
return $this->renderView($view, $fetch);
}
-
protected function getTopDimensions($idGoal)
{
$columnNbConversions = 'goal_' . $idGoal . '_nb_conversions';
@@ -310,7 +313,7 @@ protected function getTopDimensions($idGoal)
$keywordNotDefinedString = '';
if (\Piwik\PluginsManager::getInstance()->isPluginActivated('Referers')) {
- $keywordNotDefinedString = Piwik_Referers_API::getKeywordNotDefinedString();
+ $keywordNotDefinedString = ReferersAPI::getKeywordNotDefinedString();
$topDimensionsToLoad += array(
'keyword' => 'Referers.getKeywords',
'website' => 'Referers.getWebsites',
@@ -436,12 +439,12 @@ private function getGoalReportsByDimensionTable($conversions, $ecommerce = false
$customParams['idGoal'] = '0'; // NOTE: Must be string! Otherwise Piwik_View_HtmlTable_Goals fails.
}
- $allReports = Piwik_Goals::getReportsWithGoalMetrics();
+ $allReports = Goals::getReportsWithGoalMetrics();
foreach ($allReports as $category => $reports) {
$categoryText = Piwik_Translate('Goals_ViewGoalsBy', $category);
foreach ($reports as $report) {
$customParams['viewDataTable'] = 'tableGoals';
- if(in_array($report['action'], array('getVisitsUntilConversion', 'getDaysToConversion'))) {
+ if (in_array($report['action'], array('getVisitsUntilConversion', 'getDaysToConversion'))) {
$customParams['viewDataTable'] = 'table';
}
@@ -453,16 +456,16 @@ private function getGoalReportsByDimensionTable($conversions, $ecommerce = false
return $goalReportsByDimension->render();
}
-
- //
+
+ //
// Report rendering actions
- //
+ //
public function getItemsSku($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
}
-
+
public function getItemsName($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php
index 4dc4685c59a..2d3bd0de27d 100644
--- a/plugins/Goals/Goals.php
+++ b/plugins/Goals/Goals.php
@@ -6,23 +6,26 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Goals
+ * @package Goals
*/
+namespace Piwik\Plugins\Goals;
+
use Piwik\ArchiveProcessor;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Plugins\Goals\API;
+use Piwik\Plugins\Goals\Archiver;
use Piwik\Tracker\GoalManager;
use Piwik\TranslationWriter;
-use Piwik\Plugin;
use Piwik\Site;
use Piwik\WidgetsList;
use Piwik\Db;
/**
*
- * @package Piwik_Goals
+ * @package Goals
*/
-class Piwik_Goals extends Plugin
+class Goals extends \Piwik\Plugin
{
protected $ecommerceReports = array(
array('Goals_ProductSKU', 'Goals', 'getItemsSku'),
@@ -85,17 +88,17 @@ public function getInformation()
public function getListHooksRegistered()
{
$hooks = array(
- 'AssetManager.getJsFiles' => 'getJsFiles',
- 'AssetManager.getCssFiles' => 'getCssFiles',
- 'Common.fetchWebsiteAttributes' => 'fetchGoalsFromDb',
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'API.getReportMetadata.end' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenus',
- 'SitesManager.deleteSite' => 'deleteSiteGoals',
- 'Goals.getReportsWithGoalMetrics' => 'getActualReportsWithGoalMetrics',
+ 'AssetManager.getJsFiles' => 'getJsFiles',
+ 'AssetManager.getCssFiles' => 'getCssFiles',
+ 'Common.fetchWebsiteAttributes' => 'fetchGoalsFromDb',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'API.getReportMetadata.end' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenus',
+ 'SitesManager.deleteSite' => 'deleteSiteGoals',
+ 'Goals.getReportsWithGoalMetrics' => 'getActualReportsWithGoalMetrics',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties', // TODO: ViewDataTable should get ALL once
);
return $hooks;
@@ -153,7 +156,7 @@ public function getReportMetadata(&$reports, $info)
// If only one website is selected, we add the Goal metrics
if (count($idSites) == 1) {
$idSite = reset($idSites);
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
// Add overall visits to conversion report
$reports[] = array(
@@ -350,7 +353,6 @@ public function getReportMetadata(&$reports, $info)
}
}
}
-
}
static public function getProductReportColumns()
@@ -412,7 +414,7 @@ public function getCssFiles(&$cssFiles)
public function fetchGoalsFromDb(&$array, $idSite)
{
// add the 'goal' entry in the website array
- $array['goals'] = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $array['goals'] = API::getInstance()->getGoals($idSite);
}
public function addWidgets()
@@ -431,7 +433,7 @@ public function addWidgets()
// Goals widgets
WidgetsList::add('Goals_Goals', 'Goals_GoalsOverview', 'Goals', 'widgetGoalsOverview');
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
if (count($goals) > 0) {
foreach ($goals as $goal) {
WidgetsList::add('Goals_Goals', Common::sanitizeInputValue($goal['name']), 'Goals', 'widgetGoalReport', array('idGoal' => $goal['idgoal']));
@@ -442,7 +444,7 @@ public function addWidgets()
function addMenus()
{
$idSite = Common::getRequestVar('idSite', null, 'int');
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
$mainGoalMenu = $this->getGoalCategoryName($idSite);
$site = new Site($idSite);
if (count($goals) == 0) {
@@ -487,8 +489,8 @@ protected function getGoalCategoryName($idSite)
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_Goals_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
@@ -499,12 +501,12 @@ public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
*/
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_Goals_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
-
+
public function getReportDisplayProperties(&$properties)
{
$properties['Goals.getItemsSku'] = $this->getDisplayPropertiesForGetItemsSku();
@@ -513,86 +515,86 @@ public function getReportDisplayProperties(&$properties)
$properties['Goals.getVisitsUntilConversion'] = $this->getDisplayPropertiesForGetVisitsUntilConversion();
$properties['Goals.getDaysToConversion'] = $this->getDisplayPropertiesForGetDaysToConversion();
}
-
+
private function getDisplayPropertiesForGetItemsSku()
{
return $this->getDisplayPropertiesForItemsReport(Piwik_Translate('Goals_ProductSKU'));
}
-
+
private function getDisplayPropertiesForGetItemsName()
{
return $this->getDisplayPropertiesForItemsReport(Piwik_Translate('Goals_ProductName'));
}
-
+
private function getDisplayPropertiesForGetItemsCategory()
{
return $this->getDisplayPropertiesForItemsReport(Piwik_Translate('Goals_ProductCategory'));
}
-
+
private function getDisplayPropertiesForGetVisitsUntilConversion()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'show_table_all_columns' => false,
- 'columns_to_display' => array('label', 'nb_conversions'),
- 'filter_sort_column' => 'label',
- 'filter_sort_order' => 'asc',
- 'translations' => array(
- 'label' => Piwik_Translate('Goals_VisitsUntilConv'),
+ 'show_table_all_columns' => false,
+ 'columns_to_display' => array('label', 'nb_conversions'),
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array(
+ 'label' => Piwik_Translate('Goals_VisitsUntilConv'),
'nb_conversions' => Piwik_Translate('Goals_ColumnConversions'),
),
- 'filter_limit' => count(Piwik_Goals_Archiver::$visitCountRanges),
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'show_all_views_icons' => false
+ 'filter_limit' => count(Archiver::$visitCountRanges),
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'show_all_views_icons' => false
);
}
-
+
private function getDisplayPropertiesForGetDaysToConversion()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'show_table_all_columns' => false,
- 'columns_to_display' => array('label', 'nb_conversions'),
- 'filter_sort_column' => 'label',
- 'filter_sort_order' => 'asc',
- 'translations' => array(
- 'label' => Piwik_Translate('Goals_DaysToConv'),
+ 'show_table_all_columns' => false,
+ 'columns_to_display' => array('label', 'nb_conversions'),
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array(
+ 'label' => Piwik_Translate('Goals_DaysToConv'),
'nb_conversions' => Piwik_Translate('Goals_ColumnConversions'),
),
- 'filter_limit' => count(Piwik_Goals_Archiver::$daysToConvRanges),
- 'show_all_views_icons' => false,
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
+ 'filter_limit' => count(Archiver::$daysToConvRanges),
+ 'show_all_views_icons' => false,
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
);
}
-
+
private function getDisplayPropertiesForItemsReport($label)
{
$idSite = Common::getRequestVar('idSite');
-
+
$moneyColumns = array('revenue', 'avg_price');
$prettifyMoneyColumns = array(
'ColumnCallbackReplace', array($moneyColumns, '\Piwik\Piwik::getPrettyMoney', array($idSite)));
-
+
$result = array(
- 'show_ecommerce' => true,
- 'show_all_views_icons' => false,
- 'show_table' => false,
+ 'show_ecommerce' => true,
+ 'show_all_views_icons' => false,
+ 'show_table' => false,
'show_exclude_low_population' => false,
- 'show_table_all_columns' => false,
- 'filter_limit' => 10,
- 'translations' => array('label' => $label),
- 'filter_sort_column' => 'revenue',
- 'filter_sort_order' => 'desc',
- 'filters' => array($prettifyMoneyColumns)
+ 'show_table_all_columns' => false,
+ 'filter_limit' => 10,
+ 'translations' => array('label' => $label),
+ 'filter_sort_column' => 'revenue',
+ 'filter_sort_order' => 'desc',
+ 'filters' => array($prettifyMoneyColumns)
);
-
+
// set columns/translations which differ based on viewDataTable TODO: shouldn't have to do this check... amount of reports should be dynamic, but metadata should be static
- $columns = Piwik_Goals::getProductReportColumns();
-
+ $columns = Goals::getProductReportColumns();
+
$abandonedCart = Common::getRequestVar('viewDataTable', 'ecommerceOrder', 'string') == 'ecommerceAbandonedCart';
if ($abandonedCart) {
$columns['abandoned_carts'] = Piwik_Translate('General_AbandonedCarts');
@@ -601,13 +603,13 @@ private function getDisplayPropertiesForItemsReport($label)
$columns['avg_quantity'] = Piwik_Translate('Goals_LeftInCart', Piwik_Translate('General_AverageQuantity'));
unset($columns['orders']);
unset($columns['conversion_rate']);
-
+
$result['request_parameters_to_modify'] = array('abandonedCarts' => '1');
}
-
+
$result['translations'] = array_merge(array('label' => $label), $columns);
$result['columns_to_display'] = array_keys($result['translations']);
-
+
// set metrics documentation in normal ecommerce report
if (!$abandonedCart) {
$result['metrics_documentation'] = array(
@@ -621,10 +623,10 @@ private function getDisplayPropertiesForItemsReport($label)
'conversion_rate' => Piwik_Translate('Goals_ColumnConversionRateProductDocumentation', $label),
);
}
-
+
$result['custom_parameters']['viewDataTable'] =
$abandonedCart ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART : Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER;
-
+
return $result;
}
}
diff --git a/plugins/ImageGraph/API.php b/plugins/ImageGraph/API.php
index dafd9d93998..17c9c760c7a 100644
--- a/plugins/ImageGraph/API.php
+++ b/plugins/ImageGraph/API.php
@@ -6,12 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph
+ * @package ImageGraph
*/
+namespace Piwik\Plugins\ImageGraph;
+
use Piwik\Period;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Translate;
+use Piwik\Plugins\API\API as MetaAPI;
+use Piwik\Plugins\ImageGraph\StaticGraph;
/**
* The ImageGraph.get API call lets you generate beautiful static PNG Graphs for any existing Piwik report.
@@ -24,9 +28,9 @@
*
* See also How to embed static Image Graphs? for more information.
*
- * @package Piwik_ImageGraph
+ * @package ImageGraph
*/
-class Piwik_ImageGraph_API
+class API
{
const FILENAME_KEY = 'filename';
const TRUNCATE_KEY = 'truncate';
@@ -36,31 +40,31 @@ class Piwik_ImageGraph_API
const MAX_HEIGHT = 2048;
static private $DEFAULT_PARAMETERS = array(
- Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_LINE => array(
+ StaticGraph::GRAPH_TYPE_BASIC_LINE => array(
self::FILENAME_KEY => 'BasicLine',
self::TRUNCATE_KEY => 6,
self::WIDTH_KEY => 1044,
self::HEIGHT_KEY => 290,
),
- Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_VERTICAL_BAR => array(
+ StaticGraph::GRAPH_TYPE_VERTICAL_BAR => array(
self::FILENAME_KEY => 'BasicBar',
self::TRUNCATE_KEY => 6,
self::WIDTH_KEY => 1044,
self::HEIGHT_KEY => 290,
),
- Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR => array(
+ StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR => array(
self::FILENAME_KEY => 'HorizontalBar',
self::TRUNCATE_KEY => null, // horizontal bar graphs are dynamically truncated
self::WIDTH_KEY => 800,
self::HEIGHT_KEY => 290,
),
- Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_3D_PIE => array(
+ StaticGraph::GRAPH_TYPE_3D_PIE => array(
self::FILENAME_KEY => '3DPie',
self::TRUNCATE_KEY => 5,
self::WIDTH_KEY => 1044,
self::HEIGHT_KEY => 290,
),
- Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_PIE => array(
+ StaticGraph::GRAPH_TYPE_BASIC_PIE => array(
self::FILENAME_KEY => 'BasicPie',
self::TRUNCATE_KEY => 5,
self::WIDTH_KEY => 1044,
@@ -71,11 +75,11 @@ class Piwik_ImageGraph_API
static private $DEFAULT_GRAPH_TYPE_OVERRIDE = array(
'UserSettings_getPlugin' => array(
false // override if !$isMultiplePeriod
- => Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR,
+ => StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR,
),
'Referers_getRefererType' => array(
false // override if !$isMultiplePeriod
- => Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR,
+ => StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR,
),
);
@@ -100,7 +104,7 @@ class Piwik_ImageGraph_API
static private $instance = null;
/**
- * @return Piwik_ImageGraph_API
+ * @return \Piwik\Plugins\ImageGraph\API
*/
static public function getInstance()
{
@@ -118,29 +122,31 @@ public function get(
$apiModule,
$apiAction,
$graphType = false,
- $outputType = Piwik_ImageGraph_API::GRAPH_OUTPUT_INLINE,
+ $outputType = API::GRAPH_OUTPUT_INLINE,
$columns = false,
$labels = false,
$showLegend = true,
$width = false,
$height = false,
- $fontSize = Piwik_ImageGraph_API::DEFAULT_FONT_SIZE,
+ $fontSize = API::DEFAULT_FONT_SIZE,
$legendFontSize = false,
$aliasedGraph = true,
$idGoal = false,
$colors = false,
- $textColor = Piwik_ImageGraph_API::DEFAULT_TEXT_COLOR,
- $backgroundColor = Piwik_ImageGraph_API::DEFAULT_BACKGROUND_COLOR,
- $gridColor = Piwik_ImageGraph_API::DEFAULT_GRID_COLOR,
+ $textColor = API::DEFAULT_TEXT_COLOR,
+ $backgroundColor = API::DEFAULT_BACKGROUND_COLOR,
+ $gridColor = API::DEFAULT_GRID_COLOR,
$idSubtable = false,
$legendAppendMetric = true,
$segment = false
- ) {
+ )
+ {
Piwik::checkUserHasViewAccess($idSite);
// Health check - should we also test for GD2 only?
if (!Piwik::isGdExtensionEnabled()) {
- throw new Exception('Error: To create graphs in Piwik, please enable GD php extension (with Freetype support) in php.ini, and restart your web server.');
+ throw new \Exception('Error: To create graphs in Piwik, please enable GD php extension (with Freetype support) in php.ini,
+ and restart your web server.');
}
$useUnicodeFont = array(
@@ -162,7 +168,7 @@ public function get(
$apiParameters = array('idGoal' => $idGoal);
}
// Fetch the metadata for given api-action
- $metadata = Piwik_API_API::getInstance()->getMetadata(
+ $metadata = MetaAPI::getInstance()->getMetadata(
$idSite, $apiModule, $apiAction, $apiParameters, $languageLoaded, $period, $date,
$hideMetricsDoc = false, $showSubtableReports = true);
if (!$metadata) {
@@ -184,12 +190,12 @@ public function get(
if (empty($graphType)) {
if ($isMultiplePeriod) {
- $graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_LINE;
+ $graphType = StaticGraph::GRAPH_TYPE_BASIC_LINE;
} else {
if ($constantRowsCount) {
- $graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_VERTICAL_BAR;
+ $graphType = StaticGraph::GRAPH_TYPE_VERTICAL_BAR;
} else {
- $graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR;
+ $graphType = StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR;
}
}
@@ -198,7 +204,7 @@ public function get(
$graphType = self::$DEFAULT_GRAPH_TYPE_OVERRIDE[$reportUniqueId][$isMultiplePeriod];
}
} else {
- $availableGraphTypes = Piwik_ImageGraph_StaticGraph::getAvailableStaticGraphTypes();
+ $availableGraphTypes = StaticGraph::getAvailableStaticGraphTypes();
if (!in_array($graphType, $availableGraphTypes)) {
throw new Exception(
Piwik_TranslateException(
@@ -255,8 +261,8 @@ public function get(
// sort and truncate filters
$defaultFilterTruncate = self::$DEFAULT_PARAMETERS[$graphType][self::TRUNCATE_KEY];
switch ($graphType) {
- case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_3D_PIE:
- case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_PIE:
+ case StaticGraph::GRAPH_TYPE_3D_PIE:
+ case StaticGraph::GRAPH_TYPE_BASIC_PIE:
if (count($ordinateColumns) > 1) {
// pChart doesn't support multiple series on pie charts
@@ -267,8 +273,8 @@ public function get(
$this->setFilterTruncate($defaultFilterTruncate);
break;
- case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_VERTICAL_BAR:
- case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_LINE:
+ case StaticGraph::GRAPH_TYPE_VERTICAL_BAR:
+ case StaticGraph::GRAPH_TYPE_BASIC_LINE:
if (!$isMultiplePeriod && !$constantRowsCount) {
$this->setFilterTruncate($defaultFilterTruncate);
@@ -294,7 +300,7 @@ public function get(
}
}
- $processedReport = Piwik_API_API::getInstance()->getRowEvolution(
+ $processedReport = MetaAPI::getInstance()->getRowEvolution(
$idSite,
$period,
$date,
@@ -351,7 +357,7 @@ public function get(
$ordinateLabels[$plottedMetric] = $processedReport['label'] . ' (' . $metrics[$plottedMetric]['name'] . ')';
}
} else {
- $processedReport = Piwik_API_API::getInstance()->getProcessedReport(
+ $processedReport = MetaAPI::getInstance()->getProcessedReport(
$idSite,
$period,
$date,
@@ -436,7 +442,6 @@ public function get(
$ordinateSeries[$column][] = $parsedOrdinateValue;
}
-
} else {
foreach ($ordinateColumns as $column) {
$ordinateSeries[$column][] = 0;
@@ -453,7 +458,7 @@ public function get(
}
//Setup the graph
- $graph = Piwik_ImageGraph_StaticGraph::factory($graphType);
+ $graph = StaticGraph::factory($graphType);
$graph->setWidth($width);
$graph->setHeight($height);
$graph->setFont($font);
@@ -479,10 +484,9 @@ public function get(
// render graph
$graph->renderGraph();
-
} catch (Exception $e) {
- $graph = new Piwik_ImageGraph_StaticGraph_Exception();
+ $graph = new \Piwik\Plugins\ImageGraph\StaticGraph\Exception();
$graph->setWidth($width);
$graph->setHeight($height);
$graph->setFont($font);
diff --git a/plugins/ImageGraph/Controller.php b/plugins/ImageGraph/Controller.php
index a36d520b8ed..19925fdc41c 100644
--- a/plugins/ImageGraph/Controller.php
+++ b/plugins/ImageGraph/Controller.php
@@ -1,9 +1,4 @@
getReportMetadata($idSite, $period, $date);
+ $reports = API::getInstance()->getReportMetadata($idSite, $period, $date);
$plot = array();
foreach ($reports as $report) {
if (!empty($report['imageGraphUrl'])) {
@@ -53,7 +54,7 @@ public function testAllSizes()
$date = Common::getRequestVar('date', 'today', 'string');
$_GET['token_auth'] = Piwik::getCurrentUserTokenAuth();
- $availableReports = Piwik_API_API::getInstance()->getReportMetadata($this->idSite, $period, $date);
+ $availableReports = API::getInstance()->getReportMetadata($this->idSite, $period, $date);
$view->availableReports = $availableReports;
$view->graphTypes = array(
'', // default graph type
@@ -73,5 +74,4 @@ public function testAllSizes()
);
echo $view->render();
}
-
}
diff --git a/plugins/ImageGraph/ImageGraph.php b/plugins/ImageGraph/ImageGraph.php
index 6181877fb7e..fc992a34251 100644
--- a/plugins/ImageGraph/ImageGraph.php
+++ b/plugins/ImageGraph/ImageGraph.php
@@ -1,12 +1,4 @@
'Piwik_ImageGraph_StaticGraph_Evolution',
- self::GRAPH_TYPE_VERTICAL_BAR => 'Piwik_ImageGraph_StaticGraph_VerticalBar',
- self::GRAPH_TYPE_HORIZONTAL_BAR => 'Piwik_ImageGraph_StaticGraph_HorizontalBar',
- self::GRAPH_TYPE_BASIC_PIE => 'Piwik_ImageGraph_StaticGraph_Pie',
- self::GRAPH_TYPE_3D_PIE => 'Piwik_ImageGraph_StaticGraph_3DPie',
+ self::GRAPH_TYPE_BASIC_LINE => 'Evolution',
+ self::GRAPH_TYPE_VERTICAL_BAR => 'VerticalBar',
+ self::GRAPH_TYPE_HORIZONTAL_BAR => 'HorizontalBar',
+ self::GRAPH_TYPE_BASIC_PIE => 'Pie',
+ self::GRAPH_TYPE_3D_PIE => 'Pie3D',
);
const ABSCISSA_SERIE_NAME = 'ABSCISSA';
@@ -70,9 +76,9 @@ abstract public function renderGraph();
/**
* Return the StaticGraph according to the static graph type $graphType
*
- * @throws exception If the static graph type is unknown
+ * @throws Exception If the static graph type is unknown
* @param string $graphType
- * @return Piwik_ImageGraph_StaticGraph
+ * @return \Piwik\Plugins\ImageGraph\StaticGraph
*/
public static function factory($graphType)
{
@@ -138,7 +144,7 @@ public function setHeight($height)
public function setFontSize($fontSize)
{
if (!is_numeric($fontSize)) {
- $fontSize = Piwik_ImageGraph_API::DEFAULT_FONT_SIZE;
+ $fontSize = API::DEFAULT_FONT_SIZE;
}
$this->fontSize = $fontSize;
}
@@ -263,8 +269,8 @@ protected function initpImage()
$this->pImage->setFontProperties(
array_merge(
array(
- 'FontName' => $this->font,
- 'FontSize' => $this->fontSize,
+ 'FontName' => $this->font,
+ 'FontSize' => $this->fontSize,
),
$this->textColor
)
diff --git a/plugins/ImageGraph/StaticGraph/3DPie.php b/plugins/ImageGraph/StaticGraph/3DPie.php
index 62252c0059e..4a7ab3ef06c 100644
--- a/plugins/ImageGraph/StaticGraph/3DPie.php
+++ b/plugins/ImageGraph/StaticGraph/3DPie.php
@@ -6,14 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_3DPie extends Piwik_ImageGraph_StaticGraph_PieGraph
+class Pie3D extends PieGraph
{
public function renderGraph()
{
diff --git a/plugins/ImageGraph/StaticGraph/Evolution.php b/plugins/ImageGraph/StaticGraph/Evolution.php
index a4851afaa4a..3bc870b9b63 100644
--- a/plugins/ImageGraph/StaticGraph/Evolution.php
+++ b/plugins/ImageGraph/StaticGraph/Evolution.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+use Piwik\Plugins\ImageGraph\StaticGraph\GridGraph;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_Evolution extends Piwik_ImageGraph_StaticGraph_GridGraph
+class Evolution extends GridGraph
{
public function renderGraph()
diff --git a/plugins/ImageGraph/StaticGraph/Exception.php b/plugins/ImageGraph/StaticGraph/Exception.php
index 5140c73eb69..0772e603cf7 100644
--- a/plugins/ImageGraph/StaticGraph/Exception.php
+++ b/plugins/ImageGraph/StaticGraph/Exception.php
@@ -6,15 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+use Piwik\Plugins\ImageGraph\StaticGraph;
+use pData;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_Exception extends Piwik_ImageGraph_StaticGraph
+class Exception extends StaticGraph
{
const MESSAGE_RIGHT_MARGIN = 5;
@@ -30,7 +33,6 @@ protected function getDefaultColors()
return array();
}
-
public function setWidth($width)
{
if (empty($width)) {
diff --git a/plugins/ImageGraph/StaticGraph/GridGraph.php b/plugins/ImageGraph/StaticGraph/GridGraph.php
index 3efd36bc1ac..026c2952bcd 100644
--- a/plugins/ImageGraph/StaticGraph/GridGraph.php
+++ b/plugins/ImageGraph/StaticGraph/GridGraph.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+use Piwik\Plugins\ImageGraph\StaticGraph;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-abstract class Piwik_ImageGraph_StaticGraph_GridGraph extends Piwik_ImageGraph_StaticGraph
+abstract class GridGraph extends StaticGraph
{
const GRAPHIC_COLOR_KEY = 'GRAPHIC_COLOR';
@@ -413,7 +415,6 @@ protected function truncateLabel($label, $labelWidthLimit, $fontSize = false)
}
return $label;
}
-
// display min & max values
// can not currently be used because pChart's label design is not flexible enough
// e.g: it is not possible to remove the box border & the square icon
diff --git a/plugins/ImageGraph/StaticGraph/HorizontalBar.php b/plugins/ImageGraph/StaticGraph/HorizontalBar.php
index fe4cf5b3b48..64ebf2d4e55 100644
--- a/plugins/ImageGraph/StaticGraph/HorizontalBar.php
+++ b/plugins/ImageGraph/StaticGraph/HorizontalBar.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+use Piwik\Plugins\ImageGraph\StaticGraph\GridGraph;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_HorizontalBar extends Piwik_ImageGraph_StaticGraph_GridGraph
+class HorizontalBar extends GridGraph
{
const INTERLEAVE = 0.30;
const PADDING_CHARS = ' ';
@@ -173,7 +175,7 @@ public function renderGraph()
- $logoHeight / 2
+ 1;
- if(method_exists($this->pImage, $drawingFunction)) {
+ if (method_exists($this->pImage, $drawingFunction)) {
$this->pImage->$drawingFunction(
$gridLeftMarginBeforePadding,
$logoYPosition,
diff --git a/plugins/ImageGraph/StaticGraph/Pie.php b/plugins/ImageGraph/StaticGraph/Pie.php
index bdfbdef9ab4..1626ebd3fc7 100644
--- a/plugins/ImageGraph/StaticGraph/Pie.php
+++ b/plugins/ImageGraph/StaticGraph/Pie.php
@@ -6,14 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+
+use Piwik\Plugins\ImageGraph\StaticGraph\PieGraph;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_Pie extends Piwik_ImageGraph_StaticGraph_PieGraph
+class Pie extends PieGraph
{
public function renderGraph()
{
diff --git a/plugins/ImageGraph/StaticGraph/PieGraph.php b/plugins/ImageGraph/StaticGraph/PieGraph.php
index a44bf79418d..02e8d6ccecb 100644
--- a/plugins/ImageGraph/StaticGraph/PieGraph.php
+++ b/plugins/ImageGraph/StaticGraph/PieGraph.php
@@ -6,16 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+
+use Piwik\Plugins\ImageGraph\StaticGraph;
+use pPie;
+
require_once PIWIK_INCLUDE_PATH . "/libs/pChart2.1.3/class/pPie.class.php";
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-abstract class Piwik_ImageGraph_StaticGraph_PieGraph extends Piwik_ImageGraph_StaticGraph
+abstract class PieGraph extends StaticGraph
{
const RADIUS_MARGIN = 40;
const PIE_RIGHT_MARGIN = 20;
diff --git a/plugins/ImageGraph/StaticGraph/VerticalBar.php b/plugins/ImageGraph/StaticGraph/VerticalBar.php
index 5bf40df7f81..add00e64234 100644
--- a/plugins/ImageGraph/StaticGraph/VerticalBar.php
+++ b/plugins/ImageGraph/StaticGraph/VerticalBar.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+use Piwik\Plugins\ImageGraph\StaticGraph\GridGraph;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_VerticalBar extends Piwik_ImageGraph_StaticGraph_GridGraph
+class VerticalBar extends GridGraph
{
const INTERLEAVE = 0.10;
diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php
index d0207e1ffa5..9160ca4c632 100644
--- a/plugins/Installation/Controller.php
+++ b/plugins/Installation/Controller.php
@@ -6,10 +6,12 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
+namespace Piwik\Plugins\Installation;
+
+use Exception;
use Piwik\API\Request;
-use Piwik\Controller\Admin;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Db\Adapter;
use Piwik\Piwik;
@@ -24,32 +26,39 @@
use Piwik\Url;
use Piwik\ProxyHeaders;
use Piwik\Db;
+use Piwik\Plugins\Installation\FormDatabaseSetup;
+use Piwik\Plugins\Installation\FormFirstWebsiteSetup;
+use Piwik\Plugins\Installation\FormGeneralSetup;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
+use Zend_Db_Adapter_Exception;
/**
* Installation controller
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
// public so plugins can add/delete installation steps
public $steps = array(
- 'welcome' => 'Installation_Welcome',
- 'systemCheck' => 'Installation_SystemCheck',
- 'databaseSetup' => 'Installation_DatabaseSetup',
- 'databaseCheck' => 'Installation_DatabaseCheck',
- 'tablesCreation' => 'Installation_Tables',
- 'generalSetup' => 'Installation_SuperUser',
- 'firstWebsiteSetup' => 'Installation_SetupWebsite',
- 'trackingCode' => 'Installation_JsTag',
- 'finished' => 'Installation_Congratulations',
+ 'welcome' => 'Installation_Welcome',
+ 'systemCheck' => 'Installation_SystemCheck',
+ 'databaseSetup' => 'Installation_DatabaseSetup',
+ 'databaseCheck' => 'Installation_DatabaseCheck',
+ 'tablesCreation' => 'Installation_Tables',
+ 'generalSetup' => 'Installation_SuperUser',
+ 'firstWebsiteSetup' => 'Installation_SetupWebsite',
+ 'trackingCode' => 'Installation_JsTag',
+ 'finished' => 'Installation_Congratulations',
);
protected $session;
public function __construct()
{
- $this->session = new SessionNamespace('Piwik_Installation');
+ $this->session = new SessionNamespace('Installation');
if (!isset($this->session->currentStepDone)) {
$this->session->currentStepDone = '';
$this->session->skipThisStep = array();
@@ -87,7 +96,7 @@ function welcome($message = false)
// Delete merged js/css files to force regenerations based on updated activated plugin list
Piwik::deleteAllCacheOnUpdate();
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/welcome',
$this->getInstallationSteps(),
__FUNCTION__
@@ -107,7 +116,7 @@ function systemCheck()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/systemCheck',
$this->getInstallationSteps(),
__FUNCTION__
@@ -147,11 +156,11 @@ function databaseSetup()
// case the user hits the back button
$this->session->skipThisStep = array(
- 'firstWebsiteSetup' => false,
- 'trackingCode' => false,
+ 'firstWebsiteSetup' => false,
+ 'trackingCode' => false,
);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/databaseSetup',
$this->getInstallationSteps(),
__FUNCTION__
@@ -160,7 +169,7 @@ function databaseSetup()
$view->showNextStep = false;
- $form = new Piwik_Installation_FormDatabaseSetup();
+ $form = new FormDatabaseSetup();
if ($form->validate()) {
try {
@@ -187,7 +196,7 @@ function databaseSetup()
function databaseCheck()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/databaseCheck',
$this->getInstallationSteps(),
__FUNCTION__
@@ -246,7 +255,7 @@ function tablesCreation()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/tablesCreation',
$this->getInstallationSteps(),
__FUNCTION__
@@ -281,8 +290,8 @@ function tablesCreation()
Access::getInstance();
Piwik::setUserIsSuperUser();
if ($baseTablesInstalled >= $minimumCountPiwikTables &&
- count(Piwik_SitesManager_API::getInstance()->getAllSitesId()) > 0 &&
- count(Piwik_UsersManager_API::getInstance()->getUsers()) > 0
+ count(SitesManagerAPI::getInstance()->getAllSitesId()) > 0 &&
+ count(SitesManagerAPI::getInstance()->getUsers()) > 0
) {
$view->showReuseExistingTables = true;
// when the user reuses the same tables we skip the website creation step
@@ -313,14 +322,14 @@ function generalSetup()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/generalSetup',
$this->getInstallationSteps(),
__FUNCTION__
);
$this->skipThisStep(__FUNCTION__);
- $form = new Piwik_Installation_FormGeneralSetup();
+ $form = new FormGeneralSetup();
if ($form->validate()) {
$superUserInfos = array(
@@ -370,14 +379,14 @@ public function firstWebsiteSetup()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/firstWebsiteSetup',
$this->getInstallationSteps(),
__FUNCTION__
);
$this->skipThisStep(__FUNCTION__);
- $form = new Piwik_Installation_FormFirstWebsiteSetup();
+ $form = new FormFirstWebsiteSetup();
if (!isset($this->session->generalSetupSuccessMessage)) {
$view->displayGeneralSetupSuccess = true;
$this->session->generalSetupSuccessMessage = true;
@@ -407,7 +416,6 @@ public function firstWebsiteSetup()
} catch (Exception $e) {
$view->errorMessage = $e->getMessage();
}
-
}
$view->addForm($form);
echo $view->render();
@@ -420,7 +428,7 @@ public function trackingCode()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/trackingCode',
$this->getInstallationSteps(),
__FUNCTION__
@@ -458,7 +466,7 @@ public function finished()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/finished',
$this->getInstallationSteps(),
__FUNCTION__
@@ -562,7 +570,7 @@ protected function writeConfigFileFromSession()
public function saveLanguage()
{
$language = Common::getRequestVar('language');
- Piwik_LanguagesManager::setLanguageForSession($language);
+ LanguagesManager::setLanguageForSession($language);
Url::redirectToReferer();
}
@@ -601,7 +609,7 @@ protected function checkPreviousStepIsValid($currentStep)
}
}
if ($error) {
- Piwik_Login_Controller::clearSession();
+ \Piwik\Plugins\Login\Controller::clearSession();
$message = Piwik_Translate('Installation_ErrorInvalidState',
array('
',
'',
@@ -693,20 +701,20 @@ public static function getSystemInformation()
$directoriesToCheck = array();
- if(!Piwik::isInstalled()) {
+ if (!Piwik::isInstalled()) {
// at install, need /config to be writable (so we can create config.ini.php)
$directoriesToCheck[] = '/config/';
}
$directoriesToCheck = array_merge($directoriesToCheck, array(
- '/tmp/',
- '/tmp/templates_c/',
- '/tmp/cache/',
- '/tmp/assets/',
- '/tmp/latest/',
- '/tmp/tcpdf/',
- '/tmp/sessions/',
- ));
+ '/tmp/',
+ '/tmp/templates_c/',
+ '/tmp/cache/',
+ '/tmp/assets/',
+ '/tmp/latest/',
+ '/tmp/tcpdf/',
+ '/tmp/sessions/',
+ ));
$infos['directories'] = Piwik::checkDirectoriesWritable($directoriesToCheck);
@@ -905,7 +913,6 @@ public static function functionExists($functionName)
$blacklistFunctions = array_map('strtolower', array_map('trim', explode(',', $blacklist)));
return $exists && !in_array($functionName, $blacklistFunctions);
}
-
}
return $exists;
}
diff --git a/plugins/Installation/FormDatabaseSetup.php b/plugins/Installation/FormDatabaseSetup.php
index f4d1f992478..a1f58c6c78b 100644
--- a/plugins/Installation/FormDatabaseSetup.php
+++ b/plugins/Installation/FormDatabaseSetup.php
@@ -6,18 +6,24 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
+namespace Piwik\Plugins\Installation;
+
use Piwik\Db\Adapter;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\QuickForm2;
+use Exception;
+use HTML_QuickForm2_DataSource_Array;
+use HTML_QuickForm2_Factory;
+use Zend_Db_Adapter_Exception;
/**
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormDatabaseSetup extends QuickForm2
+class FormDatabaseSetup extends QuickForm2
{
function __construct($id = 'databasesetupform', $method = 'post', $attributes = null, $trackSubmit = false)
{
@@ -26,9 +32,9 @@ function __construct($id = 'databasesetupform', $method = 'post', $attributes =
function init()
{
- HTML_QuickForm2_Factory::registerRule('checkValidFilename', 'Piwik_Installation_FormDatabaseSetup_Rule_checkValidFilename');
+ HTML_QuickForm2_Factory::registerRule('checkValidFilename', 'FormDatabaseSetup_Rule_checkValidFilename');
- $checkUserPrivilegesClass = 'Piwik_Installation_FormDatabaseSetup_Rule_checkUserPrivileges';
+ $checkUserPrivilegesClass = 'Rule_checkUserPrivileges';
HTML_QuickForm2_Factory::registerRule('checkUserPrivileges', $checkUserPrivilegesClass);
$availableAdapters = Adapter::getAdapters();
@@ -44,7 +50,7 @@ function init()
$user = $this->addElement('text', 'username')
->setLabel(Piwik_Translate('Installation_DatabaseSetupLogin'));
$user->addRule('required', Piwik_Translate('General_Required', Piwik_Translate('Installation_DatabaseSetupLogin')));
- $requiredPrivileges = Piwik_Installation_FormDatabaseSetup_Rule_checkUserPrivileges::getRequiredPrivilegesPretty();
+ $requiredPrivileges = Rule_checkUserPrivileges::getRequiredPrivilegesPretty();
$user->addRule('checkUserPrivileges',
Piwik_Translate('Installation_InsufficientPrivileges', $requiredPrivileges . '
') .
Piwik_Translate('Installation_InsufficientPrivilegesHelp'));
@@ -148,9 +154,9 @@ public function createDatabaseObject()
* - DROP
* - CREATE TEMPORARY TABLES
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormDatabaseSetup_Rule_checkUserPrivileges extends HTML_QuickForm2_Rule
+class Rule_checkUserPrivileges extends HTML_QuickForm2_Rule
{
const TEST_TABLE_NAME = 'piwik_test_table';
const TEST_TEMP_TABLE_NAME = 'piwik_test_table_temp';
@@ -228,22 +234,22 @@ public static function getRequiredPrivileges()
{
return array(
'CREATE' => 'CREATE TABLE ' . self::TEST_TABLE_NAME . ' (
- id INT AUTO_INCREMENT,
- value INT,
- PRIMARY KEY (id),
- KEY index_value (value)
- )',
+ id INT AUTO_INCREMENT,
+ value INT,
+ PRIMARY KEY (id),
+ KEY index_value (value)
+ )',
'ALTER' => 'ALTER TABLE ' . self::TEST_TABLE_NAME . '
- ADD COLUMN other_value INT DEFAULT 0',
+ ADD COLUMN other_value INT DEFAULT 0',
'SELECT' => 'SELECT * FROM ' . self::TEST_TABLE_NAME,
'INSERT' => 'INSERT INTO ' . self::TEST_TABLE_NAME . ' (value) VALUES (123)',
'UPDATE' => 'UPDATE ' . self::TEST_TABLE_NAME . ' SET value = 456 WHERE id = 1',
'DELETE' => 'DELETE FROM ' . self::TEST_TABLE_NAME . ' WHERE id = 1',
'DROP' => 'DROP TABLE ' . self::TEST_TABLE_NAME,
'CREATE TEMPORARY TABLES' => 'CREATE TEMPORARY TABLE ' . self::TEST_TEMP_TABLE_NAME . ' (
- id INT AUTO_INCREMENT,
- PRIMARY KEY (id)
- )',
+ id INT AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ )',
);
}
@@ -294,9 +300,9 @@ private function dropExtraTables($db)
/**
* Filename check for prefix/DB name
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormDatabaseSetup_Rule_checkValidFilename extends HTML_QuickForm2_Rule
+class FormDatabaseSetup_Rule_checkValidFilename extends HTML_QuickForm2_Rule
{
function validateOwner()
{
diff --git a/plugins/Installation/FormFirstWebsiteSetup.php b/plugins/Installation/FormFirstWebsiteSetup.php
index 31c3e4cf4a1..2f8a810b1fa 100644
--- a/plugins/Installation/FormFirstWebsiteSetup.php
+++ b/plugins/Installation/FormFirstWebsiteSetup.php
@@ -6,15 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
+
+namespace Piwik\Plugins\Installation;
+use HTML_QuickForm2_DataSource_Array;
+use HTML_QuickForm2_Factory;
use Piwik\QuickForm2;
+use Piwik\Plugins\SitesManager\API;
/**
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormFirstWebsiteSetup extends QuickForm2
+class FormFirstWebsiteSetup extends QuickForm2
{
function __construct($id = 'websitesetupform', $method = 'post', $attributes = null, $trackSubmit = false)
{
@@ -23,12 +28,12 @@ function __construct($id = 'websitesetupform', $method = 'post', $attributes = n
function init()
{
- HTML_QuickForm2_Factory::registerRule('checkTimezone', 'Piwik_Installation_FormFirstWebsiteSetup_Rule_isValidTimezone');
+ HTML_QuickForm2_Factory::registerRule('checkTimezone', 'Rule_isValidTimezone');
$urlExample = 'http://example.org';
$javascriptOnClickUrlExample = "javascript:if(this.value=='$urlExample'){this.value='http://';} this.style.color='black';";
- $timezones = Piwik_SitesManager_API::getInstance()->getTimezonesList();
+ $timezones = API::getInstance()->getTimezonesList();
$timezones = array_merge(array('No timezone' => Piwik_Translate('SitesManager_SelectACity')), $timezones);
$this->addElement('text', 'siteName')
@@ -66,20 +71,20 @@ function init()
/**
* Timezone validation rule
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormFirstWebsiteSetup_Rule_isValidTimezone extends HTML_QuickForm2_Rule
+class Rule_isValidTimezone extends HTML_QuickForm2_Rule
{
function validateOwner()
{
try {
$timezone = $this->owner->getValue();
if (!empty($timezone)) {
- Piwik_SitesManager_API::getInstance()->setDefaultTimezone($timezone);
+ API::getInstance()->setDefaultTimezone($timezone);
}
} catch (Exception $e) {
return false;
}
return true;
}
-}
+}
\ No newline at end of file
diff --git a/plugins/Installation/FormGeneralSetup.php b/plugins/Installation/FormGeneralSetup.php
index bd2504588a6..cfa4ce3c8b0 100644
--- a/plugins/Installation/FormGeneralSetup.php
+++ b/plugins/Installation/FormGeneralSetup.php
@@ -6,16 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
-use Piwik\Piwik;
+namespace Piwik\Plugins\Installation;
+
+use HTML_QuickForm2_DataSource_Array;
+use HTML_QuickForm2_Factory;
use Piwik\QuickForm2;
+use Piwik\Piwik;
/**
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormGeneralSetup extends QuickForm2
+class FormGeneralSetup extends QuickForm2
{
function __construct($id = 'generalsetupform', $method = 'post', $attributes = null, $trackSubmit = false)
{
@@ -24,8 +28,8 @@ function __construct($id = 'generalsetupform', $method = 'post', $attributes = n
function init()
{
- HTML_QuickForm2_Factory::registerRule('checkLogin', 'Piwik_Installation_FormGeneralSetup_Rule_isValidLoginString');
- HTML_QuickForm2_Factory::registerRule('checkEmail', 'Piwik_Installation_FormGeneralSetup_Rule_isValidEmailString');
+ HTML_QuickForm2_Factory::registerRule('checkLogin', 'Rule_isValidLoginString');
+ HTML_QuickForm2_Factory::registerRule('checkEmail', 'Rule_isValidEmailString');
$login = $this->addElement('text', 'login')
->setLabel(Piwik_Translate('Installation_SuperUserLogin'));
@@ -67,9 +71,9 @@ function init()
/**
* Login id validation rule
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormGeneralSetup_Rule_isValidLoginString extends HTML_QuickForm2_Rule
+class Rule_isValidLoginString extends HTML_QuickForm2_Rule
{
function validateOwner()
{
@@ -89,12 +93,12 @@ function validateOwner()
/**
* Email address validation rule
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormGeneralSetup_Rule_isValidEmailString extends HTML_QuickForm2_Rule
+class Rule_isValidEmailString extends HTML_QuickForm2_Rule
{
function validateOwner()
{
return Piwik::isValidEmailString($this->owner->getValue());
}
-}
+}
\ No newline at end of file
diff --git a/plugins/Installation/Installation.php b/plugins/Installation/Installation.php
index 8017e4e5352..1fb9a565f99 100644
--- a/plugins/Installation/Installation.php
+++ b/plugins/Installation/Installation.php
@@ -6,20 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
+namespace Piwik\Plugins\Installation;
+
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Plugin;
-use Piwik\Translate;
/**
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation extends Plugin
+class Installation extends \Piwik\Plugin
{
- protected $installationControllerName = 'Piwik_Installation_Controller';
+ protected $installationControllerName = 'Controller';
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/Installation/View.php b/plugins/Installation/View.php
index 84a8d631cf4..d5599bed53b 100644
--- a/plugins/Installation/View.php
+++ b/plugins/Installation/View.php
@@ -6,15 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
-use Piwik\View;
+namespace Piwik\Plugins\Installation;
+
/**
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_View extends View
+class View extends \Piwik\View
{
public function __construct($subtemplatePath, $installationSteps, $currentStepName)
{
diff --git a/plugins/LanguagesManager/API.php b/plugins/LanguagesManager/API.php
index ee6dd2aaa93..332b68cc9cc 100644
--- a/plugins/LanguagesManager/API.php
+++ b/plugins/LanguagesManager/API.php
@@ -6,9 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*
*/
+namespace Piwik\Plugins\LanguagesManager;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Db;
@@ -23,14 +25,14 @@
* You can also request the default language to load for a user via "getLanguageForUser",
* or update it via "setLanguageForUser".
*
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*/
-class Piwik_LanguagesManager_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_LanguagesManager_API
+ * @return \Piwik\Plugins\LanguagesManager\API
*/
static public function getInstance()
{
diff --git a/plugins/LanguagesManager/Controller.php b/plugins/LanguagesManager/Controller.php
index 212293ce790..3eba8c5097d 100644
--- a/plugins/LanguagesManager/Controller.php
+++ b/plugins/LanguagesManager/Controller.php
@@ -6,18 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*
*/
+namespace Piwik\Plugins\LanguagesManager;
+
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\LanguagesManager\API;
use Piwik\Url;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Zend_Registry;
/**
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*/
-class Piwik_LanguagesManager_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
* anonymous = in the session
@@ -31,11 +35,11 @@ public function saveLanguage()
if (Piwik::isInstalled()) {
$this->checkTokenInUrl();
}
- Piwik_LanguagesManager::setLanguageForSession($language);
+ LanguagesManager::setLanguageForSession($language);
if (Zend_Registry::isRegistered('access')) {
$currentUser = Piwik::getCurrentUserLogin();
if ($currentUser && $currentUser !== 'anonymous') {
- Piwik_LanguagesManager_API::getInstance()->setLanguageForUser($currentUser, $language);
+ API::getInstance()->setLanguageForUser($currentUser, $language);
}
}
Url::redirectToReferer();
diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php
index 6bd1bf553c1..004d82ade6b 100644
--- a/plugins/LanguagesManager/LanguagesManager.php
+++ b/plugins/LanguagesManager/LanguagesManager.php
@@ -6,23 +6,27 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*
*/
+namespace Piwik\Plugins\LanguagesManager;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Cookie;
+use Piwik\Plugins\LanguagesManager\API;
use Piwik\View;
-use Piwik\Plugin;
use Piwik\Db;
use Piwik\Translate;
+use Zend_Registry;
/**
*
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*/
-class Piwik_LanguagesManager extends Plugin
+class LanguagesManager extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -75,7 +79,7 @@ public function addLanguagesManagerToOtherTopBar(&$str)
private function getLanguagesSelector()
{
$view = new View("@LanguagesManager/getLanguagesSelector");
- $view->languages = Piwik_LanguagesManager_API::getInstance()->getAvailableLanguageNames();
+ $view->languages = API::getInstance()->getAvailableLanguageNames();
$view->currentLanguageCode = self::getLanguageCodeForCurrentUser();
$view->currentLanguageName = self::getLanguageNameForCurrentUser();
return $view->render();
@@ -86,7 +90,7 @@ function getLanguageToLoad(&$language)
if (empty($language)) {
$language = self::getLanguageCodeForCurrentUser();
}
- if (!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($language)) {
+ if (!API::getInstance()->isLanguageAvailable($language)) {
$language = Translate::getInstance()->getLanguageDefault();
}
}
@@ -132,10 +136,10 @@ public function uninstall()
static public function getLanguageCodeForCurrentUser()
{
$languageCode = self::getLanguageFromPreferences();
- if (!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($languageCode)) {
- $languageCode = Common::extractLanguageCodeFromBrowserLanguage(Common::getBrowserLanguage(), Piwik_LanguagesManager_API::getInstance()->getAvailableLanguages());
+ if (!API::getInstance()->isLanguageAvailable($languageCode)) {
+ $languageCode = Common::extractLanguageCodeFromBrowserLanguage(Common::getBrowserLanguage(), API::getInstance()->getAvailableLanguages());
}
- if (!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($languageCode)) {
+ if (!API::getInstance()->isLanguageAvailable($languageCode)) {
$languageCode = Translate::getInstance()->getLanguageDefault();
}
return $languageCode;
@@ -147,7 +151,7 @@ static public function getLanguageCodeForCurrentUser()
static public function getLanguageNameForCurrentUser()
{
$languageCode = self::getLanguageCodeForCurrentUser();
- $languages = Piwik_LanguagesManager_API::getInstance()->getAvailableLanguageNames();
+ $languages = API::getInstance()->getAvailableLanguageNames();
foreach ($languages as $language) {
if ($language['code'] === $languageCode) {
return $language['name'];
@@ -166,13 +170,12 @@ static protected function getLanguageFromPreferences()
try {
$currentUser = Piwik::getCurrentUserLogin();
- return Piwik_LanguagesManager_API::getInstance()->getLanguageForUser($currentUser);
+ return API::getInstance()->getLanguageForUser($currentUser);
} catch (Exception $e) {
return false;
}
}
-
/**
* Returns the language for the session
*
@@ -196,7 +199,7 @@ static public function getLanguageForSession()
*/
static public function setLanguageForSession($languageCode)
{
- if (!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($languageCode)) {
+ if (!API::getInstance()->isLanguageAvailable($languageCode)) {
return false;
}
diff --git a/plugins/Live/API.php b/plugins/Live/API.php
index 3354c67335d..a1d2b9248f6 100644
--- a/plugins/Live/API.php
+++ b/plugins/Live/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Live
+ * @package Live
*/
+namespace Piwik\Plugins\Live;
+
+use Exception;
use Piwik\Config;
use Piwik\DataAccess\LogAggregator;
use Piwik\DataTable\Filter\ColumnDelete;
@@ -24,6 +27,8 @@
use Piwik\Db;
use Piwik\Tracker\Action;
use Piwik\Tracker\GoalManager;
+use Piwik\Plugins\Live\Visitor;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
* @see plugins/Referers/functions.php
@@ -49,14 +54,14 @@
* The method "getCounters" is used to return a simple counter: visits, number of actions, number of converted visits, in the last N minutes.
*
* See also the documentation about Real time widget and visitor level reports in Piwik.
- * @package Piwik_Live
+ * @package Live
*/
-class Piwik_Live_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_Live_API
+ * @return \Piwik\Plugins\Live\API
*/
static public function getInstance()
{
@@ -181,10 +186,10 @@ private function getCleanedVisitorsFromDetails($visitorDetails, $idSite, $flat =
$site = new Site($idSite);
$timezone = $site->getTimezone();
- $currencies = Piwik_SitesManager_API::getInstance()->getCurrencySymbols();
+ $currencies = SitesManagerAPI::getInstance()->getCurrencySymbols();
foreach ($visitorDetails as $visitorDetail) {
$this->cleanVisitorDetails($visitorDetail, $idSite);
- $visitor = new Piwik_Live_Visitor($visitorDetail);
+ $visitor = new Visitor($visitorDetail);
$visitorDetailsArray = $visitor->getAllVisitorDetails();
$visitorDetailsArray['siteCurrency'] = $site->getCurrency();
@@ -199,11 +204,11 @@ private function getCleanedVisitorsFromDetails($visitorDetails, $idSite, $flat =
$visitorDetailsArray['serverTimePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized('%time%');
$visitorDetailsArray['actionDetails'] = array();
- if(!$doNotFetchActions) {
+ if (!$doNotFetchActions) {
$visitorDetailsArray = $this->enrichVisitorArrayWithActions($visitorDetailsArray, $actionsLimit, $timezone);
}
- if($flat) {
+ if ($flat) {
$visitorDetailsArray = $this->flattenVisitorDetailsArray($visitorDetailsArray);
}
$table->addRowFromArray(array(Row::COLUMNS => $visitorDetailsArray));
@@ -223,7 +228,6 @@ private function getCustomVariablePrettyKey($key)
return $key;
}
-
/**
* The &flat=1 feature is used by API.getSuggestedValuesForSegment
*
@@ -259,8 +263,8 @@ private function flattenVisitorDetailsArray($visitorDetailsArray)
// Flatten Goals
$count = 1;
- foreach($visitorDetailsArray['actionDetails'] as $action) {
- if(!empty($action['goalId'])) {
+ foreach ($visitorDetailsArray['actionDetails'] as $action) {
+ if (!empty($action['goalId'])) {
$flattenedKeyName = 'visitConvertedGoalId' . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['goalId'];
$count++;
@@ -269,18 +273,18 @@ private function flattenVisitorDetailsArray($visitorDetailsArray)
// Flatten Page Titles/URLs
$count = 1;
- foreach($visitorDetailsArray['actionDetails'] as $action) {
- if(!empty($action['url'])) {
+ foreach ($visitorDetailsArray['actionDetails'] as $action) {
+ if (!empty($action['url'])) {
$flattenedKeyName = 'pageUrl' . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['url'];
}
- if(!empty($action['pageTitle'])) {
+ if (!empty($action['pageTitle'])) {
$flattenedKeyName = 'pageTitle' . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['pageTitle'];
}
- if(!empty($action['siteSearchKeyword'])) {
+ if (!empty($action['siteSearchKeyword'])) {
$flattenedKeyName = 'siteSearchKeyword' . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['siteSearchKeyword'];
}
@@ -289,25 +293,25 @@ private function flattenVisitorDetailsArray($visitorDetailsArray)
// Entry/exit pages
$firstAction = $lastAction = false;
- foreach($visitorDetailsArray['actionDetails'] as $action) {
- if($action['type'] == 'action') {
- if(empty($firstAction)) {
+ foreach ($visitorDetailsArray['actionDetails'] as $action) {
+ if ($action['type'] == 'action') {
+ if (empty($firstAction)) {
$firstAction = $action;
}
$lastAction = $action;
}
}
- if(!empty($firstAction['pageTitle'])) {
+ if (!empty($firstAction['pageTitle'])) {
$visitorDetailsArray['entryPageTitle'] = $firstAction['pageTitle'];
}
- if(!empty($firstAction['url'])) {
+ if (!empty($firstAction['url'])) {
$visitorDetailsArray['entryPageUrl'] = $firstAction['url'];
}
- if(!empty($lastAction['pageTitle'])) {
+ if (!empty($lastAction['pageTitle'])) {
$visitorDetailsArray['exitPageTitle'] = $lastAction['pageTitle'];
}
- if(!empty($lastAction['url'])) {
+ if (!empty($lastAction['url'])) {
$visitorDetailsArray['exitPageUrl'] = $lastAction['url'];
}
@@ -411,8 +415,8 @@ private function loadLastVisitorDetailsFromDatabase($idSite, $period = false, $d
// Group by idvisit so that a visitor converting 2 goals only appears once
$sql = "
- SELECT sub.*
- FROM (
+ SELECT sub.*
+ FROM (
" . $subQuery['sql'] . "
$sqlLimit
) AS sub
@@ -517,7 +521,6 @@ private function enrichVisitorArrayWithActions($visitorDetailsArray, $actionsLim
if (isset($actionDetails[$actionIdx + 1])) {
$actionDetail['timeSpent'] = $actionDetails[$actionIdx + 1]['timeSpentRef'];
$actionDetail['timeSpentPretty'] = Piwik::getPrettyTimeFromSeconds($actionDetail['timeSpent']);
-
}
unset($actionDetails[$actionIdx]['timeSpentRef']); // not needed after timeSpent is added
@@ -663,7 +666,6 @@ private function enrichVisitorArrayWithActions($visitorDetailsArray, $actionsLim
// Convert datetimes to the site timezone
$dateTimeVisit = Date::factory($details['serverTimePretty'], $timezone);
$details['serverTimePretty'] = $dateTimeVisit->getLocalized(Piwik_Translate('CoreHome_ShortDateFormat') . ' %time%');
-
}
$visitorDetailsArray['goalConversions'] = count($goalDetails);
return $visitorDetailsArray;
diff --git a/plugins/Live/Controller.php b/plugins/Live/Controller.php
index 3e708d4d798..fd961c923ff 100644
--- a/plugins/Live/Controller.php
+++ b/plugins/Live/Controller.php
@@ -6,20 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Live
+ * @package Live
*/
+namespace Piwik\Plugins\Live;
+
use Piwik\API\Request;
use Piwik\Common;
use Piwik\Piwik;
use Piwik\Config;
-use Piwik\Controller;
+use Piwik\Plugins\Live\API;
use Piwik\ViewDataTable;
use Piwik\View;
/**
- * @package Piwik_Live
+ * @package Live
*/
-class Piwik_Live_Controller extends Controller
+class Controller extends \Piwik\Controller
{
const SIMPLE_VISIT_COUNT_WIDGET_LAST_MINUTES_CONFIG_KEY = 'live_widget_visitor_count_last_minutes';
@@ -80,7 +82,7 @@ private function render(View $view, $fetch)
}
echo $rendered;
}
-
+
public function indexVisitorLog()
{
$view = new View('@Live/indexVisitorLog.twig');
@@ -120,9 +122,9 @@ public function getLastVisitsStart($fetch = false)
private function setCounters($view)
{
$segment = Request::getRawSegmentFromRequest();
- $last30min = Piwik_Live_API::getInstance()->getCounters($this->idSite, $lastMinutes = 30, $segment);
+ $last30min = API::getInstance()->getCounters($this->idSite, $lastMinutes = 30, $segment);
$last30min = $last30min[0];
- $today = Piwik_Live_API::getInstance()->getCounters($this->idSite, $lastMinutes = 24 * 60, $segment);
+ $today = API::getInstance()->getCounters($this->idSite, $lastMinutes = 24 * 60, $segment);
$today = $today[0];
$view->visitorsCountHalfHour = $last30min['visits'];
$view->visitorsCountToday = $today['visits'];
diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php
index dfa08ce8c58..7ef67b56b56 100644
--- a/plugins/Live/Live.php
+++ b/plugins/Live/Live.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Live
+ * @package Live
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\Live;
+
use Piwik\Common;
use Piwik\WidgetsList;
/**
*
- * @package Piwik_Live
+ * @package Live
*/
-class Piwik_Live extends Plugin
+class Live extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -24,10 +25,10 @@ class Piwik_Live extends Plugin
public function getListHooksRegistered()
{
return array(
- 'AssetManager.getJsFiles' => 'getJsFiles',
- 'AssetManager.getCssFiles' => 'getCssFiles',
- 'WidgetsList.add' => 'addWidget',
- 'Menu.add' => 'addMenu',
+ 'AssetManager.getJsFiles' => 'getJsFiles',
+ 'AssetManager.getCssFiles' => 'getCssFiles',
+ 'WidgetsList.add' => 'addWidget',
+ 'Menu.add' => 'addMenu',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
}
@@ -62,25 +63,25 @@ public function getReportDisplayProperties(&$properties)
private function getDisplayPropertiesForGetLastVisitsDetails()
{
return array(
- 'datatable_template' => "@Live/getVisitorLog.twig",
- 'disable_generic_filters' => true,
- 'enable_sort' => false,
- 'filter_sort_column' => 'idVisit',
- 'filter_sort_order' => 'asc',
- 'show_search' => false,
- 'filter_limit' => 20,
- 'show_offset_information' => false,
+ 'datatable_template' => "@Live/getVisitorLog.twig",
+ 'disable_generic_filters' => true,
+ 'enable_sort' => false,
+ 'filter_sort_column' => 'idVisit',
+ 'filter_sort_order' => 'asc',
+ 'show_search' => false,
+ 'filter_limit' => 20,
+ 'show_offset_information' => false,
'show_exclude_low_population' => false,
- 'show_all_views_icons' => false,
- 'show_table_all_columns' => false,
- 'show_export_as_rss_feed' => false,
- 'disable_row_actions' => true,
- 'documentation' => Piwik_Translate('Live_VisitorLogDocumentation', array('
', '
')),
- 'custom_parameters' => array(
+ 'show_all_views_icons' => false,
+ 'show_table_all_columns' => false,
+ 'show_export_as_rss_feed' => false,
+ 'disable_row_actions' => true,
+ 'documentation' => Piwik_Translate('Live_VisitorLogDocumentation', array('
', '
')),
+ 'custom_parameters' => array(
// set a very high row count so that the next link in the footer of the data table is always shown
- 'totalRows' => 10000000,
+ 'totalRows' => 10000000,
- 'filterEcommerce' => Common::getRequestVar('filterEcommerce', 0, 'int'),
+ 'filterEcommerce' => Common::getRequestVar('filterEcommerce', 0, 'int'),
'pageUrlNotDefined' => Piwik_Translate('General_NotDefined', Piwik_Translate('Actions_ColumnPageURL'))
),
);
diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php
index 5d7441fc38e..849521ba3d0 100644
--- a/plugins/Live/Visitor.php
+++ b/plugins/Live/Visitor.php
@@ -6,13 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Live
+ * @package Live
*/
+namespace Piwik\Plugins\Live;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\IP;
use Piwik\Tracker;
use Piwik\Tracker\Visit;
+use Piwik\Plugins\API\API as MetaAPI;
+use Piwik\Plugins\Referers\API as ReferersAPI;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
/**
* @see plugins/Referers/functions.php
@@ -27,10 +32,9 @@
require_once PIWIK_INCLUDE_PATH . '/plugins/Provider/functions.php';
/**
- *
- * @package Piwik_Live
+ * @package Live
*/
-class Piwik_Live_Visitor
+class Visitor
{
const DELIMITER_PLUGIN_NAME = ", ";
@@ -102,7 +106,7 @@ function getAllVisitorDetails()
'referrerSearchEngineUrl' => $this->getSearchEngineUrl(),
'referrerSearchEngineIcon' => $this->getSearchEngineIcon(),
'operatingSystem' => $this->getOperatingSystem(),
- 'operatingSystemCode' => $this->getOperatingSystemCode(),
+ 'operatingSystemCode' => $this->getOperatingSystemCode(),
'operatingSystemShortName' => $this->getOperatingSystemShortName(),
'operatingSystemIcon' => $this->getOperatingSystemIcon(),
'browserFamily' => $this->getBrowserFamily(),
@@ -244,17 +248,17 @@ function getCountryCode()
function getCountryName()
{
- return Piwik_CountryTranslate($this->getCountryCode());
+ return \Piwik\Plugins\UserCountry\countryTranslate($this->getCountryCode());
}
function getCountryFlag()
{
- return Piwik_getFlagFromCode($this->getCountryCode());
+ return \Piwik\Plugins\UserCountry\getFlagFromCode($this->getCountryCode());
}
function getContinent()
{
- return Piwik_ContinentTranslate($this->getContinentCode());
+ return \Piwik\Plugins\UserCountry\continentTranslate($this->getContinentCode());
}
function getContinentCode()
@@ -274,7 +278,7 @@ public function getRegionName()
{
$region = $this->getRegionCode();
if ($region != '' && $region != Visit::UNKNOWN_CODE) {
- return Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes(
+ return GeoIp::getRegionNameFromCodes(
$this->details['location_country'], $region);
}
return null;
@@ -335,12 +339,12 @@ function getCustomVariables()
function getRefererType()
{
- return Piwik_getRefererTypeFromShortName($this->details['referer_type']);
+ return \Piwik\Plugins\Referers\getRefererTypeFromShortName($this->details['referer_type']);
}
function getRefererTypeName()
{
- return Piwik_getRefererTypeLabel($this->details['referer_type']);
+ return \Piwik\Plugins\Referers\getRefererTypeLabel($this->details['referer_type']);
}
function getKeyword()
@@ -349,7 +353,7 @@ function getKeyword()
if (\Piwik\PluginsManager::getInstance()->isPluginActivated('Referers')
&& $this->getRefererType() == 'search'
) {
- $keyword = Piwik_Referers_API::getCleanKeyword($keyword);
+ $keyword = \Piwik\Plugins\Referers\API::getCleanKeyword($keyword);
}
return urldecode($keyword);
}
@@ -358,7 +362,7 @@ function getRefererUrl()
{
if ($this->getRefererType() == 'search') {
if (\Piwik\PluginsManager::getInstance()->isPluginActivated('Referers')
- && $this->details['referer_keyword'] == Piwik_Referers_API::LABEL_KEYWORD_NOT_DEFINED
+ && $this->details['referer_keyword'] == ReferersAPI::LABEL_KEYWORD_NOT_DEFINED
) {
return 'http://piwik.org/faq/general/#faq_144';
} // Case URL is google.XX/url.... then we rewrite to the search result page url
@@ -367,7 +371,7 @@ function getRefererUrl()
) {
$refUrl = @parse_url($this->details['referer_url']);
if (isset($refUrl['host'])) {
- $url = Piwik_getSearchEngineUrlFromUrlAndKeyword('http://google.com', $this->getKeyword());
+ $url = \Piwik\Plugins\Referers\getSearchEngineUrlFromUrlAndKeyword('http://google.com', $this->getKeyword());
$url = str_replace('google.com', $refUrl['host'], $url);
return $url;
}
@@ -406,7 +410,7 @@ function getSearchEngineUrl()
if ($this->getRefererType() == 'search'
&& !empty($this->details['referer_name'])
) {
- return Piwik_getSearchEngineUrlFromName($this->details['referer_name']);
+ return \Piwik\Plugins\Referers\getSearchEngineUrlFromName($this->details['referer_name']);
}
return null;
}
@@ -415,7 +419,7 @@ function getSearchEngineIcon()
{
$searchEngineUrl = $this->getSearchEngineUrl();
if (!is_null($searchEngineUrl)) {
- return Piwik_getSearchEngineLogoFromUrl($searchEngineUrl);
+ return \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl($searchEngineUrl);
}
return null;
}
@@ -451,7 +455,7 @@ function getPluginIcons()
$pluginIcons = array();
foreach ($pluginNames as $plugin) {
- $pluginIcons[] = array("pluginIcon" => Piwik_getPluginsLogo($plugin), "pluginName" => $plugin);
+ $pluginIcons[] = array("pluginIcon" => \Piwik\Plugins\UserSettings\getPluginsLogo($plugin), "pluginName" => $plugin);
}
return $pluginIcons;
}
@@ -465,27 +469,27 @@ function getOperatingSystemCode()
function getOperatingSystem()
{
- return Piwik_getOSLabel($this->details['config_os']);
+ return \Piwik\Plugins\UserSettings\getOSLabel($this->details['config_os']);
}
function getOperatingSystemShortName()
{
- return Piwik_getOSShortLabel($this->details['config_os']);
+ return \Piwik\Plugins\UserSettings\getOSShortLabel($this->details['config_os']);
}
function getOperatingSystemIcon()
{
- return Piwik_getOSLogo($this->details['config_os']);
+ return \Piwik\Plugins\UserSettings\getOSLogo($this->details['config_os']);
}
function getBrowserFamilyDescription()
{
- return Piwik_getBrowserTypeLabel($this->getBrowserFamily());
+ return \Piwik\Plugins\UserSettings\getBrowserTypeLabel($this->getBrowserFamily());
}
function getBrowserFamily()
{
- return Piwik_getBrowserFamily($this->details['config_browser_name']);
+ return \Piwik\Plugins\UserSettings\getBrowserFamily($this->details['config_browser_name']);
}
function getBrowserCode()
@@ -500,23 +504,23 @@ function getBrowserVersion()
function getBrowser()
{
- return Piwik_getBrowserLabel($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
+ return \Piwik\Plugins\UserSettings\getBrowserLabel($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
}
function getBrowserIcon()
{
- return Piwik_getBrowsersLogo($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
+ return \Piwik\Plugins\UserSettings\getBrowsersLogo($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
}
function getScreenType()
{
- return Piwik_getScreenTypeFromResolution($this->details['config_resolution']);
+ return \Piwik\Plugins\UserSettings\getScreenTypeFromResolution($this->details['config_resolution']);
}
function getDeviceType()
{
- if(\Piwik\PluginsManager::getInstance()->isPluginActivated('DevicesDetection')) {
- return Piwik_getDeviceTypeLabel($this->details['config_device_type']);
+ if (\Piwik\PluginsManager::getInstance()->isPluginActivated('DevicesDetection')) {
+ return \Piwik\Plugins\DevicesDetection\getDeviceTypeLabel($this->details['config_device_type']);
}
return false;
}
@@ -528,9 +532,9 @@ function getResolution()
function getScreenTypeIcon()
{
- return Piwik_getScreensLogo($this->getScreenType());
+ return \Piwik\Plugins\UserSettings\getScreensLogo($this->getScreenType());
}
-
+
function getProvider()
{
if (isset($this->details['location_provider'])) {
@@ -542,12 +546,12 @@ function getProvider()
function getProviderName()
{
- return Piwik_Provider_getPrettyProviderName($this->getProvider());
+ return \Piwik\Plugins\Provider\getPrettyProviderName($this->getProvider());
}
function getProviderUrl()
{
- return Piwik_getHostnameUrl(@$this->details['location_provider']);
+ return \Piwik\Plugins\Provider\getHostnameUrl(@$this->details['location_provider']);
}
function getDateTimeLastAction()
@@ -569,7 +573,7 @@ function getVisitEcommerceStatusIcon()
function getVisitEcommerceStatus()
{
- return Piwik_API_API::getVisitEcommerceStatusFromId($this->details['visit_goal_buyer']);
+ return MetaAPI::getVisitEcommerceStatusFromId($this->details['visit_goal_buyer']);
}
function getVisitorGoalConvertedIcon()
diff --git a/plugins/Login/Auth.php b/plugins/Login/Auth.php
index 251369e9762..10bad0d0ac6 100644
--- a/plugins/Login/Auth.php
+++ b/plugins/Login/Auth.php
@@ -6,19 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Login
+ * @package Login
*/
+namespace Piwik\Plugins\Login;
+
use Piwik\Config;
use Piwik\Common;
-use Piwik\Auth;
use Piwik\AuthResult;
use Piwik\Db;
+use Piwik\Plugins\UsersManager\API;
/**
*
- * @package Piwik_Login
+ * @package Login
*/
-class Piwik_Login_Auth implements Auth
+class Auth implements \Piwik\Auth
{
protected $login = null;
protected $token_auth = null;
@@ -42,7 +44,7 @@ public function authenticate()
{
$rootLogin = Config::getInstance()->superuser['login'];
$rootPassword = Config::getInstance()->superuser['password'];
- $rootToken = Piwik_UsersManager_API::getInstance()->getTokenAuth($rootLogin, $rootPassword);
+ $rootToken = API::getInstance()->getTokenAuth($rootLogin, $rootPassword);
if (is_null($this->login)) {
if ($this->token_auth === $rootToken) {
diff --git a/plugins/Login/Controller.php b/plugins/Login/Controller.php
index 4aebcd3a86f..1e440de915b 100644
--- a/plugins/Login/Controller.php
+++ b/plugins/Login/Controller.php
@@ -6,12 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Login
+ * @package Login
*/
+namespace Piwik\Plugins\Login;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\Cookie;
use Piwik\IP;
use Piwik\Mail;
@@ -20,15 +22,20 @@
use Piwik\Url;
use Piwik\QuickForm2;
use Piwik\Session;
+use Piwik\Plugins\Login\Login;
+use Piwik\Plugins\Login\FormLogin;
+use Piwik\Plugins\Login\FormResetPassword;
+use Piwik\Plugins\UsersManager\UsersManager;
+use Piwik\Plugins\UsersManager\API;
require_once PIWIK_INCLUDE_PATH . '/core/Config.php';
/**
* Login controller
*
- * @package Piwik_Login
+ * @package Login
*/
-class Piwik_Login_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
* Generate hash on user info and password
@@ -71,10 +78,10 @@ function login($messageNoAccess = null, $infoMessage = false)
{
self::checkForceSslLogin();
- $form = new Piwik_Login_FormLogin();
+ $form = new FormLogin();
if ($form->validate()) {
$nonce = $form->getSubmitValue('form_nonce');
- if (Nonce::verifyNonce('Piwik_Login.login', $nonce)) {
+ if (Nonce::verifyNonce('Login.login', $nonce)) {
$login = $form->getSubmitValue('form_login');
$password = $form->getSubmitValue('form_password');
$rememberMe = $form->getSubmitValue('form_rememberme') == '1';
@@ -112,7 +119,7 @@ private function configureView($view)
$view->forceSslLogin = Config::getInstance()->General['force_ssl_login'];
// crsf token: don't trust the submitted value; generate/fetch it from session data
- $view->nonce = Nonce::getNonce('Piwik_Login.login');
+ $view->nonce = Nonce::getNonce('Login.login');
}
/**
@@ -162,7 +169,7 @@ protected function authenticateAndRedirect($login, $md5Password, $rememberMe, $u
'md5Password' => $md5Password,
'rememberMe' => $rememberMe,
);
- Nonce::discardNonce('Piwik_Login.login');
+ Nonce::discardNonce('Login.login');
Piwik_PostEvent('Login.initSession', array(&$info));
Url::redirectToUrl($urlToRedirect);
}
@@ -188,10 +195,10 @@ function resetPassword()
$infoMessage = null;
$formErrors = null;
- $form = new Piwik_Login_FormResetPassword();
+ $form = new FormResetPassword();
if ($form->validate()) {
$nonce = $form->getSubmitValue('form_nonce');
- if (Nonce::verifyNonce('Piwik_Login.login', $nonce)) {
+ if (Nonce::verifyNonce('Login.login', $nonce)) {
$formErrors = $this->resetPasswordFirstStep($form);
if (empty($formErrors)) {
$infoMessage = Piwik_Translate('Login_ConfirmationLinkSent');
@@ -225,7 +232,7 @@ private function resetPasswordFirstStep($form)
// check the password
try {
- Piwik_UsersManager::checkPassword($password);
+ UsersManager::checkPassword($password);
} catch (Exception $ex) {
return array($ex->getMessage());
}
@@ -243,14 +250,14 @@ private function resetPasswordFirstStep($form)
$login = $user['login'];
// if valid, store password information in options table, then...
- Piwik_Login::savePasswordResetInfo($login, $password);
+ Login::savePasswordResetInfo($login, $password);
// ... send email with confirmation link
try {
$this->sendEmailConfirmationLink($user);
} catch (Exception $ex) {
// remove password reset info
- Piwik_Login::removePasswordResetInfo($login);
+ Login::removePasswordResetInfo($login);
return array($ex->getMessage() . '
' . Piwik_Translate('Login_ContactAdmin'));
}
@@ -312,7 +319,7 @@ public function confirmResetPassword()
}
// check that the reset token is valid
- $resetPassword = Piwik_Login::getPasswordToResetTo($login);
+ $resetPassword = Login::getPasswordToResetTo($login);
if ($resetPassword === false || !self::isValidToken($resetToken, $user)) {
throw new Exception(Piwik_Translate('Login_InvalidOrExpiredToken'));
}
@@ -356,7 +363,7 @@ private function setNewUserPassword($user, $passwordHash)
Config::getInstance()->superuser = $user;
Config::getInstance()->forceSave();
} else {
- Piwik_UsersManager_API::getInstance()->updateUser(
+ API::getInstance()->updateUser(
$user['login'], $passwordHash, $email = false, $alias = false, $isPasswordHashed = true);
}
}
@@ -390,10 +397,10 @@ protected function getUserInformation($loginMail)
'email' => Piwik::getSuperUserEmail(),
'password' => Config::getInstance()->superuser['password'],
);
- } else if (Piwik_UsersManager_API::getInstance()->userExists($loginMail)) {
- $user = Piwik_UsersManager_API::getInstance()->getUser($loginMail);
- } else if (Piwik_UsersManager_API::getInstance()->userEmailExists($loginMail)) {
- $user = Piwik_UsersManager_API::getInstance()->getUserByEmail($loginMail);
+ } else if (API::getInstance()->userExists($loginMail)) {
+ $user = API::getInstance()->getUser($loginMail);
+ } else if (API::getInstance()->userEmailExists($loginMail)) {
+ $user = API::getInstance()->getUserByEmail($loginMail);
}
return $user;
diff --git a/plugins/Login/FormLogin.php b/plugins/Login/FormLogin.php
index 229288e713f..f0f5596fe55 100644
--- a/plugins/Login/FormLogin.php
+++ b/plugins/Login/FormLogin.php
@@ -6,15 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Login
+ * @package Login
*/
+namespace Piwik\Plugins\Login;
+
+use HTML_QuickForm2_DataSource_Array;
use Piwik\QuickForm2;
/**
*
- * @package Piwik_Login
+ * @package Login
*/
-class Piwik_Login_FormLogin extends QuickForm2
+class FormLogin extends QuickForm2
{
function __construct($id = 'login_form', $method = 'post', $attributes = null, $trackSubmit = false)
{
diff --git a/plugins/Login/FormResetPassword.php b/plugins/Login/FormResetPassword.php
index abbe1bd4a1b..0f02aaedcf5 100644
--- a/plugins/Login/FormResetPassword.php
+++ b/plugins/Login/FormResetPassword.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Login
+ * @package Login
*/
+namespace Piwik\Plugins\Login;
+
use Piwik\QuickForm2;
/**
*
- * @package Piwik_Login
+ * @package Login
*/
-class Piwik_Login_FormResetPassword extends QuickForm2
+class FormResetPassword extends QuickForm2
{
function __construct($id = 'resetpasswordform', $method = 'post', $attributes = null, $trackSubmit = false)
{
diff --git a/plugins/Login/Login.php b/plugins/Login/Login.php
index b1da0954ad3..2e511b0a5ba 100644
--- a/plugins/Login/Login.php
+++ b/plugins/Login/Login.php
@@ -6,20 +6,26 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Login
+ * @package Login
*/
+namespace Piwik\Plugins\Login;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Cookie;
use Piwik\Option;
+use Piwik\Plugins\Login\Auth;
+use Piwik\Plugins\Login\Controller;
use Piwik\Session;
-use Piwik\Plugin;
+use Piwik\Plugins\UsersManager\UsersManager;
+use Piwik\Plugins\UsersManager\API;
/**
*
- * @package Piwik_Login
+ * @package Login
*/
-class Piwik_Login extends Plugin
+class Login extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -43,7 +49,7 @@ public function noAccess(Exception $exception)
{
$exceptionMessage = $exception->getMessage();
- $controller = new Piwik_Login_Controller();
+ $controller = new Controller();
$controller->login($exceptionMessage, '' /* $exception->getTraceAsString() */);
}
@@ -63,7 +69,7 @@ public function ApiRequestAuthenticate($tokenAuth)
*/
function initAuthenticationObject($allowCookieAuthentication = false)
{
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
\Zend_Registry::set('auth', $auth);
$action = Piwik::getAction();
@@ -91,7 +97,7 @@ function initAuthenticationObject($allowCookieAuthentication = false)
/**
* Authenticate user and initializes the session.
* Listens to Login.initSession hook.
- *
+ *
* @throws Exception
*/
public function initSession($info)
@@ -100,7 +106,7 @@ public function initSession($info)
$md5Password = $info['md5Password'];
$rememberMe = $info['rememberMe'];
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($login, $md5Password);
+ $tokenAuth = API::getInstance()->getTokenAuth($login, $md5Password);
$auth = \Zend_Registry::get('auth');
$auth->setLogin($login);
@@ -137,7 +143,7 @@ public function initSession($info)
public static function savePasswordResetInfo($login, $password)
{
$optionName = self::getPasswordResetInfoOptionName($login);
- $optionData = Piwik_UsersManager::getPasswordHash($password);
+ $optionData = UsersManager::getPasswordHash($password);
Piwik_SetOption($optionName, $optionData);
}
diff --git a/plugins/MobileMessaging/API.php b/plugins/MobileMessaging/API.php
index 491bb46f860..bb2664ffffd 100644
--- a/plugins/MobileMessaging/API.php
+++ b/plugins/MobileMessaging/API.php
@@ -6,10 +6,15 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Plugins\MobileMessaging\MobileMessaging;
+use Piwik\Plugins\MobileMessaging\SMSProvider;
+use Piwik\Plugins\PDFReports\API as PDFReportsAPI;
/**
* The MobileMessaging API lets you manage and access all the MobileMessaging plugin features including :
@@ -17,9 +22,9 @@
* - activate phone numbers
* - check remaining credits
* - send SMS
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging_API
+class API
{
const VERIFICATION_CODE_LENGTH = 5;
const SMS_FROM = 'Piwik';
@@ -27,7 +32,7 @@ class Piwik_MobileMessaging_API
static private $instance = null;
/**
- * @return Piwik_MobileMessaging_API
+ * @return \Piwik\Plugins\MobileMessaging\API
*/
static public function getInstance()
{
@@ -39,11 +44,11 @@ static public function getInstance()
/**
* @param string $provider
- * @return Piwik_MobileMessaging_SMSProvider
+ * @return SMSProvider
*/
static private function getSMSProviderInstance($provider)
{
- return Piwik_MobileMessaging_SMSProvider::factory($provider);
+ return SMSProvider::factory($provider);
}
/**
@@ -56,17 +61,17 @@ public function areSMSAPICredentialProvided()
Piwik::checkUserHasSomeViewAccess();
$credential = $this->getSMSAPICredential();
- return isset($credential[Piwik_MobileMessaging::API_KEY_OPTION]);
+ return isset($credential[MobileMessaging::API_KEY_OPTION]);
}
private function getSMSAPICredential()
{
$settings = $this->getCredentialManagerSettings();
return array(
- Piwik_MobileMessaging::PROVIDER_OPTION =>
- isset($settings[Piwik_MobileMessaging::PROVIDER_OPTION]) ? $settings[Piwik_MobileMessaging::PROVIDER_OPTION] : null,
- Piwik_MobileMessaging::API_KEY_OPTION =>
- isset($settings[Piwik_MobileMessaging::API_KEY_OPTION]) ? $settings[Piwik_MobileMessaging::API_KEY_OPTION] : null,
+ MobileMessaging::PROVIDER_OPTION =>
+ isset($settings[MobileMessaging::PROVIDER_OPTION]) ? $settings[MobileMessaging::PROVIDER_OPTION] : null,
+ MobileMessaging::API_KEY_OPTION =>
+ isset($settings[MobileMessaging::API_KEY_OPTION]) ? $settings[MobileMessaging::API_KEY_OPTION] : null,
);
}
@@ -79,7 +84,7 @@ public function getSMSProvider()
{
$this->checkCredentialManagementRights();
$credential = $this->getSMSAPICredential();
- return $credential[Piwik_MobileMessaging::PROVIDER_OPTION];
+ return $credential[MobileMessaging::PROVIDER_OPTION];
}
/**
@@ -99,8 +104,8 @@ public function setSMSAPICredential($provider, $apiKey)
$settings = $this->getCredentialManagerSettings();
- $settings[Piwik_MobileMessaging::PROVIDER_OPTION] = $provider;
- $settings[Piwik_MobileMessaging::API_KEY_OPTION] = $apiKey;
+ $settings[MobileMessaging::PROVIDER_OPTION] = $provider;
+ $settings[MobileMessaging::API_KEY_OPTION] = $apiKey;
$this->setCredentialManagerSettings($settings);
@@ -140,7 +145,7 @@ public function addPhoneNumber($phoneNumber)
$phoneNumbers[$phoneNumber] = $verificationCode;
$this->savePhoneNumbers($phoneNumbers);
- $this->increaseCount(Piwik_MobileMessaging::PHONE_NUMBER_VALIDATION_REQUEST_COUNT_OPTION, $phoneNumber);
+ $this->increaseCount(MobileMessaging::PHONE_NUMBER_VALIDATION_REQUEST_COUNT_OPTION, $phoneNumber);
return true;
}
@@ -171,15 +176,15 @@ public function sendSMS($content, $phoneNumber, $from)
Piwik::checkUserIsNotAnonymous();
$credential = $this->getSMSAPICredential();
- $SMSProvider = self::getSMSProviderInstance($credential[Piwik_MobileMessaging::PROVIDER_OPTION]);
+ $SMSProvider = self::getSMSProviderInstance($credential[MobileMessaging::PROVIDER_OPTION]);
$SMSProvider->sendSMS(
- $credential[Piwik_MobileMessaging::API_KEY_OPTION],
+ $credential[MobileMessaging::API_KEY_OPTION],
$content,
$phoneNumber,
$from
);
- $this->increaseCount(Piwik_MobileMessaging::SMS_SENT_COUNT_OPTION, $phoneNumber);
+ $this->increaseCount(MobileMessaging::SMS_SENT_COUNT_OPTION, $phoneNumber);
return true;
}
@@ -194,9 +199,9 @@ public function getCreditLeft()
$this->checkCredentialManagementRights();
$credential = $this->getSMSAPICredential();
- $SMSProvider = self::getSMSProviderInstance($credential[Piwik_MobileMessaging::PROVIDER_OPTION]);
+ $SMSProvider = self::getSMSProviderInstance($credential[MobileMessaging::PROVIDER_OPTION]);
return $SMSProvider->getCreditLeft(
- $credential[Piwik_MobileMessaging::API_KEY_OPTION]
+ $credential[MobileMessaging::API_KEY_OPTION]
);
}
@@ -216,7 +221,7 @@ public function removePhoneNumber($phoneNumber)
$this->savePhoneNumbers($phoneNumbers);
// remove phone number from reports
- $pdfReportsAPIInstance = Piwik_PDFReports_API::getInstance();
+ $pdfReportsAPIInstance = PDFReportsAPI::getInstance();
$reports = $pdfReportsAPIInstance->getReports(
$idSite = false,
$period = false,
@@ -225,9 +230,9 @@ public function removePhoneNumber($phoneNumber)
);
foreach ($reports as $report) {
- if ($report['type'] == Piwik_MobileMessaging::MOBILE_TYPE) {
+ if ($report['type'] == MobileMessaging::MOBILE_TYPE) {
$reportParameters = $report['parameters'];
- $reportPhoneNumbers = $reportParameters[Piwik_MobileMessaging::PHONE_NUMBERS_PARAMETER];
+ $reportPhoneNumbers = $reportParameters[MobileMessaging::PHONE_NUMBERS_PARAMETER];
$updatedPhoneNumbers = array();
foreach ($reportPhoneNumbers as $reportPhoneNumber) {
if ($reportPhoneNumber != $phoneNumber) {
@@ -236,7 +241,7 @@ public function removePhoneNumber($phoneNumber)
}
if (count($updatedPhoneNumbers) != count($reportPhoneNumbers)) {
- $reportParameters[Piwik_MobileMessaging::PHONE_NUMBERS_PARAMETER] = $updatedPhoneNumbers;
+ $reportParameters[MobileMessaging::PHONE_NUMBERS_PARAMETER] = $updatedPhoneNumbers;
// note: reports can end up without any recipients
$pdfReportsAPIInstance->updateReport(
@@ -262,8 +267,8 @@ private function retrievePhoneNumbers()
$settings = $this->getCurrentUserSettings();
$phoneNumbers = array();
- if (isset($settings[Piwik_MobileMessaging::PHONE_NUMBERS_OPTION])) {
- $phoneNumbers = $settings[Piwik_MobileMessaging::PHONE_NUMBERS_OPTION];
+ if (isset($settings[MobileMessaging::PHONE_NUMBERS_OPTION])) {
+ $phoneNumbers = $settings[MobileMessaging::PHONE_NUMBERS_OPTION];
}
return $phoneNumbers;
@@ -273,7 +278,7 @@ private function savePhoneNumbers($phoneNumbers)
{
$settings = $this->getCurrentUserSettings();
- $settings[Piwik_MobileMessaging::PHONE_NUMBERS_OPTION] = $phoneNumbers;
+ $settings[MobileMessaging::PHONE_NUMBERS_OPTION] = $phoneNumbers;
$this->setCurrentUserSettings($settings);
}
@@ -383,7 +388,7 @@ public function deleteSMSAPICredential()
$settings = $this->getCredentialManagerSettings();
- $settings[Piwik_MobileMessaging::API_KEY_OPTION] = null;
+ $settings[MobileMessaging::API_KEY_OPTION] = null;
$this->setCredentialManagerSettings($settings);
@@ -398,7 +403,7 @@ private function checkCredentialManagementRights()
private function setUserSettings($user, $settings)
{
Piwik_SetOption(
- $user . Piwik_MobileMessaging::USER_SETTINGS_POSTFIX_OPTION,
+ $user . MobileMessaging::USER_SETTINGS_POSTFIX_OPTION,
Common::json_encode($settings)
);
}
@@ -420,7 +425,7 @@ private function getCredentialManagerLogin()
private function getUserSettings($user)
{
- $optionIndex = $user . Piwik_MobileMessaging::USER_SETTINGS_POSTFIX_OPTION;
+ $optionIndex = $user . MobileMessaging::USER_SETTINGS_POSTFIX_OPTION;
$userSettings = Piwik_GetOption($optionIndex);
if (empty($userSettings)) {
@@ -450,7 +455,7 @@ private function getCurrentUserSettings()
public function setDelegatedManagement($delegatedManagement)
{
Piwik::checkUserIsSuperUser();
- Piwik_SetOption(Piwik_MobileMessaging::DELEGATED_MANAGEMENT_OPTION, $delegatedManagement);
+ Piwik_SetOption(MobileMessaging::DELEGATED_MANAGEMENT_OPTION, $delegatedManagement);
}
/**
@@ -461,6 +466,6 @@ public function setDelegatedManagement($delegatedManagement)
public function getDelegatedManagement()
{
Piwik::checkUserHasSomeViewAccess();
- return Piwik_GetOption(Piwik_MobileMessaging::DELEGATED_MANAGEMENT_OPTION) == 'true';
+ return Piwik_GetOption(MobileMessaging::DELEGATED_MANAGEMENT_OPTION) == 'true';
}
}
diff --git a/plugins/MobileMessaging/APIException.php b/plugins/MobileMessaging/APIException.php
index d48bb0520ae..515d872bf0d 100644
--- a/plugins/MobileMessaging/APIException.php
+++ b/plugins/MobileMessaging/APIException.php
@@ -6,13 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
+use Exception;
+
/**
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging_APIException extends Exception
+class APIException extends Exception
{
}
diff --git a/plugins/MobileMessaging/Controller.php b/plugins/MobileMessaging/Controller.php
index 0054d62912b..7cbf2d3bf22 100644
--- a/plugins/MobileMessaging/Controller.php
+++ b/plugins/MobileMessaging/Controller.php
@@ -6,22 +6,27 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-use Piwik\Controller\Admin;
+namespace Piwik\Plugins\MobileMessaging;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\IP;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Piwik\Plugins\MobileMessaging\API;
use Piwik\View;
+use Piwik\Plugins\MobileMessaging\CountryCallingCodes;
+use Piwik\Plugins\MobileMessaging\SMSProvider;
require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/functions.php';
/**
*
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
/*
* Mobile Messaging Settings tab :
@@ -38,7 +43,7 @@ public function index()
$view->isSuperUser = Piwik::isUserIsSuperUser();
- $mobileMessagingAPI = Piwik_MobileMessaging_API::getInstance();
+ $mobileMessagingAPI = API::getInstance();
$view->delegatedManagement = $mobileMessagingAPI->getDelegatedManagement();
$view->credentialSupplied = $mobileMessagingAPI->areSMSAPICredentialProvided();
$view->accountManagedByCurrentUser = $view->isSuperUser || $view->delegatedManagement;
@@ -48,23 +53,23 @@ public function index()
$view->creditLeft = $mobileMessagingAPI->getCreditLeft();
}
- $view->smsProviders = Piwik_MobileMessaging_SMSProvider::$availableSMSProviders;
+ $view->smsProviders = SMSProvider::$availableSMSProviders;
// construct the list of countries from the lang files
$countries = array();
foreach (Common::getCountriesList() as $countryCode => $continentCode) {
- if (isset(Piwik_MobileMessaging_CountryCallingCodes::$countryCallingCodes[$countryCode])) {
+ if (isset(CountryCallingCodes::$countryCallingCodes[$countryCode])) {
$countries[$countryCode] =
array(
- 'countryName' => Piwik_CountryTranslate($countryCode),
- 'countryCallingCode' => Piwik_MobileMessaging_CountryCallingCodes::$countryCallingCodes[$countryCode],
+ 'countryName' => \Piwik\Plugins\UserCountry\countryTranslate($countryCode),
+ 'countryCallingCode' => CountryCallingCodes::$countryCallingCodes[$countryCode],
);
}
}
$view->countries = $countries;
$view->defaultCountry = Common::getCountry(
- Piwik_LanguagesManager::getLanguageCodeForCurrentUser(),
+ LanguagesManager::getLanguageCodeForCurrentUser(),
true,
IP::getIpFromHeader()
);
diff --git a/plugins/MobileMessaging/CountryCallingCodes.php b/plugins/MobileMessaging/CountryCallingCodes.php
index b1097220f8c..b98aa180ad4 100644
--- a/plugins/MobileMessaging/CountryCallingCodes.php
+++ b/plugins/MobileMessaging/CountryCallingCodes.php
@@ -6,14 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
/**
*
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging_CountryCallingCodes
+class CountryCallingCodes
{
// list taken from core/DataFiles/Countries.php
public static $countryCallingCodes = array(
diff --git a/plugins/MobileMessaging/GSMCharset.php b/plugins/MobileMessaging/GSMCharset.php
index 4d58c965802..3a8da082901 100644
--- a/plugins/MobileMessaging/GSMCharset.php
+++ b/plugins/MobileMessaging/GSMCharset.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
/**
* GSM 03.38 Charset
*
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging_GSMCharset
+class GSMCharset
{
public static $GSMCharset = array(
diff --git a/plugins/MobileMessaging/MobileMessaging.php b/plugins/MobileMessaging/MobileMessaging.php
index 532e511d731..a7e845a0c24 100644
--- a/plugins/MobileMessaging/MobileMessaging.php
+++ b/plugins/MobileMessaging/MobileMessaging.php
@@ -6,17 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
use Piwik\Piwik;
+use Piwik\Plugins\MobileMessaging\API as MobileMessagingAPI;
use Piwik\View;
-use Piwik\Plugin;
+use Piwik\Plugins\API\API;
+use Piwik_MobileMessaging_ReportRenderer_Exception;
+use Piwik_MobileMessaging_ReportRenderer_Sms;
+use Piwik\Plugins\PDFReports\API as PDFReportsAPI;
/**
*
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging extends Plugin
+class MobileMessaging extends \Piwik\Plugin
{
const DELEGATED_MANAGEMENT_OPTION = 'MobileMessaging_DelegatedManagement';
const PROVIDER_OPTION = 'Provider';
@@ -98,12 +104,12 @@ public function getCssFiles($cssFiles)
{
$cssFiles[] = "plugins/MobileMessaging/stylesheets/MobileMessagingSettings.less";
}
-
+
public function validateReportParameters(&$parameters, $info)
{
if (self::manageEvent($info)) {
// phone number validation
- $availablePhoneNumbers = Piwik_MobileMessaging_API::getInstance()->getActivatedPhoneNumbers();
+ $availablePhoneNumbers = MobileMessagingAPI::getInstance()->getActivatedPhoneNumbers();
$phoneNumbers = $parameters[self::PHONE_NUMBERS_PARAMETER];
foreach ($phoneNumbers as $key => $phoneNumber) {
@@ -121,10 +127,10 @@ public function validateReportParameters(&$parameters, $info)
public function getReportMetadata(&$availableReportMetadata, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $idSite = $notificationInfo[Piwik_PDFReports_API::ID_SITE_INFO_KEY];
+ $idSite = $notificationInfo[PDFReportsAPI::ID_SITE_INFO_KEY];
foreach (self::$availableReports as $availableReport) {
- $reportMetadata = Piwik_API_API::getInstance()->getMetadata(
+ $reportMetadata = API::getInstance()->getMetadata(
$idSite,
$availableReport['module'],
$availableReport['action']
@@ -180,7 +186,7 @@ public function allowMultipleReports(&$allowMultipleReports, $info)
public function getReportRecipients(&$recipients, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $report = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY];
+ $report = $notificationInfo[PDFReportsAPI::REPORT_KEY];
$recipients = $report['parameters'][self::PHONE_NUMBERS_PARAMETER];
}
}
@@ -188,9 +194,9 @@ public function getReportRecipients(&$recipients, $notificationInfo)
public function sendReport($notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $report = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY];
- $contents = $notificationInfo[Piwik_PDFReports_API::REPORT_CONTENT_KEY];
- $reportSubject = $notificationInfo[Piwik_PDFReports_API::REPORT_SUBJECT_KEY];
+ $report = $notificationInfo[PDFReportsAPI::REPORT_KEY];
+ $contents = $notificationInfo[PDFReportsAPI::REPORT_CONTENT_KEY];
+ $reportSubject = $notificationInfo[PDFReportsAPI::REPORT_SUBJECT_KEY];
$parameters = $report['parameters'];
$phoneNumbers = $parameters[self::PHONE_NUMBERS_PARAMETER];
@@ -200,7 +206,7 @@ public function sendReport($notificationInfo)
$reportSubject = Piwik_Translate('General_Reports');
}
- $mobileMessagingAPI = Piwik_MobileMessaging_API::getInstance();
+ $mobileMessagingAPI = MobileMessagingAPI::getInstance();
foreach ($phoneNumbers as $phoneNumber) {
$mobileMessagingAPI->sendSMS(
$contents,
@@ -219,13 +225,13 @@ static public function template_reportParametersPDFReports(&$out)
$view = new View('@MobileMessaging/reportParametersPDFReports');
$view->reportType = self::MOBILE_TYPE;
- $view->phoneNumbers = Piwik_MobileMessaging_API::getInstance()->getActivatedPhoneNumbers();
+ $view->phoneNumbers = MobileMessagingAPI::getInstance()->getActivatedPhoneNumbers();
$out .= $view->render();
}
private static function manageEvent($notificationInfo)
{
- return in_array($notificationInfo[Piwik_PDFReports_API::REPORT_TYPE_INFO_KEY], array_keys(self::$managedReportTypes));
+ return in_array($notificationInfo[PDFReportsAPI::REPORT_TYPE_INFO_KEY], array_keys(self::$managedReportTypes));
}
function install()
@@ -239,11 +245,11 @@ function install()
function deactivate()
{
// delete all mobile reports
- $pdfReportsAPIInstance = Piwik_PDFReports_API::getInstance();
+ $pdfReportsAPIInstance = PDFReportsAPI::getInstance();
$reports = $pdfReportsAPIInstance->getReports();
foreach ($reports as $report) {
- if ($report['type'] == Piwik_MobileMessaging::MOBILE_TYPE) {
+ if ($report['type'] == MobileMessaging::MOBILE_TYPE) {
$pdfReportsAPIInstance->deleteReport($report['idreport']);
}
}
diff --git a/plugins/MobileMessaging/ReportRenderer/Sms.php b/plugins/MobileMessaging/ReportRenderer/Sms.php
index 5c89166ea25..2bd3239bdb1 100644
--- a/plugins/MobileMessaging/ReportRenderer/Sms.php
+++ b/plugins/MobileMessaging/ReportRenderer/Sms.php
@@ -9,6 +9,7 @@
* @package Piwik_MobileMessaging_ReportRenderer
*/
use Piwik\Common;
+use Piwik\Plugins\MultiSites\API;
use Piwik\View;
use Piwik\ReportRenderer;
use Piwik\Site;
@@ -62,9 +63,9 @@ public function renderReport($processedReport)
$reportData = $processedReport['reportData'];
$evolutionMetrics = array();
- $multiSitesAPIMetrics = Piwik_MultiSites_API::getApiMetrics($enhanced = true);
+ $multiSitesAPIMetrics = API::getApiMetrics($enhanced = true);
foreach ($multiSitesAPIMetrics as $metricSettings) {
- $evolutionMetrics[] = $metricSettings[Piwik_MultiSites_API::METRIC_EVOLUTION_COL_NAME_KEY];
+ $evolutionMetrics[] = $metricSettings[API::METRIC_EVOLUTION_COL_NAME_KEY];
}
// no decimal for all metrics to shorten SMS content (keeps the monetary sign for revenue metrics)
diff --git a/plugins/MobileMessaging/SMSProvider.php b/plugins/MobileMessaging/SMSProvider.php
index 402c135b48f..7a9c36bb771 100644
--- a/plugins/MobileMessaging/SMSProvider.php
+++ b/plugins/MobileMessaging/SMSProvider.php
@@ -6,17 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
+use Exception;
use Piwik\Loader;
+use Piwik\Plugins\MobileMessaging\GSMCharset;
/**
- * The Piwik_MobileMessaging_SMSProvider abstract class is used as a base class for SMS provider implementations.
+ * The SMSProvider abstract class is used as a base class for SMS provider implementations.
*
- * @package Piwik_MobileMessaging
- * @subpackage Piwik_MobileMessaging_SMSProvider
+ * @package MobileMessaging
+ * @subpackage SMSProvider
*/
-abstract class Piwik_MobileMessaging_SMSProvider
+abstract class SMSProvider
{
const MAX_GSM_CHARS_IN_ONE_UNIQUE_SMS = 160;
const MAX_GSM_CHARS_IN_ONE_CONCATENATED_SMS = 153;
@@ -26,11 +30,11 @@ abstract class Piwik_MobileMessaging_SMSProvider
static public $availableSMSProviders = array(
'Clockwork' => 'You can use to send SMS Reports from Piwik.
About Clockwork:
- - Clockwork gives you fast, reliable high quality worldwide SMS delivery, over 450 networks in every corner of the globe.
+
- Clockwork gives you fast, reliable high quality worldwide SMS delivery, over 450 networks in every corner of the globe.
- Cost per SMS message is around ~0.08USD (0.06EUR).
- Most countries and networks are supported but we suggest you check the latest position on their coverage map here.
@@ -41,13 +45,13 @@ abstract class Piwik_MobileMessaging_SMSProvider
/**
* Return the SMSProvider associated to the provider name $providerName
*
- * @throws exception If the provider is unknown
+ * @throws Exception If the provider is unknown
* @param string $providerName
- * @return Piwik_MobileMessaging_SMSProvider
+ * @return \Piwik\Plugins\MobileMessaging\SMSProvider
*/
static public function factory($providerName)
{
- $className = 'Piwik_MobileMessaging_SMSProvider_' . $providerName;
+ $className = __NAMESPACE__ . '\\SMSProvider\\' . $providerName;
try {
Loader::loadClass($className);
@@ -70,7 +74,7 @@ static public function factory($providerName)
*/
static public function containsUCS2Characters($string)
{
- $GSMCharsetAsString = implode(array_keys(Piwik_MobileMessaging_GSMCharset::$GSMCharset));
+ $GSMCharsetAsString = implode(array_keys(GSMCharset::$GSMCharset));
foreach (self::mb_str_split($string) as $char) {
if (mb_strpos($GSMCharsetAsString, $char) === false) {
@@ -128,7 +132,7 @@ static private function sizeOfSMSContent($smsContent, $containsUCS2Chars)
$sizeOfSMSContent = 0;
foreach (self::mb_str_split($smsContent) as $char) {
- $sizeOfSMSContent += Piwik_MobileMessaging_GSMCharset::$GSMCharset[$char];
+ $sizeOfSMSContent += GSMCharset::$GSMCharset[$char];
}
return $sizeOfSMSContent;
}
diff --git a/plugins/MobileMessaging/SMSProvider/Clockwork.php b/plugins/MobileMessaging/SMSProvider/Clockwork.php
index 29a153c6da4..817220afb07 100644
--- a/plugins/MobileMessaging/SMSProvider/Clockwork.php
+++ b/plugins/MobileMessaging/SMSProvider/Clockwork.php
@@ -6,17 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging_SMSProvider
+ * @package SMSProvider
*/
use Piwik\Http;
+use Piwik\Plugins\MobileMessaging\APIException;
+use Piwik\Plugins\MobileMessaging\SMSProvider;
require_once PIWIK_INCLUDE_PATH . "/plugins/MobileMessaging/APIException.php";
/**
*
- * @package Piwik_MobileMessaging_SMSProvider
+ * @package SMSProvider
*/
-class Piwik_MobileMessaging_SMSProvider_Clockwork extends Piwik_MobileMessaging_SMSProvider
+class Piwik_MobileMessaging_SMSProvider_Clockwork extends SMSProvider
{
const SOCKET_TIMEOUT = 15;
@@ -88,7 +90,7 @@ private function issueApiCall($apiKey, $resource, $additionalParameters = array(
}
if (strpos($result, self::ERROR_STRING) !== false) {
- throw new Piwik_MobileMessaging_APIException(
+ throw new APIException(
'Clockwork API returned the following error message : ' . $result
);
}
diff --git a/plugins/MobileMessaging/SMSProvider/StubbedProvider.php b/plugins/MobileMessaging/SMSProvider/StubbedProvider.php
index 8402eefc512..56f7d8c0f57 100644
--- a/plugins/MobileMessaging/SMSProvider/StubbedProvider.php
+++ b/plugins/MobileMessaging/SMSProvider/StubbedProvider.php
@@ -6,15 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging_SMSProvider
+ * @package SMSProvider
*/
+use Piwik\Plugins\MobileMessaging\SMSProvider;
/**
* Used for testing
*
- * @package Piwik_MobileMessaging_SMSProvider
+ * @package SMSProvider
*/
-class Piwik_MobileMessaging_SMSProvider_StubbedProvider extends Piwik_MobileMessaging_SMSProvider
+class Piwik_MobileMessaging_SMSProvider_StubbedProvider extends SMSProvider
{
public function verifyCredential($apiKey)
diff --git a/plugins/MultiSites/API.php b/plugins/MultiSites/API.php
index 6e4feeba76c..dec284cd3cb 100755
--- a/plugins/MultiSites/API.php
+++ b/plugins/MultiSites/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MultiSites
+ * @package MultiSites
*/
+namespace Piwik\Plugins\MultiSites;
+
+use Exception;
use Piwik\API\Request;
use Piwik\Archive;
use Piwik\DataTable\Filter\CalculateEvolutionFilter;
@@ -15,13 +18,15 @@
use Piwik\Piwik;
use Piwik\Common;
use Piwik\DataTable;
+use Piwik\Plugins\Goals\Archiver;
use Piwik\TaskScheduler;
use Piwik\Site;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
* The MultiSites API lets you request the key metrics (visits, page views, revenue) for all Websites in Piwik.
*/
-class Piwik_MultiSites_API
+class API
{
const METRIC_TRANSLATION_KEY = 'translation';
const METRIC_EVOLUTION_COL_NAME_KEY = 'evolution_column_name';
@@ -67,7 +72,7 @@ class Piwik_MultiSites_API
* Returns the singleton instance of this class. The instance is created
* if it hasn't been already.
*
- * @return Piwik_MultiSites_API
+ * @return \Piwik\Plugins\MultiSites\API
*/
static public function getInstance()
{
@@ -107,7 +112,7 @@ public function getAll($period, $date, $segment = false, $_restrictSitesToLogin
$idSites = $this->getSitesIdFromPattern($pattern);
- if(empty($idSites)) {
+ if (empty($idSites)) {
return new DataTable();
}
return $this->buildDataTable(
@@ -130,7 +135,7 @@ public function getAll($period, $date, $segment = false, $_restrictSitesToLogin
private function getSitesIdFromPattern($pattern)
{
$idSites = 'all';
- if(empty($pattern)) {
+ if (empty($pattern)) {
return $idSites;
}
$idSites = array();
@@ -185,11 +190,11 @@ private function buildDataTable($sites, $period, $date, $segment, $_restrictSite
&& !TaskScheduler::isTaskBeingExecuted()
) {
Site::setSites(
- Piwik_SitesManager_API::getInstance()->getAllSites()
+ SitesManagerAPI::getInstance()->getAllSites()
);
} else {
Site::setSitesFromArray(
- Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess($limit = false, $_restrictSitesToLogin)
+ SitesManagerAPI::getInstance()->getSitesWithAtLeastViewAccess($limit = false, $_restrictSitesToLogin)
);
}
}
@@ -207,7 +212,7 @@ private function buildDataTable($sites, $period, $date, $segment, $_restrictSite
$fieldsToGet = array();
$columnNameRewrites = array();
$apiECommerceMetrics = array();
- $apiMetrics = Piwik_MultiSites_API::getApiMetrics($enhanced);
+ $apiMetrics = API::getApiMetrics($enhanced);
foreach ($apiMetrics as $metricName => $metricSettings) {
$fieldsToGet[] = $metricSettings[self::METRIC_RECORD_NAME_KEY];
$columnNameRewrites[$metricSettings[self::METRIC_RECORD_NAME_KEY]] = $metricName;
@@ -231,7 +236,7 @@ private function buildDataTable($sites, $period, $date, $segment, $_restrictSite
&& $dataTable->getRowsCount() > 0
) {
$firstSite = is_array($sites) ? reset($sites) : $sites;
-
+
$firstDataTableRow = $dataTable->getFirstRow();
$firstDataTableRow->setColumn('label', $firstSite);
}
@@ -252,7 +257,7 @@ private function buildDataTable($sites, $period, $date, $segment, $_restrictSite
}
$pastArchive = Archive::build($sites, $period, $strLastDate, $segment, $_restrictSitesToLogin);
$pastData = $pastArchive->getDataTableFromNumeric($fieldsToGet);
-
+
if ($pastData instanceof DataTable\Map
&& $multipleWebsitesRequested
) {
@@ -302,8 +307,9 @@ private function buildDataTable($sites, $period, $date, $segment, $_restrictSite
// note: if only one website is queried and there are no visits, we can not remove the row otherwise
// ResponseBuilder throws 'Call to a member function getColumns() on a non-object'
if ($multipleWebsitesRequested
- // We don't delete the 0 visits row, if "Enhanced" mode is on.
- && !$enhanced) {
+ // We don't delete the 0 visits row, if "Enhanced" mode is on.
+ && !$enhanced
+ ) {
$dataTable->filter(
'ColumnCallbackDeleteRow',
array(
@@ -329,10 +335,10 @@ private function buildDataTable($sites, $period, $date, $segment, $_restrictSite
private function calculateEvolutionPercentages($currentData, $pastData, $apiMetrics)
{
if (get_class($currentData) != get_class($pastData)) { // sanity check for regressions
- throw new Exception("Expected \$pastData to be of type ".get_class($currentData)." - got "
- . get_class($pastData).".");
+ throw new Exception("Expected \$pastData to be of type " . get_class($currentData) . " - got "
+ . get_class($pastData) . ".");
}
-
+
if ($currentData instanceof DataTable\Map) {
$pastArray = $pastData->getArray();
foreach ($currentData->getArray() as $subTable) {
@@ -370,7 +376,7 @@ private function setMetricsTotalsMetadata($dataTable, $apiMetrics)
} else {
$revenueMetric = '';
if (Common::isGoalPluginEnabled()) {
- $revenueMetric = Piwik_Goals_Archiver::getRecordName(self::GOAL_REVENUE_METRIC);
+ $revenueMetric = Archiver::getRecordName(self::GOAL_REVENUE_METRIC);
}
$totals = array();
@@ -442,7 +448,7 @@ public static function getApiMetrics($enhanced)
$metrics[self::GOAL_REVENUE_METRIC] = array(
self::METRIC_TRANSLATION_KEY => 'Goals_ColumnRevenue',
self::METRIC_EVOLUTION_COL_NAME_KEY => self::GOAL_REVENUE_METRIC . '_evolution',
- self::METRIC_RECORD_NAME_KEY => Piwik_Goals_Archiver::getRecordName(self::GOAL_REVENUE_METRIC),
+ self::METRIC_RECORD_NAME_KEY => Archiver::getRecordName(self::GOAL_REVENUE_METRIC),
self::METRIC_IS_ECOMMERCE_KEY => false,
);
@@ -451,7 +457,7 @@ public static function getApiMetrics($enhanced)
$metrics[self::GOAL_CONVERSION_METRIC] = array(
self::METRIC_TRANSLATION_KEY => 'Goals_ColumnConversions',
self::METRIC_EVOLUTION_COL_NAME_KEY => self::GOAL_CONVERSION_METRIC . '_evolution',
- self::METRIC_RECORD_NAME_KEY => Piwik_Goals_Archiver::getRecordName(self::GOAL_CONVERSION_METRIC),
+ self::METRIC_RECORD_NAME_KEY => Archiver::getRecordName(self::GOAL_CONVERSION_METRIC),
self::METRIC_IS_ECOMMERCE_KEY => false,
);
@@ -459,7 +465,7 @@ public static function getApiMetrics($enhanced)
$metrics[self::ECOMMERCE_ORDERS_METRIC] = array(
self::METRIC_TRANSLATION_KEY => 'General_EcommerceOrders',
self::METRIC_EVOLUTION_COL_NAME_KEY => self::ECOMMERCE_ORDERS_METRIC . '_evolution',
- self::METRIC_RECORD_NAME_KEY => Piwik_Goals_Archiver::getRecordName(self::GOAL_CONVERSION_METRIC, 0),
+ self::METRIC_RECORD_NAME_KEY => Archiver::getRecordName(self::GOAL_CONVERSION_METRIC, 0),
self::METRIC_IS_ECOMMERCE_KEY => true,
);
@@ -467,7 +473,7 @@ public static function getApiMetrics($enhanced)
$metrics[self::ECOMMERCE_REVENUE_METRIC] = array(
self::METRIC_TRANSLATION_KEY => 'General_ProductRevenue',
self::METRIC_EVOLUTION_COL_NAME_KEY => self::ECOMMERCE_REVENUE_METRIC . '_evolution',
- self::METRIC_RECORD_NAME_KEY => Piwik_Goals_Archiver::getRecordName(self::GOAL_REVENUE_METRIC, 0),
+ self::METRIC_RECORD_NAME_KEY => Archiver::getRecordName(self::GOAL_REVENUE_METRIC, 0),
self::METRIC_IS_ECOMMERCE_KEY => true,
);
}
diff --git a/plugins/MultiSites/Controller.php b/plugins/MultiSites/Controller.php
index b57f90b0205..56ed2351d48 100644
--- a/plugins/MultiSites/Controller.php
+++ b/plugins/MultiSites/Controller.php
@@ -6,22 +6,25 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MultiSites
+ * @package MultiSites
*/
+namespace Piwik\Plugins\MultiSites;
+
use Piwik\Period;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Config;
use Piwik\Date;
-use Piwik\Controller;
+use Piwik\Plugins\MultiSites\API as MultiSitesAPI;
use Piwik\View;
use Piwik\Site;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
*
- * @package Piwik_MultiSites
+ * @package MultiSites
*/
-class Piwik_MultiSites_Controller extends Controller
+class Controller extends \Piwik\Controller
{
protected $orderBy = 'visits';
protected $order = 'desc';
@@ -48,7 +51,6 @@ function standalone()
$this->getSitesInfo($isWidgetized = true);
}
-
public function getSitesInfo($isWidgetized = false)
{
Piwik::checkUserHasSomeViewAccess();
@@ -56,20 +58,19 @@ public function getSitesInfo($isWidgetized = false)
$date = Common::getRequestVar('date', 'today');
$period = Common::getRequestVar('period', 'day');
- $siteIds = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
+ $siteIds = SitesManagerAPI::getInstance()->getSitesIdWithAtLeastViewAccess();
list($minDate, $maxDate) = $this->getMinMaxDateAcrossWebsites($siteIds);
// overwrites the default Date set in the parent controller
// Instead of the default current website's local date,
// we set "today" or "yesterday" based on the default Piwik timezone
- $piwikDefaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
+ $piwikDefaultTimezone = SitesManagerAPI::getInstance()->getDefaultTimezone();
if ($period != 'range') {
$date = $this->getDateParameterInTimezone($date, $piwikDefaultTimezone);
$this->setDate($date);
$date = $date->toString();
}
- $dataTable = Piwik_MultiSites_API::getInstance()->getAll($period, $date, $segment = false);
-
+ $dataTable = MultiSitesAPI::getInstance()->getAll($period, $date, $segment = false);
// put data into a form the template will understand better
$digestableData = array();
diff --git a/plugins/MultiSites/MultiSites.php b/plugins/MultiSites/MultiSites.php
index 96f14fabce3..fab4cd498ee 100644
--- a/plugins/MultiSites/MultiSites.php
+++ b/plugins/MultiSites/MultiSites.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MultiSites
+ * @package MultiSites
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\MultiSites;
+
+use Piwik\Plugins\MultiSites\API;
/**
*
- * @package Piwik_MultiSites
+ * @package MultiSites
*/
-class Piwik_MultiSites extends Plugin
+class MultiSites extends \Piwik\Plugin
{
public function getInformation()
{
@@ -40,11 +42,11 @@ public function getListHooksRegistered()
public function getReportMetadata(&$reports)
{
$metadataMetrics = array();
- foreach (Piwik_MultiSites_API::getApiMetrics($enhanced = true) as $metricName => $metricSettings) {
+ foreach (API::getApiMetrics($enhanced = true) as $metricName => $metricSettings) {
$metadataMetrics[$metricName] =
- Piwik_Translate($metricSettings[Piwik_MultiSites_API::METRIC_TRANSLATION_KEY]);
- $metadataMetrics[$metricSettings[Piwik_MultiSites_API::METRIC_EVOLUTION_COL_NAME_KEY]] =
- Piwik_Translate($metricSettings[Piwik_MultiSites_API::METRIC_TRANSLATION_KEY]) . " " . Piwik_Translate('MultiSites_Evolution');
+ Piwik_Translate($metricSettings[API::METRIC_TRANSLATION_KEY]);
+ $metadataMetrics[$metricSettings[API::METRIC_EVOLUTION_COL_NAME_KEY]] =
+ Piwik_Translate($metricSettings[API::METRIC_TRANSLATION_KEY]) . " " . Piwik_Translate('MultiSites_Evolution');
}
$reports[] = array(
diff --git a/plugins/Overlay/API.php b/plugins/Overlay/API.php
index 35e7c681e44..d065b923697 100644
--- a/plugins/Overlay/API.php
+++ b/plugins/Overlay/API.php
@@ -1,10 +1,4 @@
authenticate($idSite);
- $sitesManager = Piwik_SitesManager_API::getInstance();
+ $sitesManager = SitesManagerAPI::getInstance();
$site = $sitesManager->getSiteFromId($idSite);
try {
- return Piwik_SitesManager::getTrackerExcludedQueryParameters($site);
+ return SitesManager::getTrackerExcludedQueryParameters($site);
} catch (Exception $e) {
// an exception is thrown when the user has no view access.
// do not throw the exception to the outside.
@@ -87,7 +93,7 @@ public function getFollowingPages($url, $idSite, $period, $date, $segment = fals
try {
$limitBeforeGrouping = Config::getInstance()->General['overlay_following_pages_limit'];
- $transitionsReport = Piwik_Transitions_API::getInstance()->getTransitionsForAction(
+ $transitionsReport = TransitionsAPI::getInstance()->getTransitionsForAction(
$url, $type = 'url', $idSite, $period, $date, $segment, $limitBeforeGrouping,
$part = 'followingActions', $returnNormalizedUrls = true);
} catch (Exception $e) {
@@ -124,5 +130,4 @@ private function authenticate($idSite)
Piwik::checkUserHasViewAccess($idSite);
}
-
}
diff --git a/plugins/Overlay/Controller.php b/plugins/Overlay/Controller.php
index 2efcfd70577..3721c9b2266 100644
--- a/plugins/Overlay/Controller.php
+++ b/plugins/Overlay/Controller.php
@@ -1,13 +1,4 @@
', $path);
$request = new Request(
@@ -79,7 +81,6 @@ public function renderSidebar()
$showMetrics = array('nb_hits', 'nb_visits', 'nb_uniq_visitors',
'bounce_rate', 'exit_rate', 'avg_time_on_page');
-
foreach ($showMetrics as $metric) {
$value = $row->getColumn($metric);
if ($value === false) {
@@ -127,7 +128,7 @@ public function startOverlaySession()
$idSite = Common::getRequestVar('idsite', 0, 'int');
Piwik::checkUserHasViewAccess($idSite);
- $sitesManager = Piwik_SitesManager_API::getInstance();
+ $sitesManager = API::getInstance();
$site = $sitesManager->getSiteFromId($idSite);
$urls = $sitesManager->getSiteUrlsFromId($idSite);
@@ -142,17 +143,17 @@ function handleProtocol(url) {
return url.replace(/https:\/\//i, "http://");
}
}
-
+
function removeUrlPrefix(url) {
return url.replace(/http(s)?:\/\/(www\.)?/i, "");
}
-
+
if (window.location.hash) {
var match = false;
-
+
var urlToRedirect = window.location.hash.substr(1);
var urlToRedirectWithoutPrefix = removeUrlPrefix(urlToRedirect);
-
+
var knownUrls = ' . Common::json_encode($urls) . ';
for (var i = 0; i < knownUrls.length; i++) {
var testUrl = removeUrlPrefix(knownUrls[i]);
@@ -170,12 +171,12 @@ function removeUrlPrefix(url) {
break;
}
}
-
+
if (!match) {
var idSite = window.location.href.match(/idSite=([0-9]+)/i)[1];
window.location.href = "index.php?module=Overlay&action=showErrorWrongDomain"
+ "&idSite=" + idSite
- + "&url=" + encodeURIComponent(urlToRedirect);
+ + "&url=" + encodeURIComponent(urlToRedirect);
}
}
else {
@@ -231,5 +232,4 @@ public function notifyParentIframe()
$view = new View('@Overlay/notifyParentIframe');
echo $view->render();
}
-
}
diff --git a/plugins/Overlay/Overlay.php b/plugins/Overlay/Overlay.php
index 72a08d5046e..b0ba9a2c7bb 100644
--- a/plugins/Overlay/Overlay.php
+++ b/plugins/Overlay/Overlay.php
@@ -6,12 +6,13 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Overlay
+ * @package Overlay
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\Overlay;
-class Piwik_Overlay extends Plugin
+
+class Overlay extends \Piwik\Plugin
{
public function getInformation()
{
diff --git a/plugins/PDFReports/API.php b/plugins/PDFReports/API.php
index 716687866ba..708dd64ccb8 100644
--- a/plugins/PDFReports/API.php
+++ b/plugins/PDFReports/API.php
@@ -6,16 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
+namespace Piwik\Plugins\PDFReports;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
use Piwik\ReportRenderer;
use Piwik\ReportRenderer\Html;
use Piwik\Site;
use Piwik\Translate;
use Piwik\Db;
+use Piwik\Plugins\SegmentEditor\API as SegmentEditorAPI;
+use Zend_Mime;
/**
* The PDFReports API lets you manage Scheduled Email reports, as well as generate, download or email any existing report.
@@ -27,9 +33,9 @@
* or manage existing reports with "updateReport" and "deleteReport".
* See also the documentation about Scheduled Email reports in Piwik.
*
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
-class Piwik_PDFReports_API
+class API
{
const VALIDATE_PARAMETERS_EVENT = 'PDFReports.validateReportParameters';
const GET_REPORT_PARAMETERS_EVENT = 'PDFReports.getReportParameters';
@@ -63,7 +69,7 @@ class Piwik_PDFReports_API
static private $instance = null;
/**
- * @return Piwik_PDFReports_API
+ * @return \Piwik\Plugins\PDFReports\API
*/
static public function getInstance()
{
@@ -133,9 +139,9 @@ public function addReport($idSite, $description, $period, $hour, $reportType, $r
private static function ensureLanguageSetForUser($currentUser)
{
- $lang = Piwik_LanguagesManager_API::getInstance()->getLanguageForUser($currentUser);
+ $lang = \Piwik\Plugins\LanguagesManager\API::getInstance()->getLanguageForUser($currentUser);
if (empty($lang)) {
- Piwik_LanguagesManager_API::getInstance()->setLanguageForUser($currentUser, Piwik_LanguagesManager::getLanguageCodeForCurrentUser());
+ \Piwik\Plugins\LanguagesManager\API::getInstance()->setLanguageForUser($currentUser, LanguagesManager::getLanguageCodeForCurrentUser());
}
}
@@ -330,7 +336,7 @@ public function generateReport($idReport, $date, $language = false, $outputType
);
// available reports
- $availableReportMetadata = Piwik_API_API::getInstance()->getReportMetadata($idSite);
+ $availableReportMetadata = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite);
// we need to lookup which reports metadata are registered in this report
$reportMetadata = array();
@@ -377,7 +383,7 @@ public function generateReport($idReport, $date, $language = false, $outputType
}
}
- $processedReport = Piwik_API_API::getInstance()->getProcessedReport(
+ $processedReport = \Piwik\Plugins\API\API::getInstance()->getProcessedReport(
$idSite, $period, $date, $apiModule, $apiAction,
$segment != null ? urlencode($segment['definition']) : false,
$apiParameters, $idGoal = false, $language
@@ -504,7 +510,7 @@ public function sendReport($idReport, $period = false, $date = false)
$date = Date::now()->subPeriod(1, $report['period'])->toString();
}
- $language = Piwik_LanguagesManager_API::getInstance()->getLanguageForUser($report['login']);
+ $language = \Piwik\Plugins\LanguagesManager\API::getInstance()->getLanguageForUser($report['login']);
// generate report
list($outputFilename, $prettyDate, $reportSubject, $reportTitle, $additionalFiles) =
@@ -528,16 +534,16 @@ public function sendReport($idReport, $period = false, $date = false)
Piwik_PostEvent(
self::SEND_REPORT_EVENT,
array(
- $notificationInfo = array(
- self::REPORT_TYPE_INFO_KEY => $report['type'],
- self::REPORT_KEY => $report,
- self::REPORT_CONTENT_KEY => $contents,
- self::FILENAME_KEY => $filename,
- self::PRETTY_DATE_KEY => $prettyDate,
- self::REPORT_SUBJECT_KEY => $reportSubject,
- self::REPORT_TITLE_KEY => $reportTitle,
- self::ADDITIONAL_FILES_KEY => $additionalFiles,
- )
+ $notificationInfo = array(
+ self::REPORT_TYPE_INFO_KEY => $report['type'],
+ self::REPORT_KEY => $report,
+ self::REPORT_CONTENT_KEY => $contents,
+ self::FILENAME_KEY => $filename,
+ self::PRETTY_DATE_KEY => $prettyDate,
+ self::REPORT_SUBJECT_KEY => $reportSubject,
+ self::REPORT_TITLE_KEY => $reportTitle,
+ self::ADDITIONAL_FILES_KEY => $additionalFiles,
+ )
)
);
@@ -659,11 +665,9 @@ private static function validateIdSegment(&$idSegment)
if (empty($idSegment) || (is_numeric($idSegment) && $idSegment == 0)) {
$idSegment = null;
-
} elseif (!is_numeric($idSegment)) {
throw new Exception('Invalid segment identifier. Should be an integer.');
-
} elseif (self::getSegment($idSegment) == null) {
throw new Exception('Segment with id ' . $idSegment . ' does not exist or SegmentEditor is not activated.');
@@ -724,10 +728,10 @@ static public function allowMultipleReports($reportType)
Piwik_PostEvent(
self::ALLOW_MULTIPLE_REPORTS_EVENT,
array(
- &$allowMultipleReports,
- $notificationInfo = array(
- self::REPORT_TYPE_INFO_KEY => $reportType,
- )
+ &$allowMultipleReports,
+ $notificationInfo = array(
+ self::REPORT_TYPE_INFO_KEY => $reportType,
+ )
)
);
return $allowMultipleReports;
@@ -754,10 +758,10 @@ static public function getReportFormats($reportType)
Piwik_PostEvent(
self::GET_REPORT_FORMATS_EVENT,
array(
- &$reportFormats,
- $notificationInfo = array(
- self::REPORT_TYPE_INFO_KEY => $reportType
- )
+ &$reportFormats,
+ $notificationInfo = array(
+ self::REPORT_TYPE_INFO_KEY => $reportType
+ )
)
);
@@ -788,7 +792,7 @@ static public function getSegment($idSegment)
{
if (self::isSegmentEditorActivated() && !empty($idSegment)) {
- $segment = Piwik_SegmentEditor_API::getInstance()->get($idSegment);
+ $segment = SegmentEditorAPI::getInstance()->get($idSegment);
if ($segment) {
return $segment;
diff --git a/plugins/PDFReports/Controller.php b/plugins/PDFReports/Controller.php
index 3eed377084c..67c3ce70a3e 100644
--- a/plugins/PDFReports/Controller.php
+++ b/plugins/PDFReports/Controller.php
@@ -6,45 +6,51 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
+namespace Piwik\Plugins\PDFReports;
+
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Piwik\Plugins\PDFReports\API;
use Piwik\View;
+use Piwik\Plugins\PDFReports\PDFReports;
+use Piwik\Plugins\SegmentEditor\API as SegmentEditorAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
*
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
-class Piwik_PDFReports_Controller extends Controller
+class Controller extends \Piwik\Controller
{
- const DEFAULT_REPORT_TYPE = Piwik_PDFReports::EMAIL_TYPE;
+ const DEFAULT_REPORT_TYPE = PDFReports::EMAIL_TYPE;
public function index()
{
$view = new View('@PDFReports/index');
$this->setGeneralVariablesView($view);
- $view->countWebsites = count(Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess());
+ $view->countWebsites = count(SitesManagerAPI::getInstance()->getSitesIdWithAtLeastViewAccess());
// get report types
- $reportTypes = Piwik_PDFReports_API::getReportTypes();
+ $reportTypes = API::getReportTypes();
$view->reportTypes = $reportTypes;
$view->defaultReportType = self::DEFAULT_REPORT_TYPE;
- $view->defaultReportFormat = Piwik_PDFReports::DEFAULT_REPORT_FORMAT;
+ $view->defaultReportFormat = PDFReports::DEFAULT_REPORT_FORMAT;
$reportsByCategoryByType = array();
$reportFormatsByReportType = array();
$allowMultipleReportsByReportType = array();
foreach ($reportTypes as $reportType => $reportTypeIcon) {
// get report formats
- $reportFormatsByReportType[$reportType] = Piwik_PDFReports_API::getReportFormats($reportType);
- $allowMultipleReportsByReportType[$reportType] = Piwik_PDFReports_API::allowMultipleReports($reportType);
+ $reportFormatsByReportType[$reportType] = API::getReportFormats($reportType);
+ $allowMultipleReportsByReportType[$reportType] = API::allowMultipleReports($reportType);
// get report metadata
$reportsByCategory = array();
- $availableReportMetadata = Piwik_PDFReports_API::getReportMetadata($this->idSite, $reportType);
+ $availableReportMetadata = API::getReportMetadata($this->idSite, $reportType);
foreach ($availableReportMetadata as $reportMetadata) {
$reportsByCategory[$reportMetadata['category']][] = $reportMetadata;
}
@@ -57,28 +63,28 @@ public function index()
$reports = array();
$reportsById = array();
if (!Piwik::isUserIsAnonymous()) {
- $reports = Piwik_PDFReports_API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true);
+ $reports = API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true);
foreach ($reports as &$report) {
- $report['recipients'] = Piwik_PDFReports_API::getReportRecipients($report);
+ $report['recipients'] = API::getReportRecipients($report);
$reportsById[$report['idreport']] = $report;
}
}
$view->reports = $reports;
$view->reportsJSON = Common::json_encode($reportsById);
- $view->downloadOutputType = Piwik_PDFReports_API::OUTPUT_INLINE;
+ $view->downloadOutputType = API::OUTPUT_INLINE;
- $view->periods = Piwik_PDFReports::getPeriodToFrequency();
- $view->defaultPeriod = Piwik_PDFReports::DEFAULT_PERIOD;
- $view->defaultHour = Piwik_PDFReports::DEFAULT_HOUR;
+ $view->periods = PDFReports::getPeriodToFrequency();
+ $view->defaultPeriod = PDFReports::DEFAULT_PERIOD;
+ $view->defaultHour = PDFReports::DEFAULT_HOUR;
- $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
$view->segmentEditorActivated = false;
- if (Piwik_PDFReports_API::isSegmentEditorActivated()) {
+ if (API::isSegmentEditorActivated()) {
$savedSegmentsById = array();
- foreach (Piwik_SegmentEditor_API::getInstance()->getAll($this->idSite) as $savedSegment) {
+ foreach (SegmentEditorAPI::getInstance()->getAll($this->idSite) as $savedSegment) {
$savedSegmentsById[$savedSegment['idsegment']] = $savedSegment['name'];
}
$view->savedSegmentsById = $savedSegmentsById;
diff --git a/plugins/PDFReports/PDFReports.php b/plugins/PDFReports/PDFReports.php
index 74c5a0110fe..edd053cca40 100644
--- a/plugins/PDFReports/PDFReports.php
+++ b/plugins/PDFReports/PDFReports.php
@@ -6,26 +6,34 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
+namespace Piwik\Plugins\PDFReports;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Config;
use Piwik\Date;
use Piwik\Mail;
+use Piwik\Plugins\MobileMessaging\API as MobileMessagingAPI;
+use Piwik\Plugins\MobileMessaging\MobileMessaging;
use Piwik\View;
use Piwik\ScheduledTime;
use Piwik\ScheduledTask;
use Piwik\ReportRenderer;
-use Piwik\Plugin;
use Piwik\Site;
use Piwik\Db;
+use Piwik\Plugins\SegmentEditor\API as SegmentEditorAPI;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
+use Zend_Mime;
+use Zend_Registry;
/**
*
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
-class Piwik_PDFReports extends Plugin
+class PDFReports extends \Piwik\Plugin
{
const MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY = 'MobileMessaging_TopMenu';
const PDF_REPORTS_TOP_MENU_TRANSLATION_KEY = 'PDFReports_EmailReports';
@@ -87,7 +95,7 @@ public function getListHooksRegistered()
'template_reportParametersPDFReports' => 'template_reportParametersPDFReports',
'UsersManager.deleteUser' => 'deleteUserReport',
'SitesManager.deleteSite' => 'deleteSiteReport',
- Piwik_SegmentEditor_API::DELETE_SEGMENT_EVENT => 'segmentDeletion',
+ SegmentEditorAPI::DELETE_SEGMENT_EVENT => 'segmentDeletion',
);
}
@@ -96,11 +104,11 @@ public function getListHooksRegistered()
*/
public function deleteSiteReport(&$idSite)
{
- $idReports = Piwik_PDFReports_API::getInstance()->getReports($idSite);
+ $idReports = API::getInstance()->getReports($idSite);
foreach ($idReports as $report) {
$idReport = $report['idreport'];
- Piwik_PDFReports_API::getInstance()->deleteReport($idReport);
+ API::getInstance()->deleteReport($idReport);
}
}
@@ -154,9 +162,9 @@ static private function valueIsTrue($value)
public function getReportMetadata(&$reportMetadata, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $idSite = $notificationInfo[Piwik_PDFReports_API::ID_SITE_INFO_KEY];
+ $idSite = $notificationInfo[API::ID_SITE_INFO_KEY];
- $availableReportMetadata = Piwik_API_API::getInstance()->getReportMetadata($idSite);
+ $availableReportMetadata = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite);
$filteredReportMetadata = array();
foreach ($availableReportMetadata as $reportMetadata) {
@@ -195,7 +203,7 @@ public function getReportParameters(&$availableParameters, $info)
public function processReports(&$processedReports, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $report = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY];
+ $report = $notificationInfo[API::REPORT_KEY];
$displayFormat = $report['parameters'][self::DISPLAY_FORMAT_PARAMETER];
$evolutionGraph = $report['parameters'][self::EVOLUTION_GRAPH_PARAMETER];
@@ -222,8 +230,8 @@ public function processReports(&$processedReports, $notificationInfo)
if ($metadata['module'] == 'MultiSites') {
$columns = $processedReport['columns'];
- foreach (Piwik_MultiSites_API::getApiMetrics($enhanced = true) as $metricSettings) {
- unset($columns[$metricSettings[Piwik_MultiSites_API::METRIC_EVOLUTION_COL_NAME_KEY]]);
+ foreach (\Piwik\Plugins\MultiSites\API::getApiMetrics($enhanced = true) as $metricSettings) {
+ unset($columns[$metricSettings[\Piwik\Plugins\MultiSites\API::METRIC_EVOLUTION_COL_NAME_KEY]]);
}
$processedReport['metadata'] = $metadata;
@@ -236,13 +244,13 @@ public function processReports(&$processedReports, $notificationInfo)
public function getRendererInstance(&$reportRenderer, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $reportFormat = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY]['format'];
- $outputType = $notificationInfo[Piwik_PDFReports_API::OUTPUT_TYPE_INFO_KEY];
+ $reportFormat = $notificationInfo[API::REPORT_KEY]['format'];
+ $outputType = $notificationInfo[API::OUTPUT_TYPE_INFO_KEY];
$reportRenderer = ReportRenderer::factory($reportFormat);
if ($reportFormat == ReportRenderer::HTML_FORMAT) {
- $reportRenderer->setRenderImageInline($outputType != Piwik_PDFReports_API::OUTPUT_SAVE_ON_DISK);
+ $reportRenderer->setRenderImageInline($outputType != API::OUTPUT_SAVE_ON_DISK);
}
}
}
@@ -257,12 +265,12 @@ public function allowMultipleReports(&$allowMultipleReports, $info)
public function sendReport($notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $report = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY];
- $reportTitle = $notificationInfo[Piwik_PDFReports_API::REPORT_TITLE_KEY];
- $prettyDate = $notificationInfo[Piwik_PDFReports_API::PRETTY_DATE_KEY];
- $contents = $notificationInfo[Piwik_PDFReports_API::REPORT_CONTENT_KEY];
- $filename = $notificationInfo[Piwik_PDFReports_API::FILENAME_KEY];
- $additionalFiles = $notificationInfo[Piwik_PDFReports_API::ADDITIONAL_FILES_KEY];
+ $report = $notificationInfo[API::REPORT_KEY];
+ $reportTitle = $notificationInfo[API::REPORT_TITLE_KEY];
+ $prettyDate = $notificationInfo[API::PRETTY_DATE_KEY];
+ $contents = $notificationInfo[API::REPORT_CONTENT_KEY];
+ $filename = $notificationInfo[API::FILENAME_KEY];
+ $additionalFiles = $notificationInfo[API::ADDITIONAL_FILES_KEY];
$periods = self::getPeriodToFrequencyAsAdjective();
$message = Piwik_Translate('PDFReports_EmailHello');
@@ -279,8 +287,8 @@ public function sendReport($notificationInfo)
$displaySegmentInfo = false;
$segmentInfo = null;
- $segment = Piwik_PDFReports_API::getSegment($report['idsegment']);
- if($segment != null) {
+ $segment = API::getSegment($report['idsegment']);
+ if ($segment != null) {
$displaySegmentInfo = true;
$segmentInfo = Piwik_Translate('PDFReports_SegmentAppliedToReports', $segment['name']);
}
@@ -292,7 +300,7 @@ public function sendReport($notificationInfo)
$mail->setType(Zend_Mime::MULTIPART_RELATED);
$message .= "
" . Piwik_Translate('PDFReports_PleaseFindBelow', array($periods[$report['period']], $reportTitle));
- if($displaySegmentInfo) {
+ if ($displaySegmentInfo) {
$message .= " " . $segmentInfo;
}
@@ -303,7 +311,7 @@ public function sendReport($notificationInfo)
case 'pdf':
$message .= "\n" . Piwik_Translate('PDFReports_PleaseFindAttachedFile', array($periods[$report['period']], $reportTitle));
- if($displaySegmentInfo) {
+ if ($displaySegmentInfo) {
$message .= " " . $segmentInfo;
}
@@ -347,7 +355,7 @@ public function sendReport($notificationInfo)
$emails[] = Piwik::getSuperUserEmail();
} else {
try {
- $user = Piwik_UsersManager_API::getInstance()->getUser($report['login']);
+ $user = UsersManagerAPI::getInstance()->getUser($report['login']);
} catch (Exception $e) {
return;
}
@@ -380,7 +388,7 @@ public function sendReport($notificationInfo)
public function getReportRecipients(&$recipients, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $report = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY];
+ $report = $notificationInfo[API::REPORT_KEY];
$parameters = $report['parameters'];
$eMailMe = $parameters[self::EMAIL_ME_PARAMETER];
@@ -411,7 +419,7 @@ static public function template_reportParametersPDFReports(&$out)
private static function manageEvent($info)
{
return in_array(
- $info[Piwik_PDFReports_API::REPORT_TYPE_INFO_KEY],
+ $info[API::REPORT_TYPE_INFO_KEY],
array_keys(self::$managedReportTypes)
);
}
@@ -419,7 +427,7 @@ private static function manageEvent($info)
public function getScheduledTasks(&$tasks)
{
$arbitraryDateInUTC = Date::factory('2011-01-01');
- foreach (Piwik_PDFReports_API::getInstance()->getReports() as $report) {
+ foreach (API::getInstance()->getReports() as $report) {
if (!$report['deleted'] && $report['period'] != ScheduledTime::PERIOD_NEVER) {
$midnightInSiteTimezone =
date(
@@ -435,7 +443,7 @@ public function getScheduledTasks(&$tasks)
$schedule = ScheduledTime::getScheduledTimeForPeriod($report['period']);
$schedule->setHour($hourInUTC);
$tasks[] = new ScheduledTask (
- Piwik_PDFReports_API::getInstance(),
+ API::getInstance(),
'sendReport',
$report['idreport'], $schedule
);
@@ -445,7 +453,7 @@ public function getScheduledTasks(&$tasks)
public function segmentDeletion(&$idSegment)
{
- $reportsUsingSegment = Piwik_PDFReports_API::getInstance()->getReports(false, false, false, true, $idSegment);
+ $reportsUsingSegment = API::getInstance()->getReports(false, false, false, true, $idSegment);
if (count($reportsUsingSegment) > 0) {
@@ -486,19 +494,19 @@ function getTopMenuTranslationKey()
return self::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY;
}
- $reports = Piwik_PDFReports_API::getInstance()->getReports();
+ $reports = API::getInstance()->getReports();
$reportCount = count($reports);
// if there are no reports and the mobile account is
// not configured, display 'Email reports'
// configured, display 'Email & SMS reports'
if ($reportCount == 0)
- return Piwik_MobileMessaging_API::getInstance()->areSMSAPICredentialProvided() ?
+ return MobileMessagingAPI::getInstance()->areSMSAPICredentialProvided() ?
self::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY : self::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY;
$anyMobileReport = false;
foreach ($reports as $report) {
- if ($report['type'] == Piwik_MobileMessaging::MOBILE_TYPE) {
+ if ($report['type'] == MobileMessaging::MOBILE_TYPE) {
$anyMobileReport = true;
break;
}
@@ -600,7 +608,7 @@ static public function getPeriodToFrequencyAsAdjective()
ScheduledTime::PERIOD_DAY => Piwik_Translate('General_DailyReport'),
ScheduledTime::PERIOD_WEEK => Piwik_Translate('General_WeeklyReport'),
ScheduledTime::PERIOD_MONTH => Piwik_Translate('General_MonthlyReport'),
- ScheduledTime::PERIOD_YEAR => Piwik_Translate('General_YearlyReport'),
+ ScheduledTime::PERIOD_YEAR => Piwik_Translate('General_YearlyReport'),
ScheduledTime::PERIOD_RANGE => Piwik_Translate('General_RangeReports'),
);
}
diff --git a/plugins/PDFReports/config/tcpdf_config.php b/plugins/PDFReports/config/tcpdf_config.php
index 096171d164d..f9b2de9a6f7 100644
--- a/plugins/PDFReports/config/tcpdf_config.php
+++ b/plugins/PDFReports/config/tcpdf_config.php
@@ -6,13 +6,13 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
/**
* Override settings in libs/tcpdf_config.php
*
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
define('K_PATH_MAIN', PIWIK_INCLUDE_PATH . '/libs/tcpdf/');
diff --git a/plugins/PleineLune/PleineLune.php b/plugins/PleineLune/PleineLune.php
index b19ed3e288e..c1189727ba7 100644
--- a/plugins/PleineLune/PleineLune.php
+++ b/plugins/PleineLune/PleineLune.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PleineLune
+ * @package PleineLune
*/
+namespace Piwik\Plugins\PleineLune;
+
use Piwik\AssetManager;
-use Piwik\Plugin;
/**
*
- * @package Piwik_PleineLune
+ * @package PleineLune
*/
-class Piwik_PleineLune extends Plugin
+class PleineLune extends \Piwik\Plugin
{
public function getListHooksRegistered()
{
diff --git a/plugins/PrivacyManager/Controller.php b/plugins/PrivacyManager/Controller.php
index c11fb5d7f0e..8bf89fa4794 100644
--- a/plugins/PrivacyManager/Controller.php
+++ b/plugins/PrivacyManager/Controller.php
@@ -6,21 +6,27 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
+namespace Piwik\Plugins\PrivacyManager;
+
use Piwik\Config;
-use Piwik\Controller\Admin;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
+use Piwik\Plugins\DBStats\MySQLMetadataProvider;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
use Piwik\View;
use Piwik\TaskScheduler;
+use Piwik\Plugins\PrivacyManager\PrivacyManager;
+use Piwik\Plugins\PrivacyManager\LogDataPurger;
+use Piwik\Plugins\PrivacyManager\ReportsPurger;
/**
*
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
-class Piwik_PrivacyManager_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
const ANONYMIZE_IP_PLUGIN_NAME = "AnonymizeIP";
@@ -42,7 +48,7 @@ public function saveSettings()
case("formDeleteSettings"):
$settings = $this->getPurgeSettingsFromRequest();
- Piwik_PrivacyManager::savePurgeDataSettings($settings);
+ PrivacyManager::savePurgeDataSettings($settings);
break;
default: //do nothing
@@ -81,7 +87,7 @@ private function getPurgeSettingsFromRequest()
$settings['delete_reports_keep_range_reports'] = Common::getRequestVar("deleteReportsKeepRange", 0);
$settings['delete_reports_keep_segment_reports'] = Common::getRequestVar("deleteReportsKeepSegments", 0);
- $settings['delete_logs_max_rows_per_query'] = Piwik_PrivacyManager::DEFAULT_MAX_ROWS_PER_QUERY;
+ $settings['delete_logs_max_rows_per_query'] = PrivacyManager::DEFAULT_MAX_ROWS_PER_QUERY;
return $settings;
}
@@ -97,7 +103,7 @@ public function getDatabaseSize()
$forceEstimate = Common::getRequestVar('forceEstimate', 0);
$view->dbStats = $this->getDeleteDBSizeEstimate($getSettingsFromQuery = true, $forceEstimate);
- $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
echo $view->render();
}
@@ -124,7 +130,7 @@ public function privacySettings()
$view->canDeleteLogActions = Piwik::isLockPrivilegeGranted();
$view->dbUser = Config::getInstance()->database['username'];
}
- $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
$this->displayWarningIfConfigFileNotWritable($view);
$this->setBasicVariablesView($view);
echo $view->render();
@@ -146,14 +152,14 @@ public function executeDataPurge()
return $this->redirectToIndex('PrivacyManager', 'privacySettings');
}
- $settings = Piwik_PrivacyManager::getPurgeDataSettings();
+ $settings = PrivacyManager::getPurgeDataSettings();
if ($settings['delete_logs_enable']) {
- $logDataPurger = Piwik_PrivacyManager_LogDataPurger::make($settings);
+ $logDataPurger = LogDataPurger::make($settings);
$logDataPurger->purgeData();
}
if ($settings['delete_reports_enable']) {
- $reportsPurger = Piwik_PrivacyManager_ReportsPurger::make(
- $settings, Piwik_PrivacyManager::getAllMetricsToKeep());
+ $reportsPurger = ReportsPurger::make(
+ $settings, PrivacyManager::getAllMetricsToKeep());
$reportsPurger->purgeData(true);
}
}
@@ -164,13 +170,13 @@ protected function getDeleteDBSizeEstimate($getSettingsFromQuery = false, $force
if ($getSettingsFromQuery) {
$settings = $this->getPurgeSettingsFromRequest();
} else {
- $settings = Piwik_PrivacyManager::getPurgeDataSettings();
+ $settings = PrivacyManager::getPurgeDataSettings();
}
$doDatabaseSizeEstimate = Config::getInstance()->Deletelogs['enable_auto_database_size_estimate'];
// determine the DB size & purged DB size
- $metadataProvider = new Piwik_DBStats_MySQLMetadataProvider();
+ $metadataProvider = new MySQLMetadataProvider();
$tableStatuses = $metadataProvider->getAllTablesStatus();
$totalBytes = 0;
@@ -186,7 +192,7 @@ protected function getDeleteDBSizeEstimate($getSettingsFromQuery = false, $force
if ($doDatabaseSizeEstimate || $forceEstimate == 1) {
// maps tables whose data will be deleted with number of rows that will be deleted
// if a value is -1, it means the table will be dropped.
- $deletedDataSummary = Piwik_PrivacyManager::getPurgeEstimate($settings);
+ $deletedDataSummary = PrivacyManager::getPurgeEstimate($settings);
$totalAfterPurge = $totalBytes;
foreach ($tableStatuses as $status) {
@@ -195,7 +201,7 @@ protected function getDeleteDBSizeEstimate($getSettingsFromQuery = false, $force
$tableTotalBytes = $status['Data_length'] + $status['Index_length'];
// if dropping the table
- if ($deletedDataSummary[$tableName] === Piwik_PrivacyManager_ReportsPurger::DROP_TABLE) {
+ if ($deletedDataSummary[$tableName] === ReportsPurger::DROP_TABLE) {
$totalAfterPurge -= $tableTotalBytes;
} else // if just deleting rows
{
@@ -233,11 +239,11 @@ protected function getDeleteDataInfo()
Piwik::checkUserIsSuperUser();
$deleteDataInfos = array();
$taskScheduler = new TaskScheduler();
- $deleteDataInfos["config"] = Piwik_PrivacyManager::getPurgeDataSettings();
+ $deleteDataInfos["config"] = PrivacyManager::getPurgeDataSettings();
$deleteDataInfos["deleteTables"] =
- "
" . implode(", ", Piwik_PrivacyManager_LogDataPurger::getDeleteTableLogTables());
+ "
" . implode(", ", LogDataPurger::getDeleteTableLogTables());
- $scheduleTimetable = $taskScheduler->getScheduledTimeForMethod("Piwik_PrivacyManager", "deleteLogTables");
+ $scheduleTimetable = $taskScheduler->getScheduledTimeForMethod("PrivacyManager", "deleteLogTables");
$optionTable = Piwik_GetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS);
@@ -278,7 +284,7 @@ protected function getDeleteDataInfo()
protected function handlePluginState($state = 0)
{
- $pluginController = new Piwik_CorePluginsAdmin_Controller();
+ $pluginController = new \Piwik\Plugins\CorePluginsAdmin\Controller();
if ($state == 1 && !\Piwik\PluginsManager::getInstance()->isPluginActivated(self::ANONYMIZE_IP_PLUGIN_NAME)) {
$pluginController->activate($redirectAfter = false);
diff --git a/plugins/PrivacyManager/LogDataPurger.php b/plugins/PrivacyManager/LogDataPurger.php
index d4fa491b43c..b08216314fd 100755
--- a/plugins/PrivacyManager/LogDataPurger.php
+++ b/plugins/PrivacyManager/LogDataPurger.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
+namespace Piwik\Plugins\PrivacyManager;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
@@ -16,7 +18,7 @@
/**
* Purges the log_visit, log_conversion and related tables of old visit data.
*/
-class Piwik_PrivacyManager_LogDataPurger
+class LogDataPurger
{
const TEMP_TABLE_NAME = 'tmp_log_actions_to_keep';
@@ -312,11 +314,11 @@ public static function getDeleteTableLogTables()
*
* @param array $settings Array of settings
* @param bool $useRealTable
- * @return Piwik_PrivacyManager_LogDataPurger
+ * @return \Piwik\Plugins\PrivacyManager\LogDataPurger
*/
public static function make($settings, $useRealTable = false)
{
- return new Piwik_PrivacyManager_LogDataPurger(
+ return new LogDataPurger(
$settings['delete_logs_older_than'],
$settings['delete_logs_max_rows_per_query']
);
diff --git a/plugins/PrivacyManager/PrivacyManager.php b/plugins/PrivacyManager/PrivacyManager.php
index 517b410bfeb..2208156584f 100644
--- a/plugins/PrivacyManager/PrivacyManager.php
+++ b/plugins/PrivacyManager/PrivacyManager.php
@@ -6,18 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
+namespace Piwik\Plugins\PrivacyManager;
+
+use Exception;
use Piwik\Config;
use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
+use Piwik\Plugins\Goals\Archiver;
+use Piwik\Plugins\PrivacyManager\LogDataPurger;
use Piwik\ScheduledTask;
-use Piwik\Plugin;
use Piwik\Db;
use Piwik\ScheduledTime\Daily;
use Piwik\Tracker\GoalManager;
+use Piwik\Plugins\PrivacyManager\ReportsPurger;
/**
* @see plugins/PrivacyManager/LogDataPurger.php
@@ -31,9 +36,9 @@
/**
*
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
-class Piwik_PrivacyManager extends Plugin
+class PrivacyManager extends \Piwik\Plugin
{
const OPTION_LAST_DELETE_PIWIK_LOGS = "lastDelete_piwik_logs";
const OPTION_LAST_DELETE_PIWIK_REPORTS = 'lastDelete_piwik_reports';
@@ -197,7 +202,7 @@ public function deleteReportData()
// set last run time
Piwik_SetOption(self::OPTION_LAST_DELETE_PIWIK_REPORTS, Date::factory('today')->getTimestamp());
- Piwik_PrivacyManager_ReportsPurger::make($settings, self::getAllMetricsToKeep())->purgeData();
+ ReportsPurger::make($settings, self::getAllMetricsToKeep())->purgeData();
}
/**
@@ -236,7 +241,7 @@ public function deleteLogData()
Piwik_SetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDeleteDate);
// execute the purge
- Piwik_PrivacyManager_LogDataPurger::make($settings)->purgeData();
+ LogDataPurger::make($settings)->purgeData();
}
/**
@@ -259,12 +264,12 @@ public static function getPurgeEstimate($settings = null)
$result = array();
if ($settings['delete_logs_enable']) {
- $logDataPurger = Piwik_PrivacyManager_LogDataPurger::make($settings);
+ $logDataPurger = LogDataPurger::make($settings);
$result = array_merge($result, $logDataPurger->getPurgeEstimate());
}
if ($settings['delete_reports_enable']) {
- $reportsPurger = Piwik_PrivacyManager_ReportsPurger::make($settings, self::getAllMetricsToKeep());
+ $reportsPurger = ReportsPurger::make($settings, self::getAllMetricsToKeep());
$result = array_merge($result, $reportsPurger->getPurgeEstimate());
}
@@ -303,7 +308,7 @@ public static function shouldReportBePurged($reportDateYear, $reportDateMonth, $
$reportsOlderThan = Date::factory('today')->subMonth(1 + $reportsOlderThan);
}
- return Piwik_PrivacyManager_ReportsPurger::shouldReportBePurged(
+ return ReportsPurger::shouldReportBePurged(
$reportDateYear, $reportDateMonth, $reportsOlderThan);
}
@@ -347,12 +352,12 @@ public static function getAllMetricsToKeep()
foreach ($goalMetricsToKeep as $metric) {
for ($i = 1; $i <= $maxGoalId; ++$i) // maxGoalId can be 0
{
- $metricsToKeep[] = Piwik_Goals_Archiver::getRecordName($metric, $i);
+ $metricsToKeep[] = Archiver::getRecordName($metric, $i);
}
- $metricsToKeep[] = Piwik_Goals_Archiver::getRecordName($metric);
- $metricsToKeep[] = Piwik_Goals_Archiver::getRecordName($metric, GoalManager::IDGOAL_ORDER);
- $metricsToKeep[] = Piwik_Goals_Archiver::getRecordName($metric, GoalManager::IDGOAL_CART);
+ $metricsToKeep[] = Archiver::getRecordName($metric);
+ $metricsToKeep[] = Archiver::getRecordName($metric, GoalManager::IDGOAL_ORDER);
+ $metricsToKeep[] = Archiver::getRecordName($metric, GoalManager::IDGOAL_CART);
}
}
diff --git a/plugins/PrivacyManager/ReportsPurger.php b/plugins/PrivacyManager/ReportsPurger.php
index af527b6142f..6b81139830a 100755
--- a/plugins/PrivacyManager/ReportsPurger.php
+++ b/plugins/PrivacyManager/ReportsPurger.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
+namespace Piwik\Plugins\PrivacyManager;
+
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Piwik;
use Piwik\Date;
@@ -16,7 +18,7 @@
/**
* Purges archived reports and metrics that are considered old.
*/
-class Piwik_PrivacyManager_ReportsPurger
+class ReportsPurger
{
// constant used in database purging estimate to signify a table should be dropped
const DROP_TABLE = -1;
@@ -213,7 +215,7 @@ private function getArchiveTablesToPurge()
$oldBlobTables = array();
foreach (Piwik::getTablesInstalled() as $table) {
$type = ArchiveTableCreator::getTypeFromTableName($table);
- if($type === false) {
+ if ($type === false) {
continue;
}
$date = ArchiveTableCreator::getDateFromTableName($table);
@@ -347,7 +349,7 @@ private function findSegmentArchives($numericTables)
*/
public static function make($settings, $metricsToKeep)
{
- return new Piwik_PrivacyManager_ReportsPurger(
+ return new ReportsPurger(
$settings['delete_reports_older_than'],
$settings['delete_reports_keep_basic_metrics'] == 1,
self::getReportPeriodsToKeep($settings),
diff --git a/plugins/Provider/API.php b/plugins/Provider/API.php
index 63565b5301e..88eb4b473be 100644
--- a/plugins/Provider/API.php
+++ b/plugins/Provider/API.php
@@ -6,11 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Provider
+ * @package Provider
*/
+namespace Piwik\Plugins\Provider;
+
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
+use Piwik\Plugins\Provider\Archiver;
/**
* @see plugins/Provider/functions.php
@@ -20,9 +23,9 @@
/**
* The Provider API lets you access reports for your visitors Internet Providers.
*
- * @package Piwik_Provider
+ * @package Provider
*/
-class Piwik_Provider_API
+class API
{
static private $instance = null;
@@ -38,10 +41,10 @@ public function getProvider($idSite, $period, $date, $segment = false)
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Archive::build($idSite, $period, $date, $segment);
- $dataTable = $archive->getDataTable(Piwik_Provider_Archiver::PROVIDER_RECORD_NAME);
+ $dataTable = $archive->getDataTable(Archiver::PROVIDER_RECORD_NAME);
$dataTable->filter('Sort', array(Metrics::INDEX_NB_VISITS));
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_getHostnameUrl'));
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_Provider_getPrettyProviderName'));
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\getHostnameUrl'));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getPrettyProviderName'));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
diff --git a/plugins/Provider/Archiver.php b/plugins/Provider/Archiver.php
index bd9a4fa456a..a449a9f4e80 100644
--- a/plugins/Provider/Archiver.php
+++ b/plugins/Provider/Archiver.php
@@ -6,12 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Provider
+ * @package Provider
*/
+namespace Piwik\Plugins\Provider;
+
use Piwik\Metrics;
use Piwik\PluginsArchiver;
-class Piwik_Provider_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const PROVIDER_RECORD_NAME = 'Provider_hostnameExt';
const PROVIDER_FIELD = "location_provider";
diff --git a/plugins/Provider/Controller.php b/plugins/Provider/Controller.php
index c51d7ccf4a4..6d79bd3d1a7 100644
--- a/plugins/Provider/Controller.php
+++ b/plugins/Provider/Controller.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Provider
+ * @package Provider
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\Provider;
+
use Piwik\ViewDataTable;
/**
*
- * @package Piwik_Provider
+ * @package Provider
*/
-class Piwik_Provider_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
* Provider
diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php
index f20e823b952..f2562e9485b 100644
--- a/plugins/Provider/Provider.php
+++ b/plugins/Provider/Provider.php
@@ -6,21 +6,25 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Provider
+ * @package Provider
*/
+namespace Piwik\Plugins\Provider;
+
+use Exception;
use Piwik\Common;
use Piwik\FrontController;
use Piwik\IP;
-use Piwik\Plugin;
use Piwik\ArchiveProcessor;
use Piwik\Db;
+use Piwik\Plugins\Provider\Archiver;
use Piwik\WidgetsList;
+use Zend_Registry;
/**
*
- * @package Piwik_Provider
+ * @package Provider
*/
-class Piwik_Provider extends Plugin
+class Provider extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -28,13 +32,13 @@ class Piwik_Provider extends Plugin
public function getListHooksRegistered()
{
$hooks = array(
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'Tracker.newVisitorInformation' => 'logProviderInfo',
- 'WidgetsList.add' => 'addWidget',
- 'Menu.add' => 'addMenu',
- 'API.getReportMetadata' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'Tracker.newVisitorInformation' => 'logProviderInfo',
+ 'WidgetsList.add' => 'addWidget',
+ 'Menu.add' => 'addMenu',
+ 'API.getReportMetadata' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
return $hooks;
@@ -78,7 +82,6 @@ public function install()
throw $e;
}
}
-
}
public function uninstall()
@@ -101,7 +104,7 @@ public function addMenu()
public function postLoad()
{
- Piwik_AddAction('template_footerUserCountry', array('Piwik_Provider', 'footerUserCountry'));
+ Piwik_AddAction('template_footerUserCountry', array('Piwik\Plugins\Provider\Provider', 'footerUserCountry'));
}
/**
@@ -201,16 +204,16 @@ static public function footerUserCountry(&$out)
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_Provider_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_Provider_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
diff --git a/plugins/Provider/functions.php b/plugins/Provider/functions.php
index 540060db4b1..51a85e15d19 100644
--- a/plugins/Provider/functions.php
+++ b/plugins/Provider/functions.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Provider
+ * @package Provider
*/
+namespace Piwik\Plugins\Provider;
+
use Piwik\Common;
use Piwik\DataTable;
@@ -17,7 +19,7 @@
* @param string $in
* @return string Host name, IP (if IP address didn't resolve), or Unknown
*/
-function Piwik_getHostnameName($in)
+function getHostnameName($in)
{
if (empty($in)) {
return Piwik_Translate('General_Unknown');
@@ -37,7 +39,7 @@ function Piwik_getHostnameName($in)
* @param string $in hostname
* @return string URL
*/
-function Piwik_getHostnameUrl($in)
+function getHostnameUrl($in)
{
if ($in == DataTable::LABEL_SUMMARY_ROW) {
return false;
@@ -63,9 +65,9 @@ function Piwik_getHostnameUrl($in)
* @param string $in hostname
* @return string Real ISP name, IP (if IP address didn't resolve), or Unknown
*/
-function Piwik_Provider_getPrettyProviderName( $in )
+function getPrettyProviderName( $in )
{
- $providerName = Piwik_getHostnameName($in);
+ $providerName = getHostnameName($in);
$prettyNames = Common::getProviderNames();
diff --git a/plugins/Proxy/Controller.php b/plugins/Proxy/Controller.php
index cf1b362c7bb..d358908805f 100644
--- a/plugins/Proxy/Controller.php
+++ b/plugins/Proxy/Controller.php
@@ -6,20 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Proxy
+ * @package Proxy
*/
+namespace Piwik\Plugins\Proxy;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\AssetManager;
-use Piwik\Controller;
use Piwik\Url;
/**
* Controller for proxy services
*
- * @package Piwik_Proxy
+ * @package Proxy
*/
-class Piwik_Proxy_Controller extends Controller
+class Controller extends \Piwik\Controller
{
const TRANSPARENT_PNG_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=';
diff --git a/plugins/Proxy/Proxy.php b/plugins/Proxy/Proxy.php
index 47d085a70c4..7c7959d0e19 100644
--- a/plugins/Proxy/Proxy.php
+++ b/plugins/Proxy/Proxy.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Proxy
+ * @package Proxy
*/
+namespace Piwik\Plugins\Proxy;
+
use Piwik\Version;
-use Piwik\Plugin;
/**
* Proxy services for the UI
*
- * @package Piwik_Proxy
+ * @package Proxy
*/
-class Piwik_Proxy extends Plugin
+class Proxy extends \Piwik\Plugin
{
/**
* Return information about this plugin.
diff --git a/plugins/Referers/API.php b/plugins/Referers/API.php
index b7a16365bd3..fb0cb618474 100644
--- a/plugins/Referers/API.php
+++ b/plugins/Referers/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Referers
+ * @package Referers
*/
+namespace Piwik\Plugins\Referers;
+
+use Exception;
use Piwik\API\ResponseBuilder;
use Piwik\Archive;
use Piwik\DataTable\Row;
@@ -16,6 +19,7 @@
use Piwik\Common;
use Piwik\Date;
use Piwik\DataTable;
+use Piwik\Plugins\Referers\Archiver;
/**
* The Referrers API lets you access reports about Websites, Search engines, Keywords, Campaigns used to access your website.
@@ -25,9 +29,9 @@
*
* The methods "getKeywordsForPageUrl" and "getKeywordsForPageTitle" are used to output the top keywords used to find a page.
* Check out the widget "Top keywords used to find this page" that you can easily re-use on your website.
- * @package Piwik_Referers
+ * @package Referers
*/
-class Piwik_Referers_API
+class API
{
static private $instance = null;
@@ -78,7 +82,7 @@ protected function getDataTable($name, $idSite, $period, $date, $segment, $expan
* @return DataTable
*/
public function getRefererType($idSite, $period, $date, $segment = false, $typeReferer = false,
- $idSubtable = false, $expanded = false)
+ $idSubtable = false, $expanded = false)
{
// if idSubtable is supplied, interpret idSubtable as referrer type and return correct report
if ($idSubtable !== false) {
@@ -103,7 +107,7 @@ public function getRefererType($idSite, $period, $date, $segment = false, $type
}
// get visits by referrer type
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::REFERER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::REFERER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
if ($typeReferer !== false) // filter for a specific referrer type
{
@@ -117,7 +121,7 @@ public function getRefererType($idSite, $period, $date, $segment = false, $type
}
// set referrer type column to readable value
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getRefererTypeLabel'));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getRefererTypeLabel'));
return $dataTable;
}
@@ -144,14 +148,14 @@ public function getAll($idSite, $period, $date, $segment = false)
public function getKeywords($idSite, $period, $date, $segment = false, $expanded = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::KEYWORDS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
+ $dataTable = $this->getDataTable(Archiver::KEYWORDS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
$dataTable = $this->handleKeywordNotDefined($dataTable);
return $dataTable;
}
protected function handleKeywordNotDefined($dataTable)
{
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', array('Piwik_Referers_API', 'getCleanKeyword')));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\API::getCleanKeyword'));
return $dataTable;
}
@@ -182,7 +186,6 @@ public function getKeywordsForPageUrl($idSite, $period, $date, $url)
$table = $this->getKeywords($idSite, $period, $date, $segment);
$this->filterOutKeywordNotDefined($table);
return $this->getLabelsFromTable($table);
-
}
public function getKeywordsForPageTitle($idSite, $period, $date, $title)
@@ -227,31 +230,31 @@ protected function getLabelsFromTable($table)
public function getSearchEnginesFromKeywordId($idSite, $period, $date, $idSubtable, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::KEYWORDS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_getSearchEngineUrlFromName'));
- $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', 'Piwik_getSearchEngineLogoFromUrl'));
+ $dataTable = $this->getDataTable(Archiver::KEYWORDS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\getSearchEngineUrlFromName'));
+ $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', __NAMESPACE__ . '\getSearchEngineLogoFromUrl'));
// get the keyword and create the URL to the search result page
$keywords = $this->getKeywords($idSite, $period, $date, $segment);
$subTable = $keywords->getRowFromIdSubDataTable($idSubtable);
if ($subTable) {
$keyword = $subTable->getColumn('label');
- $dataTable->queueFilter('MetadataCallbackReplace', array('url', 'Piwik_getSearchEngineUrlFromUrlAndKeyword', array($keyword)));
+ $dataTable->queueFilter('MetadataCallbackReplace', array('url', __NAMESPACE__ . '\getSearchEngineUrlFromUrlAndKeyword', array($keyword)));
}
return $dataTable;
}
public function getSearchEngines($idSite, $period, $date, $segment = false, $expanded = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::SEARCH_ENGINES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_getSearchEngineUrlFromName'));
- $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', 'Piwik_getSearchEngineLogoFromUrl'));
+ $dataTable = $this->getDataTable(Archiver::SEARCH_ENGINES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\getSearchEngineUrlFromName'));
+ $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', __NAMESPACE__ . '\getSearchEngineLogoFromUrl'));
return $dataTable;
}
public function getKeywordsFromSearchEngineId($idSite, $period, $date, $idSubtable, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::SEARCH_ENGINES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
+ $dataTable = $this->getDataTable(Archiver::SEARCH_ENGINES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
// get the search engine and create the URL to the search result page
$searchEngines = $this->getSearchEngines($idSite, $period, $date, $segment);
@@ -274,7 +277,7 @@ public function getKeywordsFromSearchEngineId($idSite, $period, $date, $idSubtab
if (!empty($subTableRow)) {
$searchEngineUrl = $subTableRow->getMetadata('url');
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_getSearchEngineUrlFromKeywordAndUrl', array($searchEngineUrl)));
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\getSearchEngineUrlFromKeywordAndUrl', array($searchEngineUrl)));
}
$dataTable = $this->handleKeywordNotDefined($dataTable);
return $dataTable;
@@ -282,29 +285,29 @@ public function getKeywordsFromSearchEngineId($idSite, $period, $date, $idSubtab
public function getCampaigns($idSite, $period, $date, $segment = false, $expanded = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::CAMPAIGNS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
+ $dataTable = $this->getDataTable(Archiver::CAMPAIGNS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
return $dataTable;
}
public function getKeywordsFromCampaignId($idSite, $period, $date, $idSubtable, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::CAMPAIGNS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
+ $dataTable = $this->getDataTable(Archiver::CAMPAIGNS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
return $dataTable;
}
public function getWebsites($idSite, $period, $date, $segment = false, $expanded = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
+ $dataTable = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
return $dataTable;
}
public function getUrlsFromWebsiteId($idSite, $period, $date, $idSubtable, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
+ $dataTable = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
// the htmlspecialchars_decode call is for BC for before 1.1
// as the Referrer URL was previously encoded in the log tables, but is now recorded raw
$dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', create_function('$label', 'return htmlspecialchars_decode($label);')));
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getPathFromUrl'));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getPathFromUrl'));
return $dataTable;
}
@@ -323,17 +326,17 @@ public function getSocials($idSite, $period, $date, $segment = false, $expanded
{
require PIWIK_INCLUDE_PATH . '/core/DataFiles/Socials.php';
- $dataTable = $this->getDataTable( Piwik_Referers_Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
+ $dataTable = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
- $dataTable->filter('ColumnCallbackDeleteRow', array('label', 'Piwik_Referrers_isSocialUrl'));
+ $dataTable->filter('ColumnCallbackDeleteRow', array('label', __NAMESPACE__ . '\isSocialUrl'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_Referrers_cleanSocialUrl'));
- $dataTable->filter('GroupBy', array('label', 'Piwik_Referrers_getSocialNetworkFromDomain'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\cleanSocialUrl'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getSocialNetworkFromDomain'));
$this->setSocialIdSubtables($dataTable);
$this->removeSubtableMetadata($dataTable);
- $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', 'Piwik_getSocialsLogoFromUrl'));
+ $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', __NAMESPACE__ . '\getSocialsLogoFromUrl'));
return $dataTable;
}
@@ -356,7 +359,7 @@ public function getUrlsForSocial($idSite, $period, $date, $segment = false, $idS
{
require PIWIK_INCLUDE_PATH . '/core/DataFiles/Socials.php';
- $dataTable = $this->getDataTable( Piwik_Referers_Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = true);
+ $dataTable = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = true);
// get the social network domain referred to by $idSubtable
$social = false;
@@ -372,7 +375,7 @@ public function getUrlsForSocial($idSite, $period, $date, $segment = false, $idS
}
// filter out everything but social network indicated by $idSubtable
- $dataTable->filter('ColumnCallbackDeleteRow', array('label', 'Piwik_Referrers_isSocialUrl', array($social)));
+ $dataTable->filter('ColumnCallbackDeleteRow', array('label', __NAMESPACE__ . '\isSocialUrl', array($social)));
// merge the datatable's subtables which contain the individual URLs
$dataTable = $dataTable->mergeSubtables();
@@ -381,7 +384,7 @@ public function getUrlsForSocial($idSite, $period, $date, $segment = false, $idS
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'url'));
// prettify the DataTable
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_Referrers_removeUrlProtocol'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\removeUrlProtocol'));
$dataTable->filter('Sort', array(Metrics::INDEX_NB_VISITS, 'desc', $naturalSort = false, $expanded));
$dataTable->queueFilter('ReplaceColumnNames');
@@ -390,27 +393,27 @@ public function getUrlsForSocial($idSite, $period, $date, $segment = false, $idS
public function getNumberOfDistinctSearchEngines($idSite, $period, $date, $segment = false)
{
- return $this->getNumeric(Piwik_Referers_Archiver::METRIC_DISTINCT_SEARCH_ENGINE_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getNumeric(Archiver::METRIC_DISTINCT_SEARCH_ENGINE_RECORD_NAME, $idSite, $period, $date, $segment);
}
public function getNumberOfDistinctKeywords($idSite, $period, $date, $segment = false)
{
- return $this->getNumeric(Piwik_Referers_Archiver::METRIC_DISTINCT_KEYWORD_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getNumeric(Archiver::METRIC_DISTINCT_KEYWORD_RECORD_NAME, $idSite, $period, $date, $segment);
}
public function getNumberOfDistinctCampaigns($idSite, $period, $date, $segment = false)
{
- return $this->getNumeric(Piwik_Referers_Archiver::METRIC_DISTINCT_CAMPAIGN_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getNumeric(Archiver::METRIC_DISTINCT_CAMPAIGN_RECORD_NAME, $idSite, $period, $date, $segment);
}
public function getNumberOfDistinctWebsites($idSite, $period, $date, $segment = false)
{
- return $this->getNumeric(Piwik_Referers_Archiver::METRIC_DISTINCT_WEBSITE_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getNumeric(Archiver::METRIC_DISTINCT_WEBSITE_RECORD_NAME, $idSite, $period, $date, $segment);
}
public function getNumberOfDistinctWebsitesUrls($idSite, $period, $date, $segment = false)
{
- return $this->getNumeric(Piwik_Referers_Archiver::METRIC_DISTINCT_URLS_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getNumeric(Archiver::METRIC_DISTINCT_URLS_RECORD_NAME, $idSite, $period, $date, $segment);
}
private function getNumeric($name, $idSite, $period, $date, $segment)
diff --git a/plugins/Referers/Archiver.php b/plugins/Referers/Archiver.php
index 4da6a19d074..5c7d700eea1 100644
--- a/plugins/Referers/Archiver.php
+++ b/plugins/Referers/Archiver.php
@@ -1,10 +1,4 @@
getDataArray(self::SEARCH_ENGINES_RECORD_NAME);
$searchEnginesArray->sumMetricsVisits($row['referer_name'], $row);
@@ -161,7 +165,7 @@ protected function aggregateConversion($row)
switch ($row['referer_type']) {
case Common::REFERER_TYPE_SEARCH_ENGINE:
if (empty($row['referer_keyword'])) {
- $row['referer_keyword'] = Piwik_Referers_API::LABEL_KEYWORD_NOT_DEFINED;
+ $row['referer_keyword'] = API::LABEL_KEYWORD_NOT_DEFINED;
}
$this->getDataArray(self::SEARCH_ENGINES_RECORD_NAME)->sumMetricsGoals($row['referer_name'], $row);
diff --git a/plugins/Referers/Controller.php b/plugins/Referers/Controller.php
index c9362f4a017..672e6c475f2 100644
--- a/plugins/Referers/Controller.php
+++ b/plugins/Referers/Controller.php
@@ -6,23 +6,24 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Referers
+ * @package Referers
*/
+namespace Piwik\Plugins\Referers;
+
use Piwik\API\Request;
use Piwik\Metrics;
use Piwik\Period\Range;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\ViewDataTable;
use Piwik\View;
use Piwik\Url;
/**
*
- * @package Piwik_Referers
+ * @package Referers
*/
-class Piwik_Referers_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
@@ -305,7 +306,7 @@ public function getEvolutionGraph($fetch = false, $typeReferer = false, array $c
$view->documentation = Piwik_Translate('Referers_EvolutionDocumentation') . '
'
. Piwik_Translate('General_BrokenDownReportDocumentation') . '
'
. Piwik_Translate('Referers_EvolutionDocumentationMoreInfo', '"'
- . Piwik_Translate('Referers_DetailsByRefererType') . '"');
+ . Piwik_Translate('Referers_DetailsByRefererType') . '"');
return $this->renderView($view, $fetch);
}
@@ -414,7 +415,7 @@ function DisplayTopKeywords($url = "")
Example API URL - For example if you would like to get the top 10 keywords, used last week, to land on the page $topPageUrl,
in format JSON: you would dynamically fetch the data using this API request URL. Make sure you encode the 'url' parameter in the URL.
-
+
PHP Function ready to use! - If you use PHP on your website, we have prepared a small code snippet that you can copy paste in your Website PHP files. You can then simply call the function DisplayTopKeywords();
anywhere in your template, at the bottom of the content or in your blog sidebar.
If you run this code in your page $topPageUrl, it would output the following:";
@@ -458,7 +459,6 @@ function DisplayTopKeywords($url = "", $api)
On medium to large traffic websites, we recommend to cache this data, as to minimize the performance impact of calling the Piwik API on each page view.
";
-
}
/**
@@ -469,7 +469,7 @@ function DisplayTopKeywords($url = "", $api)
*/
public static function getTranslatedReferrerTypeLabel($typeReferrer)
{
- $label = Piwik_getRefererTypeLabel($typeReferrer);
+ $label = getRefererTypeLabel($typeReferrer);
return Piwik_Translate($label);
}
diff --git a/plugins/Referers/Referers.php b/plugins/Referers/Referers.php
index 4f72e81d932..1b1efdc7c41 100644
--- a/plugins/Referers/Referers.php
+++ b/plugins/Referers/Referers.php
@@ -6,12 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Referers
+ * @package Referers
*/
+namespace Piwik\Plugins\Referers;
+
use Piwik\ArchiveProcessor;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Plugin;
+use Piwik\Plugins\Referers\Archiver;
use Piwik\WidgetsList;
/**
@@ -20,9 +22,9 @@
require_once PIWIK_INCLUDE_PATH . '/plugins/Referers/functions.php';
/**
- * @package Piwik_Referers
+ * @package Referers
*/
-class Piwik_Referers extends Plugin
+class Referers extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -30,13 +32,13 @@ class Piwik_Referers extends Plugin
public function getListHooksRegistered()
{
$hooks = array(
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenus',
- 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
- 'API.getReportMetadata' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenus',
+ 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
+ 'API.getReportMetadata' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
return $hooks;
@@ -178,7 +180,7 @@ public function getSegmentsMetadata(&$segments)
'segment' => 'referrerType',
'acceptedValues' => 'direct, search, website, campaign',
'sqlSegment' => 'log_visit.referer_type',
- 'sqlFilter' => 'Piwik_getRefererTypeFromShortName',
+ 'sqlFilter' => __NAMESPACE__ . '\getRefererTypeFromShortName',
);
$segments[] = array(
'type' => 'dimension',
@@ -274,7 +276,7 @@ public function getReportsWithGoalMetrics(&$dimensions)
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_Referers_Archiver($archiveProcessor);
+ $archiving = new Archiver($archiveProcessor);
if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
@@ -286,8 +288,8 @@ public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
*/
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_Referers_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
@@ -327,15 +329,15 @@ private function getDisplayPropertiesForGetRefererType()
}
return array(
- 'default_view_type' => 'tableAllColumns',
- 'show_search' => false,
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'show_exclude_low_population' => false,
+ 'default_view_type' => 'tableAllColumns',
+ 'show_search' => false,
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'show_exclude_low_population' => false,
'disable_subtable_when_show_goals' => true,
- 'show_goals' => true,
- 'filter_limit' => 10,
- 'translations' => array('label' => $labelColumnTitle)
+ 'show_goals' => true,
+ 'filter_limit' => 10,
+ 'translations' => array('label' => $labelColumnTitle)
);
}
@@ -344,11 +346,11 @@ private function getDisplayPropertiesForGetAll()
$setGetAllHtmlPrefix = array($this, 'setGetAllHtmlPrefix');
return array(
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('Referers_Referrer')),
- 'show_goals' => true,
- 'filter_limit' => 20,
- 'custom_parameters' => array('disable_row_actions' => '1'),
- 'filters' => array(
+ 'translations' => array('label' => Piwik_Translate('Referers_Referrer')),
+ 'show_goals' => true,
+ 'filter_limit' => 20,
+ 'custom_parameters' => array('disable_row_actions' => '1'),
+ 'filters' => array(
array('MetadataCallbackAddMetadata', array('referrer_type', 'html_label_prefix', $setGetAllHtmlPrefix))
)
);
@@ -357,11 +359,11 @@ private function getDisplayPropertiesForGetAll()
private function getDisplayPropertiesForGetKeywords()
{
return array(
- 'subtable_controller_action' => 'getSearchEnginesFromKeywordId',
- 'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnKeyword')),
- 'show_goals' => true,
- 'filter_limit' => 25,
+ 'subtable_controller_action' => 'getSearchEnginesFromKeywordId',
+ 'show_exclude_low_population' => false,
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnKeyword')),
+ 'show_goals' => true,
+ 'filter_limit' => 25,
'disable_subtable_when_show_goals' => true,
);
}
@@ -369,56 +371,56 @@ private function getDisplayPropertiesForGetKeywords()
private function getDisplayPropertiesForGetSearchEnginesFromKeywordId()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnSearchEngine'))
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnSearchEngine'))
);
}
private function getDisplayPropertiesForGetSearchEngines()
{
return array(
- 'subtable_controller_action' => 'getKeywordsFromSearchEngineId',
- 'show_search' => false,
- 'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'filter_limit' => 25,
+ 'subtable_controller_action' => 'getKeywordsFromSearchEngineId',
+ 'show_search' => false,
+ 'show_exclude_low_population' => false,
+ 'show_goals' => true,
+ 'filter_limit' => 25,
'disable_subtable_when_show_goals' => true,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnSearchEngine'))
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnSearchEngine'))
);
}
private function getDisplayPropertiesForGetKeywordsFromSearchEngineId()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnKeyword'))
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnKeyword'))
);
}
private function getDisplayPropertiesForGetWebsites()
{
return array(
- 'subtable_controller_action' => 'getUrlsFromWebsiteId',
- 'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'filter_limit' => 25,
+ 'subtable_controller_action' => 'getUrlsFromWebsiteId',
+ 'show_exclude_low_population' => false,
+ 'show_goals' => true,
+ 'filter_limit' => 25,
'disable_subtable_when_show_goals' => true,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnWebsite'))
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnWebsite'))
);
}
private function getDisplayPropertiesForGetSocials()
{
$result = array(
- 'default_view_type' => 'graphPie',
- 'subtable_controller_action' => 'getUrlsForSocial',
- 'show_exclude_low_population' => false,
- 'filter_limit' => 10,
- 'show_goals' => true,
+ 'default_view_type' => 'graphPie',
+ 'subtable_controller_action' => 'getUrlsForSocial',
+ 'show_exclude_low_population' => false,
+ 'filter_limit' => 10,
+ 'show_goals' => true,
'disable_subtable_when_show_goals' => true,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnSocial'))
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnSocial'))
);
$widget = Common::getRequestVar('widget', false);
@@ -433,20 +435,20 @@ private function getDisplayPropertiesForGetUrlsForSocial()
{
return array(
'show_exclude_low_population' => false,
- 'filter_limit' => 10,
- 'show_goals' => true,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnWebsitePage'))
+ 'filter_limit' => 10,
+ 'show_goals' => true,
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnWebsitePage'))
);
}
private function getDisplayPropertiesForGetCampaigns()
{
$result = array(
- 'subtable_controller_action' => 'getKeywordsFromCampaignId',
+ 'subtable_controller_action' => 'getKeywordsFromCampaignId',
'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'filter_limit' => 25,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnCampaign')),
+ 'show_goals' => true,
+ 'filter_limit' => 25,
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnCampaign')),
);
if (Common::getRequestVar('viewDataTable', false) != 'graphEvolution') {
@@ -463,19 +465,19 @@ private function getDisplayPropertiesForGetCampaigns()
private function getDisplayPropertiesForGetKeywordsFromCampaignId()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnKeyword'))
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnKeyword'))
);
}
private function getDisplayPropertiesForGetUrlsFromWebsiteId()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnWebsitePage')),
- 'tooltip_metadata_name' => 'url'
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnWebsitePage')),
+ 'tooltip_metadata_name' => 'url'
);
}
diff --git a/plugins/Referers/functions.php b/plugins/Referers/functions.php
index b7038fb3600..0a6a50a72c7 100644
--- a/plugins/Referers/functions.php
+++ b/plugins/Referers/functions.php
@@ -6,9 +6,12 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Referers
+ * @package Referers
*/
+namespace Piwik\Plugins\Referers;
+
use Piwik\Common;
+use Piwik\Plugins\Referers\API;
/**
* Returns path component from a URL
@@ -16,7 +19,7 @@
* @param string $url
* @return string path
*/
-function Piwik_getPathFromUrl($url)
+function getPathFromUrl($url)
{
$path = Common::getPathAndQueryFromUrl($url);
if (empty($path)) {
@@ -31,7 +34,7 @@ function Piwik_getPathFromUrl($url)
* @param string $url e.g. http://www.facebook.com/?sdlfk=lksdfj
* @return string|false e.g. facebook.com
*/
-function Piwik_Referrers_cleanSocialUrl($url)
+function cleanSocialUrl($url)
{
$segment = '[^.:\/]+';
preg_match('/(?:https?:\/\/)?(?:' . $segment . '\.)?(' . $segment . '(?:\.' . $segment . ')+)/', $url, $matches);
@@ -44,9 +47,9 @@ function Piwik_Referrers_cleanSocialUrl($url)
* @param string $url
* @return string
*/
-function Piwik_Referrers_getSocialNetworkFromDomain($url)
+function getSocialNetworkFromDomain($url)
{
- $domain = Piwik_Referrers_cleanSocialUrl($url);
+ $domain = cleanSocialUrl($url);
if (isset($GLOBALS['Piwik_socialUrl'][$domain])) {
return $GLOBALS['Piwik_socialUrl'][$domain];
@@ -63,9 +66,9 @@ function Piwik_Referrers_getSocialNetworkFromDomain($url)
* for any.
* @return bool
*/
-function Piwik_Referrers_isSocialUrl($url, $socialName = false)
+function isSocialUrl($url, $socialName = false)
{
- $domain = Piwik_Referrers_cleanSocialUrl($url);
+ $domain = cleanSocialUrl($url);
if (isset($GLOBALS['Piwik_socialUrl'][$domain])
&& ($socialName === false
@@ -83,9 +86,9 @@ function Piwik_Referrers_isSocialUrl($url, $socialName = false)
* @return string path
* @see plugins/Referers/images/socials/
*/
-function Piwik_getSocialsLogoFromUrl($domain)
+function getSocialsLogoFromUrl($domain)
{
- $domain = Piwik_Referrers_cleanSocialUrl($domain);
+ $domain = cleanSocialUrl($domain);
if (isset($GLOBALS['Piwik_socialUrl'][$domain])) {
// image names are by first domain in list, so make sure we use the first if $domain isn't it
@@ -112,7 +115,7 @@ function Piwik_getSocialsLogoFromUrl($domain)
* @param string $name
* @return string URL
*/
-function Piwik_getSearchEngineUrlFromName($name)
+function getSearchEngineUrlFromName($name)
{
$searchEngineNames = Common::getSearchEngineNames();
if (isset($searchEngineNames[$name])) {
@@ -129,7 +132,7 @@ function Piwik_getSearchEngineUrlFromName($name)
* @param string $url
* @return string host
*/
-function Piwik_getSearchEngineHostFromUrl($url)
+function getSearchEngineHostFromUrl($url)
{
$url = substr($url, strpos($url, '//') + 2);
if (($p = strpos($url, '/')) !== false) {
@@ -145,10 +148,10 @@ function Piwik_getSearchEngineHostFromUrl($url)
* @return string path
* @see plugins/Referers/images/searchEnginges/
*/
-function Piwik_getSearchEngineLogoFromUrl($url)
+function getSearchEngineLogoFromUrl($url)
{
$pathInPiwik = 'plugins/Referers/images/searchEngines/%s.png';
- $pathWithCode = sprintf($pathInPiwik, Piwik_getSearchEngineHostFromUrl($url));
+ $pathWithCode = sprintf($pathInPiwik, getSearchEngineHostFromUrl($url));
$absolutePath = PIWIK_INCLUDE_PATH . '/' . $pathWithCode;
if (file_exists($absolutePath)) {
return $pathWithCode;
@@ -162,7 +165,7 @@ function Piwik_getSearchEngineLogoFromUrl($url)
* @param string $url
* @return string host
*/
-function Piwik_getSearchEngineHostPathFromUrl($url)
+function getSearchEngineHostPathFromUrl($url)
{
$url = substr($url, strpos($url, '//') + 2);
return $url;
@@ -177,15 +180,15 @@ function Piwik_getSearchEngineHostPathFromUrl($url)
* @param string $keyword Keyword, e.g., web+analytics
* @return string URL, e.g., http://search.piwik.org/q=web+analytics
*/
-function Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword)
+function getSearchEngineUrlFromUrlAndKeyword($url, $keyword)
{
- if ($keyword === Piwik_Referers_API::LABEL_KEYWORD_NOT_DEFINED) {
+ if ($keyword === API::LABEL_KEYWORD_NOT_DEFINED) {
return 'http://piwik.org/faq/general/#faq_144';
}
$searchEngineUrls = Common::getSearchEngineUrls();
$keyword = urlencode($keyword);
$keyword = str_replace(urlencode('+'), urlencode(' '), $keyword);
- $path = @$searchEngineUrls[Piwik_getSearchEngineHostPathFromUrl($url)][2];
+ $path = @$searchEngineUrls[getSearchEngineHostPathFromUrl($url)][2];
if (empty($path)) {
return false;
}
@@ -196,15 +199,15 @@ function Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword)
/**
* Return search engine URL for keyword and URL
*
- * @see Piwik_getSearchEngineUrlFromUrlAndKeyword()
+ * @see Piwik_getSearchEngineUrlFromUrlAndKeyword(getSearchEngineUrlFromUrlAndKeyword
*
* @param string $keyword Keyword, e.g., web+analytics
* @param string $url Domain name, e.g., search.piwik.org
* @return string URL, e.g., http://search.piwik.org/q=web+analytics
*/
-function Piwik_getSearchEngineUrlFromKeywordAndUrl($keyword, $url)
+function getSearchEngineUrlFromKeywordAndUrl($keyword, $url)
{
- return Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword);
+ return getSearchEngineUrlFromUrlAndKeyword($url, $keyword);
}
/**
@@ -213,7 +216,7 @@ function Piwik_getSearchEngineUrlFromKeywordAndUrl($keyword, $url)
* @param string $label
* @return string Referrer type
*/
-function Piwik_getRefererTypeLabel($label)
+function getRefererTypeLabel($label)
{
$indexTranslation = '';
switch ($label) {
@@ -243,7 +246,7 @@ function Piwik_getRefererTypeLabel($label)
* @throws Exception
* @return string
*/
-function Piwik_getRefererTypeFromShortName($name)
+function getRefererTypeFromShortName($name)
{
$map = array(
Common::REFERER_TYPE_SEARCH_ENGINE => 'search',
@@ -257,7 +260,7 @@ function Piwik_getRefererTypeFromShortName($name)
if ($found = array_search($name, $map)) {
return $found;
}
- throw new Exception("Referrer type '$name' is not valid.");
+ throw new \Exception("Referrer type '$name' is not valid.");
}
/**
@@ -266,7 +269,7 @@ function Piwik_getRefererTypeFromShortName($name)
* @param string $url
* @return string
*/
-function Piwik_Referrers_removeUrlProtocol($url)
+function removeUrlProtocol($url)
{
if (preg_match('/^[a-zA-Z_-]+:\/\//', $url, $matches)) {
return substr($url, strlen($matches[0]));
diff --git a/plugins/SEO/API.php b/plugins/SEO/API.php
index 185561df444..74dd10ac564 100644
--- a/plugins/SEO/API.php
+++ b/plugins/SEO/API.php
@@ -6,10 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SEO
+ * @package SEO
*/
+namespace Piwik\Plugins\SEO;
+
use Piwik\Piwik;
use Piwik\DataTable;
+use Piwik\Plugins\SEO\MajesticClient;
+use Piwik\Plugins\SEO\RankChecker;
/**
* @see plugins/Referers/functions.php
@@ -20,14 +24,14 @@
* The SEO API lets you access a list of SEO metrics for the specified URL: Google Pagerank, Goolge/Bing indexed pages
* Alexa Rank, age of the Domain name and count of DMOZ entries.
*
- * @package Piwik_SEO
+ * @package SEO
*/
-class Piwik_SEO_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_SEO_API
+ * @return \Piwik\Plugins\SEO\API
*/
static public function getInstance()
{
@@ -46,29 +50,29 @@ static public function getInstance()
public function getRank($url)
{
Piwik::checkUserHasSomeViewAccess();
- $rank = new Piwik_SEO_RankChecker($url);
+ $rank = new RankChecker($url);
- $linkToMajestic = Piwik_SEO_MajesticClient::getLinkForUrl($url);
+ $linkToMajestic = MajesticClient::getLinkForUrl($url);
$data = array(
'Google PageRank' => array(
'rank' => $rank->getPageRank(),
- 'logo' => Piwik_getSearchEngineLogoFromUrl('http://google.com'),
+ 'logo' => \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl('http://google.com'),
'id' => 'pagerank'
),
Piwik_Translate('SEO_Google_IndexedPages') => array(
'rank' => $rank->getIndexedPagesGoogle(),
- 'logo' => Piwik_getSearchEngineLogoFromUrl('http://google.com'),
+ 'logo' => \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl('http://google.com'),
'id' => 'google-index',
),
Piwik_Translate('SEO_Bing_IndexedPages') => array(
'rank' => $rank->getIndexedPagesBing(),
- 'logo' => Piwik_getSearchEngineLogoFromUrl('http://bing.com'),
+ 'logo' => \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl('http://bing.com'),
'id' => 'bing-index',
),
Piwik_Translate('SEO_AlexaRank') => array(
'rank' => $rank->getAlexaRank(),
- 'logo' => Piwik_getSearchEngineLogoFromUrl('http://alexa.com'),
+ 'logo' => \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl('http://alexa.com'),
'id' => 'alexa',
),
Piwik_Translate('SEO_DomainAge') => array(
@@ -95,7 +99,7 @@ public function getRank($url)
// Add DMOZ only if > 0 entries found
$dmozRank = array(
'rank' => $rank->getDmoz(),
- 'logo' => Piwik_getSearchEngineLogoFromUrl('http://dmoz.org'),
+ 'logo' => \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl('http://dmoz.org'),
'id' => 'dmoz',
);
if ($dmozRank['rank'] > 0) {
diff --git a/plugins/SEO/Controller.php b/plugins/SEO/Controller.php
index 207d92a179d..f71ec0c738b 100644
--- a/plugins/SEO/Controller.php
+++ b/plugins/SEO/Controller.php
@@ -6,18 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SEO
+ * @package SEO
*/
+namespace Piwik\Plugins\SEO;
+
use Piwik\Common;
use Piwik\DataTable\Renderer;
-use Piwik\Controller;
+use Piwik\Plugins\SEO\API;
use Piwik\View;
use Piwik\Site;
+use Piwik\Plugins\SEO\RankChecker;
/**
- * @package Piwik_SEO
+ * @package SEO
*/
-class Piwik_SEO_Controller extends Controller
+class Controller extends \Piwik\Controller
{
function getRank()
{
@@ -34,10 +37,10 @@ function getRank()
$url = $site->getMainUrl();
}
- $dataTable = Piwik_SEO_API::getInstance()->getRank($url);
+ $dataTable = API::getInstance()->getRank($url);
$view = new View('@SEO/getRank');
- $view->urlToRank = Piwik_SEO_RankChecker::extractDomainFromUrl($url);
+ $view->urlToRank = RankChecker::extractDomainFromUrl($url);
$renderer = Renderer::factory('php');
$renderer->setSerialize(false);
diff --git a/plugins/SEO/MajesticClient.php b/plugins/SEO/MajesticClient.php
index 34f16a038e4..1f890091211 100644
--- a/plugins/SEO/MajesticClient.php
+++ b/plugins/SEO/MajesticClient.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SEO
+ * @package SEO
*/
+namespace Piwik\Plugins\SEO;
+
use Piwik\Common;
use Piwik\Http;
@@ -16,7 +18,7 @@
*
* Hides the HTTP request sending logic.
*/
-class Piwik_SEO_MajesticClient
+class MajesticClient
{
const API_BASE = 'http://simpleapi.majesticseo.com/sapi/';
const API_KEY = 'ETHPYY'; // please only use this key within Piwik
diff --git a/plugins/SEO/RankChecker.php b/plugins/SEO/RankChecker.php
index cdc858176c6..74d8afda3b9 100644
--- a/plugins/SEO/RankChecker.php
+++ b/plugins/SEO/RankChecker.php
@@ -6,10 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SEO
+ * @package SEO
*/
+namespace Piwik\Plugins\SEO;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Http;
+use Piwik\Plugins\SEO\MajesticClient;
/**
* The functions below are derived/adapted from GetRank.org's
@@ -18,9 +22,9 @@
* @copyright Copyright (C) 2007 - 2010 GetRank.Org All rights reserved.
* @link http://www.getrank.org/free-pagerank-script/
* @license GPL
- * @package Piwik_SEO
+ * @package SEO
*/
-class Piwik_SEO_RankChecker
+class RankChecker
{
private $url;
private $majesticInfo = null;
@@ -185,7 +189,7 @@ public function getExternalBacklinkCount()
try {
$majesticInfo = $this->getMajesticInfo();
return $majesticInfo['backlink_count'];
- } catch(Exception $e) {
+ } catch (Exception $e) {
Piwik::log($e->getMessage());
return 0;
}
@@ -201,7 +205,7 @@ public function getReferrerDomainCount()
try {
$majesticInfo = $this->getMajesticInfo();
return $majesticInfo['referrer_domains_count'];
- } catch(Exception $e) {
+ } catch (Exception $e) {
Piwik::log($e->getMessage());
return 0;
}
@@ -366,7 +370,7 @@ private function CheckHash($Hashnum)
private function getMajesticInfo()
{
if ($this->majesticInfo === null) {
- $client = new Piwik_SEO_MajesticClient();
+ $client = new MajesticClient();
$this->majesticInfo = $client->getBacklinkStats($this->url);
}
diff --git a/plugins/SEO/SEO.php b/plugins/SEO/SEO.php
index 505f8de521f..dd488bef974 100644
--- a/plugins/SEO/SEO.php
+++ b/plugins/SEO/SEO.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SEO
+ * @package SEO
*/
+namespace Piwik\Plugins\SEO;
+
use Piwik\Version;
-use Piwik\Plugin;
use Piwik\WidgetsList;
/**
- * @package Piwik_SEO
+ * @package SEO
*/
-class Piwik_SEO extends Plugin
+class SEO extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getInformation
diff --git a/plugins/SecurityInfo/Controller.php b/plugins/SecurityInfo/Controller.php
index 7195185fdd7..fd7c29c981b 100644
--- a/plugins/SecurityInfo/Controller.php
+++ b/plugins/SecurityInfo/Controller.php
@@ -6,16 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SecurityInfo
+ * @package SecurityInfo
*/
-use Piwik\Controller\Admin;
+namespace Piwik\Plugins\SecurityInfo;
+
+use PhpSecInfo;
use Piwik\Piwik;
use Piwik\View;
/**
- * @package Piwik_SecurityInfo
+ * @package SecurityInfo
*/
-class Piwik_SecurityInfo_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
function index()
{
diff --git a/plugins/SecurityInfo/SecurityInfo.php b/plugins/SecurityInfo/SecurityInfo.php
index 785247d2a26..4d5bacf07d2 100644
--- a/plugins/SecurityInfo/SecurityInfo.php
+++ b/plugins/SecurityInfo/SecurityInfo.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SecurityInfo
+ * @package SecurityInfo
*/
+namespace Piwik\Plugins\SecurityInfo;
+
use Piwik\Piwik;
-use Piwik\Plugin;
/**
*
- * @package Piwik_SecurityInfo
+ * @package SecurityInfo
*/
-class Piwik_SecurityInfo extends Plugin
+class SecurityInfo extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/SegmentEditor/API.php b/plugins/SegmentEditor/API.php
index c8bb844a093..1dbc8b08112 100644
--- a/plugins/SegmentEditor/API.php
+++ b/plugins/SegmentEditor/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
+namespace Piwik\Plugins\SegmentEditor;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
@@ -16,16 +19,16 @@
/**
* The SegmentEditor API lets you add, update, delete custom Segments, and list saved segments.a
*
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
-class Piwik_SegmentEditor_API
+class API
{
const DELETE_SEGMENT_EVENT = 'SegmentEditor.delete';
static private $instance = null;
/**
- * @return Piwik_SegmentEditor_API
+ * @return \Piwik\Plugins\SegmentEditor\API
*/
static public function getInstance()
{
@@ -116,7 +119,7 @@ protected function getSegmentOrFail($idSegment)
protected function checkUserIsNotAnonymous()
{
- if(Piwik::isUserIsAnonymous()) {
+ if (Piwik::isUserIsAnonymous()) {
throw new Exception("To create, edit or delete Custom Segments, please sign in first.");
}
}
@@ -229,8 +232,8 @@ public function get($idSegment)
throw new Exception("idSegment should be numeric.");
}
$segment = \Zend_Registry::get('db')->fetchRow("SELECT * " .
- " FROM " . Common::prefixTable("segment") .
- " WHERE idsegment = ?", $idSegment);
+ " FROM " . Common::prefixTable("segment") .
+ " WHERE idsegment = ?", $idSegment);
if (empty($segment)) {
return false;
@@ -257,7 +260,7 @@ public function get($idSegment)
*/
public function getAll($idSite = false, $returnOnlyAutoArchived = false)
{
- if(!empty($idSite) ) {
+ if (!empty($idSite)) {
Piwik::checkUserHasViewAccess($idSite);
} else {
Piwik::checkUserHasSomeViewAccess();
@@ -266,7 +269,7 @@ public function getAll($idSite = false, $returnOnlyAutoArchived = false)
// Build basic segment filtering
$whereIdSite = '';
- if(!empty($idSite)) {
+ if (!empty($idSite)) {
$whereIdSite = 'enable_only_idsite = ? OR ';
$bind[] = $idSite;
}
@@ -274,14 +277,14 @@ public function getAll($idSite = false, $returnOnlyAutoArchived = false)
$bind[] = Piwik::getCurrentUserLogin();
$extraWhere = '';
- if($returnOnlyAutoArchived) {
+ if ($returnOnlyAutoArchived) {
$extraWhere = ' AND auto_archive = 1';
}
// Query
$sql = "SELECT * " .
- " FROM " . Common::prefixTable("segment") .
- " WHERE ($whereIdSite enable_only_idsite = 0)
+ " FROM " . Common::prefixTable("segment") .
+ " WHERE ($whereIdSite enable_only_idsite = 0)
AND (enable_all_users = 1 OR login = ?)
AND deleted = 0
$extraWhere
diff --git a/plugins/SegmentEditor/Controller.php b/plugins/SegmentEditor/Controller.php
index 4083369eceb..55b406cf53b 100644
--- a/plugins/SegmentEditor/Controller.php
+++ b/plugins/SegmentEditor/Controller.php
@@ -6,17 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
+namespace Piwik\Plugins\SegmentEditor;
+
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\SegmentEditor\API;
use Piwik\View;
+use Piwik\Plugins\API\API as MetaAPI;
/**
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
-class Piwik_SegmentEditor_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function getSelector()
@@ -24,12 +27,13 @@ public function getSelector()
$view = new View('@SegmentEditor/getSelector');
$idSite = Common::getRequestVar('idSite');
$this->setGeneralVariablesView($view);
- $segments = Piwik_API_API::getInstance()->getSegmentsMetadata($idSite);
+ $segments = MetaAPI::getInstance()->getSegmentsMetadata($idSite);
$segmentsByCategory = $customVariablesSegments = array();
- foreach($segments as $segment) {
- if($segment['category'] == Piwik_Translate('General_Visit')
- && $segment['type'] == 'metric') {
+ foreach ($segments as $segment) {
+ if ($segment['category'] == Piwik_Translate('General_Visit')
+ && $segment['type'] == 'metric'
+ ) {
$metricsLabel = Piwik_Translate('General_Metrics');
$metricsLabel[0] = strtolower($metricsLabel[0]);
$segment['category'] .= ' (' . $metricsLabel . ')';
@@ -40,8 +44,8 @@ public function getSelector()
$view->segmentsByCategory = $segmentsByCategory;
- $savedSegments = Piwik_SegmentEditor_API::getInstance()->getAll($idSite);
- foreach($savedSegments as &$savedSegment) {
+ $savedSegments = API::getInstance()->getAll($idSite);
+ foreach ($savedSegments as &$savedSegment) {
$savedSegment['name'] = Common::sanitizeInputValue($savedSegment['name']);
}
$view->savedSegmentsJson = Common::json_encode($savedSegments);
@@ -55,7 +59,7 @@ public function getSelector()
public function sortSegmentCategories($a, $b)
{
// Custom Variables last
- if($a == Piwik_Translate('CustomVariables_CustomVariables')) {
+ if ($a == Piwik_Translate('CustomVariables_CustomVariables')) {
return 1;
}
return 0;
@@ -86,7 +90,7 @@ private function getTranslations()
'',
'',
);
- foreach($translationKeys as $key) {
+ foreach ($translationKeys as $key) {
$translations[$key] = Piwik_Translate($key);
}
return $translations;
diff --git a/plugins/SegmentEditor/SegmentEditor.php b/plugins/SegmentEditor/SegmentEditor.php
index 5d1731c0063..cc0146df900 100644
--- a/plugins/SegmentEditor/SegmentEditor.php
+++ b/plugins/SegmentEditor/SegmentEditor.php
@@ -6,17 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
+namespace Piwik\Plugins\SegmentEditor;
+
+use Exception;
use Piwik\Common;
+use Piwik\Plugins\SegmentEditor\API;
+use Piwik\Plugins\SegmentEditor\Controller;
use Piwik\Version;
-use Piwik\Plugin;
use Piwik\Db;
+use Zend_Registry;
/**
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
-class Piwik_SegmentEditor extends Plugin
+class SegmentEditor extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getInformation
@@ -47,13 +52,13 @@ public function getListHooksRegistered()
function getSegmentEditorHtml(&$out)
{
- $controller = new Piwik_SegmentEditor_Controller();
+ $controller = new Controller();
$out .= $controller->getSelector();
}
public function getKnownSegmentsToArchiveAllSites(&$segments)
{
- $segmentsToAutoArchive = Piwik_SegmentEditor_API::getInstance()->getAll($idSite = false, $returnAutoArchived = true);
+ $segmentsToAutoArchive = API::getInstance()->getAll($idSite = false, $returnAutoArchived = true);
foreach ($segmentsToAutoArchive as $segment) {
$segments[] = $segment['definition'];
}
@@ -61,7 +66,7 @@ public function getKnownSegmentsToArchiveAllSites(&$segments)
public function getKnownSegmentsToArchiveForSite(&$segments, $idSite)
{
- $segmentToAutoArchive = Piwik_SegmentEditor_API::getInstance()->getAll($idSite, $returnAutoArchived = true);
+ $segmentToAutoArchive = API::getInstance()->getAll($idSite, $returnAutoArchived = true);
foreach ($segmentToAutoArchive as $segmentInfo) {
$segments[] = $segmentInfo['definition'];
diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php
index 18f22d82787..5ca33828269 100644
--- a/plugins/SitesManager/API.php
+++ b/plugins/SitesManager/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
+namespace Piwik\Plugins\SitesManager;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Access;
@@ -18,6 +21,7 @@
use Piwik\Url;
use Piwik\TaskScheduler;
use Piwik\Site;
+use false;
/**
* The SitesManager API gives you full control on Websites in Piwik (create, update and delete), and many methods to retrieve websites based on various attributes.
@@ -33,15 +37,15 @@
* "setGlobalExcludedQueryParameters" will set the list of URL parameters to remove from URLs for all websites.
* The existing values can be fetched via "getExcludedIpsGlobal" and "getExcludedQueryParametersGlobal".
* See also the documentation about Managing Websites in Piwik.
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
-class Piwik_SitesManager_API
+class API
{
static private $instance = null;
const DEFAULT_SEARCH_KEYWORD_PARAMETERS = 'q,query,s,search,searchword,k,keyword';
/**
- * @return Piwik_SitesManager_API
+ * @return \Piwik\Plugins\SitesManager\API
*/
static public function getInstance()
{
@@ -209,8 +213,8 @@ public function getAllSitesId()
{
Piwik::checkUserIsSuperUser();
try {
- return Piwik_SitesManager_API::getInstance()->getSitesId();
- } catch(Exception $e) {
+ return API::getInstance()->getSitesId();
+ } catch (Exception $e) {
// can be called before Piwik tables are created so return empty
return array();
}
@@ -236,7 +240,7 @@ public function getSitesIdWithVisits($timestamp = false)
FROM
" . Common::prefixTable('site') . " s
WHERE EXISTS (
- SELECT 1
+ SELECT 1
FROM " . Common::prefixTable('log_visit') . " v
WHERE v.idsite = s.idsite
AND visit_last_action_time > ?
@@ -250,7 +254,6 @@ public function getSitesIdWithVisits($timestamp = false)
return $idSites;
}
-
/**
* Returns the list of websites with the 'admin' access for the current user.
* For the superUser it returns all the websites in the database.
@@ -344,7 +347,7 @@ public function getSitesIdWithAtLeastViewAccess($_restrictSitesToLogin = false)
* The user access is not checked in this method so the ID have to be accessible by the user!
*
* @param array $idSites list of website ID
- * @param bool $limit
+ * @param bool $limit
* @return array
*/
private function getSitesFromIds($idSites, $limit = false)
@@ -566,7 +569,7 @@ public function deleteSite($idSite)
{
Piwik::checkUserIsSuperUser();
- $idSites = Piwik_SitesManager_API::getInstance()->getSitesId();
+ $idSites = API::getInstance()->getSitesId();
if (!in_array($idSite, $idSites)) {
throw new Exception("website id = $idSite not found");
}
@@ -592,7 +595,6 @@ public function deleteSite($idSite)
Piwik_PostEvent('SitesManager.deleteSite', array($idSite));
}
-
/**
* Checks that the array has at least one element
*
@@ -659,7 +661,7 @@ private function checkAndReturnExcludedIps($excludedIps)
* If some URLs given in parameter are already recorded as alias URLs for this website,
* they won't be duplicated. The 'main_url' of the website won't be affected by this method.
*
- * @param int $idSite
+ * @param int $idSite
* @param array|string $urls
* @return int the number of inserted URLs
*/
@@ -985,7 +987,7 @@ public function updateSite($idSite,
{
Piwik::checkUserHasAdminAccess($idSite);
- $idSites = Piwik_SitesManager_API::getInstance()->getSitesId();
+ $idSites = API::getInstance()->getSitesId();
if (!in_array($idSite, $idSites)) {
throw new Exception("website id = $idSite not found");
}
@@ -1187,9 +1189,9 @@ private function insertSiteUrls($idSite, $urls)
$db = \Zend_Registry::get('db');
foreach ($urls as $url) {
$db->insert(Common::prefixTable("site_url"), array(
- 'idsite' => $idSite,
- 'url' => $url
- )
+ 'idsite' => $idSite,
+ 'url' => $url
+ )
);
}
}
@@ -1258,7 +1260,6 @@ private function checkName($siteName)
}
}
-
private function checkSiteSearch($siteSearch)
{
if ($siteSearch === null) {
@@ -1348,10 +1349,10 @@ public function getPatternMatchSites($pattern)
}
$sites = $db->fetchAll("SELECT idsite, name, main_url
FROM " . Common::prefixTable('site') . " s
- WHERE ( s.name like ?
+ WHERE ( s.name like ?
OR s.main_url like ?
- $where )
- AND idsite in ($ids_str)
+ $where )
+ AND idsite in ($ids_str)
LIMIT " . Piwik::getWebsitesCountToDisplay(),
$bind);
return $sites;
diff --git a/plugins/SitesManager/Controller.php b/plugins/SitesManager/Controller.php
index 3a8f339693e..7a031522567 100644
--- a/plugins/SitesManager/Controller.php
+++ b/plugins/SitesManager/Controller.php
@@ -6,24 +6,27 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
+namespace Piwik\Plugins\SitesManager;
+
+use Exception;
use Piwik\API\ResponseBuilder;
-use Piwik\Controller\Admin;
use Piwik\DataTable\Renderer\Json;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
use Piwik\IP;
+use Piwik\Plugins\SitesManager\API;
use Piwik\View;
use Piwik\Url;
use Piwik\Site;
/**
*
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
-class Piwik_SitesManager_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
/**
* Main view showing listing of websites and settings
@@ -33,16 +36,16 @@ public function index()
$view = new View('@SitesManager/index');
if (Piwik::isUserIsSuperUser()) {
- $sites = Piwik_SitesManager_API::getInstance()->getAllSites();
+ $sites = API::getInstance()->getAllSites();
Site::setSites($sites);
$sites = array_values($sites);
} else {
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
+ $sites = API::getInstance()->getSitesWithAdminAccess();
Site::setSitesFromArray($sites);
}
foreach ($sites as &$site) {
- $site['alias_urls'] = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($site['idsite']);
+ $site['alias_urls'] = API::getInstance()->getSiteUrlsFromId($site['idsite']);
$site['excluded_ips'] = explode(',', $site['excluded_ips']);
$site['excluded_parameters'] = explode(',', $site['excluded_parameters']);
$site['excluded_user_agents'] = explode(',', $site['excluded_user_agents']);
@@ -50,30 +53,30 @@ public function index()
$view->adminSites = $sites;
$view->adminSitesCount = count($sites);
- $timezones = Piwik_SitesManager_API::getInstance()->getTimezonesList();
+ $timezones = API::getInstance()->getTimezonesList();
$view->timezoneSupported = Piwik::isTimezoneSupportEnabled();
$view->timezones = Common::json_encode($timezones);
- $view->defaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
+ $view->defaultTimezone = API::getInstance()->getDefaultTimezone();
- $view->currencies = Common::json_encode(Piwik_SitesManager_API::getInstance()->getCurrencyList());
- $view->defaultCurrency = Piwik_SitesManager_API::getInstance()->getDefaultCurrency();
+ $view->currencies = Common::json_encode(API::getInstance()->getCurrencyList());
+ $view->defaultCurrency = API::getInstance()->getDefaultCurrency();
$view->utcTime = Date::now()->getDatetime();
- $excludedIpsGlobal = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
+ $excludedIpsGlobal = API::getInstance()->getExcludedIpsGlobal();
$view->globalExcludedIps = str_replace(',', "\n", $excludedIpsGlobal);
- $excludedQueryParametersGlobal = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
+ $excludedQueryParametersGlobal = API::getInstance()->getExcludedQueryParametersGlobal();
$view->globalExcludedQueryParameters = str_replace(',', "\n", $excludedQueryParametersGlobal);
- $globalExcludedUserAgents = Piwik_SitesManager_API::getInstance()->getExcludedUserAgentsGlobal();
+ $globalExcludedUserAgents = API::getInstance()->getExcludedUserAgentsGlobal();
$view->globalExcludedUserAgents = str_replace(',', "\n", $globalExcludedUserAgents);
- $view->globalSearchKeywordParameters = Piwik_SitesManager_API::getInstance()->getSearchKeywordParametersGlobal();
- $view->globalSearchCategoryParameters = Piwik_SitesManager_API::getInstance()->getSearchCategoryParametersGlobal();
+ $view->globalSearchKeywordParameters = API::getInstance()->getSearchKeywordParametersGlobal();
+ $view->globalSearchCategoryParameters = API::getInstance()->getSearchCategoryParametersGlobal();
$view->isSearchCategoryTrackingEnabled = \Piwik\PluginsManager::getInstance()->isPluginActivated('CustomVariables');
$view->allowSiteSpecificUserAgentExclude =
- Piwik_SitesManager_API::getInstance()->isSiteSpecificUserAgentExcludeEnabled();
+ API::getInstance()->isSiteSpecificUserAgentExcludeEnabled();
- $view->globalKeepURLFragments = Piwik_SitesManager_API::getInstance()->getKeepURLFragmentsGlobal();
+ $view->globalKeepURLFragments = API::getInstance()->getKeepURLFragmentsGlobal();
$view->currentIpAddress = IP::getIpFromHeader();
@@ -102,7 +105,7 @@ public function setGlobalSettings()
$enableSiteUserAgentExclude = Common::getRequestVar('enableSiteUserAgentExclude', $default = 0);
$keepURLFragments = Common::getRequestVar('keepURLFragments', $default = 0);
- $api = Piwik_SitesManager_API::getInstance();
+ $api = API::getInstance();
$api->setDefaultTimezone($timezone);
$api->setDefaultCurrency($currency);
$api->setGlobalExcludedQueryParameters($excludedQueryParameters);
@@ -170,7 +173,7 @@ function displayAlternativeTagsHelp()
function getSitesForAutocompleter()
{
$pattern = Common::getRequestVar('term');
- $sites = Piwik_SitesManager_API::getInstance()->getPatternMatchSites($pattern);
+ $sites = API::getInstance()->getPatternMatchSites($pattern);
$pattern = str_replace('%', '', $pattern);
if (!count($sites)) {
$results[] = array('label' => Piwik_Translate('SitesManager_NotFound') . " $pattern.", 'id' => '#');
diff --git a/plugins/SitesManager/SitesManager.php b/plugins/SitesManager/SitesManager.php
index 7b21bbafd1b..cdc3a92f2be 100644
--- a/plugins/SitesManager/SitesManager.php
+++ b/plugins/SitesManager/SitesManager.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
+namespace Piwik\Plugins\SitesManager;
+
use Piwik\Piwik;
-use Piwik\Plugin;
/**
*
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
-class Piwik_SitesManager extends Plugin
+class SitesManager extends \Piwik\Plugin
{
const KEEP_URL_FRAGMENT_USE_DEFAULT = 0;
const KEEP_URL_FRAGMENT_YES = 1;
@@ -64,17 +65,17 @@ public function getJsFiles(&$jsFiles)
* Will record in the tracker config file all data needed for this website in Tracker.
*
* @param array $array
- * @param int $idSite
+ * @param int $idSite
* @return void
*/
public function recordWebsiteDataInCache(&$array, $idSite)
{
$idSite = (int)$idSite;
-
+
// add the 'hosts' entry in the website array
$array['hosts'] = $this->getTrackerHosts($idSite);
- $website = Piwik_SitesManager_API::getInstance()->getSiteFromId($idSite);
+ $website = API::getInstance()->getSiteFromId($idSite);
$array['excluded_ips'] = $this->getTrackerExcludedIps($website);
$array['excluded_parameters'] = self::getTrackerExcludedQueryParameters($website);
$array['excluded_user_agents'] = self::getExcludedUserAgents($website);
@@ -98,14 +99,14 @@ private static function shouldKeepURLFragmentsFor($site)
return false;
}
- return Piwik_SitesManager_API::getInstance()->getKeepURLFragmentsGlobal();
+ return API::getInstance()->getKeepURLFragmentsGlobal();
}
private function getTrackerSearchKeywordParameters($website)
{
$searchParameters = $website['sitesearch_keyword_parameters'];
if (empty($searchParameters)) {
- $searchParameters = Piwik_SitesManager_API::getInstance()->getSearchKeywordParametersGlobal();
+ $searchParameters = API::getInstance()->getSearchKeywordParametersGlobal();
}
return explode(",", $searchParameters);
}
@@ -114,7 +115,7 @@ private function getTrackerSearchCategoryParameters($website)
{
$searchParameters = $website['sitesearch_category_parameters'];
if (empty($searchParameters)) {
- $searchParameters = Piwik_SitesManager_API::getInstance()->getSearchCategoryParametersGlobal();
+ $searchParameters = API::getInstance()->getSearchCategoryParametersGlobal();
}
return explode(",", $searchParameters);
}
@@ -128,13 +129,13 @@ private function getTrackerSearchCategoryParameters($website)
private function getTrackerExcludedIps($website)
{
$excludedIps = $website['excluded_ips'];
- $globalExcludedIps = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
+ $globalExcludedIps = API::getInstance()->getExcludedIpsGlobal();
$excludedIps .= ',' . $globalExcludedIps;
$ipRanges = array();
foreach (explode(',', $excludedIps) as $ip) {
- $ipRange = Piwik_SitesManager_API::getInstance()->getIpsForRange($ip);
+ $ipRange = API::getInstance()->getIpsForRange($ip);
if ($ipRange !== false) {
$ipRanges[] = $ipRange;
}
@@ -151,8 +152,8 @@ private function getTrackerExcludedIps($website)
*/
private static function getExcludedUserAgents($website)
{
- $excludedUserAgents = Piwik_SitesManager_API::getInstance()->getExcludedUserAgentsGlobal();
- if (Piwik_SitesManager_API::getInstance()->isSiteSpecificUserAgentExcludeEnabled()) {
+ $excludedUserAgents = API::getInstance()->getExcludedUserAgentsGlobal();
+ if (API::getInstance()->isSiteSpecificUserAgentExcludeEnabled()) {
$excludedUserAgents .= ',' . $website['excluded_user_agents'];
}
return self::filterBlankFromCommaSepList($excludedUserAgents);
@@ -167,7 +168,7 @@ private static function getExcludedUserAgents($website)
public static function getTrackerExcludedQueryParameters($website)
{
$excludedQueryParameters = $website['excluded_parameters'];
- $globalExcludedQueryParameters = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
+ $globalExcludedQueryParameters = API::getInstance()->getExcludedQueryParametersGlobal();
$excludedQueryParameters .= ',' . $globalExcludedQueryParameters;
return self::filterBlankFromCommaSepList($excludedQueryParameters);
@@ -195,7 +196,7 @@ static private function filterBlankFromCommaSepList($parameters)
*/
private function getTrackerHosts($idSite)
{
- $urls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idSite);
+ $urls = API::getInstance()->getSiteUrlsFromId($idSite);
$hosts = array();
foreach ($urls as $url) {
$url = parse_url($url);
diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php
index 947e946a22e..131fb92aa30 100644
--- a/plugins/Transitions/API.php
+++ b/plugins/Transitions/API.php
@@ -6,9 +6,12 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Transitions
+ * @package Transitions
*/
+namespace Piwik\Plugins\Transitions;
+
+use Exception;
use Piwik\ArchiveProcessor;
use Piwik\DataAccess\LogAggregator;
use Piwik\DataTable\Manager;
@@ -20,16 +23,19 @@
use Piwik\Common;
use Piwik\DataTable;
use Piwik\DataArray;
+use Piwik\Plugins\Actions\Actions;
+use Piwik\Plugins\Actions\ArchivingHelper;
use Piwik\RankingQuery;
use Piwik\Segment;
use Piwik\SegmentExpression;
use Piwik\Site;
use Piwik\Tracker\Action;
+use Piwik\Plugins\Transitions\Controller;
/**
- * @package Piwik_Transitions
+ * @package Transitions
*/
-class Piwik_Transitions_API
+class API
{
static private $instance = null;
@@ -139,7 +145,7 @@ public function getTransitionsForAction($actionName, $actionType, $idSite, $peri
*/
private function deriveIdAction($actionName, $actionType)
{
- $actionsPlugin = new Piwik_Actions;
+ $actionsPlugin = new Actions;
switch ($actionType) {
case 'url':
$originalActionName = $actionName;
@@ -158,7 +164,7 @@ private function deriveIdAction($actionName, $actionType)
$id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_name', SegmentExpression::MATCH_EQUAL, 'pageTitle');
if ($id < 0) {
- $unknown = Piwik_Actions_ArchivingHelper::getUnknownActionName(
+ $unknown = ArchivingHelper::getUnknownActionName(
Action::TYPE_ACTION_NAME);
if (trim($actionName) == trim($unknown)) {
@@ -221,14 +227,12 @@ private function addFollowingActions($logAggregator, &$report, $idaction, $actio
}
}
-
-
/**
* Get information about the following actions (following pages, site searches, outlinks, downloads)
*
* @param $idaction
* @param $actionType
- * @param LogAggregator $logAggregator
+ * @param LogAggregator $logAggregator
* @param $limitBeforeGrouping
* @param $includeLoops
* @return array(followingPages:DataTable, outlinks:DataTable, downloads:DataTable)
@@ -311,11 +315,11 @@ public function queryFollowingActions($idaction, $actionType, LogAggregator $log
foreach ($data[$type] as &$record) {
$actions = intval($record[Metrics::INDEX_NB_ACTIONS]);
$dataTable->addRow(new Row(array(
- Row::COLUMNS => array(
- 'label' => $this->getPageLabel($record, $isTitle),
- Metrics::INDEX_NB_ACTIONS => $actions
- )
- )));
+ Row::COLUMNS => array(
+ 'label' => $this->getPageLabel($record, $isTitle),
+ Metrics::INDEX_NB_ACTIONS => $actions
+ )
+ )));
$this->totalTransitionsToFollowingActions += $actions;
}
}
@@ -325,7 +329,6 @@ public function queryFollowingActions($idaction, $actionType, LogAggregator $log
return $dataTables;
}
-
/**
* After calling this method, the query*()-Methods will return urls in their
* normalized form (without the prefix reconstructed)
@@ -389,7 +392,7 @@ public function queryExternalReferrers($idaction, $actionType, $logAggregator, $
foreach ($subData as &$row) {
if ($referrerType == Common::REFERER_TYPE_SEARCH_ENGINE && empty($row['referrer_data'])) {
- $row['referrer_data'] = Piwik_Referers_API::LABEL_KEYWORD_NOT_DEFINED;
+ $row['referrer_data'] = \Piwik\Plugins\Referers\API::LABEL_KEYWORD_NOT_DEFINED;
}
$referrerData[$referrerType][Metrics::INDEX_NB_VISITS] += $row[Metrics::INDEX_NB_VISITS];
@@ -466,11 +469,11 @@ protected function queryInternalReferrers($idaction, $actionType, $logAggregator
foreach ($data['result'][1] as &$page) {
$nbActions = intval($page[Metrics::INDEX_NB_ACTIONS]);
$previousPagesDataTable->addRow(new Row(array(
- Row::COLUMNS => array(
- 'label' => $this->getPageLabel($page, $isTitle),
- Metrics::INDEX_NB_ACTIONS => $nbActions
- )
- )));
+ Row::COLUMNS => array(
+ 'label' => $this->getPageLabel($page, $isTitle),
+ Metrics::INDEX_NB_ACTIONS => $nbActions
+ )
+ )));
$nbPageviews += $nbActions;
}
}
@@ -480,11 +483,11 @@ protected function queryInternalReferrers($idaction, $actionType, $logAggregator
foreach ($data['result'][2] as &$search) {
$nbActions = intval($search[Metrics::INDEX_NB_ACTIONS]);
$previousSearchesDataTable->addRow(new Row(array(
- Row::COLUMNS => array(
- 'label' => $search['name'],
- Metrics::INDEX_NB_ACTIONS => $nbActions
- )
- )));
+ Row::COLUMNS => array(
+ 'label' => $search['name'],
+ Metrics::INDEX_NB_ACTIONS => $nbActions
+ )
+ )));
$nbPageviews += $nbActions;
}
}
@@ -513,7 +516,7 @@ private function getPageLabel(&$pageRecord, $isTitle)
if ($isTitle) {
$label = $pageRecord['name'];
if (empty($label)) {
- $label = Piwik_Actions_ArchivingHelper::getUnknownActionName(
+ $label = ArchivingHelper::getUnknownActionName(
Action::TYPE_ACTION_NAME);
}
return $label;
@@ -538,7 +541,6 @@ private function getColumnTypeSuffix($actionType)
private $returnNormalizedUrls = false;
-
/**
* Get the sum of all transitions to following actions (pages, outlinks, downloads).
* Only works if queryFollowingActions() has been used directly before.
@@ -552,7 +554,7 @@ protected function getTotalTransitionsToFollowingActions()
* Add the external referrers to the report:
* direct entries, websites, campaigns, search engines
*
- * @param LogAggregator $logAggregator
+ * @param LogAggregator $logAggregator
* @param $report
* @param $idaction
* @param string $actionType
@@ -583,7 +585,7 @@ private function addExternalReferrers($logAggregator, &$report, $idaction, $acti
}
$report['referrers'][] = array(
'label' => $this->getReferrerLabel($referrerId),
- 'shortName' => Piwik_getRefererTypeFromShortName($referrerId),
+ 'shortName' => \Piwik\Plugins\Referers\getRefererTypeFromShortName($referrerId),
'visits' => $visits,
'details' => $details
);
@@ -597,7 +599,7 @@ private function addExternalReferrers($logAggregator, &$report, $idaction, $acti
if (count($report['referrers']) == 0) {
$report['referrers'][] = array(
'label' => $this->getReferrerLabel(Common::REFERER_TYPE_DIRECT_ENTRY),
- 'shortName' => Piwik_getRefererTypeLabel(Common::REFERER_TYPE_DIRECT_ENTRY),
+ 'shortName' => \Piwik\Plugins\Referers\getRefererTypeLabel(Common::REFERER_TYPE_DIRECT_ENTRY),
'visits' => 0
);
}
@@ -607,13 +609,13 @@ private function getReferrerLabel($referrerId)
{
switch ($referrerId) {
case Common::REFERER_TYPE_DIRECT_ENTRY:
- return Piwik_Transitions_Controller::getTranslation('directEntries');
+ return Controller::getTranslation('directEntries');
case Common::REFERER_TYPE_SEARCH_ENGINE:
- return Piwik_Transitions_Controller::getTranslation('fromSearchEngines');
+ return Controller::getTranslation('fromSearchEngines');
case Common::REFERER_TYPE_WEBSITE:
- return Piwik_Transitions_Controller::getTranslation('fromWebsites');
+ return Controller::getTranslation('fromWebsites');
case Common::REFERER_TYPE_CAMPAIGN:
- return Piwik_Transitions_Controller::getTranslation('fromCampaigns');
+ return Controller::getTranslation('fromCampaigns');
default:
return Piwik_Translate('General_Others');
}
@@ -621,8 +623,7 @@ private function getReferrerLabel($referrerId)
public function getTranslations()
{
- $controller = new Piwik_Transitions_Controller();
+ $controller = new Controller();
return $controller->getTranslations();
}
-
}
\ No newline at end of file
diff --git a/plugins/Transitions/Controller.php b/plugins/Transitions/Controller.php
index 5178b1923f1..172f7f1e90f 100644
--- a/plugins/Transitions/Controller.php
+++ b/plugins/Transitions/Controller.php
@@ -6,15 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Transitions
+ * @package Transitions
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\Transitions;
+
use Piwik\View;
/**
- * @package Piwik_Transitions
+ * @package Transitions
*/
-class Piwik_Transitions_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
@@ -89,5 +90,4 @@ public function getTranslations()
}
return $translations;
}
-
}
diff --git a/plugins/Transitions/Transitions.php b/plugins/Transitions/Transitions.php
index b47db2e436e..d0ea42d9b75 100644
--- a/plugins/Transitions/Transitions.php
+++ b/plugins/Transitions/Transitions.php
@@ -6,14 +6,15 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Transitions
+ * @package Transitions
*/
-use Piwik\Plugin;
+
+namespace Piwik\Plugins\Transitions;
/**
- * @package Piwik_Transitions
+ * @package Transitions
*/
-class Piwik_Transitions extends Plugin
+class Transitions extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/UserCountry/API.php b/plugins/UserCountry/API.php
index 62b472bbaa5..a621b9344cc 100644
--- a/plugins/UserCountry/API.php
+++ b/plugins/UserCountry/API.php
@@ -6,12 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry;
+
+use Exception;
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\DataTable;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\Archiver;
use Piwik\Tracker\Visit;
/**
@@ -21,9 +26,9 @@
/**
* The UserCountry API lets you access reports about your visitors' Countries and Continents.
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_API
+class API
{
static private $instance = null;
@@ -37,12 +42,12 @@ static public function getInstance()
public function getCountry($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserCountry_Archiver::COUNTRY_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::COUNTRY_RECORD_NAME, $idSite, $period, $date, $segment);
// apply filter on the whole datatable in order the inline search to work (searches are done on "beautiful" label)
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'code'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getFlagFromCode'));
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_CountryTranslate'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getFlagFromCode'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\countryTranslate'));
$dataTable->queueFilter('AddConstantMetadata', array('logoWidth', 16));
$dataTable->queueFilter('AddConstantMetadata', array('logoHeight', 11));
@@ -51,12 +56,12 @@ public function getCountry($idSite, $period, $date, $segment = false)
public function getContinent($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserCountry_Archiver::COUNTRY_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::COUNTRY_RECORD_NAME, $idSite, $period, $date, $segment);
$getContinent = array('Piwik\Common', 'getContinent');
$dataTable->filter('GroupBy', array('label', $getContinent));
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_ContinentTranslate'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\continentTranslate'));
$dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'code'));
return $dataTable;
@@ -73,31 +78,31 @@ public function getContinent($idSite, $period, $date, $segment = false)
*/
public function getRegion($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserCountry_Archiver::REGION_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::REGION_RECORD_NAME, $idSite, $period, $date, $segment);
- $separator = Piwik_UserCountry_Archiver::LOCATION_SEPARATOR;
+ $separator = Archiver::LOCATION_SEPARATOR;
$unk = Visit::UNKNOWN_CODE;
// split the label and put the elements into the 'region' and 'country' metadata fields
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'region', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 0, $unk)));
+ array('label', 'region', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 0, $unk)));
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'country', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 1, $unk)));
+ array('label', 'country', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 1, $unk)));
// add country name metadata
$dataTable->filter('MetadataCallbackAddMetadata',
- array('country', 'country_name', 'Piwik_CountryTranslate', $applyToSummaryRow = false));
+ array('country', 'country_name', __NAMESPACE__ . '\CountryTranslate', $applyToSummaryRow = false));
// get the region name of each row and put it into the 'region_name' metadata
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'region_name', 'Piwik_UserCountry_getRegionName', $params = null,
+ array('label', 'region_name', __NAMESPACE__ . '\getRegionName', $params = null,
$applyToSummaryRow = false));
// add the country flag as a url to the 'logo' metadata field
- $dataTable->filter('MetadataCallbackAddMetadata', array('country', 'logo', 'Piwik_getFlagFromCode'));
+ $dataTable->filter('MetadataCallbackAddMetadata', array('country', 'logo', __NAMESPACE__ . '\getFlagFromCode'));
// prettify the region label
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_UserCountry_getPrettyRegionName'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getPrettyRegionName'));
$dataTable->queueFilter('ReplaceSummaryRowLabel');
@@ -115,43 +120,43 @@ public function getRegion($idSite, $period, $date, $segment = false)
*/
public function getCity($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserCountry_Archiver::CITY_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::CITY_RECORD_NAME, $idSite, $period, $date, $segment);
- $separator = Piwik_UserCountry_Archiver::LOCATION_SEPARATOR;
+ $separator = Archiver::LOCATION_SEPARATOR;
$unk = Visit::UNKNOWN_CODE;
// split the label and put the elements into the 'city_name', 'region', 'country',
// 'lat' & 'long' metadata fields
$strUnknown = Piwik_Translate('General_Unknown');
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'city_name', 'Piwik_UserCountry_getElementFromStringArray',
+ array('label', 'city_name', __NAMESPACE__ . '\getElementFromStringArray',
array($separator, 0, $strUnknown)));
$dataTable->filter('MetadataCallbackAddMetadata',
array('city_name', 'city', create_function('$city', ' if ($city == "' . $strUnknown . '") { return "xx"; } else { return false; } ')));
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'region', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 1, $unk)));
+ array('label', 'region', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 1, $unk)));
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'country', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 2, $unk)));
+ array('label', 'country', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 2, $unk)));
// backwards compatibility: for reports that have lat|long in label
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'lat', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 3, false)));
+ array('label', 'lat', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 3, false)));
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'long', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 4, false)));
+ array('label', 'long', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 4, false)));
// add country name & region name metadata
$dataTable->filter('MetadataCallbackAddMetadata',
- array('country', 'country_name', 'Piwik_CountryTranslate', $applyToSummaryRow = false));
+ array('country', 'country_name', __NAMESPACE__ . '\countryTranslate', $applyToSummaryRow = false));
- $getRegionName = array('Piwik_UserCountry_LocationProvider_GeoIp', 'getRegionNameFromCodes');
+ $getRegionName = '\\Piwik\\Plugins\\UserCountry\\LocationProvider\\GeoIp::getRegionNameFromCodes';
$dataTable->filter('MetadataCallbackAddMetadata', array(
array('country', 'region'), 'region_name', $getRegionName, $applyToSummaryRow = false));
// add the country flag as a url to the 'logo' metadata field
- $dataTable->filter('MetadataCallbackAddMetadata', array('country', 'logo', 'Piwik_getFlagFromCode'));
+ $dataTable->filter('MetadataCallbackAddMetadata', array('country', 'logo', __NAMESPACE__ . '\getFlagFromCode'));
// prettify the label
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_UserCountry_getPrettyCityName'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getPrettyCityName'));
$dataTable->queueFilter('ReplaceSummaryRowLabel');
@@ -161,7 +166,7 @@ public function getCity($idSite, $period, $date, $segment = false)
/**
* Uses a location provider to find/guess the location of an IP address.
*
- * See Piwik_UserCountry_LocationProvider::getLocation to see the details
+ * See LocationProvider::getLocation to see the details
* of the result of this function.
*
* @param string $ip The IP address.
@@ -175,10 +180,10 @@ public function getLocationFromIP($ip, $provider = false)
Piwik::checkUserHasSomeViewAccess();
if ($provider === false) {
- $provider = Piwik_UserCountry_LocationProvider::getCurrentProviderId();
+ $provider = LocationProvider::getCurrentProviderId();
}
- $oProvider = Piwik_UserCountry_LocationProvider::getProviderById($provider);
+ $oProvider = LocationProvider::getProviderById($provider);
if ($oProvider === false) {
throw new Exception("Cannot find the '$provider' provider. It is either an invalid provider "
. "ID or the ID of a provider that is not working.");
@@ -206,6 +211,6 @@ public function getNumberOfDistinctCountries($idSite, $period, $date, $segment =
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Archive::build($idSite, $period, $date, $segment);
- return $archive->getDataTableFromNumeric(Piwik_UserCountry_Archiver::DISTINCT_COUNTRIES_METRIC);
+ return $archive->getDataTableFromNumeric(Archiver::DISTINCT_COUNTRIES_METRIC);
}
}
diff --git a/plugins/UserCountry/Archiver.php b/plugins/UserCountry/Archiver.php
index 656239ac24a..5485d2fe98c 100644
--- a/plugins/UserCountry/Archiver.php
+++ b/plugins/UserCountry/Archiver.php
@@ -6,16 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry;
+
use Piwik\ArchiveProcessor;
use Piwik\Metrics;
use Piwik\DataTable;
use Piwik\DataArray;
+use Piwik\Plugins\UserCountry\LocationProvider;
use Piwik\PluginsArchiver;
-class Piwik_UserCountry_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const COUNTRY_RECORD_NAME = 'UserCountry_country';
const REGION_RECORD_NAME = 'UserCountry_region';
@@ -35,16 +38,15 @@ class Piwik_UserCountry_Archiver extends PluginsArchiver
const CITY_FIELD = 'location_city';
- protected $dimensions = array( self::COUNTRY_FIELD, self::REGION_FIELD, self::CITY_FIELD );
+ protected $dimensions = array(self::COUNTRY_FIELD, self::REGION_FIELD, self::CITY_FIELD);
protected $arrays;
const LATITUDE_FIELD = 'location_latitude';
const LONGITUDE_FIELD = 'location_longitude';
-
public function archiveDay()
{
- foreach($this->dimensions as $dimension) {
+ foreach ($this->dimensions as $dimension) {
$this->arrays[$dimension] = new DataArray();
}
$this->aggregateFromVisits();
@@ -95,11 +97,12 @@ private function makeRegionCityLabelsUnique(&$row)
protected function rememberCityLatLong($row)
{
- if ( !empty($row[self::CITY_FIELD])
+ if (!empty($row[self::CITY_FIELD])
&& !empty($row[self::LATITUDE_FIELD])
&& !empty($row[self::LONGITUDE_FIELD])
- && empty($this->latLongForCities[$row[self::CITY_FIELD]])) {
- $this->latLongForCities[$row[self::CITY_FIELD]] = array($row[self::LATITUDE_FIELD], $row[self::LONGITUDE_FIELD]);
+ && empty($this->latLongForCities[$row[self::CITY_FIELD]])
+ ) {
+ $this->latLongForCities[$row[self::CITY_FIELD]] = array($row[self::LATITUDE_FIELD], $row[self::LONGITUDE_FIELD]);
}
}
@@ -153,8 +156,8 @@ private function setLatitudeLongitude(DataTable $tableCity)
if (isset($this->latLongForCities[$label])) {
// get lat/long for city
list($lat, $long) = $this->latLongForCities[$label];
- $lat = round($lat, Piwik_UserCountry_LocationProvider::GEOGRAPHIC_COORD_PRECISION);
- $long = round($long, Piwik_UserCountry_LocationProvider::GEOGRAPHIC_COORD_PRECISION);
+ $lat = round($lat, LocationProvider::GEOGRAPHIC_COORD_PRECISION);
+ $long = round($long, LocationProvider::GEOGRAPHIC_COORD_PRECISION);
// set latitude + longitude metadata
$row->setMetadata('lat', $lat);
@@ -175,5 +178,4 @@ public function archivePeriod()
$this->getProcessor()->insertNumericRecord(self::DISTINCT_COUNTRIES_METRIC,
$nameToCount[self::COUNTRY_RECORD_NAME]['level0']);
}
-
}
\ No newline at end of file
diff --git a/plugins/UserCountry/Controller.php b/plugins/UserCountry/Controller.php
index 16548850014..8fc88f80b52 100644
--- a/plugins/UserCountry/Controller.php
+++ b/plugins/UserCountry/Controller.php
@@ -6,23 +6,32 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-use Piwik\Controller\Admin;
+namespace Piwik\Plugins\UserCountry;
+
+use Admin;
+use Exception;
use Piwik\DataTable\Renderer\Json;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Http;
use Piwik\IP;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\GeoIPAutoUpdater;
use Piwik\ViewDataTable;
use Piwik\View;
use Piwik\Url;
+use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Pecl;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\ServerBased;
/**
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
public function index()
{
@@ -44,19 +53,19 @@ public function adminIndex()
Piwik::checkUserIsSuperUser();
$view = new View('@UserCountry/adminIndex');
- $allProviderInfo = Piwik_UserCountry_LocationProvider::getAllProviderInfo(
+ $allProviderInfo = LocationProvider::getAllProviderInfo(
$newline = '
', $includeExtra = true);
$view->locationProviders = $allProviderInfo;
- $view->currentProviderId = Piwik_UserCountry_LocationProvider::getCurrentProviderId();
+ $view->currentProviderId = LocationProvider::getCurrentProviderId();
$view->thisIP = IP::getIpFromHeader();
- $geoIPDatabasesInstalled = Piwik_UserCountry_LocationProvider_GeoIp::isDatabaseInstalled();
+ $geoIPDatabasesInstalled = GeoIp::isDatabaseInstalled();
$view->geoIPDatabasesInstalled = $geoIPDatabasesInstalled;
// check if there is a working provider (that isn't the default one)
$isThereWorkingProvider = false;
foreach ($allProviderInfo as $id => $provider) {
- if ($id != Piwik_UserCountry_LocationProvider_Default::ID
- && $provider['status'] == Piwik_UserCountry_LocationProvider::INSTALLED
+ if ($id != DefaultProvider::ID
+ && $provider['status'] == LocationProvider::INSTALLED
) {
$isThereWorkingProvider = true;
break;
@@ -67,11 +76,11 @@ public function adminIndex()
// if using either the Apache or PECL module, they are working and there are no databases
// in misc, then the databases are located outside of Piwik, so we cannot update them
$view->showGeoIPUpdateSection = true;
- $currentProviderId = Piwik_UserCountry_LocationProvider::getCurrentProviderId();
+ $currentProviderId = LocationProvider::getCurrentProviderId();
if (!$geoIPDatabasesInstalled
- && ($currentProviderId == Piwik_UserCountry_LocationProvider_GeoIp_ServerBased::ID
- || $currentProviderId == Piwik_UserCountry_LocationProvider_GeoIp_Pecl::ID)
- && $allProviderInfo[$currentProviderId]['status'] == Piwik_UserCountry_LocationProvider::INSTALLED
+ && ($currentProviderId == ServerBased::ID
+ || $currentProviderId == Pecl::ID)
+ && $allProviderInfo[$currentProviderId]['status'] == LocationProvider::INSTALLED
) {
$view->showGeoIPUpdateSection = false;
}
@@ -106,23 +115,23 @@ public function downloadFreeGeoIPDB()
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
Json::sendHeaderJSON();
- $outputPath = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase('GeoIPCity.dat') . '.gz';
+ $outputPath = GeoIp::getPathForGeoIpDatabase('GeoIPCity.dat') . '.gz';
try {
$result = Http::downloadChunk(
- $url = Piwik_UserCountry_LocationProvider_GeoIp::GEO_LITE_URL,
+ $url = GeoIp::GEO_LITE_URL,
$outputPath,
$continue = Common::getRequestVar('continue', true, 'int')
);
// if the file is done
if ($result['current_size'] >= $result['expected_file_size']) {
- Piwik_UserCountry_GeoIPAutoUpdater::unzipDownloadedFile($outputPath, $unlink = true);
+ GeoIPAutoUpdater::unzipDownloadedFile($outputPath, $unlink = true);
// setup the auto updater
- Piwik_UserCountry_GeoIPAutoUpdater::setUpdaterOptions(array(
- 'loc_db' => Piwik_UserCountry_LocationProvider_GeoIp::GEO_LITE_URL,
- 'period' => Piwik_UserCountry_GeoIPAutoUpdater::SCHEDULE_PERIOD_MONTHLY,
- ));
+ GeoIPAutoUpdater::setUpdaterOptions(array(
+ 'loc_db' => GeoIp::GEO_LITE_URL,
+ 'period' => GeoIPAutoUpdater::SCHEDULE_PERIOD_MONTHLY,
+ ));
// make sure to echo out the geoip updater management screen
$result['next_screen'] = $this->getGeoIpUpdaterManageScreen();
@@ -155,16 +164,16 @@ private function getGeoIpUpdaterManageScreen()
*/
private function setUpdaterManageVars($view)
{
- $urls = Piwik_UserCountry_GeoIPAutoUpdater::getConfiguredUrls();
+ $urls = GeoIPAutoUpdater::getConfiguredUrls();
$view->geoIPLocUrl = $urls['loc'];
$view->geoIPIspUrl = $urls['isp'];
$view->geoIPOrgUrl = $urls['org'];
- $view->geoIPUpdatePeriod = Piwik_UserCountry_GeoIPAutoUpdater::getSchedulePeriod();
+ $view->geoIPUpdatePeriod = GeoIPAutoUpdater::getSchedulePeriod();
- $view->geoLiteUrl = Piwik_UserCountry_LocationProvider_GeoIp::GEO_LITE_URL;
+ $view->geoLiteUrl = GeoIp::GEO_LITE_URL;
- $lastRunTime = Piwik_UserCountry_GeoIPAutoUpdater::getLastRunTime();
+ $lastRunTime = GeoIPAutoUpdater::getLastRunTime();
if ($lastRunTime !== false) {
$view->lastTimeUpdaterRun = '' . $lastRunTime->toString() . '';
}
@@ -191,7 +200,7 @@ public function updateGeoIPLinks()
try {
$this->checkTokenInUrl();
- Piwik_UserCountry_GeoIPAutoUpdater::setUpdaterOptionsFromUrl();
+ GeoIPAutoUpdater::setUpdaterOptionsFromUrl();
// if there is a updater URL for a database, but its missing from the misc dir, tell
// the browser so it can download it next
@@ -237,15 +246,15 @@ public function downloadMissingGeoIpDb()
// based on the database type (provided by the 'key' query param) determine the
// url & output file name
$key = Common::getRequestVar('key', null, 'string');
- $url = Piwik_UserCountry_GeoIPAutoUpdater::getConfiguredUrl($key);
+ $url = GeoIPAutoUpdater::getConfiguredUrl($key);
- $ext = Piwik_UserCountry_GeoIPAutoUpdater::getGeoIPUrlExtension($url);
- $filename = Piwik_UserCountry_LocationProvider_GeoIp::$dbNames[$key][0] . '.' . $ext;
+ $ext = GeoIPAutoUpdater::getGeoIPUrlExtension($url);
+ $filename = GeoIp::$dbNames[$key][0] . '.' . $ext;
if (substr($filename, 0, 15) == 'GeoLiteCity.dat') {
$filename = 'GeoIPCity.dat' . substr($filename, 15);
}
- $outputPath = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase($filename);
+ $outputPath = GeoIp::getPathForGeoIpDatabase($filename);
// download part of the file
$result = Http::downloadChunk(
@@ -253,7 +262,7 @@ public function downloadMissingGeoIpDb()
// if the file is done
if ($result['current_size'] >= $result['expected_file_size']) {
- Piwik_UserCountry_GeoIPAutoUpdater::unzipDownloadedFile($outputPath, $unlink = true);
+ GeoIPAutoUpdater::unzipDownloadedFile($outputPath, $unlink = true);
$info = $this->getNextMissingDbUrlInfo();
if ($info !== false) {
@@ -285,7 +294,7 @@ public function setCurrentLocationProvider()
$this->checkTokenInUrl();
$providerId = Common::getRequestVar('id');
- $provider = Piwik_UserCountry_LocationProvider::setCurrentProvider($providerId);
+ $provider = LocationProvider::setCurrentProvider($providerId);
if ($provider === false) {
throw new Exception("Invalid provider ID: '$providerId'.");
}
@@ -305,7 +314,7 @@ public function setCurrentLocationProvider()
public function getLocationUsingProvider()
{
$providerId = Common::getRequestVar('id');
- $provider = $provider = Piwik_UserCountry_LocationProvider::getProviderById($providerId);
+ $provider = $provider = LocationProvider::getProviderById($providerId);
if ($provider === false) {
throw new Exception("Invalid provider ID: '$providerId'.");
}
@@ -313,7 +322,7 @@ public function getLocationUsingProvider()
$location = $provider->getLocation(array('ip' => IP::getIpFromHeader(),
'lang' => Common::getBrowserLanguage(),
'disable_fallbacks' => true));
- $location = Piwik_UserCountry_LocationProvider::prettyFormatLocation(
+ $location = LocationProvider::prettyFormatLocation(
$location, $newline = '
', $includeExtra = true);
echo $location;
@@ -370,11 +379,11 @@ public function getLastDistinctCountriesGraph($fetch = false)
*/
private function getNextMissingDbUrlInfo()
{
- $missingDbs = Piwik_UserCountry_GeoIPAutoUpdater::getMissingDatabases();
+ $missingDbs = GeoIPAutoUpdater::getMissingDatabases();
if (!empty($missingDbs)) {
$missingDbKey = $missingDbs[0];
- $missingDbName = Piwik_UserCountry_LocationProvider_GeoIp::$dbNames[$missingDbKey][0];
- $url = Piwik_UserCountry_GeoIPAutoUpdater::getConfiguredUrl($missingDbKey);
+ $missingDbName = GeoIp::$dbNames[$missingDbKey][0];
+ $url = GeoIPAutoUpdater::getConfiguredUrl($missingDbKey);
$link = '' . $missingDbName . '';
diff --git a/plugins/UserCountry/GeoIPAutoUpdater.php b/plugins/UserCountry/GeoIPAutoUpdater.php
index 784a28ed7f6..6d28c192cd2 100755
--- a/plugins/UserCountry/GeoIPAutoUpdater.php
+++ b/plugins/UserCountry/GeoIPAutoUpdater.php
@@ -6,22 +6,28 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
use Piwik\Http;
+use Piwik\Plugins\UserCountry\LocationProvider;
use Piwik\ScheduledTime\Monthly;
use Piwik\ScheduledTime\Weekly;
use Piwik\Unzip;
use Piwik\ScheduledTask;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Php;
/**
* Used to automatically update installed GeoIP databases, and manages the updater's
* scheduled task.
*/
-class Piwik_UserCountry_GeoIPAutoUpdater
+class GeoIPAutoUpdater
{
const SCHEDULE_PERIOD_MONTHLY = 'month';
const SCHEDULE_PERIOD_WEEKLY = 'week';
@@ -71,7 +77,7 @@ public function update()
$this->downloadFile('org', $orgUrl);
}
} catch (Exception $ex) {
- // message will already be prefixed w/ 'Piwik_UserCountry_GeoIPAutoUpdater: '
+ // message will already be prefixed w/ 'GeoIPAutoUpdater: '
Piwik::log($ex->getMessage());
$this->performRedundantDbChecks();
throw $ex;
@@ -94,34 +100,34 @@ public function update()
*/
protected function downloadFile($dbType, $url)
{
- $ext = Piwik_UserCountry_GeoIPAutoUpdater::getGeoIPUrlExtension($url);
- $zippedFilename = Piwik_UserCountry_LocationProvider_GeoIp::$dbNames[$dbType][0] . '.' . $ext;
+ $ext = GeoIPAutoUpdater::getGeoIPUrlExtension($url);
+ $zippedFilename = GeoIp::$dbNames[$dbType][0] . '.' . $ext;
- $zippedOutputPath = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase($zippedFilename);
+ $zippedOutputPath = GeoIp::getPathForGeoIpDatabase($zippedFilename);
// download zipped file to misc dir
try {
$success = Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath);
} catch (Exception $ex) {
- throw new Exception("Piwik_UserCountry_GeoIPAutoUpdater: failed to download '$url' to "
+ throw new Exception("GeoIPAutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath': " . $ex->getMessage());
}
if ($success !== true) {
- throw new Exception("Piwik_UserCountry_GeoIPAutoUpdater: failed to download '$url' to "
+ throw new Exception("GeoIPAutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath'! (Unknown error)");
}
- Piwik::log(sprintf("Piwik_UserCountry_GeoIPAutoUpdater: successfully downloaded '%s'", $url));
+ Piwik::log(sprintf("GeoIPAutoUpdater: successfully downloaded '%s'", $url));
try {
self::unzipDownloadedFile($zippedOutputPath, $unlink = true);
} catch (Exception $ex) {
- throw new Exception("Piwik_UserCountry_GeoIPAutoUpdater: failed to unzip '$zippedOutputPath' after "
+ throw new Exception("GeoIPAutoUpdater: failed to unzip '$zippedOutputPath' after "
. "downloading " . "'$url': " . $ex->getMessage());
}
- Piwik::log(sprintf("Piwik_UserCountry_GeoIPAutoUpdater: successfully updated GeoIP database '%s'", $url));
+ Piwik::log(sprintf("GeoIPAutoUpdater: successfully updated GeoIP database '%s'", $url));
}
/**
@@ -138,7 +144,7 @@ public static function unzipDownloadedFile($path, $unlink = false)
$dbFilename = $filenameStart . '.dat';
$tempFilename = $filenameStart . '.dat.new';
- $outputPath = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase($tempFilename);
+ $outputPath = GeoIp::getPathForGeoIpDatabase($tempFilename);
// extract file
if (substr($path, -7, 7) == '.tar.gz') {
@@ -191,7 +197,7 @@ public static function unzipDownloadedFile($path, $unlink = false)
try {
// test that the new archive is a valid GeoIP database
- $dbType = Piwik_UserCountry_LocationProvider_GeoIp::getGeoIPDatabaseTypeFromFilename($dbFilename);
+ $dbType = GeoIp::getGeoIPDatabaseTypeFromFilename($dbFilename);
if ($dbType === false) // sanity check
{
throw new Exception("Unexpected GeoIP archive file name '$path'.");
@@ -204,7 +210,7 @@ public static function unzipDownloadedFile($path, $unlink = false)
);
$customDbNames[$dbType] = array($tempFilename);
- $phpProvider = new Piwik_UserCountry_LocationProvider_GeoIp_Php($customDbNames);
+ $phpProvider = new Php($customDbNames);
$location = self::getTestLocationCatchPhpErrors($phpProvider);
@@ -213,7 +219,7 @@ public static function unzipDownloadedFile($path, $unlink = false)
) {
if (self::$unzipPhpError !== null) {
list($errno, $errstr, $errfile, $errline) = self::$unzipPhpError;
- Piwik::log("Piwik_UserCountry_GeoIPAutoUpdater: Encountered PHP error when testing newly downloaded" .
+ Piwik::log("GeoIPAutoUpdater: Encountered PHP error when testing newly downloaded" .
" GeoIP database: $errno: $errstr on line $errline of $errfile.");
}
@@ -221,12 +227,12 @@ public static function unzipDownloadedFile($path, $unlink = false)
}
// delete the existing GeoIP database (if any) and rename the downloaded file
- $oldDbFile = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase($dbFilename);
+ $oldDbFile = GeoIp::getPathForGeoIpDatabase($dbFilename);
if (file_exists($oldDbFile)) {
unlink($oldDbFile);
}
- $tempFile = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase($tempFilename);
+ $tempFile = GeoIp::getPathForGeoIpDatabase($tempFilename);
rename($existing = $tempFile, $newName = $oldDbFile);
// delete original archive
@@ -251,7 +257,7 @@ public static function unzipDownloadedFile($path, $unlink = false)
*/
public static function makeScheduledTask()
{
- $instance = new Piwik_UserCountry_GeoIPAutoUpdater();
+ $instance = new GeoIPAutoUpdater();
$schedulePeriodStr = self::getSchedulePeriod();
@@ -379,7 +385,7 @@ public static function getConfiguredUrl($key)
*/
public static function performUpdate()
{
- $instance = new Piwik_UserCountry_GeoIPAutoUpdater();
+ $instance = new GeoIPAutoUpdater();
$instance->update();
}
@@ -412,8 +418,8 @@ public static function getMissingDatabases()
if (!empty($url)) {
// if a database of the type does not exist, but there's a url to update, then
// a database is missing
- $path = Piwik_UserCountry_LocationProvider_GeoIp::getPathToGeoIpDatabase(
- Piwik_UserCountry_LocationProvider_GeoIp::$dbNames[$key]);
+ $path = GeoIp::getPathToGeoIpDatabase(
+ GeoIp::$dbNames[$key]);
if ($path === false) {
$result[] = $key;
}
@@ -448,7 +454,7 @@ public static function getGeoIPUrlExtension($url)
/**
* Avoid downloading archive types we don't support. No point in downloading it,
* if we can't unzip it...
- *
+ *
* @param string $ext The URL file's extension.
*/
private static function checkForSupportedArchiveType($ext)
@@ -464,7 +470,7 @@ private static function checkForSupportedArchiveType($ext)
* Tests a location provider using a test IP address and catches PHP errors
* (ie, notices) if they occur. PHP error information is held in self::$unzipPhpError.
*
- * @param Piwik_UserCountry_LocationProvider $provider The provider to test.
+ * @param LocationProvider $provider The provider to test.
* @return array|false $location The result of geolocation. False if no location
* can be found.
*/
@@ -474,9 +480,9 @@ private static function getTestLocationCatchPhpErrors($provider)
// in order to delete the files in such a case (which can be caused by a man-in-the-middle attack)
// we need to catch them, so we set a new error handler.
self::$unzipPhpError = null;
- set_error_handler(array('Piwik_UserCountry_GeoIPAutoUpdater', 'catchGeoIPError'));
+ set_error_handler(array('Piwik\Plugins\UserCountry\GeoIPAutoUpdater', 'catchGeoIPError'));
- $location = $provider->getLocation(array('ip' => Piwik_UserCountry_LocationProvider_GeoIp::TEST_IP));
+ $location = $provider->getLocation(array('ip' => GeoIp::TEST_IP));
restore_error_handler();
@@ -495,7 +501,7 @@ private static function getTestLocationCatchPhpErrors($provider)
*/
protected function performRedundantDbChecks()
{
- $databaseTypes = array_keys(Piwik_UserCountry_LocationProvider_GeoIp::$dbNames);
+ $databaseTypes = array_keys(GeoIp::$dbNames);
foreach ($databaseTypes as $type) {
$customNames = array(
@@ -503,16 +509,16 @@ protected function performRedundantDbChecks()
'isp' => array(),
'org' => array()
);
- $customNames[$type] = Piwik_UserCountry_LocationProvider_GeoIp::$dbNames[$type];
+ $customNames[$type] = GeoIp::$dbNames[$type];
// create provider that only uses the DB type we're testing
- $provider = new Piwik_UserCountry_LocationProvider_GeoIp_Php($customNames);
+ $provider = new Php($customNames);
// test the provider. on error, we rename the broken DB.
self::getTestLocationCatchPhpErrors($provider);
if (self::$unzipPhpError !== null) {
list($errno, $errstr, $errfile, $errline) = self::$unzipPhpError;
- Piwik::log("Piwik_UserCountry_GeoIPAutoUpdater: Encountered PHP error when performing redundant " .
+ Piwik::log("GeoIPAutoUpdater: Encountered PHP error when performing redundant " .
"tests on GeoIP $type database: $errno: $errstr on line $errline of $errfile.");
// get the current filename for the DB and an available new one to rename it to
@@ -542,7 +548,7 @@ protected function performRedundantDbChecks()
*/
private function getOldAndNewPathsForBrokenDb($possibleDbNames)
{
- $pathToDb = Piwik_UserCountry_LocationProvider_GeoIp::getPathToGeoIpDatabase($possibleDbNames);
+ $pathToDb = GeoIp::getPathToGeoIpDatabase($possibleDbNames);
$newPath = false;
if ($pathToDb !== false) {
diff --git a/plugins/UserCountry/LocationProvider.php b/plugins/UserCountry/LocationProvider.php
index 40751b72475..e26e72934da 100755
--- a/plugins/UserCountry/LocationProvider.php
+++ b/plugins/UserCountry/LocationProvider.php
@@ -6,11 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry;
+
+use Exception;
use Piwik\Common;
use Piwik\IP;
use Piwik\Tracker\Cache;
+use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider;
+use ReflectionClass;
/**
* @see plugins/UserCountry/LocationProvider/Default.php
@@ -29,7 +34,7 @@
* visitor info. All LocationProviders require a visitor's IP address, some
* require more, such as the browser language.
*/
-abstract class Piwik_UserCountry_LocationProvider
+abstract class LocationProvider
{
const NOT_INSTALLED = 0;
const INSTALLED = 1;
@@ -139,7 +144,7 @@ public static function getAllProviders()
if (is_null(self::$providers)) {
self::$providers = array();
foreach (get_declared_classes() as $klass) {
- if (is_subclass_of($klass, 'Piwik_UserCountry_LocationProvider')) {
+ if (is_subclass_of($klass, 'Piwik\Plugins\UserCountry\LocationProvider')) {
$klassInfo = new ReflectionClass($klass);
if ($klassInfo->isAbstract()) {
continue;
@@ -188,7 +193,7 @@ public static function getAvailableProviders()
* 'geoip_php' => array('id' => 'geoip_php',
* 'title' => '...',
* 'desc' => '...',
- * 'status' => Piwik_UserCountry_LocationProvider_GeoIp::BROKEN,
+ * 'status' => GeoIp::BROKEN,
* 'statusMessage' => '...',
* 'location' => '...')
* 'geoip_serverbased' => array(...)
@@ -259,7 +264,7 @@ public static function getAllProviderInfo($newline = "\n", $includeExtra = false
public static function getCurrentProviderId()
{
$optionValue = Piwik_GetOption(self::CURRENT_PROVIDER_OPTION_NAME);
- return $optionValue === false ? Piwik_UserCountry_LocationProvider_Default::ID : $optionValue;
+ return $optionValue === false ? DefaultProvider::ID : $optionValue;
}
/**
@@ -267,7 +272,7 @@ public static function getCurrentProviderId()
*
* This function should not be called by the Tracker.
*
- * @return Piwik_UserCountry_LocationProvider
+ * @return \Piwik\Plugins\UserCountry\LocationProvider
*/
public static function getCurrentProvider()
{
@@ -278,7 +283,7 @@ public static function getCurrentProvider()
* Sets the provider to use when tracking.
*
* @param string $providerId The ID of the provider to use.
- * @return Piwik_UserCountry_LocationProvider The new current provider.
+ * @return \Piwik\Plugins\UserCountry\LocationProvider The new current provider.
* @throws Exception If the provider ID is invalid.
*/
public static function setCurrentProvider($providerId)
@@ -297,7 +302,7 @@ public static function setCurrentProvider($providerId)
* Returns a provider instance by ID or false if the ID is invalid or unavailable.
*
* @param string $providerId
- * @return Piwik_UserCountry_LocationProvider|false
+ * @return \Piwik\Plugins\UserCountry\LocationProvider|false
*/
public static function getProviderById($providerId)
{
diff --git a/plugins/UserCountry/LocationProvider/Default.php b/plugins/UserCountry/LocationProvider/Default.php
index a7798a5ca0f..dd44183f214 100755
--- a/plugins/UserCountry/LocationProvider/Default.php
+++ b/plugins/UserCountry/LocationProvider/Default.php
@@ -6,18 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry\LocationProvider;
+
use Piwik\Config;
use Piwik\Common;
+use Piwik\Plugins\UserCountry\LocationProvider;
/**
* The default LocationProvider, this LocationProvider guesses a visitor's country
* using the language they use. This provider is not very accurate.
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_LocationProvider_Default extends Piwik_UserCountry_LocationProvider
+class DefaultProvider extends LocationProvider
{
const ID = 'default';
const TITLE = 'General_Default';
diff --git a/plugins/UserCountry/LocationProvider/GeoIp.php b/plugins/UserCountry/LocationProvider/GeoIp.php
index 5cf139ac120..b40783d7c40 100755
--- a/plugins/UserCountry/LocationProvider/GeoIp.php
+++ b/plugins/UserCountry/LocationProvider/GeoIp.php
@@ -6,15 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry\LocationProvider;
+
+use Exception;
+use Piwik\Plugins\UserCountry\LocationProvider;
/**
* Base type for all GeoIP LocationProviders.
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-abstract class Piwik_UserCountry_LocationProvider_GeoIp extends Piwik_UserCountry_LocationProvider
+abstract class GeoIp extends LocationProvider
{
/* For testing, use: 'http://piwik-team.s3.amazonaws.com/GeoLiteCity.dat.gz' */
const GEO_LITE_URL = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz';
@@ -255,7 +259,6 @@ public static function getGeoIPDatabaseTypeFromFilename($filename)
}
}
-
/**
* @see plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php
*/
diff --git a/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php b/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php
index 9ffc4ffa0a6..c4113fd9e87 100755
--- a/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php
+++ b/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
/**
* A LocationProvider that uses the PECL implementation of GeoIP.
@@ -15,9 +18,9 @@
* FIXME: For some reason, if the PECL module is loaded & an organization DB is available, the PHP
* module won't return organization info. If the PECL module is not loaded, organization info is returned.
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_LocationProvider_GeoIp_Pecl extends Piwik_UserCountry_LocationProvider_GeoIp
+class Pecl extends GeoIp
{
const ID = 'geoip_pecl';
const TITLE = 'GeoIP (PECL)';
diff --git a/plugins/UserCountry/LocationProvider/GeoIp/Php.php b/plugins/UserCountry/LocationProvider/GeoIp/Php.php
index 001b7f8c4eb..dc54f5b29c8 100755
--- a/plugins/UserCountry/LocationProvider/GeoIp/Php.php
+++ b/plugins/UserCountry/LocationProvider/GeoIp/Php.php
@@ -6,16 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+
use Piwik\Piwik;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
/**
* A LocationProvider that uses the PHP implementation of GeoIP.
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_LocationProvider_GeoIp_Php extends Piwik_UserCountry_LocationProvider_GeoIp
+class Php extends GeoIp
{
const ID = 'geoip_php';
const TITLE = 'GeoIP (Php)';
@@ -38,7 +41,7 @@ class Piwik_UserCountry_LocationProvider_GeoIp_Php extends Piwik_UserCountry_Loc
* This variable is an array mapping either the 'loc', 'isp' or 'org' strings with
* an array of filenames.
*
- * By default, this will be set to Piwik_UserCountry_LocationProvider_GeoIp_Php::$dbNames.
+ * By default, this will be set to Php::$dbNames.
*
* @var array
*/
diff --git a/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php b/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php
index ab3942974f0..7d2be065d2f 100755
--- a/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php
+++ b/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php
@@ -6,11 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+
use Piwik\Common;
use Piwik\IP;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Pecl;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Php;
/**
* A LocationProvider that uses an GeoIP module installed in an HTTP Server.
@@ -18,9 +24,9 @@
* To make this provider available, make sure the GEOIP_ADDR server
* variable is set.
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_LocationProvider_GeoIp_ServerBased extends Piwik_UserCountry_LocationProvider_GeoIp
+class ServerBased extends GeoIp
{
const ID = 'geoip_serverbased';
const TITLE = 'GeoIP (%s)';
@@ -74,11 +80,11 @@ public function getLocation($info)
) {
Common::printDebug("The request is for IP address: " . $info['ip'] . " but your IP is: $myIP. GeoIP Server Module (apache/nginx) does not support this use case... ");
$fallbacks = array(
- Piwik_UserCountry_LocationProvider_GeoIp_Pecl::ID,
- Piwik_UserCountry_LocationProvider_GeoIp_Php::ID
+ Pecl::ID,
+ Php::ID
);
foreach ($fallbacks as $fallbackProviderId) {
- $otherProvider = Piwik_UserCountry_LocationProvider::getProviderById($fallbackProviderId);
+ $otherProvider = LocationProvider::getProviderById($fallbackProviderId);
if ($otherProvider) {
Common::printDebug("Used $fallbackProviderId to detect this visitor IP");
return $otherProvider->getLocation($info);
diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php
index 26706dbfa2b..5c7bde67e0d 100644
--- a/plugins/UserCountry/UserCountry.php
+++ b/plugins/UserCountry/UserCountry.php
@@ -6,13 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry;
+
use Piwik\ArchiveProcessor;
use Piwik\Common;
use Piwik\Piwik;
-use Piwik\Plugin;
use Piwik\WidgetsList;
+use Piwik_Url;
+use Piwik\Plugins\UserCountry\Archiver;
+use Piwik\Plugins\UserCountry\GeoIPAutoUpdater;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
/**
* @see plugins/UserCountry/GeoIPAutoUpdater.php
@@ -21,9 +28,9 @@
/**
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry extends Plugin
+class UserCountry extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -31,18 +38,18 @@ class Piwik_UserCountry extends Plugin
public function getListHooksRegistered()
{
$hooks = array(
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenu',
- 'AdminMenu.add' => 'addAdminMenu',
- 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
- 'API.getReportMetadata' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
- 'AssetManager.getCssFiles' => 'getCssFiles',
- 'AssetManager.getJsFiles' => 'getJsFiles',
- 'Tracker.getVisitorLocation' => 'getVisitorLocation',
- 'TaskScheduler.getScheduledTasks' => 'getScheduledTasks',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenu',
+ 'AdminMenu.add' => 'addAdminMenu',
+ 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
+ 'API.getReportMetadata' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'AssetManager.getCssFiles' => 'getCssFiles',
+ 'AssetManager.getJsFiles' => 'getJsFiles',
+ 'Tracker.getVisitorLocation' => 'getVisitorLocation',
+ 'TaskScheduler.getScheduledTasks' => 'getScheduledTasks',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
return $hooks;
@@ -51,7 +58,7 @@ public function getListHooksRegistered()
public function getScheduledTasks(&$tasks)
{
// add the auto updater task
- $tasks[] = Piwik_UserCountry_GeoIPAutoUpdater::makeScheduledTask();
+ $tasks[] = GeoIPAutoUpdater::makeScheduledTask();
}
public function getCssFiles(&$cssFiles)
@@ -69,10 +76,10 @@ public function getVisitorLocation(&$location, $visitorInfo)
require_once PIWIK_INCLUDE_PATH . "/plugins/UserCountry/LocationProvider.php";
$id = Common::getCurrentLocationProviderId();
- $provider = Piwik_UserCountry_LocationProvider::getProviderById($id);
+ $provider = LocationProvider::getProviderById($id);
if ($provider === false) {
- $id = Piwik_UserCountry_LocationProvider_Default::ID;
- $provider = Piwik_UserCountry_LocationProvider::getProviderById($id);
+ $id = DefaultProvider::ID;
+ $provider = LocationProvider::getProviderById($id);
Common::printDebug("GEO: no current location provider sent, falling back to default '$id' one.");
}
@@ -80,8 +87,8 @@ public function getVisitorLocation(&$location, $visitorInfo)
// if we can't find a location, use default provider
if ($location === false) {
- $defaultId = Piwik_UserCountry_LocationProvider_Default::ID;
- $provider = Piwik_UserCountry_LocationProvider::getProviderById($defaultId);
+ $defaultId = DefaultProvider::ID;
+ $provider = LocationProvider::getProviderById($defaultId);
$location = $provider->getLocation($visitorInfo);
Common::printDebug("GEO: couldn't find a location with Geo Module '$id', using Default '$defaultId' provider as fallback...");
$id = $defaultId;
@@ -139,7 +146,7 @@ public function getSegmentsMetadata(&$segments)
'segment' => 'continentCode',
'sqlSegment' => 'log_visit.location_country',
'acceptedValues' => 'eur, asi, amc, amn, ams, afr, ant, oce',
- 'sqlFilter' => array('Piwik_UserCountry', 'getCountriesForContinent'),
+ 'sqlFilter' => __NAMESPACE__ . '\UserCountry::getCountriesForContinent',
);
$segments[] = array(
'type' => 'dimension',
@@ -250,21 +257,20 @@ public function getReportsWithGoalMetrics(&$dimensions)
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_UserCountry_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_UserCountry_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
-
/**
* Returns a list of country codes for a given continent code.
*
@@ -296,10 +302,10 @@ private function getDisplayPropertiesForGetCountry()
{
return array(
'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'filter_limit' => 5,
- 'translations' => array('label' => Piwik_Translate('UserCountry_Country')),
- 'documentation' => Piwik_Translate('UserCountry_getCountryDocumentation')
+ 'show_goals' => true,
+ 'filter_limit' => 5,
+ 'translations' => array('label' => Piwik_Translate('UserCountry_Country')),
+ 'documentation' => Piwik_Translate('UserCountry_getCountryDocumentation')
);
}
@@ -307,12 +313,12 @@ private function getDisplayPropertiesForGetContinent()
{
return array(
'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'show_search' => false,
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'translations' => array('label' => Piwik_Translate('UserCountry_Continent')),
- 'documentation' => Piwik_Translate('UserCountry_getContinentDocumentation')
+ 'show_goals' => true,
+ 'show_search' => false,
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'translations' => array('label' => Piwik_Translate('UserCountry_Continent')),
+ 'documentation' => Piwik_Translate('UserCountry_getContinentDocumentation')
);
}
@@ -320,11 +326,11 @@ private function getDisplayPropertiesForGetRegion()
{
$result = array(
'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'filter_limit' => 5,
- 'translations' => array('label' => Piwik_Translate('UserCountry_Region')),
- 'documentation' => Piwik_Translate('UserCountry_getRegionDocumentation') . '
'
- . $this->getGeoIPReportDocSuffix()
+ 'show_goals' => true,
+ 'filter_limit' => 5,
+ 'translations' => array('label' => Piwik_Translate('UserCountry_Region')),
+ 'documentation' => Piwik_Translate('UserCountry_getRegionDocumentation') . '
'
+ . $this->getGeoIPReportDocSuffix()
);
$this->checkIfNoDataForGeoIpReport($result);
return $result;
@@ -334,11 +340,11 @@ private function getDisplayPropertiesForGetCity()
{
$result = array(
'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'filter_limit' => 5,
- 'translations' => array('label' => Piwik_Translate('UserCountry_City')),
- 'documentation' => Piwik_Translate('UserCountry_getCityDocumentation') . '
'
- . $this->getGeoIPReportDocSuffix()
+ 'show_goals' => true,
+ 'filter_limit' => 5,
+ 'translations' => array('label' => Piwik_Translate('UserCountry_City')),
+ 'documentation' => Piwik_Translate('UserCountry_getCityDocumentation') . '
'
+ . $this->getGeoIPReportDocSuffix()
);
$this->checkIfNoDataForGeoIpReport($result);
return $result;
@@ -393,8 +399,8 @@ private function checkIfNoDataForGeoIpReport(&$properties)
*/
public function isGeoIPWorking()
{
- $provider = Piwik_UserCountry_LocationProvider::getCurrentProvider();
- return $provider instanceof Piwik_UserCountry_LocationProvider_GeoIp
+ $provider = LocationProvider::getCurrentProvider();
+ return $provider instanceof GeoIp
&& $provider->isAvailable() === true
&& $provider->isWorking() === true;
}
diff --git a/plugins/UserCountry/functions.php b/plugins/UserCountry/functions.php
index cdc408a273d..cae545f5219 100644
--- a/plugins/UserCountry/functions.php
+++ b/plugins/UserCountry/functions.php
@@ -6,9 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+
+namespace Piwik\Plugins\UserCountry;
+
use Piwik\DataTable;
+use Piwik\Plugins\UserCountry\Archiver;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
use Piwik\Tracker\Visit;
/**
@@ -17,7 +22,7 @@
* @param string $code ISO country code
* @return string Flag image path
*/
-function Piwik_getFlagFromCode($code)
+function getFlagFromCode($code)
{
$pathInPiwik = 'plugins/UserCountry/images/flags/%s.png';
$pathWithCode = sprintf($pathInPiwik, $code);
@@ -34,7 +39,7 @@ function Piwik_getFlagFromCode($code)
* @param string $label Continent code
* @return string Continent name
*/
-function Piwik_ContinentTranslate($label)
+function continentTranslate($label)
{
if ($label == 'unk' || $label == '') {
return Piwik_Translate('General_Unknown');
@@ -48,7 +53,7 @@ function Piwik_ContinentTranslate($label)
* @param string $label country code
* @return string Country name
*/
-function Piwik_CountryTranslate($label)
+function countryTranslate($label)
{
if ($label == Visit::UNKNOWN_CODE || $label == '') {
return Piwik_Translate('General_Unknown');
@@ -67,7 +72,7 @@ function Piwik_CountryTranslate($label)
* @return string|false Returns false if $label == DataTable::LABEL_SUMMARY_ROW, otherwise
* explode($separator, $label)[$index].
*/
-function Piwik_UserCountry_getElementFromStringArray($label, $separator, $index, $emptyValue = false)
+function getElementFromStringArray($label, $separator, $index, $emptyValue = false)
{
if ($label == DataTable::LABEL_SUMMARY_ROW) {
return false; // so no metadata/column is added
@@ -84,7 +89,7 @@ function Piwik_UserCountry_getElementFromStringArray($label, $separator, $index,
* 'P3|GB'.
* @return string|false The region name or false if $label == DataTable::LABEL_SUMMARY_ROW.
*/
-function Piwik_UserCountry_getRegionName($label)
+function getRegionName($label)
{
if ($label == DataTable::LABEL_SUMMARY_ROW) {
return false; // so no metadata/column is added
@@ -94,8 +99,8 @@ function Piwik_UserCountry_getRegionName($label)
return Piwik_Translate('General_Unknown');
}
- list($regionCode, $countryCode) = explode(Piwik_UserCountry_Archiver::LOCATION_SEPARATOR, $label);
- return Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
+ list($regionCode, $countryCode) = explode(Archiver::LOCATION_SEPARATOR, $label);
+ return GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
}
/**
@@ -106,7 +111,7 @@ function Piwik_UserCountry_getRegionName($label)
* 'P3|GB'.
* @return string|false eg. 'Ile de France, France' or false if $label == DataTable::LABEL_SUMMARY_ROW.
*/
-function Piwik_UserCountry_getPrettyRegionName($label)
+function getPrettyRegionName($label)
{
if ($label == DataTable::LABEL_SUMMARY_ROW) {
return $label;
@@ -116,11 +121,11 @@ function Piwik_UserCountry_getPrettyRegionName($label)
return Piwik_Translate('General_Unknown');
}
- list($regionCode, $countryCode) = explode(Piwik_UserCountry_Archiver::LOCATION_SEPARATOR, $label);
+ list($regionCode, $countryCode) = explode(Archiver::LOCATION_SEPARATOR, $label);
- $result = Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
+ $result = GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
if ($countryCode != Visit::UNKNOWN_CODE && $countryCode != '') {
- $result .= ', ' . Piwik_CountryTranslate($countryCode);
+ $result .= ', ' . countryTranslate($countryCode);
}
return $result;
}
@@ -134,7 +139,7 @@ function Piwik_UserCountry_getPrettyRegionName($label)
* @return string|false eg. 'Paris, Ile de France, France' or false if $label ==
* DataTable::LABEL_SUMMARY_ROW.
*/
-function Piwik_UserCountry_getPrettyCityName($label)
+function getPrettyCityName($label)
{
if ($label == DataTable::LABEL_SUMMARY_ROW) {
return $label;
@@ -145,7 +150,7 @@ function Piwik_UserCountry_getPrettyCityName($label)
}
// get city name, region code & country code
- $parts = explode(Piwik_UserCountry_Archiver::LOCATION_SEPARATOR, $label);
+ $parts = explode(Archiver::LOCATION_SEPARATOR, $label);
$cityName = $parts[0];
$regionCode = $parts[1];
$countryCode = @$parts[2];
@@ -157,10 +162,10 @@ function Piwik_UserCountry_getPrettyCityName($label)
$result = $cityName;
if ($countryCode != Visit::UNKNOWN_CODE && $countryCode != '') {
if ($regionCode != '' && $regionCode != Visit::UNKNOWN_CODE) {
- $regionName = Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
+ $regionName = GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
$result .= ', ' . $regionName;
}
- $result .= ', ' . Piwik_CountryTranslate($countryCode);
+ $result .= ', ' . countryTranslate($countryCode);
}
return $result;
}
diff --git a/plugins/UserCountryMap/Controller.php b/plugins/UserCountryMap/Controller.php
index 1470a5e4cff..187aeb93026 100644
--- a/plugins/UserCountryMap/Controller.php
+++ b/plugins/UserCountryMap/Controller.php
@@ -6,12 +6,15 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountryMap
+ * @package UserCountryMap
*/
+namespace Piwik\Plugins\UserCountryMap;
+
+use Exception;
use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\Goals\API;
use Piwik\ViewDataTable;
use Piwik\View;
use Piwik\Site;
@@ -19,9 +22,9 @@
/**
*
- * @package Piwik_UserCountryMap
+ * @package UserCountryMap
*/
-class Piwik_UserCountryMap_Controller extends Controller
+class Controller extends \Piwik\Controller
{
// By default plot up to the last 30 days of visitors on the map, for low traffic sites
@@ -63,16 +66,16 @@ public function visitorMap()
// some translations
$view->localeJSON = Common::json_encode(array(
- 'nb_visits' => Piwik_Translate('VisitsSummary_NbVisits'),
- 'one_visit' => Piwik_Translate('General_OneVisit'),
- 'no_visit' => Piwik_Translate('UserCountryMap_NoVisit'),
- 'nb_actions' => Piwik_Translate('VisitsSummary_NbActionsDescription'),
- 'nb_actions_per_visit' => Piwik_Translate('VisitsSummary_NbActionsPerVisit'),
- 'bounce_rate' => Piwik_Translate('VisitsSummary_NbVisitsBounced'),
- 'avg_time_on_site' => Piwik_Translate('VisitsSummary_AverageVisitDuration'),
- 'and_n_others' => Piwik_Translate('UserCountryMap_AndNOthers'),
- 'no_data' => Piwik_Translate('CoreHome_ThereIsNoDataForThisReport')
- ));
+ 'nb_visits' => Piwik_Translate('VisitsSummary_NbVisits'),
+ 'one_visit' => Piwik_Translate('General_OneVisit'),
+ 'no_visit' => Piwik_Translate('UserCountryMap_NoVisit'),
+ 'nb_actions' => Piwik_Translate('VisitsSummary_NbActionsDescription'),
+ 'nb_actions_per_visit' => Piwik_Translate('VisitsSummary_NbActionsPerVisit'),
+ 'bounce_rate' => Piwik_Translate('VisitsSummary_NbVisitsBounced'),
+ 'avg_time_on_site' => Piwik_Translate('VisitsSummary_AverageVisitDuration'),
+ 'and_n_others' => Piwik_Translate('UserCountryMap_AndNOthers'),
+ 'no_data' => Piwik_Translate('CoreHome_ThereIsNoDataForThisReport')
+ ));
$view->reqParamsJSON = $this->getEnrichedRequest($params = array(
'period' => $period,
@@ -119,7 +122,7 @@ public function realtimeMap($standalone = false)
$view->defaultMetric = 'nb_visits';
$view->liveRefreshAfterMs = (int)Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000;
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
$site = new Site($idSite);
$view->hasGoals = !empty($goals) || $site->isEcommerceEnabled() ? 'true' : 'false';
@@ -144,11 +147,11 @@ public function realtimeMap($standalone = false)
));
$view->reqParamsJSON = $this->getEnrichedRequest(array(
- 'period' => 'range',
- 'idSite' => $idSite,
- 'date' => self::REAL_TIME_WINDOW,
- 'token_auth' => $token_auth,
- ));
+ 'period' => 'range',
+ 'idSite' => $idSite,
+ 'date' => self::REAL_TIME_WINDOW,
+ 'token_auth' => $token_auth,
+ ));
echo $view->render();
}
@@ -158,14 +161,13 @@ private function getEnrichedRequest($params)
$params['format'] = 'json';
$params['showRawMetrics'] = 1;
$segment = \Piwik\API\Request::getRawSegmentFromRequest();
- if(!empty($segment)) {
+ if (!empty($segment)) {
$params['segment'] = $segment;
}
return Common::json_encode($params);
}
-
private function checkUserCountryPluginEnabled()
{
if (!\Piwik\PluginsManager::getInstance()->isPluginActivated('UserCountry')) {
@@ -226,5 +228,4 @@ private function _report($module, $action, $idSite, $period, $date, $token_auth,
{
return $this->getApiRequestUrl('API', 'getProcessedReport&apiModule=' . $module . '&apiAction=' . $action, $idSite, $period, $date, $token_auth, $filter_by_country);
}
-
}
diff --git a/plugins/UserCountryMap/UserCountryMap.php b/plugins/UserCountryMap/UserCountryMap.php
index 19e0c345907..66da62b1370 100644
--- a/plugins/UserCountryMap/UserCountryMap.php
+++ b/plugins/UserCountryMap/UserCountryMap.php
@@ -6,18 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountryMap
+ * @package UserCountryMap
*/
+namespace Piwik\Plugins\UserCountryMap;
+
use Piwik\FrontController;
use Piwik\Version;
use Piwik\WidgetsList;
-use Piwik\Plugin;
/**
*
- * @package Piwik_UserCountryMap
+ * @package UserCountryMap
*/
-class Piwik_UserCountryMap extends Plugin
+class UserCountryMap extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getInformation
@@ -38,7 +39,7 @@ public function postLoad()
WidgetsList::add('General_Visitors', Piwik_Translate('UserCountryMap_VisitorMap'), 'UserCountryMap', 'visitorMap');
WidgetsList::add('Live!', Piwik_Translate('UserCountryMap_RealTimeMap'), 'UserCountryMap', 'realtimeMap');
- Piwik_AddAction('template_leftColumnUserCountry', array('Piwik_UserCountryMap', 'insertMapInLocationReport'));
+ Piwik_AddAction('template_leftColumnUserCountry', array('Piwik\Plugins\UserCountryMap\UserCountryMap', 'insertMapInLocationReport'));
}
static public function insertMapInLocationReport(&$out)
diff --git a/plugins/UserSettings/API.php b/plugins/UserSettings/API.php
index c1c5535c1cb..9e0fdf12f39 100644
--- a/plugins/UserSettings/API.php
+++ b/plugins/UserSettings/API.php
@@ -6,12 +6,15 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
+namespace Piwik\Plugins\UserSettings;
+
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\DataTable;
+use Piwik\Plugins\UserSettings\Archiver;
/**
* @see plugins/UserSettings/functions.php
@@ -22,9 +25,9 @@
* The UserSettings API lets you access reports about your Visitors technical settings: browsers, browser types (rendering engine),
* operating systems, plugins supported in their browser, Screen resolution and Screen types (normal, widescreen, dual screen or mobile).
*
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
-class Piwik_UserSettings_API
+class API
{
static private $instance = null;
@@ -49,27 +52,27 @@ protected function getDataTable($name, $idSite, $period, $date, $segment)
public function getResolution($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::RESOLUTION_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::RESOLUTION_RECORD_NAME, $idSite, $period, $date, $segment);
return $dataTable;
}
public function getConfiguration($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::CONFIGURATION_RECORD_NAME, $idSite, $period, $date, $segment);
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getConfigurationLabel'));
+ $dataTable = $this->getDataTable(Archiver::CONFIGURATION_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getConfigurationLabel'));
return $dataTable;
}
public function getOS($idSite, $period, $date, $segment = false, $addShortLabel = true)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::OS_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::OS_RECORD_NAME, $idSite, $period, $date, $segment);
// these filters are applied directly so other API methods can use GroupBy on the result of this method
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getOSLogo'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOSLogo'));
if ($addShortLabel) {
$dataTable->filter(
- 'ColumnCallbackAddMetadata', array('label', 'shortLabel', 'Piwik_getOSShortLabel'));
+ 'ColumnCallbackAddMetadata', array('label', 'shortLabel', __NAMESPACE__ . '\getOSShortLabel'));
}
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getOSLabel'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getOSLabel'));
return $dataTable;
}
@@ -80,7 +83,7 @@ public function getOS($idSite, $period, $date, $segment = false, $addShortLabel
public function getOSFamily($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getOS($idSite, $period, $date, $segment, $addShortLabel = false);
- $dataTable->filter('GroupBy', array('label', 'Piwik_UserSettings_getOSFamily'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getOSFamily'));
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_Translate'));
return $dataTable;
}
@@ -91,12 +94,12 @@ public function getOSFamily($idSite, $period, $date, $segment = false)
public function getMobileVsDesktop($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getOS($idSite, $period, $date, $segment, $addShortLabel = false);
- $dataTable->filter('GroupBy', array('label', 'Piwik_UserSettings_getDeviceTypeFromOS'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getDeviceTypeFromOS'));
$this->ensureDefaultRowsInTable($dataTable);
// set the logo metadata
$dataTable->queueFilter('MetadataCallbackReplace',
- array('logo', 'Piwik_UserSettings_getDeviceTypeImg', null, array('label')));
+ array('logo', __NAMESPACE__ . '\getDeviceTypeImg', null, array('label')));
// translate the labels
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_Translate'));
@@ -133,15 +136,15 @@ protected function ensureDefaultRowsInTable($dataTable)
public function getBrowserVersion($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getBrowserTable($idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'shortLabel', 'Piwik_getBrowserShortLabel'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'shortLabel', __NAMESPACE__ . '\getBrowserShortLabel'));
return $dataTable;
}
protected function getBrowserTable($idSite, $period, $date, $segment)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::BROWSER_RECORD_NAME, $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getBrowsersLogo'));
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getBrowserLabel'));
+ $dataTable = $this->getDataTable(Archiver::BROWSER_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowsersLogo'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getBrowserLabel'));
return $dataTable;
}
@@ -152,22 +155,22 @@ protected function getBrowserTable($idSite, $period, $date, $segment)
public function getBrowser($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getBrowserTable($idSite, $period, $date, $segment);
- $dataTable->filter('GroupBy', array('label', 'Piwik_UserSettings_getBrowserFromBrowserVersion'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserFromBrowserVersion'));
return $dataTable;
}
public function getBrowserType($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::BROWSER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::BROWSER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
$dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'shortLabel', 'ucfirst'));
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getBrowserTypeLabel'));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getBrowserTypeLabel'));
return $dataTable;
}
public function getWideScreen($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::SCREEN_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getScreensLogo'));
+ $dataTable = $this->getDataTable(Archiver::SCREEN_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getScreensLogo'));
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'ucfirst'));
return $dataTable;
}
@@ -175,8 +178,8 @@ public function getWideScreen($idSite, $period, $date, $segment = false)
public function getPlugin($idSite, $period, $date, $segment = false)
{
// fetch all archive data required
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::PLUGIN_RECORD_NAME, $idSite, $period, $date, $segment);
- $browserTypes = $this->getDataTable(Piwik_UserSettings_Archiver::BROWSER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::PLUGIN_RECORD_NAME, $idSite, $period, $date, $segment);
+ $browserTypes = $this->getDataTable(Archiver::BROWSER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
$archive = Archive::build($idSite, $period, $date, $segment);
$visitsSums = $archive->getDataTableFromNumeric('nb_visits');
@@ -225,7 +228,6 @@ public function getPlugin($idSite, $period, $date, $segment = false)
$visitsSum = $visitsSumTotal - $ieVisits;
-
// When Truncate filter is applied, it will call AddSummaryRow which tries to sum all rows.
// We tell the object to skip the column nb_visits_percentage when aggregating (since it's not correct to sum % values)
$table->setColumnAggregationOperation('nb_visits_percentage', 'skip');
@@ -236,7 +238,7 @@ public function getPlugin($idSite, $period, $date, $segment = false)
$table->filter('RangeCheck', array('nb_visits_percentage'));
}
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getPluginsLogo'));
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getPluginsLogo'));
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'ucfirst'));
return $dataTable;
@@ -244,8 +246,8 @@ public function getPlugin($idSite, $period, $date, $segment = false)
public function getLanguage($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::LANGUAGE_RECORD_NAME, $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_LanguageTranslate'));
+ $dataTable = $this->getDataTable(Archiver::LANGUAGE_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\languageTranslate'));
$dataTable->filter('ReplaceColumnNames');
return $dataTable;
}
diff --git a/plugins/UserSettings/Archiver.php b/plugins/UserSettings/Archiver.php
index d6ff51d459a..d25420ec200 100644
--- a/plugins/UserSettings/Archiver.php
+++ b/plugins/UserSettings/Archiver.php
@@ -6,9 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
+namespace Piwik\Plugins\UserSettings;
+
use Piwik\Common;
use Piwik\DataAccess\LogAggregator;
use Piwik\Metrics;
@@ -23,7 +25,7 @@
*
* @see PluginsArchiver
*/
-class Piwik_UserSettings_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const LANGUAGE_RECORD_NAME = 'UserSettings_language';
const PLUGIN_RECORD_NAME = 'UserSettings_plugin';
@@ -80,7 +82,7 @@ protected function aggregateByBrowserVersion()
protected function aggregateByBrowserType(DataTable $tableBrowser)
{
- $tableBrowser->filter('GroupBy', array('label', 'Piwik_getBrowserFamily'));
+ $tableBrowser->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserFamily'));
$this->insertTable(self::BROWSER_TYPE_RECORD_NAME, $tableBrowser);
}
@@ -94,14 +96,14 @@ protected function aggregateByResolution()
{
$metrics = $this->getProcessor()->getMetricsForDimension(self::RESOLUTION_DIMENSION);
$table = $this->getProcessor()->getDataTableFromDataArray($metrics);
- $table->filter('ColumnCallbackDeleteRow', array('label', 'Piwik_UserSettings_keepStrlenGreater'));
+ $table->filter('ColumnCallbackDeleteRow', array('label', __NAMESPACE__ . '\keepStrlenGreater'));
$this->insertTable(self::RESOLUTION_RECORD_NAME, $table);
return $table;
}
protected function aggregateByScreenType(DataTable $resolutions)
{
- $resolutions->filter('GroupBy', array('label', 'Piwik_getScreenTypeFromResolution'));
+ $resolutions->filter('GroupBy', array('label', __NAMESPACE__ . '\getScreenTypeFromResolution'));
$this->insertTable(self::SCREEN_TYPE_RECORD_NAME, $resolutions);
}
@@ -129,7 +131,7 @@ protected function aggregateByPlugin()
protected function aggregateByLanguage()
{
- $query = $this->getLogAggregator()->queryVisitsByDimension( array("label" => self::LANGUAGE_DIMENSION) );
+ $query = $this->getLogAggregator()->queryVisitsByDimension(array("label" => self::LANGUAGE_DIMENSION));
$languageCodes = array_keys(Common::getLanguagesList());
$metricsByLanguage = new DataArray();
while ($row = $query->fetch()) {
diff --git a/plugins/UserSettings/Controller.php b/plugins/UserSettings/Controller.php
index b5180359f83..3bdd3e8f5dc 100644
--- a/plugins/UserSettings/Controller.php
+++ b/plugins/UserSettings/Controller.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\UserSettings;
+
use Piwik\ViewDataTable;
use Piwik\View;
/**
*
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
-class Piwik_UserSettings_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
@@ -33,12 +34,12 @@ public function index()
echo $view->render();
}
-
+
public function getResolution($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
}
-
+
public function getConfiguration($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php
index 3795d0d6fd2..f6dd1d8a7ea 100644
--- a/plugins/UserSettings/UserSettings.php
+++ b/plugins/UserSettings/UserSettings.php
@@ -6,17 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
+namespace Piwik\Plugins\UserSettings;
+
use Piwik\ArchiveProcessor;
-use Piwik\Plugin;
+use Piwik\Plugins\UserSettings\Archiver;
use Piwik\WidgetsList;
/**
*
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
-class Piwik_UserSettings extends Plugin
+class UserSettings extends \Piwik\Plugin
{
/**
* Mapping between the browser family shortcode and the displayed name
@@ -172,104 +174,104 @@ public function getListHooksRegistered()
);
return $hooks;
}
-
+
public function getReportDisplayProperties(&$properties)
{
$basicUserSettingsProperties = array('show_search' => false,
'show_exclude_low_population' => false,
'filter_limit' => 5,
'graph_limit' => 5);
-
+
$osRelatedReports = array(
'UserSettings.getOSFamily' => Piwik_Translate('UserSettings_OperatingSystemFamily'),
'UserSettings.getOS' => Piwik_Translate('UserSettings_OperatingSystems')
);
-
+
$browserRelatedReports = array(
- 'UserSettings.getBrowser' => Piwik_Translate('UserSettings_Browsers'),
+ 'UserSettings.getBrowser' => Piwik_Translate('UserSettings_Browsers'),
'UserSettings.getBrowserVersion' => Piwik_Translate('UserSettings_ColumnBrowserVersion')
);
-
+
$wideScreenDeviceTypeRelatedReports = array(
'UserSettings.getMobileVsDesktop' => Piwik_Translate('UserSettings_MobileVsDesktop'),
- 'UserSettings.getWideScreen' => Piwik_Translate('UserSettings_ColumnTypeOfScreen')
+ 'UserSettings.getWideScreen' => Piwik_Translate('UserSettings_ColumnTypeOfScreen')
);
-
+
$properties['UserSettings.getResolution'] = array_merge($basicUserSettingsProperties, array(
- 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnResolution'))
- ));
-
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnResolution'))
+ ));
+
$properties['UserSettings.getConfiguration'] = array_merge($basicUserSettingsProperties, array(
- 'filter_limit' => 3,
- 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnConfiguration'))
- ));
-
+ 'filter_limit' => 3,
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnConfiguration'))
+ ));
+
$properties['UserSettings.getOS'] = array_merge($basicUserSettingsProperties, array(
- 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnOperatingSystem')),
- 'title' => Piwik_Translate('UserSettings_OperatingSystems'),
- 'relatedReports' => $osRelatedReports
- ));
-
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnOperatingSystem')),
+ 'title' => Piwik_Translate('UserSettings_OperatingSystems'),
+ 'relatedReports' => $osRelatedReports
+ ));
+
$properties['UserSettings.getOSFamily'] = array_merge($basicUserSettingsProperties, array(
- 'translations' => array('label' => Piwik_Translate('UserSettings_OperatingSystemFamily')),
- 'title' => Piwik_Translate('UserSettings_OperatingSystemFamily'),
- 'relatedReports' => $osRelatedReports
- ));
-
+ 'translations' => array('label' => Piwik_Translate('UserSettings_OperatingSystemFamily')),
+ 'title' => Piwik_Translate('UserSettings_OperatingSystemFamily'),
+ 'relatedReports' => $osRelatedReports
+ ));
+
$properties['UserSettings.getBrowserVersion'] = array_merge($basicUserSettingsProperties, array(
- 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnBrowserVersion')),
- 'graph_limit' => 7,
- 'title' => Piwik_Translate('UserSettings_ColumnBrowserVersion'),
- 'relatedReports' => $browserRelatedReports
- ));
-
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnBrowserVersion')),
+ 'graph_limit' => 7,
+ 'title' => Piwik_Translate('UserSettings_ColumnBrowserVersion'),
+ 'relatedReports' => $browserRelatedReports
+ ));
+
$properties['UserSettings.getBrowser'] = array_merge($basicUserSettingsProperties, array(
- 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnBrowser')),
- 'graph_limit' => 7,
- 'title' => Piwik_Translate('UserSettings_Browsers'),
- 'relatedReports' => $browserRelatedReports
- ));
-
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnBrowser')),
+ 'graph_limit' => 7,
+ 'title' => Piwik_Translate('UserSettings_Browsers'),
+ 'relatedReports' => $browserRelatedReports
+ ));
+
$properties['UserSettings.getBrowserType'] = array_merge($basicUserSettingsProperties, array(
- 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnBrowserFamily')),
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'default_view_type' => 'graphPie',
- ));
-
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnBrowserFamily')),
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'default_view_type' => 'graphPie',
+ ));
+
$properties['UserSettings.getWideScreen'] = array_merge($basicUserSettingsProperties, array(
- 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnTypeOfScreen')),
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'title' => Piwik_Translate('UserSettings_ColumnTypeOfScreen'),
- 'relatedReports' => $wideScreenDeviceTypeRelatedReports
- ));
-
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnTypeOfScreen')),
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'title' => Piwik_Translate('UserSettings_ColumnTypeOfScreen'),
+ 'relatedReports' => $wideScreenDeviceTypeRelatedReports
+ ));
+
$properties['UserSettings.getMobileVsDesktop'] = array_merge($basicUserSettingsProperties, array(
- 'translations' => array('label' => Piwik_Translate('UserSettings_MobileVsDesktop')),
- 'title' => Piwik_Translate('UserSettings_MobileVsDesktop'),
- 'relatedReports' => $wideScreenDeviceTypeRelatedReports
- ));
-
+ 'translations' => array('label' => Piwik_Translate('UserSettings_MobileVsDesktop')),
+ 'title' => Piwik_Translate('UserSettings_MobileVsDesktop'),
+ 'relatedReports' => $wideScreenDeviceTypeRelatedReports
+ ));
+
$properties['UserSettings.getPlugin'] = array_merge($basicUserSettingsProperties, array(
- 'translations' => array(
- 'label' => Piwik_Translate('UserSettings_ColumnPlugin'),
- 'nb_visits_percentage' =>
- str_replace(' ', ' ', Piwik_Translate('General_ColumnPercentageVisits'))
- ),
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'show_all_views_icons' => false,
- 'show_table_all_columns' => false,
- 'columns_to_display' => array('label', 'nb_visits_percentage', 'nb_visits'),
- 'filter_sort_column' => 'nb_visits_percentage',
- 'filter_sort_order' => 'desc',
- 'filter_limit' => 10,
- 'show_footer_message' => Piwik_Translate('UserSettings_PluginDetectionDoesNotWorkInIE'),
- ));
-
+ 'translations' => array(
+ 'label' => Piwik_Translate('UserSettings_ColumnPlugin'),
+ 'nb_visits_percentage' =>
+ str_replace(' ', ' ', Piwik_Translate('General_ColumnPercentageVisits'))
+ ),
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'show_all_views_icons' => false,
+ 'show_table_all_columns' => false,
+ 'columns_to_display' => array('label', 'nb_visits_percentage', 'nb_visits'),
+ 'filter_sort_column' => 'nb_visits_percentage',
+ 'filter_sort_order' => 'desc',
+ 'filter_limit' => 10,
+ 'show_footer_message' => Piwik_Translate('UserSettings_PluginDetectionDoesNotWorkInIE'),
+ ));
+
$properties['UserSettings.getLanguage'] = array(
- 'translations' => array('label' => Piwik_Translate('General_Language')),
+ 'translations' => array('label' => Piwik_Translate('General_Language')),
'filter_sort_column' => 'nb_visits',
'filter_sort_order' => 'desc',
'show_search' => false,
@@ -369,8 +371,8 @@ function addMenu()
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_UserSettings_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
@@ -380,8 +382,8 @@ public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
*/
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_UserSettings_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
diff --git a/plugins/UserSettings/functions.php b/plugins/UserSettings/functions.php
index 41269b773bf..28215d2e44d 100644
--- a/plugins/UserSettings/functions.php
+++ b/plugins/UserSettings/functions.php
@@ -6,17 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
+
+namespace Piwik\Plugins\UserSettings;
+
use Piwik\Piwik;
+use Piwik\Plugins\UserSettings\UserSettings;
use Piwik\Tracker\Request;
+use UserAgentParser;
/**
* @see libs/UserAgentParser/UserAgentParser.php
*/
require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php';
-function Piwik_getPluginsLogo($oldLabel)
+function getPluginsLogo($oldLabel)
{
if($oldLabel == Piwik_Translate('General_Others')) {
return false;
@@ -24,7 +29,7 @@ function Piwik_getPluginsLogo($oldLabel)
return 'plugins/UserSettings/images/plugins/' . $oldLabel . '.gif';
}
-function Piwik_getOSLabel($osId)
+function getOSLabel($osId)
{
$osName = UserAgentParser::getOperatingSystemNameFromId($osId);
if ($osName !== false) {
@@ -36,7 +41,7 @@ function Piwik_getOSLabel($osId)
return $osId;
}
-function Piwik_getOSShortLabel($osId)
+function getOSShortLabel($osId)
{
$osShortName = UserAgentParser::getOperatingSystemShortNameFromId($osId);
if ($osShortName !== false) {
@@ -49,7 +54,7 @@ function Piwik_getOSShortLabel($osId)
}
-function Piwik_UserSettings_getOSFamily($osLabel)
+function getOSFamily($osLabel)
{
$osId = UserAgentParser::getOperatingSystemIdFromName($osLabel);
$osFamily = UserAgentParser::getOperatingSystemFamilyFromId($osId);
@@ -63,7 +68,7 @@ function Piwik_UserSettings_getOSFamily($osLabel)
return $osFamily;
}
-function Piwik_UserSettings_getDeviceTypeFromOS($osLabel)
+function getDeviceTypeFromOS($osLabel)
{
$osId = UserAgentParser::getOperatingSystemIdFromName($osLabel);
$osFamily = UserAgentParser::getOperatingSystemFamilyFromId($osId);
@@ -88,10 +93,10 @@ function Piwik_UserSettings_getDeviceTypeFromOS($osLabel)
}
}
-function Piwik_getBrowserTypeLabel($oldLabel)
+function getBrowserTypeLabel($oldLabel)
{
- if (isset(Piwik_UserSettings::$browserType_display[$oldLabel])) {
- return Piwik_UserSettings::$browserType_display[$oldLabel];
+ if (isset(UserSettings::$browserType_display[$oldLabel])) {
+ return UserSettings::$browserType_display[$oldLabel];
}
if ($oldLabel == 'unknown') {
return Piwik_Translate('General_Unknown');
@@ -100,14 +105,14 @@ function Piwik_getBrowserTypeLabel($oldLabel)
}
-function Piwik_getConfigurationLabel($str)
+function getConfigurationLabel($str)
{
if (strpos($str, ';') === false) {
return $str;
}
$values = explode(";", $str);
- $os = Piwik_getOSLabel($values[0]);
+ $os = getOSLabel($values[0]);
$name = $values[1];
$browser = UserAgentParser::getBrowserNameFromId($name);
if ($browser === false) {
@@ -117,10 +122,10 @@ function Piwik_getConfigurationLabel($str)
return $os . " / " . $browser . " / " . $resolution;
}
-function Piwik_getBrowserLabel($oldLabel)
+function getBrowserLabel($oldLabel)
{
- $browserId = Piwik_getBrowserId($oldLabel);
- $version = Piwik_getBrowserVersion($oldLabel);
+ $browserId = getBrowserId($oldLabel);
+ $version = getBrowserVersion($oldLabel);
$browserName = UserAgentParser::getBrowserNameFromId($browserId);
if ($browserName !== false) {
return $browserName . " " . $version;
@@ -131,10 +136,10 @@ function Piwik_getBrowserLabel($oldLabel)
return $oldLabel;
}
-function Piwik_getBrowserShortLabel($oldLabel)
+function getBrowserShortLabel($oldLabel)
{
- $browserId = Piwik_getBrowserId($oldLabel);
- $version = Piwik_getBrowserVersion($oldLabel);
+ $browserId = getBrowserId($oldLabel);
+ $version = getBrowserVersion($oldLabel);
$browserName = UserAgentParser::getBrowserShortNameFromId($browserId);
if ($browserName !== false) {
return $browserName . " " . $version;
@@ -145,17 +150,17 @@ function Piwik_getBrowserShortLabel($oldLabel)
return $oldLabel;
}
-function Piwik_getBrowserId($str)
+function getBrowserId($str)
{
return substr($str, 0, strpos($str, ';'));
}
-function Piwik_getBrowserVersion($str)
+function getBrowserVersion($str)
{
return substr($str, strpos($str, ';') + 1);
}
-function Piwik_getLogoImageFromId($dir, $id)
+function getLogoImageFromId($dir, $id)
{
$path = $dir.'/'.$id.'.gif';
if (file_exists(PIWIK_INCLUDE_PATH . '/' . $path)) {
@@ -165,31 +170,31 @@ function Piwik_getLogoImageFromId($dir, $id)
}
}
-function Piwik_getBrowsersLogo($label)
+function getBrowsersLogo($label)
{
- $id = Piwik_getBrowserId($label);
+ $id = getBrowserId($label);
// For aggregated row 'Others'
if (empty($id)) {
$id = 'UNK';
}
- return Piwik_getLogoImageFromId('plugins/UserSettings/images/browsers', $id);
+ return getLogoImageFromId('plugins/UserSettings/images/browsers', $id);
}
-function Piwik_getOSLogo($label)
+function getOSLogo($label)
{
// For aggregated row 'Others'
if (empty($label)) {
$label = 'UNK';
}
- return Piwik_getLogoImageFromId('plugins/UserSettings/images/os', $label);
+ return getLogoImageFromId('plugins/UserSettings/images/os', $label);
}
-function Piwik_getScreensLogo($label)
+function getScreensLogo($label)
{
return 'plugins/UserSettings/images/screens/' . $label . '.gif';
}
-function Piwik_UserSettings_getDeviceTypeImg($oldOSImage, $osFamilyLabel)
+function getDeviceTypeImg($oldOSImage, $osFamilyLabel)
{
switch ($osFamilyLabel) {
case 'General_Desktop':
@@ -202,12 +207,12 @@ function Piwik_UserSettings_getDeviceTypeImg($oldOSImage, $osFamilyLabel)
}
}
-function Piwik_UserSettings_keepStrlenGreater($value)
+function keepStrlenGreater($value)
{
return strlen($value) > 5;
}
-function Piwik_getScreenTypeFromResolution($resolution)
+function getScreenTypeFromResolution($resolution)
{
if ($resolution === Request::UNKNOWN_RESOLUTION) {
return $resolution;
@@ -229,7 +234,7 @@ function Piwik_getScreenTypeFromResolution($resolution)
return $name;
}
-function Piwik_getBrowserFamily($browserLabel)
+function getBrowserFamily($browserLabel)
{
$familyNameToUse = UserAgentParser::getBrowserFamilyFromId(substr($browserLabel, 0, 2));
return $familyNameToUse;
@@ -238,7 +243,7 @@ function Piwik_getBrowserFamily($browserLabel)
/**
* Extracts the browser name from a string with the browser name and version.
*/
-function Piwik_UserSettings_getBrowserFromBrowserVersion($browserWithVersion)
+function getBrowserFromBrowserVersion($browserWithVersion)
{
if (preg_match("/(.+) [0-9]+(?:\.[0-9]+)?$/", $browserWithVersion, $matches) === 0) {
return $browserWithVersion;
@@ -254,7 +259,7 @@ function Piwik_UserSettings_getBrowserFromBrowserVersion($browserWithVersion)
*
* @return string
*/
-function Piwik_LanguageTranslate($label)
+function languageTranslate($label)
{
if ($label == '' || $label == 'xx') {
return Piwik_Translate('General_Unknown');
diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php
index 9c9c1a776eb..a960d847621 100644
--- a/plugins/UsersManager/API.php
+++ b/plugins/UsersManager/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
+namespace Piwik\Plugins\UsersManager;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
@@ -16,6 +19,7 @@
use Piwik\Site;
use Piwik\Db;
use Piwik\Tracker\Cache;
+use Piwik\Plugins\UsersManager\UsersManager;
/**
* The UsersManager API lets you Manage Users and their permissions to access specific websites.
@@ -28,13 +32,13 @@
* or you can list all users and websites for a given permission via "getUsersSitesFromAccess". Permissions are set and updated
* via the method "setUserAccess".
* See also the documentation about Managing Users in Piwik.
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
-class Piwik_UsersManager_API
+class API
{
const PREFERENCE_DEFAULT_REPORT = 'defaultReport';
const PREFERENCE_DEFAULT_REPORT_DATE = 'defaultReportDate';
-
+
static private $instance = null;
/**
@@ -45,15 +49,15 @@ class Piwik_UsersManager_API
* \Zend_Registry::set('UsersManager_API',Piwik_MyCustomUsersManager_API::getInstance());
*
* @throws Exception
- * @return Piwik_UsersManager_API
+ * @return \Piwik\Plugins\UsersManager\API
*/
static public function getInstance()
{
try {
$instance = \Zend_Registry::get('UsersManager_API');
- if (!($instance instanceof Piwik_UsersManager_API)) {
+ if (!($instance instanceof API)) {
// Exception is caught below and corrected
- throw new Exception('UsersManager_API must inherit Piwik_UsersManager_API');
+ throw new Exception('UsersManager_API must inherit API');
}
self::$instance = $instance;
} catch (Exception $e) {
@@ -85,7 +89,7 @@ public function setUserPreference($userLogin, $preferenceName, $preferenceValue)
public function getUserPreference($userLogin, $preferenceName)
{
Piwik::checkUserIsSuperUserOrTheUser($userLogin);
-
+
$optionValue = Piwik_GetOption($this->getPreferenceId($userLogin, $preferenceName));
if ($optionValue !== false) {
return $optionValue;
@@ -97,12 +101,12 @@ private function getPreferenceId($login, $preference)
{
return $login . '_' . $preference;
}
-
+
private function getDefaultUserPreference($preferenceName, $login)
{
switch ($preferenceName) {
case self::PREFERENCE_DEFAULT_REPORT:
- $viewableSiteIds = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess($login);
+ $viewableSiteIds = \Piwik\Plugins\SitesManager\API::getInstance()->getSitesIdWithAtLeastViewAccess($login);
return reset($viewableSiteIds);
case self::PREFERENCE_DEFAULT_REPORT_DATE:
return Config::getInstance()->General['default_day'];
@@ -131,7 +135,7 @@ public function getUsers($userLogins = '')
$db = \Zend_Registry::get('db');
$users = $db->fetchAll("SELECT *
FROM " . Common::prefixTable("user") . "
- $where
+ $where
ORDER BY login ASC", $bind);
// Non Super user can only access login & alias
if (!Piwik::isUserIsSuperUser()) {
@@ -193,7 +197,6 @@ public function getUsersSitesFromAccess($access)
$return[$user['login']][] = $user['idsite'];
}
return $return;
-
}
/**
@@ -201,7 +204,7 @@ public function getUsersSitesFromAccess($access)
* If a user doesn't have any access to the $idSite ('noaccess'),
* the user will not be in the returned array.
*
- * @param int website ID
+ * @param int $idSite Website ID
*
* @return array The returned array has the format
* array(
@@ -373,23 +376,23 @@ public function addUser($userLogin, $password, $email, $alias = false)
$this->checkEmail($email);
$password = Common::unsanitizeInputValue($password);
- Piwik_UsersManager::checkPassword($password);
+ UsersManager::checkPassword($password);
$alias = $this->getCleanAlias($alias, $userLogin);
- $passwordTransformed = Piwik_UsersManager::getPasswordHash($password);
+ $passwordTransformed = UsersManager::getPasswordHash($password);
$token_auth = $this->getTokenAuth($userLogin, $passwordTransformed);
$db = \Zend_Registry::get('db');
$db->insert(Common::prefixTable("user"), array(
- 'login' => $userLogin,
- 'password' => $passwordTransformed,
- 'alias' => $alias,
- 'email' => $email,
- 'token_auth' => $token_auth,
- 'date_registered' => Date::now()->getDatetime()
- )
+ 'login' => $userLogin,
+ 'password' => $passwordTransformed,
+ 'alias' => $alias,
+ 'email' => $email,
+ 'token_auth' => $token_auth,
+ 'date_registered' => Date::now()->getDatetime()
+ )
);
// we reload the access list which doesn't yet take in consideration this new user
@@ -420,8 +423,8 @@ public function updateUser($userLogin, $password = false, $email = false, $alias
} else {
$password = Common::unsanitizeInputValue($password);
if (!$_isPasswordHashed) {
- Piwik_UsersManager::checkPassword($password);
- $password = Piwik_UsersManager::getPasswordHash($password);
+ UsersManager::checkPassword($password);
+ $password = UsersManager::getPasswordHash($password);
}
}
@@ -541,7 +544,7 @@ public function setUserAccess($userLogin, $access, $idSites)
// in case idSites is null we grant access to all the websites on which the current connected user
// has an 'admin' access
if ($idSites === 'all') {
- $idSites = Piwik_SitesManager_API::getInstance()->getSitesIdWithAdminAccess();
+ $idSites = \Piwik\Plugins\SitesManager\API::getInstance()->getSitesIdWithAdminAccess();
} // in case the idSites is an integer we build an array
else {
$idSites = Site::getIdSitesFromIdSitesString($idSites);
@@ -643,7 +646,6 @@ private function deleteUserOnly($userLogin)
Piwik_PostEvent('UsersManager.deleteUser', array($userLogin));
}
-
/**
* Delete the user access for the given websites.
* The array of idsite must be either null OR the values must have been checked before for their validity!
diff --git a/plugins/UsersManager/Controller.php b/plugins/UsersManager/Controller.php
index bedf2bb5fb0..1ead3ed8eb1 100644
--- a/plugins/UsersManager/Controller.php
+++ b/plugins/UsersManager/Controller.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
+namespace Piwik\Plugins\UsersManager;
+
+use Exception;
use Piwik\API\ResponseBuilder;
use Piwik\Controller\Admin;
use Piwik\Piwik;
@@ -17,12 +20,14 @@
use Piwik\View;
use Piwik\Url;
use Piwik\Site;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
/**
*
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
-class Piwik_UsersManager_Controller extends Admin
+class Controller extends Admin
{
static function orderByName($a, $b)
{
@@ -38,7 +43,7 @@ function index()
$view = new View('@UsersManager/index');
- $IdSitesAdmin = Piwik_SitesManager_API::getInstance()->getSitesIdWithAdminAccess();
+ $IdSitesAdmin = SitesManagerAPI::getInstance()->getSitesIdWithAdminAccess();
$idSiteSelected = 1;
if (count($IdSitesAdmin) > 0) {
@@ -50,13 +55,13 @@ function index()
$usersAccessByWebsite = array();
$defaultReportSiteName = Piwik_Translate('UsersManager_ApplyToAllWebsites');
} else {
- $usersAccessByWebsite = Piwik_UsersManager_API::getInstance()->getUsersAccessFromSite($idSiteSelected);
+ $usersAccessByWebsite = UsersManagerAPI::getInstance()->getUsersAccessFromSite($idSiteSelected);
$defaultReportSiteName = Site::getNameFor($idSiteSelected);
}
// we dont want to display the user currently logged so that the user can't change his settings from admin to view...
$currentlyLogged = Piwik::getCurrentUserLogin();
- $usersLogin = Piwik_UsersManager_API::getInstance()->getUsersLogin();
+ $usersLogin = UsersManagerAPI::getInstance()->getUsersLogin();
foreach ($usersLogin as $login) {
if (!isset($usersAccessByWebsite[$login])) {
$usersAccessByWebsite[$login] = 'noaccess';
@@ -64,7 +69,6 @@ function index()
}
unset($usersAccessByWebsite[$currentlyLogged]);
-
// $usersAccessByWebsite is not supposed to contain unexistant logins, but it does when upgrading from some old Piwik version
foreach ($usersAccessByWebsite as $login => $access) {
if (!in_array($login, $usersLogin)) {
@@ -78,7 +82,7 @@ function index()
$users = array();
$usersAliasByLogin = array();
if (Piwik::isUserHasSomeAdminAccess()) {
- $users = Piwik_UsersManager_API::getInstance()->getUsers();
+ $users = UsersManagerAPI::getInstance()->getUsers();
foreach ($users as $user) {
$usersAliasByLogin[$user['login']] = $user['alias'];
}
@@ -90,8 +94,8 @@ function index()
$view->usersAliasByLogin = $usersAliasByLogin;
$view->usersCount = count($users) - 1;
$view->usersAccessByWebsite = $usersAccessByWebsite;
- $websites = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
- uasort($websites, array('Piwik_UsersManager_Controller', 'orderByName'));
+ $websites = SitesManagerAPI::getInstance()->getSitesWithAdminAccess();
+ uasort($websites, array('Piwik\Plugins\UsersManager\Controller', 'orderByName'));
$view->websites = $websites;
$this->setBasicVariablesView($view);
echo $view->render();
@@ -118,7 +122,7 @@ private function hasAnonymousUserViewAccess($usersAccessByWebsite)
*/
protected function getDefaultDateForUser($user)
{
- return Piwik_UsersManager_API::getInstance()->getUserPreference($user, Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE);
+ return UsersManagerAPI::getInstance()->getUserPreference($user, UsersManagerAPI::PREFERENCE_DEFAULT_REPORT_DATE);
}
/**
@@ -135,14 +139,13 @@ public function userSettings()
$view->userAlias = $userLogin;
$view->userEmail = Piwik::getSuperUserEmail();
$this->displayWarningIfConfigFileNotWritable($view);
-
} else {
- $user = Piwik_UsersManager_API::getInstance()->getUser($userLogin);
+ $user = UsersManagerAPI::getInstance()->getUser($userLogin);
$view->userAlias = $user['alias'];
$view->userEmail = $user['email'];
}
- $defaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference($userLogin, Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
+ $defaultReport = UsersManagerAPI::getInstance()->getUserPreference($userLogin, UsersManagerAPI::PREFERENCE_DEFAULT_REPORT);
if ($defaultReport === false) {
$defaultReport = $this->getDefaultWebsiteId();
}
@@ -196,11 +199,11 @@ protected function initViewAnonymousUserSettings($view)
$userLogin = 'anonymous';
// Which websites are available to the anonymous users?
- $anonymousSitesAccess = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser($userLogin);
+ $anonymousSitesAccess = UsersManagerAPI::getInstance()->getSitesAccessFromUser($userLogin);
$anonymousSites = array();
foreach ($anonymousSitesAccess as $info) {
$idSite = $info['site'];
- $site = Piwik_SitesManager_API::getInstance()->getSiteFromId($idSite);
+ $site = SitesManagerAPI::getInstance()->getSiteFromId($idSite);
// Work around manual website deletion
if (!empty($site)) {
$anonymousSites[$idSite] = $site;
@@ -209,7 +212,7 @@ protected function initViewAnonymousUserSettings($view)
$view->anonymousSites = $anonymousSites;
// Which report is displayed by default to the anonymous user?
- $anonymousDefaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference($userLogin, Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
+ $anonymousDefaultReport = UsersManagerAPI::getInstance()->getUserPreference($userLogin, UsersManagerAPI::PREFERENCE_DEFAULT_REPORT);
if ($anonymousDefaultReport === false) {
if (empty($anonymousSites)) {
$anonymousDefaultReport = Piwik::getLoginPluginName();
@@ -239,11 +242,11 @@ public function recordAnonymousUserSettings()
$anonymousDefaultReport = Common::getRequestVar('anonymousDefaultReport');
$anonymousDefaultDate = Common::getRequestVar('anonymousDefaultDate');
$userLogin = 'anonymous';
- Piwik_UsersManager_API::getInstance()->setUserPreference($userLogin,
- Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT,
+ UsersManagerAPI::getInstance()->setUserPreference($userLogin,
+ UsersManagerAPI::PREFERENCE_DEFAULT_REPORT,
$anonymousDefaultReport);
- Piwik_UsersManager_API::getInstance()->setUserPreference($userLogin,
- Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE,
+ UsersManagerAPI::getInstance()->setUserPreference($userLogin,
+ UsersManagerAPI::PREFERENCE_DEFAULT_REPORT_DATE,
$anonymousDefaultDate);
$toReturn = $response->getResponse();
} catch (Exception $e) {
@@ -306,7 +309,7 @@ public function recordUserSettings()
Config::getInstance()->forceSave();
}
} else {
- Piwik_UsersManager_API::getInstance()->updateUser($userLogin, $newPassword, $email, $alias);
+ UsersManagerAPI::getInstance()->updateUser($userLogin, $newPassword, $email, $alias);
if ($newPassword !== false) {
$newPassword = Common::unsanitizeInputValue($newPassword);
}
@@ -322,11 +325,11 @@ public function recordUserSettings()
Piwik_PostEvent('Login.initSession', array($info));
}
- Piwik_UsersManager_API::getInstance()->setUserPreference($userLogin,
- Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT,
+ UsersManagerAPI::getInstance()->setUserPreference($userLogin,
+ UsersManagerAPI::PREFERENCE_DEFAULT_REPORT,
$defaultReport);
- Piwik_UsersManager_API::getInstance()->setUserPreference($userLogin,
- Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE,
+ UsersManagerAPI::getInstance()->setUserPreference($userLogin,
+ UsersManagerAPI::PREFERENCE_DEFAULT_REPORT_DATE,
$defaultDate);
$toReturn = $response->getResponse();
} catch (Exception $e) {
diff --git a/plugins/UsersManager/UsersManager.php b/plugins/UsersManager/UsersManager.php
index a0828d79040..905f23cc2fb 100644
--- a/plugins/UsersManager/UsersManager.php
+++ b/plugins/UsersManager/UsersManager.php
@@ -6,18 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
+namespace Piwik\Plugins\UsersManager;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Option;
-use Piwik\Plugin;
+use Piwik\Plugins\UsersManager\API;
/**
* Manage Piwik users
*
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
-class Piwik_UsersManager extends Plugin
+class UsersManager extends \Piwik\Plugin
{
const PASSWORD_MIN_LENGTH = 6;
const PASSWORD_MAX_LENGTH = 26;
@@ -36,7 +39,6 @@ public function getListHooksRegistered()
);
}
-
/**
* Hooks when a website tracker cache is flushed (website/user updated, cache deleted, or empty cache)
* Will record in the tracker config file the list of Admin token_auth for this website. This
@@ -49,7 +51,7 @@ public function getListHooksRegistered()
public function recordAdminUsersInCache(&$array, $idSite)
{
// add the 'hosts' entry in the website array
- $users = Piwik_UsersManager_API::getInstance()->getUsersWithSiteAccess($idSite, 'admin');
+ $users = API::getInstance()->getUsersWithSiteAccess($idSite, 'admin');
$tokens = array();
foreach ($users as $user) {
@@ -62,7 +64,7 @@ public function recordAdminUsersInCache(&$array, $idSite)
*/
public function deleteSite(&$idSite)
{
- Option::getInstance()->deleteLike('%\_' . Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT, $idSite);
+ Option::getInstance()->deleteLike('%\_' . API::PREFERENCE_DEFAULT_REPORT, $idSite);
}
/**
diff --git a/plugins/VisitFrequency/API.php b/plugins/VisitFrequency/API.php
index 7e77d561ec1..f8f433f581d 100644
--- a/plugins/VisitFrequency/API.php
+++ b/plugins/VisitFrequency/API.php
@@ -6,22 +6,26 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
+namespace Piwik\Plugins\VisitFrequency;
+
use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\SegmentExpression;
+use Piwik\Plugins\VisitsSummary\API as VisitsSummaryAPI;
/**
* VisitFrequency API lets you access a list of metrics related to Returning Visitors.
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
-class Piwik_VisitFrequency_API
+class API
{
const RETURNING_VISITOR_SEGMENT = "visitorType==returning";
const COLUMN_SUFFIX = "_returning";
static private $instance = null;
+
static public function getInstance()
{
if (self::$instance == null) {
@@ -71,7 +75,7 @@ protected function unprefixColumns(&$columns)
protected function prefixColumns($table, $period)
{
$rename = array();
- foreach (Piwik_VisitsSummary_API::getInstance()->getColumns($period) as $oldColumn) {
+ foreach (VisitsSummaryAPI::getInstance()->getColumns($period) as $oldColumn) {
$rename[$oldColumn] = $oldColumn . self::COLUMN_SUFFIX;
}
$table->filter('ReplaceColumnNames', array($rename));
diff --git a/plugins/VisitFrequency/Controller.php b/plugins/VisitFrequency/Controller.php
index 77baa6b5391..b83a117840a 100644
--- a/plugins/VisitFrequency/Controller.php
+++ b/plugins/VisitFrequency/Controller.php
@@ -6,19 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
+namespace Piwik\Plugins\VisitFrequency;
+
use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\View;
/**
*
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
-class Piwik_VisitFrequency_Controller extends Controller
+class Controller extends \Piwik\Controller
{
function index()
{
@@ -96,7 +97,6 @@ protected function setSparklinesAndNumbers($view)
$view->avgVisitDurationReturning = $dataRow->getColumn('avg_time_on_site_returning');
$nbBouncedReturningVisits = $dataRow->getColumn('bounce_count_returning');
$view->bounceRateReturning = Piwik::getPercentageSafe($nbBouncedReturningVisits, $nbVisitsReturning);
-
}
protected function getSummary()
diff --git a/plugins/VisitFrequency/VisitFrequency.php b/plugins/VisitFrequency/VisitFrequency.php
index 07b17351596..90a59297609 100644
--- a/plugins/VisitFrequency/VisitFrequency.php
+++ b/plugins/VisitFrequency/VisitFrequency.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\VisitFrequency;
+
use Piwik\WidgetsList;
/**
*
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
-class Piwik_VisitFrequency extends Plugin
+class VisitFrequency extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -23,9 +24,9 @@ class Piwik_VisitFrequency extends Plugin
public function getListHooksRegistered()
{
$hooks = array(
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenu',
- 'API.getReportMetadata' => 'getReportMetadata',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenu',
+ 'API.getReportMetadata' => 'getReportMetadata',
);
return $hooks;
}
diff --git a/plugins/VisitTime/API.php b/plugins/VisitTime/API.php
index 186c378f834..5a24ec36c98 100644
--- a/plugins/VisitTime/API.php
+++ b/plugins/VisitTime/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
+namespace Piwik\Plugins\VisitTime;
+
+use Exception;
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Period;
@@ -15,13 +18,16 @@
use Piwik\Date;
use Piwik\DataTable;
use Piwik\Site;
+use Piwik\Plugins\VisitTime\Archiver;
+
+require_once PIWIK_INCLUDE_PATH . '/plugins/VisitTime/functions.php';
/**
* VisitTime API lets you access reports by Hour (Server time), and by Hour Local Time of your visitors.
*
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
-class Piwik_VisitTime_API
+class API
{
static private $instance = null;
@@ -39,19 +45,19 @@ protected function getDataTable($name, $idSite, $period, $date, $segment)
$archive = Archive::build($idSite, $period, $date, $segment);
$dataTable = $archive->getDataTable($name);
$dataTable->filter('Sort', array('label', 'asc', true));
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getTimeLabel'));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ .'\getTimeLabel'));
$dataTable->queueFilter('ReplaceColumnNames');
return $dataTable;
}
public function getVisitInformationPerLocalTime($idSite, $period, $date, $segment = false)
{
- return $this->getDataTable(Piwik_VisitTime_Archiver::LOCAL_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getDataTable(Archiver::LOCAL_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
}
public function getVisitInformationPerServerTime($idSite, $period, $date, $segment = false, $hideFutureHoursWhenToday = false)
{
- $table = $this->getDataTable(Piwik_VisitTime_Archiver::SERVER_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
+ $table = $this->getDataTable(Archiver::SERVER_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
if ($hideFutureHoursWhenToday) {
$table = $this->removeHoursInFuture($table, $idSite, $period, $date);
}
@@ -76,7 +82,7 @@ public function getByDayOfWeek($idSite, $period, $date, $segment = false)
// metrics to query
$metrics = Metrics::getVisitsMetricNames();
unset($metrics[Metrics::INDEX_MAX_ACTIONS]);
-
+
// disabled for multiple dates
if (Period::isMultiplePeriod($date, $period)) {
throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates.");
@@ -100,7 +106,7 @@ public function getByDayOfWeek($idSite, $period, $date, $segment = false)
}
// group by the day of the week (see below for dayOfWeekFromDate function)
- $dataTable->filter('GroupBy', array('label', 'Piwik_VisitTime_dayOfWeekFromDate'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\dayOfWeekFromDate'));
// create new datatable w/ empty rows, then add calculated datatable
$rows = array();
@@ -115,7 +121,7 @@ public function getByDayOfWeek($idSite, $period, $date, $segment = false)
$result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week'));
// translate labels
- $result->filter('ColumnCallbackReplace', array('label', 'Piwik_VisitTime_translateDayOfWeek'));
+ $result->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\translateDayOfWeek'));
// set datatable metadata for period start & finish
$result->setMetadata('date_start', $oPeriod->getDateStart());
@@ -154,31 +160,3 @@ protected function removeHoursInFuture($table, $idSite, $period, $date)
return $table;
}
}
-
-function Piwik_getTimeLabel($label)
-{
- return sprintf(Piwik_Translate('VisitTime_NHour'), $label);
-}
-
-/**
- * Returns the day of the week for a date string, without creating a new
- * Date instance.
- *
- * @param string $dateStr
- * @return int The day of the week (1-7)
- */
-function Piwik_VisitTime_dayOfWeekFromDate($dateStr)
-{
- return date('N', strtotime($dateStr));
-}
-
-/**
- * Returns translated long name of a day of the week.
- *
- * @param int $dayOfWeek 1-7, for Sunday-Saturday
- * @return string
- */
-function Piwik_VisitTime_translateDayOfWeek($dayOfWeek)
-{
- return Piwik_Translate('General_LongDay_' . $dayOfWeek);
-}
diff --git a/plugins/VisitTime/Archiver.php b/plugins/VisitTime/Archiver.php
index 77b7659d9bc..c51c0829674 100644
--- a/plugins/VisitTime/Archiver.php
+++ b/plugins/VisitTime/Archiver.php
@@ -6,14 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
+namespace Piwik\Plugins\VisitTime;
+
use Piwik\Date;
use Piwik\DataArray;
use Piwik\PluginsArchiver;
-class Piwik_VisitTime_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const SERVER_TIME_RECORD_NAME = 'VisitTime_serverTime';
const LOCAL_TIME_RECORD_NAME = 'VisitTime_localTime';
@@ -26,8 +28,8 @@ public function archiveDay()
protected function aggregateByServerTime()
{
- $array = $this->getProcessor()->getMetricsForDimension( array("label" => "HOUR(log_visit.visit_last_action_time)" )) ;
- $query = $this->getLogAggregator()->queryConversionsByDimension( array("label" => "HOUR(log_conversion.server_time)") );
+ $array = $this->getProcessor()->getMetricsForDimension(array("label" => "HOUR(log_visit.visit_last_action_time)"));
+ $query = $this->getLogAggregator()->queryConversionsByDimension(array("label" => "HOUR(log_conversion.server_time)"));
if ($query === false) {
return;
}
@@ -62,13 +64,12 @@ protected function convertTimeToLocalTimezone(DataArray &$array)
return new DataArray($converted);
}
-
- private function ensureAllHoursAreSet( DataArray &$array)
+ private function ensureAllHoursAreSet(DataArray &$array)
{
$data = $array->getDataArray();
for ($i = 0; $i <= 23; $i++) {
if (empty($data[$i])) {
- $array->sumMetricsVisits( $i, DataArray::makeEmptyRow());
+ $array->sumMetricsVisits($i, DataArray::makeEmptyRow());
}
}
}
diff --git a/plugins/VisitTime/Controller.php b/plugins/VisitTime/Controller.php
index 4c4fa760db3..dcc89ac9fbb 100644
--- a/plugins/VisitTime/Controller.php
+++ b/plugins/VisitTime/Controller.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\VisitTime;
+
use Piwik\ViewDataTable;
use Piwik\View;
/**
*
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
-class Piwik_VisitTime_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php
index 9b652577d33..2cd34adc66e 100644
--- a/plugins/VisitTime/VisitTime.php
+++ b/plugins/VisitTime/VisitTime.php
@@ -6,20 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
+namespace Piwik\Plugins\VisitTime;
+
+use Exception;
use Piwik\ArchiveProcessor;
use Piwik\Common;
use Piwik\Period;
-use Piwik\Plugin;
+use Piwik\Plugins\VisitTime\Archiver;
use Piwik\Site;
use Piwik\WidgetsList;
/**
*
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
-class Piwik_VisitTime extends Plugin
+class VisitTime extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -116,7 +119,7 @@ public function getSegmentsMetadata(&$segments)
'acceptedValues' => $acceptedValues
);
}
-
+
public function getReportDisplayProperties(&$properties)
{
$commonProperties = array(
@@ -128,33 +131,33 @@ public function getReportDisplayProperties(&$properties)
'show_pagination_control' => false,
'default_view_type' => 'graphVerticalBar'
);
-
+
$properties['VisitTime.getVisitInformationPerServerTime'] = array_merge($commonProperties, array(
- 'filter_limit' => 24,
- 'graph_limit' => null,
- 'show_goals' => true,
- 'translations' => array('label' => Piwik_Translate('VisitTime_ColumnServerTime')),
-
- // custom parameter
- 'hideFutureHoursWhenToday' => 1,
- ));
-
+ 'filter_limit' => 24,
+ 'graph_limit' => null,
+ 'show_goals' => true,
+ 'translations' => array('label' => Piwik_Translate('VisitTime_ColumnServerTime')),
+
+ // custom parameter
+ 'hideFutureHoursWhenToday' => 1,
+ ));
+
$properties['VisitTime.getVisitInformationPerLocalTime'] = array_merge($commonProperties, array(
- 'filter_limit' => 24,
- 'graph_limit' => null,
- 'title' => Piwik_Translate('VisitTime_ColumnLocalTime'),
- 'translations' => array('label' => Piwik_Translate('VisitTime_LocalTime')),
- ));
-
+ 'filter_limit' => 24,
+ 'graph_limit' => null,
+ 'title' => Piwik_Translate('VisitTime_ColumnLocalTime'),
+ 'translations' => array('label' => Piwik_Translate('VisitTime_LocalTime')),
+ ));
+
$properties['VisitTime.getByDayOfWeek'] = array_merge($commonProperties, array(
- 'filter_limit' => 7,
- 'graph_limit' => null,
- 'enable_sort' => false,
- 'show_all_ticks' => true,
- 'show_footer_message' =>
- Piwik_Translate('General_ReportGeneratedFrom', self::getDateRangeForFooterMessage()),
- 'translations' => array('label' => Piwik_Translate('VisitTime_DayOfWeek')),
- ));
+ 'filter_limit' => 7,
+ 'graph_limit' => null,
+ 'enable_sort' => false,
+ 'show_all_ticks' => true,
+ 'show_footer_message' =>
+ Piwik_Translate('General_ReportGeneratedFrom', self::getDateRangeForFooterMessage()),
+ 'translations' => array('label' => Piwik_Translate('VisitTime_DayOfWeek')),
+ ));
// add the visits by day of week as a related report, if the current period is not 'day'
if (Common::getRequestVar('period', 'day') != 'day') {
@@ -166,21 +169,20 @@ public function getReportDisplayProperties(&$properties)
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_VisitTime_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
-
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_VisitTime_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
-
+
private static function getDateRangeForFooterMessage()
{
// get query params
diff --git a/plugins/VisitTime/functions.php b/plugins/VisitTime/functions.php
new file mode 100644
index 00000000000..f4ccb20d46a
--- /dev/null
+++ b/plugins/VisitTime/functions.php
@@ -0,0 +1,40 @@
+getSitesWithAdminAccess();
+ $sitesList = SitesManagerAPI::getInstance()->getSitesWithAdminAccess();
$view = new View('@VisitorGenerator/index');
$this->setBasicVariablesView($view);
$view->assign('sitesList', $sitesList);
- $view->nonce = Nonce::getNonce('Piwik_VisitorGenerator.generate');
+ $view->nonce = Nonce::getNonce('VisitorGenerator.generate');
$view->countActionsPerRun = count($this->getAccessLog());
$view->accessLogPath = $this->getAccessLogPath();
echo $view->render();
@@ -57,11 +61,11 @@ public function generate()
Piwik::checkUserIsSuperUser();
$nonce = Common::getRequestVar('form_nonce', '', 'string', $_POST);
if (Common::getRequestVar('choice', 'no') != 'yes' ||
- !Nonce::verifyNonce('Piwik_VisitorGenerator.generate', $nonce)
+ !Nonce::verifyNonce('VisitorGenerator.generate', $nonce)
) {
Piwik::redirectToModule('VisitorGenerator', 'index');
}
- Nonce::discardNonce('Piwik_VisitorGenerator.generate');
+ Nonce::discardNonce('VisitorGenerator.generate');
$daysToCompute = Common::getRequestVar('daysToCompute', 1, 'int');
@@ -83,7 +87,7 @@ public function generate()
$nbActionsTotal += $nbActionsTotalThisDay;
}
- $api = Piwik_CoreAdminHome_API::getInstance();
+ $api = CoreAdminHomeAPI::getInstance();
$api->invalidateArchivedReports($idSite, implode($dates, ","));
$browserArchiving = Rules::isBrowserTriggerEnabled();
diff --git a/plugins/VisitorGenerator/VisitorGenerator.php b/plugins/VisitorGenerator/VisitorGenerator.php
index 9ad4fa3d669..4e3c13e677e 100644
--- a/plugins/VisitorGenerator/VisitorGenerator.php
+++ b/plugins/VisitorGenerator/VisitorGenerator.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitorGenerator
+ * @package VisitorGenerator
*/
+namespace Piwik\Plugins\VisitorGenerator;
+
use Piwik\Piwik;
-use Piwik\Plugin;
/**
*
- * @package Piwik_VisitorGenerator
+ * @package VisitorGenerator
*/
-class Piwik_VisitorGenerator extends Plugin
+class VisitorGenerator extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/VisitorInterest/API.php b/plugins/VisitorInterest/API.php
index 8f34623fec7..7a6f925254c 100644
--- a/plugins/VisitorInterest/API.php
+++ b/plugins/VisitorInterest/API.php
@@ -6,20 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
+namespace Piwik\Plugins\VisitorInterest;
+
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\DataTable;
+use Piwik\Plugins\VisitorInterest\Archiver;
/**
* VisitorInterest API lets you access two Visitor Engagement reports: number of visits per number of pages,
* and number of visits per visit duration.
*
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
-class Piwik_VisitorInterest_API
+class API
{
static private $instance = null;
@@ -42,7 +45,7 @@ protected function getDataTable($name, $idSite, $period, $date, $segment, $colum
public function getNumberOfVisitsPerVisitDuration($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_VisitorInterest_Archiver::TIME_SPENT_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::TIME_SPENT_RECORD_NAME, $idSite, $period, $date, $segment);
$dataTable->queueFilter('Sort', array('label', 'asc', true));
$dataTable->queueFilter('BeautifyTimeRangeLabels', array(
Piwik_Translate('VisitorInterest_BetweenXYSeconds'),
@@ -53,7 +56,7 @@ public function getNumberOfVisitsPerVisitDuration($idSite, $period, $date, $segm
public function getNumberOfVisitsPerPage($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_VisitorInterest_Archiver::PAGES_VIEWED_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::PAGES_VIEWED_RECORD_NAME, $idSite, $period, $date, $segment);
$dataTable->queueFilter('Sort', array('label', 'asc', true));
$dataTable->queueFilter('BeautifyRangeLabels', array(
Piwik_Translate('VisitorInterest_OnePage'),
@@ -74,7 +77,7 @@ public function getNumberOfVisitsPerPage($idSite, $period, $date, $segment = fal
public function getNumberOfVisitsByDaysSinceLast($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable(
- Piwik_VisitorInterest_Archiver::DAYS_SINCE_LAST_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS);
+ Archiver::DAYS_SINCE_LAST_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS);
$dataTable->queueFilter('BeautifyRangeLabels', array(Piwik_Translate('General_OneDay'), Piwik_Translate('General_NDays')));
return $dataTable;
}
@@ -92,7 +95,7 @@ public function getNumberOfVisitsByDaysSinceLast($idSite, $period, $date, $segme
public function getNumberOfVisitsByVisitCount($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable(
- Piwik_VisitorInterest_Archiver::VISITS_COUNT_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS);
+ Archiver::VISITS_COUNT_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS);
$dataTable->queueFilter('BeautifyRangeLabels', array(
Piwik_Translate('General_OneVisit'), Piwik_Translate('General_NVisits')));
diff --git a/plugins/VisitorInterest/Archiver.php b/plugins/VisitorInterest/Archiver.php
index 18449cbf4cd..d6aa1a29ba7 100644
--- a/plugins/VisitorInterest/Archiver.php
+++ b/plugins/VisitorInterest/Archiver.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
+namespace Piwik\Plugins\VisitorInterest;
+
use Piwik\DataAccess\LogAggregator;
use Piwik\Metrics;
use Piwik\DataTable;
use Piwik\PluginsArchiver;
-class Piwik_VisitorInterest_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
// third element is unit (s for seconds, default is munutes)
const TIME_SPENT_RECORD_NAME = 'VisitorInterest_timeGap';
@@ -90,9 +92,9 @@ public function archiveDay()
// these prefixes are prepended to the 'SELECT as' parts of each SELECT expression. detecting
// these prefixes allows us to get all the data in one query.
$prefixes = array(
- self::TIME_SPENT_RECORD_NAME => 'tg',
- self::PAGES_VIEWED_RECORD_NAME => 'pg',
- self::VISITS_COUNT_RECORD_NAME => 'vbvn',
+ self::TIME_SPENT_RECORD_NAME => 'tg',
+ self::PAGES_VIEWED_RECORD_NAME => 'pg',
+ self::VISITS_COUNT_RECORD_NAME => 'vbvn',
self::DAYS_SINCE_LAST_RECORD_NAME => 'dslv',
);
@@ -105,13 +107,13 @@ public function archiveDay()
),
);
$selects = array();
- foreach($aggregatesMetadata as $aggregateMetadata) {
+ foreach ($aggregatesMetadata as $aggregateMetadata) {
$selectsFromRangedColumn = LogAggregator::getSelectsFromRangedColumn($aggregateMetadata);
- $selects = array_merge( $selects, $selectsFromRangedColumn);
+ $selects = array_merge($selects, $selectsFromRangedColumn);
}
$query = $this->getLogAggregator()->queryVisitsByDimension(array(), $where = false, $selects, array());
$row = $query->fetch();
- foreach($prefixes as $recordName => $selectAsPrefix) {
+ foreach ($prefixes as $recordName => $selectAsPrefix) {
$cleanRow = LogAggregator::makeArrayOneColumn($row, Metrics::INDEX_NB_VISITS, $selectAsPrefix);
$dataTable = DataTable::makeFromIndexedArray($cleanRow);
$this->getProcessor()->insertBlobRecord($recordName, $dataTable->getSerialized());
diff --git a/plugins/VisitorInterest/Controller.php b/plugins/VisitorInterest/Controller.php
index d7a505d6b4b..5475d6cba83 100644
--- a/plugins/VisitorInterest/Controller.php
+++ b/plugins/VisitorInterest/Controller.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
+namespace Piwik\Plugins\VisitorInterest;
+
use Piwik\Metrics;
-use Piwik\Controller;
use Piwik\ViewDataTable;
use Piwik\View;
/**
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
-class Piwik_VisitorInterest_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
diff --git a/plugins/VisitorInterest/VisitorInterest.php b/plugins/VisitorInterest/VisitorInterest.php
index a656e738042..a60118961d2 100644
--- a/plugins/VisitorInterest/VisitorInterest.php
+++ b/plugins/VisitorInterest/VisitorInterest.php
@@ -6,19 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
+namespace Piwik\Plugins\VisitorInterest;
+
use Piwik\ArchiveProcessor;
use Piwik\FrontController;
-use Piwik\Plugin;
use Piwik\Metrics;
+use Piwik\Plugins\VisitorInterest\Archiver;
use Piwik\WidgetsList;
/**
*
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
-class Piwik_VisitorInterest extends Plugin
+class VisitorInterest extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -26,11 +28,11 @@ class Piwik_VisitorInterest extends Plugin
public function getListHooksRegistered()
{
$hooks = array(
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenu',
- 'API.getReportMetadata' => 'getReportMetadata',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenu',
+ 'API.getReportMetadata' => 'getReportMetadata',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
return $hooks;
@@ -113,22 +115,22 @@ public function addMenu()
function postLoad()
{
- Piwik_AddAction('template_headerVisitsFrequency', array('Piwik_VisitorInterest', 'headerVisitsFrequency'));
- Piwik_AddAction('template_footerVisitsFrequency', array('Piwik_VisitorInterest', 'footerVisitsFrequency'));
+ Piwik_AddAction('template_headerVisitsFrequency', array('Piwik\Plugins\VisitorInterest\VisitorInterest', 'headerVisitsFrequency'));
+ Piwik_AddAction('template_footerVisitsFrequency', array('Piwik\Plugins\VisitorInterest\VisitorInterest', 'footerVisitsFrequency'));
}
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_VisitorInterest_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_VisitorInterest_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
@@ -162,70 +164,70 @@ public function getReportDisplayProperties(&$properties)
private function getDisplayPropertiesForGetNumberOfVisitsPerVisitDuration()
{
return array(
- 'default_view_type' => 'cloud',
- 'filter_sort_column' => 'label',
- 'filter_sort_order' => 'asc',
- 'translations' => array('label' => Piwik_Translate('VisitorInterest_ColumnVisitDuration')),
- 'graph_limit' => 10,
- 'enable_sort' => false,
+ 'default_view_type' => 'cloud',
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array('label' => Piwik_Translate('VisitorInterest_ColumnVisitDuration')),
+ 'graph_limit' => 10,
+ 'enable_sort' => false,
'show_exclude_low_population' => false,
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'show_search' => false,
- 'show_table_all_columns' => false,
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'show_search' => false,
+ 'show_table_all_columns' => false,
);
}
private function getDisplayPropertiesForGetNumberOfVisitsPerPage()
{
return array(
- 'default_view_type' => 'cloud',
- 'filter_sort_column' => 'label',
- 'filter_sort_order' => 'asc',
- 'translations' => array('label' => Piwik_Translate('VisitorInterest_ColumnPagesPerVisit')),
- 'graph_limit' => 10,
- 'enable_sort' => false,
+ 'default_view_type' => 'cloud',
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array('label' => Piwik_Translate('VisitorInterest_ColumnPagesPerVisit')),
+ 'graph_limit' => 10,
+ 'enable_sort' => false,
'show_exclude_low_population' => false,
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'show_search' => false,
- 'show_table_all_columns' => false,
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'show_search' => false,
+ 'show_table_all_columns' => false,
);
}
private function getDisplayPropertiesForGetNumberOfVisitsByVisitCount()
{
return array(
- 'columns_to_display' => array('label', 'nb_visits', 'nb_visits_percentage'),
- 'filter_sort_column' => 'label',
- 'filter_sort_order' => 'asc',
- 'translations' => array('label' => Piwik_Translate('VisitorInterest_VisitNum'),
- 'nb_visits_percentage' => Metrics::getPercentVisitColumn()),
+ 'columns_to_display' => array('label', 'nb_visits', 'nb_visits_percentage'),
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array('label' => Piwik_Translate('VisitorInterest_VisitNum'),
+ 'nb_visits_percentage' => Metrics::getPercentVisitColumn()),
'show_exclude_low_population' => false,
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'filter_limit' => 15,
- 'show_search' => false,
- 'enable_sort' => false,
- 'show_table_all_columns' => false,
- 'show_all_views_icons' => false,
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'filter_limit' => 15,
+ 'show_search' => false,
+ 'enable_sort' => false,
+ 'show_table_all_columns' => false,
+ 'show_all_views_icons' => false,
);
}
private function getDisplayPropertiesForGetNumberOfVisitsByDaysSinceLast()
{
return array(
- 'filter_sort_column' => 'label',
- 'filter_sort_order' => 'asc',
- 'translations' => array('label' => Piwik_Translate('General_DaysSinceLastVisit')),
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array('label' => Piwik_Translate('General_DaysSinceLastVisit')),
'show_exclude_low_population' => false,
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'show_all_views_icons' => false,
- 'filter_limit' => 15,
- 'show_search' => false,
- 'enable_sort' => false,
- 'show_table_all_columns' => false
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'show_all_views_icons' => false,
+ 'filter_limit' => 15,
+ 'show_search' => false,
+ 'enable_sort' => false,
+ 'show_table_all_columns' => false
);
}
}
diff --git a/plugins/VisitsSummary/API.php b/plugins/VisitsSummary/API.php
index 7dbabcf6d9f..57e81115ef0 100644
--- a/plugins/VisitsSummary/API.php
+++ b/plugins/VisitsSummary/API.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
+namespace Piwik\Plugins\VisitsSummary;
+
use Piwik\Archive;
use Piwik\Piwik;
@@ -15,14 +17,14 @@
* VisitsSummary API lets you access the core web analytics metrics (visits, unique visitors,
* count of actions (page views & downloads & clicks on outlinks), time on site, bounces and converted visits.
*
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
-class Piwik_VisitsSummary_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_VisitsSummary_API
+ * @return \Piwik\Plugins\VisitsSummary\API
*/
static public function getInstance()
{
diff --git a/plugins/VisitsSummary/Controller.php b/plugins/VisitsSummary/Controller.php
index 4bc553a94dc..2594a9689ca 100644
--- a/plugins/VisitsSummary/Controller.php
+++ b/plugins/VisitsSummary/Controller.php
@@ -6,23 +6,25 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
+namespace Piwik\Plugins\VisitsSummary;
+
use Piwik\API\Request;
use Piwik\DataTable\Row;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\DataTable;
-use Piwik\Controller;
+use Piwik\Plugins\Actions\API;
use Piwik\ViewDataTable;
use Piwik\View;
use Piwik\Site;
/**
*
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
-class Piwik_VisitsSummary_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
@@ -126,7 +128,7 @@ protected function setSparklinesAndNumbers($view)
$view->urlSparklineMaxActions = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('max_actions')));
$view->urlSparklineActionsPerVisit = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_actions_per_visit')));
$view->urlSparklineBounceRate = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('bounce_rate')));
- $view->urlSparklineAvgGenerationTime = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('avg_time_generation')));
+ $view->urlSparklineAvgGenerationTime = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('avg_time_generation')));
$idSite = Common::getRequestVar('idSite');
$displaySiteSearch = Site::isSiteSearchEnabledFor($idSite);
@@ -138,7 +140,7 @@ protected function setSparklinesAndNumbers($view)
$dataTableVisit = self::getVisitsSummary();
$dataRow = $dataTableVisit->getRowsCount() == 0 ? new Row() : $dataTableVisit->getFirstRow();
- $dataTableActions = Piwik_Actions_API::getInstance()->get($idSite, Common::getRequestVar('period'), Common::getRequestVar('date'),
+ $dataTableActions = API::getInstance()->get($idSite, Common::getRequestVar('period'), Common::getRequestVar('date'),
\Piwik\API\Request::getRawSegmentFromRequest());
$dataActionsRow =
$dataTableActions->getRowsCount() == 0 ? new Row() : $dataTableActions->getFirstRow();
@@ -157,7 +159,7 @@ protected function setSparklinesAndNumbers($view)
$view->bounceRate = Piwik::getPercentageSafe($nbBouncedVisits, $nbVisits);
$view->maxActions = (int)$dataRow->getColumn('max_actions');
$view->nbActionsPerVisit = $dataRow->getColumn('nb_actions_per_visit');
- $view->averageGenerationTime = $dataActionsRow->getColumn('avg_time_generation');
+ $view->averageGenerationTime = $dataActionsRow->getColumn('avg_time_generation');
if ($displaySiteSearch) {
$view->nbSearches = (int)$dataActionsRow->getColumn('nb_searches');
diff --git a/plugins/VisitsSummary/VisitsSummary.php b/plugins/VisitsSummary/VisitsSummary.php
index 91e4a65661f..3ef1a89f0db 100644
--- a/plugins/VisitsSummary/VisitsSummary.php
+++ b/plugins/VisitsSummary/VisitsSummary.php
@@ -6,9 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\VisitsSummary;
+
use Piwik\WidgetsList;
/**
@@ -17,9 +18,9 @@
* Day class directly.
* These metrics can be used by other Plugins so they need to be processed up front.
*
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
-class Piwik_VisitsSummary extends Plugin
+class VisitsSummary extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/Widgetize/Controller.php b/plugins/Widgetize/Controller.php
index c49fa226d34..1dea78feb46 100644
--- a/plugins/Widgetize/Controller.php
+++ b/plugins/Widgetize/Controller.php
@@ -6,20 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Widgetize
+ * @package Widgetize
*/
+namespace Piwik\Plugins\Widgetize;
+
use Piwik\API\Request;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\FrontController;
use Piwik\View;
use Piwik\WidgetsList;
/**
*
- * @package Piwik_Widgetize
+ * @package Widgetize
*/
-class Piwik_Widgetize_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
diff --git a/plugins/Widgetize/Widgetize.php b/plugins/Widgetize/Widgetize.php
index 7bf8cdb7c1f..6464807d8c7 100644
--- a/plugins/Widgetize/Widgetize.php
+++ b/plugins/Widgetize/Widgetize.php
@@ -7,15 +7,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Widgetize
+ * @package Widgetize
*/
-use Piwik\Plugin;
+
+namespace Piwik\Plugins\Widgetize;
/**
*
- * @package Piwik_Widgetize
+ * @package Widgetize
*/
-class Piwik_Widgetize extends Plugin
+class Widgetize extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/Zeitgeist/stylesheets/base.css b/plugins/Zeitgeist/stylesheets/base.css
index a4cd523faec..959c4065eb4 100644
--- a/plugins/Zeitgeist/stylesheets/base.css
+++ b/plugins/Zeitgeist/stylesheets/base.css
@@ -1,3 +1,4 @@
+/* TO GENERATE: lessc plugins/Zeitgeist/stylesheets/base.less plugins/Zeitgeist/stylesheets/base.css */
/* base.less is a standalone Less file */
/* base.css is automatically generated. DO NOT MODIFY */
/* Genreral styles */
diff --git a/plugins/Zeitgeist/stylesheets/base.less b/plugins/Zeitgeist/stylesheets/base.less
index 4f593a9c926..cce7c668222 100644
--- a/plugins/Zeitgeist/stylesheets/base.less
+++ b/plugins/Zeitgeist/stylesheets/base.less
@@ -1,3 +1,4 @@
+/* TO GENERATE: lessc plugins/Zeitgeist/stylesheets/base.less plugins/Zeitgeist/stylesheets/base.css */
/* base.less is a standalone Less file */
/* base.css is automatically generated. DO NOT MODIFY */
diff --git a/tests/PHPUnit/BaseFixture.php b/tests/PHPUnit/BaseFixture.php
index 70e9e87e5bc..cf57226d8b8 100644
--- a/tests/PHPUnit/BaseFixture.php
+++ b/tests/PHPUnit/BaseFixture.php
@@ -9,6 +9,12 @@
use Piwik\Common;
use Piwik\Access;
use Piwik\Date;
+use Piwik\Plugins\MobileMessaging\MobileMessaging;
+use Piwik\Plugins\PDFReports\API as PDFReportsAPI;
+use Piwik\Plugins\PDFReports\PDFReports;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
use Piwik\Url;
use Piwik\ReportRenderer;
use Piwik\Site;
@@ -57,7 +63,7 @@ public static function createWebsite($dateTime, $ecommerce = 0, $siteName = 'Piw
$siteSearch = 1, $searchKeywordParameters = null,
$searchCategoryParameters = null)
{
- $idSite = Piwik_SitesManager_API::getInstance()->addSite(
+ $idSite = SitesManagerAPI::getInstance()->addSite(
$siteName,
$siteUrl === false ? "http://piwik.net/" : $siteUrl,
$ecommerce,
@@ -166,12 +172,12 @@ public static function checkResponse($response)
public static function makeLocation($city, $region, $country, $lat = null, $long = null, $isp = null)
{
- return array(Piwik_UserCountry_LocationProvider::CITY_NAME_KEY => $city,
- Piwik_UserCountry_LocationProvider::REGION_CODE_KEY => $region,
- Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY => $country,
- Piwik_UserCountry_LocationProvider::LATITUDE_KEY => $lat,
- Piwik_UserCountry_LocationProvider::LONGITUDE_KEY => $long,
- Piwik_UserCountry_LocationProvider::ISP_KEY => $isp);
+ return array(LocationProvider::CITY_NAME_KEY => $city,
+ LocationProvider::REGION_CODE_KEY => $region,
+ LocationProvider::COUNTRY_CODE_KEY => $country,
+ LocationProvider::LATITUDE_KEY => $lat,
+ LocationProvider::LONGITUDE_KEY => $long,
+ LocationProvider::ISP_KEY => $isp);
}
/**
@@ -182,7 +188,7 @@ public static function makeLocation($city, $region, $country, $lat = null, $long
*/
public static function getTokenAuth()
{
- return Piwik_UsersManager_API::getInstance()->getTokenAuth(
+ return UsersManagerAPI::getInstance()->getTokenAuth(
Config::getInstance()->superuser['login'],
Config::getInstance()->superuser['password']
);
@@ -208,7 +214,7 @@ public static function setUpScheduledReports($idSite)
Access::setSingletonInstance($pseudoMockAccess);
// retrieve available reports
- $availableReportMetadata = Piwik_PDFReports_API::getReportMetadata($idSite, Piwik_PDFReports::EMAIL_TYPE);
+ $availableReportMetadata = PDFReportsAPI::getReportMetadata($idSite, PDFReports::EMAIL_TYPE);
$availableReportIds = array();
foreach ($availableReportMetadata as $reportMetadata) {
@@ -217,66 +223,66 @@ public static function setUpScheduledReports($idSite)
//@review should we also test evolution graphs?
// set-up mail report
- Piwik_PDFReports_API::getInstance()->addReport(
+ PDFReportsAPI::getInstance()->addReport(
$idSite,
'Mail Test report',
'day', // overridden in getApiForTestingScheduledReports()
0,
- Piwik_PDFReports::EMAIL_TYPE,
+ PDFReports::EMAIL_TYPE,
ReportRenderer::HTML_FORMAT, // overridden in getApiForTestingScheduledReports()
$availableReportIds,
- array(Piwik_PDFReports::DISPLAY_FORMAT_PARAMETER => Piwik_PDFReports::DISPLAY_FORMAT_TABLES_ONLY)
+ array(PDFReports::DISPLAY_FORMAT_PARAMETER => PDFReports::DISPLAY_FORMAT_TABLES_ONLY)
);
// set-up sms report for one website
- Piwik_PDFReports_API::getInstance()->addReport(
+ PDFReportsAPI::getInstance()->addReport(
$idSite,
'SMS Test report, one website',
'day', // overridden in getApiForTestingScheduledReports()
0,
- Piwik_MobileMessaging::MOBILE_TYPE,
- Piwik_MobileMessaging::SMS_FORMAT,
+ MobileMessaging::MOBILE_TYPE,
+ MobileMessaging::SMS_FORMAT,
array("MultiSites_getOne"),
array("phoneNumbers" => array())
);
// set-up sms report for all websites
- Piwik_PDFReports_API::getInstance()->addReport(
+ PDFReportsAPI::getInstance()->addReport(
$idSite,
'SMS Test report, all websites',
'day', // overridden in getApiForTestingScheduledReports()
0,
- Piwik_MobileMessaging::MOBILE_TYPE,
- Piwik_MobileMessaging::SMS_FORMAT,
+ MobileMessaging::MOBILE_TYPE,
+ MobileMessaging::SMS_FORMAT,
array("MultiSites_getAll"),
array("phoneNumbers" => array())
);
if (self::canImagesBeIncludedInScheduledReports()) {
// set-up mail report with images
- Piwik_PDFReports_API::getInstance()->addReport(
+ PDFReportsAPI::getInstance()->addReport(
$idSite,
'Mail Test report',
'day', // overridden in getApiForTestingScheduledReports()
0,
- Piwik_PDFReports::EMAIL_TYPE,
+ PDFReports::EMAIL_TYPE,
ReportRenderer::HTML_FORMAT, // overridden in getApiForTestingScheduledReports()
$availableReportIds,
- array(Piwik_PDFReports::DISPLAY_FORMAT_PARAMETER => Piwik_PDFReports::DISPLAY_FORMAT_TABLES_AND_GRAPHS)
+ array(PDFReports::DISPLAY_FORMAT_PARAMETER => PDFReports::DISPLAY_FORMAT_TABLES_AND_GRAPHS)
);
// set-up mail report with one row evolution based png graph
- Piwik_PDFReports_API::getInstance()->addReport(
+ PDFReportsAPI::getInstance()->addReport(
$idSite,
'Mail Test report',
'day',
0,
- Piwik_PDFReports::EMAIL_TYPE,
+ PDFReports::EMAIL_TYPE,
ReportRenderer::HTML_FORMAT,
array('Actions_getPageTitles'),
array(
- Piwik_PDFReports::DISPLAY_FORMAT_PARAMETER => Piwik_PDFReports::DISPLAY_FORMAT_GRAPHS_ONLY,
- Piwik_PDFReports::EVOLUTION_GRAPH_PARAMETER => 'true',
+ PDFReports::DISPLAY_FORMAT_PARAMETER => PDFReports::DISPLAY_FORMAT_GRAPHS_ONLY,
+ PDFReports::EVOLUTION_GRAPH_PARAMETER => 'true',
)
);
}
diff --git a/tests/PHPUnit/BenchmarkTestCase.php b/tests/PHPUnit/BenchmarkTestCase.php
index d62038a8e95..42b54260e64 100755
--- a/tests/PHPUnit/BenchmarkTestCase.php
+++ b/tests/PHPUnit/BenchmarkTestCase.php
@@ -8,6 +8,7 @@
use Piwik\Config;
use Piwik\Db;
use Piwik\Common;
+use Piwik\Plugins\Goals\API;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/IntegrationTestCase.php';
require_once PIWIK_INCLUDE_PATH . '/tests/LocalTracker.php';
@@ -107,7 +108,7 @@ public function setUp()
$this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
// add two goals
- $goals = Piwik_Goals_API::getInstance();
+ $goals = API::getInstance();
$goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
$goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains');
}
diff --git a/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php b/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php
index adf616fa279..2dcdbbec180 100644
--- a/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php
+++ b/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php
@@ -9,6 +9,7 @@
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Period;
use Piwik\Date;
+use Piwik\Plugins\VisitsSummary\API;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/BenchmarkTestCase.php';
@@ -24,7 +25,7 @@ public function setUp()
$archivingTables = ArchiveTableCreator::getTablesArchivesInstalled();
if (empty($archivingTables)) {
$this->archivingLaunched = true;
- Piwik_VisitsSummary_API::getInstance()->get(
+ API::getInstance()->get(
self::$fixture->idSite, self::$fixture->period, self::$fixture->date);
}
}
@@ -44,6 +45,6 @@ public function testArchivingProcess()
$period = Period::factory(self::$fixture->period, Date::factory(self::$fixture->date));
$dateRange = $period->getDateStart().','.$period->getDateEnd();
- Piwik_VisitsSummary_API::getInstance()->get(self::$fixture->idSite, 'day', $dateRange);
+ API::getInstance()->get(self::$fixture->idSite, 'day', $dateRange);
}
}
diff --git a/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php b/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php
index ad5d4504f8c..294ec73a121 100755
--- a/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php
+++ b/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php
@@ -5,6 +5,8 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\VisitsSummary\API;
+
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/BenchmarkTestCase.php';
/**
@@ -23,7 +25,7 @@ public function setUp()
*/
public function testArchivingProcess()
{
- Piwik_VisitsSummary_API::getInstance()->get(
+ API::getInstance()->get(
self::$fixture->idSite, self::$fixture->period, self::$fixture->date);
}
}
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php b/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
index 83569527d09..8f8fb4ef02a 100644
--- a/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Reusable fixture. Adds 20,000 sites and tracks one pageview for each on one day.
@@ -23,7 +24,7 @@ public function setUp()
$idSite = Test_Piwik_BaseFixture::createWebsite(
$this->date, $ecommerce = 1, $siteName = "Site #$i", $siteUrl = "http://site$i.com/");
- Piwik_Goals_API::getInstance()->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5);
+ API::getInstance()->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5);
}
// track one visit for each site
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
index 7696cda917a..42b3718212e 100644
--- a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds one site and 1000 actions for every day of one month (January). Each
@@ -25,7 +26,7 @@ public function setUp()
$this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
// add two goals
- $goals = Piwik_Goals_API::getInstance();
+ $goals = API::getInstance();
$goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
$goals->addGoal($this->idSite, 'all', 'url', 'thing2', 'contains');
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
index 743a77bad9b..1d7ea0462bf 100755
--- a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Reusable fixture. Tracks twelve thousand page views over a year for one site.
@@ -25,7 +26,7 @@ public function setUp()
$this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
// add two goals
- $goals = Piwik_Goals_API::getInstance();
+ $goals = API::getInstance();
$goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
$goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains');
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php b/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
index e56a16a5df4..2186c9e39cb 100755
--- a/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API as GoalsAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
* Reusable fixture. Tracks twelve thousand page views for 1000 sites on one day.
@@ -18,8 +20,7 @@ class Piwik_Test_Fixture_ThousandSitesTwelveVisitsEachOneDay
public function setUp()
{
- $sitesManager = Piwik_SitesManager_API::getInstance();
- $goals = Piwik_Goals_API::getInstance();
+ $goals = GoalsAPI::getInstance();
// add one thousand sites
$allIdSites = array();
diff --git a/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php b/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php
index a1390fc67ac..1954ba168d2 100644
--- a/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php
+++ b/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php
@@ -7,6 +7,8 @@
*/
use Piwik\ArchiveProcessor\Rules;
use Piwik\DataAccess\ArchiveTableCreator;
+use Piwik\Plugins\MultiSites\API as MultiSitesAPI;
+use Piwik\Plugins\VisitsSummary\API as VisitsSummaryAPI;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/BenchmarkTestCase.php';
@@ -22,7 +24,7 @@ public function setUp()
$archivingTables = ArchiveTableCreator::getTablesArchivesInstalled();
if (empty($archivingTables)) {
$this->archivingLaunched = true;
- Piwik_VisitsSummary_API::getInstance()->get(
+ VisitsSummaryAPI::getInstance()->get(
self::$fixture->idSite, self::$fixture->period, self::$fixture->date);
}
}
@@ -38,6 +40,6 @@ public function testArchivingProcess()
}
Rules::$archivingDisabledByTests = true;
- Piwik_MultiSites_API::getInstance()->getAll(self::$fixture->period, self::$fixture->date);
+ MultiSitesAPI::getInstance()->getAll(self::$fixture->period, self::$fixture->date);
}
}
diff --git a/tests/PHPUnit/Core/AccessTest.php b/tests/PHPUnit/Core/AccessTest.php
index 30e252732f3..732d8636e0d 100644
--- a/tests/PHPUnit/Core/AccessTest.php
+++ b/tests/PHPUnit/Core/AccessTest.php
@@ -396,11 +396,13 @@ public function testReloadAccessWithEmptyAuthSuperUser()
*/
public function testReloadAccessWithMockedAuthValid()
{
- $mock = $this->getMock('Piwik_Login_Auth', array('authenticate'));
+ $mock = $this->getMock('\\Piwik\\Auth', array('authenticate', 'getName'));
$mock->expects($this->once())
->method('authenticate')
->will($this->returnValue(new AuthResult(AuthResult::SUCCESS, 'login', 'token')));
+ $mock->expects($this->any())->method('getName')->will($this->returnValue("test name"));
+
$access = Access::getInstance();
$this->assertTrue($access->reloadAccess($mock));
$this->assertFalse($access->isSuperUser());
@@ -412,11 +414,12 @@ public function testReloadAccessWithMockedAuthValid()
*/
public function testReloadAccessWithMockedAuthSuperUser()
{
- $mock = $this->getMock('Piwik_Login_Auth', array('authenticate'));
+ $mock = $this->getMock('\\Piwik\\Auth', array('authenticate', 'getName'));
$mock->expects($this->once())
->method('authenticate')
->will($this->returnValue(new AuthResult(AuthResult::SUCCESS_SUPERUSER_AUTH_CODE, 'superuser', 'superusertoken')));
+ $mock->expects($this->any())->method('getName')->will($this->returnValue("test name"));
$access = Access::getInstance();
$this->assertTrue($access->reloadAccess($mock));
$this->assertTrue($access->isSuperUser());
@@ -428,11 +431,12 @@ public function testReloadAccessWithMockedAuthSuperUser()
*/
public function testReloadAccessWithMockedAuthInvalidUser()
{
- $mock = $this->getMock('Piwik_Login_Auth', array('authenticate'));
+ $mock = $this->getMock('\\Piwik\\Auth', array('authenticate', 'getName'));
$mock->expects($this->once())
->method('authenticate')
->will($this->returnValue(new AuthResult(AuthResult::FAILURE_CREDENTIAL_INVALID, null, null)));
+ $mock->expects($this->any())->method('getName')->will($this->returnValue("test name"));
$access = Access::getInstance();
$this->assertFalse($access->reloadAccess($mock));
}
diff --git a/tests/PHPUnit/Core/ArchiveProcessingTest.php b/tests/PHPUnit/Core/ArchiveProcessingTest.php
index b341c6960a0..657741eef21 100644
--- a/tests/PHPUnit/Core/ArchiveProcessingTest.php
+++ b/tests/PHPUnit/Core/ArchiveProcessingTest.php
@@ -15,6 +15,7 @@
use Piwik\Access;
use Piwik\Date;
use Piwik\ArchiveProcessor;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Segment;
use Piwik\Site;
use Piwik\Db;
@@ -39,7 +40,7 @@ public function setUp()
*/
private function _createWebsite($timezone = 'UTC')
{
- $idSite = Piwik_SitesManager_API::getInstance()->addSite(
+ $idSite = API::getInstance()->addSite(
"site1",
array("http://piwik.net"),
$ecommerce = 0,
diff --git a/tests/PHPUnit/Core/PiwikTest.php b/tests/PHPUnit/Core/PiwikTest.php
index 26a0339309f..d9ae053b253 100644
--- a/tests/PHPUnit/Core/PiwikTest.php
+++ b/tests/PHPUnit/Core/PiwikTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Piwik;
use Piwik\Access;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Translate;
class PiwikTest extends DatabaseTestCase
@@ -217,7 +218,7 @@ public function testGetPrettyValue($columnName, $value, $expected)
$access = Access::getInstance();
$access->setSuperUser(true);
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("test", "http://test");
+ $idsite = API::getInstance()->addSite("test", "http://test");
$this->assertEquals(
$expected,
diff --git a/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php b/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php
index 31b2cfc06cd..b246fa20c63 100644
--- a/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php
+++ b/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Access;
+use Piwik\Plugins\Goals\API;
use Piwik\WidgetsList;
class WidgetsListTest extends DatabaseTestCase
@@ -70,7 +71,7 @@ public function testGetWithGoals()
Access::setSingletonInstance($pseudoMockAccess);
Test_Piwik_BaseFixture::createWebsite('2009-01-04 00:11:42');
- Piwik_Goals_API::getInstance()->addGoal(1, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 1);
+ API::getInstance()->addGoal(1, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 1);
$_GET['idSite'] = 1;
@@ -107,7 +108,7 @@ public function testGetWithGoalsAndEcommerce()
Access::setSingletonInstance($pseudoMockAccess);
Test_Piwik_BaseFixture::createWebsite('2009-01-04 00:11:42', true);
- Piwik_Goals_API::getInstance()->addGoal(1, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 1);
+ API::getInstance()->addGoal(1, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 1);
$_GET['idSite'] = 1;
diff --git a/tests/PHPUnit/Core/ScheduledTaskTest.php b/tests/PHPUnit/Core/ScheduledTaskTest.php
index 7bb26624d9c..48602d9d96a 100644
--- a/tests/PHPUnit/Core/ScheduledTaskTest.php
+++ b/tests/PHPUnit/Core/ScheduledTaskTest.php
@@ -5,6 +5,7 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\PDFReports\PDFReports;
use Piwik\ScheduledTask;
require_once PIWIK_INCLUDE_PATH . '/plugins/PDFReports/PDFReports.php';
@@ -17,8 +18,8 @@ class ScheduledTaskTest extends PHPUnit_Framework_TestCase
*/
public function testGetClassName()
{
- $scheduledTask = new ScheduledTask (new Piwik_PDFReports(), null, null, null);
- $this->assertEquals('Piwik_PDFReports', $scheduledTask->getClassName());
+ $scheduledTask = new ScheduledTask (new PDFReports(), null, null, null);
+ $this->assertEquals('PDFReports', $scheduledTask->getClassName());
}
/**
@@ -27,10 +28,10 @@ public function testGetClassName()
public function getTaskNameTestCases()
{
return array(
- array('Piwik_CoreAdminHome.purgeOutdatedArchives', 'Piwik_CoreAdminHome', 'purgeOutdatedArchives', null),
- array('Piwik_CoreAdminHome.purgeOutdatedArchives_previous30', 'Piwik_CoreAdminHome', 'purgeOutdatedArchives', 'previous30'),
- array('Piwik_PDFReports.weeklySchedule', 'Piwik_PDFReports', 'weeklySchedule', null),
- array('Piwik_PDFReports.weeklySchedule_1', 'Piwik_PDFReports', 'weeklySchedule', 1),
+ array('CoreAdminHome.purgeOutdatedArchives', 'CoreAdminHome', 'purgeOutdatedArchives', null),
+ array('CoreAdminHome.purgeOutdatedArchives_previous30', 'CoreAdminHome', 'purgeOutdatedArchives', 'previous30'),
+ array('PDFReports.weeklySchedule', 'PDFReports', 'weeklySchedule', null),
+ array('PDFReports.weeklySchedule_1', 'PDFReports', 'weeklySchedule', 1),
);
}
diff --git a/tests/PHPUnit/Core/TaskSchedulerTest.php b/tests/PHPUnit/Core/TaskSchedulerTest.php
index ae6a80ba4bb..1e16e0c8a0f 100644
--- a/tests/PHPUnit/Core/TaskSchedulerTest.php
+++ b/tests/PHPUnit/Core/TaskSchedulerTest.php
@@ -15,8 +15,8 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase
private static function getTestTimetable()
{
return array(
- 'Piwik_CoreAdminHome.purgeOutdatedArchives' => 1355529607,
- 'Piwik_PrivacyManager.deleteReportData_1' => 1322229607,
+ 'CoreAdminHome.purgeOutdatedArchives' => 1355529607,
+ 'PrivacyManager.deleteReportData_1' => 1322229607,
);
}
@@ -37,10 +37,10 @@ public function getTimetableFromOptionValueTestCases()
// valid serialized array
array(
array(
- 'Piwik_CoreAdminHome.purgeOutdatedArchives' => 1355529607,
- 'Piwik_PrivacyManager.deleteReportData' => 1355529607,
+ 'CoreAdminHome.purgeOutdatedArchives' => 1355529607,
+ 'PrivacyManager.deleteReportData' => 1355529607,
),
- 'a:2:{s:41:"Piwik_CoreAdminHome.purgeOutdatedArchives";i:1355529607;s:37:"Piwik_PrivacyManager.deleteReportData";i:1355529607;}'
+ 'a:2:{s:35:"CoreAdminHome.purgeOutdatedArchives";i:1355529607;s:31:"PrivacyManager.deleteReportData";i:1355529607;}'
),
);
}
@@ -53,10 +53,9 @@ public function getTimetableFromOptionValueTestCases()
public function testGetTimetableFromOptionValue($expectedTimetable, $option)
{
$getTimetableFromOptionValue = new ReflectionMethod(
- '\Piwik\TaskScheduler', 'getTimetableFromOptionValue'
+ '\\Piwik\\TaskScheduler', 'getTimetableFromOptionValue'
);
$getTimetableFromOptionValue->setAccessible(true);
-
$this->assertEquals($expectedTimetable, $getTimetableFromOptionValue->invoke(new TaskScheduler(), $option));
}
@@ -68,9 +67,9 @@ public function taskHasBeenScheduledOnceTestCases()
$timetable = self::getTestTimetable();
return array(
- array(true, 'Piwik_CoreAdminHome.purgeOutdatedArchives', $timetable),
- array(true, 'Piwik_PrivacyManager.deleteReportData_1', $timetable),
- array(false, 'Piwik_PDFReports.weeklySchedule"', $timetable)
+ array(true, 'CoreAdminHome.purgeOutdatedArchives', $timetable),
+ array(true, 'PrivacyManager.deleteReportData_1', $timetable),
+ array(false, 'PDFReports.weeklySchedule"', $timetable)
);
}
@@ -97,9 +96,9 @@ public function getScheduledTimeForMethodTestCases()
$timetable = serialize(self::getTestTimetable());
return array(
- array(1355529607, 'Piwik_CoreAdminHome', 'purgeOutdatedArchives', null, $timetable),
- array(1322229607, 'Piwik_PrivacyManager', 'deleteReportData', 1, $timetable),
- array(false, 'Piwik_PDFReports', 'weeklySchedule', null, $timetable)
+ array(1355529607, 'CoreAdminHome', 'purgeOutdatedArchives', null, $timetable),
+ array(1322229607, 'PrivacyManager', 'deleteReportData', 1, $timetable),
+ array(false, 'PDFReports', 'weeklySchedule', null, $timetable)
);
}
@@ -125,15 +124,15 @@ public function taskShouldBeExecutedTestCases()
$timetable = self::getTestTimetable();
// set a date in the future (should not run)
- $timetable['Piwik_CoreAdminHome.purgeOutdatedArchives'] = time() + 60000;
+ $timetable['CoreAdminHome.purgeOutdatedArchives'] = time() + 60000;
// set now (should run)
- $timetable['Piwik_PrivacyManager.deleteReportData_1'] = time();
+ $timetable['PrivacyManager.deleteReportData_1'] = time();
return array(
- array(false, 'Piwik_CoreAdminHome.purgeOutdatedArchives', $timetable),
- array(true, 'Piwik_PrivacyManager.deleteReportData_1', $timetable),
- array(false, 'Piwik_PDFReports.weeklySchedule"', $timetable)
+ array(false, 'CoreAdminHome.purgeOutdatedArchives', $timetable),
+ array(true, 'PrivacyManager.deleteReportData_1', $timetable),
+ array(false, 'PDFReports.weeklySchedule"', $timetable)
);
}
@@ -308,7 +307,7 @@ public function testRunTasks($expectedTimetable, $expectedExecutedTasks, $timeta
$this->assertEquals($expectedExecutedTasks, $executedTasks);
// assert the timetable is correctly updated
- $getTimetableFromOptionTable = new ReflectionMethod('\Piwik\TaskScheduler', 'getTimetableFromOptionTable');
+ $getTimetableFromOptionTable = new ReflectionMethod('\\Piwik\\TaskScheduler', 'getTimetableFromOptionTable');
$getTimetableFromOptionTable->setAccessible(true);
$this->assertEquals($expectedTimetable, $getTimetableFromOptionTable->invoke(new TaskScheduler()));
diff --git a/tests/PHPUnit/Core/Tracker/ActionTest.php b/tests/PHPUnit/Core/Tracker/ActionTest.php
index f04bfafea55..95a0444d4bf 100644
--- a/tests/PHPUnit/Core/Tracker/ActionTest.php
+++ b/tests/PHPUnit/Core/Tracker/ActionTest.php
@@ -1,6 +1,7 @@
setUpRootAccess();
- $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
+ $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null,
$excludedIps = '', $excludedQueryParameters = '', $timezone = null, $currency = null,
$group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1);
@@ -157,7 +158,7 @@ public function testExcludeQueryParametersSiteExcluded($url, $filteredUrl)
{
$excludedQueryParameters = 'p4, p2, var[value][date]';
$this->setUpRootAccess();
- $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
+ $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null,
$excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null,
$group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1);
@@ -177,11 +178,11 @@ public function testExcludeQueryParametersSiteAndGlobalExcluded($url, $filteredU
$excludedQueryParameters = 'P2,var[value][date]';
$excludedGlobalParameters = 'blabla, P4';
$this->setUpRootAccess();
- $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
+ $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null,
$excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null,
$group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1);
- Piwik_SitesManager_API::getInstance()->setGlobalExcludedQueryParameters($excludedGlobalParameters);
+ API::getInstance()->setGlobalExcludedQueryParameters($excludedGlobalParameters);
$this->assertEquals($filteredUrl[1], Action::excludeQueryParametersFromUrl($url, $idSite));
}
@@ -366,7 +367,7 @@ public function getExtractUrlData()
public function testExtractUrlAndActionNameFromRequest($request, $expected)
{
$this->setUpRootAccess();
- $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'));
+ $idSite = API::getInstance()->addSite("site1", array('http://example.org'));
$request['idsite'] = $idSite;
$request = new Request($request);
$action = new Test_Piwik_TrackerAction_extractUrlAndActionNameFromRequest($request);
diff --git a/tests/PHPUnit/Core/Tracker/VisitTest.php b/tests/PHPUnit/Core/Tracker/VisitTest.php
index dd5490f2ff4..0de590116cb 100644
--- a/tests/PHPUnit/Core/Tracker/VisitTest.php
+++ b/tests/PHPUnit/Core/Tracker/VisitTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Access;
use Piwik\IP;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Tracker\VisitExcluded;
use Piwik\Tracker\Request;
@@ -74,7 +75,7 @@ public function getExcludedIpTestData()
*/
public function testIsVisitorIpExcluded($excludedIp, $tests)
{
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0,
+ $idsite = API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIp);
$request = new Request(array('idsite' => $idsite));
@@ -121,9 +122,9 @@ public function getExcludedUserAgentTestData()
*/
public function testIsVisitorUserAgentExcluded($excludedUserAgent, $tests)
{
- Piwik_SitesManager_API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(true);
+ API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(true);
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0,
+ $idsite = API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIp = null,
$excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null,
$excludedUserAgent);
diff --git a/tests/PHPUnit/DatabaseTestCase.php b/tests/PHPUnit/DatabaseTestCase.php
index 47a34f8bbe5..39395c375dc 100644
--- a/tests/PHPUnit/DatabaseTestCase.php
+++ b/tests/PHPUnit/DatabaseTestCase.php
@@ -10,6 +10,7 @@
use Piwik\DataTable\Manager;
use Piwik\Piwik;
use Piwik\Option;
+use Piwik\Plugins\PDFReports\API;
use Piwik\Site;
use Piwik\Tracker\Cache;
@@ -71,7 +72,7 @@ public function tearDown()
Piwik::dropDatabase();
Manager::getInstance()->deleteAll();
Option::getInstance()->clearCache();
- Piwik_PDFReports_API::$cache = array();
+ API::$cache = array();
Site::clearCache();
Cache::deleteTrackerCache();
Config::getInstance()->clear();
diff --git a/tests/PHPUnit/FakeAccess.php b/tests/PHPUnit/FakeAccess.php
index 0498531052a..5b72265dfff 100644
--- a/tests/PHPUnit/FakeAccess.php
+++ b/tests/PHPUnit/FakeAccess.php
@@ -5,6 +5,7 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\SitesManager\API;
use Piwik\Site;
/**
@@ -64,7 +65,7 @@ public static function checkUserHasAdminAccess($idSites)
if (!self::$superUser) {
$websitesAccess = self::$idSitesAdmin;
} else {
- $websitesAccess = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $websitesAccess = API::getInstance()->getAllSitesId();
}
$idSites = Site::getIdSitesFromIdSitesString($idSites);
@@ -81,12 +82,12 @@ public static function checkUserHasViewAccess($idSites)
if (!self::$superUser) {
$websitesAccess = array_merge(self::$idSitesView, self::$idSitesAdmin);
} else {
- $websitesAccess = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $websitesAccess = API::getInstance()->getAllSitesId();
}
if (!is_array($idSites)) {
if ($idSites == 'all') {
- $idSites = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $idSites = API::getInstance()->getAllSitesId();
} else {
$idSites = explode(',', $idSites);
}
@@ -134,7 +135,7 @@ public static function getLogin()
public static function getSitesIdWithAdminAccess()
{
if (self::$superUser) {
- return Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ return API::getInstance()->getAllSitesId();
}
return self::$idSitesAdmin;
}
@@ -142,7 +143,7 @@ public static function getSitesIdWithAdminAccess()
public static function getSitesIdWithViewAccess()
{
if (self::$superUser) {
- return Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ return API::getInstance()->getAllSitesId();
}
return self::$idSitesView;
}
@@ -150,7 +151,7 @@ public static function getSitesIdWithViewAccess()
public static function getSitesIdWithAtLeastViewAccess()
{
if (self::$superUser) {
- return Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ return API::getInstance()->getAllSitesId();
}
return array_merge(self::$idSitesView, self::$idSitesAdmin);
}
diff --git a/tests/PHPUnit/Fixtures/InvalidVisits.php b/tests/PHPUnit/Fixtures/InvalidVisits.php
index 144227e1c06..8e31367b587 100644
--- a/tests/PHPUnit/Fixtures/InvalidVisits.php
+++ b/tests/PHPUnit/Fixtures/InvalidVisits.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Http;
+use Piwik\Plugins\SitesManager\API;
/**
* Adds one site and sends several invalid tracking requests. The result should be
@@ -43,8 +44,8 @@ private function trackVisits()
$dateTime = $this->dateTime;
$idSite = $this->idSite;
- Piwik_SitesManager_API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(true);
- Piwik_SitesManager_API::getInstance()->setGlobalExcludedUserAgents('globalexcludeduseragent');
+ API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(true);
+ API::getInstance()->setGlobalExcludedUserAgents('globalexcludeduseragent');
// Trigger empty request
$trackerUrl = self::getTrackerUrl();
@@ -60,7 +61,7 @@ private function trackVisits()
// Test IP Exclusion works with or without IP exclusion
foreach (array(false, true) as $enable) {
$excludedIp = '154.1.12.34';
- Piwik_SitesManager_API::getInstance()->updateSite($idSite, 'new site name', $url = array('http://site.com'), $ecommerce = 0, $ss = 1, $ss_kwd = '', $ss_cat = '', $excludedIp . ',1.2.3.4', $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = 'excludeduseragentstring');
+ API::getInstance()->updateSite($idSite, 'new site name', $url = array('http://site.com'), $ecommerce = 0, $ss = 1, $ss_kwd = '', $ss_cat = '', $excludedIp . ',1.2.3.4', $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = 'excludeduseragentstring');
// Enable IP Anonymization
$t->DEBUG_APPEND_URL = '&forceIpAnonymization=' . (int)$enable;
@@ -82,7 +83,7 @@ private function trackVisits()
// test with global list of excluded IPs
$excludedIpBis = '145.5.3.4';
- Piwik_SitesManager_API::getInstance()->setGlobalExcludedIps($excludedIpBis);
+ API::getInstance()->setGlobalExcludedIps($excludedIpBis);
$t->setIp($excludedIpBis);
self::checkResponse($t->doTrackPageView('visit from IP globally excluded'));
}
diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
index 8cd88282d56..00195af7806 100644
--- a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
+++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
@@ -6,6 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Access;
+use Piwik\Plugins\Goals\API as GoalsAPI;
+use Piwik\Plugins\SegmentEditor\API as SegmentEditorAPI;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
/**
* Imports visits from several log files using the python log importer.
@@ -25,9 +29,9 @@ public function setUp()
$this->setUpWebsitesAndGoals();
self::downloadGeoIpDbs();
- Piwik_UserCountry_LocationProvider::$providers = null;
- Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
- Piwik_UserCountry_LocationProvider::setCurrentProvider('geoip_php');
+ LocationProvider::$providers = null;
+ GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
+ LocationProvider::setCurrentProvider('geoip_php');
$this->trackVisits();
$this->setupSegments();
@@ -35,16 +39,16 @@ public function setUp()
public function tearDown()
{
- Piwik_UserCountry_LocationProvider::$providers = null;
- Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
- Piwik_UserCountry_LocationProvider::setCurrentProvider('default');
+ LocationProvider::$providers = null;
+ GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
+ LocationProvider::setCurrentProvider('default');
}
public function setUpWebsitesAndGoals()
{
// for conversion testing
self::createWebsite($this->dateTime);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
+ GoalsAPI::getInstance()->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'Piwik test two',
$siteUrl = 'http://example-site-two.com');
}
@@ -101,7 +105,7 @@ private function setupSegments()
$enabledAllUsers = $info['enabledAllUsers'];
}
- Piwik_SegmentEditor_API::getInstance()->add(
+ SegmentEditorAPI::getInstance()->add(
$segmentName, $info['definition'], $idSite, $autoArchive, $enabledAllUsers);
}
}
diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
index 9e41a649558..57611b8c04e 100644
--- a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
+++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
@@ -7,6 +7,9 @@
*/
use Piwik\Common;
use Piwik\FrontController;
+use Piwik\Plugins\Annotations\API as AnnotationsAPI;
+use Piwik\Plugins\Goals\API as GoalsAPI;
+use Piwik\Plugins\SegmentEditor\API as SegmentEditorAPI;
use Piwik\WidgetsList;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php';
@@ -31,7 +34,7 @@ public function setUpWebsitesAndGoals()
// for conversion testing
$siteName = self::makeXssContent("site name", $sanitize = true);
self::createWebsite($this->dateTime, $ecommerce = 1, $siteName);
- Piwik_Goals_API::getInstance()->addGoal(
+ GoalsAPI::getInstance()->addGoal(
$this->idSite, self::makeXssContent("goal name"), 'url', 'http', 'contains', false, 5);
self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'Piwik test two',
@@ -101,16 +104,16 @@ public function setupXssSegment()
{
$segmentName = self::makeXssContent('segment');
$segmentDefinition = "browserCode==FF";
- Piwik_SegmentEditor_API::getInstance()->add(
+ SegmentEditorAPI::getInstance()->add(
$segmentName, $segmentDefinition, $this->idSite, $autoArchive = true, $enabledAllUsers = true);
}
public function addAnnotations()
{
- Piwik_Annotations_API::getInstance()->add($this->idSite, '2012-08-09', "Note 1", $starred = 1);
- Piwik_Annotations_API::getInstance()->add(
+ AnnotationsAPI::getInstance()->add($this->idSite, '2012-08-09', "Note 1", $starred = 1);
+ AnnotationsAPI::getInstance()->add(
$this->idSite, '2012-08-08', self::makeXssContent("annotation"), $starred = 0);
- Piwik_Annotations_API::getInstance()->add($this->idSite, '2012-08-10', "Note 3", $starred = 1);
+ AnnotationsAPI::getInstance()->add($this->idSite, '2012-08-10', "Note 3", $starred = 1);
}
// NOTE: since API_Request does sanitization, API methods do not. when calling them, we must
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
index 074433d85fe..916a7b46607 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
@@ -7,6 +7,9 @@
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php';
@@ -63,8 +66,8 @@ public function tearDown()
private function setUpWebsitesAndGoals()
{
self::createWebsite($this->dateTime, 0, "Site 1");
- $this->idGoal = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
- $this->idGoal2 = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'two', 'url', 'xxxxxxxxxxxxx', 'contains', false, 5);
+ $this->idGoal = API::getInstance()->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
+ $this->idGoal2 = API::getInstance()->addGoal($this->idSite, 'two', 'url', 'xxxxxxxxxxxxx', 'contains', false, 5);
}
private function trackVisits($visitorCount, $setIp = false, $useLocal = true, $doBulk = false)
@@ -167,25 +170,25 @@ private function trackOtherVisits()
private function setLocationProvider($file)
{
- Piwik_UserCountry_LocationProvider_GeoIp::$dbNames['loc'] = array($file);
- Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
- Piwik_UserCountry_LocationProvider::$providers = null;
- Piwik_UserCountry_LocationProvider::setCurrentProvider(self::GEOIP_IMPL_TO_TEST);
+ GeoIp::$dbNames['loc'] = array($file);
+ GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
+ LocationProvider::$providers = null;
+ LocationProvider::setCurrentProvider(self::GEOIP_IMPL_TO_TEST);
- if (Piwik_UserCountry_LocationProvider::getCurrentProviderId() !== self::GEOIP_IMPL_TO_TEST) {
+ if (LocationProvider::getCurrentProviderId() !== self::GEOIP_IMPL_TO_TEST) {
throw new Exception("Failed to set the current location provider to '" . self::GEOIP_IMPL_TO_TEST . "'.");
}
- $possibleFiles = Piwik_UserCountry_LocationProvider_GeoIp::$dbNames['loc'];
- if (Piwik_UserCountry_LocationProvider_GeoIp::getPathToGeoIpDatabase($possibleFiles) === false) {
+ $possibleFiles = GeoIp::$dbNames['loc'];
+ if (GeoIp::getPathToGeoIpDatabase($possibleFiles) === false) {
throw new Exception("The GeoIP location provider cannot find the '$file' file! Tests will fail.");
}
}
private function setMockLocationProvider()
{
- Piwik_UserCountry_LocationProvider::$providers = null;
- Piwik_UserCountry_LocationProvider::setCurrentProvider('mock_provider');
+ LocationProvider::$providers = null;
+ LocationProvider::setCurrentProvider('mock_provider');
MockLocationProvider::$locations = array(
self::makeLocation('Stratford-upon-Avon', 'P3', 'gb', 123.456, 21.321), // template location
@@ -217,7 +220,7 @@ private function setMockLocationProvider()
private function unsetLocationProvider()
{
- Piwik_UserCountry_LocationProvider::setCurrentProvider('default');
+ LocationProvider::setCurrentProvider('default');
}
}
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
index be3d29c30fc..e3a0997340d 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
@@ -7,6 +7,7 @@
*/
use Piwik\Date;
+use Piwik\Plugins\UserCountry\LocationProvider;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php';
@@ -204,7 +205,7 @@ private function trackAction($t, $actionType, $visitorCounter, $actionNum)
private function setMockLocationProvider()
{
- Piwik_UserCountry_LocationProvider::setCurrentProvider('mock_provider');
+ LocationProvider::setCurrentProvider('mock_provider');
MockLocationProvider::$locations = array(
self::makeLocation('Toronto', 'ON', 'CA', $lat = null, $long = null, $isp = 'comcast.net'),
@@ -218,6 +219,6 @@ private function setMockLocationProvider()
private function unsetMockLocationProvider()
{
- Piwik_UserCountry_LocationProvider::setCurrentProvider('default');
+ LocationProvider::setCurrentProvider('default');
}
}
diff --git a/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php b/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
index 64c3312628f..e2323cd60ee 100644
--- a/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
+++ b/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API as GoalsAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
* This fixture adds one website and tracks two visits by one visitor.
@@ -41,7 +43,7 @@ private function trackVisits()
$idSite = $this->idSite;
if ($this->excludeMozilla) {
- Piwik_SitesManager_API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(false);
+ SitesManagerAPI::getInstance()->setSiteSpecificUserAgentExcludeEnabled(false);
}
$t = self::getTracker($idSite, $dateTime, $defaultInit = true);
@@ -56,7 +58,7 @@ private function trackVisits()
// testing URL excluded parameters
$parameterToExclude = 'excluded_parameter';
- Piwik_SitesManager_API::getInstance()->updateSite(
+ SitesManagerAPI::getInstance()->updateSite(
$idSite,
'new name',
$url = array('http://site.com'),
@@ -102,7 +104,7 @@ private function trackVisits()
self::checkResponse($t->doTrackAction('http://dev.piwik.org/svn', 'link'));
// Create Goal 1: Triggered by JS, after 18 minutes
- $idGoal = Piwik_Goals_API::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
+ $idGoal = GoalsAPI::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.3)->getDatetime());
// Change to Thai browser to ensure the conversion is credited to FR instead (the visitor initial country)
@@ -139,7 +141,7 @@ private function trackVisits()
// End of first visit: 24min
// Create Goal 2: Matching on URL
- Piwik_Goals_API::getInstance()->addGoal($idSite, 'matching purchase.htm', 'url', '(.*)store\/purchase\.(.*)', 'regex', false, $revenue = 1);
+ GoalsAPI::getInstance()->addGoal($idSite, 'matching purchase.htm', 'url', '(.*)store\/purchase\.(.*)', 'regex', false, $revenue = 1);
// -
// Start of returning visit, 1 hour after first page view
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php b/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
index ad47b32696a..272a8091540 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds one site and tracks a couple conversions.
@@ -33,13 +34,13 @@ private function setUpWebsitesAndGoals()
self::createWebsite($this->dateTime);
// First, a goal that is only recorded once per visit
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal(
$this->idSite, 'triggered js ONCE', 'title', 'Thank you', 'contains', $caseSensitive = false,
$revenue = 10, $allowMultipleConversions = false
);
// Second, a goal allowing multiple conversions
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal(
$this->idSite, 'triggered js MULTIPLE ALLOWED', 'manually', '', '', $caseSensitive = false,
$revenue = 10, $allowMultipleConversions = true
);
@@ -68,10 +69,10 @@ private function trackVisits()
self::checkResponse($t->doTrackGoal($idGoal_MultipleConversionPerVisit, $revenue = 366));
// Update & set to not allow multiple
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
$goal = $goals[$idGoal_OneConversionPerVisit];
self::assertTrue($goal['allow_multiple'] == 0);
- Piwik_Goals_API::getInstance()->updateGoal($idSite, $idGoal_OneConversionPerVisit, $goal['name'], @$goal['match_attribute'], @$goal['pattern'], @$goal['pattern_type'], @$goal['case_sensitive'], $goal['revenue'], $goal['allow_multiple'] = 1);
+ API::getInstance()->updateGoal($idSite, $idGoal_OneConversionPerVisit, $goal['name'], @$goal['match_attribute'], @$goal['pattern'], @$goal['pattern_type'], @$goal['case_sensitive'], $goal['revenue'], $goal['allow_multiple'] = 1);
self::assertTrue($goal['allow_multiple'] == 1);
// 1st goal should Now be tracked
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
index be0e42eed9e..57f7826bd11 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Add one site and track many visits with custom variables & campaign IDs and
@@ -31,7 +32,7 @@ public function tearDown()
private function setUpWebsitesAndGoals()
{
self::createWebsite($this->dateTime);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
+ API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
}
private function trackVisits()
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php b/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
index 199fc691232..23819ec4e30 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\SitesManager\API;
/**
* Adds one website and some visits with non unicode page titles.
@@ -33,7 +34,7 @@ public function tearDown()
*/
private function setUpWebsites()
{
- Piwik_SitesManager_API::getInstance()->setGlobalSearchParameters($searchKeywordParameters = 'gkwd', $searchCategoryParameters = 'gcat');
+ API::getInstance()->setGlobalSearchParameters($searchKeywordParameters = 'gkwd', $searchCategoryParameters = 'gcat');
self::createWebsite(Date::factory($this->dateTime)->getDatetime(), 0, "Site 1 - Site search", $siteurl = false, $search = 1, $searchKwd = 'q,mykwd,p', $searchCat = 'cats');
}
diff --git a/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php b/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
index 3ef00a51887..71d0be9fb0b 100644
--- a/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
+++ b/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Fixture that adds one site with three goals and tracks one pageview & one manual
@@ -33,17 +34,17 @@ public function tearDown()
private function setUpWebsitesAndGoals()
{
self::createWebsite($this->dateTime, $ecommerce = 1);
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal(
$this->idSite, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false,
$revenue = 10, $allowMultipleConversions = 1
);
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal(
$this->idSite, 'Goal 2 - Hello', 'url', 'hellow', 'contains', $caseSensitive = false,
$revenue = 10, $allowMultipleConversions = 0
);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
+ API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
}
private function trackVisits()
diff --git a/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php b/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
index a5b747debf6..cecddf208aa 100644
--- a/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
+++ b/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\SitesManager\API;
/**
* Adds three websites with different site search configurations and adds
@@ -36,7 +37,7 @@ public function tearDown()
*/
protected function setUpWebsites()
{
- Piwik_SitesManager_API::getInstance()->setGlobalSearchParameters($searchKeywordParameters = 'gkwd', $searchCategoryParameters = 'gcat');
+ API::getInstance()->setGlobalSearchParameters($searchKeywordParameters = 'gkwd', $searchCategoryParameters = 'gcat');
self::createWebsite(Date::factory($this->dateTime)->subHour(200)->getDatetime(), 0, "Site 1 - Site search", $siteurl = false, $search = 1, $searchKwd = 'q,mykwd,p', $searchCat = 'cats');
self::createWebsite(Date::factory($this->dateTime)->subHour(400)->getDatetime(), 0, "Site 2 - Site search use default", $siteurl = false, $search = 1, $searchKwd = '', $searchCat = '');
self::createWebsite(Date::factory($this->dateTime)->subHour(600)->getDatetime(), 0, "Site 3 - No site search", $siteurl = false, $search = 0);
diff --git a/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php b/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
index 33e244d7cac..675bf59fa74 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds two sites and tracks some visits with ecommerce orders.
@@ -33,7 +34,7 @@ private function setUpWebsitesAndGoals()
{
self::createWebsite($this->dateTime, $ecommerce = 1);
self::createWebsite($this->dateTime);
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal(
$this->idSite, 'title match, triggered ONCE', 'title', 'incredible', 'contains',
$caseSensitive = false, $revenue = 10, $allowMultipleConversions = true
);
diff --git a/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php b/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
index a122bb5436e..4ff6ab125c4 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds one website and tracks visits on different days over a month
@@ -38,8 +39,8 @@ private function setUpWebsitesAndGoals()
$siteCreated = '2010-02-01 11:22:33';
self::createWebsite($siteCreated);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'triggered php', 'manually', '', '');
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal($this->idSite, 'triggered php', 'manually', '', '');
+ API::getInstance()->addGoal(
$this->idSite, 'another triggered php', 'manually', '', '', false, false, true);
self::createWebsite($siteCreated);
diff --git a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
index ad7dfa04760..bac08e43469 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API as GoalsAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
* Adds two websites and tracks visits from two visitors on different days.
@@ -41,16 +43,16 @@ private function setUpWebsitesAndGoals()
self::createWebsite($this->dateTime, 0, "Site 2");
if ($this->allowConversions) {
- Piwik_Goals_API::getInstance()->addGoal($this->idSite1, 'all', 'url', 'http', 'contains', false, 5);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite2, 'all', 'url', 'http', 'contains');
+ GoalsAPI::getInstance()->addGoal($this->idSite1, 'all', 'url', 'http', 'contains', false, 5);
+ GoalsAPI::getInstance()->addGoal($this->idSite2, 'all', 'url', 'http', 'contains');
}
- Piwik_SitesManager_API::getInstance()->updateSite(
+ SitesManagerAPI::getInstance()->updateSite(
$this->idSite1, "Site 1", $urls = null, $ecommerce = null, $siteSearch = null,
$searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null,
$excludedQueryParameters = null, $timezone = null, $currency = null, $group = null,
$startDate = null, $excludedUserAgents = null, $keepURLFragments = 2); // KEEP_URL_FRAGMENT_NO No for idSite 1
- Piwik_SitesManager_API::getInstance()->updateSite(
+ SitesManagerAPI::getInstance()->updateSite(
$this->idSite2, "Site 2", $urls = null, $ecommerce = null, $siteSearch = null,
$searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null,
$excludedQueryParameters = null, $timezone = null, $currency = null, $group = null,
diff --git a/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php b/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
index 83b4eded013..29f9d75da8a 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
@@ -7,6 +7,7 @@
*/
use Piwik\Access;
use Piwik\Date;
+use Piwik\Plugins\Annotations\API;
/**
* A fixture that adds two websites and annotations for each website.
@@ -45,8 +46,8 @@ private function addAnnotations()
$site1Text = "$count: Site 1 annotation for " . $dateStart->toString();
$site2Text = "$count: Site 2 annotation for " . $dateStart->toString();
- Piwik_Annotations_API::getInstance()->add($this->idSite1, $dateStart->toString(), $site1Text, $starred);
- Piwik_Annotations_API::getInstance()->add($this->idSite2, $dateStart->toString(), $site2Text, $starred);
+ API::getInstance()->add($this->idSite1, $dateStart->toString(), $site1Text, $starred);
+ API::getInstance()->add($this->idSite2, $dateStart->toString(), $site2Text, $starred);
$nextDay = $dateStart->addDay(1);
++$count;
@@ -55,8 +56,8 @@ private function addAnnotations()
$site1Text = "$count: Site 1 annotation for " . $nextDay->toString();
$site2Text = "$count: Site 2 annotation for " . $nextDay->toString();
- Piwik_Annotations_API::getInstance()->add($this->idSite1, $nextDay->toString(), $site1Text, $starred);
- Piwik_Annotations_API::getInstance()->add($this->idSite2, $nextDay->toString(), $site2Text, $starred);
+ API::getInstance()->add($this->idSite1, $nextDay->toString(), $site1Text, $starred);
+ API::getInstance()->add($this->idSite2, $nextDay->toString(), $site2Text, $starred);
$dateStart = $dateStart->addPeriod(1, 'WEEK');
++$count;
diff --git a/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php b/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
index fe28c492d9d..2e69bacded2 100644
--- a/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
+++ b/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds one site and tracks two visits. One visit is a bot and one has no keyword
@@ -49,7 +50,7 @@ private function trackVisits()
$t->setUrlReferrer('http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC&url=http%3A%2F%2Fpiwik.org%2F&ei=&usg=');
$t->setUrl('http://example.org/this%20is%20cool!');
self::checkResponse($t->doTrackPageView('incredible title!'));
- $idGoal = Piwik_Goals_API::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
+ $idGoal = API::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.3)->getDatetime());
self::checkResponse($t->doTrackGoal($idGoal, $revenue = 42));
diff --git a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
index 5ab144c1157..735d2bf726b 100644
--- a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
+++ b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds one site with two goals and tracks two visits with custom variables.
@@ -39,8 +40,8 @@ private function setUpWebsitesAndGoals()
{
// tests run in UTC, the Tracker in UTC
self::createWebsite($this->dateTime);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'second goal', 'manually', '', '');
+ API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
+ API::getInstance()->addGoal($this->idSite, 'second goal', 'manually', '', '');
}
private function trackVisits()
diff --git a/tests/PHPUnit/Integration/AnnotationsTest.php b/tests/PHPUnit/Integration/AnnotationsTest.php
index b7322b5a926..5d7b29ccb9e 100755
--- a/tests/PHPUnit/Integration/AnnotationsTest.php
+++ b/tests/PHPUnit/Integration/AnnotationsTest.php
@@ -8,6 +8,7 @@
use Piwik\API\Request;
use Piwik\Access;
+use Piwik\Plugins\Annotations\API;
class AnnotationsTest extends IntegrationTestCase
{
@@ -94,7 +95,7 @@ public function testApi($api, $params)
public function testAddMultipleSitesFail()
{
try {
- Piwik_Annotations_API::getInstance()->add("1,2,3", "2012-01-01", "whatever");
+ API::getInstance()->add("1,2,3", "2012-01-01", "whatever");
$this->fail("add should fail when given multiple sites in idSite");
} catch (Exception $ex) {
// pass
@@ -108,7 +109,7 @@ public function testAddMultipleSitesFail()
public function testAddInvalidDateFail()
{
try {
- Piwik_Annotations_API::getInstance()->add(self::$fixture->idSite1, "invaliddate", "whatever");
+ API::getInstance()->add(self::$fixture->idSite1, "invaliddate", "whatever");
$this->fail("add should fail when given invalid date");
} catch (Exception $ex) {
// pass
@@ -122,7 +123,7 @@ public function testAddInvalidDateFail()
public function testSaveMultipleSitesFail()
{
try {
- Piwik_Annotations_API::getInstance()->save("1,2,3", 0);
+ API::getInstance()->save("1,2,3", 0);
$this->fail("save should fail when given multiple sites");
} catch (Exception $ex) {
// pass
@@ -136,7 +137,7 @@ public function testSaveMultipleSitesFail()
public function testSaveInvalidDateFail()
{
try {
- Piwik_Annotations_API::getInstance()->save(self::$fixture->idSite1, 0, "invaliddate");
+ API::getInstance()->save(self::$fixture->idSite1, 0, "invaliddate");
$this->fail("save should fail when given an invalid date");
} catch (Exception $ex) {
// pass
@@ -150,7 +151,7 @@ public function testSaveInvalidDateFail()
public function testSaveInvalidNoteIdFail()
{
try {
- Piwik_Annotations_API::getInstance()->save(self::$fixture->idSite1, -1);
+ API::getInstance()->save(self::$fixture->idSite1, -1);
$this->fail("save should fail when given an invalid note id");
} catch (Exception $ex) {
// pass
@@ -164,7 +165,7 @@ public function testSaveInvalidNoteIdFail()
public function testDeleteMultipleSitesFail()
{
try {
- Piwik_Annotations_API::getInstance()->delete("1,2,3", 0);
+ API::getInstance()->delete("1,2,3", 0);
$this->fail("delete should fail when given multiple site IDs");
} catch (Exception $ex) {
// pass
@@ -178,7 +179,7 @@ public function testDeleteMultipleSitesFail()
public function testDeleteInvalidNoteIdFail()
{
try {
- Piwik_Annotations_API::getInstance()->delete(self::$fixture->idSite1, -1);
+ API::getInstance()->delete(self::$fixture->idSite1, -1);
$this->fail("delete should fail when given an invalid site ID");
} catch (Exception $ex) {
// pass
@@ -192,7 +193,7 @@ public function testDeleteInvalidNoteIdFail()
public function testGetMultipleSitesFail()
{
try {
- Piwik_Annotations_API::getInstance()->get("1,2,3", 0);
+ API::getInstance()->get("1,2,3", 0);
$this->fail("get should fail when given multiple site IDs");
} catch (Exception $ex) {
// pass
@@ -206,7 +207,7 @@ public function testGetMultipleSitesFail()
public function testGetInvalidNoteIdFail()
{
try {
- Piwik_Annotations_API::getInstance()->get(self::$fixture->idSite1, -1);
+ API::getInstance()->get(self::$fixture->idSite1, -1);
$this->fail("get should fail when given an invalid note ID");
} catch (Exception $ex) {
// pass
@@ -219,7 +220,7 @@ public function testGetInvalidNoteIdFail()
*/
public function testSaveSuccess()
{
- Piwik_Annotations_API::getInstance()->save(
+ API::getInstance()->save(
self::$fixture->idSite1, 0, $date = '2011-04-01', $note = 'new note text', $starred = 1);
$expectedAnnotation = array(
@@ -230,7 +231,7 @@ public function testSaveSuccess()
'idNote' => 0,
'canEditOrDelete' => true
);
- $this->assertEquals($expectedAnnotation, Piwik_Annotations_API::getInstance()->get(self::$fixture->idSite1, 0));
+ $this->assertEquals($expectedAnnotation, API::getInstance()->get(self::$fixture->idSite1, 0));
}
/**
@@ -239,7 +240,7 @@ public function testSaveSuccess()
*/
public function testSaveNoChangesSuccess()
{
- Piwik_Annotations_API::getInstance()->save(self::$fixture->idSite1, 1);
+ API::getInstance()->save(self::$fixture->idSite1, 1);
$expectedAnnotation = array(
'date' => '2011-12-02',
@@ -249,7 +250,7 @@ public function testSaveNoChangesSuccess()
'idNote' => 1,
'canEditOrDelete' => true
);
- $this->assertEquals($expectedAnnotation, Piwik_Annotations_API::getInstance()->get(self::$fixture->idSite1, 1));
+ $this->assertEquals($expectedAnnotation, API::getInstance()->get(self::$fixture->idSite1, 1));
}
/**
@@ -258,10 +259,10 @@ public function testSaveNoChangesSuccess()
*/
public function testDeleteSuccess()
{
- Piwik_Annotations_API::getInstance()->delete(self::$fixture->idSite1, 1);
+ API::getInstance()->delete(self::$fixture->idSite1, 1);
try {
- Piwik_Annotations_API::getInstance()->get(self::$fixture->idSite1, 1);
+ API::getInstance()->get(self::$fixture->idSite1, 1);
$this->fail("failed to delete annotation");
} catch (Exception $ex) {
// pass
diff --git a/tests/PHPUnit/Integration/ArchiveCronTest.php b/tests/PHPUnit/Integration/ArchiveCronTest.php
index dce02cf182b..8e952981475 100644
--- a/tests/PHPUnit/Integration/ArchiveCronTest.php
+++ b/tests/PHPUnit/Integration/ArchiveCronTest.php
@@ -8,6 +8,7 @@
use Piwik\Piwik;
use Piwik\Access;
use Piwik\Date;
+use Piwik\Plugins\SitesManager\API;
/**
* Tests the archive.php cron script.
@@ -90,7 +91,7 @@ public function testArchivePhpCron($optionGroupName, $archivePhpOptions)
private function setLastRunArchiveOptions()
{
$periodTypes = array('day', 'periods');
- $idSites = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $idSites = API::getInstance()->getAllSitesId();
$time = Date::factory(self::$fixture->dateTime)->subDay(1)->getTimestamp();
diff --git a/tests/PHPUnit/Integration/AutoSuggestAPITest.php b/tests/PHPUnit/Integration/AutoSuggestAPITest.php
index 1433c3ce66f..838cce31f41 100644
--- a/tests/PHPUnit/Integration/AutoSuggestAPITest.php
+++ b/tests/PHPUnit/Integration/AutoSuggestAPITest.php
@@ -42,7 +42,7 @@ public function getApiForTesting()
$idSite = self::$fixture->idSite;
$apiForTesting = array();
- $segments = Piwik_API_API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
+ $segments = \Piwik\Plugins\API\API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
foreach ($segments as $segment) {
$apiForTesting[] = $this->getApiForTestingForSegment($idSite, $segment['segment']);
}
@@ -102,7 +102,7 @@ public function testAnotherApi($api, $params)
public function getAnotherApiForTesting()
{
$apiForTesting = array();
- $segments = Piwik_API_API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
+ $segments = \Piwik\Plugins\API\API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
foreach ($segments as $segment) {
$apiForTesting[] = array('VisitsSummary.get',
array('idSite' => self::$fixture->idSite,
diff --git a/tests/PHPUnit/Integration/BlobReportLimitingTest.php b/tests/PHPUnit/Integration/BlobReportLimitingTest.php
index 367bfd21bfd..835822ed6aa 100755
--- a/tests/PHPUnit/Integration/BlobReportLimitingTest.php
+++ b/tests/PHPUnit/Integration/BlobReportLimitingTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Config;
+use Piwik\Plugins\Actions\ArchivingHelper;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php';
@@ -109,7 +110,7 @@ public function testApiWithRankingQuery()
$generalConfig['datatable_archiving_maximum_rows_subtable_custom_variables'] = 4;
$generalConfig['datatable_archiving_maximum_rows_standard'] = 4;
Config::getInstance()->General['archiving_ranking_query_row_limit'] = 3;
- Piwik_Actions_ArchivingHelper::reloadConfig();
+ ArchivingHelper::reloadConfig();
foreach ($this->getApiForTesting() as $pair) {
list($apiToCall, $params) = $pair;
diff --git a/tests/PHPUnit/Integration/ImportLogsTest.php b/tests/PHPUnit/Integration/ImportLogsTest.php
index 795cece9dfa..cbb79e257d3 100755
--- a/tests/PHPUnit/Integration/ImportLogsTest.php
+++ b/tests/PHPUnit/Integration/ImportLogsTest.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Access;
+use Piwik\Plugins\SitesManager\API;
/**
* Tests the log importer.
@@ -58,13 +59,13 @@ public function testDynamicResolverSitesCreated()
Access::getInstance()->setSuperUser(true);
// make sure sites aren't created twice
- $piwikDotNet = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
+ $piwikDotNet = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
$this->assertEquals(1, count($piwikDotNet));
- $anothersiteDotCom = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://anothersite.com');
+ $anothersiteDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://anothersite.com');
$this->assertEquals(1, count($anothersiteDotCom));
- $whateverDotCom = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://whatever.com');
+ $whateverDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://whatever.com');
$this->assertEquals(1, count($whateverDotCom));
}
diff --git a/tests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php b/tests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php
index 1c7b05699ff..828f0334ef4 100755
--- a/tests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php
+++ b/tests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php
@@ -5,6 +5,7 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\Goals\API;
/**
* Tests API methods with goals that do and don't allow multiple
@@ -34,11 +35,11 @@ public function testCheck()
$idSite = self::$fixture->idSite;
// test delete is working as expected
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
$this->assertTrue(2 == count($goals));
- Piwik_Goals_API::getInstance()->deleteGoal($idSite, self::$fixture->idGoal_OneConversionPerVisit);
- Piwik_Goals_API::getInstance()->deleteGoal($idSite, self::$fixture->idGoal_MultipleConversionPerVisit);
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ API::getInstance()->deleteGoal($idSite, self::$fixture->idGoal_OneConversionPerVisit);
+ API::getInstance()->deleteGoal($idSite, self::$fixture->idGoal_MultipleConversionPerVisit);
+ $goals = API::getInstance()->getGoals($idSite);
$this->assertTrue(empty($goals));
}
diff --git a/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ConversionsTest.php b/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ConversionsTest.php
index 0af36e21f9d..122d527fc06 100755
--- a/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ConversionsTest.php
+++ b/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ConversionsTest.php
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\Goals\Archiver;
+
require_once 'Goals/Goals.php';
/**
@@ -91,7 +93,7 @@ public function getApiForTesting()
// Tests that getting a visits summary metric (nb_visits) & a Goal's metric (Goal_revenue)
// at the same time works.
$dateTime = '2010-01-03,2010-01-06';
- $columns = 'nb_visits,' . Piwik_Goals_Archiver::getRecordName('conversion_rate');
+ $columns = 'nb_visits,' . Archiver::getRecordName('conversion_rate');
$result[] = array(
'VisitsSummary.get', array('idSite' => 'all', 'date' => $dateTime, 'periods' => 'range',
diff --git a/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchNONETest.php b/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchNONETest.php
index 3ec0be949bb..9a57a57c559 100755
--- a/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchNONETest.php
+++ b/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchNONETest.php
@@ -5,6 +5,7 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\API\API;
/**
* testing a segment containing all supported fields
@@ -41,7 +42,7 @@ public function getApiForTesting()
public function getSegmentToTest()
{
// Segment matching NONE
- $segments = Piwik_API_API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
+ $segments = API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
$minimumExpectedSegmentsCount = 55; // as of Piwik 1.12
$this->assertTrue( count($segments) >= $minimumExpectedSegmentsCount);
diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php
index 0fdb16c32d6..59c13c82b9d 100755
--- a/tests/PHPUnit/IntegrationTestCase.php
+++ b/tests/PHPUnit/IntegrationTestCase.php
@@ -17,6 +17,7 @@
use Piwik\Common;
use Piwik\Access;
use Piwik\Option;
+use Piwik\Plugins\LanguagesManager\API;
use Piwik\ReportRenderer;
use Piwik\Site;
use Piwik\Tracker\Cache;
@@ -196,7 +197,7 @@ public static function _setUpBeforeClass($dbName = false, $createEmptyDatabase =
// Make sure translations are loaded to check messages in English
Translate::getInstance()->reloadLanguage('en');
- Piwik_LanguagesManager_API::getInstance()->setLanguageForUser('superUserLogin', 'en');
+ API::getInstance()->setLanguageForUser('superUserLogin', 'en');
// List of Modules, or Module.Method that should not be called as part of the XML output compare
// Usually these modules either return random changing data, or are already tested in specific unit tests.
@@ -238,7 +239,7 @@ public static function _tearDownAfterClass($dropDatabase = true)
Cache::deleteTrackerCache();
Config::getInstance()->clear();
ArchiveTableCreator::clear();
- Piwik_PDFReports_API::$cache = array();
+ \Piwik\Plugins\PDFReports\API::$cache = array();
\Zend_Registry::_unsetInstance();
$_GET = $_REQUEST = array();
@@ -364,7 +365,7 @@ protected static function getApiForTestingScheduledReports($dateTime, $period)
'otherRequestParameters' => array(
'idReport' => 1,
'reportFormat' => ReportRenderer::HTML_FORMAT,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
@@ -387,7 +388,7 @@ protected static function getApiForTestingScheduledReports($dateTime, $period)
'otherRequestParameters' => array(
'idReport' => 1,
'reportFormat' => ReportRenderer::PDF_FORMAT,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
@@ -407,7 +408,7 @@ protected static function getApiForTestingScheduledReports($dateTime, $period)
'fileExtension' => 'sms.txt',
'otherRequestParameters' => array(
'idReport' => 2,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
@@ -426,7 +427,7 @@ protected static function getApiForTestingScheduledReports($dateTime, $period)
'fileExtension' => 'sms.txt',
'otherRequestParameters' => array(
'idReport' => 3,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
@@ -447,7 +448,7 @@ protected static function getApiForTestingScheduledReports($dateTime, $period)
'otherRequestParameters' => array(
'idReport' => 4,
'reportFormat' => ReportRenderer::HTML_FORMAT,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
@@ -466,7 +467,7 @@ protected static function getApiForTestingScheduledReports($dateTime, $period)
'fileExtension' => 'html',
'otherRequestParameters' => array(
'idReport' => 5,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
diff --git a/tests/PHPUnit/MockLocationProvider.php b/tests/PHPUnit/MockLocationProvider.php
index 68c1c435028..d4a202ece01 100755
--- a/tests/PHPUnit/MockLocationProvider.php
+++ b/tests/PHPUnit/MockLocationProvider.php
@@ -6,7 +6,9 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-class MockLocationProvider extends Piwik_UserCountry_LocationProvider
+use Piwik\Plugins\UserCountry\LocationProvider;
+
+class MockLocationProvider extends LocationProvider
{
public static $locations = array();
private $currentLocation = 0;
diff --git a/tests/PHPUnit/Plugins/ActionsTest.php b/tests/PHPUnit/Plugins/ActionsTest.php
index c6c3465fa9e..39456058753 100644
--- a/tests/PHPUnit/Plugins/ActionsTest.php
+++ b/tests/PHPUnit/Plugins/ActionsTest.php
@@ -5,6 +5,7 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\Actions\ArchivingHelper;
use Piwik\Tracker\Action;
use Piwik\Translate;
@@ -115,8 +116,8 @@ public function getActionNameTestData()
*/
public function testGetActionExplodedNames($params, $expected)
{
- Piwik_Actions_ArchivingHelper::reloadConfig();
- $processed = Piwik_Actions_ArchivingHelper::getActionExplodedNames($params['name'], $params['type'], (isset($params['urlPrefix']) ? $params['urlPrefix'] : null));
+ ArchivingHelper::reloadConfig();
+ $processed = ArchivingHelper::getActionExplodedNames($params['name'], $params['type'], (isset($params['urlPrefix']) ? $params['urlPrefix'] : null));
$this->assertEquals($expected, $processed);
}
}
diff --git a/tests/PHPUnit/Plugins/AnonymizeIPTest.php b/tests/PHPUnit/Plugins/AnonymizeIPTest.php
index c9a18a45cd6..0c52d7954b7 100644
--- a/tests/PHPUnit/Plugins/AnonymizeIPTest.php
+++ b/tests/PHPUnit/Plugins/AnonymizeIPTest.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\IP;
+use Piwik\Plugins\AnonymizeIP\AnonymizeIP;
require_once 'AnonymizeIP/AnonymizeIP.php';
@@ -41,21 +42,21 @@ public function testApplyIPMask($ip, $expected)
{
// each IP is tested with 0 to 4 octets masked
for ($maskLength = 0; $maskLength <= 4; $maskLength++) {
- $res = Piwik_AnonymizeIP::applyIPMask(IP::P2N($ip), $maskLength);
+ $res = AnonymizeIP::applyIPMask(IP::P2N($ip), $maskLength);
$this->assertEquals($expected[$maskLength], $res, "Got " . bin2hex($res) . ", Expected " . bin2hex($expected[$maskLength]));
}
// edge case (bounds check)
- $this->assertEquals("\x00\x00\x00\x00", Piwik_AnonymizeIP::applyIPMask(IP::P2N($ip), 5));
+ $this->assertEquals("\x00\x00\x00\x00", AnonymizeIP::applyIPMask(IP::P2N($ip), 5));
// mask IPv4 mapped addresses
for ($maskLength = 0; $maskLength <= 4; $maskLength++) {
- $res = Piwik_AnonymizeIP::applyIPMask(IP::P2N('::ffff:' . $ip), $maskLength);
+ $res = AnonymizeIP::applyIPMask(IP::P2N('::ffff:' . $ip), $maskLength);
$this->assertEquals($res, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff" . $expected[$maskLength], "Got " . bin2hex($res) . ", Expected " . bin2hex($expected[$maskLength]));
}
- $this->assertEquals("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x00", Piwik_AnonymizeIP::applyIPMask(IP::P2N('::ffff:' . $ip), 5));
+ $this->assertEquals("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x00", AnonymizeIP::applyIPMask(IP::P2N('::ffff:' . $ip), 5));
// edge case (bounds check)
- $this->assertEquals("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", Piwik_AnonymizeIP::applyIPMask(IP::P2N('2001::ffff:' . $ip), 17));
+ $this->assertEquals("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", AnonymizeIP::applyIPMask(IP::P2N('2001::ffff:' . $ip), 17));
}
}
diff --git a/tests/PHPUnit/Plugins/LanguagesManagerTest.php b/tests/PHPUnit/Plugins/LanguagesManagerTest.php
index fb0ca7012c3..ac7d2de015e 100755
--- a/tests/PHPUnit/Plugins/LanguagesManagerTest.php
+++ b/tests/PHPUnit/Plugins/LanguagesManagerTest.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Common;
+use Piwik\Plugins\LanguagesManager\API;
use Piwik\TranslationWriter;
require_once 'LanguagesManager/API.php';
@@ -32,7 +33,7 @@ function getTestDataForLanguageFiles()
self::$englishStringsWithParameters = array();
self::$englishStringsIndexed = array();
self::$expectedLanguageKeys = array();
- $englishStrings = Piwik_LanguagesManager_API::getInstance()->getTranslationsForLanguage('en');
+ $englishStrings = API::getInstance()->getTranslationsForLanguage('en');
foreach ($englishStrings as $englishString) {
$stringLabel = $englishString['label'];
$stringValue = $englishString['value'];
@@ -45,7 +46,7 @@ function getTestDataForLanguageFiles()
}
// we also test that none of the language php files outputs any character on the screen (eg. space before the getAvailableLanguages();
+ $languages = API::getInstance()->getAvailableLanguages();
$return = array();
foreach ($languages AS $language) {
@@ -68,7 +69,7 @@ function testGetTranslationsForLanguages($language)
self::$errors = array();
ob_start();
$writeCleanedFile = false;
- $strings = Piwik_LanguagesManager_API::getInstance()->getTranslationsForLanguage($language);
+ $strings = API::getInstance()->getTranslationsForLanguage($language);
$content = ob_get_flush();
$serializedStrings = serialize($strings);
$invalids = array("