diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-08-02 17:59:33 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-08-02 17:59:33 +0400 |
commit | a96ec40e983a8b64f4c25def541a519ff3670e6a (patch) | |
tree | bef2a5f7b1e9532dc96161334e23a553cdff7ea1 /core | |
parent | 61997f45e4c39360000e815c9e0853ae04e2f56f (diff) |
Refs #4059 Converting dozens of plugins/* classes to use Namespaces, \Piwik\Plugins\*
Added namespaces to functions.php files in the five plugins that had one
Work in progress
Diffstat (limited to 'core')
37 files changed, 191 insertions, 166 deletions
diff --git a/core/API/DataTableManipulator.php b/core/API/DataTableManipulator.php index 1fce679f95..e93c1f5c87 100644 --- a/core/API/DataTableManipulator.php +++ b/core/API/DataTableManipulator.php @@ -14,7 +14,7 @@ use Exception; 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 @@ abstract class DataTableManipulator } } - $class = 'Piwik_' . $this->apiModule . '_API'; + $class = Request::getClassNameAPI( $this->apiModule ); $method = $this->getApiMethodForSubtable(); $this->manipulateSubtableRequest($request); @@ -166,7 +166,7 @@ abstract class DataTableManipulator 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 ae1b1557bf..50362fc60b 100644 --- a/core/API/DocumentationGenerator.php +++ b/core/API/DocumentationGenerator.php @@ -33,9 +33,9 @@ class DocumentationGenerator { $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 e3861facb1..981452f41f 100644 --- a/core/API/Proxy.php +++ b/core/API/Proxy.php @@ -88,7 +88,7 @@ class Proxy * * 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 @@ class Proxy * 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 @@ class Proxy $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 @@ class Proxy /** * 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 @@ class Proxy } /** - * 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 @@ class Proxy 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 91d664af56..f627dd5f0b 100644 --- a/core/API/Request.php +++ b/core/API/Request.php @@ -149,12 +149,12 @@ class Request 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 @@ class Request 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 7f1f89c616..4866080812 100644 --- a/core/Access.php +++ b/core/Access.php @@ -212,7 +212,7 @@ class Access $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 ed64a1121b..df3448126e 100644 --- a/core/AssetManager.php +++ b/core/AssetManager.php @@ -133,7 +133,7 @@ class AssetManager // 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 0fbf8f8ddf..2a1bae68d9 100644 --- a/core/Common.php +++ b/core/Common.php @@ -15,7 +15,7 @@ use Piwik\IP; 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 @@ use Piwik_UserCountry_LocationProvider_Default; */ class Common { - const CLASSES_PREFIX = 'Piwik_'; - /** * Const used to map the referer type to an integer in the log_visit table */ @@ -1554,27 +1552,11 @@ class Common { $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 * * For more information: @link http://dev.piwik.org/trac/ticket/374 diff --git a/core/Controller.php b/core/Controller.php index 9c1fe1519b..dd122579bd 100644 --- a/core/Controller.php +++ b/core/Controller.php @@ -21,13 +21,13 @@ use Piwik\Common; 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 @@ abstract class Controller 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 @@ abstract class Controller $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 @@ abstract class Controller $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 @@ abstract class Controller $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 @@ abstract class Controller $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 @@ abstract class Controller return $defaultWebsiteId; } - $sitesId = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess(); + $sitesId = SitesManagerAPI::getInstance()->getSitesIdWithAtLeastViewAccess(); if (!empty($sitesId)) { return $sitesId[0]; } @@ -695,7 +696,7 @@ abstract class Controller 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 @@ abstract class Controller */ 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 92ad07185c..d22c61a83f 100644 --- a/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php +++ b/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php @@ -22,7 +22,7 @@ use Piwik\DataTable\Filter\ColumnCallbackAddColumnQuotient; * 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 bdec4b87ca..0cefcc5f29 100644 --- a/core/DataTable/Renderer.php +++ b/core/DataTable/Renderer.php @@ -299,7 +299,7 @@ abstract class Renderer $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 9064a6a908..4a86ce9763 100644 --- a/core/Db/Schema.php +++ b/core/Db/Schema.php @@ -116,7 +116,7 @@ class Schema $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 fc33f3eae2..5837256a55 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -99,7 +99,7 @@ class FrontController throw new PluginDeactivatedException($module); } - $controllerClassName = 'Piwik_' . $module . '_Controller'; + $controllerClassName = $this->getClassNameController( $module ); // FrontController's autoloader if (!class_exists($controllerClassName, false)) { @@ -110,7 +110,9 @@ class FrontController 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 @@ class FrontController } } + 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 fc913112e9..927fbdc797 100644 --- a/core/Loader.php +++ b/core/Loader.php @@ -46,7 +46,13 @@ class Loader 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 5bb4adb39c..a0fa8c4c2b 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 @@ abstract class MenuAbstract 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 3c04d54308..f846ef6006 100644 --- a/core/Period.php +++ b/core/Period.php @@ -19,16 +19,6 @@ use Piwik\Period\Week; 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 @@ abstract class Period return $this->getDate(); } $periods = $this->getSubperiods(); + /** @var $currentPeriod Period */ $currentPeriod = $periods[0]; while ($currentPeriod->getNumberOfSubperiods() > 0) { $periods = $currentPeriod->getSubperiods(); @@ -196,6 +187,7 @@ abstract class Period 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 de54f033ad..7dff9430aa 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -24,7 +24,7 @@ use Piwik\Tracker; 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 @@ class Piwik 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 578d38c5f5..756d4ae4f3 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 @@ class Plugin /** * 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 dd49ba37e7..eb3b24592d 100644 --- a/core/PluginsArchiver.php +++ b/core/PluginsArchiver.php @@ -36,8 +36,8 @@ abstract class PluginsArchiver // 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 0626db36a3..b4af8fbac0 100644 --- a/core/PluginsManager.php +++ b/core/PluginsManager.php @@ -399,13 +399,13 @@ class PluginsManager } /** - * 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 @@ class PluginsManager /** * 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 @@ class PluginsManager 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 @@ class PluginsManager 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 @@ class PluginsManager return $newPlugin; } + protected function getClassNamePlugin($pluginName) + { + $className = $pluginName; + if($pluginName == 'API') { + $className = 'Plugin'; + } + return "\\Piwik\\Plugins\\$pluginName\\$className"; + } + /** * Unload plugin * @@ -663,6 +673,7 @@ class PluginsManager // 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 d2d51f1425..f724935209 100644 --- a/core/ReportRenderer.php +++ b/core/ReportRenderer.php @@ -17,7 +17,7 @@ use Piwik\Piwik; 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 class ReportRenderer * 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 @@ abstract class ReportRenderer } $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 e1d30734c4..cb8d33faa0 100644 --- a/core/ReportRenderer/Html.php +++ b/core/ReportRenderer/Html.php @@ -13,7 +13,7 @@ namespace Piwik\ReportRenderer; use Piwik\Piwik; use Piwik\View; use Piwik\ReportRenderer; -use Piwik_API_API; +use Piwik\Plugins\API\API; /** * @@ -121,7 +121,7 @@ class Html extends ReportRenderer $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 192a7f9133..c3ab722e27 100644 --- a/core/ReportRenderer/Pdf.php +++ b/core/ReportRenderer/Pdf.php @@ -13,7 +13,7 @@ namespace Piwik\ReportRenderer; 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 @@ class Pdf extends ReportRenderer $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 8d9c368c54..5262e7cbc3 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 @@ class ScheduledTask $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 cfc82c86e7..8687362a56 100644 --- a/core/Segment.php +++ b/core/Segment.php @@ -12,7 +12,7 @@ namespace Piwik; use Exception; use Piwik\Piwik; use Piwik\Common; -use Piwik_API_API; +use Piwik\Plugins\API\API; use Piwik\SegmentExpression; /** @@ -90,7 +90,7 @@ class Segment 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 @@ class Segment $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 b0824e77ee..eb13215e34 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 @@ class Site { $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 @@ class Site 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 @@ class Site $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 1e6423d8f6..7319818e41 100644 --- a/core/Tracker/Cache.php +++ b/core/Tracker/Cache.php @@ -15,7 +15,7 @@ use Piwik\Config; 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 @@ class Cache $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 668d23fa1e..e52e89424a 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -8,7 +8,7 @@ use Piwik\Cookie; 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 @@ class Request public function setForceIp($ip) { - $this->enforcedIp = $ip; + if(!empty($ip)) { + $this->enforcedIp = $ip; + } } public function setForceDateTime($dateTime) @@ -442,12 +446,16 @@ class Request 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 @@ class Request // 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 3590b4c319..9121936339 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -32,7 +32,7 @@ use Piwik\Tracker\Request; 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 @@ class Visit implements Tracker\VisitInterface * 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 @@ class Visit implements Tracker\VisitInterface /** * 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 @@ class Visit implements Tracker\VisitInterface } // 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 5a316c65ce..ae79b90e89 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 @@ class Twig { $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 2c30124676..29261f8341 100644 --- a/core/UpdateCheck.php +++ b/core/UpdateCheck.php @@ -14,7 +14,7 @@ use Exception; 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 @@ class UpdateCheck '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 740bb2e031..b6b13de4c6 100644 --- a/core/Updater.php +++ b/core/Updater.php @@ -138,6 +138,7 @@ class Updater 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 785627f875..5ad44f5268 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 @@ class Piwik_Updates_0_2_34 extends Updates { // 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 74bbe6b6b6..af541713a2 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 @@ class Piwik_Updates_0_6_2 extends Updates // 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 84d9ce56d5..f217635ebc 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 @@ class Piwik_Updates_1_8_3_b1 extends Updates $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 @@ class Piwik_Updates_1_8_3_b1 extends Updates $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 e765791b72..9d221c9d9c 100644 --- a/core/View.php +++ b/core/View.php @@ -20,8 +20,8 @@ use Piwik\Url; 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 @@ class View implements ViewInterface $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 @@ class View implements ViewInterface $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 386d41e6cb..e6ee1289be 100644 --- a/core/ViewDataTable.php +++ b/core/ViewDataTable.php @@ -13,6 +13,7 @@ namespace Piwik; 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\Url; 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 @@ class ViewDataTable $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 @@ class ViewDataTable 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 @@ class ViewDataTable } } - $segment = \Piwik\API\Request::getRawSegmentFromRequest(); + $segment = Request::getRawSegmentFromRequest(); if(!empty($segment)) { $requestArray['segment'] = $segment; } @@ -848,7 +849,7 @@ class ViewDataTable // 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 @@ class ViewDataTable } } - $rawSegment = \Piwik\API\Request::getRawSegmentFromRequest(); + $rawSegment = Request::getRawSegmentFromRequest(); if(!empty($rawSegment)) { $javascriptVariablesToSet['segment'] = $rawSegment; } @@ -982,7 +983,7 @@ class ViewDataTable { $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 @@ class ViewDataTable $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 @@ class ViewDataTable 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 @@ class ViewDataTable */ 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 @@ class ViewDataTable } } } -}
\ No newline at end of file +} diff --git a/core/ViewDataTable/HtmlTable/Goals.php b/core/ViewDataTable/HtmlTable/Goals.php index 414e78d6ba..88f3ab4b1a 100644 --- a/core/ViewDataTable/HtmlTable/Goals.php +++ b/core/ViewDataTable/HtmlTable/Goals.php @@ -15,7 +15,7 @@ use Piwik\Common; 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 @@ class Goals extends HtmlTable $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, |