diff --git a/core/API/Proxy.php b/core/API/Proxy.php index 759f4664378dd498fbc111e1d9fd1715fa6e5057..80810c3c31300ba83e1b2e20cfdeb6d739235178 100644 --- a/core/API/Proxy.php +++ b/core/API/Proxy.php @@ -13,6 +13,7 @@ namespace Piwik\API; use Exception; use Piwik\Common; +use Piwik\Piwik; use ReflectionClass; use ReflectionMethod; @@ -187,14 +188,14 @@ class Proxy * * The `$fnalParameters` contains all paramteres that will be passed to the actual API method. */ - Piwik_PostEvent(sprintf('API.Request.dispatch', $pluginName, $methodName), array(&$finalParameters)); + Piwik::postEvent(sprintf('API.Request.dispatch', $pluginName, $methodName), array(&$finalParameters)); /** * This event is similar to the `API.Request.dispatch` event. It distinguishes the possibility to subscribe * only to a specific API method instead of all API methods. You can use it for example to modify any input * parameters or to execute any other logic before the actual API method is called. */ - Piwik_PostEvent(sprintf('API.%s.%s', $pluginName, $methodName), array(&$finalParameters)); + Piwik::postEvent(sprintf('API.%s.%s', $pluginName, $methodName), array(&$finalParameters)); // call the method $returnedValue = call_user_func_array(array($object, $methodName), $finalParameters); @@ -223,7 +224,7 @@ class Proxy * ); * ``` */ - Piwik_PostEvent(sprintf('API.%s.%s.end', $pluginName, $methodName), $endHookParams); + Piwik::postEvent(sprintf('API.%s.%s.end', $pluginName, $methodName), $endHookParams); /** * Generic hook that plugins can use to modify any output of any API method. The event is triggered after @@ -240,7 +241,7 @@ class Proxy * ); * ``` */ - Piwik_PostEvent(sprintf('API.Request.dispatch.end', $pluginName, $methodName), $endHookParams); + Piwik::postEvent(sprintf('API.Request.dispatch.end', $pluginName, $methodName), $endHookParams); // Restore the request $_GET = $saveGET; diff --git a/core/API/Request.php b/core/API/Request.php index 9ab13d4f6a783464d103bc6bd7ba83b42fbaa07d..bf43170d0a2b9eedfdc7cf04bb2d4f14ac154e15 100644 --- a/core/API/Request.php +++ b/core/API/Request.php @@ -14,6 +14,7 @@ use Exception; use Piwik\Access; use Piwik\Common; use Piwik\DataTable; +use Piwik\Piwik; use Piwik\PluginDeactivatedException; use Piwik\PluginsManager; use Piwik\SettingsServer; @@ -186,7 +187,7 @@ class Request * This event is triggered when authenticating the API call, only if the token_auth is found in the request. * In this case the current session should authenticate using this token_auth. */ - Piwik_PostEvent('API.Request.authenticate', array($token_auth)); + Piwik::postEvent('API.Request.authenticate', array($token_auth)); Access::getInstance()->reloadAccess(); SettingsServer::raiseMemoryLimitIfNecessary(); } diff --git a/core/Access.php b/core/Access.php index e4414500ae2954a71be3287dae96eaeb269dee47..7ee7128f27120e3e4264933caa749eb26fc948ff 100644 --- a/core/Access.php +++ b/core/Access.php @@ -49,7 +49,7 @@ class Access if (self::$instance == null) { self::$instance = new self; - Piwik_PostTestEvent('Access.createAccessSingleton', array(self::$instance)); + Piwik::postTestEvent('Access.createAccessSingleton', array(self::$instance)); } return self::$instance; } @@ -216,7 +216,7 @@ class Access $this->idsitesByAccess['superuser'] = $allSitesId; $this->login = Config::getInstance()->superuser['login']; - Piwik_PostTestEvent('Access.loadingSuperUserAccess', array(&$this->idsitesByAccess, &$this->login)); + Piwik::postTestEvent('Access.loadingSuperUserAccess', array(&$this->idsitesByAccess, &$this->login)); return true; } diff --git a/core/ArchiveProcessor/Day.php b/core/ArchiveProcessor/Day.php index d9f0b88f0cecc17a7d17d4717673cf82aea0822b..1a512ba932743d141bc493da652154f284be9503 100644 --- a/core/ArchiveProcessor/Day.php +++ b/core/ArchiveProcessor/Day.php @@ -14,6 +14,7 @@ use Piwik\ArchiveProcessor; use Piwik\DataArray; use Piwik\DataTable; use Piwik\Metrics; +use Piwik\Piwik; /** * This class @@ -120,6 +121,6 @@ class Day extends ArchiveProcessor * } * ``` */ - Piwik_PostEvent('ArchiveProcessor.Day.compute', array(&$this)); + Piwik::postEvent('ArchiveProcessor.Day.compute', array(&$this)); } } diff --git a/core/ArchiveProcessor/Period.php b/core/ArchiveProcessor/Period.php index a85debf563dd58935ae2be97b779d8aab4f9df40..8a87c1fd1e7d96557d77db8750c97dd925e828e1 100644 --- a/core/ArchiveProcessor/Period.php +++ b/core/ArchiveProcessor/Period.php @@ -18,6 +18,7 @@ use Piwik\Common; use Piwik\DataTable; use Piwik\DataTable\Manager; use Piwik\Metrics; +use Piwik\Piwik; use Piwik\SettingsPiwik; /** @@ -201,7 +202,7 @@ class Period extends ArchiveProcessor * } * ``` */ - Piwik_PostEvent('ArchiveProcessor.Period.compute', array(&$this)); + Piwik::postEvent('ArchiveProcessor.Period.compute', array(&$this)); } protected function aggregateCoreVisitsMetrics() diff --git a/core/AssetManager.php b/core/AssetManager.php index f199ce85fad869527acc51844ba721d1b48d3027..1adfae0f8699c99ce1b8d71e826ee981fe252767 100644 --- a/core/AssetManager.php +++ b/core/AssetManager.php @@ -165,7 +165,7 @@ class AssetManager * merged into one file but before the generated CSS is written to disk. It can be used to change the modify the * stylesheets to your needs, like replacing image paths or adding further custom stylesheets. */ - Piwik_PostEvent('AssetManager.filterMergedStylesheets', array(&$mergedContent)); + Piwik::postEvent('AssetManager.filterMergedStylesheets', array(&$mergedContent)); $mergedContent = $firstLineCompileHash . "\n" @@ -300,7 +300,7 @@ class AssetManager * } * ``` */ - Piwik_PostEvent(self::STYLESHEET_IMPORT_EVENT, array(&$stylesheets)); + Piwik::postEvent(self::STYLESHEET_IMPORT_EVENT, array(&$stylesheets)); $stylesheets = self::sortCssFiles($stylesheets); @@ -382,7 +382,7 @@ class AssetManager * generated JS file is written to disk. It can be used to change the generated JavaScript to your needs, * like adding further scripts or storing the generated file somewhere else. */ - Piwik_PostEvent('AssetManager.filterMergedJavaScripts', array(&$mergedContent)); + Piwik::postEvent('AssetManager.filterMergedJavaScripts', array(&$mergedContent)); self::writeAssetToFile($mergedContent, self::MERGED_JS_FILE); } @@ -428,7 +428,7 @@ class AssetManager * } * ``` */ - Piwik_PostEvent(self::JAVASCRIPT_IMPORT_EVENT, array(&$jsFiles)); + Piwik::postEvent(self::JAVASCRIPT_IMPORT_EVENT, array(&$jsFiles)); $jsFiles = self::sortJsFiles($jsFiles); return $jsFiles; } diff --git a/core/Config.php b/core/Config.php index dfade336737746fe93240286e67131d50864c80f..4926bbda3097728cbdb129934fc914557b1f1508 100644 --- a/core/Config.php +++ b/core/Config.php @@ -300,7 +300,7 @@ class Config // must be called here, not in init(), since setTestEnvironment() calls init(). (this avoids // infinite recursion) - Piwik_PostTestEvent('Config.createConfigSingleton', array(self::$instance)); + Piwik::postTestEvent('Config.createConfigSingleton', array(self::$instance)); } // check cache for merged section diff --git a/core/Db.php b/core/Db.php index c6119205e5fe1d4987beb749639e6c4d98f734b1..476423753cc482375268eca52ec07e0e160b6d69 100644 --- a/core/Db.php +++ b/core/Db.php @@ -59,7 +59,7 @@ class Db * datatabase settings defined in the config. The reporting database config is used in case someone accesses * the Piwik UI. */ - Piwik_PostEvent('Reporting.getDatabaseConfig', array(&$dbInfos)); + Piwik::postEvent('Reporting.getDatabaseConfig', array(&$dbInfos)); $dbInfos['profiler'] = $config->Debug['enable_sql_profiler']; diff --git a/core/Error.php b/core/Error.php index 9b1ed7b8dd13ec5e22e5040da7208e52a9937c4d..3e54ef45ec801e98b0699cf40cb75921ce24c9a9 100644 --- a/core/Error.php +++ b/core/Error.php @@ -160,9 +160,9 @@ class Error public static function setErrorHandler() { - Piwik_AddAction('Log.formatFileMessage', array('\\Piwik\\Error', 'formatFileAndDBLogMessage')); - Piwik_AddAction('Log.formatDatabaseMessage', array('\\Piwik\\Error', 'formatFileAndDBLogMessage')); - Piwik_AddAction('Log.formatScreenMessage', array('\\Piwik\\Error', 'formatScreenMessage')); + Piwik::addAction('Log.formatFileMessage', array('\\Piwik\\Error', 'formatFileAndDBLogMessage')); + Piwik::addAction('Log.formatDatabaseMessage', array('\\Piwik\\Error', 'formatFileAndDBLogMessage')); + Piwik::addAction('Log.formatScreenMessage', array('\\Piwik\\Error', 'formatScreenMessage')); set_error_handler(array('\\Piwik\\Error', 'errorHandler')); } diff --git a/core/ExceptionHandler.php b/core/ExceptionHandler.php index 7df27348842575e4f47416b6d6c68d116b98e72f..9c08ecc3ceb89b14a4225801be9218c108d85a98 100644 --- a/core/ExceptionHandler.php +++ b/core/ExceptionHandler.php @@ -28,9 +28,9 @@ class ExceptionHandler public static function setUp() { - Piwik_AddAction('Log.formatFileMessage', array('\\Piwik\\ExceptionHandler', 'formatFileAndDBLogMessage')); - Piwik_AddAction('Log.formatDatabaseMessage', array('\\Piwik\\ExceptionHandler', 'formatFileAndDBLogMessage')); - Piwik_AddAction('Log.formatScreenMessage', array('\\Piwik\\ExceptionHandler', 'formatScreenMessage')); + Piwik::addAction('Log.formatFileMessage', array('\\Piwik\\ExceptionHandler', 'formatFileAndDBLogMessage')); + Piwik::addAction('Log.formatDatabaseMessage', array('\\Piwik\\ExceptionHandler', 'formatFileAndDBLogMessage')); + Piwik::addAction('Log.formatScreenMessage', array('\\Piwik\\ExceptionHandler', 'formatScreenMessage')); set_exception_handler(array('\\Piwik\\ExceptionHandler', 'exceptionHandler')); } diff --git a/core/FrontController.php b/core/FrontController.php index 02f16e7ccb8f8e79cc91f32b42efd9bfedbe2665..e1068e46d8ae1aae8e55bb1c08f613cff84663bd 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -130,14 +130,14 @@ class FrontController * * The `$params` array contains the following properties: `array($module, $action, $parameters, $controller)` */ - Piwik_PostEvent('Request.dispatch', $params); + Piwik::postEvent('Request.dispatch', $params); /** * This event is similar to the `Request.dispatch` hook. It distinguishes the possibility to subscribe only to a * specific controller method instead of all controller methods. You can use it for example to modify any input * parameters or execute any other logic before the actual controller is called. */ - Piwik_PostEvent(sprintf('Controller.%s.%s', $module, $action), array($parameters)); + Piwik::postEvent(sprintf('Controller.%s.%s', $module, $action), array($parameters)); try { $result = call_user_func_array(array($params[3], $params[1]), $params[2]); @@ -147,14 +147,14 @@ class FrontController * only to the end of a specific controller method instead of all controller methods. You can use it for * example to modify the response of a single controller method. */ - Piwik_PostEvent(sprintf('Controller.%s.%s.end', $module, $action), array(&$result, $parameters)); + Piwik::postEvent(sprintf('Controller.%s.%s.end', $module, $action), array(&$result, $parameters)); /** * Generic hook that plugins can use to modify any output of any controller method. The event is triggered * after a controller method is executed but before the result is send to the user. The parameters * originally passed to the method are available as well. */ - Piwik_PostEvent('Request.dispatch.end', array(&$result, $parameters)); + Piwik::postEvent('Request.dispatch.end', array(&$result, $parameters)); return $result; @@ -165,7 +165,7 @@ class FrontController * required permissions to do this. You can subscribe to this event to display a custom error message or * to display a custom login form in such a case. */ - Piwik_PostEvent('User.isNotAuthorized', array($exception), $pending = true); + Piwik::postEvent('User.isNotAuthorized', array($exception), $pending = true); } catch (Exception $e) { $debugTrace = $e->getTraceAsString(); $message = Common::sanitizeInputValue($e->getMessage()); @@ -245,7 +245,7 @@ class FrontController * installed yet. The event can be used to start the installation process or to display a custom error * message. */ - Piwik_PostEvent('Config.NoConfigurationFile', array($exception), $pending = true); + Piwik::postEvent('Config.NoConfigurationFile', array($exception), $pending = true); $exceptionToThrow = $exception; } return $exceptionToThrow; @@ -318,7 +318,7 @@ class FrontController * are missing. The event can be used to start the installation process or to display a custom error * message. */ - Piwik_PostEvent('Config.badConfigurationFile', array($exception), $pending = true); + Piwik::postEvent('Config.badConfigurationFile', array($exception), $pending = true); throw $exception; } @@ -329,7 +329,7 @@ class FrontController * This event is the first event triggered just after the platform is initialized and plugins are loaded. * You can use this event to do early initialization. Note: the user is not authenticated yet. */ - Piwik_PostEvent('Request.dispatchCoreAndPluginUpdatesScreen'); + Piwik::postEvent('Request.dispatchCoreAndPluginUpdatesScreen'); PluginsManager::getInstance()->installLoadedPlugins(); @@ -342,7 +342,7 @@ class FrontController * This event is triggered before the user is authenticated. You can use it to create your own * authentication object which implements the `Piwik\Auth` interface, and override the default authentication logic. */ - Piwik_PostEvent('Request.initAuthenticationObject'); + Piwik::postEvent('Request.initAuthenticationObject'); try { $authAdapter = Registry::get('auth'); } catch (Exception $e) { @@ -368,7 +368,7 @@ class FrontController * the user is authenticated but before the platform is going to dispatch the actual request. You can use * it to check for any updates. */ - Piwik_PostEvent('Updater.checkForUpdates'); + Piwik::postEvent('Updater.checkForUpdates'); } catch (Exception $e) { if (self::shouldRethrowException()) { diff --git a/core/Log.php b/core/Log.php index 9be82abe7862c11a30d9056ada677f35a1a2533f..026f63c839c510c66ca1115f14260d5038e386a3 100644 --- a/core/Log.php +++ b/core/Log.php @@ -299,7 +299,7 @@ class Log * // 'myloggername' can now be used in the log_writers config option. * ``` */ - Piwik_PostEvent(self::GET_AVAILABLE_WRITERS_EVENT, array(&$writers)); + Piwik::postEvent(self::GET_AVAILABLE_WRITERS_EVENT, array(&$writers)); $writers['file'] = array($this, 'logToFile'); $writers['screen'] = array($this, 'logToScreen'); @@ -322,7 +322,7 @@ class Log * check if the object is of a certain type and if it is, set $message to the * string that should be logged. */ - Piwik_PostEvent(self::FORMAT_FILE_MESSAGE_EVENT, array(&$message, $level, $tag, $datetime, $logger)); + Piwik::postEvent(self::FORMAT_FILE_MESSAGE_EVENT, array(&$message, $level, $tag, $datetime, $logger)); } if (empty($message)) { @@ -366,7 +366,7 @@ class Log * The result of this callback can be HTML so no sanitization is done on the result. * This means YOU MUST SANITIZE THE MESSAGE YOURSELF if you use this event. */ - Piwik_PostEvent(self::FORMAT_SCREEN_MESSAGE_EVENT, array(&$message, $level, $tag, $datetime, $logger)); + Piwik::postEvent(self::FORMAT_SCREEN_MESSAGE_EVENT, array(&$message, $level, $tag, $datetime, $logger)); } if (empty($message)) { @@ -391,7 +391,7 @@ class Log * check if the object is of a certain type and if it is, set $message to the * string that should be logged. */ - Piwik_PostEvent(self::FORMAT_DATABASE_MESSAGE_EVENT, array(&$message, $level, $tag, $datetime, $logger)); + Piwik::postEvent(self::FORMAT_DATABASE_MESSAGE_EVENT, array(&$message, $level, $tag, $datetime, $logger)); } if (empty($message)) { diff --git a/core/Menu/Admin.php b/core/Menu/Admin.php index d32335d4d40995d56ee0c56713068467489d1fc1..2c9bf9339371d437b4167f70e85ef3ccff2f4191 100644 --- a/core/Menu/Admin.php +++ b/core/Menu/Admin.php @@ -59,7 +59,7 @@ class Admin extends MenuAbstract * } * ``` */ - Piwik_PostEvent('Menu.Admin.addItems'); + Piwik::postEvent('Menu.Admin.addItems'); } return parent::get(); } diff --git a/core/Menu/Main.php b/core/Menu/Main.php index 1511a3f9fb1c66aad4a4a64592d29ff7b7934329..db858f8c74f6e84829ac57811b72bf2b93381101 100644 --- a/core/Menu/Main.php +++ b/core/Menu/Main.php @@ -9,6 +9,7 @@ * @package Piwik_Menu */ namespace Piwik\Menu; +use Piwik\Piwik; /** @@ -79,7 +80,7 @@ class Main extends MenuAbstract * } * ``` */ - Piwik_PostEvent('Menu.Reporting.addItems'); + Piwik::postEvent('Menu.Reporting.addItems'); } return parent::get(); } diff --git a/core/Menu/Top.php b/core/Menu/Top.php index 7901a13d7167e920f1d640b50b923c593a42a3b8..52d6f7ef318c6640360659549c1b13b811b54092 100644 --- a/core/Menu/Top.php +++ b/core/Menu/Top.php @@ -9,6 +9,7 @@ * @package Piwik_Menu */ namespace Piwik\Menu; +use Piwik\Piwik; /** @@ -79,7 +80,7 @@ class Top extends MenuAbstract * } * ``` */ - Piwik_PostEvent('Menu.Top.addItems'); + Piwik::postEvent('Menu.Top.addItems'); } return parent::get(); } diff --git a/core/Piwik.php b/core/Piwik.php index 8da79c3f08b85e3577190a12a4bae37c5c578040..3be8c765eb6efbd36954d6d7073fb681184e4260 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -46,7 +46,6 @@ class Piwik 'range' => 5, ); - const LABEL_ID_GOAL_IS_ECOMMERCE_CART = 'ecommerceAbandonedCart'; const LABEL_ID_GOAL_IS_ECOMMERCE_ORDER = 'ecommerceOrder'; @@ -82,10 +81,6 @@ class Piwik exit; } - /* - * Amounts, Percentages, Currency, Time, Math Operations, and Pretty Printing - */ - /** * Computes the division of i1 by i2. If either i1 or i2 are not number, or if i2 has a value of zero * we return 0 to avoid the division by zero. @@ -646,4 +641,43 @@ class Piwik $parts = explode('\\', $className); return end($parts); } + + + /** + * Post an event to the dispatcher which will notice the observers. + * + * @param string $eventName The event name. + * @param array $params The parameter array to forward to observer callbacks. + * @param bool $pending + * @param null $plugins + * @return void + * @api + */ + public static function postEvent($eventName, $params = array(), $pending = false, $plugins = null) + { + EventDispatcher::getInstance()->postEvent($eventName, $params, $pending, $plugins); + } + + /** + * Register an action to execute for a given event + * + * @param string $eventName Name of event + * @param callable $function Callback hook + * @api + */ + public static function addAction($eventName, $function) + { + EventDispatcher::getInstance()->addObserver($eventName, $function); + } + + /** + * Posts an event if we are currently running tests. Whether we are running tests is + * determined by looking for the PIWIK_TEST_MODE constant. + */ + public static function postTestEvent($eventName, $params = array(), $pending = false, $plugins = null) + { + if (defined('PIWIK_TEST_MODE')) { + Piwik::postEvent($eventName, $params, $pending, $plugins); + } + } } diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php index 24e857d3f045eff2137a618375b9dd13307de74b..a7412d9a3c4b54b0e9c2e07fce43dff1c194a2da 100644 --- a/core/SettingsPiwik.php +++ b/core/SettingsPiwik.php @@ -66,7 +66,7 @@ class SettingsPiwik * This event is triggered when the automatic archiving runs. * You can use it to add segments to the list of segments to pre-process during archiving. */ - Piwik_PostEvent('Segments.getKnownSegmentsToArchiveAllSites', array(&$segmentsToProcess)); + Piwik::postEvent('Segments.getKnownSegmentsToArchiveAllSites', array(&$segmentsToProcess)); self::$cachedKnownSegmentsToArchive = array_unique($segmentsToProcess); } @@ -82,7 +82,7 @@ class SettingsPiwik /** * @matt */ - Piwik_PostEvent('Segments.getKnownSegmentsToArchiveForSite', array(&$segments, $idSite)); + Piwik::postEvent('Segments.getKnownSegmentsToArchiveForSite', array(&$segments, $idSite)); return $segments; } diff --git a/core/TaskScheduler.php b/core/TaskScheduler.php index 2b529566d99ae29a9ebd27a12b603d10b65e20ae..a81268c4c99636809909cae675ae2c7095fdd228 100644 --- a/core/TaskScheduler.php +++ b/core/TaskScheduler.php @@ -65,7 +65,7 @@ class TaskScheduler * } * ``` */ - Piwik_PostEvent(self::GET_TASKS_EVENT, array(&$tasks)); + Piwik::postEvent(self::GET_TASKS_EVENT, array(&$tasks)); /** @var ScheduledTask[] $tasks */ // remove from timetable tasks that are not active anymore diff --git a/core/Tracker.php b/core/Tracker.php index a9a38556958ac703ecd70d76995bc3693f035b50..0db9fb2adf31295d39a0dcff1f6f1a9b45f636dc 100644 --- a/core/Tracker.php +++ b/core/Tracker.php @@ -561,7 +561,7 @@ class Tracker * datatabase settings defined in the config. The tracker database config is used in case a new pageview/visit * will be tracked. */ - Piwik_PostEvent('Tracker.getDatabaseConfig', array(&$configDb)); + Piwik::postEvent('Tracker.getDatabaseConfig', array(&$configDb)); $db = Tracker::factory($configDb); $db->connect(); @@ -614,7 +614,7 @@ class Tracker * usage of your own or your extended visit object but make sure to implement the * `Piwik\Tracker\VisitInterface`. */ - Piwik_PostEvent('Tracker.makeNewVisitObject', array(&$visit)); + Piwik::postEvent('Tracker.makeNewVisitObject', array(&$visit)); if (is_null($visit)) { $visit = new Visit(); diff --git a/core/Tracker/Action.php b/core/Tracker/Action.php index c869cf8a53b0b7a84afb1a9a0723c8876ee30b39..cba622ed992710cc0b46eb072591fa34e11a7439 100644 --- a/core/Tracker/Action.php +++ b/core/Tracker/Action.php @@ -14,6 +14,7 @@ namespace Piwik\Tracker; use Exception; use Piwik\Common; use Piwik\Config; +use Piwik\Piwik; use Piwik\Tracker; use Piwik\UrlHelper; @@ -644,7 +645,7 @@ class Action implements ActionInterface * This hook is called after saving (and updating) visitor information. You can use it for instance to sync the * recorded action with third party systems. */ - Piwik_PostEvent('Tracker.recordAction', array($trackerAction = $this, $info)); + Piwik::postEvent('Tracker.recordAction', array($trackerAction = $this, $info)); } public function getCustomVariables() diff --git a/core/Tracker/Cache.php b/core/Tracker/Cache.php index de62ad590b7fe4e8394d0c7f2a814acef09d40bf..948d1a34ad87dc24f367062c5fc722f354ab6080 100644 --- a/core/Tracker/Cache.php +++ b/core/Tracker/Cache.php @@ -65,7 +65,7 @@ class Cache * This hook is called to get the details of a specific site depending on the id. You can use this to add any * custom attributes to the website. */ - Piwik_PostEvent('Site.getSiteAttributes', array(&$content, $idSite)); + Piwik::postEvent('Site.getSiteAttributes', array(&$content, $idSite)); // restore original user privilege Piwik::setUserIsSuperUser($isSuperUser); @@ -113,7 +113,7 @@ class Cache * This event is triggered to add any custom content to the Tracker cache. You may want to cache any tracker * data that is expensive to re-calculate on each tracking request. */ - Piwik_PostEvent('Tracker.setTrackerCacheGeneral', array(&$cacheContent)); + Piwik::postEvent('Tracker.setTrackerCacheGeneral', array(&$cacheContent)); self::setCacheGeneral($cacheContent); return $cacheContent; } diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php index 7c8b3bbc81299d0c8701a0151ed02cdbb300cd80..a60864ce479049e96a0b1856d7f5837f729bfb67 100644 --- a/core/Tracker/GoalManager.php +++ b/core/Tracker/GoalManager.php @@ -13,6 +13,7 @@ namespace Piwik\Tracker; use Exception; use Piwik\Common; use Piwik\Config; +use Piwik\Piwik; use Piwik\Tracker; /** @@ -409,7 +410,7 @@ class GoalManager * This hook is called after recording an ecommerce goal. You can use it for instance to sync the recorded goal * with third party systems. `$goal` contains all available information like `items` and `revenue`. */ - Piwik_PostEvent('Tracker.recordEcommerceGoal', array($goal)); + Piwik::postEvent('Tracker.recordEcommerceGoal', array($goal)); } /** @@ -774,7 +775,7 @@ class GoalManager * This hook is called after recording a standard goal. You can use it for instance to sync the recorded * goal with third party systems. `$goal` contains all available information like `url` and `revenue`. */ - Piwik_PostEvent('Tracker.recordStandardGoals', array($newGoal)); + Piwik::postEvent('Tracker.recordStandardGoals', array($newGoal)); } } diff --git a/core/Tracker/Referrer.php b/core/Tracker/Referrer.php index 5954ca1dc81e8c9b93fe271a138880d13cbeb6de..28c7c966c1a823541c088e637d1435fc2046cc8f 100644 --- a/core/Tracker/Referrer.php +++ b/core/Tracker/Referrer.php @@ -11,6 +11,7 @@ namespace Piwik\Tracker; use Piwik\Common; +use Piwik\Piwik; use Piwik\UrlHelper; /** @@ -132,7 +133,7 @@ class Referrer * This event is triggered after basic search engine detection has been attempted. A plugin can use this event * to modify or provide new results based on the passed referrer URL. */ - Piwik_PostEvent('Tracker.detectReferrerSearchEngine', array(&$searchEngineInformation, $this->referrerUrl)); + Piwik::postEvent('Tracker.detectReferrerSearchEngine', array(&$searchEngineInformation, $this->referrerUrl)); if ($searchEngineInformation === false) { return false; } diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php index 7ae021fb0b81bf9ce0766924333864e98247a84f..8a7218979f28146978b73408fe3e87b22a75c7f4 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -6,6 +6,7 @@ use Piwik\Common; use Piwik\Config; use Piwik\Cookie; use Piwik\IP; +use Piwik\Piwik; use Piwik\Tracker; /** @@ -297,7 +298,7 @@ class Request * be higher than `0`, otherwise an exception will be triggered. By default the idSite is specified on the URL * parameter `idsite`. */ - Piwik_PostEvent('Tracker.setSiteId', array(&$idSite, $this->params)); + Piwik::postEvent('Tracker.setSiteId', array(&$idSite, $this->params)); if ($idSite <= 0) { throw new Exception('Invalid idSite'); } diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index ca55b00e75db49eeaae753b594e4d1b135e23c1c..cadd3ac9f7b6fa1c1d57f07ba2fbc1752d3bca2a 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -16,6 +16,7 @@ use Piwik\Common; use Piwik\Config; use Piwik\IP; +use Piwik\Piwik; use Piwik\Tracker; use UserAgentParser; @@ -95,7 +96,7 @@ class Visit implements VisitInterface /** * This event can be used for instance to anonymize the IP (after testing for IP exclusion). */ - Piwik_PostEvent('Tracker.setVisitorIp', array(&$this->visitorInfo['location_ip'])); + Piwik::postEvent('Tracker.setVisitorIp', array(&$this->visitorInfo['location_ip'])); $this->visitorCustomVariables = $this->request->getCustomVariables($scope = 'visit'); if (!empty($this->visitorCustomVariables)) { @@ -309,7 +310,7 @@ class Visit implements VisitInterface * This event is triggered before saving a known visitor. Use it to change any visitor information before * the visitor is saved. */ - Piwik_PostEvent('Tracker.knownVisitorUpdate', array(&$valuesToUpdate)); + Piwik::postEvent('Tracker.knownVisitorUpdate', array(&$valuesToUpdate)); $this->visitorInfo['time_spent_ref_action'] = $this->getTimeSpentReferrerAction(); @@ -354,7 +355,7 @@ class Visit implements VisitInterface * After a known visitor is saved and updated by Piwik, this event is called. Useful for plugins that want to * register information about a returning visitor, or filter the existing information. */ - Piwik_PostEvent('Tracker.knownVisitorInformation', array(&$this->visitorInfo)); + Piwik::postEvent('Tracker.knownVisitorInformation', array(&$this->visitorInfo)); } /** @@ -476,7 +477,7 @@ class Visit implements VisitInterface * new information about a visitor, or filter the existing information. `$extraInfo` contains the UserAgent. * You can for instance change the user's location country depending on the User Agent. */ - Piwik_PostEvent('Tracker.newVisitorInformation', array(&$this->visitorInfo, $extraInfo)); + Piwik::postEvent('Tracker.newVisitorInformation', array(&$this->visitorInfo, $extraInfo)); $this->request->overrideLocation($this->visitorInfo); diff --git a/core/Tracker/VisitExcluded.php b/core/Tracker/VisitExcluded.php index 2374e31b913e158c7f08c9bb92078b36c29b8919..48d37036c6d97eb9e5f97143a3b05b3dc03a5c1c 100644 --- a/core/Tracker/VisitExcluded.php +++ b/core/Tracker/VisitExcluded.php @@ -12,6 +12,7 @@ namespace Piwik\Tracker; use Piwik\Common; use Piwik\IP; +use Piwik\Piwik; /** * This class contains the logic to exclude some visitors from being tracked as per user settings @@ -75,7 +76,7 @@ class VisitExcluded * At every page view, this event will be called. It is useful for plugins that want to exclude specific visits * (ie. IP excluding, Cookie excluding). If you set `$excluded` to `true`, the visit will be excluded. */ - Piwik_PostEvent('Tracker.isExcludedVisit', array(&$excluded)); + Piwik::postEvent('Tracker.isExcludedVisit', array(&$excluded)); /* * Following exclude operations happen after the hook. diff --git a/core/Translate.php b/core/Translate.php index 6c03b882366cefcc71d0ce530044040ac5da3b7d..22b2193f17eee6707cc1bbc54a973f8533096603 100644 --- a/core/Translate.php +++ b/core/Translate.php @@ -119,7 +119,7 @@ class Translate * it for instance to detect the users language by using a third party API such as a CMS. The language that * is set in the request URL is passed as an argument. */ - Piwik_PostEvent('User.getLanguage', array(&$lang)); + Piwik::postEvent('User.getLanguage', array(&$lang)); self::$languageToLoad = $lang; } @@ -188,7 +188,7 @@ class Translate * } * ``` */ - Piwik_PostEvent(self::GET_CLIENT_SIDE_TRANSLATION_KEYS_EVENT, array(&$result)); + Piwik::postEvent(self::GET_CLIENT_SIDE_TRANSLATION_KEYS_EVENT, array(&$result)); $result = array_unique($result); diff --git a/core/Twig.php b/core/Twig.php index 8ec3fa5bee7a66adda2eebe2bf3deec36866c66f..d0a3ddea5b49f6902d5d1886d790009581733e0e 100644 --- a/core/Twig.php +++ b/core/Twig.php @@ -115,7 +115,7 @@ class Twig { $postEventFunction = new Twig_SimpleFunction('postEvent', function ($eventName) { $str = ''; - Piwik_PostEvent($eventName, array(&$str)); + Piwik::postEvent($eventName, array(&$str)); return $str; }, array('is_safe' => array('html'))); $this->twig->addFunction($postEventFunction); diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php index d93d95dbd313b6565444be8ee8713155620057d5..1977cf8243b889682b7bc8437f7e7f4ca36f94fd 100644 --- a/core/ViewDataTable.php +++ b/core/ViewDataTable.php @@ -441,7 +441,7 @@ class ViewDataTable * } * ``` */ - Piwik_PostEvent('Visualization.getReportDisplayProperties', array(&self::$reportPropertiesCache)); + Piwik::postEvent('Visualization.getReportDisplayProperties', array(&self::$reportPropertiesCache)); } return self::$reportPropertiesCache; @@ -1106,7 +1106,7 @@ class ViewDataTable * that provide new visualizations can use this event to make sure certain reports * are configured differently when viewed with the new visualization. */ - Piwik_PostEvent(self::CONFIGURE_VIEW_EVENT, array($viewDataTable = $this)); + Piwik::postEvent(self::CONFIGURE_VIEW_EVENT, array($viewDataTable = $this)); $this->overrideViewProperties(); try { @@ -1299,7 +1299,7 @@ class ViewDataTable * ) * ``` */ - Piwik_PostEvent(self::CONFIGURE_FOOTER_ICONS_EVENT, array(&$result, $viewDataTable = $this)); + Piwik::postEvent(self::CONFIGURE_FOOTER_ICONS_EVENT, array(&$result, $viewDataTable = $this)); return $result; } diff --git a/core/ViewDataTable/Visualization.php b/core/ViewDataTable/Visualization.php index 98111be77a49c154da2f868e1acdc0e7c5ad2f18..5adf6b3cf6207dec7ce1c0d8a3b3528b90bd68d7 100644 --- a/core/ViewDataTable/Visualization.php +++ b/core/ViewDataTable/Visualization.php @@ -12,6 +12,7 @@ namespace Piwik\ViewDataTable; use Piwik\DataTable; +use Piwik\Piwik; use Piwik\View; /** @@ -154,7 +155,7 @@ abstract class Visualization extends View * This event is used to gather all available DataTable visualizations. Callbacks should add visualization * class names to the incoming array. */ - Piwik_PostEvent(self::GET_AVAILABLE_EVENT, array(&$visualizations)); + Piwik::postEvent(self::GET_AVAILABLE_EVENT, array(&$visualizations)); $result = array(); foreach ($visualizations as $viz) { diff --git a/core/WidgetsList.php b/core/WidgetsList.php index 3696cd02f2d70d5aac79d25a9ea563e183b83eb3..71a813b64f72cf866b00e071b0bfd086572b7e6d 100644 --- a/core/WidgetsList.php +++ b/core/WidgetsList.php @@ -69,7 +69,7 @@ class WidgetsList * } * ``` */ - Piwik_PostEvent('WidgetsList.addWidgets'); + Piwik::postEvent('WidgetsList.addWidgets'); } } diff --git a/core/functions.php b/core/functions.php index 68fe8829a4a9a368bd40b161bd66a2a2a286801b..6cca433647a3ea6de6ce7a1229b5eea63ea58656 100644 --- a/core/functions.php +++ b/core/functions.php @@ -13,49 +13,10 @@ namespace { use Piwik\DataTable; - use Piwik\EventDispatcher; use Piwik\Menu\Admin; use Piwik\Menu\Main; use Piwik\Menu\Top; - /** - * Post an event to the dispatcher which will notice the observers. - * - * @param string $eventName The event name. - * @param array $params The parameter array to forward to observer callbacks. - * @param bool $pending - * @param null $plugins - * @return void - * @api - */ - function Piwik_PostEvent($eventName, $params = array(), $pending = false, $plugins = null) - { - EventDispatcher::getInstance()->postEvent($eventName, $params, $pending, $plugins); - } - - /** - * Register an action to execute for a given event - * - * @param string $eventName Name of event - * @param callable $function Callback hook - * @api - */ - function Piwik_AddAction($eventName, $function) - { - EventDispatcher::getInstance()->addObserver($eventName, $function); - } - - /** - * Posts an event if we are currently running tests. Whether we are running tests is - * determined by looking for the PIWIK_TEST_MODE constant. - */ - function Piwik_PostTestEvent($eventName, $params = array(), $pending = false, $plugins = null) - { - if (defined('PIWIK_TEST_MODE')) { - Piwik_PostEvent($eventName, $params, $pending, $plugins); - } - } - /** * Returns translated string or given message if translation is not found. * diff --git a/plugins/API/API.php b/plugins/API/API.php index afe0ea8a870f22f4d500c3f0329471c040f04d3a..41aeea28c48f749417475881422f7d4a120cf192 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -99,7 +99,7 @@ class API * This event is triggered to get all available segments. Your plugin can use this event to add one or * multiple new segments. */ - Piwik_PostEvent('API.getSegmentsMetadata', array(&$segments, $idSites)); + Piwik::postEvent('API.getSegmentsMetadata', array(&$segments, $idSites)); $isAuthenticatedWithViewAccess = Piwik::isUserHasViewAccess($idSites) && !Piwik::isUserIsAnonymous(); diff --git a/plugins/API/ProcessedReport.php b/plugins/API/ProcessedReport.php index eeea9bb4cae99d83a22632493316a376f368fd81..af7c271762cfc0b0db1502778ed9c521e30a30f2 100644 --- a/plugins/API/ProcessedReport.php +++ b/plugins/API/ProcessedReport.php @@ -90,7 +90,7 @@ class ProcessedReport * multiple reports. By doing that the report will be for instance available in ScheduledReports as well as * in the Piwik Mobile App. */ - Piwik_PostEvent('API.getReportMetadata', array(&$availableReports, $parameters)); + Piwik::postEvent('API.getReportMetadata', array(&$availableReports, $parameters)); foreach ($availableReports as &$availableReport) { if (!isset($availableReport['metrics'])) { $availableReport['metrics'] = Metrics::getDefaultMetrics(); @@ -112,7 +112,7 @@ class ProcessedReport * This event is triggered after all available reports are collected. Plugins can add custom metrics to * other reports or remove reports from the list of all available reports. */ - Piwik_PostEvent('API.getReportMetadata.end', array(&$availableReports, $parameters)); + Piwik::postEvent('API.getReportMetadata.end', array(&$availableReports, $parameters)); // Sort results to ensure consistent order usort($availableReports, array($this, 'sort')); diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index 21a34d25629289685853108cc5c1f7c32c2cf91c..847fabd7ad4be9550deede5f3fdca5b937436f16 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -359,7 +359,7 @@ class Goals extends \Piwik\Plugin * This event is triggered by the Goals plugin to gather the list of all reports which define Goal metrics (conversions, revenue). * You can use this event to add your report to the list of reports displayed in the left column of the Goals Overview report. */ - Piwik_PostEvent('Goals.getReportsWithGoalMetrics', array(&$reportsWithGoals)); + Piwik::postEvent('Goals.getReportsWithGoalMetrics', array(&$reportsWithGoals)); return $reportsWithGoals; } diff --git a/plugins/Live/API.php b/plugins/Live/API.php index 065521a26350ce239927415acdb171ce7827922c..3cfc1bba75a6c1d0b72ab3181db7dd92da6897fd 100644 --- a/plugins/Live/API.php +++ b/plugins/Live/API.php @@ -370,7 +370,7 @@ class API * - visitorAvatar: A URL to an image to display in the top left corner of the popup. * - visitorDescription: Text to be used as the tooltip of the avatar image. */ - Piwik_PostEvent('Live.getExtraVisitorDetails', array(&$result)); + Piwik::postEvent('Live.getExtraVisitorDetails', array(&$result)); return $result; } diff --git a/plugins/Login/Controller.php b/plugins/Login/Controller.php index c39071069308980c8052bf6fb248c22fb56e9e8f..ea9cd8788e16d5d0967389b1ec7c0c85df146655 100644 --- a/plugins/Login/Controller.php +++ b/plugins/Login/Controller.php @@ -184,7 +184,7 @@ class Controller extends \Piwik\Controller * } * ``` */ - Piwik_PostEvent('Login.initSession', array(&$info)); + Piwik::postEvent('Login.initSession', array(&$info)); Url::redirectToUrl($urlToRedirect); } diff --git a/plugins/Overlay/API.php b/plugins/Overlay/API.php index de5fb7f39d9143af4a8547accb54d6fc9e0fbbfd..37ac6b7e491e4e4f534141af34a0a37902b0307e 100644 --- a/plugins/Overlay/API.php +++ b/plugins/Overlay/API.php @@ -121,7 +121,7 @@ class API * authentication object instead of the Piwik authentication. Make sure to implement the `Piwik\Auth` * interface in case you want to define your own authentication. */ - Piwik_PostEvent('Request.initAuthenticationObject', array($allowCookieAuthentication = true)); + Piwik::postEvent('Request.initAuthenticationObject', array($allowCookieAuthentication = true)); $auth = \Piwik\Registry::get('auth'); $success = Access::getInstance()->reloadAccess($auth); diff --git a/plugins/PrivacyManager/LogDataPurger.php b/plugins/PrivacyManager/LogDataPurger.php index 152b71de367e32faf23b17dfae0d5106edb4afae..eb95300a07467938a8cba821059f7ab72c796d4e 100755 --- a/plugins/PrivacyManager/LogDataPurger.php +++ b/plugins/PrivacyManager/LogDataPurger.php @@ -15,6 +15,7 @@ use Piwik\Common; use Piwik\Date; use Piwik\Db; use Piwik\Log; +use Piwik\Piwik; /** * Purges the log_visit, log_conversion and related tables of old visit data. @@ -230,12 +231,12 @@ class LogDataPurger /** * @ignore */ - Piwik_PostEvent("LogDataPurger.ActionsToKeepInserted.olderThan"); + Piwik::postEvent("LogDataPurger.ActionsToKeepInserted.olderThan"); } else { /** * @ignore */ - Piwik_PostEvent("LogDataPurger.ActionsToKeepInserted.newerThan"); + Piwik::postEvent("LogDataPurger.ActionsToKeepInserted.newerThan"); } } diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php index 79f8b60217ce9bf9d819ccecb05adc3863ea4391..a6b67e68fd8154d9a52da07eef1978ea170922c5 100644 --- a/plugins/Provider/Provider.php +++ b/plugins/Provider/Provider.php @@ -17,6 +17,7 @@ use Piwik\Db; use Piwik\FrontController; use Piwik\IP; +use Piwik\Piwik; use Piwik\WidgetsList; /** @@ -103,7 +104,7 @@ class Provider extends \Piwik\Plugin public function postLoad() { - Piwik_AddAction('Template.footerUserCountry', array('Piwik\Plugins\Provider\Provider', 'footerUserCountry')); + Piwik::addAction('Template.footerUserCountry', array('Piwik\Plugins\Provider\Provider', 'footerUserCountry')); } /** @@ -178,7 +179,7 @@ class Provider extends \Piwik\Plugin * } * ``` */ - Piwik_PostEvent('Provider.getCleanHostname', array(&$cleanHostname, $hostname)); + Piwik::postEvent('Provider.getCleanHostname', array(&$cleanHostname, $hostname)); if ($cleanHostname !== null) { return $cleanHostname; } diff --git a/plugins/ScheduledReports/API.php b/plugins/ScheduledReports/API.php index 3e45c18fded4c6b5814cd4aeecea996357f7f44d..bdac69a7db0675d02c436a1365ac3af19ad0faf2 100644 --- a/plugins/ScheduledReports/API.php +++ b/plugins/ScheduledReports/API.php @@ -415,7 +415,7 @@ class API /** * This event allows plugins to alter processed reports. */ - Piwik_PostEvent( + Piwik::postEvent( self::PROCESS_REPORTS_EVENT, array(&$processedReports, $notificationInfo) ); @@ -424,7 +424,7 @@ class API * This event is triggered to retrieve the report renderer instance. */ $reportRenderer = null; - Piwik_PostEvent( + Piwik::postEvent( self::GET_RENDERER_INSTANCE_EVENT, array(&$reportRenderer, $notificationInfo) ); @@ -535,7 +535,7 @@ class API $contents = fread($handle, filesize($outputFilename)); fclose($handle); - Piwik_PostEvent( + Piwik::postEvent( self::SEND_REPORT_EVENT, array( $notificationInfo = array( @@ -587,7 +587,7 @@ class API self::REPORT_TYPE_INFO_KEY => $reportType ); - Piwik_PostEvent(self::GET_REPORT_PARAMETERS_EVENT, array(&$availableParameters, $notificationInfo)); + Piwik::postEvent(self::GET_REPORT_PARAMETERS_EVENT, array(&$availableParameters, $notificationInfo)); // unset invalid parameters $availableParameterKeys = array_keys($availableParameters); @@ -607,7 +607,7 @@ class API /** * This event is triggered to delegate report parameter validation. */ - Piwik_PostEvent(self::VALIDATE_PARAMETERS_EVENT, array(&$parameters, $notificationInfo)); + Piwik::postEvent(self::VALIDATE_PARAMETERS_EVENT, array(&$parameters, $notificationInfo)); return Common::json_encode($parameters); } @@ -719,7 +719,7 @@ class API * This event is used to retrieve all available reports. */ $availableReportMetadata = array(); - Piwik_PostEvent( + Piwik::postEvent( self::GET_REPORT_METADATA_EVENT, array(&$availableReportMetadata, $notificationInfo) ); @@ -733,7 +733,7 @@ class API static public function allowMultipleReports($reportType) { $allowMultipleReports = null; - Piwik_PostEvent( + Piwik::postEvent( self::ALLOW_MULTIPLE_REPORTS_EVENT, array( &$allowMultipleReports, @@ -751,7 +751,7 @@ class API static public function getReportTypes() { $reportTypes = array(); - Piwik_PostEvent(self::GET_REPORT_TYPES_EVENT, array(&$reportTypes)); + Piwik::postEvent(self::GET_REPORT_TYPES_EVENT, array(&$reportTypes)); return $reportTypes; } @@ -763,7 +763,7 @@ class API { $reportFormats = array(); - Piwik_PostEvent( + Piwik::postEvent( self::GET_REPORT_FORMATS_EVENT, array( &$reportFormats, @@ -790,7 +790,7 @@ class API * This event is used to retrieve the report renderer instance. */ $recipients = array(); - Piwik_PostEvent(self::GET_REPORT_RECIPIENTS_EVENT, array(&$recipients, $notificationInfo)); + Piwik::postEvent(self::GET_REPORT_RECIPIENTS_EVENT, array(&$recipients, $notificationInfo)); return $recipients; } diff --git a/plugins/SegmentEditor/API.php b/plugins/SegmentEditor/API.php index f98d93e72f7e8c4ff0cd15c4cc7329d9319e1a91..e17bbacd19d21a0321d467baab17ad85f518bf44 100644 --- a/plugins/SegmentEditor/API.php +++ b/plugins/SegmentEditor/API.php @@ -314,7 +314,7 @@ class API * This event is triggered when a segment is deleted or made invisible. It allows plugins to throw an exception * or to propagate the action. */ - Piwik_PostEvent(self::DEACTIVATE_SEGMENT_EVENT, array(&$idSegment)); + Piwik::postEvent(self::DEACTIVATE_SEGMENT_EVENT, array(&$idSegment)); } /** diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php index fa322d1aceb493e236ed77d934f4afb938e728c9..00ba33b32fcdade7234eb4711ec22ca938e422a5 100644 --- a/plugins/SitesManager/API.php +++ b/plugins/SitesManager/API.php @@ -599,7 +599,7 @@ class API * values or settings. For instance removing all goals that belong to a specific website. If you store any data * related to a website you may want to clean up that information. */ - Piwik_PostEvent('SitesManager.deleteSite.end', array($idSite)); + Piwik::postEvent('SitesManager.deleteSite.end', array($idSite)); } /** diff --git a/plugins/UserCountryMap/UserCountryMap.php b/plugins/UserCountryMap/UserCountryMap.php index 61e24df047c77dbc8adfa3a3d73696935453210f..8376d9bfa86f3121c4f07d75f2072e305313d318 100644 --- a/plugins/UserCountryMap/UserCountryMap.php +++ b/plugins/UserCountryMap/UserCountryMap.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\UserCountryMap; use Piwik\FrontController; +use Piwik\Piwik; use Piwik\Version; use Piwik\WidgetsList; @@ -39,7 +40,7 @@ class UserCountryMap extends \Piwik\Plugin 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\Plugins\UserCountryMap\UserCountryMap', 'insertMapInLocationReport')); + Piwik::addAction('Template.leftColumnUserCountry', array('Piwik\Plugins\UserCountryMap\UserCountryMap', 'insertMapInLocationReport')); } static public function insertMapInLocationReport(&$out) diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php index 98ec5a97dffdab51d8275e2bd6e9adf9b549aa0d..12a246b5a22e22f82eb7f0747904f7d41fe0512c 100644 --- a/plugins/UsersManager/API.php +++ b/plugins/UsersManager/API.php @@ -402,7 +402,7 @@ class API * This event is triggered after a new user is created and saved in the database. `$userLogin` contains all * relevant user information like login name, alias, email and transformed password. */ - Piwik_PostEvent('UsersManager.addUser.end', array($userLogin)); + Piwik::postEvent('UsersManager.addUser.end', array($userLogin)); } /** @@ -463,7 +463,7 @@ class API * This event is triggered after an existing user has been updated. `$userLogin` contains the updated user * information like login name, alias and email. */ - Piwik_PostEvent('UsersManager.updateUser.end', array($userLogin)); + Piwik::postEvent('UsersManager.updateUser.end', array($userLogin)); } /** @@ -654,7 +654,7 @@ class API * values or settings. For instance removing all created dashboards that belong to a specific user. * If you store any data related to a user, you may want to clean up that information. */ - Piwik_PostEvent('UsersManager.deleteUser', array($userLogin)); + Piwik::postEvent('UsersManager.deleteUser', array($userLogin)); } /** diff --git a/plugins/UsersManager/Controller.php b/plugins/UsersManager/Controller.php index 3241b7e30f7d6c6029c164ba95fe8b587f4a448d..35954c73cffb408fcfd50adb882f85d53e821cc0 100644 --- a/plugins/UsersManager/Controller.php +++ b/plugins/UsersManager/Controller.php @@ -338,7 +338,7 @@ class Controller extends Admin * ``` * @matt this event is also triggered twice. */ - Piwik_PostEvent('Login.initSession', array($info)); + Piwik::postEvent('Login.initSession', array($info)); } APIUsersManager::getInstance()->setUserPreference($userLogin, diff --git a/plugins/VisitorInterest/VisitorInterest.php b/plugins/VisitorInterest/VisitorInterest.php index 01207200042f0655970de5150bb2a0a3a55255db..4bf80255a9960559e23e06ff6230c3386cdd86a6 100644 --- a/plugins/VisitorInterest/VisitorInterest.php +++ b/plugins/VisitorInterest/VisitorInterest.php @@ -14,6 +14,7 @@ use Piwik\ArchiveProcessor; use Piwik\FrontController; use Piwik\Metrics; +use Piwik\Piwik; use Piwik\WidgetsList; /** @@ -115,8 +116,8 @@ class VisitorInterest extends \Piwik\Plugin function postLoad() { - Piwik_AddAction('Template.headerVisitsFrequency', array('Piwik\Plugins\VisitorInterest\VisitorInterest', 'headerVisitsFrequency')); - Piwik_AddAction('Template.footerVisitsFrequency', array('Piwik\Plugins\VisitorInterest\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) diff --git a/tests/PHPUnit/Core/TaskSchedulerTest.php b/tests/PHPUnit/Core/TaskSchedulerTest.php index 1ae9ad1eb8f96bf3ca00f362f950320429e89989..821b45f7e00ecf9b0f35fe598612696799545bd2 100644 --- a/tests/PHPUnit/Core/TaskSchedulerTest.php +++ b/tests/PHPUnit/Core/TaskSchedulerTest.php @@ -288,7 +288,7 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase \Piwik\PluginsManager::getInstance()->unloadPlugins(); // make sure the get tasks event returns our configured tasks - Piwik_AddAction(TaskScheduler::GET_TASKS_EVENT, function(&$tasks) use($configuredTasks) { + Piwik::addAction(TaskScheduler::GET_TASKS_EVENT, function(&$tasks) use($configuredTasks) { $tasks = $configuredTasks; }); diff --git a/tests/PHPUnit/Integration/ArchiveCronTest.php b/tests/PHPUnit/Integration/ArchiveCronTest.php index ddfa87cfb2ce021a5c70afd92788ae6931a91fdd..89f90c57df84bf30224cb3bef69514db238936a0 100644 --- a/tests/PHPUnit/Integration/ArchiveCronTest.php +++ b/tests/PHPUnit/Integration/ArchiveCronTest.php @@ -20,7 +20,7 @@ class Test_Piwik_Integration_ArchiveCronTest extends IntegrationTestCase public static function createAccessInstance() { Access::setSingletonInstance($access = new Test_Access_OverrideLogin()); - Piwik_PostEvent('Request.initAuthenticationObject'); + Piwik::postEvent('Request.initAuthenticationObject'); } public function getApiForTesting() diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php index 9f60838c97918133926ed8e329c24c6f1d4da58f..799ad6eaa372b36cf1fb861b45b61dd354a96719 100755 --- a/tests/PHPUnit/IntegrationTestCase.php +++ b/tests/PHPUnit/IntegrationTestCase.php @@ -57,7 +57,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase { Access::setSingletonInstance(null); Access::getInstance(); - Piwik_PostEvent('Request.initAuthenticationObject'); + Piwik::postEvent('Request.initAuthenticationObject'); } /** diff --git a/tests/PHPUnit/Plugins/PrivacyManagerTest.php b/tests/PHPUnit/Plugins/PrivacyManagerTest.php index 80944961095ce827cedc18032eaeb0cc03f5fed0..70100d265e92e27d97a3ecbb5ea88939186b4367 100755 --- a/tests/PHPUnit/Plugins/PrivacyManagerTest.php +++ b/tests/PHPUnit/Plugins/PrivacyManagerTest.php @@ -512,7 +512,7 @@ class PrivacyManagerTest extends IntegrationTestCase */ public function testPurgeLogDataConcurrency() { - Piwik_AddAction("LogDataPurger.ActionsToKeepInserted.olderThan", array($this, 'addReferenceToUnusedAction')); + Piwik::addAction("LogDataPurger.ActionsToKeepInserted.olderThan", array($this, 'addReferenceToUnusedAction')); $purger = LogDataPurger::make($this->settings, true); diff --git a/tests/PHPUnit/TestingEnvironment.php b/tests/PHPUnit/TestingEnvironment.php index 67099469886adc462c310dbc3880a0c9c40a0681..fa43514d9250f4fb9ed03cdfd458bacb490f5ca8 100644 --- a/tests/PHPUnit/TestingEnvironment.php +++ b/tests/PHPUnit/TestingEnvironment.php @@ -37,11 +37,11 @@ class Piwik_TestingEnvironment { public static function addHooks() { - Piwik_AddAction('Access.createAccessSingleton', function($access) { + Piwik::addAction('Access.createAccessSingleton', function($access) { $access = new Piwik_MockAccess($access); \Piwik\Access::setSingletonInstance($access); }); - Piwik_AddAction('Config.createConfigSingleton', function($config) { + Piwik::addAction('Config.createConfigSingleton', function($config) { \Piwik\CacheFile::$invalidateOpCacheBeforeRead = true; $config->setTestEnvironment(); @@ -60,15 +60,15 @@ class Piwik_TestingEnvironment $config->General['session_save_handler'] = 'dbtables'; // to avoid weird session error in travis $config->superuser['email'] = 'hello@example.org'; }); - Piwik_AddAction('Request.dispatch', function() { + Piwik::addAction('Request.dispatch', function() { \Piwik\Plugins\CoreVisualizations\Visualizations\Cloud::$debugDisableShuffle = true; \Piwik\Visualization\Sparkline::$enableSparklineImages = false; \Piwik\Plugins\ExampleUI\API::$disableRandomness = true; }); - Piwik_AddAction('AssetManager.getStylesheetFiles', function(&$stylesheets) { + Piwik::addAction('AssetManager.getStylesheetFiles', function(&$stylesheets) { $stylesheets[] = 'tests/resources/screenshot-override/override.css'; }); - Piwik_AddAction('AssetManager.getJavaScriptFiles', function(&$jsFiles) { + Piwik::addAction('AssetManager.getJavaScriptFiles', function(&$jsFiles) { $jsFiles[] = 'tests/resources/screenshot-override/jquery.waitforimages.js'; $jsFiles[] = 'tests/resources/screenshot-override/override.js'; }); diff --git a/tests/PHPUnit/UITest.php b/tests/PHPUnit/UITest.php index bc8643607dac80ef42fadada47f60f0b4893ac27..eb94d754675eed22cf9b4360bea2a35b43739404 100644 --- a/tests/PHPUnit/UITest.php +++ b/tests/PHPUnit/UITest.php @@ -24,7 +24,7 @@ abstract class UITest extends IntegrationTestCase public static function createAccessInstance() { Access::setSingletonInstance($access = new Test_Access_OverrideLogin()); - Piwik_PostEvent('Request.initAuthenticationObject'); + Piwik::postEvent('Request.initAuthenticationObject'); } public static function setUpBeforeClass()