diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-08-02 17:59:33 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-08-02 17:59:33 +0400 |
commit | a96ec40e983a8b64f4c25def541a519ff3670e6a (patch) | |
tree | bef2a5f7b1e9532dc96161334e23a553cdff7ea1 /misc | |
parent | 61997f45e4c39360000e815c9e0853ae04e2f56f (diff) |
Refs #4059 Converting dozens of plugins/* classes to use Namespaces, \Piwik\Plugins\*
Added namespaces to functions.php files in the five plugins that had one
Work in progress
Diffstat (limited to 'misc')
-rw-r--r-- | misc/cron/archive.php | 20 | ||||
-rwxr-xr-x | misc/others/geoipUpdateRows.php | 23 | ||||
-rw-r--r-- | misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php | 3 |
3 files changed, 26 insertions, 20 deletions
diff --git a/misc/cron/archive.php b/misc/cron/archive.php index 1f63c26ebf..cf6d2a5e44 100644 --- a/misc/cron/archive.php +++ b/misc/cron/archive.php @@ -6,6 +6,8 @@ use Piwik\Common; use Piwik\Date; use Piwik\FrontController; use Piwik\Http; +use Piwik\Plugins\CoreAdminHome\API as CoreAdminHomeAPI; +use Piwik\Plugins\SitesManager\API as SitesManagerAPI; use Piwik\Version; use Piwik\Url; use Piwik\Timer; @@ -327,13 +329,13 @@ class Archiving // Remove this website from the list of websites to be invalidated // since it's now just been re-processing the reports, job is done! if ($websiteIsOldDataInvalidate) { - $websiteIdsInvalidated = Piwik_CoreAdminHome_API::getWebsiteIdsToInvalidate(); + $websiteIdsInvalidated = CoreAdminHomeAPI::getWebsiteIdsToInvalidate(); if (count($websiteIdsInvalidated)) { $found = array_search($idsite, $websiteIdsInvalidated); if ($found !== false) { unset($websiteIdsInvalidated[$found]); // $this->log("Websites left to invalidate: " . implode(", ", $websiteIdsInvalidated)); - Piwik_SetOption(Piwik_CoreAdminHome_API::OPTION_INVALIDATED_IDSITES, serialize($websiteIdsInvalidated)); + Piwik_SetOption(CoreAdminHomeAPI::OPTION_INVALIDATED_IDSITES, serialize($websiteIdsInvalidated)); } } } @@ -394,8 +396,8 @@ class Archiving private function initSegmentsToArchive() { -// Fetching segments to process - $this->segments = Piwik_CoreAdminHome_API::getInstance()->getKnownSegmentsToArchive(); + // Fetching segments to process + $this->segments = CoreAdminHomeAPI::getInstance()->getKnownSegmentsToArchive(); if (empty($this->segments)) $this->segments = array(); if (!empty($this->segments)) { $this->log("- Will pre-process " . count($this->segments) . " Segments for each website and each period: " . implode(", ", $this->segments)); @@ -720,7 +722,7 @@ class Archiving // Fetching websites to process private function initWebsitesToProcess() { - $this->allWebsites = Piwik_SitesManager_API::getInstance()->getAllSitesId(); + $this->allWebsites = SitesManagerAPI::getInstance()->getAllSitesId(); if ($this->shouldArchiveAllWebsites) { $this->websites = $this->allWebsites; @@ -734,7 +736,7 @@ class Archiving . Piwik::getPrettyTimeFromSeconds($this->firstRunActiveWebsitesWithTraffic, true, false) ); } - $this->websites = Piwik_SitesManager_API::getInstance()->getSitesIdWithVisits($timestampActiveTraffic); + $this->websites = SitesManagerAPI::getInstance()->getSitesIdWithVisits($timestampActiveTraffic); $websiteIds = !empty($this->websites) ? ", IDs: " . implode(", ", $this->websites) : ""; $prettySeconds = Piwik::getPrettyTimeFromSeconds(empty($this->timeLastCompleted) ? $this->firstRunActiveWebsitesWithTraffic @@ -747,7 +749,7 @@ class Archiving // 2) All websites that had reports in the past invalidated recently // eg. when using Python log import script - $this->idSitesInvalidatedOldReports = Piwik_CoreAdminHome_API::getWebsiteIdsToInvalidate(); + $this->idSitesInvalidatedOldReports = CoreAdminHomeAPI::getWebsiteIdsToInvalidate(); $this->idSitesInvalidatedOldReports = array_intersect($this->idSitesInvalidatedOldReports, $this->allWebsites); if (count($this->idSitesInvalidatedOldReports) > 0) { @@ -758,7 +760,7 @@ class Archiving // 3) Also process all other websites which days have finished since the last run. // This ensures we process the previous day/week/month/year that just finished, even if there was no new visit - $uniqueTimezones = Piwik_SitesManager_API::getInstance()->getUniqueSiteTimezones(); + $uniqueTimezones = SitesManagerAPI::getInstance()->getUniqueSiteTimezones(); $timezoneToProcess = array(); foreach ($uniqueTimezones as &$timezone) { $processedDateInTz = Date::factory((int)$timestampActiveTraffic, $timezone); @@ -769,7 +771,7 @@ class Archiving } } - $websiteDayHasFinishedSinceLastRun = Piwik_SitesManager_API::getInstance()->getSitesIdFromTimezones($timezoneToProcess); + $websiteDayHasFinishedSinceLastRun = SitesManagerAPI::getInstance()->getSitesIdFromTimezones($timezoneToProcess); $websiteDayHasFinishedSinceLastRun = array_diff($websiteDayHasFinishedSinceLastRun, $this->websites); $this->websiteDayHasFinishedSinceLastRun = $websiteDayHasFinishedSinceLastRun; if (count($websiteDayHasFinishedSinceLastRun) > 0) { diff --git a/misc/others/geoipUpdateRows.php b/misc/others/geoipUpdateRows.php index b0ffb11d7c..d0392c9f3b 100755 --- a/misc/others/geoipUpdateRows.php +++ b/misc/others/geoipUpdateRows.php @@ -5,6 +5,9 @@ use Piwik\Common; use Piwik\FrontController; use Piwik\IP; use Piwik\Db; +use Piwik\Plugins\UserCountry\LocationProvider; +use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Php; +use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Pecl; ini_set("memory_limit", "512M"); error_reporting(E_ALL | E_NOTICE); @@ -120,7 +123,7 @@ function geoipUpdateError($message) $displayNotes = $start == 0; // try getting the pecl location provider -$provider = new Piwik_UserCountry_LocationProvider_GeoIp_Pecl(); +$provider = new Pecl(); if (!$provider->isAvailable()) { if ($displayNotes) { Piwik::log("[note] The GeoIP PECL extension is not installed."); @@ -146,7 +149,7 @@ if (is_null($provider)) { Piwik::log("[note] Falling back to PHP API. This may become too slow for you. If so, you can read this link on how to install the PECL extension: http://piwik.org/faq/how-to/#faq_164"); } - $provider = new Piwik_UserCountry_LocationProvider_GeoIp_Php(); + $provider = new Php(); if (!$provider->isAvailable()) { if ($displayNotes) { Piwik::log("[note] The GeoIP PHP API is not available. This means you do not have a GeoIP location database in your ./misc directory. The database must be named either GeoIP.dat or GeoIPCity.dat based on the type of database it is."); @@ -173,11 +176,11 @@ if ($displayNotes) { } // perform update -$logVisitFieldsToUpdate = array('location_country' => Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY, - 'location_region' => Piwik_UserCountry_LocationProvider::REGION_CODE_KEY, - 'location_city' => Piwik_UserCountry_LocationProvider::CITY_NAME_KEY, - 'location_latitude' => Piwik_UserCountry_LocationProvider::LATITUDE_KEY, - 'location_longitude' => Piwik_UserCountry_LocationProvider::LONGITUDE_KEY); +$logVisitFieldsToUpdate = array('location_country' => LocationProvider::COUNTRY_CODE_KEY, + 'location_region' => LocationProvider::REGION_CODE_KEY, + 'location_city' => LocationProvider::CITY_NAME_KEY, + 'location_latitude' => LocationProvider::LATITUDE_KEY, + 'location_longitude' => LocationProvider::LONGITUDE_KEY); if ($displayNotes) { Piwik::log("\n$count rows to process in " . Common::prefixTable('log_visit') @@ -208,9 +211,9 @@ for (; $start < $end; $start += $limit) { $ip = IP::N2P($row['location_ip']); $location = $provider->getLocation(array('ip' => $ip)); - if (!empty($location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY])) { - $location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY] = - strtolower($location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY]); + if (!empty($location[LocationProvider::COUNTRY_CODE_KEY])) { + $location[LocationProvider::COUNTRY_CODE_KEY] = + strtolower($location[LocationProvider::COUNTRY_CODE_KEY]); } $row['location_country'] = strtolower($row['location_country']); diff --git a/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php b/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php index e9c6b32449..69154a4b13 100644 --- a/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php +++ b/misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php @@ -4,6 +4,7 @@ use Piwik\Piwik; use Piwik\Common; use Piwik\FrontController; +use Piwik\Plugins\SitesManager\API; exit; @@ -19,7 +20,7 @@ FrontController::getInstance()->init(); Piwik::setUserIsSuperUser(); $count = 100; for ($i = 0; $i <= $count; $i++) { - $id = Piwik_SitesManager_API::getInstance()->addSite(Common::getRandomString(), 'http://piwik.org'); + $id = API::getInstance()->addSite(Common::getRandomString(), 'http://piwik.org'); $t = new PiwikTracker($id, 'http://localhost/trunk/piwik.php'); echo $id . " <img width=100 height=10 border=1 src='" . $t->getUrlTrackPageView('title') . "'><br/>"; } |