diff options
author | Fabian Becker <fabian.becker@uni-tuebingen.de> | 2013-07-18 13:25:08 +0400 |
---|---|---|
committer | Fabian Becker <fabian.becker@uni-tuebingen.de> | 2013-07-18 13:25:08 +0400 |
commit | 879d0e094824bd6d46ca1ecbba1cda945394bb05 (patch) | |
tree | 038ad7cbfe1e6441ada4e5a979ec54331d910f42 | |
parent | df0fd261c9172926a8a2a9a05fd4b30bd840d5f7 (diff) |
Refactor Piwik_Config to \Piwik\Core\Config
2 steps required:
1. Refactor > Move > \Piwik\Core\Config (uncheck "Create new File")
2. Refactor > Rename > Piwik_Config to Config
96 files changed, 436 insertions, 312 deletions
diff --git a/core/Access.php b/core/Access.php index 33952f943e..cab3a766e9 100644 --- a/core/Access.php +++ b/core/Access.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Class to handle User Access: @@ -217,7 +218,7 @@ class Piwik_Access if (isset($GLOBALS['PIWIK_ACCESS_SUPERUSER_LOGIN'])) { $this->login = $GLOBALS['PIWIK_ACCESS_SUPERUSER_LOGIN']; } else { - $this->login = Piwik_Config::getInstance()->superuser['login']; + $this->login = Config::getInstance()->superuser['login']; } return true; @@ -276,7 +277,7 @@ class Piwik_Access */ public function getSuperUserLogin() { - $superuser = Piwik_Config::getInstance()->superuser; + $superuser = Config::getInstance()->superuser; return $superuser['login']; } diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php index b25326d68f..21f18e99de 100644 --- a/core/ArchiveProcessor.php +++ b/core/ArchiveProcessor.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * The ArchiveProcessor class is used by the Archive object to make sure the given Archive is processed and available in the DB. @@ -225,7 +226,7 @@ abstract class Piwik_ArchiveProcessor } elseif ($period == 'range') { $debugSetting = 'always_archive_data_range'; } - return Piwik_Config::getInstance()->Debug[$debugSetting]; + return Config::getInstance()->Debug[$debugSetting]; } /** diff --git a/core/ArchiveProcessor/Rules.php b/core/ArchiveProcessor/Rules.php index 02f10c7d37..708ca72b9d 100644 --- a/core/ArchiveProcessor/Rules.php +++ b/core/ArchiveProcessor/Rules.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * This class contains Archiving rules/logic which are used in several places @@ -171,7 +172,7 @@ class Piwik_ArchiveProcessor_Rules if ($timeToLive !== false) { return $timeToLive; } - return Piwik_Config::getInstance()->General['time_before_today_archive_considered_outdated']; + return Config::getInstance()->General['time_before_today_archive_considered_outdated']; } public static function isArchivingDisabledFor(Piwik_Segment $segment, $periodLabel) @@ -188,7 +189,7 @@ class Piwik_ArchiveProcessor_Rules // if browser archiving is not allowed, then archiving is disabled if (!$segment->isEmpty() && $isArchivingDisabled - && Piwik_Config::getInstance()->General['browser_archiving_disabled_enforce'] + && Config::getInstance()->General['browser_archiving_disabled_enforce'] ) { Piwik::log("Archiving is disabled because of config setting browser_archiving_disabled_enforce=1"); return true; @@ -213,7 +214,7 @@ class Piwik_ArchiveProcessor_Rules if ($browserArchivingEnabled !== false) { return (bool)$browserArchivingEnabled; } - return (bool)Piwik_Config::getInstance()->General['enable_browser_archiving_triggering']; + return (bool)Config::getInstance()->General['enable_browser_archiving_triggering']; } public static function setBrowserTriggerArchiving($enabled) diff --git a/core/AssetManager.php b/core/AssetManager.php index a87db2a3f0..6f305bab08 100644 --- a/core/AssetManager.php +++ b/core/AssetManager.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @see libs/jsmin/jsmin.php @@ -322,7 +323,7 @@ class Piwik_AssetManager */ private static function getDisableMergedAssets() { - return Piwik_Config::getInstance()->Debug['disable_merged_assets']; + return Config::getInstance()->Debug['disable_merged_assets']; } /** diff --git a/core/Common.php b/core/Common.php index b3f3560344..d9c9371c69 100644 --- a/core/Common.php +++ b/core/Common.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Static class providing functions used by both the CORE of Piwik and the visitor Tracking engine. @@ -62,7 +63,7 @@ class Piwik_Common */ public static function prefixTable($table) { - $prefix = Piwik_Config::getInstance()->database['tables_prefix']; + $prefix = Config::getInstance()->database['tables_prefix']; return $prefix . $table; } @@ -91,7 +92,7 @@ class Piwik_Common { static $prefixTable = null; if (is_null($prefixTable)) { - $prefixTable = Piwik_Config::getInstance()->database['tables_prefix']; + $prefixTable = Config::getInstance()->database['tables_prefix']; } if (empty($prefixTable) || strpos($table, $prefixTable) !== 0 @@ -671,7 +672,7 @@ class Piwik_Common { static $salt = null; if (is_null($salt)) { - $salt = @Piwik_Config::getInstance()->superuser['salt']; + $salt = @Config::getInstance()->superuser['salt']; } return $salt; } @@ -687,7 +688,7 @@ class Piwik_Common { static $hashAlgorithm = null; if (is_null($hashAlgorithm)) { - $hashAlgorithm = @Piwik_Config::getInstance()->General['hash_algorithm']; + $hashAlgorithm = @Config::getInstance()->General['hash_algorithm']; } if ($hashAlgorithm) { @@ -1130,8 +1131,8 @@ class Piwik_Common public static function getCampaignParameters() { $return = array( - Piwik_Config::getInstance()->Tracker['campaign_var_name'], - Piwik_Config::getInstance()->Tracker['campaign_keyword_var_name'], + Config::getInstance()->Tracker['campaign_var_name'], + Config::getInstance()->Tracker['campaign_keyword_var_name'], ); foreach ($return as &$list) { diff --git a/core/Config.php b/core/Config.php index 8b71e0c256..b5c5fb05fd 100644 --- a/core/Config.php +++ b/core/Config.php @@ -9,6 +9,9 @@ * @package Piwik */ +namespace Piwik\Core; +use Exception; + /** * For general performance (and specifically, the Tracker), we use deferred (lazy) initialization * and cache sections. We also avoid any dependency on Zend Framework's Zend_Config. @@ -38,20 +41,20 @@ * @package Piwik * @subpackage Piwik_Config */ -class Piwik_Config +class Config { private static $instance = null; /** * Returns the singleton Piwik_Config * - * @return Piwik_Config + * @return \Piwik\Core\Config */ public static function getInstance() { if (self::$instance == null) { self::$instance = new self; - + if (empty($GLOBALS['PIWIK_CONFIG_TEST_ENVIRONMENT'])) { self::$instance->init(); } else { @@ -126,12 +129,12 @@ class Piwik_Config // for unit tests, we set that no plugin is installed. This will force // the test initialization to create the plugins tables, execute ALTER queries, etc. $this->configCache['PluginsInstalled'] = array('PluginsInstalled' => array()); - + if (isset($configGlobal['Plugins'])) { $this->configCache['Plugins'] = $this->configGlobal['Plugins']; $this->configCache['Plugins']['Plugins'][] = 'DevicesDetection'; } - + $this->configCache['disable_merged_assets'] = 1; } diff --git a/core/Controller.php b/core/Controller.php index e8c485d5f7..14dc7e5628 100644 --- a/core/Controller.php +++ b/core/Controller.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Parent class of all plugins Controllers (located in /plugins/PluginName/Controller.php @@ -430,7 +431,7 @@ abstract class Piwik_Controller $language = Piwik_LanguagesManager::getLanguageForSession(); $view->language = !empty($language) ? $language : Piwik_LanguagesManager::getLanguageCodeForCurrentUser(); - $view->config_action_url_category_delimiter = Piwik_Config::getInstance()->General['action_url_category_delimiter']; + $view->config_action_url_category_delimiter = Config::getInstance()->General['action_url_category_delimiter']; $this->setBasicVariablesView($view); @@ -447,17 +448,17 @@ abstract class Piwik_Controller */ protected function setBasicVariablesView($view) { - $view->debugTrackVisitsInsidePiwikUI = Piwik_Config::getInstance()->Debug['track_visits_inside_piwik_ui']; + $view->debugTrackVisitsInsidePiwikUI = Config::getInstance()->Debug['track_visits_inside_piwik_ui']; $view->isSuperUser = Piwik_Access::getInstance()->isSuperUser(); $view->hasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess(); - $view->isCustomLogo = Piwik_Config::getInstance()->branding['use_custom_logo']; + $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->enableFrames = Piwik_Config::getInstance()->General['enable_framed_pages'] - || @Piwik_Config::getInstance()->General['enable_framed_logins']; + $view->enableFrames = Config::getInstance()->General['enable_framed_pages'] + || @Config::getInstance()->General['enable_framed_logins']; if (!$view->enableFrames) { $view->setXFrameOptions('sameorigin'); } @@ -480,7 +481,7 @@ abstract class Piwik_Controller $view->isValidHost = Piwik_Url::isValidHost(); if (!$view->isValidHost) { // invalid host, so display warning to user - $validHost = Piwik_Config::getInstance()->General['trusted_hosts'][0]; + $validHost = Config::getInstance()->General['trusted_hosts'][0]; $invalidHost = Piwik_Common::sanitizeInputValue($_SERVER['HTTP_HOST']); $emailSubject = rawurlencode(Piwik_Translate('CoreHome_InjectedHostEmailSubject', $invalidHost)); @@ -741,7 +742,7 @@ abstract class Piwik_Controller { $userSettingsDate = Piwik_UsersManager_API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE); if ($userSettingsDate === false) { - return Piwik_Config::getInstance()->General['default_period']; + return Config::getInstance()->General['default_period']; } if (in_array($userSettingsDate, array('today', 'yesterday'))) { return 'day'; diff --git a/core/Controller/Admin.php b/core/Controller/Admin.php index 35dbbd4780..16b633a0e9 100644 --- a/core/Controller/Admin.php +++ b/core/Controller/Admin.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Parent class of all plugins Controllers with admin functions @@ -31,12 +32,12 @@ abstract class Piwik_Controller_Admin extends Piwik_Controller static public function displayWarningIfConfigFileNotWritable(Piwik_View $view ) { - $view->configFileNotWritable = !Piwik_Config::getInstance()->isFileWritable(); + $view->configFileNotWritable = !Config::getInstance()->isFileWritable(); } static public function setBasicVariablesAdminView(Piwik_View $view) { - $statsEnabled = Piwik_Config::getInstance()->Tracker['record_statistics']; + $statsEnabled = Config::getInstance()->Tracker['record_statistics']; if ($statsEnabled == "0") { $view->statisticsNotRecorded = true; } @@ -44,7 +45,7 @@ abstract class Piwik_Controller_Admin extends Piwik_Controller $view->topMenu = Piwik_GetTopMenu(); $view->currentAdminMenuName = Piwik_GetCurrentAdminMenuName(); - $view->enableFrames = Piwik_Config::getInstance()->General['enable_framed_settings']; + $view->enableFrames = Config::getInstance()->General['enable_framed_settings']; if (!$view->enableFrames) { $view->setXFrameOptions('sameorigin'); } diff --git a/core/DataAccess/ArchiveWriter.php b/core/DataAccess/ArchiveWriter.php index bb10fe7a44..61c421b34f 100644 --- a/core/DataAccess/ArchiveWriter.php +++ b/core/DataAccess/ArchiveWriter.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * This class is used to create a new Archive. @@ -112,7 +113,7 @@ class Piwik_DataAccess_ArchiveWriter protected static function makeLockName($idsite, Piwik_Period $period, Piwik_Segment $segment) { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $lockName = 'piwik.' . $config->database['dbname'] . '.' diff --git a/core/Db/Adapter/Mysqli.php b/core/Db/Adapter/Mysqli.php index efb309afa5..c20800e2ea 100644 --- a/core/Db/Adapter/Mysqli.php +++ b/core/Db/Adapter/Mysqli.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @package Piwik @@ -53,7 +54,7 @@ class Piwik_Db_Adapter_Mysqli extends Zend_Db_Adapter_Mysqli implements Piwik_Db public function checkServerVersion() { $serverVersion = $this->getServerVersion(); - $requiredVersion = Piwik_Config::getInstance()->General['minimum_mysql_version']; + $requiredVersion = Config::getInstance()->General['minimum_mysql_version']; if (version_compare($serverVersion, $requiredVersion) === -1) { throw new Exception(Piwik_TranslateException('General_ExceptionDatabaseVersion', array('MySQL', $serverVersion, $requiredVersion))); } diff --git a/core/Db/Adapter/Pdo/Mssql.php b/core/Db/Adapter/Pdo/Mssql.php index 54a156295b..2e9def1834 100644 --- a/core/Db/Adapter/Pdo/Mssql.php +++ b/core/Db/Adapter/Pdo/Mssql.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @package Piwik @@ -129,7 +130,7 @@ class Piwik_Db_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Mssql implements Piwik_Db_A public function checkServerVersion() { $serverVersion = $this->getServerVersion(); - $requiredVersion = Piwik_Config::getInstance()->General['minimum_mssql_version']; + $requiredVersion = Config::getInstance()->General['minimum_mssql_version']; if (version_compare($serverVersion, $requiredVersion) === -1) { throw new Exception(Piwik_TranslateException('General_ExceptionDatabaseVersion', array('MSSQL', $serverVersion, $requiredVersion))); } @@ -244,7 +245,7 @@ class Piwik_Db_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Mssql implements Piwik_Db_A $this->_connect(); try { $version = $this->_connection->getAttribute(PDO::ATTR_CLIENT_VERSION); - $requiredVersion = Piwik_Config::getInstance()->General['minimum_mssql_client_version']; + $requiredVersion = Config::getInstance()->General['minimum_mssql_client_version']; if (version_compare($version['DriverVer'], $requiredVersion) === -1) { throw new Exception(Piwik_TranslateException('General_ExceptionDatabaseVersion', array('MSSQL', $version['DriverVer'], $requiredVersion))); } else { diff --git a/core/Db/Adapter/Pdo/Mysql.php b/core/Db/Adapter/Pdo/Mysql.php index 515019cb4f..33f52df232 100644 --- a/core/Db/Adapter/Pdo/Mysql.php +++ b/core/Db/Adapter/Pdo/Mysql.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @package Piwik @@ -83,7 +84,7 @@ class Piwik_Db_Adapter_Pdo_Mysql extends Zend_Db_Adapter_Pdo_Mysql implements Pi public function checkServerVersion() { $serverVersion = $this->getServerVersion(); - $requiredVersion = Piwik_Config::getInstance()->General['minimum_mysql_version']; + $requiredVersion = Config::getInstance()->General['minimum_mysql_version']; if (version_compare($serverVersion, $requiredVersion) === -1) { throw new Exception(Piwik_TranslateException('General_ExceptionDatabaseVersion', array('MySQL', $serverVersion, $requiredVersion))); } diff --git a/core/Db/Adapter/Pdo/Pgsql.php b/core/Db/Adapter/Pdo/Pgsql.php index c6b07bedf3..1b67103633 100644 --- a/core/Db/Adapter/Pdo/Pgsql.php +++ b/core/Db/Adapter/Pdo/Pgsql.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @package Piwik @@ -41,7 +42,7 @@ class Piwik_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Pgsql implements Pi public function checkServerVersion() { $databaseVersion = $this->getServerVersion(); - $requiredVersion = Piwik_Config::getInstance()->General['minimum_pgsql_version']; + $requiredVersion = Config::getInstance()->General['minimum_pgsql_version']; if (version_compare($databaseVersion, $requiredVersion) === -1) { throw new Exception(Piwik_TranslateException('General_ExceptionDatabaseVersion', array('PostgreSQL', $databaseVersion, $requiredVersion))); } diff --git a/core/Db/Schema.php b/core/Db/Schema.php index e9057e4852..ad972e910d 100644 --- a/core/Db/Schema.php +++ b/core/Db/Schema.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Schema abstraction @@ -130,7 +131,7 @@ class Piwik_Db_Schema $schema = null; Piwik_PostEvent('Schema.loadSchema', array(&$schema)); if ($schema === null) { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $dbInfos = $config->database; if (isset($dbInfos['schema'])) { $schemaName = $dbInfos['schema']; diff --git a/core/Db/Schema/Myisam.php b/core/Db/Schema/Myisam.php index 55cd20e715..b65e50d9f6 100644 --- a/core/Db/Schema/Myisam.php +++ b/core/Db/Schema/Myisam.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * MySQL schema @@ -51,7 +52,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface */ public function getTablesCreateSql() { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $prefixTables = $config->database['tables_prefix']; $tables = array( 'user' => "CREATE TABLE {$prefixTables}user ( @@ -421,7 +422,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface public function getTablesNames() { $aTables = array_keys($this->getTablesCreateSql()); - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $prefixTables = $config->database['tables_prefix']; $return = array(); foreach ($aTables as $table) { @@ -444,7 +445,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface || $forceReload === true ) { $db = Zend_Registry::get('db'); - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $prefixTables = $config->database['tables_prefix']; // '_' matches any character; force it to be literal @@ -487,7 +488,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface public function createDatabase($dbName = null) { if (is_null($dbName)) { - $dbName = Piwik_Config::getInstance()->database['dbname']; + $dbName = Config::getInstance()->database['dbname']; } Piwik_Exec("CREATE DATABASE IF NOT EXISTS " . $dbName . " DEFAULT CHARACTER SET utf8"); } @@ -497,7 +498,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface */ public function dropDatabase() { - $dbName = Piwik_Config::getInstance()->database['dbname']; + $dbName = Config::getInstance()->database['dbname']; Piwik_Exec("DROP DATABASE IF EXISTS " . $dbName); } @@ -507,7 +508,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface public function createTables() { $db = Zend_Registry::get('db'); - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $prefixTables = $config->database['tables_prefix']; $tablesAlreadyInstalled = $this->getTablesInstalled(); diff --git a/core/FrontController.php b/core/FrontController.php index 9932f6b058..3898033767 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @see core/PluginsManager.php @@ -189,7 +190,7 @@ class Piwik_FrontController { $exceptionToThrow = false; try { - Piwik_Config::getInstance(); + Config::getInstance(); } catch (Exception $e) { Piwik_PostEvent('FrontController.NoConfigurationFile', array($e), $pending = true); $exceptionToThrow = $e; @@ -243,7 +244,7 @@ class Piwik_FrontController $this->handleSSLRedirection(); $pluginsManager = Piwik_PluginsManager::getInstance(); - $pluginsToLoad = Piwik_Config::getInstance()->Plugins['Plugins']; + $pluginsToLoad = Config::getInstance()->Plugins['Plugins']; $pluginsManager->loadPlugins($pluginsToLoad); @@ -311,7 +312,7 @@ class Piwik_FrontController protected function handleMaintenanceMode() { - if (Piwik_Config::getInstance()->General['maintenance_mode'] == 1 + if (Config::getInstance()->General['maintenance_mode'] == 1 && !Piwik_Common::isPhpCliMode() ) { $format = Piwik_Common::getRequestVar('format', ''); @@ -319,7 +320,7 @@ class Piwik_FrontController $message = "Piwik is in scheduled maintenance. Please come back later." . " The administrator can disable maintenance by editing the file piwik/config/config.ini.php and removing the following: " . " maintenance_mode=1 "; - if (Piwik_Config::getInstance()->Tracker['record_statistics'] == 0) { + if (Config::getInstance()->Tracker['record_statistics'] == 0) { $message .= ' and record_statistics=0'; } @@ -338,7 +339,7 @@ class Piwik_FrontController protected function handleSSLRedirection() { if (!Piwik_Common::isPhpCliMode() - && Piwik_Config::getInstance()->General['force_ssl'] == 1 + && Config::getInstance()->General['force_ssl'] == 1 && !Piwik::isHttps() // Specifically disable for the opt out iframe && !(Piwik_Common::getRequestVar('module', '') == 'CoreAdminHome' diff --git a/core/Http.php b/core/Http.php index d120a49a91..5aa2712a9b 100644 --- a/core/Http.php +++ b/core/Http.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Server-side http client to retrieve content from remote servers, and optionally save to a local file. @@ -145,10 +146,10 @@ class Piwik_Http } // proxy configuration - $proxyHost = Piwik_Config::getInstance()->proxy['host']; - $proxyPort = Piwik_Config::getInstance()->proxy['port']; - $proxyUser = Piwik_Config::getInstance()->proxy['username']; - $proxyPassword = Piwik_Config::getInstance()->proxy['password']; + $proxyHost = Config::getInstance()->proxy['host']; + $proxyPort = Config::getInstance()->proxy['port']; + $proxyUser = Config::getInstance()->proxy['username']; + $proxyPassword = Config::getInstance()->proxy['password']; // other result data $status = null; diff --git a/core/IP.php b/core/IP.php index 4b2a94c942..86f7555b80 100644 --- a/core/IP.php +++ b/core/IP.php @@ -9,6 +9,8 @@ * @package Piwik */ +use Piwik\Core\Config; + if (Piwik_Common::isWindows() || !function_exists('inet_ntop')) { function _inet_ntop($in_addr) { @@ -365,7 +367,7 @@ class Piwik_IP */ public static function getIpFromHeader() { - $clientHeaders = @Piwik_Config::getInstance()->General['proxy_client_headers']; + $clientHeaders = @Config::getInstance()->General['proxy_client_headers']; if (!is_array($clientHeaders)) { $clientHeaders = array(); } @@ -388,7 +390,7 @@ class Piwik_IP */ public static function getNonProxyIpFromHeader($default, $proxyHeaders) { - $proxyIps = @Piwik_Config::getInstance()->General['proxy_ips']; + $proxyIps = @Config::getInstance()->General['proxy_ips']; if (!is_array($proxyIps)) { $proxyIps = array(); } diff --git a/core/Log.php b/core/Log.php index 5e658094f6..40ec5e88cf 100644 --- a/core/Log.php +++ b/core/Log.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @@ -35,7 +36,7 @@ abstract class Piwik_Log extends Zend_Log $this->currentRequestKey = substr(Piwik_Common::generateUniqId(), 0, 8); - $log_dir = Piwik_Config::getInstance()->log['logger_file_path']; + $log_dir = Config::getInstance()->log['logger_file_path']; if ($log_dir[0] != '/' && $log_dir[0] != DIRECTORY_SEPARATOR) { $log_dir = PIWIK_USER_PATH . '/' . $log_dir; } diff --git a/core/Mail.php b/core/Mail.php index 77cb44bef4..cadb830061 100644 --- a/core/Mail.php +++ b/core/Mail.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Class for sending mails, for more information see: @@ -38,7 +39,7 @@ class Piwik_Mail extends Zend_Mail */ public function setFrom($email, $name = null) { - $hostname = Piwik_Config::getInstance()->mail['defaultHostnameIfEmpty']; + $hostname = Config::getInstance()->mail['defaultHostnameIfEmpty']; $piwikHost = Piwik_Url::getCurrentHost($hostname); // If known Piwik URL, use it instead of "localhost" @@ -59,7 +60,7 @@ class Piwik_Mail extends Zend_Mail */ private function initSmtpTransport() { - $mailConfig = Piwik_Config::getInstance()->mail; + $mailConfig = Config::getInstance()->mail; if (empty($mailConfig['host']) || $mailConfig['transport'] != 'smtp' ) { diff --git a/core/Piwik.php b/core/Piwik.php index b37d8cf95b..413b9e3daa 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @see core/Translate.php @@ -56,7 +57,7 @@ class Piwik */ static public function isUniqueVisitorsEnabled($periodLabel) { - $generalSettings = Piwik_Config::getInstance()->General; + $generalSettings = Config::getInstance()->General; $settingName = "enable_processing_unique_visitors_$periodLabel"; $result = !empty($generalSettings[$settingName]) && $generalSettings[$settingName] == 1; @@ -79,7 +80,7 @@ class Piwik public static function isSegmentationEnabled() { return !Piwik::isUserIsAnonymous() - || Piwik_Config::getInstance()->General['anonymous_user_enable_use_segments_API']; + || Config::getInstance()->General['anonymous_user_enable_use_segments_API']; } /** @@ -941,14 +942,14 @@ class Piwik if ($memoryLimit === false) { return false; } - $minimumMemoryLimit = Piwik_Config::getInstance()->General['minimum_memory_limit']; + $minimumMemoryLimit = Config::getInstance()->General['minimum_memory_limit']; if (Piwik_Common::isArchivePhpTriggered() && Piwik::isUserIsSuperUser() ) { // archive.php: no time limit, high memory limit self::setMaxExecutionTime(0); - $minimumMemoryLimitWhenArchiving = Piwik_Config::getInstance()->General['minimum_memory_limit_when_archiving']; + $minimumMemoryLimitWhenArchiving = Config::getInstance()->General['minimum_memory_limit_when_archiving']; if ($memoryLimit < $minimumMemoryLimitWhenArchiving) { return self::setMemoryLimit($minimumMemoryLimitWhenArchiving); } @@ -997,9 +998,9 @@ class Piwik { try { $shouldLog = (Piwik_Common::isPhpCliMode() - || Piwik_Config::getInstance()->log['log_only_when_cli'] == 0) + || Config::getInstance()->log['log_only_when_cli'] == 0) && - (Piwik_Config::getInstance()->log['log_only_when_debug_parameter'] == 0 + (Config::getInstance()->log['log_only_when_debug_parameter'] == 0 || isset($_REQUEST['debug'])); } catch (Exception $e) { $shouldLog = false; @@ -1506,8 +1507,8 @@ class Piwik */ static public function getWebsitesCountToDisplay() { - $count = max(Piwik_Config::getInstance()->General['site_selector_max_sites'], - Piwik_Config::getInstance()->General['autocomplete_min_sites']); + $count = max(Config::getInstance()->General['site_selector_max_sites'], + Config::getInstance()->General['autocomplete_min_sites']); return (int)$count; } @@ -1519,7 +1520,7 @@ class Piwik static public function getKnownSegmentsToArchive() { if (self::$cachedKnownSegmentsToArchive === null) { - $segments = Piwik_Config::getInstance()->Segments; + $segments = Config::getInstance()->Segments; $cachedResult = isset($segments['Segments']) ? $segments['Segments'] : array(); Piwik_PostEvent('Piwik.getKnownSegmentsToArchiveAllSites', array(&$cachedResult)); @@ -1572,7 +1573,7 @@ class Piwik */ static public function getSuperUserEmail() { - $superuser = Piwik_Config::getInstance()->superuser; + $superuser = Config::getInstance()->superuser; return $superuser['email']; } @@ -1888,7 +1889,7 @@ class Piwik */ static public function createDatabaseObject($dbInfos = null) { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); if (is_null($dbInfos)) { $dbInfos = $config->database; @@ -1948,7 +1949,7 @@ class Piwik */ static public function createLogObject() { - $configAPI = Piwik_Config::getInstance()->log; + $configAPI = Config::getInstance()->log; $aLoggers = array( 'logger_api_call' => new Piwik_Log_APICall, @@ -2039,7 +2040,7 @@ class Piwik */ static public function isChecksEnabled() { - return Piwik_Config::getInstance()->General['disable_checks_usernames_attributes'] == 0; + return Config::getInstance()->General['disable_checks_usernames_attributes'] == 0; } /** @@ -2308,7 +2309,7 @@ class Piwik ); // hack for charset mismatch - if (!self::isDatabaseConnectionUTF8() && !isset(Piwik_Config::getInstance()->database['charset'])) { + if (!self::isDatabaseConnectionUTF8() && !isset(Config::getInstance()->database['charset'])) { $fileSpec['charset'] = 'latin1'; } diff --git a/core/PluginsArchiver.php b/core/PluginsArchiver.php index 6d1b047939..782e2536cb 100644 --- a/core/PluginsArchiver.php +++ b/core/PluginsArchiver.php @@ -9,6 +9,7 @@ * @category Piwik * @package Piwik_PluginArchiver */ +use Piwik\Core\Config; /** * Plugins that archive metrics for websites can implement an Archiver that extends this class @@ -19,7 +20,7 @@ abstract class Piwik_PluginsArchiver public function __construct(Piwik_ArchiveProcessor $processing) { - $this->maximumRows = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_standard']; + $this->maximumRows = Config::getInstance()->General['datatable_archiving_maximum_rows_standard']; $this->processor = $processing; } diff --git a/core/PluginsFunctions/Sql.php b/core/PluginsFunctions/Sql.php index 95c5ace1e0..fef08121e1 100644 --- a/core/PluginsFunctions/Sql.php +++ b/core/PluginsFunctions/Sql.php @@ -8,6 +8,7 @@ * @category Piwik * @package PluginsFunctions */ +use Piwik\Core\Config; /** * SQL wrapper @@ -147,7 +148,7 @@ class Piwik_Sql */ static public function optimizeTables($tables) { - $optimize = Piwik_Config::getInstance()->General['enable_sql_optimize_queries']; + $optimize = Config::getInstance()->General['enable_sql_optimize_queries']; if (empty($optimize)) { return; } diff --git a/core/PluginsManager.php b/core/PluginsManager.php index db32db0e65..eaff33e2c7 100644 --- a/core/PluginsManager.php +++ b/core/PluginsManager.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @see core/Menu/Abstract.php @@ -85,9 +86,9 @@ class Piwik_PluginsManager */ private function updatePluginsConfig($plugins) { - $section = Piwik_Config::getInstance()->Plugins; + $section = Config::getInstance()->Plugins; $section['Plugins'] = $plugins; - Piwik_Config::getInstance()->Plugins = $section; + Config::getInstance()->Plugins = $section; } /** @@ -97,9 +98,9 @@ class Piwik_PluginsManager */ private function updatePluginsTrackerConfig($plugins) { - $section = Piwik_Config::getInstance()->Plugins_Tracker; + $section = Config::getInstance()->Plugins_Tracker; $section['Plugins_Tracker'] = $plugins; - Piwik_Config::getInstance()->Plugins_Tracker = $section; + Config::getInstance()->Plugins_Tracker = $section; } /** @@ -109,9 +110,9 @@ class Piwik_PluginsManager */ private function updatePluginsInstalledConfig($plugins) { - $section = Piwik_Config::getInstance()->PluginsInstalled; + $section = Config::getInstance()->PluginsInstalled; $section['PluginsInstalled'] = $plugins; - Piwik_Config::getInstance()->PluginsInstalled = $section; + Config::getInstance()->PluginsInstalled = $section; } /** @@ -134,7 +135,7 @@ class Piwik_PluginsManager public function isPluginUninstallable($name) { // Reading the plugins from the global.ini.php config file - $pluginsBundledWithPiwik = Piwik_Config::getInstance()->getFromDefaultConfig('Plugins'); + $pluginsBundledWithPiwik = Config::getInstance()->getFromDefaultConfig('Plugins'); $pluginsBundledWithPiwik = $pluginsBundledWithPiwik['Plugins']; return !in_array($name, $pluginsBundledWithPiwik); @@ -236,7 +237,7 @@ class Piwik_PluginsManager } $this->updatePluginsConfig($plugins); - $pluginsTracker = Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; + $pluginsTracker = Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; if (!is_null($pluginsTracker)) { $key = array_search($pluginName, $pluginsTracker); if ($key !== false) { @@ -245,7 +246,7 @@ class Piwik_PluginsManager } } - Piwik_Config::getInstance()->forceSave(); + Config::getInstance()->forceSave(); Piwik::deleteAllCacheOnUpdate(); return $plugins; @@ -273,7 +274,7 @@ class Piwik_PluginsManager */ public function activatePlugin($pluginName) { - $plugins = Piwik_Config::getInstance()->Plugins['Plugins']; + $plugins = Config::getInstance()->Plugins['Plugins']; if (in_array($pluginName, $plugins)) { throw new Exception("Plugin '$pluginName' already activated."); } @@ -308,7 +309,7 @@ class Piwik_PluginsManager // the config file will automatically be saved with the new plugin $this->updatePluginsConfig($plugins); - Piwik_Config::getInstance()->forceSave(); + Config::getInstance()->forceSave(); Piwik::deleteAllCacheOnUpdate(); } @@ -628,7 +629,7 @@ class Piwik_PluginsManager */ public function getInstalledPluginsName() { - $pluginNames = Piwik_Config::getInstance()->PluginsInstalled['PluginsInstalled']; + $pluginNames = Config::getInstance()->PluginsInstalled['PluginsInstalled']; return $pluginNames; } @@ -641,8 +642,8 @@ class Piwik_PluginsManager public function getMissingPlugins() { $missingPlugins = array(); - if (isset(Piwik_Config::getInstance()->Plugins['Plugins'])) { - $plugins = Piwik_Config::getInstance()->Plugins['Plugins']; + if (isset(Config::getInstance()->Plugins['Plugins'])) { + $plugins = Config::getInstance()->Plugins['Plugins']; foreach ($plugins as $pluginName) { // if a plugin is listed in the config, but is not loaded, it does not exist in the folder if (!Piwik_PluginsManager::getInstance()->isPluginLoaded($pluginName)) { @@ -674,7 +675,7 @@ class Piwik_PluginsManager } if ($this->isTrackerPlugin($plugin)) { - $pluginsTracker = Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; + $pluginsTracker = Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; if (is_null($pluginsTracker)) { $pluginsTracker = array(); } @@ -686,7 +687,7 @@ class Piwik_PluginsManager } if ($saveConfig) { - Piwik_Config::getInstance()->forceSave(); + Config::getInstance()->forceSave(); } } diff --git a/core/Session.php b/core/Session.php index e102ef605e..a534a4aa50 100644 --- a/core/Session.php +++ b/core/Session.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Session initialization. @@ -26,7 +27,7 @@ class Piwik_Session extends Zend_Session */ public static function isFileBasedSessions() { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); return !isset($config->General['session_save_handler']) || $config->General['session_save_handler'] === 'files'; } @@ -70,7 +71,7 @@ class Piwik_Session extends Zend_Session @ini_set('session.referer_check', ''); $currentSaveHandler = ini_get('session.save_handler'); - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); if (self::isFileBasedSessions()) { // Note: this handler doesn't work well in load-balanced environments and may have a concurrency issue with locked session files diff --git a/core/Tracker.php b/core/Tracker.php index c499872e4c..3de00cdd32 100644 --- a/core/Tracker.php +++ b/core/Tracker.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Class used by the logging script piwik.php called by the javascript tag. @@ -136,9 +137,9 @@ class Piwik_Tracker */ static private function updateTrackerConfig($name, $value) { - $section = Piwik_Config::getInstance()->Tracker; + $section = Config::getInstance()->Tracker; $section[$name] = $value; - Piwik_Config::getInstance()->Tracker = $section; + Config::getInstance()->Tracker = $section; } protected function initRequests($args) @@ -278,7 +279,7 @@ class Piwik_Tracker // Currently, there is no hourly tasks. When there are some, // this could be too agressive minimum interval (some hours would be skipped in case of low traffic) - $minimumInterval = Piwik_Config::getInstance()->Tracker['scheduled_tasks_min_interval']; + $minimumInterval = Config::getInstance()->Tracker['scheduled_tasks_min_interval']; // If the user disabled browser archiving, he has already setup a cron // To avoid parallel requests triggering the Scheduled Tasks, @@ -340,7 +341,7 @@ class Piwik_Tracker require_once PIWIK_INCLUDE_PATH . '/core/Option.php'; $access = Piwik_Access::getInstance(); - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); try { $db = Zend_Registry::get('db'); @@ -349,7 +350,7 @@ class Piwik_Tracker } $pluginsManager = Piwik_PluginsManager::getInstance(); - $pluginsToLoad = Piwik_Config::getInstance()->Plugins['Plugins']; + $pluginsToLoad = Config::getInstance()->Plugins['Plugins']; $pluginsForcedNotToLoad = Piwik_Tracker::getPluginsNotToLoad(); $pluginsToLoad = array_diff($pluginsToLoad, $pluginsForcedNotToLoad); $pluginsToLoad = array_merge($pluginsToLoad, Piwik_Tracker::getPluginsToLoad()); @@ -477,7 +478,7 @@ class Piwik_Tracker public static function connectPiwikTrackerDb() { $db = null; - $configDb = Piwik_Config::getInstance()->database; + $configDb = Config::getInstance()->database; if (!isset($configDb['port'])) { // before 0.2.4 there is no port specified in config file @@ -596,7 +597,7 @@ class Piwik_Tracker } try { - $pluginsTracker = Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; + $pluginsTracker = Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; if (count($pluginsTracker) > 0) { $pluginsTracker = array_diff($pluginsTracker, self::getPluginsNotToLoad()); Piwik_PluginsManager::getInstance()->doNotLoadAlwaysActivatedPlugins(); @@ -623,7 +624,7 @@ class Piwik_Tracker protected function handleDisabledTracker() { - $saveStats = Piwik_Config::getInstance()->Tracker['record_statistics']; + $saveStats = Config::getInstance()->Tracker['record_statistics']; if ($saveStats == 0) { $this->setState(self::STATE_LOGGING_DISABLE); } @@ -700,9 +701,9 @@ class Piwik_Tracker if (Piwik_Common::getRequestVar('forceIpAnonymization', false, null, $args) == 1) { self::updateTrackerConfig('ip_address_mask_length', 2); - $section = Piwik_Config::getInstance()->Plugins_Tracker; + $section = Config::getInstance()->Plugins_Tracker; $section['Plugins_Tracker'][] = "AnonymizeIP"; - Piwik_Config::getInstance()->Plugins_Tracker = $section; + Config::getInstance()->Plugins_Tracker = $section; $forceIpAnonymization = true; } diff --git a/core/Tracker/Action.php b/core/Tracker/Action.php index f4b3bb3288..5da8309682 100644 --- a/core/Tracker/Action.php +++ b/core/Tracker/Action.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Interface of the Action object. @@ -616,7 +617,7 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface $urlType = Piwik_Tracker_Action::TYPE_ACTION_URL; // By default, Site Search does not record the URL for the Search Result page, to slightly improve performance - if (empty(Piwik_Config::getInstance()->Tracker['action_sitesearch_record_url'])) { + if (empty(Config::getInstance()->Tracker['action_sitesearch_record_url'])) { $url = false; } } @@ -784,9 +785,9 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface $url = $this->request->getParam('url'); // get the delimiter, by default '/'; BC, we read the old action_category_delimiter first (see #1067) - $actionCategoryDelimiter = isset(Piwik_Config::getInstance()->General['action_category_delimiter']) - ? Piwik_Config::getInstance()->General['action_category_delimiter'] - : Piwik_Config::getInstance()->General['action_url_category_delimiter']; + $actionCategoryDelimiter = isset(Config::getInstance()->General['action_category_delimiter']) + ? Config::getInstance()->General['action_category_delimiter'] + : Config::getInstance()->General['action_url_category_delimiter']; // create an array of the categories delimited by the delimiter $split = explode($actionCategoryDelimiter, $actionName); @@ -835,7 +836,7 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface return false; } $actionName = $url = $categoryName = $count = false; - $doTrackUrlForSiteSearch = !empty(Piwik_Config::getInstance()->Tracker['action_sitesearch_record_url']); + $doTrackUrlForSiteSearch = !empty(Config::getInstance()->Tracker['action_sitesearch_record_url']); $originalUrl = self::cleanupUrl($originalUrl); @@ -1005,7 +1006,7 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface $string = trim($string); $string = str_replace(array("\n", "\r", "\0"), '', $string); - $limit = Piwik_Config::getInstance()->Tracker['page_maximum_length']; + $limit = Config::getInstance()->Tracker['page_maximum_length']; return substr($string, 0, $limit); } diff --git a/core/Tracker/Cache.php b/core/Tracker/Cache.php index f529b1d874..5fd14f936f 100644 --- a/core/Tracker/Cache.php +++ b/core/Tracker/Cache.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Simple cache mechanism used in Tracker to avoid requesting settings from mysql on every request @@ -26,7 +27,7 @@ class Piwik_Tracker_Cache static protected function getInstance() { if (is_null(self::$trackerCache)) { - $ttl = Piwik_Config::getInstance()->Tracker['tracker_cache_file_ttl']; + $ttl = Config::getInstance()->Tracker['tracker_cache_file_ttl']; self::$trackerCache = new Piwik_CacheFile('tracker', $ttl); } return self::$trackerCache; diff --git a/core/Tracker/Config.php b/core/Tracker/Config.php index ed9bb9fb2c..1ce66aaa55 100644 --- a/core/Tracker/Config.php +++ b/core/Tracker/Config.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Backward compatibility layer @@ -28,10 +29,10 @@ class Piwik_Tracker_Config /** * Returns the singleton Piwik_Config * - * @return Piwik_Config + * @return Config */ static public function getInstance() { - return Piwik_Config::getInstance(); + return Config::getInstance(); } } diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php index 5ed89c14b3..4a33837ac4 100644 --- a/core/Tracker/GoalManager.php +++ b/core/Tracker/GoalManager.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @package Piwik @@ -228,7 +229,7 @@ class Piwik_Tracker_GoalManager ? $visitorInformation['location_country'] : Piwik_Common::getCountry( $browserLanguage, - $enableLanguageToCountryGuess = Piwik_Config::getInstance()->Tracker['enable_language_to_country_guess'], + $enableLanguageToCountryGuess = Config::getInstance()->Tracker['enable_language_to_country_guess'], $visitorInformation['location_ip'] ); diff --git a/core/Tracker/IgnoreCookie.php b/core/Tracker/IgnoreCookie.php index 3819fa1e15..7fd2cc9fb3 100644 --- a/core/Tracker/IgnoreCookie.php +++ b/core/Tracker/IgnoreCookie.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Tracking cookies. @@ -24,8 +25,8 @@ class Piwik_Tracker_IgnoreCookie */ static public function getTrackingCookie() { - $cookie_name = @Piwik_Config::getInstance()->Tracker['cookie_name']; - $cookie_path = @Piwik_Config::getInstance()->Tracker['cookie_path']; + $cookie_name = @Config::getInstance()->Tracker['cookie_name']; + $cookie_path = @Config::getInstance()->Tracker['cookie_path']; return new Piwik_Cookie($cookie_name, null, $cookie_path); } @@ -37,8 +38,8 @@ class Piwik_Tracker_IgnoreCookie */ static public function getIgnoreCookie() { - $cookie_name = @Piwik_Config::getInstance()->Tracker['ignore_visits_cookie_name']; - $cookie_path = @Piwik_Config::getInstance()->Tracker['cookie_path']; + $cookie_name = @Config::getInstance()->Tracker['ignore_visits_cookie_name']; + $cookie_path = @Config::getInstance()->Tracker['cookie_path']; return new Piwik_Cookie($cookie_name, null, $cookie_path); } diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php index 486808e3ae..f1a6757806 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -54,7 +56,7 @@ class Piwik_Tracker_Request */ protected function authenticateTrackingApi($tokenAuthFromBulkRequest) { - $shouldAuthenticate = Piwik_Config::getInstance()->Tracker['tracking_requests_require_authentication']; + $shouldAuthenticate = Config::getInstance()->Tracker['tracking_requests_require_authentication']; if ($shouldAuthenticate) { $tokenAuth = $tokenAuthFromBulkRequest || Piwik_Common::getRequestVar('token_auth', false, 'string', $this->params); try { @@ -78,8 +80,8 @@ class Piwik_Tracker_Request if (!$tokenAuth) { return false; } - $superUserLogin = Piwik_Config::getInstance()->superuser['login']; - $superUserPassword = Piwik_Config::getInstance()->superuser['password']; + $superUserLogin = Config::getInstance()->superuser['login']; + $superUserPassword = Config::getInstance()->superuser['password']; if (md5($superUserLogin . $superUserPassword) == $tokenAuth) { return true; } @@ -318,7 +320,7 @@ class Piwik_Tracker_Request protected function shouldUseThirdPartyCookie() { - return (bool)Piwik_Config::getInstance()->Tracker['use_third_party_id_cookie']; + return (bool)Config::getInstance()->Tracker['use_third_party_id_cookie']; } /** @@ -349,17 +351,17 @@ class Piwik_Tracker_Request protected function getCookieName() { - return Piwik_Config::getInstance()->Tracker['cookie_name']; + return Config::getInstance()->Tracker['cookie_name']; } protected function getCookieExpire() { - return $this->getCurrentTimestamp() + Piwik_Config::getInstance()->Tracker['cookie_expire']; + return $this->getCurrentTimestamp() + Config::getInstance()->Tracker['cookie_expire']; } protected function getCookiePath() { - return Piwik_Config::getInstance()->Tracker['cookie_path']; + return Config::getInstance()->Tracker['cookie_path']; } /** diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index 3058656d51..27457ad860 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @package Piwik @@ -351,7 +352,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface { $timeSpent = $this->request->getCurrentTimestamp() - $this->visitorInfo['visit_last_action_time']; if ($timeSpent < 0 - || $timeSpent > Piwik_Config::getInstance()->Tracker['visit_standard_length'] + || $timeSpent > Config::getInstance()->Tracker['visit_standard_length'] ) { $timeSpent = 0; } @@ -398,7 +399,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface : ($visitCount > 1 || $this->isVisitorKnown() || $daysSinceLastVisit > 0 ? 1 /* Returning */ : 0 /* New */); - $defaultTimeOnePageVisit = Piwik_Config::getInstance()->Tracker['default_time_one_page_visit']; + $defaultTimeOnePageVisit = Config::getInstance()->Tracker['default_time_one_page_visit']; /** * Save the visitor @@ -762,8 +763,8 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface $isNewVisitForced = !empty($isNewVisitForced); $newVisitEnforcedAPI = $isNewVisitForced && ($this->request->isAuthenticated() - || !Piwik_Config::getInstance()->Tracker['new_visit_api_requires_admin']); - $enforceNewVisit = $newVisitEnforcedAPI || Piwik_Config::getInstance()->Debug['tracker_always_new_visitor']; + || !Config::getInstance()->Tracker['new_visit_api_requires_admin']); + $enforceNewVisit = $newVisitEnforcedAPI || Config::getInstance()->Debug['tracker_always_new_visitor']; if (!$enforceNewVisit && $visitRow @@ -836,8 +837,8 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface */ protected function getWindowLookupThisVisit() { - $visitStandardLength = Piwik_Config::getInstance()->Tracker['visit_standard_length']; - $lookBackNSecondsCustom = Piwik_Config::getInstance()->Tracker['window_look_back_for_visitor']; + $visitStandardLength = Config::getInstance()->Tracker['visit_standard_length']; + $lookBackNSecondsCustom = Config::getInstance()->Tracker['window_look_back_for_visitor']; $lookAheadNSeconds = $visitStandardLength; $lookBackNSeconds = $visitStandardLength; @@ -856,7 +857,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface { // This setting would be enabled for Intranet websites, to ensure that visitors using all the same computer config, same IP // are not counted as 1 visitor. In this case, we want to enforce and trust the visitor ID from the cookie. - $trustCookiesOnly = Piwik_Config::getInstance()->Tracker['trust_visitors_cookies']; + $trustCookiesOnly = Config::getInstance()->Tracker['trust_visitors_cookies']; // If a &cid= was set, we force to select this visitor (or create a new one) $isForcedVisitorIdMustMatch = ($this->request->getForcedVisitorId() != null); @@ -942,7 +943,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface { return isset($this->visitorInfo['visit_last_action_time']) && ($this->visitorInfo['visit_last_action_time'] - > ($this->request->getCurrentTimestamp() - Piwik_Config::getInstance()->Tracker['visit_standard_length'])); + > ($this->request->getCurrentTimestamp() - Config::getInstance()->Tracker['visit_standard_length'])); } /** diff --git a/core/Translate.php b/core/Translate.php index 177cb64ca7..95e6b9551f 100644 --- a/core/Translate.php +++ b/core/Translate.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * @package Piwik @@ -119,7 +120,7 @@ class Piwik_Translate public function getLanguageDefault() { - return Piwik_Config::getInstance()->General['default_language']; + return Config::getInstance()->General['default_language']; } /** diff --git a/core/UpdateCheck.php b/core/UpdateCheck.php index 84e4e11df4..7e94922f32 100644 --- a/core/UpdateCheck.php +++ b/core/UpdateCheck.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Class to check if a newer version of Piwik is available @@ -49,12 +50,12 @@ class Piwik_UpdateCheck 'timezone' => Piwik_SitesManager_API::getInstance()->getDefaultTimezone(), ); - $url = Piwik_Config::getInstance()->General['api_service_url'] + $url = Config::getInstance()->General['api_service_url'] . '/1.0/getLatestVersion/' . '?' . http_build_query($parameters, '', '&'); $timeout = self::SOCKET_TIMEOUT; - if (@Piwik_Config::getInstance()->Debug['allow_upgrades_to_beta']) { + if (@Config::getInstance()->Debug['allow_upgrades_to_beta']) { $url = 'http://builds.piwik.org/LATEST_BETA'; } diff --git a/core/Updates.php b/core/Updates.php index b9409de5ea..16e5f0d7e9 100644 --- a/core/Updates.php +++ b/core/Updates.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Abstract class for update scripts @@ -53,7 +54,7 @@ abstract class Piwik_Updates */ static function enableMaintenanceMode() { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $config->init(); $tracker = $config->Tracker; @@ -72,7 +73,7 @@ abstract class Piwik_Updates */ static function disableMaintenanceMode() { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $config->init(); $tracker = $config->Tracker; @@ -89,7 +90,7 @@ abstract class Piwik_Updates public static function deletePluginFromConfigFile($pluginToDelete) { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $config->init(); if (isset($config->Plugins['Plugins'])) { $plugins = $config->Plugins['Plugins']; diff --git a/core/Updates/0.5.4.php b/core/Updates/0.5.4.php index 733fccfd3d..45e69d1c18 100644 --- a/core/Updates/0.5.4.php +++ b/core/Updates/0.5.4.php @@ -8,6 +8,7 @@ * @category Piwik * @package Updates */ +use Piwik\Core\Config; /** * @package Updates @@ -25,11 +26,11 @@ class Piwik_Updates_0_5_4 extends Piwik_Updates static function update() { $salt = Piwik_Common::generateUniqId(); - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $superuser = $config->superuser; if (!isset($superuser['salt'])) { try { - if (is_writable(Piwik_Config::getLocalConfigPath())) { + if (is_writable(Config::getLocalConfigPath())) { $superuser['salt'] = $salt; $config->superuser = $superuser; $config->forceSave(); @@ -44,7 +45,7 @@ class Piwik_Updates_0_5_4 extends Piwik_Updates $plugins = $config->Plugins; if (!in_array('MultiSites', $plugins)) { try { - if (is_writable(Piwik_Config::getLocalConfigPath())) { + if (is_writable(Config::getLocalConfigPath())) { $plugins[] = 'MultiSites'; $config->Plugins = $plugins; $config->forceSave(); diff --git a/core/Updates/0.6.3.php b/core/Updates/0.6.3.php index 21bb715b44..0cb43f125f 100644 --- a/core/Updates/0.6.3.php +++ b/core/Updates/0.6.3.php @@ -8,6 +8,7 @@ * @category Piwik * @package Updates */ +use Piwik\Core\Config; /** * @package Updates @@ -26,11 +27,11 @@ class Piwik_Updates_0_6_3 extends Piwik_Updates static function update() { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $dbInfos = $config->database; if (!isset($dbInfos['schema'])) { try { - if (is_writable(Piwik_Config::getLocalConfigPath())) { + if (is_writable(Config::getLocalConfigPath())) { $dbInfos['schema'] = 'Myisam'; $config->database = $dbInfos; $config->forceSave(); diff --git a/core/Updates/1.1.php b/core/Updates/1.1.php index a98e4dc2f8..eb740fd49b 100644 --- a/core/Updates/1.1.php +++ b/core/Updates/1.1.php @@ -8,6 +8,7 @@ * @category Piwik * @package Updates */ +use Piwik\Core\Config; /** * @package Updates @@ -16,7 +17,7 @@ class Piwik_Updates_1_1 extends Piwik_Updates { static function update($schema = 'Myisam') { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $rootLogin = $config->superuser['login']; try { diff --git a/core/Updates/1.2.3.php b/core/Updates/1.2.3.php index f4a1104e9f..177b85a092 100644 --- a/core/Updates/1.2.3.php +++ b/core/Updates/1.2.3.php @@ -8,6 +8,7 @@ * @category Piwik * @package Updates */ +use Piwik\Core\Config; /** * @package Updates @@ -18,7 +19,7 @@ class Piwik_Updates_1_2_3 extends Piwik_Updates { return array( // LOAD DATA INFILE uses the database's charset - 'ALTER DATABASE `' . Piwik_Config::getInstance()->database['dbname'] . '` DEFAULT CHARACTER SET utf8' => false, + 'ALTER DATABASE `' . Config::getInstance()->database['dbname'] . '` DEFAULT CHARACTER SET utf8' => false, // Various performance improvements schema updates 'ALTER TABLE `' . Piwik_Common::prefixTable('log_visit') . '` diff --git a/core/Url.php b/core/Url.php index 50d7f32cd0..7ae6b3f50b 100644 --- a/core/Url.php +++ b/core/Url.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Class to retrieve absolute URL or URI components of the current URL, @@ -143,7 +144,7 @@ class Piwik_Url static public function getCurrentScheme() { try { - $assume_secure_protocol = @Piwik_Config::getInstance()->General['assume_secure_protocol']; + $assume_secure_protocol = @Config::getInstance()->General['assume_secure_protocol']; } catch (Exception $e) { $assume_secure_protocol = false; } @@ -168,8 +169,8 @@ class Piwik_Url static public function isValidHost($host = false) { // only do trusted host check if it's enabled - if (isset(Piwik_Config::getInstance()->General['enable_trusted_host_check']) - && Piwik_Config::getInstance()->General['enable_trusted_host_check'] == 0 + if (isset(Config::getInstance()->General['enable_trusted_host_check']) + && Config::getInstance()->General['enable_trusted_host_check'] == 0 ) { return true; } @@ -186,7 +187,7 @@ class Piwik_Url return true; } - $trustedHosts = @Piwik_Config::getInstance()->General['trusted_hosts']; + $trustedHosts = @Config::getInstance()->General['trusted_hosts']; // if no trusted hosts, just assume it's valid if (empty($trustedHosts)) { self::saveTrustedHostnameInConfig($host); @@ -220,9 +221,9 @@ class Piwik_Url public static function saveTrustedHostnameInConfig($host) { if (Piwik::isUserIsSuperUser() - && file_exists(Piwik_Config::getLocalConfigPath()) + && file_exists(Config::getLocalConfigPath()) ) { - $general = Piwik_Config::getInstance()->General; + $general = Config::getInstance()->General; if (!is_array($host)) { $host = array($host); } @@ -231,8 +232,8 @@ class Piwik_Url return false; } $general['trusted_hosts'] = $host; - Piwik_Config::getInstance()->General = $general; - Piwik_Config::getInstance()->forceSave(); + Config::getInstance()->General = $general; + Config::getInstance()->forceSave(); return true; } return false; @@ -275,7 +276,7 @@ class Piwik_Url */ static public function getCurrentHost($default = 'unknown', $checkTrustedHost = true) { - $hostHeaders = @Piwik_Config::getInstance()->General['proxy_host_headers']; + $hostHeaders = @Config::getInstance()->General['proxy_host_headers']; if (!is_array($hostHeaders)) { $hostHeaders = array(); } @@ -434,7 +435,7 @@ class Piwik_Url // drop port numbers from hostnames and IP addresses $hosts = array_map(array('Piwik_IP', 'sanitizeIp'), $hosts); - $disableHostCheck = Piwik_Config::getInstance()->General['enable_trusted_host_check'] == 0; + $disableHostCheck = Config::getInstance()->General['enable_trusted_host_check'] == 0; // compare scheme and host $parsedUrl = @parse_url($url); $host = Piwik_IP::sanitizeIp(@$parsedUrl['host']); diff --git a/core/View.php b/core/View.php index 183b9601a7..682a0c01dd 100644 --- a/core/View.php +++ b/core/View.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Transition for pre-Piwik 0.4.4 @@ -103,7 +104,7 @@ class Piwik_View implements Piwik_View_Interface $this->latest_version_available = Piwik_UpdateCheck::isNewestVersionAvailable(); $this->disableLink = Piwik_Common::getRequestVar('disableLink', 0, 'int'); $this->isWidget = Piwik_Common::getRequestVar('widget', 0, 'int'); - if (Piwik_Config::getInstance()->General['autocomplete_min_sites'] <= count($sites)) { + if (Config::getInstance()->General['autocomplete_min_sites'] <= count($sites)) { $this->show_autocompleter = true; } else { $this->show_autocompleter = false; diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php index d689a9f6ea..30116ad872 100644 --- a/core/ViewDataTable.php +++ b/core/ViewDataTable.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * This class is used to load (from the API) and customize the output of a given DataTable. @@ -151,7 +152,7 @@ abstract class Piwik_ViewDataTable $this->viewProperties['show_limit_control'] = false; $this->viewProperties['show_footer'] = true; $this->viewProperties['show_related_reports'] = true; - $this->viewProperties['exportLimit'] = Piwik_Config::getInstance()->General['API_datatable_default_limit']; + $this->viewProperties['exportLimit'] = Config::getInstance()->General['API_datatable_default_limit']; $this->viewProperties['highlight_summary_row'] = false; $this->viewProperties['metadata'] = array(); $this->viewProperties['relatedReports'] = array(); diff --git a/core/ViewDataTable/HtmlTable.php b/core/ViewDataTable/HtmlTable.php index bd901cc100..5b47f7b5bc 100644 --- a/core/ViewDataTable/HtmlTable.php +++ b/core/ViewDataTable/HtmlTable.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ +use Piwik\Core\Config; /** * Outputs an AJAX Table for a given DataTable. @@ -36,7 +37,7 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable $this->viewProperties['disable_row_actions'] = false; $this->setSortedColumn('nb_visits', 'desc'); - $this->setLimit(Piwik_Config::getInstance()->General['datatable_default_limit']); + $this->setLimit(Config::getInstance()->General['datatable_default_limit']); $this->handleLowPopulation(); $this->setSubtableTemplate("@CoreHome/_dataTable.twig"); $this->viewProperties['datatable_js_type'] = 'dataTable'; diff --git a/misc/cron/archive.php b/misc/cron/archive.php index d8b9a96362..20b5c908c4 100644 --- a/misc/cron/archive.php +++ b/misc/cron/archive.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + $USAGE = " Usage: /path/to/cli/php \"" . @$_SERVER['argv'][0] . "\" --url=http://your-website.org/path/to/piwik/ [arguments] @@ -602,7 +604,7 @@ class Archiving private function initLog() { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $config->log['log_only_when_debug_parameter'] = 0; $config->log['logger_message'] = array("logger_message" => "screen"); Piwik::createLogObject(); @@ -770,8 +772,8 @@ class Archiving private function initTokenAuth() { - $login = Piwik_Config::getInstance()->superuser['login']; - $md5Password = Piwik_Config::getInstance()->superuser['password']; + $login = Config::getInstance()->superuser['login']; + $md5Password = Config::getInstance()->superuser['password']; $this->token_auth = md5($login . $md5Password); $this->login = $login; } @@ -797,7 +799,7 @@ class Archiving $piwikUrl .= '/'; } } - if (Piwik_Config::getInstance()->General['force_ssl'] == 1) { + if (Config::getInstance()->General['force_ssl'] == 1) { $piwikUrl = str_replace('http://', 'https://', $piwikUrl); } $this->piwikUrl = $piwikUrl . "index.php"; diff --git a/misc/others/geoipUpdateRows.php b/misc/others/geoipUpdateRows.php index 37c841947b..9d5a6454c2 100755 --- a/misc/others/geoipUpdateRows.php +++ b/misc/others/geoipUpdateRows.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + ini_set("memory_limit", "512M"); error_reporting(E_ALL | E_NOTICE); @@ -24,7 +26,7 @@ require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; $GLOBALS['PIWIK_TRACKER_DEBUG'] = false; define('PIWIK_ENABLE_DISPATCH', false); -Piwik_Config::getInstance()->log['logger_message'][] = 'screen'; +Config::getInstance()->log['logger_message'][] = 'screen'; Piwik_FrontController::getInstance()->init(); $query = "SELECT count(*) FROM " . Piwik_Common::prefixTable('log_visit'); diff --git a/misc/others/test_generateLotsVisitsWebsites.php b/misc/others/test_generateLotsVisitsWebsites.php index eeb5b22e5a..30ca703d68 100644 --- a/misc/others/test_generateLotsVisitsWebsites.php +++ b/misc/others/test_generateLotsVisitsWebsites.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__) . "/../..")); define('PIWIK_ENABLE_DISPATCH', false); define('PIWIK_ENABLE_ERROR_HANDLER', false); @@ -23,7 +25,7 @@ class Piwik_StressTests_CopyLogs { function init() { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $config->log['log_only_when_debug_parameter'] = 0; $config->log['logger_message'] = array("logger_message" => "screen"); Piwik::createLogObject(); diff --git a/plugins/API/API.php b/plugins/API/API.php index cbaa9b0ec0..c8b784fd39 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_API */ +use Piwik\Core\Config; /** * @package Piwik_API @@ -102,7 +103,7 @@ class Piwik_API_API */ public function getSettings() { - return Piwik_Config::getInstance()->APISettings; + return Config::getInstance()->APISettings; } /** @@ -301,7 +302,7 @@ class Piwik_API_API public function getLogoUrl($pathOnly = false) { $logo = 'plugins/Zeitgeist/images/logo.png'; - if (Piwik_Config::getInstance()->branding['use_custom_logo'] == 1 + if (Config::getInstance()->branding['use_custom_logo'] == 1 && file_exists(Piwik_Common::getPathToPiwikRoot() . '/misc/user/logo.png') ) { $logo = 'misc/user/logo.png'; @@ -321,7 +322,7 @@ class Piwik_API_API public function getHeaderLogoUrl($pathOnly = false) { $logo = 'plugins/Zeitgeist/images/logo-header.png'; - if (Piwik_Config::getInstance()->branding['use_custom_logo'] == 1 + if (Config::getInstance()->branding['use_custom_logo'] == 1 && file_exists(Piwik_Common::getPathToPiwikRoot() . '/misc/user/logo-header.png') ) { $logo = 'misc/user/logo-header.png'; @@ -342,7 +343,7 @@ class Piwik_API_API public function getSVGLogoUrl($pathOnly = false) { $logo = 'plugins/Zeitgeist/images/logo.svg'; - if (Piwik_Config::getInstance()->branding['use_custom_logo'] == 1 + if (Config::getInstance()->branding['use_custom_logo'] == 1 && file_exists(Piwik_Common::getPathToPiwikRoot() . '/misc/user/logo.svg') ) { $logo = 'misc/user/logo.svg'; @@ -360,10 +361,10 @@ class Piwik_API_API */ public function hasSVGLogo() { - if (Piwik_Config::getInstance()->branding['use_custom_logo'] == 0) { + if (Config::getInstance()->branding['use_custom_logo'] == 0) { /* We always have our application logo */ return true; - } else if (Piwik_Config::getInstance()->branding['use_custom_logo'] == 1 + } else if (Config::getInstance()->branding['use_custom_logo'] == 1 && file_exists(Piwik_Common::getPathToPiwikRoot() . '/misc/user/logo.svg') ) { return true; diff --git a/plugins/API/Controller.php b/plugins/API/Controller.php index 0ed49180a6..a586b43b1a 100644 --- a/plugins/API/Controller.php +++ b/plugins/API/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_API */ +use Piwik\Core\Config; /** * @@ -19,7 +20,7 @@ class Piwik_API_Controller extends Piwik_Controller { // when calling the API through http, we limit the number of returned results if (!isset($_GET['filter_limit'])) { - $_GET['filter_limit'] = Piwik_Config::getInstance()->General['API_datatable_default_limit']; + $_GET['filter_limit'] = Config::getInstance()->General['API_datatable_default_limit']; } $request = new Piwik_API_Request('token_auth=' . Piwik_Common::getRequestVar('token_auth', 'anonymous', 'string')); echo $request->process(); diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php index 61f9cc3a86..0fa1f4f0e2 100644 --- a/plugins/Actions/Archiver.php +++ b/plugins/Actions/Archiver.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_Actions */ +use Piwik\Core\Config; /** * Class encapsulating logic to process Day/Period Archiving for the Actions reports @@ -130,7 +131,7 @@ class Piwik_Actions_Archiver extends Piwik_PluginsArchiver */ private static function getRankingQueryLimit() { - $configGeneral = Piwik_Config::getInstance()->General; + $configGeneral = Config::getInstance()->General; $configLimit = $configGeneral['archiving_ranking_query_row_limit']; return $configLimit == 0 ? 0 : max( $configLimit, diff --git a/plugins/Actions/ArchivingHelper.php b/plugins/Actions/ArchivingHelper.php index 0f7744522c..37e9e99122 100644 --- a/plugins/Actions/ArchivingHelper.php +++ b/plugins/Actions/ArchivingHelper.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_Actions */ +use Piwik\Core\Config; /** * This static class provides: @@ -205,18 +206,18 @@ class Piwik_Actions_ArchivingHelper static public function reloadConfig() { // for BC, we read the old style delimiter first (see #1067)Row - $actionDelimiter = @Piwik_Config::getInstance()->General['action_category_delimiter']; + $actionDelimiter = @Config::getInstance()->General['action_category_delimiter']; if (empty($actionDelimiter)) { - self::$actionUrlCategoryDelimiter = Piwik_Config::getInstance()->General['action_url_category_delimiter']; - self::$actionTitleCategoryDelimiter = Piwik_Config::getInstance()->General['action_title_category_delimiter']; + self::$actionUrlCategoryDelimiter = Config::getInstance()->General['action_url_category_delimiter']; + self::$actionTitleCategoryDelimiter = Config::getInstance()->General['action_title_category_delimiter']; } else { self::$actionUrlCategoryDelimiter = self::$actionTitleCategoryDelimiter = $actionDelimiter; } - self::$defaultActionName = Piwik_Config::getInstance()->General['action_default_name']; + self::$defaultActionName = Config::getInstance()->General['action_default_name']; self::$columnToSortByBeforeTruncation = Piwik_Metrics::INDEX_NB_VISITS; - self::$maximumRowsInDataTableLevelZero = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_actions']; - self::$maximumRowsInSubDataTable = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_actions']; + self::$maximumRowsInDataTableLevelZero = Config::getInstance()->General['datatable_archiving_maximum_rows_actions']; + self::$maximumRowsInSubDataTable = Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_actions']; Piwik_DataTable::setMaximumDepthLevelAllowedAtLeast(self::getSubCategoryLevelLimit() + 1); } @@ -412,7 +413,7 @@ class Piwik_Actions_ArchivingHelper */ public static function getSubCategoryLevelLimit() { - return Piwik_Config::getInstance()->General['action_category_level_limit']; + return Config::getInstance()->General['action_category_level_limit']; } /** diff --git a/plugins/AnonymizeIP/AnonymizeIP.php b/plugins/AnonymizeIP/AnonymizeIP.php index 382faa329a..4e14459fd7 100644 --- a/plugins/AnonymizeIP/AnonymizeIP.php +++ b/plugins/AnonymizeIP/AnonymizeIP.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_AnonymizeIP */ +use Piwik\Core\Config; /** * Anonymize visitor IP addresses to comply with the privacy laws/guidelines in countries, such as Germany. @@ -65,6 +66,6 @@ class Piwik_AnonymizeIP extends Piwik_Plugin */ public function setVisitorIpAddress(&$ip) { - $ip = self::applyIPMask($ip, Piwik_Config::getInstance()->Tracker['ip_address_mask_length']); + $ip = self::applyIPMask($ip, Config::getInstance()->Tracker['ip_address_mask_length']); } } diff --git a/plugins/CoreAdminHome/API.php b/plugins/CoreAdminHome/API.php index a2e272ffb3..917b2f4e14 100644 --- a/plugins/CoreAdminHome/API.php +++ b/plugins/CoreAdminHome/API.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_CoreAdminHome */ +use Piwik\Core\Config; /** * @package Piwik_CoreAdminHome @@ -95,8 +96,8 @@ class Piwik_CoreAdminHome_API // If using the feature "Delete logs older than N days"... - $logsAreDeletedBeforeThisDate = Piwik_Config::getInstance()->Deletelogs['delete_logs_schedule_lowest_interval']; - $logsDeleteEnabled = Piwik_Config::getInstance()->Deletelogs['delete_logs_enable']; + $logsAreDeletedBeforeThisDate = Config::getInstance()->Deletelogs['delete_logs_schedule_lowest_interval']; + $logsDeleteEnabled = Config::getInstance()->Deletelogs['delete_logs_enable']; $minimumDateWithLogs = false; if ($logsDeleteEnabled && $logsAreDeletedBeforeThisDate diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php index 2a971d6cf9..11035cb3ad 100644 --- a/plugins/CoreAdminHome/Controller.php +++ b/plugins/CoreAdminHome/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_CoreAdminHome */ +use Piwik\Core\Config; /** * @@ -43,7 +44,7 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin $this->displayWarningIfConfigFileNotWritable($view); - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $debug = $config->Debug; $view->enableBetaReleaseCheck = $debug['allow_upgrades_to_beta']; @@ -92,7 +93,7 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin $mail['password'] = Piwik_Common::unsanitizeInputValue(Piwik_Common::getRequestVar('mailPassword', '')); $mail['encryption'] = Piwik_Common::getRequestVar('mailEncryption', ''); - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $config->mail = $mail; // update branding settings diff --git a/plugins/CorePluginsAdmin/Controller.php b/plugins/CorePluginsAdmin/Controller.php index d9e6f0fca9..a0b741c7ac 100644 --- a/plugins/CorePluginsAdmin/Controller.php +++ b/plugins/CorePluginsAdmin/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_CorePluginsAdmin */ +use Piwik\Core\Config; /** * @@ -50,7 +51,7 @@ class Piwik_CorePluginsAdmin_Controller extends Piwik_Controller_Admin $listPlugins = array_merge( Piwik_PluginsManager::getInstance()->readPluginsDirectory(), - Piwik_Config::getInstance()->Plugins['Plugins'] + Config::getInstance()->Plugins['Plugins'] ); $listPlugins = array_unique($listPlugins); foreach ($listPlugins as $pluginName) { diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php index f60e2041a8..59d9c846fb 100644 --- a/plugins/CoreUpdater/Controller.php +++ b/plugins/CoreUpdater/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_CoreUpdater */ +use Piwik\Core\Config; /** * @@ -25,10 +26,10 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller static protected function getLatestZipUrl($newVersion) { - if (@Piwik_Config::getInstance()->Debug['allow_upgrades_to_beta']) { + if (@Config::getInstance()->Debug['allow_upgrades_to_beta']) { return 'http://builds.piwik.org/piwik-' . $newVersion . '.zip'; } - return Piwik_Config::getInstance()->General['latest_version_url']; + return Config::getInstance()->General['latest_version_url']; } public function newVersionAvailable() @@ -277,7 +278,7 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller // handle case of existing database with no tables if (!Piwik::isInstalled()) { - $this->errorMessages[] = Piwik_Translate('CoreUpdater_EmptyDatabaseError', Piwik_Config::getInstance()->database['dbname']); + $this->errorMessages[] = Piwik_Translate('CoreUpdater_EmptyDatabaseError', Config::getInstance()->database['dbname']); $this->coreError = true; $currentVersion = 'N/A'; } else { diff --git a/plugins/CustomVariables/Archiver.php b/plugins/CustomVariables/Archiver.php index 8b2e0a516f..8d8d018d67 100644 --- a/plugins/CustomVariables/Archiver.php +++ b/plugins/CustomVariables/Archiver.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -25,8 +27,8 @@ class Piwik_CustomVariables_Archiver extends Piwik_PluginsArchiver function __construct($processor) { parent::__construct($processor); - $this->maximumRowsInDataTableLevelZero = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_custom_variables']; - $this->maximumRowsInSubDataTable = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_custom_variables']; + $this->maximumRowsInDataTableLevelZero = Config::getInstance()->General['datatable_archiving_maximum_rows_custom_variables']; + $this->maximumRowsInSubDataTable = Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_custom_variables']; } public function archiveDay() diff --git a/plugins/DBStats/MySQLMetadataProvider.php b/plugins/DBStats/MySQLMetadataProvider.php index f9405b02de..e114bf3eeb 100755 --- a/plugins/DBStats/MySQLMetadataProvider.php +++ b/plugins/DBStats/MySQLMetadataProvider.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_DBStats */ +use Piwik\Core\Config; /** * Utility class that provides general information about databases, including the size of @@ -41,7 +42,7 @@ class Piwik_DBStats_MySQLMetadataProvider public function getDBStatus() { if (function_exists('mysql_connect')) { - $configDb = Piwik_Config::getInstance()->database; + $configDb = Config::getInstance()->database; $link = mysql_connect($configDb['host'], $configDb['username'], $configDb['password']); $status = mysql_stat($link); mysql_close($link); diff --git a/plugins/DevicesDetection/DevicesDetection.php b/plugins/DevicesDetection/DevicesDetection.php index e86c5d9a98..85324d7cbd 100644 --- a/plugins/DevicesDetection/DevicesDetection.php +++ b/plugins/DevicesDetection/DevicesDetection.php @@ -9,6 +9,8 @@ * @category Piwik_Plugins * @package Piwik_DevicesDetection */ +use Piwik\Core\Config; + require_once PIWIK_INCLUDE_PATH . "/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php"; require_once PIWIK_INCLUDE_PATH . '/plugins/DevicesDetection/functions.php'; @@ -191,7 +193,7 @@ class Piwik_DevicesDetection extends Piwik_Plugin ADD `config_device_model` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_device_brand`"; Piwik_Exec($q1); // conditionaly add this column - if (@Piwik_Config::getInstance()->Debug['store_user_agent_in_visit']) { + if (@Config::getInstance()->Debug['store_user_agent_in_visit']) { $q2 = "ALTER TABLE `" . Piwik_Common::prefixTable("log_visit") . "` ADD `config_debug_ua` VARCHAR( 512 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_device_model`"; Piwik_Exec($q2); @@ -217,7 +219,7 @@ class Piwik_DevicesDetection extends Piwik_Plugin $deviceInfo['config_device_model'] = $UAParser->getModel(); $deviceInfo['config_device_brand'] = $UAParser->getBrand(); - if (@Piwik_Config::getInstance()->Debug['store_user_agent_in_visit']) { + if (@Config::getInstance()->Debug['store_user_agent_in_visit']) { $deviceInfo['config_debug_ua'] = $userAgent; } diff --git a/plugins/Feedback/Controller.php b/plugins/Feedback/Controller.php index 7a30d38302..e2b457a22d 100644 --- a/plugins/Feedback/Controller.php +++ b/plugins/Feedback/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_Feedback */ +use Piwik\Core\Config; /** * @@ -34,7 +35,7 @@ class Piwik_Feedback_Controller extends Piwik_Controller $nonce = Piwik_Common::getRequestVar('nonce', '', 'string'); $view = new Piwik_View('@Feedback/sendFeedback'); - $view->feedbackEmailAddress = Piwik_Config::getInstance()->General['feedback_email_address']; + $view->feedbackEmailAddress = Config::getInstance()->General['feedback_email_address']; try { $minimumBodyLength = 40; if (strlen($body) < $minimumBodyLength diff --git a/plugins/ImageGraph/ImageGraph.php b/plugins/ImageGraph/ImageGraph.php index 4dd048827d..0604942cde 100644 --- a/plugins/ImageGraph/ImageGraph.php +++ b/plugins/ImageGraph/ImageGraph.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -80,7 +82,7 @@ class Piwik_ImageGraph extends Piwik_Plugin $piwikSite = new Piwik_Site($idSite); if ($periodForSinglePeriodGraph == 'range') { - $periodForMultiplePeriodGraph = Piwik_Config::getInstance()->General['graphs_default_period_to_plot_when_period_range']; + $periodForMultiplePeriodGraph = Config::getInstance()->General['graphs_default_period_to_plot_when_period_range']; $dateForMultiplePeriodGraph = $dateForSinglePeriodGraph; } else { $periodForMultiplePeriodGraph = $periodForSinglePeriodGraph; diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php index 33760871fb..e0ada880c7 100644 --- a/plugins/Installation/Controller.php +++ b/plugins/Installation/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_Installation */ +use Piwik\Core\Config; /** * Installation controller @@ -76,7 +77,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin $this->getInstallationSteps(), __FUNCTION__ ); - $view->newInstall = !file_exists(Piwik_Config::getLocalConfigPath()); + $view->newInstall = !file_exists(Config::getLocalConfigPath()); $view->errorMessage = $message; $this->skipThisStep(__FUNCTION__); $view->showNextStep = $view->newInstall; @@ -316,7 +317,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin $this->session->superuser_infos = $superUserInfos; - $url = Piwik_Config::getInstance()->General['api_service_url']; + $url = Config::getInstance()->General['api_service_url']; $url .= '/1.0/subscribeNewsletter/'; $params = array( 'email' => $form->getSubmitValue('email'), @@ -449,7 +450,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin ); $this->skipThisStep(__FUNCTION__); - if (!file_exists(Piwik_Config::getLocalConfigPath())) { + if (!file_exists(Config::getLocalConfigPath())) { // $this->addTrustedHosts(); $this->writeConfigFileFromSession(); } @@ -505,7 +506,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin protected function createDbFromSessionInformation() { $dbInfos = $this->session->db_infos; - Piwik_Config::getInstance()->database = $dbInfos; + Config::getInstance()->database = $dbInfos; Piwik::createDatabaseObject($dbInfos); } @@ -520,7 +521,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin return; } - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); try { // expect exception since config.ini.php doesn't exist yet $config->init(); @@ -567,7 +568,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin } else if ($currentStep == 'finished' && $this->session->currentStepDone == 'finished') { // ok to refresh this page or use language selector } else { - if (file_exists(Piwik_Config::getLocalConfigPath())) { + if (file_exists(Config::getLocalConfigPath())) { $error = true; } @@ -669,7 +670,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin public static function getSystemInformation() { global $piwik_minimumPHPVersion; - $minimumMemoryLimit = Piwik_Config::getInstance()->General['minimum_memory_limit']; + $minimumMemoryLimit = Config::getInstance()->General['minimum_memory_limit']; $infos = array(); diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php index 2afe21d209..6ff458d4a7 100644 --- a/plugins/LanguagesManager/LanguagesManager.php +++ b/plugins/LanguagesManager/LanguagesManager.php @@ -9,6 +9,7 @@ * @package Piwik_LanguagesManager * */ +use Piwik\Core\Config; /** * @@ -172,7 +173,7 @@ class Piwik_LanguagesManager extends Piwik_Plugin */ static public function getLanguageForSession() { - $cookieName = Piwik_Config::getInstance()->General['language_cookie_name']; + $cookieName = Config::getInstance()->General['language_cookie_name']; $cookie = new Piwik_Cookie($cookieName); if ($cookie->isCookieFound()) { return $cookie->get('language'); @@ -192,7 +193,7 @@ class Piwik_LanguagesManager extends Piwik_Plugin return false; } - $cookieName = Piwik_Config::getInstance()->General['language_cookie_name']; + $cookieName = Config::getInstance()->General['language_cookie_name']; $cookie = new Piwik_Cookie($cookieName, 0); $cookie->set('language', $languageCode); $cookie->save(); diff --git a/plugins/Live/API.php b/plugins/Live/API.php index 074f1f7a05..23cbea6ce9 100644 --- a/plugins/Live/API.php +++ b/plugins/Live/API.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_Live */ +use Piwik\Core\Config; /** * @see plugins/Referers/functions.php @@ -159,7 +160,7 @@ class Piwik_Live_API */ private function getCleanedVisitorsFromDetails($visitorDetails, $idSite, $flat = false, $doNotFetchActions = false) { - $actionsLimit = (int)Piwik_Config::getInstance()->General['visitor_log_maximum_actions_per_visit']; + $actionsLimit = (int)Config::getInstance()->General['visitor_log_maximum_actions_per_visit']; $table = new Piwik_DataTable(); diff --git a/plugins/Live/Controller.php b/plugins/Live/Controller.php index 53e7083d61..7ecf378809 100644 --- a/plugins/Live/Controller.php +++ b/plugins/Live/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_Live */ +use Piwik\Core\Config; /** * @package Piwik_Live @@ -26,7 +27,7 @@ class Piwik_Live_Controller extends Piwik_Controller $view = new Piwik_View('@Live/index'); $view->idSite = $this->idSite; $view = $this->setCounters($view); - $view->liveRefreshAfterMs = (int)Piwik_Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000; + $view->liveRefreshAfterMs = (int)Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000; $view->visitors = $this->getLastVisitsStart($fetchPlease = true); $view->liveTokenAuth = Piwik::getCurrentUserTokenAuth(); return $this->render($view, $fetch); @@ -34,7 +35,7 @@ class Piwik_Live_Controller extends Piwik_Controller public function getSimpleLastVisitCount($fetch = false) { - $lastMinutes = Piwik_Config::getInstance()->General[self::SIMPLE_VISIT_COUNT_WIDGET_LAST_MINUTES_CONFIG_KEY]; + $lastMinutes = Config::getInstance()->General[self::SIMPLE_VISIT_COUNT_WIDGET_LAST_MINUTES_CONFIG_KEY]; $lastNData = Piwik_API_Request::processRequest('Live.getCounters', array('lastMinutes' => $lastMinutes)); @@ -43,7 +44,7 @@ class Piwik_Live_Controller extends Piwik_Controller $view->visitors = Piwik::getPrettyNumber($lastNData[0]['visitors']); $view->visits = Piwik::getPrettyNumber($lastNData[0]['visits']); $view->actions = Piwik::getPrettyNumber($lastNData[0]['actions']); - $view->refreshAfterXSecs = Piwik_Config::getInstance()->General['live_widget_refresh_after_seconds']; + $view->refreshAfterXSecs = Config::getInstance()->General['live_widget_refresh_after_seconds']; $view->translations = array( 'one_visitor' => Piwik_Translate('Live_NbVisitor'), 'visitors' => Piwik_Translate('Live_NbVisitors'), diff --git a/plugins/Login/Auth.php b/plugins/Login/Auth.php index a7a8a2e490..4bcfe24d06 100644 --- a/plugins/Login/Auth.php +++ b/plugins/Login/Auth.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_Login */ +use Piwik\Core\Config; /** * @@ -35,8 +36,8 @@ class Piwik_Login_Auth implements Piwik_Auth */ public function authenticate() { - $rootLogin = Piwik_Config::getInstance()->superuser['login']; - $rootPassword = Piwik_Config::getInstance()->superuser['password']; + $rootLogin = Config::getInstance()->superuser['login']; + $rootPassword = Config::getInstance()->superuser['password']; $rootToken = Piwik_UsersManager_API::getInstance()->getTokenAuth($rootLogin, $rootPassword); if (is_null($this->login)) { diff --git a/plugins/Login/Controller.php b/plugins/Login/Controller.php index dede4bee21..d5d988d648 100644 --- a/plugins/Login/Controller.php +++ b/plugins/Login/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_Login */ +use Piwik\Core\Config; /** * Login controller @@ -95,7 +96,7 @@ class Piwik_Login_Controller extends Piwik_Controller $view->linkTitle = Piwik::getRandomTitle(); - $view->forceSslLogin = Piwik_Config::getInstance()->General['force_ssl_login']; + $view->forceSslLogin = Config::getInstance()->General['force_ssl_login']; // crsf token: don't trust the submitted value; generate/fetch it from session data $view->nonce = Piwik_Nonce::getNonce('Piwik_Login.login'); @@ -117,7 +118,7 @@ class Piwik_Login_Controller extends Piwik_Controller } $login = Piwik_Common::getRequestVar('login', null, 'string'); - if ($login == Piwik_Config::getInstance()->superuser['login']) { + if ($login == Config::getInstance()->superuser['login']) { throw new Exception(Piwik_TranslateException('Login_ExceptionInvalidSuperUserAuthenticationMethod', array("logme"))); } @@ -273,8 +274,8 @@ class Piwik_Login_Controller extends Piwik_Controller ) . "\n"; $mail->setBodyText($bodyText); - $fromEmailName = Piwik_Config::getInstance()->General['login_password_recovery_email_name']; - $fromEmailAddress = Piwik_Config::getInstance()->General['login_password_recovery_email_address']; + $fromEmailName = Config::getInstance()->General['login_password_recovery_email_name']; + $fromEmailAddress = Config::getInstance()->General['login_password_recovery_email_address']; $mail->setFrom($fromEmailAddress, $fromEmailName); @$mail->send(); } @@ -334,13 +335,13 @@ class Piwik_Login_Controller extends Piwik_Controller } if ($user['email'] == Piwik::getSuperUserEmail()) { - if (!Piwik_Config::getInstance()->isFileWritable()) { + if (!Config::getInstance()->isFileWritable()) { throw new Exception(Piwik_Translate('General_ConfigFileIsNotWritable', array("(config/config.ini.php)", "<br/>"))); } $user['password'] = $passwordHash; - Piwik_Config::getInstance()->superuser = $user; - Piwik_Config::getInstance()->forceSave(); + Config::getInstance()->superuser = $user; + Config::getInstance()->forceSave(); } else { Piwik_UsersManager_API::getInstance()->updateUser( $user['login'], $passwordHash, $email = false, $alias = false, $isPasswordHashed = true); @@ -369,12 +370,12 @@ class Piwik_Login_Controller extends Piwik_Controller $user = null; if ($loginMail == Piwik::getSuperUserEmail() - || $loginMail == Piwik_Config::getInstance()->superuser['login'] + || $loginMail == Config::getInstance()->superuser['login'] ) { $user = array( - 'login' => Piwik_Config::getInstance()->superuser['login'], + 'login' => Config::getInstance()->superuser['login'], 'email' => Piwik::getSuperUserEmail(), - 'password' => Piwik_Config::getInstance()->superuser['password'], + 'password' => Config::getInstance()->superuser['password'], ); } else if (Piwik_UsersManager_API::getInstance()->userExists($loginMail)) { $user = Piwik_UsersManager_API::getInstance()->getUser($loginMail); @@ -441,7 +442,7 @@ class Piwik_Login_Controller extends Piwik_Controller */ static public function clearSession() { - $authCookieName = Piwik_Config::getInstance()->General['login_cookie_name']; + $authCookieName = Config::getInstance()->General['login_cookie_name']; $cookie = new Piwik_Cookie($authCookieName); $cookie->delete(); @@ -458,7 +459,7 @@ class Piwik_Login_Controller extends Piwik_Controller { self::clearSession(); - $logoutUrl = @Piwik_Config::getInstance()->General['login_logout_url']; + $logoutUrl = @Config::getInstance()->General['login_logout_url']; if (empty($logoutUrl)) { Piwik::redirectToModule('CoreHome'); } else { @@ -474,7 +475,7 @@ class Piwik_Login_Controller extends Piwik_Controller */ protected function checkForceSslLogin() { - $forceSslLogin = Piwik_Config::getInstance()->General['force_ssl_login']; + $forceSslLogin = Config::getInstance()->General['force_ssl_login']; if ($forceSslLogin && !Piwik::isHttps() ) { diff --git a/plugins/Login/Login.php b/plugins/Login/Login.php index 62336764f1..accc865eeb 100644 --- a/plugins/Login/Login.php +++ b/plugins/Login/Login.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_Login */ +use Piwik\Core\Config; /** * @@ -68,9 +69,9 @@ class Piwik_Login extends Piwik_Plugin return; } - $authCookieName = Piwik_Config::getInstance()->General['login_cookie_name']; + $authCookieName = Config::getInstance()->General['login_cookie_name']; $authCookieExpiry = 0; - $authCookiePath = Piwik_Config::getInstance()->General['login_cookie_path']; + $authCookiePath = Config::getInstance()->General['login_cookie_path']; $authCookie = new Piwik_Cookie($authCookieName, $authCookieExpiry, $authCookiePath); $defaultLogin = 'anonymous'; $defaultTokenAuth = 'anonymous'; @@ -101,9 +102,9 @@ class Piwik_Login extends Piwik_Plugin $auth->setTokenAuth($tokenAuth); $authResult = $auth->authenticate(); - $authCookieName = Piwik_Config::getInstance()->General['login_cookie_name']; - $authCookieExpiry = $rememberMe ? time() + Piwik_Config::getInstance()->General['login_cookie_expire'] : 0; - $authCookiePath = Piwik_Config::getInstance()->General['login_cookie_path']; + $authCookieName = Config::getInstance()->General['login_cookie_name']; + $authCookieExpiry = $rememberMe ? time() + Config::getInstance()->General['login_cookie_expire'] : 0; + $authCookiePath = Config::getInstance()->General['login_cookie_path']; $cookie = new Piwik_Cookie($authCookieName, $authCookieExpiry, $authCookiePath); if (!$authResult->isValid()) { $cookie->delete(); diff --git a/plugins/MultiSites/Controller.php b/plugins/MultiSites/Controller.php index 46bf83848f..ec31a095f9 100644 --- a/plugins/MultiSites/Controller.php +++ b/plugins/MultiSites/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_MultiSites */ +use Piwik\Core\Config; /** * @@ -27,7 +28,7 @@ class Piwik_MultiSites_Controller extends Piwik_Controller { parent::__construct(); - $this->limit = Piwik_Config::getInstance()->General['all_websites_website_per_page']; + $this->limit = Config::getInstance()->General['all_websites_website_per_page']; } function index() @@ -152,12 +153,12 @@ class Piwik_MultiSites_Controller extends Piwik_Controller Piwik_Date::factory('now', 'UTC+14')->toString('Y-m-d'))) ) { - $view->autoRefreshTodayReport = Piwik_Config::getInstance()->General['multisites_refresh_after_seconds']; + $view->autoRefreshTodayReport = Config::getInstance()->General['multisites_refresh_after_seconds']; } $this->setGeneralVariablesView($view); $this->setMinDateView($minDate, $view); $this->setMaxDateView($maxDate, $view); - $view->show_sparklines = Piwik_Config::getInstance()->General['show_multisites_sparklines']; + $view->show_sparklines = Config::getInstance()->General['show_multisites_sparklines']; echo $view->render(); } diff --git a/plugins/Overlay/API.php b/plugins/Overlay/API.php index 70f55adf6c..9ba98a900d 100644 --- a/plugins/Overlay/API.php +++ b/plugins/Overlay/API.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -80,7 +82,7 @@ class Piwik_Overlay_API $resultDataTable = new Piwik_DataTable; try { - $limitBeforeGrouping = Piwik_Config::getInstance()->General['overlay_following_pages_limit']; + $limitBeforeGrouping = Config::getInstance()->General['overlay_following_pages_limit']; $transitionsReport = Piwik_Transitions_API::getInstance()->getTransitionsForAction( $url, $type = 'url', $idSite, $period, $date, $segment, $limitBeforeGrouping, $part = 'followingActions', $returnNormalizedUrls = true); diff --git a/plugins/PDFReports/PDFReports.php b/plugins/PDFReports/PDFReports.php index eb07f07f0b..8b68d8c377 100644 --- a/plugins/PDFReports/PDFReports.php +++ b/plugins/PDFReports/PDFReports.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_PDFReports */ +use Piwik\Core\Config; /** * @@ -258,10 +259,10 @@ class Piwik_PDFReports extends Piwik_Plugin $mail = new Piwik_Mail(); $mail->setSubject($subject); - $fromEmailName = Piwik_Config::getInstance()->branding['use_custom_logo'] + $fromEmailName = Config::getInstance()->branding['use_custom_logo'] ? Piwik_Translate('CoreHome_WebAnalyticsReports') : Piwik_Translate('PDFReports_PiwikReports'); - $fromEmailAddress = Piwik_Config::getInstance()->General['noreply_email_address']; + $fromEmailAddress = Config::getInstance()->General['noreply_email_address']; $attachmentName = $subject; $mail->setFrom($fromEmailAddress, $fromEmailName); diff --git a/plugins/PrivacyManager/Controller.php b/plugins/PrivacyManager/Controller.php index 583fcd4afa..e9b62e1482 100644 --- a/plugins/PrivacyManager/Controller.php +++ b/plugins/PrivacyManager/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_PrivacyManager */ +use Piwik\Core\Config; /** * @@ -27,10 +28,10 @@ class Piwik_PrivacyManager_Controller extends Piwik_Controller_Admin switch (Piwik_Common::getRequestVar('form')) { case("formMaskLength"): $this->handlePluginState(Piwik_Common::getRequestVar("anonymizeIPEnable", 0)); - $trackerConfig = Piwik_Config::getInstance()->Tracker; + $trackerConfig = Config::getInstance()->Tracker; $trackerConfig['ip_address_mask_length'] = Piwik_Common::getRequestVar("maskLength", 1); - Piwik_Config::getInstance()->Tracker = $trackerConfig; - Piwik_Config::getInstance()->forceSave(); + Config::getInstance()->Tracker = $trackerConfig; + Config::getInstance()->forceSave(); break; case("formDeleteSettings"): @@ -115,7 +116,7 @@ class Piwik_PrivacyManager_Controller extends Piwik_Controller_Admin $view->anonymizeIP = $this->getAnonymizeIPInfo(); $view->dntSupport = self::isDntSupported(); $view->canDeleteLogActions = Piwik::isLockPrivilegeGranted(); - $view->dbUser = Piwik_Config::getInstance()->database['username']; + $view->dbUser = Config::getInstance()->database['username']; } $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser(); $this->displayWarningIfConfigFileNotWritable($view); @@ -160,7 +161,7 @@ class Piwik_PrivacyManager_Controller extends Piwik_Controller_Admin $settings = Piwik_PrivacyManager::getPurgeDataSettings(); } - $doDatabaseSizeEstimate = Piwik_Config::getInstance()->Deletelogs['enable_auto_database_size_estimate']; + $doDatabaseSizeEstimate = Config::getInstance()->Deletelogs['enable_auto_database_size_estimate']; // determine the DB size & purged DB size $metadataProvider = new Piwik_DBStats_MySQLMetadataProvider(); @@ -215,7 +216,7 @@ class Piwik_PrivacyManager_Controller extends Piwik_Controller_Admin $anonymizeIP["name"] = self::ANONYMIZE_IP_PLUGIN_NAME; $anonymizeIP["enabled"] = Piwik_PluginsManager::getInstance()->isPluginActivated(self::ANONYMIZE_IP_PLUGIN_NAME); - $anonymizeIP["maskLength"] = Piwik_Config::getInstance()->Tracker['ip_address_mask_length']; + $anonymizeIP["maskLength"] = Config::getInstance()->Tracker['ip_address_mask_length']; $anonymizeIP["info"] = Piwik_PluginsManager::getInstance()->getLoadedPlugin(self::ANONYMIZE_IP_PLUGIN_NAME)->getInformation(); return $anonymizeIP; diff --git a/plugins/PrivacyManager/PrivacyManager.php b/plugins/PrivacyManager/PrivacyManager.php index c3ec627713..5a2d6f2f93 100644 --- a/plugins/PrivacyManager/PrivacyManager.php +++ b/plugins/PrivacyManager/PrivacyManager.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_PrivacyManager */ +use Piwik\Core\Config; /** * @see plugins/PrivacyManager/LogDataPurger.php @@ -108,7 +109,7 @@ class Piwik_PrivacyManager extends Piwik_Plugin 'delete_logs_older_than', ); - $deleteLogsSettings = Piwik_Config::getInstance()->Deletelogs; + $deleteLogsSettings = Config::getInstance()->Deletelogs; foreach ($oldSettings as $settingName) { $settings[$settingName] = $deleteLogsSettings[$settingName]; } diff --git a/plugins/Referers/Archiver.php b/plugins/Referers/Archiver.php index 5d31a3d421..6c37226e26 100644 --- a/plugins/Referers/Archiver.php +++ b/plugins/Referers/Archiver.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -32,8 +34,8 @@ class Piwik_Referers_Archiver extends Piwik_PluginsArchiver { parent::__construct($processor); $this->columnToSortByBeforeTruncation = Piwik_Metrics::INDEX_NB_VISITS; - $this->maximumRowsInDataTableLevelZero = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_referers']; - $this->maximumRowsInSubDataTable = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_referers']; + $this->maximumRowsInDataTableLevelZero = Config::getInstance()->General['datatable_archiving_maximum_rows_referers']; + $this->maximumRowsInSubDataTable = Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_referers']; } public function archiveDay() diff --git a/plugins/UserCountry/LocationProvider/Default.php b/plugins/UserCountry/LocationProvider/Default.php index f19fc47641..b7467e71d3 100755 --- a/plugins/UserCountry/LocationProvider/Default.php +++ b/plugins/UserCountry/LocationProvider/Default.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_UserCountry */ +use Piwik\Core\Config; /** * The default LocationProvider, this LocationProvider guesses a visitor's country @@ -28,7 +29,7 @@ class Piwik_UserCountry_LocationProvider_Default extends Piwik_UserCountry_Locat */ public function getLocation($info) { - $enableLanguageToCountryGuess = Piwik_Config::getInstance()->Tracker['enable_language_to_country_guess']; + $enableLanguageToCountryGuess = Config::getInstance()->Tracker['enable_language_to_country_guess']; if (empty($info['lang'])) { $info['lang'] = Piwik_Common::getBrowserLanguage(); diff --git a/plugins/UserCountryMap/Controller.php b/plugins/UserCountryMap/Controller.php index 9a02b6ff9f..002d3145c2 100644 --- a/plugins/UserCountryMap/Controller.php +++ b/plugins/UserCountryMap/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_UserCountryMap */ +use Piwik\Core\Config; /** * @@ -109,7 +110,7 @@ class Piwik_UserCountryMap_Controller extends Piwik_Controller $view->metrics = $this->getMetrics($idSite, 'range', self::REAL_TIME_WINDOW, $token_auth); $view->defaultMetric = 'nb_visits'; - $view->liveRefreshAfterMs = (int)Piwik_Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000; + $view->liveRefreshAfterMs = (int)Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000; $goals = Piwik_Goals_API::getInstance()->getGoals($idSite); $site = new Piwik_Site($idSite); diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php index bfb273e1d1..32d47cf48d 100644 --- a/plugins/UsersManager/API.php +++ b/plugins/UsersManager/API.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_UsersManager */ +use Piwik\Core\Config; /** * The UsersManager API lets you Manage Users and their permissions to access specific websites. @@ -97,7 +98,7 @@ class Piwik_UsersManager_API $viewableSiteIds = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess($login); return reset($viewableSiteIds); case self::PREFERENCE_DEFAULT_REPORT_DATE: - return Piwik_Config::getInstance()->General['default_day']; + return Config::getInstance()->General['default_day']; default: return false; } @@ -498,7 +499,7 @@ class Piwik_UsersManager_API FROM " . Piwik_Common::prefixTable("user") . " WHERE email = ?", $userEmail); return $count != 0 - || Piwik_Config::getInstance()->superuser['email'] == $userEmail; + || Config::getInstance()->superuser['email'] == $userEmail; } /** diff --git a/plugins/UsersManager/Controller.php b/plugins/UsersManager/Controller.php index 661b625cf2..8f8c69f666 100644 --- a/plugins/UsersManager/Controller.php +++ b/plugins/UsersManager/Controller.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_UsersManager */ +use Piwik\Core\Config; /** * @@ -279,7 +280,7 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin $userLogin = Piwik::getCurrentUserLogin(); if (Piwik::isUserIsSuperUser()) { - $superUser = Piwik_Config::getInstance()->superuser; + $superUser = Config::getInstance()->superuser; $updatedSuperUser = false; if ($newPassword !== false) { @@ -293,8 +294,8 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin $updatedSuperUser = true; } if ($updatedSuperUser) { - Piwik_Config::getInstance()->superuser = $superUser; - Piwik_Config::getInstance()->forceSave(); + Config::getInstance()->superuser = $superUser; + Config::getInstance()->forceSave(); } } else { Piwik_UsersManager_API::getInstance()->updateUser($userLogin, $newPassword, $email, $alias); diff --git a/tests/LocalTracker.php b/tests/LocalTracker.php index 52d46b4c2b..7cdbab883e 100755 --- a/tests/LocalTracker.php +++ b/tests/LocalTracker.php @@ -1,5 +1,7 @@ <?php +use Piwik\Core\Config; + $GLOBALS['PIWIK_TRACKER_DEBUG'] = false; $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] = false; if (!defined('PIWIK_ENABLE_TRACKING')) { @@ -46,10 +48,10 @@ class Piwik_LocalTracker extends PiwikTracker Piwik_Tracker::setForceVisitorId(null); // save some values - $plugins = Piwik_Config::getInstance()->Plugins['Plugins']; + $plugins = Config::getInstance()->Plugins['Plugins']; $plugins[] = 'DevicesDetection'; - $pluginsTracker = Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; - $oldTrackerConfig = Piwik_Config::getInstance()->Tracker; + $pluginsTracker = Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; + $oldTrackerConfig = Config::getInstance()->Tracker; Piwik_PluginsManager::getInstance()->unloadPlugins(); @@ -82,8 +84,8 @@ class Piwik_LocalTracker extends PiwikTracker ob_end_clean(); // restore vars - Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker'] = $pluginsTracker; - Piwik_Config::getInstance()->Tracker = $oldTrackerConfig; + Config::getInstance()->Plugins_Tracker['Plugins_Tracker'] = $pluginsTracker; + Config::getInstance()->Tracker = $oldTrackerConfig; $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $oldLang; $_SERVER['HTTP_USER_AGENT'] = $oldUserAgent; $_COOKIE = $oldCookie; diff --git a/tests/PHPUnit/BaseFixture.php b/tests/PHPUnit/BaseFixture.php index edbc6de5a7..fae7717825 100644 --- a/tests/PHPUnit/BaseFixture.php +++ b/tests/PHPUnit/BaseFixture.php @@ -5,6 +5,7 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\Core\Config; /** * Base type for all integration test fixtures. Integration test fixtures @@ -176,8 +177,8 @@ abstract class Test_Piwik_BaseFixture extends PHPUnit_Framework_Assert public static function getTokenAuth() { return Piwik_UsersManager_API::getInstance()->getTokenAuth( - Piwik_Config::getInstance()->superuser['login'], - Piwik_Config::getInstance()->superuser['password'] + Config::getInstance()->superuser['login'], + Config::getInstance()->superuser['password'] ); } diff --git a/tests/PHPUnit/BenchmarkTestCase.php b/tests/PHPUnit/BenchmarkTestCase.php index 261e6fdbab..46f2400d75 100755 --- a/tests/PHPUnit/BenchmarkTestCase.php +++ b/tests/PHPUnit/BenchmarkTestCase.php @@ -5,6 +5,8 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\Core\Config; + require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/IntegrationTestCase.php'; require_once PIWIK_INCLUDE_PATH . '/tests/LocalTracker.php'; @@ -43,7 +45,7 @@ abstract class BenchmarkTestCase extends IntegrationTestCase $installedFixture = false; try { if (isset(self::$fixture->tablesPrefix)) { - Piwik_Config::getInstance()->database['tables_prefix'] = self::$fixture->tablesPrefix; + Config::getInstance()->database['tables_prefix'] = self::$fixture->tablesPrefix; Piwik_Common::$cachedTablePrefix = null; } diff --git a/tests/PHPUnit/Benchmarks/Fixtures/SqlDump.php b/tests/PHPUnit/Benchmarks/Fixtures/SqlDump.php index 08843aff65..f4c303430c 100755 --- a/tests/PHPUnit/Benchmarks/Fixtures/SqlDump.php +++ b/tests/PHPUnit/Benchmarks/Fixtures/SqlDump.php @@ -5,6 +5,7 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\Core\Config; /** * Reusable fixture. Loads a ~1GB SQL dump into the DB. @@ -50,10 +51,10 @@ class Piwik_Test_Fixture_SqlDump } // load the data into the correct database - $user = Piwik_Config::getInstance()->database['username']; - $password = Piwik_Config::getInstance()->database['password']; - $dbName = Piwik_Config::getInstance()->database['dbname']; - Piwik_Config::getInstance()->database['tables_prefix'] = 'piwik_'; + $user = Config::getInstance()->database['username']; + $password = Config::getInstance()->database['password']; + $dbName = Config::getInstance()->database['dbname']; + Config::getInstance()->database['tables_prefix'] = 'piwik_'; Piwik_Common::$cachedTablePrefix = null; exec("mysql -u \"$user\" \"--password=$password\" $dbName < \"" . $deflatedDumpPath . "\" 2>&1", $output, $return); diff --git a/tests/PHPUnit/Core/ArchiveProcessingTest.php b/tests/PHPUnit/Core/ArchiveProcessingTest.php index 9ae4db35a4..fbe5fccecc 100644 --- a/tests/PHPUnit/Core/ArchiveProcessingTest.php +++ b/tests/PHPUnit/Core/ArchiveProcessingTest.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -316,7 +318,7 @@ class ArchiveProcessingTest extends DatabaseTestCase && $skippedOnce === false // HACK: Only alert for MysqlI since PDO is often failing and Jenkins should always run MYSQLI + PDO // This helps "hiding" the warning on PDO Mysql but we have to make sure mysqli tests are always executed! - && Piwik_Config::getInstance()->database['adapter'] == 'MYSQLI' + && Config::getInstance()->database['adapter'] == 'MYSQLI' ) { $skippedOnce = true; $this->fail( diff --git a/tests/PHPUnit/Core/ConfigTest.php b/tests/PHPUnit/Core/ConfigTest.php index ddd2619b71..df6ef685a6 100644 --- a/tests/PHPUnit/Core/ConfigTest.php +++ b/tests/PHPUnit/Core/ConfigTest.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -16,7 +18,7 @@ class ConfigTest extends PHPUnit_Framework_TestCase $userFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/config.ini.php'; $globalFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/global.ini.php'; - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $config->setTestEnvironment($userFile, $globalFile); $config->init(); @@ -44,7 +46,7 @@ class ConfigTest extends PHPUnit_Framework_TestCase $userFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/config.written.ini.php'; $globalFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/global.ini.php'; - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $config->setTestEnvironment($userFile, $globalFile); $config->init(); @@ -53,7 +55,7 @@ class ConfigTest extends PHPUnit_Framework_TestCase $this->assertEquals($stringWritten, $config->Category['test']); unset($config); - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $config->setTestEnvironment($userFile, $globalFile); $config->init(); @@ -75,7 +77,7 @@ class ConfigTest extends PHPUnit_Framework_TestCase $userFile = PIWIK_PATH_TEST_TO_ROOT . '/tests/resources/Config/config.ini.php'; $globalFile = PIWIK_PATH_TEST_TO_ROOT . '/tests/resources/Config/global.ini.php'; - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $config->setTestEnvironment($userFile, $globalFile); $this->assertEquals("value_overwritten", $config->Category['key1']); @@ -92,7 +94,7 @@ class ConfigTest extends PHPUnit_Framework_TestCase $array = $config->TestArrayOnlyInGlobalFile; $this->assertEquals($expectedArray, $array['my_array']); - Piwik_Config::getInstance()->clear(); + Config::getInstance()->clear(); } /** @@ -137,7 +139,7 @@ class ConfigTest extends PHPUnit_Framework_TestCase { list($a, $b, $expected) = $test; - $result = Piwik_Config::compareElements($a, $b); + $result = Config::compareElements($a, $b); $this->assertEquals($expected, $result, $description); } @@ -194,7 +196,7 @@ class ConfigTest extends PHPUnit_Framework_TestCase */ public function testArrayUnmerge($description, $test) { - $configWriter = Piwik_Config::getInstance(); + $configWriter = Config::getInstance(); list($a, $b) = $test; @@ -342,7 +344,7 @@ class ConfigTest extends PHPUnit_Framework_TestCase */ public function testDumpConfig($description, $test) { - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); list($configLocal, $configGlobal, $configCache, $expected) = $test; diff --git a/tests/PHPUnit/Core/DataTable/ArrayTest.php b/tests/PHPUnit/Core/DataTable/ArrayTest.php index 9be0608b33..9ceaed5caa 100755 --- a/tests/PHPUnit/Core/DataTable/ArrayTest.php +++ b/tests/PHPUnit/Core/DataTable/ArrayTest.php @@ -1,10 +1,12 @@ <?php +use Piwik\Core\Config; + class Test_Piwik_DataTable_Array extends PHPUnit_Framework_TestCase { public function setUp() { parent::setUp(); - Piwik_Config::getInstance()->setTestEnvironment(); + Config::getInstance()->setTestEnvironment(); Piwik_DataTable_Manager::getInstance()->deleteAll(); } diff --git a/tests/PHPUnit/Core/IPTest.php b/tests/PHPUnit/Core/IPTest.php index ff7e9ca067..f9ae6bc3d3 100644 --- a/tests/PHPUnit/Core/IPTest.php +++ b/tests/PHPUnit/Core/IPTest.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -580,12 +582,12 @@ class IPTest extends PHPUnit_Framework_TestCase */ public function testGetIpFromHeader($description, $test) { - Piwik_Config::getInstance()->setTestEnvironment(); + Config::getInstance()->setTestEnvironment(); $_SERVER['REMOTE_ADDR'] = $test[0]; $_SERVER['HTTP_X_FORWARDED_FOR'] = $test[1]; - Piwik_Config::getInstance()->General['proxy_client_headers'] = array($test[2]); - Piwik_Config::getInstance()->General['proxy_ips'] = array($test[3]); + Config::getInstance()->General['proxy_client_headers'] = array($test[2]); + Config::getInstance()->General['proxy_ips'] = array($test[3]); $this->assertEquals($test[4], Piwik_IP::getIpFromHeader(), $description); } diff --git a/tests/PHPUnit/Core/NonceTest.php b/tests/PHPUnit/Core/NonceTest.php index da64ee35c3..25ecd3579c 100644 --- a/tests/PHPUnit/Core/NonceTest.php +++ b/tests/PHPUnit/Core/NonceTest.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -28,9 +30,9 @@ class NonceTest extends PHPUnit_Framework_TestCase */ public function test_getAcceptableOrigins($host, $expected) { - Piwik_Config::getInstance()->General['enable_trusted_host_check'] = 0; + Config::getInstance()->General['enable_trusted_host_check'] = 0; $_SERVER['HTTP_HOST'] = $host; - Piwik_Config::getInstance()->General['trusted_hosts'] = array('example.com'); + Config::getInstance()->General['trusted_hosts'] = array('example.com'); $this->assertEquals($expected, Piwik_Nonce::getAcceptableOrigins(), $host); } } diff --git a/tests/PHPUnit/Core/Tracker/ActionTest.php b/tests/PHPUnit/Core/Tracker/ActionTest.php index 608cd33bc5..83899537ea 100644 --- a/tests/PHPUnit/Core/Tracker/ActionTest.php +++ b/tests/PHPUnit/Core/Tracker/ActionTest.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -11,7 +13,7 @@ class Tracker_ActionTest extends DatabaseTestCase { parent::setUp(); $userFile = dirname(__FILE__) . '/../../../resources/Tracker/Action.config.ini.php'; - $config = Piwik_Config::getInstance(); + $config = Config::getInstance(); $config->clear(); $config->setTestEnvironment($userFile, false); diff --git a/tests/PHPUnit/Core/UrlTest.php b/tests/PHPUnit/Core/UrlTest.php index 114adb365b..8bb62b9b70 100644 --- a/tests/PHPUnit/Core/UrlTest.php +++ b/tests/PHPUnit/Core/UrlTest.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -62,9 +64,9 @@ class UrlTest extends PHPUnit_Framework_TestCase { $_SERVER['HTTP_HOST'] = $test[0]; $_SERVER['HTTP_X_FORWARDED_HOST'] = $test[1]; - Piwik_Config::getInstance()->General['proxy_host_headers'] = array($test[2]); - Piwik_Config::getInstance()->General['proxy_ips'] = array($test[3]); - Piwik_Config::getInstance()->General['enable_trusted_host_check'] = 0; + Config::getInstance()->General['proxy_host_headers'] = array($test[2]); + Config::getInstance()->General['proxy_ips'] = array($test[3]); + Config::getInstance()->General['enable_trusted_host_check'] = 0; $this->assertEquals($test[4], Piwik_Url::getCurrentHost(), $description); } @@ -134,8 +136,8 @@ class UrlTest extends PHPUnit_Framework_TestCase $_SERVER['HTTP_HOST'] = $httphost; $_SERVER['SCRIPT_URI'] = $scripturi; $_SERVER['REQUEST_URI'] = $requesturi; - Piwik_Config::getInstance()->General['enable_trusted_host_check'] = 1; - Piwik_Config::getInstance()->General['trusted_hosts'] = array($httphost); + Config::getInstance()->General['enable_trusted_host_check'] = 1; + Config::getInstance()->General['trusted_hosts'] = array($httphost); $urlToTest = $testurl; $this->assertEquals($result, Piwik_Url::isLocalUrl($urlToTest)); } @@ -175,7 +177,7 @@ class UrlTest extends PHPUnit_Framework_TestCase $_SERVER['REQUEST_URI'] = $path; $_SERVER['HTTP_HOST'] = $host; - Piwik_Config::getInstance()->General['trusted_hosts'] = array($host); + Config::getInstance()->General['trusted_hosts'] = array($host); $url = Piwik_Url::getCurrentUrlWithoutFilename(); $this->assertEquals($expected, $url); @@ -245,8 +247,8 @@ class UrlTest extends PHPUnit_Framework_TestCase */ public function testIsValidHost($expected, $host, $trustedHosts, $description) { - Piwik_Config::getInstance()->General['enable_trusted_host_check'] = 1; - Piwik_Config::getInstance()->General['trusted_hosts'] = $trustedHosts; + Config::getInstance()->General['enable_trusted_host_check'] = 1; + Config::getInstance()->General['trusted_hosts'] = $trustedHosts; $this->assertEquals($expected, Piwik_Url::isValidHost($host), $description); } diff --git a/tests/PHPUnit/DatabaseTestCase.php b/tests/PHPUnit/DatabaseTestCase.php index d38aca1d89..f30c5b0fe3 100644 --- a/tests/PHPUnit/DatabaseTestCase.php +++ b/tests/PHPUnit/DatabaseTestCase.php @@ -5,6 +5,8 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\Core\Config; + /** * Tests extending DatabaseTestCase are much slower to run: the setUp will * create all Piwik tables in a freshly empty test database. @@ -23,9 +25,9 @@ class DatabaseTestCase extends PHPUnit_Framework_TestCase { parent::setUp(); try { - Piwik_Config::getInstance()->setTestEnvironment(); + Config::getInstance()->setTestEnvironment(); - $dbConfig = Piwik_Config::getInstance()->database; + $dbConfig = Config::getInstance()->database; $dbName = $dbConfig['dbname']; $dbConfig['dbname'] = null; @@ -66,7 +68,7 @@ class DatabaseTestCase extends PHPUnit_Framework_TestCase Piwik_PDFReports_API::$cache = array(); Piwik_Site::clearCache(); Piwik_Tracker_Cache::deleteTrackerCache(); - Piwik_Config::getInstance()->clear(); + Config::getInstance()->clear(); Piwik_DataAccess_ArchiveTableCreator::clear(); Zend_Registry::_unsetInstance(); } diff --git a/tests/PHPUnit/Integration/BlobReportLimitingTest.php b/tests/PHPUnit/Integration/BlobReportLimitingTest.php index 979fa128da..2f0389774a 100755 --- a/tests/PHPUnit/Integration/BlobReportLimitingTest.php +++ b/tests/PHPUnit/Integration/BlobReportLimitingTest.php @@ -6,6 +6,8 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\Core\Config; + require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php'; /** @@ -106,7 +108,7 @@ class Test_Piwik_Integration_BlobReportLimitingTest extends IntegrationTestCase $generalConfig['datatable_archiving_maximum_rows_custom_variables'] = 4; $generalConfig['datatable_archiving_maximum_rows_subtable_custom_variables'] = 4; $generalConfig['datatable_archiving_maximum_rows_standard'] = 4; - Piwik_Config::getInstance()->General['archiving_ranking_query_row_limit'] = 3; + Config::getInstance()->General['archiving_ranking_query_row_limit'] = 3; Piwik_Actions_ArchivingHelper::reloadConfig(); foreach ($this->getApiForTesting() as $pair) { @@ -128,7 +130,7 @@ class Test_Piwik_Integration_BlobReportLimitingTest extends IntegrationTestCase public function testApiWithRankingQueryDisabled() { self::deleteArchiveTables(); - $generalConfig =& Piwik_Config::getInstance()->General; + $generalConfig =& Config::getInstance()->General; $generalConfig['datatable_archiving_maximum_rows_referers'] = 500; $generalConfig['datatable_archiving_maximum_rows_subtable_referers'] = 500; $generalConfig['datatable_archiving_maximum_rows_actions'] = 500; @@ -158,7 +160,7 @@ class Test_Piwik_Integration_BlobReportLimitingTest extends IntegrationTestCase protected static function setUpConfigOptions() { self::createTestConfig(); - $generalConfig =& Piwik_Config::getInstance()->General; + $generalConfig =& Config::getInstance()->General; $generalConfig['datatable_archiving_maximum_rows_referers'] = 3; $generalConfig['datatable_archiving_maximum_rows_subtable_referers'] = 2; $generalConfig['datatable_archiving_maximum_rows_actions'] = 3; diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php index 902380177d..9967f8252e 100755 --- a/tests/PHPUnit/IntegrationTestCase.php +++ b/tests/PHPUnit/IntegrationTestCase.php @@ -5,6 +5,8 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\Core\Config; + require_once PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/PiwikTracker.php'; /** @@ -27,7 +29,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase */ public static function createTestConfig() { - Piwik_Config::getInstance()->setTestEnvironment(); + Config::getInstance()->setTestEnvironment(); } /** @@ -45,7 +47,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase */ public static function connectWithoutDatabase() { - $dbConfig = Piwik_Config::getInstance()->database; + $dbConfig = Config::getInstance()->database; $oldDbName = $dbConfig['dbname']; $dbConfig['dbname'] = null; @@ -81,7 +83,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase public static function loadAllPlugins() { $pluginsManager = Piwik_PluginsManager::getInstance(); - $pluginsToLoad = Piwik_Config::getInstance()->Plugins['Plugins']; + $pluginsToLoad = Config::getInstance()->Plugins['Plugins']; $pluginsToLoad[] = 'DevicesDetection'; $pluginsManager->loadPlugins($pluginsToLoad); @@ -133,7 +135,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase if ($dbName === false) // must be after test config is created { - $dbName = Piwik_Config::getInstance()->database['dbname']; + $dbName = Config::getInstance()->database['dbname']; } self::connectWithoutDatabase(); @@ -144,7 +146,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase Piwik::disconnectDatabase(); // reconnect once we're sure the database exists - Piwik_Config::getInstance()->database['dbname'] = $dbName; + Config::getInstance()->database['dbname'] = $dbName; Piwik::createDatabaseObject(); Piwik::createTables(); @@ -217,7 +219,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase Piwik_Option::getInstance()->clearCache(); Piwik_Site::clearCache(); Piwik_Tracker_Cache::deleteTrackerCache(); - Piwik_Config::getInstance()->clear(); + Config::getInstance()->clear(); Piwik_DataAccess_ArchiveTableCreator::clear(); Piwik_PDFReports_API::$cache = array(); Zend_Registry::_unsetInstance(); @@ -965,10 +967,10 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase if (isset($params['disableArchiving']) && $params['disableArchiving'] === true) { Piwik_ArchiveProcessor_Rules::$archivingDisabledByTests = true; - Piwik_Config::getInstance()->General['browser_archiving_disabled_enforce'] = 1; + Config::getInstance()->General['browser_archiving_disabled_enforce'] = 1; } else { Piwik_ArchiveProcessor_Rules::$archivingDisabledByTests = false; - Piwik_Config::getInstance()->General['browser_archiving_disabled_enforce'] = 0; + Config::getInstance()->General['browser_archiving_disabled_enforce'] = 0; } if (isset($params['language'])) { diff --git a/tests/PHPUnit/Plugins/LoginTest.php b/tests/PHPUnit/Plugins/LoginTest.php index 5ddbafcbc1..efd1e101a3 100644 --- a/tests/PHPUnit/Plugins/LoginTest.php +++ b/tests/PHPUnit/Plugins/LoginTest.php @@ -5,6 +5,8 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\Core\Config; + require_once 'Login/Auth.php'; class LoginTest extends DatabaseTestCase @@ -23,7 +25,7 @@ class LoginTest extends DatabaseTestCase Piwik_Access::setSingletonInstance($pseudoMockAccess); // we make sure the tests don't depend on the config file content - Piwik_Config::getInstance()->superuser = array( + Config::getInstance()->superuser = array( 'login' => 'superusertest', 'password' => md5('passwordsuperusertest'), 'email' => 'superuser@example.com' @@ -383,7 +385,7 @@ class LoginTest extends DatabaseTestCase */ public function testAuthenticateFailureSuperUserEmptyTokenAuth() { - $user = Piwik_Config::getInstance()->superuser; + $user = Config::getInstance()->superuser; $password = $user['password']; $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password); @@ -401,7 +403,7 @@ class LoginTest extends DatabaseTestCase */ public function testAuthenticateFailureSuperUserInvalidTokenAuth() { - $user = Piwik_Config::getInstance()->superuser; + $user = Config::getInstance()->superuser; $password = $user['password']; $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password); @@ -419,7 +421,7 @@ class LoginTest extends DatabaseTestCase */ public function testAuthenticateFailureSuperUserInvalidTokenAuth2() { - $user = Piwik_Config::getInstance()->superuser; + $user = Config::getInstance()->superuser; $password = $user['password']; $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password); @@ -437,7 +439,7 @@ class LoginTest extends DatabaseTestCase */ public function testAuthenticateFailureSuperUserEmptyLogin() { - $user = Piwik_Config::getInstance()->superuser; + $user = Config::getInstance()->superuser; $password = $user['password']; $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password); @@ -455,7 +457,7 @@ class LoginTest extends DatabaseTestCase */ public function testAuthenticateFailureSuperUserLoginTokenAuthMissmatch() { - $user = Piwik_Config::getInstance()->superuser; + $user = Config::getInstance()->superuser; $password = $user['password']; $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password); @@ -473,7 +475,7 @@ class LoginTest extends DatabaseTestCase */ public function testAuthenticateSuccessSuperUserTokenAuth() { - $user = Piwik_Config::getInstance()->superuser; + $user = Config::getInstance()->superuser; $password = $user['password']; $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password); @@ -491,7 +493,7 @@ class LoginTest extends DatabaseTestCase */ public function testAuthenticateSuccessSuperLoginAndTokenAuth() { - $user = Piwik_Config::getInstance()->superuser; + $user = Config::getInstance()->superuser; $password = $user['password']; $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password); @@ -509,7 +511,7 @@ class LoginTest extends DatabaseTestCase */ public function testAuthenticateSuccessSuperUserLoginAndHashedTokenAuth() { - $user = Piwik_Config::getInstance()->superuser; + $user = Config::getInstance()->superuser; $password = $user['password']; $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password); diff --git a/tests/PHPUnit/Plugins/PrivacyManagerTest.php b/tests/PHPUnit/Plugins/PrivacyManagerTest.php index 1d4b235c79..f731f91bef 100755 --- a/tests/PHPUnit/Plugins/PrivacyManagerTest.php +++ b/tests/PHPUnit/Plugins/PrivacyManagerTest.php @@ -5,6 +5,8 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ +use Piwik\Core\Config; + require_once 'PrivacyManager/PrivacyManager.php'; class PrivacyManagerTest extends IntegrationTestCase @@ -842,7 +844,7 @@ class PrivacyManagerTest extends IntegrationTestCase protected function _tableExists($tableName) { - $dbName = Piwik_Config::getInstance()->database['dbname']; + $dbName = Config::getInstance()->database['dbname']; $sql = "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = ? AND table_name = ?"; return Piwik_FetchOne($sql, array($dbName, Piwik_Common::prefixTable($tableName))) == 1; diff --git a/tests/PHPUnit/Plugins/UsersManagerTest.php b/tests/PHPUnit/Plugins/UsersManagerTest.php index 2d2da44ba5..e720a0082b 100644 --- a/tests/PHPUnit/Plugins/UsersManagerTest.php +++ b/tests/PHPUnit/Plugins/UsersManagerTest.php @@ -1,4 +1,6 @@ <?php +use Piwik\Core\Config; + /** * Piwik - Open source web analytics * @@ -25,7 +27,7 @@ class UsersManagerTest extends DatabaseTestCase Piwik_Access::setSingletonInstance($pseudoMockAccess); // we make sure the tests don't depend on the config file content - Piwik_Config::getInstance()->superuser = array( + Config::getInstance()->superuser = array( 'login' => 'superusertest', 'password' => 'passwordsuperusertest', 'email' => 'superuser@example.com' @@ -71,7 +73,7 @@ class UsersManagerTest extends DatabaseTestCase */ public function testAllSuperUserIncluded() { - Piwik_Config::getInstance()->superuser = array( + Config::getInstance()->superuser = array( 'login' => 'superusertest', 'password' => 'passwordsuperusertest', 'email' => 'superuser@example.com' diff --git a/tests/PHPUnit/proxy/piwik.php b/tests/PHPUnit/proxy/piwik.php index 841d2bb549..1f4c58258c 100755 --- a/tests/PHPUnit/proxy/piwik.php +++ b/tests/PHPUnit/proxy/piwik.php @@ -11,6 +11,8 @@ // Wrapping the request inside ob_start() calls to ensure that the Test // calling us waits for the full request to process before unblocking +use Piwik\Core\Config; + ob_start(); define('PIWIK_INCLUDE_PATH', '../../..'); @@ -22,15 +24,15 @@ require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; // Config files forced to use the test database // Note that this also provides security for Piwik installs containing tests files: // this proxy will not record any data in the production database. -Piwik_Config::getInstance()->setTestEnvironment(); -Piwik_Config::getInstance()->PluginsInstalled['PluginsInstalled'] = array(); +Config::getInstance()->setTestEnvironment(); +Config::getInstance()->PluginsInstalled['PluginsInstalled'] = array(); try { - $trackerPlugins = Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; + $trackerPlugins = Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; }catch(Exception $e) { $trackerPlugins = array(); } $trackerPlugins[] = 'DevicesDetection'; -Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker'] = $trackerPlugins; +Config::getInstance()->Plugins_Tracker['Plugins_Tracker'] = $trackerPlugins; Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files'; Piwik_Tracker::setTestEnvironment(); |