Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-08-11 21:28:30 +0400
committermattab <matthieu.aubry@gmail.com>2013-08-11 21:28:30 +0400
commitd293408450bc8b0c0f79934da6a43914626935ae (patch)
treee50c0df2f698b6033e13f963b9a16a01ef5bf020
parent3b74ae5cdac37e16315c3a24ecf2591f742ca3c7 (diff)
parent2340530c1109a37527f3b8ad0b82e54e7a6eb137 (diff)
Merge branch 'plugin_namespaces'
Conflicts: plugins/UserCountryMap/Controller.php
-rw-r--r--config/global.ini.php2
-rw-r--r--core/API/DataTableManipulator.php6
-rw-r--r--core/API/DocumentationGenerator.php4
-rw-r--r--core/API/Proxy.php32
-rw-r--r--core/API/Request.php9
-rw-r--r--core/Access.php2
-rw-r--r--core/ArchiveProcessor.php15
-rw-r--r--core/AssetManager.php11
-rw-r--r--core/Common.php22
-rw-r--r--core/Controller.php35
-rw-r--r--core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php2
-rw-r--r--core/DataTable/Renderer.php2
-rw-r--r--core/Db/Schema.php2
-rw-r--r--core/FrontController.php13
-rw-r--r--core/Loader.php8
-rw-r--r--core/Menu/MenuAbstract.php4
-rw-r--r--core/Period.php12
-rw-r--r--core/Piwik.php4
-rw-r--r--core/Plugin.php5
-rw-r--r--core/PluginsArchiver.php7
-rw-r--r--core/PluginsManager.php34
-rw-r--r--core/ReportRenderer.php6
-rw-r--r--core/ReportRenderer/Html.php4
-rw-r--r--core/ReportRenderer/Pdf.php4
-rw-r--r--core/ScheduledTask.php9
-rw-r--r--core/Segment.php6
-rw-r--r--core/Site.php8
-rw-r--r--core/Tracker/Cache.php4
-rw-r--r--core/Tracker/Request.php12
-rw-r--r--core/Tracker/Visit.php30
-rw-r--r--core/Twig.php2
-rw-r--r--core/UpdateCheck.php4
-rw-r--r--core/Updater.php1
-rw-r--r--core/Updates/0.2.34.php3
-rw-r--r--core/Updates/0.6.2.php3
-rw-r--r--core/Updates/1.8.3-b1.php13
-rw-r--r--core/View.php8
-rw-r--r--core/ViewDataTable.php33
-rw-r--r--misc/cron/archive.php20
-rwxr-xr-xmisc/others/geoipUpdateRows.php23
-rw-r--r--misc/others/test_cookies_GenerateHundredsWebsitesAndVisits.php3
-rw-r--r--plugins/API/API.php137
-rw-r--r--plugins/API/Controller.php9
-rw-r--r--plugins/API/ProcessedReport.php29
-rw-r--r--plugins/API/RowEvolution.php17
-rw-r--r--plugins/Actions/API.php38
-rw-r--r--plugins/Actions/Actions.php203
-rw-r--r--plugins/Actions/Archiver.php70
-rw-r--r--plugins/Actions/ArchivingHelper.php35
-rw-r--r--plugins/Actions/Controller.php25
-rw-r--r--plugins/Alerts/README.md3
-rwxr-xr-xplugins/Annotations/API.php30
-rwxr-xr-xplugins/Annotations/AnnotationList.php11
-rwxr-xr-xplugins/Annotations/Annotations.php8
-rwxr-xr-xplugins/Annotations/Controller.php15
-rw-r--r--plugins/AnonymizeIP/AnonymizeIP.php9
-rw-r--r--plugins/CoreAdminHome/API.php14
-rw-r--r--plugins/CoreAdminHome/Controller.php30
-rw-r--r--plugins/CoreAdminHome/CoreAdminHome.php10
-rw-r--r--plugins/CoreHome/Controller.php29
-rw-r--r--plugins/CoreHome/CoreHome.php9
-rw-r--r--plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php12
-rw-r--r--plugins/CoreHome/DataTableRowAction/RowEvolution.php17
-rw-r--r--plugins/CorePluginsAdmin/Controller.php11
-rw-r--r--plugins/CorePluginsAdmin/CorePluginsAdmin.php9
-rw-r--r--plugins/CoreUpdater/Controller.php17
-rw-r--r--plugins/CoreUpdater/CoreUpdater.php12
-rw-r--r--plugins/CoreVisualizations/CoreVisualizations.php12
-rw-r--r--plugins/CustomVariables/API.php15
-rw-r--r--plugins/CustomVariables/Archiver.php33
-rw-r--r--plugins/CustomVariables/Controller.php9
-rw-r--r--plugins/CustomVariables/CustomVariables.php42
-rw-r--r--plugins/DBStats/API.php19
-rw-r--r--plugins/DBStats/Controller.php13
-rw-r--r--plugins/DBStats/DBStats.php24
-rwxr-xr-xplugins/DBStats/MySQLMetadataProvider.php8
-rw-r--r--plugins/Dashboard/API.php22
-rw-r--r--plugins/Dashboard/Controller.php28
-rw-r--r--plugins/Dashboard/Dashboard.php11
-rw-r--r--plugins/DevicesDetection/API.php41
-rw-r--r--plugins/DevicesDetection/Archiver.php22
-rw-r--r--plugins/DevicesDetection/Controller.php21
-rw-r--r--plugins/DevicesDetection/DevicesDetection.php77
-rw-r--r--plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php2
-rw-r--r--plugins/DevicesDetection/UserAgentParserEnhanced/regexes/browsers.yml2
-rw-r--r--plugins/DevicesDetection/UserAgentParserEnhanced/regexes/mobiles.yml2
-rw-r--r--plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml2
-rw-r--r--plugins/DevicesDetection/functions.php42
-rw-r--r--plugins/DoNotTrack/DoNotTrack.php9
-rw-r--r--plugins/ExampleAPI/API.php20
-rw-r--r--plugins/ExampleAPI/ExampleAPI.php20
-rw-r--r--plugins/ExamplePlugin/Controller.php20
-rw-r--r--plugins/ExamplePlugin/ExamplePlugin.php9
-rw-r--r--plugins/ExamplePlugin/lang/en.php2
-rw-r--r--plugins/ExampleRssWidget/Controller.php16
-rw-r--r--plugins/ExampleRssWidget/ExampleRssWidget.php9
-rw-r--r--plugins/ExampleRssWidget/RssRenderer.php (renamed from plugins/ExampleRssWidget/Rss.php)11
-rw-r--r--plugins/ExampleUI/API.php10
-rw-r--r--plugins/ExampleUI/Controller.php11
-rw-r--r--plugins/ExampleUI/ExampleUI.php9
-rw-r--r--plugins/Feedback/Controller.php16
-rw-r--r--plugins/Feedback/Feedback.php9
-rw-r--r--plugins/Goals/API.php45
-rw-r--r--plugins/Goals/Archiver.php26
-rw-r--r--plugins/Goals/Controller.php37
-rw-r--r--plugins/Goals/Goals.php124
-rw-r--r--plugins/ImageGraph/API.php76
-rw-r--r--plugins/ImageGraph/Controller.php20
-rw-r--r--plugins/ImageGraph/ImageGraph.php26
-rw-r--r--plugins/ImageGraph/StaticGraph.php37
-rw-r--r--plugins/ImageGraph/StaticGraph/3DPie.php8
-rw-r--r--plugins/ImageGraph/StaticGraph/Evolution.php8
-rw-r--r--plugins/ImageGraph/StaticGraph/Exception.php10
-rw-r--r--plugins/ImageGraph/StaticGraph/GridGraph.php9
-rw-r--r--plugins/ImageGraph/StaticGraph/HorizontalBar.php10
-rw-r--r--plugins/ImageGraph/StaticGraph/Pie.php9
-rw-r--r--plugins/ImageGraph/StaticGraph/PieGraph.php11
-rw-r--r--plugins/ImageGraph/StaticGraph/VerticalBar.php8
-rw-r--r--plugins/Installation/Controller.php93
-rw-r--r--plugins/Installation/FormDatabaseSetup.php44
-rw-r--r--plugins/Installation/FormFirstWebsiteSetup.php23
-rw-r--r--plugins/Installation/FormGeneralSetup.php26
-rw-r--r--plugins/Installation/Installation.php12
-rw-r--r--plugins/Installation/View.php9
-rw-r--r--plugins/LanguagesManager/API.php10
-rw-r--r--plugins/LanguagesManager/Controller.php16
-rw-r--r--plugins/LanguagesManager/LanguagesManager.php29
-rw-r--r--plugins/Live/API.php54
-rw-r--r--plugins/Live/Controller.php16
-rw-r--r--plugins/Live/Live.php37
-rw-r--r--plugins/Live/Visitor.php68
-rw-r--r--plugins/Login/Auth.php12
-rw-r--r--plugins/Login/Controller.php45
-rw-r--r--plugins/Login/FormLogin.php9
-rw-r--r--plugins/Login/FormResetPassword.php8
-rw-r--r--plugins/Login/Login.php24
-rw-r--r--plugins/MobileMessaging/API.php69
-rw-r--r--plugins/MobileMessaging/APIException.php10
-rw-r--r--plugins/MobileMessaging/Controller.php25
-rw-r--r--plugins/MobileMessaging/CountryCallingCodes.php8
-rw-r--r--plugins/MobileMessaging/GSMCharset.php8
-rw-r--r--plugins/MobileMessaging/MobileMessaging.php44
-rw-r--r--plugins/MobileMessaging/ReportRenderer/ReportRendererException.php (renamed from plugins/MobileMessaging/ReportRenderer/Exception.php)13
-rw-r--r--plugins/MobileMessaging/ReportRenderer/Sms.php9
-rw-r--r--plugins/MobileMessaging/SMSProvider.php28
-rw-r--r--plugins/MobileMessaging/SMSProvider/Clockwork.php15
-rw-r--r--plugins/MobileMessaging/SMSProvider/StubbedProvider.php9
-rwxr-xr-xplugins/MultiSites/API.php46
-rw-r--r--plugins/MultiSites/Controller.php19
-rw-r--r--plugins/MultiSites/MultiSites.php18
-rw-r--r--plugins/Overlay/API.php31
-rw-r--r--plugins/Overlay/Controller.php44
-rw-r--r--plugins/Overlay/Overlay.php7
-rw-r--r--plugins/PDFReports/API.php64
-rw-r--r--plugins/PDFReports/Controller.php46
-rw-r--r--plugins/PDFReports/PDFReports.php78
-rw-r--r--plugins/PDFReports/config/tcpdf_config.php4
-rw-r--r--plugins/PleineLune/PleineLune.php31
-rw-r--r--plugins/PleineLune/plugin.piwik.json3
-rw-r--r--plugins/PrivacyManager/Controller.php46
-rwxr-xr-xplugins/PrivacyManager/LogDataPurger.php10
-rw-r--r--plugins/PrivacyManager/PrivacyManager.php31
-rwxr-xr-xplugins/PrivacyManager/ReportsPurger.php10
-rw-r--r--plugins/Provider/API.php15
-rw-r--r--plugins/Provider/Archiver.php6
-rw-r--r--plugins/Provider/Controller.php9
-rw-r--r--plugins/Provider/Provider.php37
-rw-r--r--plugins/Provider/functions.php12
-rw-r--r--plugins/Proxy/Controller.php9
-rw-r--r--plugins/Proxy/Proxy.php9
-rw-r--r--plugins/Referers/API.php75
-rw-r--r--plugins/Referers/Archiver.php24
-rw-r--r--plugins/Referers/Controller.php16
-rw-r--r--plugins/Referers/Referers.php64
-rw-r--r--plugins/Referers/functions.php51
-rw-r--r--plugins/SEO/API.php26
-rw-r--r--plugins/SEO/Controller.php15
-rw-r--r--plugins/SEO/MajesticClient.php6
-rw-r--r--plugins/SEO/RankChecker.php16
-rw-r--r--plugins/SEO/SEO.php9
-rw-r--r--plugins/SecurityInfo/Controller.php10
-rw-r--r--plugins/SecurityInfo/SecurityInfo.php9
-rw-r--r--plugins/SegmentEditor/API.php27
-rw-r--r--plugins/SegmentEditor/Controller.php28
-rw-r--r--plugins/SegmentEditor/SegmentEditor.php19
-rw-r--r--plugins/SitesManager/API.php41
-rw-r--r--plugins/SitesManager/Controller.php43
-rw-r--r--plugins/SitesManager/SitesManager.php33
-rw-r--r--plugins/Transitions/API.php73
-rw-r--r--plugins/Transitions/Controller.php10
-rw-r--r--plugins/Transitions/Transitions.php9
-rw-r--r--plugins/UserCountry/API.php67
-rw-r--r--plugins/UserCountry/Archiver.php24
-rw-r--r--plugins/UserCountry/Controller.php81
-rwxr-xr-xplugins/UserCountry/GeoIPAutoUpdater.php64
-rwxr-xr-xplugins/UserCountry/LocationProvider.php21
-rwxr-xr-xplugins/UserCountry/LocationProvider/Default.php9
-rwxr-xr-xplugins/UserCountry/LocationProvider/GeoIp.php11
-rwxr-xr-xplugins/UserCountry/LocationProvider/GeoIp/Pecl.php9
-rwxr-xr-xplugins/UserCountry/LocationProvider/GeoIp/Php.php11
-rwxr-xr-xplugins/UserCountry/LocationProvider/GeoIp/ServerBased.php18
-rw-r--r--plugins/UserCountry/UserCountry.php106
-rw-r--r--plugins/UserCountry/functions.php37
-rw-r--r--plugins/UserCountryMap/Controller.php50
-rw-r--r--plugins/UserCountryMap/UserCountryMap.php11
-rw-r--r--plugins/UserSettings/API.php58
-rw-r--r--plugins/UserSettings/Archiver.php14
-rw-r--r--plugins/UserSettings/Controller.php13
-rw-r--r--plugins/UserSettings/UserSettings.php18
-rw-r--r--plugins/UserSettings/functions.php69
-rw-r--r--plugins/UsersManager/API.php52
-rw-r--r--plugins/UsersManager/Controller.php55
-rw-r--r--plugins/UsersManager/UsersManager.php16
-rw-r--r--plugins/VisitFrequency/API.php12
-rw-r--r--plugins/VisitFrequency/Controller.php10
-rw-r--r--plugins/VisitFrequency/VisitFrequency.php15
-rw-r--r--plugins/VisitTime/API.php52
-rw-r--r--plugins/VisitTime/Archiver.php15
-rw-r--r--plugins/VisitTime/Controller.php9
-rw-r--r--plugins/VisitTime/VisitTime.php26
-rw-r--r--plugins/VisitTime/functions.php40
-rw-r--r--plugins/VisitorGenerator/Controller.php20
-rw-r--r--plugins/VisitorGenerator/VisitorGenerator.php9
-rw-r--r--plugins/VisitorInterest/API.php17
-rw-r--r--plugins/VisitorInterest/Archiver.php18
-rw-r--r--plugins/VisitorInterest/Controller.php9
-rw-r--r--plugins/VisitorInterest/VisitorInterest.php76
-rw-r--r--plugins/VisitsSummary/API.php10
-rw-r--r--plugins/VisitsSummary/Controller.php16
-rw-r--r--plugins/VisitsSummary/VisitsSummary.php9
-rw-r--r--plugins/Widgetize/Controller.php9
-rw-r--r--plugins/Widgetize/Widgetize.php9
-rw-r--r--plugins/Zeitgeist/stylesheets/base.css1
-rw-r--r--plugins/Zeitgeist/stylesheets/base.less1
-rw-r--r--tests/PHPUnit/BaseFixture.php56
-rwxr-xr-xtests/PHPUnit/BenchmarkTestCase.php3
-rw-r--r--tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php5
-rwxr-xr-xtests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php4
-rw-r--r--tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php3
-rw-r--r--tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php3
-rwxr-xr-xtests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php3
-rwxr-xr-xtests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php5
-rw-r--r--tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php6
-rw-r--r--tests/PHPUnit/Core/AccessTest.php10
-rw-r--r--tests/PHPUnit/Core/ArchiveProcessingTest.php3
-rw-r--r--tests/PHPUnit/Core/PiwikTest.php3
-rw-r--r--tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php5
-rw-r--r--tests/PHPUnit/Core/ScheduledTaskTest.php13
-rw-r--r--tests/PHPUnit/Core/TaskSchedulerTest.php37
-rw-r--r--tests/PHPUnit/Core/Tracker/ActionTest.php11
-rw-r--r--tests/PHPUnit/Core/Tracker/VisitTest.php7
-rw-r--r--tests/PHPUnit/DatabaseTestCase.php3
-rw-r--r--tests/PHPUnit/FakeAccess.php13
-rw-r--r--tests/PHPUnit/Fixtures/InvalidVisits.php9
-rw-r--r--tests/PHPUnit/Fixtures/ManySitesImportedLogs.php20
-rw-r--r--tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php13
-rw-r--r--tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php27
-rw-r--r--tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php5
-rw-r--r--tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php10
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php9
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php3
-rw-r--r--tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php3
-rw-r--r--tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php7
-rw-r--r--tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php3
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php3
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php5
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php10
-rw-r--r--tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php9
-rw-r--r--tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php3
-rw-r--r--tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php5
-rwxr-xr-xtests/PHPUnit/Integration/AnnotationsTest.php31
-rw-r--r--tests/PHPUnit/Integration/ArchiveCronTest.php5
-rw-r--r--tests/PHPUnit/Integration/AutoSuggestAPITest.php4
-rwxr-xr-xtests/PHPUnit/Integration/BlobReportLimitingTest.php3
-rwxr-xr-xtests/PHPUnit/Integration/ImportLogsTest.php7
-rwxr-xr-xtests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php9
-rwxr-xr-xtests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ConversionsTest.php4
-rwxr-xr-xtests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchNONETest.php3
-rwxr-xr-xtests/PHPUnit/IntegrationTestCase.php17
-rwxr-xr-xtests/PHPUnit/MockLocationProvider.php4
-rw-r--r--tests/PHPUnit/Plugins/ActionsTest.php5
-rw-r--r--tests/PHPUnit/Plugins/AnonymizeIPTest.php11
-rwxr-xr-xtests/PHPUnit/Plugins/LanguagesManagerTest.php11
-rw-r--r--tests/PHPUnit/Plugins/LoginTest.php82
-rw-r--r--tests/PHPUnit/Plugins/MobileMessagingTest.php35
-rw-r--r--tests/PHPUnit/Plugins/MultiSitesTest.php6
-rw-r--r--tests/PHPUnit/Plugins/PDFReportsTest.php97
-rwxr-xr-xtests/PHPUnit/Plugins/PrivacyManagerTest.php94
-rw-r--r--tests/PHPUnit/Plugins/ProxyTest.php4
-rw-r--r--tests/PHPUnit/Plugins/ReferersTest.php6
-rw-r--r--tests/PHPUnit/Plugins/SEOTest.php3
-rw-r--r--tests/PHPUnit/Plugins/SegmentEditorTest.php43
-rw-r--r--tests/PHPUnit/Plugins/SitesManagerTest.php260
-rw-r--r--tests/PHPUnit/Plugins/UserCountryTest.php16
-rw-r--r--tests/PHPUnit/Plugins/UserSettingsTest.php2
-rw-r--r--tests/PHPUnit/Plugins/UsersManagerTest.php268
-rw-r--r--tests/PHPUnit/UI/UIIntegrationTest.php5
-rwxr-xr-xtests/PHPUnit/proxy/piwik.php3
298 files changed, 3706 insertions, 3146 deletions
diff --git a/config/global.ini.php b/config/global.ini.php
index 1114efc681..a818c3248c 100644
--- a/config/global.ini.php
+++ b/config/global.ini.php
@@ -236,7 +236,7 @@ datatable_archiving_maximum_rows_subtable_custom_variables = 1000
; maximum number of rows for any of the Actions tables (pages, downloads, outlinks)
datatable_archiving_maximum_rows_actions = 500
; maximum number of rows for pages in categories (sub pages, when clicking on the + for a page category)
-; note: should not exceed the display limit in Piwik_Actions_Controller::ACTIONS_REPORT_ROWS_DISPLAY
+; note: should not exceed the display limit in Piwik\Actions\Controller::ACTIONS_REPORT_ROWS_DISPLAY
; because each subdirectory doesn't have paging at the bottom, so all data should be displayed if possible.
datatable_archiving_maximum_rows_subtable_actions = 100
diff --git a/core/API/DataTableManipulator.php b/core/API/DataTableManipulator.php
index 08cd2898f9..9e5d3d9868 100644
--- a/core/API/DataTableManipulator.php
+++ b/core/API/DataTableManipulator.php
@@ -14,7 +14,7 @@ use Exception;
use Piwik\DataTable\Row;
use Piwik\Period\Range;
use Piwik\DataTable;
-use Piwik_API_API;
+use Piwik\Plugins\API\API;
use Piwik\API\Proxy;
use Piwik\API\ResponseBuilder;
@@ -129,7 +129,7 @@ abstract class DataTableManipulator
}
}
- $class = 'Piwik_' . $this->apiModule . '_API';
+ $class = Request::getClassNameAPI( $this->apiModule );
$method = $this->getApiMethodForSubtable();
$this->manipulateSubtableRequest($request);
@@ -169,7 +169,7 @@ abstract class DataTableManipulator
private function getApiMethodForSubtable()
{
if (!$this->apiMethodForSubtable) {
- $meta = Piwik_API_API::getInstance()->getMetadata('all', $this->apiModule, $this->apiMethod);
+ $meta = API::getInstance()->getMetadata('all', $this->apiModule, $this->apiMethod);
if (isset($meta[0]['actionToLoadSubTables'])) {
$this->apiMethodForSubtable = $meta[0]['actionToLoadSubTables'];
} else {
diff --git a/core/API/DocumentationGenerator.php b/core/API/DocumentationGenerator.php
index c80dbd4711..a419895a42 100644
--- a/core/API/DocumentationGenerator.php
+++ b/core/API/DocumentationGenerator.php
@@ -33,9 +33,9 @@ class DocumentationGenerator
{
$plugins = PluginsManager::getInstance()->getLoadedPluginsName();
foreach ($plugins as $plugin) {
- $plugin = Common::unprefixClass($plugin);
try {
- Proxy::getInstance()->registerClass('Piwik_' . $plugin . '_API');
+ $className = Request::getClassNameAPI($plugin);
+ Proxy::getInstance()->registerClass($className);
} catch (Exception $e) {
}
}
diff --git a/core/API/Proxy.php b/core/API/Proxy.php
index e3861facb1..981452f41f 100644
--- a/core/API/Proxy.php
+++ b/core/API/Proxy.php
@@ -88,7 +88,7 @@ class Proxy
*
* The method will introspect the methods, their parameters, etc.
*
- * @param string $className ModuleName eg. "Piwik_UserSettings_API"
+ * @param string $className ModuleName eg. "API"
*/
public function registerClass($className)
{
@@ -146,7 +146,7 @@ class Proxy
* It also logs the API calls, with the parameters values, the returned value, the performance, etc.
* You can enable logging in config/global.ini.php (log_api_call)
*
- * @param string $className The class name (eg. Piwik_Referers_API)
+ * @param string $className The class name (eg. API)
* @param string $methodName The method name
* @param array $parametersRequest The parameters pairs (name=>value)
*
@@ -186,16 +186,14 @@ class Proxy
$returnedValue = call_user_func_array(array($object, $methodName), $finalParameters);
// allow plugins to manipulate the value
- if (substr($className, 0, 6) == 'Piwik_' && substr($className, -4) == '_API') {
- $pluginName = substr($className, 6, -4);
- Piwik_PostEvent('API.Proxy.processReturnValue', array(
- &$returnedValue,
- array('className' => $className,
- 'module' => $pluginName,
- 'action' => $methodName,
- 'parameters' => &$parametersRequest)
- ));
- }
+ $pluginName = $this->getModuleNameFromClassName($className);
+ Piwik_PostEvent('API.Proxy.processReturnValue', array(
+ &$returnedValue,
+ array('className' => $className,
+ 'module' => $pluginName,
+ 'action' => $methodName,
+ 'parameters' => &$parametersRequest)
+ ));
// Restore the request
$_GET = $saveGET;
@@ -242,12 +240,12 @@ class Proxy
/**
* Returns the 'moduleName' part of 'Piwik_moduleName_API' classname
*
- * @param string $className "Piwik_Referers_API"
+ * @param string $className "API"
* @return string "Referers"
*/
public function getModuleNameFromClassName($className)
{
- return str_replace(array('Piwik_', '_API'), '', $className);
+ return str_replace(array('\\Piwik\\Plugins\\', '\\API'), '', $className);
}
/**
@@ -308,9 +306,9 @@ class Proxy
}
/**
- * Includes the class Piwik_UserSettings_API by looking up plugins/UserSettings/API.php
+ * Includes the class API by looking up plugins/UserSettings/API.php
*
- * @param string $fileName api class name eg. "Piwik_UserSettings_API"
+ * @param string $fileName api class name eg. "API"
* @throws Exception
*/
private function includeApiFile($fileName)
@@ -403,7 +401,7 @@ class Proxy
private function checkClassIsSingleton($className)
{
if (!method_exists($className, "getInstance")) {
- throw new Exception("Objects that provide an API must be Singleton and have a 'static public function getInstance()' method.");
+ throw new Exception("$className that provide an API must be Singleton and have a 'static public function getInstance()' method.");
}
}
}
diff --git a/core/API/Request.php b/core/API/Request.php
index 91d664af56..f627dd5f0b 100644
--- a/core/API/Request.php
+++ b/core/API/Request.php
@@ -149,12 +149,12 @@ class Request
if (!PluginsManager::getInstance()->isPluginActivated($module)) {
throw new PluginDeactivatedException($module);
}
- $moduleClass = "Piwik_" . $module . "_API";
+ $apiClassName = $this->getClassNameAPI($module);
self::reloadAuthUsingTokenAuth($this->request);
// call the method
- $returnedValue = Proxy::getInstance()->call($moduleClass, $method, $this->request);
+ $returnedValue = Proxy::getInstance()->call($apiClassName, $method, $this->request);
$toReturn = $response->getResponse($returnedValue, $module, $method);
} catch (Exception $e) {
@@ -163,6 +163,11 @@ class Request
return $toReturn;
}
+ static public function getClassNameAPI($module)
+ {
+ return "\\Piwik\\Plugins\\$module\\API";
+ }
+
/**
* If the token_auth is found in the $request parameter,
* the current session will be authenticated using this token_auth.
diff --git a/core/Access.php b/core/Access.php
index 0f8d24f77b..303e5d638d 100644
--- a/core/Access.php
+++ b/core/Access.php
@@ -213,7 +213,7 @@ class Access
$this->isSuperUser = true;
try {
- $allSitesId = \Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $allSitesId = Plugins\SitesManager\API::getInstance()->getAllSitesId();
} catch(\Exception $e) {
$allSitesId = array();
}
diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php
index 46cde2533e..493aee7713 100644
--- a/core/ArchiveProcessor.php
+++ b/core/ArchiveProcessor.php
@@ -242,20 +242,19 @@ abstract class ArchiveProcessor
}
/**
- * A flag mechanism to store whether
+ * A flag mechanism to store whether visits were selected from archive
+ *
* @param $visitsMetricCached
* @param bool $convertedVisitsMetricCached
*/
protected function setNumberOfVisits($visitsMetricCached, $convertedVisitsMetricCached = false)
{
- if (empty($visitsMetricCached)) {
- $visitsMetricCached = 0;
- }
- if (empty($convertedVisitsMetricCached)) {
- $convertedVisitsMetricCached = 0;
+ if($visitsMetricCached === false) {
+ $this->visitsMetricCached = $this->convertedVisitsMetricCached = false;
+ } else {
+ $this->visitsMetricCached = (int)$visitsMetricCached;
+ $this->convertedVisitsMetricCached = (int)$convertedVisitsMetricCached;
}
- $this->visitsMetricCached = (int)$visitsMetricCached;
- $this->convertedVisitsMetricCached = (int)$convertedVisitsMetricCached;
}
public function getNumberOfVisits()
diff --git a/core/AssetManager.php b/core/AssetManager.php
index 79f81fafe1..086f538a3f 100644
--- a/core/AssetManager.php
+++ b/core/AssetManager.php
@@ -254,7 +254,18 @@ class AssetManager
{
$cssFiles = array();
Piwik_PostEvent(self::CSS_IMPORT_EVENT, array(&$cssFiles));
+
$cssFiles = self::sortCssFiles($cssFiles);
+
+ // We also look for the currently enabled theme and add CSS from the json
+ $theme = PluginsManager::getInstance()->getThemeEnabled();
+ if($theme) {
+ $info = $theme->getInformation();
+ if(isset($info['stylesheet'])) {
+ $themeStylesheetFile = 'plugins/'. $theme->getPluginName() . '/' . $info['stylesheet'];
+ }
+ $cssFiles[] = $themeStylesheetFile;
+ }
return $cssFiles;
}
diff --git a/core/Common.php b/core/Common.php
index ceb905193c..9b7373ef2c 100644
--- a/core/Common.php
+++ b/core/Common.php
@@ -15,7 +15,7 @@ use Piwik\IP;
use Piwik\Tracker;
use Piwik\Tracker\Cache;
use Piwik\PluginsManager;
-use Piwik_UserCountry_LocationProvider_Default;
+use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider;
/**
* Static class providing functions used by both the CORE of Piwik and the visitor Tracking engine.
@@ -28,8 +28,6 @@ use Piwik_UserCountry_LocationProvider_Default;
*/
class Common
{
- const CLASSES_PREFIX = 'Piwik_';
-
/**
* Const used to map the referer type to an integer in the log_visit table
*/
@@ -1516,27 +1514,11 @@ class Common
{
$cache = Cache::getCacheGeneral();
return empty($cache['currentLocationProviderId'])
- ? Piwik_UserCountry_LocationProvider_Default::ID
+ ? DefaultProvider::ID
: $cache['currentLocationProviderId'];
}
/**
- * Unprefix class name (if needed)
- *
- * @param string $class
- * @return string
- */
- public static function unprefixClass($class)
- {
- $lenPrefix = strlen(self::CLASSES_PREFIX);
- if (!strncmp($class, self::CLASSES_PREFIX, $lenPrefix)) {
- return substr($class, $lenPrefix);
- }
- return $class;
- }
-
-
- /**
* Mark orphaned object for garbage collection
*
* For more information: @link http://dev.piwik.org/trac/ticket/374
diff --git a/core/Controller.php b/core/Controller.php
index ee5b5ada1b..b1d394430d 100644
--- a/core/Controller.php
+++ b/core/Controller.php
@@ -22,13 +22,13 @@ use Piwik\Access;
use Piwik\NoAccessException;
use Piwik\Date;
use Piwik\Site;
-use Piwik_API_API;
+use Piwik\Plugins\API\API;
use Piwik\API\Request;
use Piwik\FrontController;
-use Piwik_LanguagesManager;
-use Piwik_SitesManager_API;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
use Piwik\Url;
-use Piwik_UsersManager_API;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
use Piwik\View;
use Piwik\ViewDataTable;
use Zend_Registry;
@@ -81,8 +81,9 @@ abstract class Controller
protected function init()
{
- $aPluginName = explode('_', get_class($this));
- $this->pluginName = $aPluginName[1];
+ $aPluginName = explode('\\', get_class($this));
+ $this->pluginName = $aPluginName[2];
+
$date = Common::getRequestVar('date', 'yesterday', 'string');
try {
$this->idSite = Common::getRequestVar('idSite', false, 'int');
@@ -203,7 +204,7 @@ abstract class Controller
$idSite = Common::getRequestVar('idSite');
$period = Common::getRequestVar('period');
$date = Common::getRequestVar('date');
- $meta = Piwik_API_API::getInstance()->getReportMetadata($idSite, $period, $date);
+ $meta = API::getInstance()->getReportMetadata($idSite, $period, $date);
$columns = array_merge($columnsToDisplay, $selectableColumns);
$translations = array();
@@ -424,8 +425,8 @@ abstract class Controller
$view->startDate = $dateStart;
$view->endDate = $dateEnd;
- $language = Piwik_LanguagesManager::getLanguageForSession();
- $view->language = !empty($language) ? $language : Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ $language = LanguagesManager::getLanguageForSession();
+ $view->language = !empty($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
$view->config_action_url_category_delimiter = Config::getInstance()->General['action_url_category_delimiter'];
@@ -448,10 +449,10 @@ abstract class Controller
$view->isSuperUser = Access::getInstance()->isSuperUser();
$view->hasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
$view->isCustomLogo = Config::getInstance()->branding['use_custom_logo'];
- $view->logoHeader = Piwik_API_API::getInstance()->getHeaderLogoUrl();
- $view->logoLarge = Piwik_API_API::getInstance()->getLogoUrl();
- $view->logoSVG = Piwik_API_API::getInstance()->getSVGLogoUrl();
- $view->hasSVGLogo = Piwik_API_API::getInstance()->hasSVGLogo();
+ $view->logoHeader = API::getInstance()->getHeaderLogoUrl();
+ $view->logoLarge = API::getInstance()->getLogoUrl();
+ $view->logoSVG = API::getInstance()->getSVGLogoUrl();
+ $view->hasSVGLogo = API::getInstance()->hasSVGLogo();
$view->enableFrames = Config::getInstance()->General['enable_framed_pages']
|| @Config::getInstance()->General['enable_framed_logins'];
@@ -637,7 +638,7 @@ abstract class Controller
$defaultWebsiteId = false;
// User preference: default website ID to load
- $defaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
+ $defaultReport = UsersManagerAPI::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), UsersManagerAPI::PREFERENCE_DEFAULT_REPORT);
if (is_numeric($defaultReport)) {
$defaultWebsiteId = $defaultReport;
}
@@ -648,7 +649,7 @@ abstract class Controller
return $defaultWebsiteId;
}
- $sitesId = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
+ $sitesId = SitesManagerAPI::getInstance()->getSitesIdWithAtLeastViewAccess();
if (!empty($sitesId)) {
return $sitesId[0];
}
@@ -663,7 +664,7 @@ abstract class Controller
protected function getDefaultDate()
{
// NOTE: a change in this function might mean a change in plugins/UsersManager/javascripts/usersSettings.js as well
- $userSettingsDate = Piwik_UsersManager_API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE);
+ $userSettingsDate = UsersManagerAPI::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), UsersManagerAPI::PREFERENCE_DEFAULT_REPORT_DATE);
if ($userSettingsDate == 'yesterday') {
return $userSettingsDate;
}
@@ -683,7 +684,7 @@ abstract class Controller
*/
protected function getDefaultPeriod()
{
- $userSettingsDate = Piwik_UsersManager_API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE);
+ $userSettingsDate = UsersManagerAPI::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), UsersManagerAPI::PREFERENCE_DEFAULT_REPORT_DATE);
if ($userSettingsDate === false) {
return Config::getInstance()->General['default_period'];
}
diff --git a/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php b/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php
index 92ad07185c..d22c61a83f 100644
--- a/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php
+++ b/core/DataTable/Filter/ColumnCallbackAddColumnPercentage.php
@@ -22,7 +22,7 @@ use Piwik\DataTable\Filter\ColumnCallbackAddColumnQuotient;
* You can also specify the precision of the percentage value to be displayed (defaults to 0, eg "11%")
*
* Usage:
- * $nbVisits = Piwik_VisitsSummary_API::getInstance()->getVisits($idSite, $period, $date);
+ * $nbVisits = API::getInstance()->getVisits($idSite, $period, $date);
* $dataTable->queueFilter('ColumnCallbackAddColumnPercentage', array('nb_visits', 'nb_visits_percentage', $nbVisits, 1));
*
* @package Piwik
diff --git a/core/DataTable/Renderer.php b/core/DataTable/Renderer.php
index 928ae2ee67..d62514c1f4 100644
--- a/core/DataTable/Renderer.php
+++ b/core/DataTable/Renderer.php
@@ -304,7 +304,7 @@ abstract class Renderer
$this->apiMetaData = false;
}
- $api = \Piwik_API_API::getInstance();
+ $api = \Piwik\Plugins\API\API::getInstance();
$meta = $api->getMetadata($this->idSite, $apiModule, $apiAction);
if (is_array($meta[0])) {
$meta = $meta[0];
diff --git a/core/Db/Schema.php b/core/Db/Schema.php
index 9064a6a908..4a86ce9763 100644
--- a/core/Db/Schema.php
+++ b/core/Db/Schema.php
@@ -116,7 +116,7 @@ class Schema
$schemas = array();
foreach ($schemaNames as $schemaName) {
- $className = 'Piwik_Db_Schema_' . $schemaName;
+ $className = __NAMESPACE__ . '\\Schema\\' . $schemaName;
if (call_user_func(array($className, 'isAvailable'))) {
$schemas[] = $schemaName;
}
diff --git a/core/FrontController.php b/core/FrontController.php
index 4b267bfba6..88ddad8cf8 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -99,7 +99,7 @@ class FrontController
throw new PluginDeactivatedException($module);
}
- $controllerClassName = 'Piwik_' . $module . '_Controller';
+ $controllerClassName = $this->getClassNameController( $module );
// FrontController's autoloader
if (!class_exists($controllerClassName, false)) {
@@ -110,7 +110,9 @@ class FrontController
require_once $moduleController; // prefixed by PIWIK_INCLUDE_PATH
}
- $controller = new $controllerClassName();
+ $class = $this->getClassNameController($module);
+ /** @var $controller Controller */
+ $controller = new $class;
if ($action === false) {
$action = $controller->getDefaultAction();
}
@@ -135,6 +137,11 @@ class FrontController
}
}
+ protected function getClassNameController($module)
+ {
+ return "\\Piwik\\Plugins\\$module\\Controller";
+ }
+
/**
* Often plugins controller display stuff using echo/print.
* Using this function instead of dispatch() returns the output string form the actions calls.
@@ -365,4 +372,4 @@ class PluginDeactivatedException extends Exception
{
parent::__construct("The plugin $module is not enabled. You can activate the plugin on Settings > Plugins page in Piwik.");
}
-} \ No newline at end of file
+}
diff --git a/core/Loader.php b/core/Loader.php
index fc913112e9..927fbdc797 100644
--- a/core/Loader.php
+++ b/core/Loader.php
@@ -46,7 +46,13 @@ class Loader
return $class;
}
- $vendorPrefixToRemove = 'Piwik/';
+ $class = self::removePrefix($class, 'Piwik/');
+ $class = self::removePrefix($class, 'Plugins/');
+ return $class;
+ }
+
+ protected static function removePrefix($class, $vendorPrefixToRemove)
+ {
if (strpos($class, $vendorPrefixToRemove) === 0) {
return substr($class, strlen($vendorPrefixToRemove));
}
diff --git a/core/Menu/MenuAbstract.php b/core/Menu/MenuAbstract.php
index 5bb4adb39c..a0fa8c4c2b 100644
--- a/core/Menu/MenuAbstract.php
+++ b/core/Menu/MenuAbstract.php
@@ -11,7 +11,7 @@
namespace Piwik\Menu;
use Piwik\Common;
-use Piwik_SitesManager_API;
+use Piwik\Plugins\SitesManager\API;
/**
* @package Piwik_Menu
@@ -60,7 +60,7 @@ abstract class MenuAbstract
if ($displayedForCurrentUser) {
// make sure the idSite value used is numeric (hack-y fix for #3426)
if (!is_numeric(Common::getRequestVar('idSite', false))) {
- $idSites = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
+ $idSites = API::getInstance()->getSitesIdWithAtLeastViewAccess();
$url['idSite'] = reset($idSites);
}
diff --git a/core/Period.php b/core/Period.php
index 725bc71ba5..b8867cbea5 100644
--- a/core/Period.php
+++ b/core/Period.php
@@ -19,16 +19,6 @@ use Piwik\Period\Week;
use Piwik\Period\Year;
/**
- * Creating a new Period subclass:
- *
- * Every overloaded method must start with the code
- * if(!$this->subperiodsProcessed)
- * {
- * $this->generate();
- * }
- * that checks whether the subperiods have already been computed.
- * This is for performance improvements, computing the subperiods is done a per demand basis.
- *
* @package Piwik
* @subpackage Period
*/
@@ -174,6 +164,7 @@ abstract class Period
return $this->getDate();
}
$periods = $this->getSubperiods();
+ /** @var $currentPeriod Period */
$currentPeriod = $periods[0];
while ($currentPeriod->getNumberOfSubperiods() > 0) {
$periods = $currentPeriod->getSubperiods();
@@ -196,6 +187,7 @@ abstract class Period
return $this->getDate();
}
$periods = $this->getSubperiods();
+ /** @var $currentPeriod Period */
$currentPeriod = $periods[count($periods) - 1];
while ($currentPeriod->getNumberOfSubperiods() > 0) {
$periods = $currentPeriod->getSubperiods();
diff --git a/core/Piwik.php b/core/Piwik.php
index a2196d87a9..af4a187c4b 100644
--- a/core/Piwik.php
+++ b/core/Piwik.php
@@ -25,7 +25,7 @@ use Piwik\Tracker;
use Piwik\Tracker\Cache;
use Piwik\Tracker\GoalManager;
use Piwik\Url;
-use Piwik_UsersManager_API;
+use Piwik\Plugins\UsersManager\API;
use Piwik\View;
use Piwik\Log\ScreenFormatter;
use Zend_Registry;
@@ -1575,7 +1575,7 @@ class Piwik
static public function getCurrentUserEmail()
{
if (!Piwik::isUserIsSuperUser()) {
- $user = Piwik_UsersManager_API::getInstance()->getUser(Piwik::getCurrentUserLogin());
+ $user = API::getInstance()->getUser(Piwik::getCurrentUserLogin());
return $user['email'];
}
return self::getSuperUserEmail();
diff --git a/core/Plugin.php b/core/Plugin.php
index 444fb1568d..03db5df17c 100644
--- a/core/Plugin.php
+++ b/core/Plugin.php
@@ -48,7 +48,8 @@ class Plugin
public function __construct($pluginName = false)
{
if (empty($pluginName)) {
- $pluginName = Common::unprefixClass(get_class($this));
+ $pluginName = explode('\\', get_class($this));
+ $pluginName = end($pluginName);
}
$this->pluginName = $pluginName;
@@ -162,7 +163,7 @@ class Plugin
/**
* Returns the plugin's base class name without the "Piwik_" prefix,
- * e.g., "UserCountry" when the plugin class is "Piwik_UserCountry"
+ * e.g., "UserCountry" when the plugin class is "UserCountry"
*
* @return string
*/
diff --git a/core/PluginsArchiver.php b/core/PluginsArchiver.php
index 981c6fbce5..e54201c4ef 100644
--- a/core/PluginsArchiver.php
+++ b/core/PluginsArchiver.php
@@ -39,8 +39,11 @@ abstract class PluginsArchiver
// todo: review this concept, each plugin should somehow maintain the list of report names they generate
public function shouldArchive()
{
- $pluginName = Common::unprefixClass(get_class($this));
- $pluginName = str_replace("_Archiver", "", $pluginName);
+ $className = get_class($this);
+ $pluginName = str_replace(array("Piwik\\Plugins\\", "\\Archiver"), "", $className);
+ if(strpos($pluginName, "\\") !== false) {
+ throw new \Exception("unexpected plugin name $pluginName in shouldArchive()");
+ }
return $this->getProcessor()->shouldProcessReportsForPlugin($pluginName);
}
diff --git a/core/PluginsManager.php b/core/PluginsManager.php
index 0b8bcabe58..51a22ba8df 100644
--- a/core/PluginsManager.php
+++ b/core/PluginsManager.php
@@ -286,8 +286,9 @@ class PluginsManager
}
// Only one theme enabled at a time
- $themeAlreadyEnabled = $this->getThemeEnabled();
- if($themeAlreadyEnabled) {
+ $themeEnabled = $this->getThemeEnabled();
+ if($themeEnabled) {
+ $themeAlreadyEnabled = $themeEnabled->getPluginName();
$plugin = $this->loadPlugin($pluginName);
if($plugin->isTheme()) {
$plugins = $this->deactivatePlugin( $themeAlreadyEnabled, $plugins );
@@ -328,16 +329,16 @@ class PluginsManager
* Returns the name of the non default theme currently enabled.
* If Zeitgeist is enabled, returns false (nb: Zeitgeist cannot be disabled)
*
- * @return string
+ * @return Plugin
*/
- protected function getThemeEnabled()
+ public function getThemeEnabled()
{
$plugins = $this->getLoadedPlugins();
foreach($plugins as $plugin) {
/* @var $plugin Plugin */
if($plugin->isTheme()
&& $plugin->getPluginName() != self::DEFAULT_THEME) {
- return $plugin->getPluginName();
+ return $plugin;
}
}
return false;
@@ -405,13 +406,13 @@ class PluginsManager
}
/**
- * Returns an array containing the plugins class names (eg. 'Piwik_UserCountry' and NOT 'UserCountry')
+ * Returns an array containing the plugins class names (eg. 'UserCountry' and NOT 'UserCountry')
*
* @return array
*/
public function getLoadedPluginsName()
{
- return array_map('get_class', $this->getLoadedPlugins());
+ return array_keys($this->getLoadedPlugins());
}
/**
@@ -466,7 +467,7 @@ class PluginsManager
/**
* Loads the plugin filename and instantiates the plugin with the given name, eg. UserCountry
- * Do NOT give the class name ie. Piwik_UserCountry, but give the plugin name ie. UserCountry
+ * Do NOT give the class name ie. UserCountry, but give the plugin name ie. UserCountry
*
* @param string $pluginName
* @throws \Exception
@@ -494,7 +495,7 @@ class PluginsManager
protected function makePluginClass($pluginName)
{
$pluginFileName = sprintf("%s/%s.php", $pluginName, $pluginName);
- $pluginClassName = sprintf('Piwik_%s', $pluginName);
+ $pluginClassName = $pluginName;
if (!Common::isValidFilename($pluginName)) {
throw new \Exception(sprintf("The plugin filename '%s' is not a valid filename", $pluginFileName));
@@ -510,10 +511,11 @@ class PluginsManager
require_once $path;
- if (!class_exists($pluginClassName, false)) {
+ $namespacedClass = $this->getClassNamePlugin($pluginName);
+ if(!class_exists($namespacedClass, false)) {
throw new \Exception("The class $pluginClassName couldn't be found in the file '$path'");
}
- $newPlugin = new $pluginClassName();
+ $newPlugin = new $namespacedClass;
if (!($newPlugin instanceof Plugin)) {
throw new \Exception("The plugin $pluginClassName in the file $path must inherit from Plugin.");
@@ -521,6 +523,15 @@ class PluginsManager
return $newPlugin;
}
+ protected function getClassNamePlugin($pluginName)
+ {
+ $className = $pluginName;
+ if($pluginName == 'API') {
+ $className = 'Plugin';
+ }
+ return "\\Piwik\\Plugins\\$pluginName\\$className";
+ }
+
/**
* Unload plugin
*
@@ -669,6 +680,7 @@ class PluginsManager
// is the plugin already installed or is it the first time we activate it?
$pluginsInstalled = $this->getInstalledPluginsName();
+
if (!in_array($pluginName, $pluginsInstalled)) {
$this->installPlugin($plugin);
$pluginsInstalled[] = $pluginName;
diff --git a/core/ReportRenderer.php b/core/ReportRenderer.php
index d2d51f1425..f724935209 100644
--- a/core/ReportRenderer.php
+++ b/core/ReportRenderer.php
@@ -17,7 +17,7 @@ use Piwik\Piwik;
use Piwik\DataTable;
use Piwik\Loader;
use Piwik\API\Request;
-use Piwik_ImageGraph_API;
+use Piwik\Plugins\ImageGraph\API;
/**
* A Report Renderer produces user friendly renderings of any given Piwik report.
@@ -122,7 +122,7 @@ abstract class ReportRenderer
* Render the provided report.
* Multiple calls to this method before calling outputRendering appends each report content.
*
- * @param array $processedReport @see Piwik_API_API::getProcessedReport()
+ * @param array $processedReport @see API::getProcessedReport()
*/
abstract public function renderReport($processedReport);
@@ -235,7 +235,7 @@ abstract class ReportRenderer
}
$requestGraph = $imageGraphUrl .
- '&outputType=' . Piwik_ImageGraph_API::GRAPH_OUTPUT_PHP .
+ '&outputType=' . API::GRAPH_OUTPUT_PHP .
'&format=original&serialize=0' .
'&filter_truncate=' .
'&width=' . $width .
diff --git a/core/ReportRenderer/Html.php b/core/ReportRenderer/Html.php
index e1d30734c4..cb8d33faa0 100644
--- a/core/ReportRenderer/Html.php
+++ b/core/ReportRenderer/Html.php
@@ -13,7 +13,7 @@ namespace Piwik\ReportRenderer;
use Piwik\Piwik;
use Piwik\View;
use Piwik\ReportRenderer;
-use Piwik_API_API;
+use Piwik\Plugins\API\API;
/**
*
@@ -121,7 +121,7 @@ class Html extends ReportRenderer
$view->assign("reportTableRowTextSize", self::REPORT_TABLE_ROW_TEXT_SIZE);
$view->assign("reportBackToTopTextSize", self::REPORT_BACK_TO_TOP_TEXT_SIZE);
$view->assign("currentPath", Piwik::getPiwikUrl());
- $view->assign("logoHeader", Piwik_API_API::getInstance()->getHeaderLogoUrl());
+ $view->assign("logoHeader", API::getInstance()->getHeaderLogoUrl());
}
public function renderReport($processedReport)
diff --git a/core/ReportRenderer/Pdf.php b/core/ReportRenderer/Pdf.php
index 192a7f9133..c3ab722e27 100644
--- a/core/ReportRenderer/Pdf.php
+++ b/core/ReportRenderer/Pdf.php
@@ -13,7 +13,7 @@ namespace Piwik\ReportRenderer;
use Piwik\Common;
use Piwik\TCPDF;
use Piwik\ReportRenderer;
-use Piwik_API_API;
+use Piwik\Plugins\API\API;
/**
* @see libs/tcpdf
@@ -166,7 +166,7 @@ class Pdf extends ReportRenderer
$this->TCPDF->Bookmark(Piwik_Translate('PDFReports_FrontPage'));
// logo
- $this->TCPDF->Image(Piwik_API_API::getInstance()->getLogoUrl(true), $this->logoImagePosition[0], $this->logoImagePosition[1], 180 / $factor = 2, 0, $type = '', $link = '', $align = '', $resize = false, $dpi = 300);
+ $this->TCPDF->Image(API::getInstance()->getLogoUrl(true), $this->logoImagePosition[0], $this->logoImagePosition[1], 180 / $factor = 2, 0, $type = '', $link = '', $align = '', $resize = false, $dpi = 300);
$this->TCPDF->Ln(8);
// report title
diff --git a/core/ScheduledTask.php b/core/ScheduledTask.php
index 8d9c368c54..5262e7cbc3 100644
--- a/core/ScheduledTask.php
+++ b/core/ScheduledTask.php
@@ -66,7 +66,7 @@ class ScheduledTask
function __construct($_objectInstance, $_methodName, $_methodParameter, $_scheduledTime, $_priority = self::NORMAL_PRIORITY)
{
- $this->className = get_class($_objectInstance);
+ $this->className = $this->getClassNameFromInstance($_objectInstance);
if ($_priority < self::HIGHEST_PRIORITY || $_priority > self::LOWEST_PRIORITY) {
throw new Exception("Invalid priority for ScheduledTask '$this->className.$_methodName': $_priority");
@@ -79,6 +79,13 @@ class ScheduledTask
$this->priority = $_priority;
}
+ protected function getClassNameFromInstance($_objectInstance)
+ {
+ $namespaced = get_class($_objectInstance);
+ $class = explode('\\', $namespaced);
+ return end($class);
+ }
+
/**
* Return the object instance on which the method should be executed
* @return string
diff --git a/core/Segment.php b/core/Segment.php
index cfc82c86e7..8687362a56 100644
--- a/core/Segment.php
+++ b/core/Segment.php
@@ -12,7 +12,7 @@ namespace Piwik;
use Exception;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik_API_API;
+use Piwik\Plugins\API\API;
use Piwik\SegmentExpression;
/**
@@ -90,7 +90,7 @@ class Segment
protected function getCleanedExpression($expression)
{
if (empty($this->availableSegments)) {
- $this->availableSegments = Piwik_API_API::getInstance()->getSegmentsMetadata($this->idSites, $_hideImplementationData = false);
+ $this->availableSegments = API::getInstance()->getSegmentsMetadata($this->idSites, $_hideImplementationData = false);
}
$name = $expression[0];
@@ -121,7 +121,7 @@ class Segment
$value = call_user_func($segment['sqlFilter'], $value, $segment['sqlSegment'], $matchType, $name);
// sqlFilter-callbacks might return arrays for more complex cases
- // e.g. see Piwik_Actions::getIdActionFromSegment()
+ // e.g. see Actions::getIdActionFromSegment()
if (is_array($value)
&& isset($value['SQL'])
) {
diff --git a/core/Site.php b/core/Site.php
index b0824e77ee..eb13215e34 100644
--- a/core/Site.php
+++ b/core/Site.php
@@ -12,7 +12,7 @@
namespace Piwik;
use Exception;
use Piwik\Date;
-use Piwik_SitesManager_API;
+use Piwik\Plugins\SitesManager\API;
/**
*
@@ -37,7 +37,7 @@ class Site
{
$this->id = (int)$idsite;
if (!isset(self::$infoSites[$this->id])) {
- self::$infoSites[$this->id] = Piwik_SitesManager_API::getInstance()->getSiteFromId($this->id);
+ self::$infoSites[$this->id] = API::getInstance()->getSiteFromId($this->id);
}
}
@@ -215,7 +215,7 @@ class Site
static public function getIdSitesFromIdSitesString($ids, $_restrictSitesToLogin = false)
{
if ($ids === 'all') {
- return Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess($_restrictSitesToLogin);
+ return API::getInstance()->getSitesIdWithAtLeastViewAccess($_restrictSitesToLogin);
}
if (!is_array($ids)) {
@@ -256,7 +256,7 @@ class Site
$idsite = (int)$idsite;
if (!isset(self::$infoSites[$idsite])) {
- self::$infoSites[$idsite] = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
+ self::$infoSites[$idsite] = API::getInstance()->getSiteFromId($idsite);
}
return self::$infoSites[$idsite][$field];
diff --git a/core/Tracker/Cache.php b/core/Tracker/Cache.php
index 1e6423d8f6..7319818e41 100644
--- a/core/Tracker/Cache.php
+++ b/core/Tracker/Cache.php
@@ -15,7 +15,7 @@ use Piwik\Config;
use Piwik\Piwik;
use Piwik\CacheFile;
use Piwik\Tracker;
-use Piwik_UserCountry_LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider;
/**
* Simple cache mechanism used in Tracker to avoid requesting settings from mysql on every request
@@ -104,7 +104,7 @@ class Cache
$cacheContent = array(
'isBrowserTriggerEnabled' => Rules::isBrowserTriggerEnabled(),
'lastTrackerCronRun' => Piwik_GetOption('lastTrackerCronRun'),
- 'currentLocationProviderId' => Piwik_UserCountry_LocationProvider::getCurrentProviderId(),
+ 'currentLocationProviderId' => LocationProvider::getCurrentProviderId(),
);
self::setCacheGeneral($cacheContent);
return $cacheContent;
diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php
index 05052b0f5c..dce2aceaf3 100644
--- a/core/Tracker/Request.php
+++ b/core/Tracker/Request.php
@@ -8,7 +8,7 @@ use Piwik\Cookie;
use Piwik\IP;
use Piwik\Tracker;
use Piwik\Tracker\Cache;
-use Piwik_UserCountry_LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider;
/**
* Piwik - Open source web analytics
@@ -493,11 +493,11 @@ class Request
// check for location override query parameters (ie, lat, long, country, region, city)
$locationOverrideParams = array(
- 'country' => array('string', Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY),
- 'region' => array('string', Piwik_UserCountry_LocationProvider::REGION_CODE_KEY),
- 'city' => array('string', Piwik_UserCountry_LocationProvider::CITY_NAME_KEY),
- 'lat' => array('float', Piwik_UserCountry_LocationProvider::LATITUDE_KEY),
- 'long' => array('float', Piwik_UserCountry_LocationProvider::LONGITUDE_KEY),
+ 'country' => array('string', LocationProvider::COUNTRY_CODE_KEY),
+ 'region' => array('string', LocationProvider::REGION_CODE_KEY),
+ 'city' => array('string', LocationProvider::CITY_NAME_KEY),
+ 'lat' => array('float', LocationProvider::LATITUDE_KEY),
+ 'long' => array('float', LocationProvider::LONGITUDE_KEY),
);
foreach ($locationOverrideParams as $queryParamName => $info) {
list($type, $locationResultKey) = $info;
diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php
index 0b478836ea..74ab001bae 100644
--- a/core/Tracker/Visit.php
+++ b/core/Tracker/Visit.php
@@ -39,7 +39,7 @@ use Piwik\Tracker\Request;
use Piwik\Tracker\Referrer;
use Exception;
use Piwik\Tracker\VisitExcluded;
-use Piwik_UserCountry_LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider;
use UserAgentParser;
/**
@@ -514,7 +514,7 @@ class Visit implements Tracker\VisitInterface
* Returns the location of the visitor, based on the visitor's IP and browser language.
*
* @param string $browserLang
- * @return array See Piwik_UserCountry_LocationProvider::getLocation for more info.
+ * @return array See LocationProvider::getLocation for more info.
*/
private function getVisitorLocation($browserLang)
{
@@ -535,19 +535,19 @@ class Visit implements Tracker\VisitInterface
/**
* Sets visitor info array with location info.
*
- * @param array $location See Piwik_UserCountry_LocationProvider::getLocation for more info.
+ * @param array $location See LocationProvider::getLocation for more info.
*/
private function updateVisitInfoWithLocation($location)
{
static $logVisitToLowerLocationMapping = array(
- 'location_country' => Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY,
+ 'location_country' => LocationProvider::COUNTRY_CODE_KEY,
);
static $logVisitToLocationMapping = array(
- 'location_region' => Piwik_UserCountry_LocationProvider::REGION_CODE_KEY,
- 'location_city' => Piwik_UserCountry_LocationProvider::CITY_NAME_KEY,
- 'location_latitude' => Piwik_UserCountry_LocationProvider::LATITUDE_KEY,
- 'location_longitude' => Piwik_UserCountry_LocationProvider::LONGITUDE_KEY,
+ 'location_region' => LocationProvider::REGION_CODE_KEY,
+ 'location_city' => LocationProvider::CITY_NAME_KEY,
+ 'location_latitude' => LocationProvider::LATITUDE_KEY,
+ 'location_longitude' => LocationProvider::LONGITUDE_KEY,
);
foreach ($logVisitToLowerLocationMapping as $column => $locationKey) {
@@ -563,17 +563,17 @@ class Visit implements Tracker\VisitInterface
}
// if the location has provider/organization info, set it
- if (!empty($location[Piwik_UserCountry_LocationProvider::ISP_KEY])) {
- $providerValue = $location[Piwik_UserCountry_LocationProvider::ISP_KEY];
+ if (!empty($location[LocationProvider::ISP_KEY])) {
+ $providerValue = $location[LocationProvider::ISP_KEY];
// if the org is set and not the same as the isp, add it to the provider value
- if (!empty($location[Piwik_UserCountry_LocationProvider::ORG_KEY])
- && $location[Piwik_UserCountry_LocationProvider::ORG_KEY] != $providerValue
+ if (!empty($location[LocationProvider::ORG_KEY])
+ && $location[LocationProvider::ORG_KEY] != $providerValue
) {
- $providerValue .= ' - ' . $location[Piwik_UserCountry_LocationProvider::ORG_KEY];
+ $providerValue .= ' - ' . $location[LocationProvider::ORG_KEY];
}
- } else if (!empty($location[Piwik_UserCountry_LocationProvider::ORG_KEY])) {
- $providerValue = $location[Piwik_UserCountry_LocationProvider::ORG_KEY];
+ } else if (!empty($location[LocationProvider::ORG_KEY])) {
+ $providerValue = $location[LocationProvider::ORG_KEY];
}
if (isset($providerValue)) {
diff --git a/core/Twig.php b/core/Twig.php
index a5a9cea40e..5f6550512e 100644
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -11,6 +11,7 @@
namespace Piwik;
use Exception;
+use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\AssetManager;
@@ -239,7 +240,6 @@ class Twig
{
$plugins = PluginsManager::getInstance()->getLoadedPluginsName();
foreach ($plugins as $name) {
- $name = Common::unprefixClass($name);
$path = sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, $name);
if (is_dir($path)) {
$loader->addPath(PIWIK_INCLUDE_PATH . '/plugins/' . $name . '/templates', $name);
diff --git a/core/UpdateCheck.php b/core/UpdateCheck.php
index 08e4c02a1a..770a69eff3 100644
--- a/core/UpdateCheck.php
+++ b/core/UpdateCheck.php
@@ -14,7 +14,7 @@ use Exception;
use Piwik\Config;
use Piwik\Common;
use Piwik\Http;
-use Piwik_SitesManager_API;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Url;
use Piwik\Version;
@@ -55,7 +55,7 @@ class UpdateCheck
'php_version' => PHP_VERSION,
'url' => Url::getCurrentUrlWithoutQueryString(),
'trigger' => Common::getRequestVar('module', '', 'string'),
- 'timezone' => Piwik_SitesManager_API::getInstance()->getDefaultTimezone(),
+ 'timezone' => API::getInstance()->getDefaultTimezone(),
);
$url = Config::getInstance()->General['api_service_url']
diff --git a/core/Updater.php b/core/Updater.php
index db405da9e1..eca0d3fd4f 100644
--- a/core/Updater.php
+++ b/core/Updater.php
@@ -141,6 +141,7 @@ class Updater
private function getUpdateClassName($componentName, $fileVersion)
{
+ ////unprefixClass TODOA FIXME
$suffix = strtolower(str_replace(array('-', '.'), '_', $fileVersion));
if ($componentName == 'core') {
return 'Piwik_Updates_' . $suffix;
diff --git a/core/Updates/0.2.34.php b/core/Updates/0.2.34.php
index 785627f875..5ad44f5268 100644
--- a/core/Updates/0.2.34.php
+++ b/core/Updates/0.2.34.php
@@ -9,6 +9,7 @@
* @package Updates
*/
use Piwik\Piwik;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Tracker\Cache;
use Piwik\Updates;
@@ -21,7 +22,7 @@ class Piwik_Updates_0_2_34 extends Updates
{
// force regeneration of cache files following #648
Piwik::setUserIsSuperUser();
- $allSiteIds = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $allSiteIds = API::getInstance()->getAllSitesId();
Cache::regenerateCacheWebsiteAttributes($allSiteIds);
}
}
diff --git a/core/Updates/0.6.2.php b/core/Updates/0.6.2.php
index 74bbe6b6b6..af541713a2 100644
--- a/core/Updates/0.6.2.php
+++ b/core/Updates/0.6.2.php
@@ -9,6 +9,7 @@
* @package Updates
*/
use Piwik\Piwik;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Tracker\Cache;
use Piwik\Updates;
@@ -39,7 +40,7 @@ class Piwik_Updates_0_6_2 extends Updates
// force regeneration of cache files
Piwik::setUserIsSuperUser();
- $allSiteIds = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $allSiteIds = API::getInstance()->getAllSitesId();
Cache::regenerateCacheWebsiteAttributes($allSiteIds);
}
}
diff --git a/core/Updates/1.8.3-b1.php b/core/Updates/1.8.3-b1.php
index 84d9ce56d5..f217635ebc 100644
--- a/core/Updates/1.8.3-b1.php
+++ b/core/Updates/1.8.3-b1.php
@@ -9,6 +9,7 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Plugins\PDFReports\PDFReports;
use Piwik\Updater;
use Piwik\Updates;
use Piwik\Db;
@@ -78,11 +79,11 @@ class Piwik_Updates_1_8_3_b1 extends Updates
$parameters = array();
if (!is_null($additional_emails)) {
- $parameters[Piwik_PDFReports::ADDITIONAL_EMAILS_PARAMETER] = preg_split('/,/', $additional_emails);
+ $parameters[PDFReports::ADDITIONAL_EMAILS_PARAMETER] = preg_split('/,/', $additional_emails);
}
- $parameters[Piwik_PDFReports::EMAIL_ME_PARAMETER] = is_null($email_me) ? Piwik_PDFReports::EMAIL_ME_PARAMETER_DEFAULT_VALUE : (bool)$email_me;
- $parameters[Piwik_PDFReports::DISPLAY_FORMAT_PARAMETER] = $display_format;
+ $parameters[PDFReports::EMAIL_ME_PARAMETER] = is_null($email_me) ? PDFReports::EMAIL_ME_PARAMETER_DEFAULT_VALUE : (bool)$email_me;
+ $parameters[PDFReports::DISPLAY_FORMAT_PARAMETER] = $display_format;
Db::query(
'INSERT INTO `' . Common::prefixTable('report') . '` SET
@@ -94,9 +95,9 @@ class Piwik_Updates_1_8_3_b1 extends Updates
$idsite,
$login,
$description,
- is_null($period) ? Piwik_PDFReports::DEFAULT_PERIOD : $period,
- Piwik_PDFReports::EMAIL_TYPE,
- is_null($format) ? Piwik_PDFReports::DEFAULT_REPORT_FORMAT : $format,
+ is_null($period) ? PDFReports::DEFAULT_PERIOD : $period,
+ PDFReports::EMAIL_TYPE,
+ is_null($format) ? PDFReports::DEFAULT_REPORT_FORMAT : $format,
Common::json_encode(preg_split('/,/', $reports)),
Common::json_encode($parameters),
$ts_created,
diff --git a/core/View.php b/core/View.php
index e765791b72..9d221c9d9c 100644
--- a/core/View.php
+++ b/core/View.php
@@ -20,8 +20,8 @@ use Piwik\Url;
use Piwik\UpdateCheck;
use Piwik\Twig;
use Piwik\QuickForm2;
-use Piwik_SitesManager_API;
-use Piwik_UsersManager_API;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
use Piwik\View\ViewInterface;
use Twig_Environment;
use Zend_Registry;
@@ -110,7 +110,7 @@ class View implements ViewInterface
$count = Piwik::getWebsitesCountToDisplay();
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess($count);
+ $sites = SitesManagerAPI::getInstance()->getSitesWithAtLeastViewAccess($count);
usort($sites, create_function('$site1, $site2', 'return strcasecmp($site1["name"], $site2["name"]);'));
$this->sites = $sites;
$this->url = Common::sanitizeInputValue(Url::getCurrentUrl());
@@ -128,7 +128,7 @@ class View implements ViewInterface
$this->loginModule = Piwik::getLoginPluginName();
- $user = Piwik_UsersManager_API::getInstance()->getUser($userLogin);
+ $user = UsersManagerAPI::getInstance()->getUser($userLogin);
$this->userAlias = $user['alias'];
} catch (Exception $e) {
// can fail, for example at installation (no plugin loaded yet)
diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php
index a4d2037183..a75b2354d5 100644
--- a/core/ViewDataTable.php
+++ b/core/ViewDataTable.php
@@ -13,6 +13,7 @@ namespace Piwik;
use Piwik\Config;
use Piwik\Metrics;
use Piwik\Period;
+use Piwik\API\Request;
use Piwik\Period\Range;
use Piwik\Piwik;
use Piwik\NoAccessException;
@@ -23,9 +24,7 @@ use Piwik\Url;
use Piwik\Site;
use Piwik\ViewDataTable\Properties;
use Piwik\ViewDataTable\VisualizationPropertiesProxy;
-use Piwik_API_API;
-use Piwik\PluginsManager;
-use Piwik\DataTableVisualization;
+use Piwik\Plugins\API\API;
/**
* This class is used to load (from the API) and customize the output of a given DataTable.
@@ -472,7 +471,7 @@ class ViewDataTable
$requestArray = $this->getRequestArray();
// we make the request to the API
- $request = new API\Request($requestArray);
+ $request = new Request($requestArray);
// and get the DataTable structure
$dataTable = $request->process();
@@ -587,13 +586,13 @@ class ViewDataTable
if (!$this->areGenericFiltersDisabled()) {
// Second, generic filters (Sort, Limit, Replace Column Names, etc.)
$requestArray = $this->getRequestArray();
- $request = API\Request::getRequestArrayFromString($requestArray);
+ $request = Request::getRequestArrayFromString($requestArray);
if ($this->viewProperties['enable_sort'] === false) {
$request['filter_sort_column'] = $request['filter_sort_order'] = '';
}
- $genericFilter = new API\DataTableGenericFilter($request);
+ $genericFilter = new \Piwik\API\DataTableGenericFilter($request);
$genericFilter->filter($this->dataTable);
}
@@ -696,7 +695,7 @@ class ViewDataTable
}
}
- $segment = \Piwik\API\Request::getRawSegmentFromRequest();
+ $segment = Request::getRawSegmentFromRequest();
if(!empty($segment)) {
$requestArray['segment'] = $segment;
}
@@ -729,7 +728,7 @@ class ViewDataTable
// build javascript variables to set
$javascriptVariablesToSet = array();
- $genericFilters = API\DataTableGenericFilter::getGenericFiltersInformation();
+ $genericFilters = \Piwik\API\DataTableGenericFilter::getGenericFiltersInformation();
foreach ($genericFilters as $filter) {
foreach ($filter as $filterVariableName => $filterInfo) {
// if there is a default value for this filter variable we set it
@@ -821,7 +820,7 @@ class ViewDataTable
}
}
- $rawSegment = \Piwik\API\Request::getRawSegmentFromRequest();
+ $rawSegment = Request::getRawSegmentFromRequest();
if(!empty($rawSegment)) {
$javascriptVariablesToSet['segment'] = $rawSegment;
}
@@ -884,7 +883,7 @@ class ViewDataTable
{
$this->viewProperties['metrics_documentation'] = array();
- $report = Piwik_API_API::getInstance()->getMetadata(0, $this->currentControllerName, $this->currentControllerAction);
+ $report = API::getInstance()->getMetadata(0, $this->currentControllerName, $this->currentControllerAction);
$report = $report[0];
if (isset($report['metricsDocumentation'])) {
@@ -978,8 +977,8 @@ class ViewDataTable
$reportYear = $reportDate->toString('Y');
$reportMonth = $reportDate->toString('m');
- if (class_exists('Piwik_PrivacyManager')
- && \Piwik_PrivacyManager::shouldReportBePurged($reportYear, $reportMonth)
+ if (PluginsManager::getInstance()->isPluginActivated('PrivacyManager')
+ && Plugins\PrivacyManager\PrivacyManager::shouldReportBePurged($reportYear, $reportMonth)
) {
return true;
}
@@ -999,7 +998,7 @@ class ViewDataTable
private function getBaseReportUrl($module, $action, $queryParams = array())
{
$params = array_merge($queryParams, array('module' => $module, 'action' => $action));
- return API\Request::getCurrentUrlWithoutGenericFilters($params);
+ return Request::getCurrentUrlWithoutGenericFilters($params);
}
/**
@@ -1013,9 +1012,9 @@ class ViewDataTable
*/
static public function renderReport($pluginName, $apiAction, $fetch = true)
{
- $apiClassName = 'Piwik_' . $pluginName . '_API';
- if (!method_exists($apiClassName::getInstance(), $apiAction)) {
- throw new \Exception("Invalid action name '$apiAction' for '$pluginName' plugin.");
+ $namespacedApiClassName = "\\Piwik\\Plugins\\$pluginName\\API";
+ if (!method_exists($namespacedApiClassName::getInstance(), $apiAction)) {
+ throw new \Exception("$namespacedApiClassName Invalid action name '$apiAction' for '$pluginName' plugin.");
}
$view = self::factory(null, $pluginName.'.'.$apiAction);
@@ -1141,4 +1140,4 @@ class ViewDataTable
{
return is_bool($value) ? (int)$value : $value;
}
-} \ No newline at end of file
+}
diff --git a/misc/cron/archive.php b/misc/cron/archive.php
index bd8dafd715..0225c3a0ec 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;
@@ -325,13 +327,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));
}
}
}
@@ -392,8 +394,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));
@@ -718,7 +720,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;
@@ -732,7 +734,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
@@ -745,7 +747,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) {
@@ -756,7 +758,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);
@@ -767,7 +769,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/>";
}
diff --git a/plugins/API/API.php b/plugins/API/API.php
index d1ea3c6eb8..7058bdb0ce 100644
--- a/plugins/API/API.php
+++ b/plugins/API/API.php
@@ -8,6 +8,8 @@
* @category Piwik_Plugins
* @package Piwik_API
*/
+namespace Piwik\Plugins\API;
+
use Piwik\API\Request;
use Piwik\API\Proxy;
use Piwik\DataTable\Filter\ColumnDelete;
@@ -20,56 +22,11 @@ use Piwik\Date;
use Piwik\DataTable;
use Piwik\Tracker\GoalManager;
use Piwik\Version;
-use Piwik\Plugin;
use Piwik\Translate;
require_once PIWIK_INCLUDE_PATH . '/core/Config.php';
/**
- * @package Piwik_API
- */
-class Piwik_API extends Plugin
-{
- /**
- * @see Piwik_Plugin::getListHooksRegistered
- */
- public function getListHooksRegistered()
- {
- return array(
- 'AssetManager.getCssFiles' => 'getCssFiles',
- 'TopMenu.add' => 'addTopMenu',
- );
- }
-
- public function addTopMenu()
- {
- $apiUrlParams = array('module' => 'API', 'action' => 'listAllAPI', 'segment' => false);
- $tooltip = Piwik_Translate('API_TopLinkTooltip');
-
- Piwik_AddTopMenu('General_API', $apiUrlParams, true, 7, $isHTML = false, $tooltip);
-
- $this->addTopMenuMobileApp();
- }
-
- protected function addTopMenuMobileApp()
- {
- if (empty($_SERVER['HTTP_USER_AGENT'])) {
- return;
- }
- require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php';
- $os = UserAgentParser::getOperatingSystem($_SERVER['HTTP_USER_AGENT']);
- if ($os && in_array($os['id'], array('AND', 'IPD', 'IPA', 'IPH'))) {
- Piwik_AddTopMenu('Piwik Mobile App', array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
- }
- }
-
- public function getCssFiles(&$cssFiles)
- {
- $cssFiles[] = "plugins/API/stylesheets/listAllAPI.less";
- }
-}
-
-/**
* This API is the <a href='http://piwik.org/docs/analytics-api/metadata/' target='_blank'>Metadata API</a>: it gives information about all other available APIs methods, as well as providing
* human readable and more complete outputs than normal API methods.
*
@@ -87,12 +44,12 @@ class Piwik_API extends Plugin
*
* @package Piwik_API
*/
-class Piwik_API_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_API_API
+ * @return \Piwik\Plugins\API\API
*/
static public function getInstance()
{
@@ -230,7 +187,7 @@ class Piwik_API_API
'acceptedValues' => implode(", ", self::$visitEcommerceStatus)
. '. ' . Piwik_Translate('General_EcommerceVisitStatusEg', '"&segment=visitEcommerceStatus==ordered,visitEcommerceStatus==orderedThenAbandonedCart"'),
'sqlSegment' => 'log_visit.visit_goal_buyer',
- 'sqlFilter' => array('Piwik_API_API', 'getVisitEcommerceStatus'),
+ 'sqlFilter' => __NAMESPACE__ . '\API::getVisitEcommerceStatus',
);
$segments[] = array(
@@ -268,7 +225,7 @@ class Piwik_API_API
static public function getVisitEcommerceStatusFromId($id)
{
if (!isset(self::$visitEcommerceStatus[$id])) {
- throw new Exception("Unexpected ECommerce status value ");
+ throw new \Exception("Unexpected ECommerce status value ");
}
return self::$visitEcommerceStatus[$id];
}
@@ -280,7 +237,7 @@ class Piwik_API_API
{
$id = array_search($status, self::$visitEcommerceStatus);
if ($id === false) {
- throw new Exception("Invalid 'visitEcommerceStatus' segment value");
+ throw new \Exception("Invalid 'visitEcommerceStatus' segment value");
}
return $id;
}
@@ -396,8 +353,8 @@ class Piwik_API_API
$period = false, $date = false, $hideMetricsDoc = false, $showSubtableReports = false)
{
Translate::getInstance()->reloadLanguage($language);
- $reporter = new Piwik_API_ProcessedReport();
- $metadata = $reporter->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $language, $period, $date, $hideMetricsDoc, $showSubtableReports);
+ $reporter = new ProcessedReport();
+ $metadata = $reporter->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $language, $period, $date, $hideMetricsDoc, $showSubtableReports);
return $metadata;
}
@@ -415,8 +372,8 @@ class Piwik_API_API
public function getReportMetadata($idSites = '', $period = false, $date = false, $hideMetricsDoc = false,
$showSubtableReports = false)
{
- $reporter = new Piwik_API_ProcessedReport();
- $metadata = $reporter->getReportMetadata($idSites, $period, $date, $hideMetricsDoc, $showSubtableReports);
+ $reporter = new ProcessedReport();
+ $metadata = $reporter->getReportMetadata($idSites, $period, $date, $hideMetricsDoc, $showSubtableReports);
return $metadata;
}
@@ -424,8 +381,8 @@ class Piwik_API_API
$apiParameters = false, $idGoal = false, $language = false,
$showTimer = true, $hideMetricsDoc = false, $idSubtable = false, $showRawMetrics = false)
{
- $reporter = new Piwik_API_ProcessedReport();
- $processed = $reporter->getProcessedReport( $idSite, $period, $date, $apiModule, $apiAction, $segment,
+ $reporter = new ProcessedReport();
+ $processed = $reporter->getProcessedReport($idSite, $period, $date, $apiModule, $apiAction, $segment,
$apiParameters, $idGoal, $language, $showTimer, $hideMetricsDoc, $idSubtable, $showRawMetrics);
return $processed;
@@ -446,7 +403,7 @@ class Piwik_API_API
// find out which columns belong to which plugin
$columnsByPlugin = array();
- $meta = Piwik_API_API::getInstance()->getReportMetadata($idSite, $period, $date);
+ $meta = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite, $period, $date);
foreach ($meta as $reportMeta) {
// scan all *.get reports
if ($reportMeta['action'] == 'get'
@@ -472,7 +429,7 @@ class Piwik_API_API
$params = compact('idSite', 'period', 'date', 'segment', 'idGoal');
foreach ($columnsByPlugin as $plugin => $columns) {
// load the data
- $className = 'Piwik_' . $plugin . '_API';
+ $className = Request::getClassNameAPI($plugin);
$params['columns'] = implode(',', $columns);
$dataTable = Proxy::getInstance()->call($className, 'get', $params);
// make sure the table has all columns
@@ -549,7 +506,7 @@ class Piwik_API_API
*/
public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label = false, $segment = false, $column = false, $language = false, $idGoal = false, $legendAppendMetric = true, $labelUseAbsoluteUrl = true)
{
- $rowEvolution = new Piwik_API_RowEvolution();
+ $rowEvolution = new RowEvolution();
return $rowEvolution->getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label, $segment, $column,
$language, $idGoal, $legendAppendMetric, $labelUseAbsoluteUrl);
}
@@ -603,12 +560,12 @@ class Piwik_API_API
$startDate = Date::now()->subDay(60)->toString();
$requestLastVisits = "method=Live.getLastVisitsDetails
- &idSite=$idSite
- &period=range
- &date=$startDate,today
- &format=original
- &serialize=0
- &flat=1";
+ &idSite=$idSite
+ &period=range
+ &date=$startDate,today
+ &format=original
+ &serialize=0
+ &flat=1";
// Select non empty fields only
// Note: this optimization has only a very minor impact
@@ -663,3 +620,53 @@ class Piwik_API_API
return $doesSegmentNeedActionsInfo;
}
}
+
+/**
+ * @package Piwik_API
+ */
+class Plugin extends \Piwik\Plugin
+{
+ public function __construct()
+ {
+ // this class is named 'Plugin', manually set the 'API' plugin
+ parent::__construct($pluginName = 'API');
+ }
+
+ /**
+ * @see Piwik_Plugin::getListHooksRegistered
+ */
+ public function getListHooksRegistered()
+ {
+ return array(
+ 'AssetManager.getCssFiles' => 'getCssFiles',
+ 'TopMenu.add' => 'addTopMenu',
+ );
+ }
+
+ public function addTopMenu()
+ {
+ $apiUrlParams = array('module' => 'API', 'action' => 'listAllAPI', 'segment' => false);
+ $tooltip = Piwik_Translate('API_TopLinkTooltip');
+
+ Piwik_AddTopMenu('General_API', $apiUrlParams, true, 7, $isHTML = false, $tooltip);
+
+ $this->addTopMenuMobileApp();
+ }
+
+ protected function addTopMenuMobileApp()
+ {
+ if (empty($_SERVER['HTTP_USER_AGENT'])) {
+ return;
+ }
+ require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php';
+ $os = \UserAgentParser::getOperatingSystem($_SERVER['HTTP_USER_AGENT']);
+ if ($os && in_array($os['id'], array('AND', 'IPD', 'IPA', 'IPH'))) {
+ Piwik_AddTopMenu('Piwik Mobile App', array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
+ }
+ }
+
+ public function getCssFiles(&$cssFiles)
+ {
+ $cssFiles[] = "plugins/API/stylesheets/listAllAPI.less";
+ }
+} \ No newline at end of file
diff --git a/plugins/API/Controller.php b/plugins/API/Controller.php
index ed4addae2c..ac8e31ac84 100644
--- a/plugins/API/Controller.php
+++ b/plugins/API/Controller.php
@@ -8,19 +8,21 @@
* @category Piwik_Plugins
* @package Piwik_API
*/
+namespace Piwik\Plugins\API;
+
use Piwik\API\DocumentationGenerator;
use Piwik\API\Request;
use Piwik\API\Proxy;
use Piwik\Config;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\API\API;
use Piwik\View;
/**
*
* @package Piwik_API
*/
-class Piwik_API_Controller extends Controller
+class Controller extends \Piwik\Controller
{
function index()
{
@@ -51,7 +53,7 @@ class Piwik_API_Controller extends Controller
public function listSegments()
{
- $segments = Piwik_API_API::getInstance()->getSegmentsMetadata($this->idSite);
+ $segments = API::getInstance()->getSegmentsMetadata($this->idSite);
$tableDimensions = $tableMetrics = '';
$customVariables = 0;
@@ -98,7 +100,6 @@ class Piwik_API_Controller extends Controller
}
}
-
if ($segment['type'] == 'dimension') {
$tableDimensions .= $output;
} else {
diff --git a/plugins/API/ProcessedReport.php b/plugins/API/ProcessedReport.php
index 3491372420..92e82aa275 100644
--- a/plugins/API/ProcessedReport.php
+++ b/plugins/API/ProcessedReport.php
@@ -1,4 +1,16 @@
<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ * @category Piwik_Plugins
+ * @package Piwik_API
+ */
+namespace Piwik\Plugins\API;
+
+use Exception;
use Piwik\API\Request;
use Piwik\DataTable\Simple;
use Piwik\DataTable\Row;
@@ -12,18 +24,7 @@ use Piwik\Url;
use Piwik\Timer;
use Piwik\Site;
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- * @category Piwik_Plugins
- * @package Piwik_API
- */
-
-
-class Piwik_API_ProcessedReport
+class ProcessedReport
{
/**
@@ -175,7 +176,6 @@ class Piwik_API_ProcessedReport
return array_values($availableReports); // make sure array has contiguous key values
}
-
/**
* API metadata are sorted by category/name,
* with a little tweak to replicate the standard Piwik category ordering
@@ -240,8 +240,6 @@ class Piwik_API_ProcessedReport
$availableReports[] = $metadata;
}
-
-
public function getProcessedReport($idSite, $period, $date, $apiModule, $apiAction, $segment = false,
$apiParameters = false, $idGoal = false, $language = false,
$showTimer = true, $hideMetricsDoc = false, $idSubtable = false, $showRawMetrics = false)
@@ -554,5 +552,4 @@ class Piwik_API_ProcessedReport
$rowsMetadata
);
}
-
}
diff --git a/plugins/API/RowEvolution.php b/plugins/API/RowEvolution.php
index cbc50d2e1c..a565424763 100644
--- a/plugins/API/RowEvolution.php
+++ b/plugins/API/RowEvolution.php
@@ -8,6 +8,9 @@
* @category Piwik_Plugins
* @package Piwik_API
*/
+namespace Piwik\Plugins\API;
+
+use Exception;
use Piwik\API\DataTableManipulator\LabelFilter;
use Piwik\API\ResponseBuilder;
use Piwik\API\Request;
@@ -25,7 +28,7 @@ use Piwik\Url;
*
* @package Piwik_API
*/
-class Piwik_API_RowEvolution
+class RowEvolution
{
public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label = false, $segment = false, $column = false, $language = false, $idGoal = false, $legendAppendMetric = true, $labelUseAbsoluteUrl = true)
@@ -43,7 +46,6 @@ class Piwik_API_RowEvolution
$label = ResponseBuilder::unsanitizeLabelParameter($label);
$labels = Piwik::getArrayFromApiParameter($label);
-
$dataTable = $this->loadRowEvolutionDataFromAPI($idSite, $period, $date, $apiModule, $apiAction, $labels, $segment, $idGoal);
if (empty($labels)) {
@@ -290,8 +292,8 @@ class Piwik_API_RowEvolution
if (!empty($idGoal) && $idGoal > 0) {
$apiParameters = array('idGoal' => $idGoal);
}
- $reportMetadata = Piwik_API_API::getInstance()->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $language,
- $period, $date, $hideMetricsDoc = false, $showSubtableReports = true);
+ $reportMetadata = API::getInstance()->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $language,
+ $period, $date, $hideMetricsDoc = false, $showSubtableReports = true);
if (empty($reportMetadata)) {
throw new Exception("Requested report $apiModule.$apiAction for Website id=$idSite "
@@ -480,17 +482,14 @@ class Piwik_API_RowEvolution
private function getRowEvolutionRowFromLabelIdx($table, $labelIdx)
{
$labelIdx = (int)$labelIdx;
- foreach ($table->getRows() as $row)
- {
- if ($row->getMetadata(LabelFilter::FLAG_IS_ROW_EVOLUTION) === $labelIdx)
- {
+ foreach ($table->getRows() as $row) {
+ if ($row->getMetadata(LabelFilter::FLAG_IS_ROW_EVOLUTION) === $labelIdx) {
return $row;
}
}
return false;
}
-
/**
* Returns a prettier, more comprehensible version of a row evolution label
* for display.
diff --git a/plugins/Actions/API.php b/plugins/Actions/API.php
index 538adccc8b..81402e5f2d 100644
--- a/plugins/Actions/API.php
+++ b/plugins/Actions/API.php
@@ -6,15 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Actions
+ * @package Actions
*/
+namespace Piwik\Plugins\Actions;
+
+use Exception;
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
use Piwik\DataTable;
+use Piwik\Plugins\Actions\Actions;
use Piwik\Tracker\Action;
+use Piwik\Plugins\Actions\Archiver;
+use Piwik\Plugins\Actions\ArchivingHelper;
+use Piwik\Plugins\CustomVariables\API as CustomVariablesAPI;
/**
* The Actions API lets you request reports for all your Visitor Actions: Page URLs, Page titles (Piwik Events),
@@ -28,14 +35,14 @@ use Piwik\Tracker\Action;
* and an outlink via "getOutlink".
*
* Note: pageName, pageUrl, outlinkUrl, downloadUrl parameters must be URL encoded before you call the API.
- * @package Piwik_Actions
+ * @package Actions
*/
-class Piwik_Actions_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_Actions_API
+ * @return \Piwik\Plugins\Actions\API
*/
static public function getInstance()
{
@@ -60,7 +67,7 @@ class Piwik_Actions_API
Piwik::checkUserHasViewAccess($idSite);
$archive = Archive::build($idSite, $period, $date, $segment);
- $metrics = Piwik_Actions_Archiver::$actionsAggregateMetrics;
+ $metrics = Archiver::$actionsAggregateMetrics;
$metrics['Actions_avg_time_generation'] = 'avg_time_generation';
// get requested columns
@@ -89,13 +96,13 @@ class Piwik_Actions_API
}
if ($avgGenerationTimeRequested) {
- $tempColumns[] = Piwik_Actions_Archiver::METRIC_SUM_TIME_RECORD_NAME;
- $tempColumns[] = Piwik_Actions_Archiver::METRIC_HITS_TIMED_RECORD_NAME;
+ $tempColumns[] = Archiver::METRIC_SUM_TIME_RECORD_NAME;
+ $tempColumns[] = Archiver::METRIC_HITS_TIMED_RECORD_NAME;
$columns = array_merge($columns, $tempColumns);
$columns = array_unique($columns);
- $nameReplace[Piwik_Actions_Archiver::METRIC_SUM_TIME_RECORD_NAME] = 'sum_time_generation';
- $nameReplace[Piwik_Actions_Archiver::METRIC_HITS_TIMED_RECORD_NAME] = 'nb_hits_with_time_generation';
+ $nameReplace[Archiver::METRIC_SUM_TIME_RECORD_NAME] = 'sum_time_generation';
+ $nameReplace[Archiver::METRIC_HITS_TIMED_RECORD_NAME] = 'nb_hits_with_time_generation';
}
$table = $archive->getDataTableFromNumeric($columns);
@@ -334,8 +341,8 @@ class Piwik_Actions_API
*/
public function getSiteSearchCategories($idSite, $period, $date, $segment = false)
{
- Piwik_Actions::checkCustomVariablesPluginEnabled();
- $customVariables = Piwik_CustomVariables_API::getInstance()->getCustomVariables($idSite, $period, $date, $segment, $expanded = false, $_leavePiwikCoreVariables = true);
+ Actions::checkCustomVariablesPluginEnabled();
+ $customVariables = CustomVariablesAPI::getInstance()->getCustomVariables($idSite, $period, $date, $segment, $expanded = false, $_leavePiwikCoreVariables = true);
$customVarNameToLookFor = Action::CVAR_KEY_SEARCH_CATEGORY;
@@ -354,7 +361,7 @@ class Piwik_Actions_API
if ($row) {
$dateRewrite = $customVariableTableForDate->metadata['period']->getDateStart()->toString();
$idSubtable = $row->getIdSubDataTable();
- $categories = Piwik_CustomVariables_API::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $dateRewrite, $idSubtable, $segment);
+ $categories = CustomVariablesAPI::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $dateRewrite, $idSubtable, $segment);
$dataTable->addTable($categories, $key);
}
}
@@ -363,7 +370,7 @@ class Piwik_Actions_API
$row = $customVariables->getRowFromLabel($customVarNameToLookFor);
if ($row) {
$idSubtable = $row->getIdSubDataTable();
- $dataTable = Piwik_CustomVariables_API::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment);
+ $dataTable = CustomVariablesAPI::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment);
}
}
$this->filterActionsDataTable($dataTable);
@@ -390,8 +397,8 @@ class Piwik_Actions_API
$searchedString = $search;
}
}
- Piwik_Actions_ArchivingHelper::reloadConfig();
- $searchTree = Piwik_Actions_ArchivingHelper::getActionExplodedNames($searchedString, $actionType);
+ ArchivingHelper::reloadConfig();
+ $searchTree = ArchivingHelper::getActionExplodedNames($searchedString, $actionType);
}
if ($table === false) {
@@ -412,7 +419,6 @@ class Piwik_Actions_API
return $newTableArray;
}
-
}
return $this->doFilterPageDatatableSearch($callBackParameters, $table, $searchTree);
diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php
index b97895ed7d..1fd74b5efe 100644
--- a/plugins/Actions/Actions.php
+++ b/plugins/Actions/Actions.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Actions
+ * @package Actions
*/
+namespace Piwik\Plugins\Actions;
+
use Piwik\API\Request;
use Piwik\ArchiveProcessor;
use Piwik\Piwik;
@@ -15,7 +17,6 @@ use Piwik\Common;
use Piwik\Tracker\Action;
use Piwik\ViewDataTable;
use Piwik\WidgetsList;
-use Piwik\Plugin;
use Piwik\SegmentExpression;
use Piwik\Db;
use Piwik\Site;
@@ -25,18 +26,18 @@ use Piwik\Site;
*
* Reports about the page views, the outlinks and downloads.
*
- * @package Piwik_Actions
+ * @package Actions
*/
-class Piwik_Actions extends Plugin
+class Actions extends \Piwik\Plugin
{
const ACTIONS_REPORT_ROWS_DISPLAY = 100;
-
+
private $columnTranslations;
-
+
public function __construct()
{
parent::__construct();
-
+
$this->columnTranslations = array(
'nb_hits' => Piwik_Translate('General_ColumnPageviews'),
'nb_visits' => Piwik_Translate('General_ColumnUniquePageviews'),
@@ -217,7 +218,7 @@ class Piwik_Actions extends Plugin
'nb_uniq_outlinks' => Piwik_Translate('Actions_ColumnUniqueOutlinks'),
'nb_searches' => Piwik_Translate('Actions_ColumnSearches'),
'nb_keywords' => Piwik_Translate('Actions_ColumnSiteSearchKeywords'),
- 'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTime'),
+ 'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTime'),
),
'metricsDocumentation' => array(
'nb_pageviews' => Piwik_Translate('General_ColumnPageviewsDocumentation'),
@@ -227,7 +228,7 @@ class Piwik_Actions extends Plugin
'nb_outlinks' => Piwik_Translate('Actions_ColumnClicksDocumentation'),
'nb_uniq_outlinks' => Piwik_Translate('Actions_ColumnUniqueClicksDocumentation'),
'nb_searches' => Piwik_Translate('Actions_ColumnSearchesDocumentation'),
- 'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTimeDocumentation'),
+ 'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTimeDocumentation'),
// 'nb_keywords' => Piwik_Translate('Actions_ColumnSiteSearchKeywords'),
),
'processedMetrics' => false,
@@ -587,16 +588,16 @@ class Piwik_Actions extends Plugin
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_Actions_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_Actions_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
@@ -637,20 +638,20 @@ class Piwik_Actions extends Plugin
public function getReportDisplayProperties(&$properties)
{
$properties['Actions.getPageUrls'] = $this->getDisplayPropertiesForPageUrls();
- $properties['Actions.getEntryPageUrls'] = $this->getDisplayPropertiesForEntryPageUrls();
- $properties['Actions.getExitPageUrls'] = $this->getDisplayPropertiesForExitPageUrls();
- $properties['Actions.getSiteSearchKeywords'] = $this->getDisplayPropertiesForSiteSearchKeywords();
- $properties['Actions.getSiteSearchNoResultKeywords'] = $this->getDisplayPropertiesForSiteSearchNoResultKeywords();
- $properties['Actions.getSiteSearchCategories'] = $this->getDisplayPropertiesForSiteSearchCategories();
- $properties['Actions.getPageUrlsFollowingSiteSearch'] = $this->getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch(false);
- $properties['Actions.getPageTitlesFollowingSiteSearch'] = $this->getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch(true);
- $properties['Actions.getPageTitles'] = $this->getDisplayPropertiesForGetPageTitles();
- $properties['Actions.getEntryPageTitles'] = $this->getDisplayPropertiesForGetEntryPageTitles();
- $properties['Actions.getExitPageTitles'] = $this->getDisplayPropertiesForGetExitPageTitles();
- $properties['Actions.getDownloads'] = $this->getDisplayPropertiesForGetDownloads();
- $properties['Actions.getOutlinks'] = $this->getDisplayPropertiesForGetOutlinks();
+ $properties['Actions.getEntryPageUrls'] = $this->getDisplayPropertiesForEntryPageUrls();
+ $properties['Actions.getExitPageUrls'] = $this->getDisplayPropertiesForExitPageUrls();
+ $properties['Actions.getSiteSearchKeywords'] = $this->getDisplayPropertiesForSiteSearchKeywords();
+ $properties['Actions.getSiteSearchNoResultKeywords'] = $this->getDisplayPropertiesForSiteSearchNoResultKeywords();
+ $properties['Actions.getSiteSearchCategories'] = $this->getDisplayPropertiesForSiteSearchCategories();
+ $properties['Actions.getPageUrlsFollowingSiteSearch'] = $this->getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch(false);
+ $properties['Actions.getPageTitlesFollowingSiteSearch'] = $this->getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch(true);
+ $properties['Actions.getPageTitles'] = $this->getDisplayPropertiesForGetPageTitles();
+ $properties['Actions.getEntryPageTitles'] = $this->getDisplayPropertiesForGetEntryPageTitles();
+ $properties['Actions.getExitPageTitles'] = $this->getDisplayPropertiesForGetExitPageTitles();
+ $properties['Actions.getDownloads'] = $this->getDisplayPropertiesForGetDownloads();
+ $properties['Actions.getOutlinks'] = $this->getDisplayPropertiesForGetOutlinks();
}
-
+
private function addBaseDisplayProperties(&$result)
{
$result['datatable_js_type'] = 'actionDataTable';
@@ -660,16 +661,16 @@ class Piwik_Actions extends Plugin
$result['show_all_views_icons'] = false;
$result['show_table_all_columns'] = false;
$result['filter_limit'] = self::ACTIONS_REPORT_ROWS_DISPLAY;
-
+
// if the flat parameter is not provided, make sure it is set to 0 in the URL,
// so users can see that they can set it to 1 (see #3365)
$result['custom_parameters'] = array('flat' => 0);
-
+
if (ViewDataTable::shouldLoadExpanded()) {
$result['visualization_properties']['table']['show_expanded'] = true;
$result['filters'][] = function ($dataTable) {
- Piwik_Actions::setDataTableRowLevels($dataTable);
+ Actions::setDataTableRowLevels($dataTable);
};
}
@@ -689,15 +690,15 @@ class Piwik_Actions extends Plugin
public static function setDataTableRowLevels($dataTable, $level = 0)
{
foreach ($dataTable->getRows() as $row) {
- $row->setMetadata('css_class', 'level'.$level);
-
+ $row->setMetadata('css_class', 'level' . $level);
+
$subtable = $row->getSubtable();
if ($subtable) {
self::setDataTableRowLevels($subtable, $level + 1);
}
}
}
-
+
private function addExcludeLowPopDisplayProperties(&$result)
{
if (Common::getRequestVar('enable_filter_excludelowpop', '0', 'string') != '0') {
@@ -707,60 +708,60 @@ class Piwik_Actions extends Plugin
$visitsInfo = Piwik_VisitsSummary_Controller::getVisitsSummary()->getFirstRow();
$nbActions = $visitsInfo->getColumn('nb_actions');
$nbActionsLowPopulationThreshold = floor(0.02 * $nbActions);
-
+
// we remove 1 to make sure some actions/downloads are displayed in the case we have a very few of them
// and each of them has 1 or 2 hits...
return min($visitsInfo->getColumn('max_actions') - 1, $nbActionsLowPopulationThreshold - 1);
};
}
}
-
+
private function addPageDisplayProperties(&$result)
{
// add common translations
$result['translations'] += array(
- 'nb_hits' => Piwik_Translate('General_ColumnPageviews'),
- 'nb_visits' => Piwik_Translate('General_ColumnUniquePageviews'),
- 'avg_time_on_page' => Piwik_Translate('General_ColumnAverageTimeOnPage'),
- 'bounce_rate' => Piwik_Translate('General_ColumnBounceRate'),
- 'exit_rate' => Piwik_Translate('General_ColumnExitRate'),
+ 'nb_hits' => Piwik_Translate('General_ColumnPageviews'),
+ 'nb_visits' => Piwik_Translate('General_ColumnUniquePageviews'),
+ 'avg_time_on_page' => Piwik_Translate('General_ColumnAverageTimeOnPage'),
+ 'bounce_rate' => Piwik_Translate('General_ColumnBounceRate'),
+ 'exit_rate' => Piwik_Translate('General_ColumnExitRate'),
'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTime'),
);
-
+
// prettify avg_time_on_page column
$getPrettyTimeFromSeconds = '\Piwik\Piwik::getPrettyTimeFromSeconds';
$result['filters'][] = array('ColumnCallbackReplace', array('avg_time_on_page', $getPrettyTimeFromSeconds));
-
+
// prettify avg_time_generation column
$avgTimeCallback = function ($time) {
return $time ? Piwik::getPrettyTimeFromSeconds($time, true, true, false) : "-";
};
$result['filters'][] = array('ColumnCallbackReplace', array('avg_time_generation', $avgTimeCallback));
-
+
// add avg_generation_time tooltip
$tooltipCallback = function ($hits, $min, $max) {
if (!$hits) {
return false;
}
-
+
return Piwik_Translate("Actions_AvgGenerationTimeTooltip", array(
- $hits,
- "<br />",
- Piwik::getPrettyTimeFromSeconds($min),
- Piwik::getPrettyTimeFromSeconds($max)
- ));
+ $hits,
+ "<br />",
+ Piwik::getPrettyTimeFromSeconds($min),
+ Piwik::getPrettyTimeFromSeconds($max)
+ ));
};
$result['filters'][] = array('ColumnCallbackAddMetadata',
- array(
- array('nb_hits_with_time_generation', 'min_time_generation', 'max_time_generation'),
- 'avg_time_generation_tooltip',
- $tooltipCallback
- )
+ array(
+ array('nb_hits_with_time_generation', 'min_time_generation', 'max_time_generation'),
+ 'avg_time_generation_tooltip',
+ $tooltipCallback
+ )
);
-
+
$this->addExcludeLowPopDisplayProperties($result);
}
-
+
public function getDisplayPropertiesForPageUrls()
{
$result = array(
@@ -768,26 +769,26 @@ class Piwik_Actions extends Plugin
'columns_to_display' => array('label', 'nb_hits', 'nb_visits', 'bounce_rate',
'avg_time_on_page', 'exit_rate', 'avg_time_generation'),
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
-
+
public function getDisplayPropertiesForEntryPageUrls()
{
// link to the page, not just the report, but only if not a widget
$widget = Common::getRequestVar('widget', false);
$reportUrl = Request::getCurrentUrlWithoutGenericFilters(array(
- 'module' => 'Actions',
- 'action' => $widget === false ? 'indexEntryPageUrls' : 'getEntryPageUrls'
- ));
-
+ 'module' => 'Actions',
+ 'action' => $widget === false ? 'indexEntryPageUrls' : 'getEntryPageUrls'
+ ));
+
$result = array(
- 'translations' => array('label' => Piwik_Translate('Actions_ColumnEntryPageURL'),
+ 'translations' => array('label' => Piwik_Translate('Actions_ColumnEntryPageURL'),
'entry_bounce_count' => Piwik_Translate('General_ColumnBounces'),
- 'entry_nb_visits' => Piwik_Translate('General_ColumnEntrances')),
+ 'entry_nb_visits' => Piwik_Translate('General_ColumnEntrances')),
'columns_to_display' => array('label', 'entry_nb_visits', 'entry_bounce_count', 'bounce_rate'),
'filter_sort_column' => 'entry_nb_visits',
'filter_sort_order' => 'desc',
@@ -797,24 +798,24 @@ class Piwik_Actions extends Plugin
),
'self_url' => $reportUrl
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
-
+
public function getDisplayPropertiesForExitPageUrls()
{
// link to the page, not just the report, but only if not a widget
$widget = Common::getRequestVar('widget', false);
$reportUrl = Request::getCurrentUrlWithoutGenericFilters(array(
- 'module' => 'Actions',
- 'action' => $widget === false ? 'indexExitPageUrls' : 'getExitPageUrls'
- ));
-
+ 'module' => 'Actions',
+ 'action' => $widget === false ? 'indexExitPageUrls' : 'getExitPageUrls'
+ ));
+
$result = array(
- 'translations' => array('label' => Piwik_Translate('Actions_ColumnExitPageURL'),
+ 'translations' => array('label' => Piwik_Translate('Actions_ColumnExitPageURL'),
'exit_nb_visits' => Piwik_Translate('General_ColumnExits')),
'columns_to_display' => array('label', 'exit_nb_visits', 'nb_visits', 'exit_rate'),
'filter_sort_column' => 'exit_nb_visits',
@@ -825,13 +826,13 @@ class Piwik_Actions extends Plugin
),
'self_url' => $reportUrl,
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
-
+
private function addSiteSearchDisplayProperties(&$result)
{
$result['translations'] += array(
@@ -842,16 +843,16 @@ class Piwik_Actions extends Plugin
$result['show_bar_chart'] = false;
$result['show_table_all_columns'] = false;
}
-
+
public function getDisplayPropertiesForSiteSearchKeywords()
{
$result = array(
'translations' => array('label' => Piwik_Translate('Actions_ColumnSearchKeyword')),
'columns_to_display' => array('label', 'nb_visits', 'nb_pages_per_search', 'exit_rate'),
);
-
+
$this->addSiteSearchDisplayProperties($result);
-
+
return $result;
}
@@ -861,9 +862,9 @@ class Piwik_Actions extends Plugin
'translations' => array('label', Piwik_Translate('Actions_ColumnNoResultKeyword')),
'columns_to_display' => array('label', 'nb_visits', 'exit_rate')
);
-
+
$this->addSiteSearchDisplayProperties($result);
-
+
return $result;
}
@@ -890,12 +891,12 @@ class Piwik_Actions extends Plugin
{
$title = $isTitle ? Piwik_Translate('Actions_WidgetPageTitlesFollowingSearch')
: Piwik_Translate('Actions_WidgetPageUrlsFollowingSearch');
-
+
$relatedReports = array(
'Actions.getPageTitlesFollowingSiteSearch' => Piwik_Translate('Actions_WidgetPageTitlesFollowingSearch'),
- 'Actions.getPageUrlsFollowingSiteSearch' => Piwik_Translate('Actions_WidgetPageUrlsFollowingSearch'),
+ 'Actions.getPageUrlsFollowingSiteSearch' => Piwik_Translate('Actions_WidgetPageUrlsFollowingSearch'),
);
-
+
$result = array(
'translations' => array(
'label' => Piwik_Translate('General_ColumnDestinationPage'),
@@ -909,10 +910,10 @@ class Piwik_Actions extends Plugin
'title' => $title,
'related_reports' => $relatedReports
);
-
+
$this->addExcludeLowPopDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
@@ -921,10 +922,10 @@ class Piwik_Actions extends Plugin
// link to the page, not just the report, but only if not a widget
$widget = Common::getRequestVar('widget', false);
$reportUrl = Request::getCurrentUrlWithoutGenericFilters(array(
- 'module' => 'Actions',
- 'action' => $widget === false ? 'indexPageTitles' : 'getPageTitles'
- ));
-
+ 'module' => 'Actions',
+ 'action' => $widget === false ? 'indexPageTitles' : 'getPageTitles'
+ ));
+
$result = array(
'translations' => array('label' => Piwik_Translate('Actions_ColumnPageName')),
'columns_to_display' => array('label', 'nb_hits', 'nb_visits', 'bounce_rate',
@@ -936,10 +937,10 @@ class Piwik_Actions extends Plugin
),
'self_url' => $reportUrl
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
@@ -947,7 +948,7 @@ class Piwik_Actions extends Plugin
{
$entryPageUrlAction =
Common::getRequestVar('widget', false) === false ? 'indexEntryPageUrls' : 'getEntryPageUrls';
-
+
$result = array(
'translations' => array(
'label' => Piwik_Translate('Actions_ColumnEntryPageTitle'),
@@ -961,10 +962,10 @@ class Piwik_Actions extends Plugin
"Actions.$entryPageUrlAction" => Piwik_Translate('Actions_SubmenuPagesEntry')
),
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
@@ -972,7 +973,7 @@ class Piwik_Actions extends Plugin
{
$exitPageUrlAction =
Common::getRequestVar('widget', false) === false ? 'indexExitPageUrls' : 'getExitPageUrls';
-
+
$result = array(
'translations' => array(
'label' => Piwik_Translate('Actions_ColumnExitPageTitle'),
@@ -985,10 +986,10 @@ class Piwik_Actions extends Plugin
"Actions.$exitPageUrlAction" => Piwik_Translate('Actions_SubmenuPagesExit'),
),
);
-
+
$this->addPageDisplayProperties($result);
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
@@ -1003,9 +1004,9 @@ class Piwik_Actions extends Plugin
'columns_to_display' => array('label', 'nb_visits', 'nb_hits'),
'show_exclude_low_population' => false
);
-
+
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
@@ -1020,9 +1021,9 @@ class Piwik_Actions extends Plugin
'columns_to_display' => array('label', 'nb_visits', 'nb_hits'),
'show_exclude_low_population' => false
);
-
+
$this->addBaseDisplayProperties($result);
-
+
return $result;
}
}
diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php
index f3dfa31138..c177a73ffe 100644
--- a/plugins/Actions/Archiver.php
+++ b/plugins/Actions/Archiver.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Actions
+ * @package Actions
*/
+namespace Piwik\Plugins\Actions;
+
use Piwik\Config;
use Piwik\DataTable\Manager;
use Piwik\DataTable\Row\DataTableSummaryRow;
@@ -16,13 +18,14 @@ use Piwik\DataTable;
use Piwik\RankingQuery;
use Piwik\PluginsArchiver;
use Piwik\Tracker\Action;
+use Piwik\Plugins\Actions\ArchivingHelper;
/**
* Class encapsulating logic to process Day/Period Archiving for the Actions reports
*
- * @package Piwik_Actions
+ * @package Actions
*/
-class Piwik_Actions_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const DOWNLOADS_RECORD_NAME = 'Actions_downloads';
const OUTLINKS_RECORD_NAME = 'Actions_outlink';
@@ -42,15 +45,15 @@ class Piwik_Actions_Archiver extends PluginsArchiver
const METRIC_KEYWORDS_RECORD_NAME = 'Actions_nb_keywords';
/* Metrics in use by the API Actions.get */
- public static $actionsAggregateMetrics = array(
- self::METRIC_PAGEVIEWS_RECORD_NAME => 'nb_pageviews',
- self::METRIC_UNIQ_PAGEVIEWS_RECORD_NAME => 'nb_uniq_pageviews',
- self::METRIC_DOWNLOADS_RECORD_NAME => 'nb_downloads',
- self::METRIC_UNIQ_DOWNLOADS_RECORD_NAME => 'nb_uniq_downloads',
- self::METRIC_OUTLINKS_RECORD_NAME => 'nb_outlinks',
- self::METRIC_UNIQ_OUTLINKS_RECORD_NAME => 'nb_uniq_outlinks',
- self::METRIC_SEARCHES_RECORD_NAME => 'nb_searches',
- self::METRIC_KEYWORDS_RECORD_NAME => 'nb_keywords',
+ public static $actionsAggregateMetrics = array(
+ self::METRIC_PAGEVIEWS_RECORD_NAME => 'nb_pageviews',
+ self::METRIC_UNIQ_PAGEVIEWS_RECORD_NAME => 'nb_uniq_pageviews',
+ self::METRIC_DOWNLOADS_RECORD_NAME => 'nb_downloads',
+ self::METRIC_UNIQ_DOWNLOADS_RECORD_NAME => 'nb_uniq_downloads',
+ self::METRIC_OUTLINKS_RECORD_NAME => 'nb_outlinks',
+ self::METRIC_UNIQ_OUTLINKS_RECORD_NAME => 'nb_uniq_outlinks',
+ self::METRIC_SEARCHES_RECORD_NAME => 'nb_searches',
+ self::METRIC_KEYWORDS_RECORD_NAME => 'nb_keywords',
);
public static $actionTypes = array(
@@ -93,24 +96,24 @@ class Piwik_Actions_Archiver extends PluginsArchiver
$rankingQueryLimit = self::getRankingQueryLimit();
// FIXME: This is a quick fix for #3482. The actual cause of the bug is that
- // the site search & performance metrics additions to
- // Piwik_Actions_ArchivingHelper::updateActionsTableWithRowQuery expect every
+ // the site search & performance metrics additions to
+ // ArchivingHelper::updateActionsTableWithRowQuery expect every
// row to have 'type' data, but not all of the SQL queries that are run w/o
// ranking query join on the log_action table and thus do not select the
// log_action.type column.
- //
+ //
// NOTES: Archiving logic can be generalized as follows:
// 0) Do SQL query over log_link_visit_action & join on log_action to select
// some metrics (like visits, hits, etc.)
// 1) For each row, cache the action row & metrics. (This is done by
- // updateActionsTableWithRowQuery for result set rows that have
+ // updateActionsTableWithRowQuery for result set rows that have
// name & type columns.)
// 2) Do other SQL queries for metrics we can't put in the first query (like
// entry visits, exit vists, etc.) w/o joining log_action.
// 3) For each row, find the cached row by idaction & add the new metrics to
// it. (This is done by updateActionsTableWithRowQuery for result set rows
// that DO NOT have name & type columns.)
- //
+ //
// The site search & performance metrics additions expect a 'type' all the time
// which breaks the original pre-rankingquery logic. Ranking query requires a
// join, so the bug is only seen when ranking query is disabled.
@@ -118,7 +121,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver
$rankingQueryLimit = 100000;
}
- Piwik_Actions_ArchivingHelper::reloadConfig();
+ ArchivingHelper::reloadConfig();
$this->initActionsTables();
$this->archiveDayActions($rankingQueryLimit);
@@ -159,7 +162,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver
$this->actionsTablesByType = array();
foreach (self::$actionTypes as $type) {
$dataTable = new DataTable();
- $dataTable->setMaximumAllowedRows(Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero);
+ $dataTable->setMaximumAllowedRows(ArchivingHelper::$maximumRowsInDataTableLevelZero);
if ($type == Action::TYPE_ACTION_URL
|| $type == Action::TYPE_ACTION_NAME
@@ -271,7 +274,6 @@ class Piwik_Actions_Archiver extends PluginsArchiver
// to the outer select. therefore, $segment needs to know about it.
$select = sprintf($select, $sprintfField);
-
// get query with segmentation
$query = $this->getLogAggregator()->generateQuery($select, $from, $where, $groupBy, $orderBy);
@@ -285,7 +287,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver
// get result
$resultSet = $this->getLogAggregator()->getDb()->query($querySql, $query['bind']);
- $modified = Piwik_Actions_ArchivingHelper::updateActionsTableWithRowQuery($resultSet, $sprintfField, $this->actionsTablesByType);
+ $modified = ArchivingHelper::updateActionsTableWithRowQuery($resultSet, $sprintfField, $this->actionsTablesByType);
return $modified;
}
@@ -435,7 +437,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver
*/
protected function recordDayReports()
{
- Piwik_Actions_ArchivingHelper::clearActionsCache();
+ ArchivingHelper::clearActionsCache();
$this->recordPageUrlsReports();
$this->recordDownloadsReports();
@@ -450,12 +452,12 @@ class Piwik_Actions_Archiver extends PluginsArchiver
$this->recordDataTable($dataTable, self::PAGE_URLS_RECORD_NAME);
$records = array(
- self::METRIC_PAGEVIEWS_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_NB_HITS)),
+ self::METRIC_PAGEVIEWS_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_NB_HITS)),
self::METRIC_UNIQ_PAGEVIEWS_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_NB_VISITS)),
- self::METRIC_SUM_TIME_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_SUM_TIME_GENERATION)),
- self::METRIC_HITS_TIMED_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION))
+ self::METRIC_SUM_TIME_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_SUM_TIME_GENERATION)),
+ self::METRIC_HITS_TIMED_RECORD_NAME => array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION))
);
- $this->getProcessor()->insertNumericRecords( $records );
+ $this->getProcessor()->insertNumericRecords($records);
}
/**
@@ -470,7 +472,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver
protected function recordDataTable($dataTable, $recordName)
{
self::deleteInvalidSummedColumnsFromDataTable($dataTable);
- $s = $dataTable->getSerialized(Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero, Piwik_Actions_ArchivingHelper::$maximumRowsInSubDataTable, Piwik_Actions_ArchivingHelper::$columnToSortByBeforeTruncation);
+ $s = $dataTable->getSerialized(ArchivingHelper::$maximumRowsInDataTableLevelZero, ArchivingHelper::$maximumRowsInSubDataTable, ArchivingHelper::$columnToSortByBeforeTruncation);
$this->getProcessor()->insertBlobRecord($recordName, $s);
}
@@ -566,15 +568,15 @@ class Piwik_Actions_Archiver extends PluginsArchiver
public function archivePeriod()
{
- Piwik_Actions_ArchivingHelper::reloadConfig();
+ ArchivingHelper::reloadConfig();
$dataTableToSum = array(
self::PAGE_TITLES_RECORD_NAME,
self::PAGE_URLS_RECORD_NAME,
);
$this->getProcessor()->aggregateDataTableReports($dataTableToSum,
- Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero,
- Piwik_Actions_ArchivingHelper::$maximumRowsInSubDataTable,
- Piwik_Actions_ArchivingHelper::$columnToSortByBeforeTruncation,
+ ArchivingHelper::$maximumRowsInDataTableLevelZero,
+ ArchivingHelper::$maximumRowsInSubDataTable,
+ ArchivingHelper::$columnToSortByBeforeTruncation,
self::$actionColumnAggregationOperations,
self::$invalidSummedColumnNameToRenamedNameFromPeriodArchive
);
@@ -586,9 +588,9 @@ class Piwik_Actions_Archiver extends PluginsArchiver
);
$aggregation = null;
$nameToCount = $this->getProcessor()->aggregateDataTableReports($dataTableToSum,
- Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero,
- Piwik_Actions_ArchivingHelper::$maximumRowsInSubDataTable,
- Piwik_Actions_ArchivingHelper::$columnToSortByBeforeTruncation,
+ ArchivingHelper::$maximumRowsInDataTableLevelZero,
+ ArchivingHelper::$maximumRowsInSubDataTable,
+ ArchivingHelper::$columnToSortByBeforeTruncation,
$aggregation,
self::$invalidSummedColumnNameToRenamedNameFromPeriodArchive
);
diff --git a/plugins/Actions/ArchivingHelper.php b/plugins/Actions/ArchivingHelper.php
index 8c95ae629f..e66cf73a97 100644
--- a/plugins/Actions/ArchivingHelper.php
+++ b/plugins/Actions/ArchivingHelper.php
@@ -6,29 +6,33 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Actions
+ * @package Actions
*/
+namespace Piwik\Plugins\Actions;
+
+use PDOStatement;
use Piwik\Config;
use Piwik\DataTable\Row;
use Piwik\Metrics;
use Piwik\DataTable;
use Piwik\Tracker\Action;
+use Zend_Db_Statement;
/**
* This static class provides:
* - logic to parse/cleanup Action names,
* - logic to efficiently process aggregate the array data during Archiving
*
- * @package Piwik_Actions
+ * @package Actions
*/
-class Piwik_Actions_ArchivingHelper
+class ArchivingHelper
{
const OTHERS_ROW_KEY = '';
/**
- * FIXME See FIXME related to this function at Piwik_Actions_Archiver::archiveDay.
- *
+ * FIXME See FIXME related to this function at Archiver::archiveDay.
+ *
* @param Zend_Db_Statement|PDOStatement $query
* @param string|bool $fieldQueried
* @param array $actionsTablesByType
@@ -91,7 +95,6 @@ class Piwik_Actions_ArchivingHelper
}
}
-
if (is_null($actionRow)) {
continue;
}
@@ -226,7 +229,6 @@ class Piwik_Actions_ArchivingHelper
DataTable::setMaximumDepthLevelAllowedAtLeast(self::getSubCategoryLevelLimit() + 1);
}
-
/**
* The default row is used when archiving, if data is inconsistent in the DB,
* there could be pages that have exit/entry hits, but don't yet
@@ -242,11 +244,11 @@ class Piwik_Actions_ArchivingHelper
// but this action was not properly recorded when it was hit in the first place
// so we add this fake row information to make sure there is a nb_hits, etc. column for every action
$row = new Row(array(
- Row::COLUMNS => array(
- Metrics::INDEX_NB_VISITS => 1,
- Metrics::INDEX_NB_UNIQ_VISITORS => 1,
- Metrics::INDEX_PAGE_NB_HITS => 1,
- )));
+ Row::COLUMNS => array(
+ Metrics::INDEX_NB_VISITS => 1,
+ Metrics::INDEX_NB_UNIQ_VISITORS => 1,
+ Metrics::INDEX_PAGE_NB_HITS => 1,
+ )));
}
return $row;
}
@@ -287,7 +289,7 @@ class Piwik_Actions_ArchivingHelper
/**
* Explodes action name into an array of elements.
*
- * NOTE: before calling this function make sure Piwik_Actions_ArchivingHelper::reloadConfig(); is called
+ * NOTE: before calling this function make sure ArchivingHelper::reloadConfig(); is called
*
* for downloads:
* we explode link http://piwik.org/some/path/piwik.zip into an array( 'piwik.org', '/some/path/piwik.zip' );
@@ -357,7 +359,6 @@ class Piwik_Actions_ArchivingHelper
$categoryDelimiter = self::$actionUrlCategoryDelimiter;
}
-
if ($isUrl) {
$urlFragment = Action::processUrlFragment($urlFragment);
if (!empty($urlFragment)) {
@@ -504,8 +505,8 @@ class Piwik_Actions_ArchivingHelper
private static function createSummaryRow()
{
return new Row(array(
- Row::COLUMNS =>
- array('label' => DataTable::LABEL_SUMMARY_ROW) + self::getDefaultRowColumns()
- ));
+ Row::COLUMNS =>
+ array('label' => DataTable::LABEL_SUMMARY_ROW) + self::getDefaultRowColumns()
+ ));
}
}
diff --git a/plugins/Actions/Controller.php b/plugins/Actions/Controller.php
index 9ce7800197..e6342352f6 100644
--- a/plugins/Actions/Controller.php
+++ b/plugins/Actions/Controller.php
@@ -6,23 +6,24 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Actions
+ * @package Actions
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\Actions;
+
use Piwik\ViewDataTable;
use Piwik\View;
/**
* Actions controller
*
- * @package Piwik_Actions
+ * @package Actions
*/
-class Piwik_Actions_Controller extends Controller
+class Controller extends \Piwik\Controller
{
- //
+ //
// Actions that render whole pages
- //
-
+ //
+
public function indexPageUrls($fetch = false)
{
return View::singleReport(
@@ -80,16 +81,16 @@ class Piwik_Actions_Controller extends Controller
Piwik_Translate('Actions_SubmenuOutlinks'),
$this->getOutlinks(true), $fetch);
}
-
- //
+
+ //
// Actions that render individual reports
- //
-
+ //
+
public function getPageUrls($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
}
-
+
public function getEntryPageUrls($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
diff --git a/plugins/Alerts/README.md b/plugins/Alerts/README.md
deleted file mode 100644
index 292963a701..0000000000
--- a/plugins/Alerts/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Alerts
-
-
diff --git a/plugins/Annotations/API.php b/plugins/Annotations/API.php
index ec34c1f127..0e946b7302 100755
--- a/plugins/Annotations/API.php
+++ b/plugins/Annotations/API.php
@@ -6,12 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Annotations
+ * @package Annotations
*/
+namespace Piwik\Plugins\Annotations;
+
+use Exception;
use Piwik\Period;
use Piwik\Period\Range;
use Piwik\Piwik;
use Piwik\Date;
+use Piwik\Plugins\Annotations\AnnotationList;
use Piwik\ViewDataTable;
use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution as EvolutionViz;
@@ -24,16 +28,16 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/Annotations/AnnotationList.php';
* API for annotations plugin. Provides methods to create, modify, delete & query
* annotations.
*
- * @package Piwik_Annotations
+ * @package Annotations
*/
-class Piwik_Annotations_API
+class API
{
static private $instance = null;
/**
* Returns this API's singleton instance.
*
- * @return Piwik_Annotations_API
+ * @return \Piwik\Plugins\Annotations\API
*/
static public function getInstance()
{
@@ -49,7 +53,7 @@ class Piwik_Annotations_API
* @param string $idSite The site ID to add the annotation to.
* @param string $date The date the annotation is attached to.
* @param string $note The text of the annotation.
- * @param int $starred Either 0 or 1. Whether the annotation should be starred.
+ * @param int $starred Either 0 or 1. Whether the annotation should be starred.
* @return array Returns an array of two elements. The first element (indexed by
* 'annotation') is the new annotation. The second element (indexed
* by 'idNote' is the new note's ID).
@@ -61,7 +65,7 @@ class Piwik_Annotations_API
$this->checkUserCanAddNotesFor($idSite);
// add, save & return a new annotation
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
$newAnnotation = $annotations->add($idSite, $date, $note, $starred);
$annotations->save($idSite);
@@ -97,7 +101,7 @@ class Piwik_Annotations_API
$this->checkDateIsValid($date, $canBeNull = true);
// get the annotations for the site
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
// check permissions
$this->checkUserCanModifyOrDelete($idSite, $annotations->get($idSite, $idNote));
@@ -125,7 +129,7 @@ class Piwik_Annotations_API
{
$this->checkSingleIdSite($idSite, $extraMessage = "Note: Cannot delete multiple notes.");
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
// check permissions
$this->checkUserCanModifyOrDelete($idSite, $annotations->get($idSite, $idNote));
@@ -154,7 +158,7 @@ class Piwik_Annotations_API
Piwik::checkUserHasViewAccess($idSite);
// get single annotation
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
return $annotations->get($idSite, $idNote);
}
@@ -182,7 +186,7 @@ class Piwik_Annotations_API
{
Piwik::checkUserHasViewAccess($idSite);
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
// if date/period are supplied, determine start/end date for search
list($startDate, $endDate) = self::getDateRangeForPeriod($date, $period, $lastN);
@@ -234,7 +238,7 @@ class Piwik_Annotations_API
$dates[] = $startDate;
// get annotations for the site
- $annotations = new Piwik_Annotations_AnnotationList($idSite);
+ $annotations = new AnnotationList($idSite);
// create result w/ 0-counts
$result = array();
@@ -292,7 +296,7 @@ class Piwik_Annotations_API
*/
private static function checkUserCanAddNotesFor($idSite)
{
- if (!Piwik_Annotations_AnnotationList::canUserAddNotesFor($idSite)) {
+ if (!AnnotationList::canUserAddNotesFor($idSite)) {
throw new Exception("The current user is not allowed to add notes for site #$idSite.");
}
}
@@ -303,7 +307,7 @@ class Piwik_Annotations_API
*
* @param string|bool $date The start date of the period (or the date range of a range
* period).
- * @param string $period The period type ('day', 'week', 'month', 'year' or 'range').
+ * @param string $period The period type ('day', 'week', 'month', 'year' or 'range').
* @param bool|int $lastN Whether to include the last N periods in the range or not.
* Ignored if period == range.
*
diff --git a/plugins/Annotations/AnnotationList.php b/plugins/Annotations/AnnotationList.php
index 0f5ba42ae9..75b4d95df1 100755
--- a/plugins/Annotations/AnnotationList.php
+++ b/plugins/Annotations/AnnotationList.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Annotations
+ * @package Annotations
*/
+namespace Piwik\Plugins\Annotations;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Date;
use Piwik\Site;
@@ -17,7 +20,7 @@ use Piwik\Site;
* at once.
*
* Example use:
- * $annotations = new Piwik_Annotations_AnnotationList($idSites = "1,2,5");
+ * $annotations = new AnnotationList($idSites = "1,2,5");
* $annotation = $annotations->get($idSite = 1, $idNote = 4);
* // do stuff w/ annotation
* $annotations->update($idSite = 2, $idNote = 4, $note = "This is the new text.");
@@ -27,9 +30,9 @@ use Piwik\Site;
* an annotation for the same site, it's possible one of their changes will
* never get made (as it will be overwritten by the other's).
*
- * @package Piwik_Annotations
+ * @package Annotations
*/
-class Piwik_Annotations_AnnotationList
+class AnnotationList
{
const ANNOTATION_COLLECTION_OPTION_SUFFIX = '_annotations';
diff --git a/plugins/Annotations/Annotations.php b/plugins/Annotations/Annotations.php
index 5b29ec48b5..3b756314c9 100755
--- a/plugins/Annotations/Annotations.php
+++ b/plugins/Annotations/Annotations.php
@@ -6,17 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Annotations
+ * @package Annotations
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\Annotations;
/**
* Annotations plugins. Provides the ability to attach text notes to
* dates for each sites. Notes can be viewed, modified, deleted or starred.
*
- * @package Piwik_Annotations
+ * @package Annotations
*/
-class Piwik_Annotations extends Plugin
+class Annotations extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/Annotations/Controller.php b/plugins/Annotations/Controller.php
index 739ec5deeb..00a927fe6d 100755
--- a/plugins/Annotations/Controller.php
+++ b/plugins/Annotations/Controller.php
@@ -6,19 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Annotations
+ * @package Annotations
*/
+namespace Piwik\Plugins\Annotations;
+
use Piwik\API\Request;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\Annotations\AnnotationList;
+use Piwik\Plugins\Annotations\API;
use Piwik\View;
/**
* Controller for the Annotations plugin.
*
- * @package Piwik_Annotations
+ * @package Annotations
*/
-class Piwik_Annotations_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
* Controller action that returns HTML displaying annotations for a site and
@@ -68,7 +71,7 @@ class Piwik_Annotations_Controller extends Controller
$view->period = $period;
$view->lastN = $lastN;
- list($startDate, $endDate) = Piwik_Annotations_API::getDateRangeForPeriod($date, $period, $lastN);
+ list($startDate, $endDate) = API::getDateRangeForPeriod($date, $period, $lastN);
$view->startDate = $startDate->toString();
$view->endDate = $endDate->toString();
@@ -76,7 +79,7 @@ class Piwik_Annotations_Controller extends Controller
$view->startDatePretty = $startDate->getLocalized($dateFormat);
$view->endDatePretty = $endDate->getLocalized($dateFormat);
- $view->canUserAddNotes = Piwik_Annotations_AnnotationList::canUserAddNotesFor($idSite);
+ $view->canUserAddNotes = AnnotationList::canUserAddNotesFor($idSite);
if ($fetch) {
return $view->render();
diff --git a/plugins/AnonymizeIP/AnonymizeIP.php b/plugins/AnonymizeIP/AnonymizeIP.php
index 79af7308a5..ba0e2c2230 100644
--- a/plugins/AnonymizeIP/AnonymizeIP.php
+++ b/plugins/AnonymizeIP/AnonymizeIP.php
@@ -6,19 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_AnonymizeIP
+ * @package AnonymizeIP
*/
+namespace Piwik\Plugins\AnonymizeIP;
+
use Piwik\Config;
use Piwik\Common;
use Piwik\Version;
-use Piwik\Plugin;
/**
* Anonymize visitor IP addresses to comply with the privacy laws/guidelines in countries, such as Germany.
*
- * @package Piwik_AnonymizeIP
+ * @package AnonymizeIP
*/
-class Piwik_AnonymizeIP extends Plugin
+class AnonymizeIP extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getInformation
diff --git a/plugins/CoreAdminHome/API.php b/plugins/CoreAdminHome/API.php
index 2768708ef5..71444288e3 100644
--- a/plugins/CoreAdminHome/API.php
+++ b/plugins/CoreAdminHome/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
+namespace Piwik\Plugins\CoreAdminHome;
+
+use Exception;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Period;
use Piwik\Period\Week;
@@ -20,14 +23,14 @@ use Piwik\Site;
use Piwik\Db;
/**
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
-class Piwik_CoreAdminHome_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_CoreAdminHome_API
+ * @return \Piwik\Plugins\CoreAdminHome\API
*/
static public function getInstance()
{
@@ -103,7 +106,6 @@ class Piwik_CoreAdminHome_API
}
}
-
// If using the feature "Delete logs older than N days"...
$logsAreDeletedBeforeThisDate = Config::getInstance()->Deletelogs['delete_logs_schedule_lowest_interval'];
$logsDeleteEnabled = Config::getInstance()->Deletelogs['delete_logs_enable'];
@@ -188,7 +190,7 @@ class Piwik_CoreAdminHome_API
Db::query($query, $bind);
// Force to re-process data for these websites in the next archive.php cron run
- $invalidatedIdSites = Piwik_CoreAdminHome_API::getWebsiteIdsToInvalidate();
+ $invalidatedIdSites = self::getWebsiteIdsToInvalidate();
$invalidatedIdSites = array_merge($invalidatedIdSites, $idSites);
$invalidatedIdSites = array_unique($invalidatedIdSites);
$invalidatedIdSites = array_values($invalidatedIdSites);
diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php
index 64d62ed158..f8a23c8dc2 100644
--- a/plugins/CoreAdminHome/Controller.php
+++ b/plugins/CoreAdminHome/Controller.php
@@ -6,12 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
+namespace Piwik\Plugins\CoreAdminHome;
+
+use Exception;
use Piwik\API\ResponseBuilder;
use Piwik\ArchiveProcessor\Rules;
use Piwik\Config;
-use Piwik\Controller\Admin;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Nonce;
@@ -19,12 +21,15 @@ use Piwik\Tracker\IgnoreCookie;
use Piwik\View;
use Piwik\Url;
use Piwik\Site;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Piwik\Plugins\LanguagesManager\API as LanguagesManagerAPI;
+use Piwik\Plugins\SitesManager\API;
/**
*
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
-class Piwik_CoreAdminHome_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
const LOGO_HEIGHT = 300;
const LOGO_SMALL_HEIGHT = 100;
@@ -67,7 +72,8 @@ class Piwik_CoreAdminHome_Controller extends Admin
$directoryWritable = is_writable(PIWIK_DOCUMENT_ROOT . '/misc/user/');
$logoFilesWriteable = is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo.png')
&& is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo.svg')
- && is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo-header.png');;
+ && is_writeable(PIWIK_DOCUMENT_ROOT . '/misc/user/logo-header.png');
+ ;
$view->logosWriteable = ($logoFilesWriteable || $directoryWritable) && ini_get('file_uploads') == 1;
$trustedHosts = array();
@@ -77,7 +83,7 @@ class Piwik_CoreAdminHome_Controller extends Admin
$view->trustedHosts = $trustedHosts;
}
- $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
$this->setBasicVariablesView($view);
echo $view->render();
}
@@ -141,7 +147,7 @@ class Piwik_CoreAdminHome_Controller extends Admin
$this->setBasicVariablesView($view);
$view->topMenu = Piwik_GetTopMenu();
- $viewableIdSites = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
+ $viewableIdSites = API::getInstance()->getSitesIdWithAtLeastViewAccess();
$defaultIdSite = reset($viewableIdSites);
$view->idSite = Common::getRequestVar('idSite', $defaultIdSite, 'int');
@@ -149,7 +155,7 @@ class Piwik_CoreAdminHome_Controller extends Admin
$view->defaultReportSiteName = Site::getNameFor($view->idSite);
$view->defaultSiteRevenue = Piwik::getCurrency($view->idSite);
- $allUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($view->idSite);
+ $allUrls = API::getInstance()->getSiteUrlsFromId($view->idSite);
if (isset($allUrls[1])) {
$aliasUrl = $allUrls[1];
} else {
@@ -161,9 +167,9 @@ class Piwik_CoreAdminHome_Controller extends Admin
$view->defaultReportSiteDomain = @parse_url($mainUrl, PHP_URL_HOST);
// get currencies for each viewable site
- $view->currencySymbols = Piwik_SitesManager_API::getInstance()->getCurrencySymbols();
+ $view->currencySymbols = API::getInstance()->getCurrencySymbols();
- $view->serverSideDoNotTrackEnabled = \Piwik_PrivacyManager_Controller::isDntSupported();
+ $view->serverSideDoNotTrackEnabled = \Piwik\Plugins\PrivacyManager\Controller::isDntSupported();
echo $view->render();
}
@@ -186,9 +192,9 @@ class Piwik_CoreAdminHome_Controller extends Admin
$view = new View('@CoreAdminHome/optOut');
$view->trackVisits = $trackVisits;
$view->nonce = Nonce::getNonce('Piwik_OptOut', 3600);
- $view->language = Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($language)
+ $view->language = LanguagesManagerAPI::getInstance()->isLanguageAvailable($language)
? $language
- : Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ : LanguagesManager::getLanguageCodeForCurrentUser();
echo $view->render();
}
diff --git a/plugins/CoreAdminHome/CoreAdminHome.php b/plugins/CoreAdminHome/CoreAdminHome.php
index c3517d8870..607df94246 100644
--- a/plugins/CoreAdminHome/CoreAdminHome.php
+++ b/plugins/CoreAdminHome/CoreAdminHome.php
@@ -6,22 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
+namespace Piwik\Plugins\CoreAdminHome;
+
use Piwik\DataAccess\ArchiveSelector;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Piwik;
use Piwik\Date;
use Piwik\ScheduledTask;
-use Piwik\Plugin;
use Piwik\Db;
use Piwik\ScheduledTime\Daily;
/**
*
- * @package Piwik_CoreAdminHome
+ * @package CoreAdminHome
*/
-class Piwik_CoreAdminHome extends Plugin
+class CoreAdminHome extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -91,7 +92,6 @@ class Piwik_CoreAdminHome extends Plugin
array('module' => 'CoreAdminHome', 'action' => 'trackingCodeGenerator'),
Piwik::isUserHasSomeAdminAccess(),
$order = 4);
-
}
function purgeOutdatedArchives()
diff --git a/plugins/CoreHome/Controller.php b/plugins/CoreHome/Controller.php
index f89727fb51..7a70f1ac94 100644
--- a/plugins/CoreHome/Controller.php
+++ b/plugins/CoreHome/Controller.php
@@ -6,26 +6,30 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
+namespace Piwik\Plugins\CoreHome;
+
+use Exception;
use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
use Piwik\AssetManager;
-use Piwik\Controller;
use Piwik\FrontController;
use Piwik\View;
use Piwik\Url;
use Piwik\UpdateCheck;
use Piwik\Site;
-
+use Piwik\Plugins\CoreHome\DataTableRowAction\MultiRowEvolution;
+use Piwik\Plugins\CoreHome\DataTableRowAction\RowEvolution;
+use Piwik\Plugins\UsersManager\API;
/**
*
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
-class Piwik_CoreHome_Controller extends Controller
+class Controller extends \Piwik\Controller
{
function getDefaultAction()
{
@@ -34,7 +38,7 @@ class Piwik_CoreHome_Controller extends Controller
function redirectToCoreHomeIndex()
{
- $defaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
+ $defaultReport = API::getInstance()->getUserPreference(Piwik::getCurrentUserLogin(), API::PREFERENCE_DEFAULT_REPORT);
$module = 'CoreHome';
$action = 'index';
@@ -128,7 +132,6 @@ class Piwik_CoreHome_Controller extends Controller
Piwik::serveStaticFile($jsMergedFile, "application/javascript; charset=UTF-8");
}
-
// --------------------------------------------------------
// ROW EVOLUTION
// The following methods render the popover that shows the
@@ -170,9 +173,9 @@ class Piwik_CoreHome_Controller extends Controller
private function makeRowEvolution($isMultiRowEvolution, $graphType = null)
{
if ($isMultiRowEvolution) {
- return new Piwik_CoreHome_DataTableRowAction_MultiRowEvolution($this->idSite, $this->date, $graphType);
+ return new MultiRowEvolution($this->idSite, $this->date, $graphType);
} else {
- return new Piwik_CoreHome_DataTableRowAction_RowEvolution($this->idSite, $this->date, $graphType);
+ return new RowEvolution($this->idSite, $this->date, $graphType);
}
}
@@ -219,7 +222,7 @@ class Piwik_CoreHome_Controller extends Controller
$view->promoVideoUrl = 'http://www.youtube.com/watch?v=OslfF_EH81g';
echo $view->render();
}
-
+
/**
* Redirects the user to a paypal so they can donate to Piwik.
*/
@@ -234,9 +237,9 @@ class Piwik_CoreHome_Controller extends Controller
unset($parameters[$name]);
}
}
-
- $url = "https://www.paypal.com/cgi-bin/webscr?".Url::getQueryStringFromParameters($parameters);
-
+
+ $url = "https://www.paypal.com/cgi-bin/webscr?" . Url::getQueryStringFromParameters($parameters);
+
header("Location: $url");
exit;
}
diff --git a/plugins/CoreHome/CoreHome.php b/plugins/CoreHome/CoreHome.php
index c7b6e01a5f..e2e32b1a6b 100644
--- a/plugins/CoreHome/CoreHome.php
+++ b/plugins/CoreHome/CoreHome.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\CoreHome;
+
use Piwik\WidgetsList;
/**
*
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
-class Piwik_CoreHome extends Plugin
+class CoreHome extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php b/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php
index 11b2d25ef2..3594675f41 100644
--- a/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php
+++ b/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php
@@ -6,18 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
+namespace Piwik\Plugins\CoreHome\DataTableRowAction;
+
use Piwik\Common;
use Piwik\ViewDataTable;
+use Piwik\Plugins\CoreHome\DataTableRowAction\RowEvolution;
/**
* MULTI ROW EVOLUTION
* The class handles the popover that shows the evolution of a multiple rows in a data table
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
-class Piwik_CoreHome_DataTableRowAction_MultiRowEvolution
- extends Piwik_CoreHome_DataTableRowAction_RowEvolution
+class MultiRowEvolution extends RowEvolution
{
/** The requested metric */
protected $metric;
@@ -70,4 +72,4 @@ class Piwik_CoreHome_DataTableRowAction_MultiRowEvolution
return parent::renderPopover($controller, $view);
}
-} \ No newline at end of file
+}
diff --git a/plugins/CoreHome/DataTableRowAction/RowEvolution.php b/plugins/CoreHome/DataTableRowAction/RowEvolution.php
index 46654c531e..081b9ad374 100644
--- a/plugins/CoreHome/DataTableRowAction/RowEvolution.php
+++ b/plugins/CoreHome/DataTableRowAction/RowEvolution.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
+namespace Piwik\Plugins\CoreHome\DataTableRowAction;
+
+use Exception;
use Piwik\API\ResponseBuilder;
use Piwik\API\Request;
use Piwik\Common;
@@ -21,9 +24,9 @@ use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution as Evo
/**
* ROW EVOLUTION
* The class handles the popover that shows the evolution of a singe row in a data table
- * @package Piwik_CoreHome
+ * @package CoreHome
*/
-class Piwik_CoreHome_DataTableRowAction_RowEvolution
+class RowEvolution
{
/** The current site id */
@@ -52,7 +55,7 @@ class Piwik_CoreHome_DataTableRowAction_RowEvolution
/**
* The data
- * @var Piwik\DataTable
+ * @var \Piwik\DataTable
*/
protected $dataTable;
@@ -186,12 +189,12 @@ class Piwik_CoreHome_DataTableRowAction_RowEvolution
public function getRowEvolutionGraph($graphType = false, $metrics = false)
{
// set up the view data table
- $view = ViewDataTable::factory($graphType ?: $this->graphType, $this->apiMethod,
+ $view = ViewDataTable::factory($graphType ? : $this->graphType, $this->apiMethod,
$controllerAction = 'CoreHome.getRowEvolutionGraph', $forceDefault = true);
$view->setDataTable($this->dataTable);
if (!empty($this->graphMetrics)) { // In row Evolution popover, this is empty
- $view->columns_to_display = array_keys($metrics ?: $this->graphMetrics);
+ $view->columns_to_display = array_keys($metrics ? : $this->graphMetrics);
}
$view->show_goals = false;
@@ -217,7 +220,7 @@ class Piwik_CoreHome_DataTableRowAction_RowEvolution
protected function getMetricsToggles()
{
$chart = new Evolution;
-
+
$i = 0;
$metrics = array();
foreach ($this->availableMetrics as $metric => $metricData) {
diff --git a/plugins/CorePluginsAdmin/Controller.php b/plugins/CorePluginsAdmin/Controller.php
index c1156cce99..0237c26a81 100644
--- a/plugins/CorePluginsAdmin/Controller.php
+++ b/plugins/CorePluginsAdmin/Controller.php
@@ -6,9 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CorePluginsAdmin
+ * @package CorePluginsAdmin
*/
-use Piwik\Controller\Admin;
+namespace Piwik\Plugins\CorePluginsAdmin;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Config;
@@ -17,9 +18,9 @@ use Piwik\Url;
/**
*
- * @package Piwik_CorePluginsAdmin
+ * @package CorePluginsAdmin
*/
-class Piwik_CorePluginsAdmin_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
function extend()
{
@@ -141,7 +142,7 @@ class Piwik_CorePluginsAdmin_Controller extends Admin
{
$pluginName = $this->initPluginModification();
$uninstalled = \Piwik\PluginsManager::getInstance()->uninstallPlugin($pluginName);
- if(!$uninstalled) {
+ if (!$uninstalled) {
$path = Common::getPathToPiwikRoot() . '/plugins/' . $pluginName . '/';
$messagePermissions = Piwik::getErrorMessageMissingPermissions($path);
diff --git a/plugins/CorePluginsAdmin/CorePluginsAdmin.php b/plugins/CorePluginsAdmin/CorePluginsAdmin.php
index fe4e9d8780..6116300ce2 100644
--- a/plugins/CorePluginsAdmin/CorePluginsAdmin.php
+++ b/plugins/CorePluginsAdmin/CorePluginsAdmin.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CorePluginsAdmin
+ * @package CorePluginsAdmin
*/
+namespace Piwik\Plugins\CorePluginsAdmin;
+
use Piwik\Piwik;
-use Piwik\Plugin;
/**
*
- * @package Piwik_CorePluginsAdmin
+ * @package CorePluginsAdmin
*/
-class Piwik_CorePluginsAdmin extends Plugin
+class CorePluginsAdmin extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php
index 82e24475fa..d829734ae3 100644
--- a/plugins/CoreUpdater/Controller.php
+++ b/plugins/CoreUpdater/Controller.php
@@ -6,14 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreUpdater
+ * @package CoreUpdater
*/
+namespace Piwik\Plugins\CoreUpdater;
+
+use Exception;
use Piwik\API\Request;
use Piwik\ArchiveProcessor\Rules;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\Http;
use Piwik\Updater;
use Piwik\View;
@@ -21,12 +23,15 @@ use Piwik\Version;
use Piwik\UpdateCheck;
use Piwik\Unzip;
use Piwik\View\OneClickDone;
+use Piwik\Plugins\CoreUpdater\CoreUpdater;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Updater_UpdateErrorException;
/**
*
- * @package Piwik_CoreUpdater
+ * @package CoreUpdater
*/
-class Piwik_CoreUpdater_Controller extends Controller
+class Controller extends \Piwik\Controller
{
const CONFIG_FILE_BACKUP = '/config/global.ini.auto-backup-before-update.php';
const PATH_TO_EXTRACT_LATEST_VERSION = '/tmp/latest/';
@@ -232,7 +237,7 @@ class Piwik_CoreUpdater_Controller extends Controller
{
$language = Common::getRequestVar('language', '');
if (!empty($language)) {
- Piwik_LanguagesManager::setLanguageForSession($language);
+ LanguagesManager::setLanguageForSession($language);
}
$this->runUpdaterAndExit();
}
@@ -240,7 +245,7 @@ class Piwik_CoreUpdater_Controller extends Controller
protected function runUpdaterAndExit()
{
$updater = new Updater();
- $componentsWithUpdateFile = Piwik_CoreUpdater::getComponentUpdates($updater);
+ $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater);
if (empty($componentsWithUpdateFile)) {
Piwik::redirectToModule('CoreHome');
}
diff --git a/plugins/CoreUpdater/CoreUpdater.php b/plugins/CoreUpdater/CoreUpdater.php
index 7e4d2497a5..20f3f5c0ae 100644
--- a/plugins/CoreUpdater/CoreUpdater.php
+++ b/plugins/CoreUpdater/CoreUpdater.php
@@ -6,21 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreUpdater
+ * @package CoreUpdater
*/
+namespace Piwik\Plugins\CoreUpdater;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\FrontController;
use Piwik\Updater;
use Piwik\Version;
use Piwik\UpdateCheck;
-use Piwik\Plugin;
/**
*
- * @package Piwik_CoreUpdater
+ * @package CoreUpdater
*/
-class Piwik_CoreUpdater extends Plugin
+class CoreUpdater extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -69,7 +71,7 @@ class Piwik_CoreUpdater extends Plugin
&& $action == 'saveLanguage')
) {
if (FrontController::shouldRethrowException()) {
- throw new Exception("Piwik and/or some plugins have been upgraded to a new version. \n".
+ throw new Exception("Piwik and/or some plugins have been upgraded to a new version. \n" .
"--> Please run the update process first. See documentation: http://piwik.org/docs/update/ \n");
} else {
Piwik::redirectToModule('CoreUpdater');
diff --git a/plugins/CoreVisualizations/CoreVisualizations.php b/plugins/CoreVisualizations/CoreVisualizations.php
index 00330377a2..a1b970459e 100644
--- a/plugins/CoreVisualizations/CoreVisualizations.php
+++ b/plugins/CoreVisualizations/CoreVisualizations.php
@@ -6,10 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CoreVisualizations
+ * @package CoreVisualizations
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\CoreVisualizations;
require_once PIWIK_INCLUDE_PATH . '/plugins/CoreVisualizations/JqplotDataGenerator.php';
require_once PIWIK_INCLUDE_PATH . '/plugins/CoreVisualizations/Visualizations/Cloud.php';
@@ -20,7 +20,7 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/CoreVisualizations/Visualizations/Jq
* This plugin contains all core visualizations, such as the normal HTML table and
* jqPlot graphs.
*/
-class Piwik_CoreVisualizations extends Plugin
+class CoreVisualizations extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -28,9 +28,9 @@ class Piwik_CoreVisualizations extends Plugin
public function getListHooksRegistered()
{
return array(
- 'AssetManager.getCssFiles' => 'getCssFiles',
- 'AssetManager.getJsFiles' => 'getJsFiles',
- 'DataTableVisualization.getAvailable' => 'getAvailableDataTableVisualizations',
+ 'AssetManager.getCssFiles' => 'getCssFiles',
+ 'AssetManager.getJsFiles' => 'getJsFiles',
+ 'DataTableVisualization.getAvailable' => 'getAvailableDataTableVisualizations',
);
}
diff --git a/plugins/CustomVariables/API.php b/plugins/CustomVariables/API.php
index fb3e88456e..21bdca1f55 100644
--- a/plugins/CustomVariables/API.php
+++ b/plugins/CustomVariables/API.php
@@ -6,25 +6,28 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
+namespace Piwik\Plugins\CustomVariables;
+
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Date;
use Piwik\DataTable;
use Piwik\Tracker\Action;
+use Piwik\Plugins\CustomVariables\Archiver;
/**
* The Custom Variables API lets you access reports for your <a href='http://piwik.org/docs/custom-variables/' target='_blank'>Custom Variables</a> names and values.
*
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
-class Piwik_CustomVariables_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_CustomVariables_API
+ * @return \Piwik\Plugins\CustomVariables\API
*/
static public function getInstance()
{
@@ -46,7 +49,7 @@ class Piwik_CustomVariables_API
*/
protected function getDataTable($idSite, $period, $date, $segment, $expanded, $idSubtable)
{
- $dataTable = Archive::getDataTableFromArchive(Piwik_CustomVariables_Archiver::CUSTOM_VARIABLE_RECORD_NAME, $idSite, $period, $date, $segment, $expanded, $idSubtable);
+ $dataTable = Archive::getDataTableFromArchive(Archiver::CUSTOM_VARIABLE_RECORD_NAME, $idSite, $period, $date, $segment, $expanded, $idSubtable);
$dataTable->filter('Sort', array(Metrics::INDEX_NB_ACTIONS, 'desc', $naturalSort = false, $expanded));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ColumnDelete', 'nb_uniq_visitors');
@@ -111,7 +114,7 @@ class Piwik_CustomVariables_API
$dataTable->renameColumn('price_viewed', 'price');
}
$dataTable->queueFilter('ColumnCallbackReplace', array('label', create_function('$label', '
- return $label == Piwik_CustomVariables_Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED
+ return $label == \\Piwik\\Plugins\\CustomVariables\\Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED
? "' . Piwik_Translate('General_NotDefined', Piwik_Translate('CustomVariables_ColumnCustomVariableValue')) . '"
: $label;')));
return $dataTable;
diff --git a/plugins/CustomVariables/Archiver.php b/plugins/CustomVariables/Archiver.php
index e26bb0a254..d4d3cb7884 100644
--- a/plugins/CustomVariables/Archiver.php
+++ b/plugins/CustomVariables/Archiver.php
@@ -1,24 +1,27 @@
<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ * @category Piwik_Plugins
+ * @package CustomVariables
+ */
+namespace Piwik\Plugins\CustomVariables;
+
use Piwik\Common;
use Piwik\Config;
use Piwik\DataAccess\LogAggregator;
use Piwik\Metrics;
use Piwik\DataArray;
+use Piwik\Plugins\CustomVariables\API;
use Piwik\Tracker;
use Piwik\PluginsArchiver;
use Piwik\Tracker\GoalManager;
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- * @category Piwik_Plugins
- * @package Piwik_CustomVariables
- */
-class Piwik_CustomVariables_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const LABEL_CUSTOM_VALUE_NOT_DEFINED = "Value not defined";
const CUSTOM_VARIABLE_RECORD_NAME = 'CustomVariables_valueByName';
@@ -71,8 +74,8 @@ class Piwik_CustomVariables_Archiver extends PluginsArchiver
// then we also query the "Product page view" price which was possibly recorded.
$additionalSelects = false;
// FIXMEA
- if (in_array($slot, array(3,4,5))) {
- $additionalSelects = array( $this->getSelectAveragePrice() );
+ if (in_array($slot, array(3, 4, 5))) {
+ $additionalSelects = array($this->getSelectAveragePrice());
}
$query = $this->getLogAggregator()->queryActionsByDimension($dimensions, $where, $additionalSelects);
$this->aggregateFromActions($query, $keyField, $valueField);
@@ -106,7 +109,6 @@ class Piwik_CustomVariables_Archiver extends PluginsArchiver
return self::LABEL_CUSTOM_VALUE_NOT_DEFINED;
}
-
protected function aggregateFromActions($query, $keyField, $valueField)
{
while ($row = $query->fetch()) {
@@ -171,10 +173,9 @@ class Piwik_CustomVariables_Archiver extends PluginsArchiver
protected static function isReservedKey($key)
{
- return in_array($key, Piwik_CustomVariables_API::getReservedCustomVariableKeys());
+ return in_array($key, API::getReservedCustomVariableKeys());
}
-
protected function aggregateFromConversions($query, $keyField, $valueField)
{
if ($query === false) {
@@ -190,7 +191,7 @@ class Piwik_CustomVariables_Archiver extends PluginsArchiver
protected function removeVisitsMetricsFromActionsAggregate()
{
- $dataArray = &$this->dataArray->getDataArray();
+ $dataArray = & $this->dataArray->getDataArray();
foreach ($dataArray as $key => &$row) {
if (!self::isReservedKey($key)
&& DataArray::isRowActions($row)
diff --git a/plugins/CustomVariables/Controller.php b/plugins/CustomVariables/Controller.php
index 5607e2c630..da88d4e66e 100644
--- a/plugins/CustomVariables/Controller.php
+++ b/plugins/CustomVariables/Controller.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\CustomVariables;
+
use Piwik\ViewDataTable;
use Piwik\View;
/**
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
-class Piwik_CustomVariables_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index($fetch = false)
{
diff --git a/plugins/CustomVariables/CustomVariables.php b/plugins/CustomVariables/CustomVariables.php
index 30ebb6b580..45bc3fa14b 100644
--- a/plugins/CustomVariables/CustomVariables.php
+++ b/plugins/CustomVariables/CustomVariables.php
@@ -6,17 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
+namespace Piwik\Plugins\CustomVariables;
+
use Piwik\ArchiveProcessor;
+use Piwik\Plugins\CustomVariables\Archiver;
use Piwik\Tracker;
-use Piwik\Plugin;
use Piwik\WidgetsList;
/**
- * @package Piwik_CustomVariables
+ * @package CustomVariables
*/
-class Piwik_CustomVariables extends Plugin
+class CustomVariables extends \Piwik\Plugin
{
public function getInformation()
{
@@ -137,16 +139,16 @@ class Piwik_CustomVariables extends Plugin
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_CustomVariables_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_CustomVariables_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
@@ -164,26 +166,26 @@ class Piwik_CustomVariables extends Plugin
array('<a target="_blank" href="http://piwik.org/docs/custom-variables/">', '</a>'));
return array(
- 'columns_to_display' => array('label', 'nb_actions', 'nb_visits'),
- 'filter_sort_column' => 'nb_actions',
- 'filter_sort_order' => 'desc',
- 'show_goals' => true,
+ 'columns_to_display' => array('label', 'nb_actions', 'nb_visits'),
+ 'filter_sort_column' => 'nb_actions',
+ 'filter_sort_order' => 'desc',
+ 'show_goals' => true,
'subtable_controller_action' => 'getCustomVariablesValuesFromNameId',
- 'translations' => array('label' => Piwik_Translate('CustomVariables_ColumnCustomVariableName')),
- 'show_footer_message' => $footerMessage
+ 'translations' => array('label' => Piwik_Translate('CustomVariables_ColumnCustomVariableName')),
+ 'show_footer_message' => $footerMessage
);
}
private function getDisplayPropertiesForGetCustomVariablesValuesFromNameId()
{
return array(
- 'columns_to_display' => array('label', 'nb_actions', 'nb_visits'),
- 'filter_sort_column' => 'nb_actions',
- 'filter_sort_order' => 'desc',
- 'show_goals' => true,
- 'show_search' => false,
+ 'columns_to_display' => array('label', 'nb_actions', 'nb_visits'),
+ 'filter_sort_column' => 'nb_actions',
+ 'filter_sort_order' => 'desc',
+ 'show_goals' => true,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('CustomVariables_ColumnCustomVariableValue'))
+ 'translations' => array('label' => Piwik_Translate('CustomVariables_ColumnCustomVariableValue'))
);
}
}
diff --git a/plugins/DBStats/API.php b/plugins/DBStats/API.php
index 46b3666c02..11788d19a1 100644
--- a/plugins/DBStats/API.php
+++ b/plugins/DBStats/API.php
@@ -6,11 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DBStats
+ * @package DBStats
*/
+namespace Piwik\Plugins\DBStats;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\DataTable;
+use Piwik\Plugins\DBStats\MySQLMetadataProvider;
/**
* @see plugins/DBStats/MySQLMetadataProvider.php
@@ -20,9 +23,9 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/DBStats/MySQLMetadataProvider.php';
/**
* DBStats API is used to request the overall status of the Mysql tables in use by Piwik.
*
- * @package Piwik_DBStats
+ * @package DBStats
*/
-class Piwik_DBStats_API
+class API
{
/** Singleton instance of this class. */
static private $instance = null;
@@ -48,7 +51,7 @@ class Piwik_DBStats_API
*/
public function __construct()
{
- $this->metadataProvider = new Piwik_DBStats_MySQLMetadataProvider();
+ $this->metadataProvider = new MySQLMetadataProvider();
}
/**
@@ -57,7 +60,7 @@ class Piwik_DBStats_API
public function resetTableStatuses()
{
Piwik::checkUserIsSuperUser();
- self::getInstance()->metadataProvider = new Piwik_DBStats_MySQLMetadataProvider();
+ self::getInstance()->metadataProvider = new MySQLMetadataProvider();
}
/**
@@ -169,8 +172,7 @@ class Piwik_DBStats_API
$dataTable = $this->getMetricDataSummary();
- $getTableYear = array('Piwik_DBStats_API', 'getArchiveTableYear');
- $dataTable->filter('GroupBy', array('label', $getTableYear));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\API::getArchiveTableYear'));
return $dataTable;
}
@@ -199,8 +201,7 @@ class Piwik_DBStats_API
$dataTable = $this->getReportDataSummary();
- $getTableYear = array('Piwik_DBStats_API', 'getArchiveTableYear');
- $dataTable->filter('GroupBy', array('label', $getTableYear));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\API::getArchiveTableYear'));
return $dataTable;
}
diff --git a/plugins/DBStats/Controller.php b/plugins/DBStats/Controller.php
index 51f2a00ae6..941b095f81 100644
--- a/plugins/DBStats/Controller.php
+++ b/plugins/DBStats/Controller.php
@@ -6,18 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DBStats
+ * @package DBStats
*/
-use Piwik\Controller\Admin;
+namespace Piwik\Plugins\DBStats;
+
use Piwik\Piwik;
+use Piwik\Plugins\DBStats\API;
use Piwik\ViewDataTable;
use Piwik\View;
/**
- *
- * @package Piwik_DBStats
+ * @package DBStats
*/
-class Piwik_DBStats_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
/**
* Returns the index for this plugin. Shows every other report defined by this plugin,
@@ -38,7 +39,7 @@ class Piwik_DBStats_Controller extends Admin
$view->reportDataSummary = $this->getReportDataSummary(true);
$view->adminDataSummary = $this->getAdminDataSummary(true);
- list($siteCount, $userCount, $totalSpaceUsed) = Piwik_DBStats_API::getInstance()->getGeneralInformation();
+ list($siteCount, $userCount, $totalSpaceUsed) = API::getInstance()->getGeneralInformation();
$view->siteCount = Piwik::getPrettyNumber($siteCount);
$view->userCount = Piwik::getPrettyNumber($userCount);
$view->totalSpaceUsed = Piwik::getPrettySizeFromBytes($totalSpaceUsed);
diff --git a/plugins/DBStats/DBStats.php b/plugins/DBStats/DBStats.php
index 630bf4fe57..e3821800cc 100644
--- a/plugins/DBStats/DBStats.php
+++ b/plugins/DBStats/DBStats.php
@@ -6,20 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DBStats
+ * @package DBStats
*/
+namespace Piwik\Plugins\DBStats;
+
use Piwik\Piwik;
use Piwik\Date;
use Piwik\Common;
+use Piwik\Plugins\DBStats\API;
use Piwik\ScheduledTask;
-use Piwik\Plugin;
use Piwik\ScheduledTime\Weekly;
/**
*
- * @package Piwik_DBStats
+ * @package DBStats
*/
-class Piwik_DBStats extends Plugin
+class DBStats extends \Piwik\Plugin
{
const TIME_OF_LAST_TASK_RUN_OPTION = 'dbstats_time_of_last_cache_task_run';
@@ -65,7 +67,7 @@ class Piwik_DBStats extends Plugin
*/
public function cacheDataByArchiveNameReports()
{
- $api = Piwik_DBStats_API::getInstance();
+ $api = API::getInstance();
$api->getIndividualReportsSummary(true);
$api->getIndividualMetricsSummary(true);
@@ -202,7 +204,7 @@ class Piwik_DBStats extends Plugin
$result = array();
$this->addBaseDisplayProperties($result);
$viewDataTable = $this->addPresentationFilters($result, $addTotalSizeColumn = false, $addPercentColumn = false,
- $sizeColumns = array('estimated_size'));
+ $sizeColumns = array('estimated_size'));
$result['filter_sort_order'] = 'asc';
$result['translations']['label'] = Piwik_Translate('General_Report');
@@ -222,7 +224,7 @@ class Piwik_DBStats extends Plugin
$result = array();
$this->addBaseDisplayProperties($result);
$this->addPresentationFilters($result, $addTotalSizeColumn = false, $addPercentColumn = false,
- $sizeColumns = array('estimated_size'));
+ $sizeColumns = array('estimated_size'));
$result['filter_sort_order'] = 'asc';
$result['translations']['label'] = Piwik_Translate('General_Metric');
@@ -279,7 +281,7 @@ class Piwik_DBStats extends Plugin
};
$properties['filters'][] = array('ColumnCallbackAddColumn',
- array(array('data_size', 'index_size'), 'total_size', $getTotalTableSize), $isPriority = true);
+ array(array('data_size', 'index_size'), 'total_size', $getTotalTableSize), $isPriority = true);
$sizeColumns[] = 'total_size';
}
@@ -299,9 +301,9 @@ class Piwik_DBStats extends Plugin
&& $addTotalSizeColumn
) {
$properties['filters'][] = array('ColumnCallbackAddColumnPercentage',
- array('percent_total', 'total_size', 'total_size', $quotientPrecision = 0,
- $shouldSkipRows = false, $getDivisorFromSummaryRow = true),
- $isPriority = true
+ array('percent_total', 'total_size', 'total_size', $quotientPrecision = 0,
+ $shouldSkipRows = false, $getDivisorFromSummaryRow = true),
+ $isPriority = true
);
$properties['filter_sort_column'] = 'percent_total';
diff --git a/plugins/DBStats/MySQLMetadataProvider.php b/plugins/DBStats/MySQLMetadataProvider.php
index d47713cf30..4e39d50887 100755
--- a/plugins/DBStats/MySQLMetadataProvider.php
+++ b/plugins/DBStats/MySQLMetadataProvider.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DBStats
+ * @package DBStats
*/
+namespace Piwik\Plugins\DBStats;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Config;
use Piwik\DataTable;
use Piwik\Db;
-
/**
* Utility class that provides general information about databases, including the size of
* the entire database, the size and row count of each table and the size and row count
@@ -23,7 +25,7 @@ use Piwik\Db;
* This class will cache the table information it retrieves from the database. In order to
* issue a new query instead of using this cache, you must create a new instance of this type.
*/
-class Piwik_DBStats_MySQLMetadataProvider
+class MySQLMetadataProvider
{
/**
* Cached MySQL table statuses. So we won't needlessly re-issue SHOW TABLE STATUS queries.
diff --git a/plugins/Dashboard/API.php b/plugins/Dashboard/API.php
index dd87979739..1330eacef6 100644
--- a/plugins/Dashboard/API.php
+++ b/plugins/Dashboard/API.php
@@ -5,21 +5,22 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
* @category Piwik_Plugins
- * @package Piwik_Dashboard
+ * @package Dashboard
*/
+namespace Piwik\Plugins\Dashboard;
+
use Piwik\Piwik;
use Piwik\WidgetsList;
-
/**
* This API is the <a href='http://piwik.org/docs/analytics-api/reference/' target='_blank'>Dashboard API</a>: it gives information about dashboards.
*
* @package Piwik_API
*/
-class Piwik_Dashboard_API
+class API
{
/**
- * @var Piwik_Dashboard_API
+ * @var \Piwik\Plugins\Dashboard\API
*/
static private $instance = null;
@@ -27,11 +28,11 @@ class Piwik_Dashboard_API
public function __construct()
{
- $this->dashboard = new Piwik_Dashboard();
+ $this->dashboard = new Dashboard();
}
/**
- * @return Piwik_Dashboard_API
+ * @return \Piwik\Plugins\Dashboard\API
*/
static public function getInstance()
{
@@ -83,7 +84,7 @@ class Piwik_Dashboard_API
*/
private function getUserDashboards()
{
- $userLogin = Piwik::getCurrentUserLogin();
+ $userLogin = Piwik::getCurrentUserLogin();
$userDashboards = $this->dashboard->getAllDashboards($userLogin);
$dashboards = array();
@@ -91,10 +92,9 @@ class Piwik_Dashboard_API
foreach ($userDashboards as $userDashboard) {
if ($this->hasDashboardColumns($userDashboard)) {
- $widgets = $this->getExistingWidgetsWithinDashboard($userDashboard);
+ $widgets = $this->getExistingWidgetsWithinDashboard($userDashboard);
$dashboards[] = $this->buildDashboard($userDashboard, $widgets);
}
-
}
return $dashboards;
@@ -111,8 +111,8 @@ class Piwik_Dashboard_API
foreach ($column as $widget) {
if ($this->widgetIsNotHidden($widget) && $this->widgetExists($widget)) {
- $module = $widget->parameters->module;
- $action = $widget->parameters->action;
+ $module = $widget->parameters->module;
+ $action = $widget->parameters->action;
$widgets[] = array('module' => $module, 'action' => $action);
}
diff --git a/plugins/Dashboard/Controller.php b/plugins/Dashboard/Controller.php
index 7ffe0dc79e..bded95b33e 100644
--- a/plugins/Dashboard/Controller.php
+++ b/plugins/Dashboard/Controller.php
@@ -5,12 +5,14 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
* @category Piwik_Plugins
- * @package Piwik_Dashboard
+ * @package Dashboard
*/
+namespace Piwik\Plugins\Dashboard;
+
use Piwik\DataTable\Renderer\Json;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\Dashboard\Dashboard;
use Piwik\Session\SessionNamespace;
use Piwik\View;
use Piwik\Db;
@@ -19,12 +21,12 @@ use Piwik\WidgetsList;
/**
* Dashboard Controller
*
- * @package Piwik_Dashboard
+ * @package Dashboard
*/
-class Piwik_Dashboard_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
- * @var Piwik_Dashboard
+ * @var Dashboard
*/
private $dashboard;
@@ -32,7 +34,7 @@ class Piwik_Dashboard_Controller extends Controller
{
parent::init();
- $this->dashboard = new Piwik_Dashboard();
+ $this->dashboard = new Dashboard();
}
protected function _getDashboardView($template)
@@ -96,7 +98,7 @@ class Piwik_Dashboard_Controller extends Controller
$layout = $this->dashboard->getDefaultLayout();
$idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
if (Piwik::isUserIsAnonymous()) {
- $session = new SessionNamespace("Piwik_Dashboard");
+ $session = new SessionNamespace("Dashboard");
$session->dashboardLayout = $layout;
$session->setExpirationSeconds(1800);
} else {
@@ -161,15 +163,15 @@ class Piwik_Dashboard_Controller extends Controller
public function getAllDashboards()
{
$this->checkTokenInUrl();
-
+
if (Piwik::isUserIsAnonymous()) {
Json::sendHeaderJSON();
echo '[]';
-
+
return;
}
- $login = Piwik::getCurrentUserLogin();
+ $login = Piwik::getCurrentUserLogin();
$dashboards = $this->dashboard->getAllDashboards($login);
Json::sendHeaderJSON();
@@ -260,7 +262,7 @@ class Piwik_Dashboard_Controller extends Controller
$idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
$name = Common::getRequestVar('name', '', 'string');
if (Piwik::isUserIsAnonymous()) {
- $session = new SessionNamespace("Piwik_Dashboard");
+ $session = new SessionNamespace("Dashboard");
$session->dashboardLayout = $layout;
$session->setExpirationSeconds(1800);
} else {
@@ -298,14 +300,13 @@ class Piwik_Dashboard_Controller extends Controller
{
if (Piwik::isUserIsAnonymous()) {
- $session = new SessionNamespace("Piwik_Dashboard");
+ $session = new SessionNamespace("Dashboard");
if (!isset($session->dashboardLayout)) {
return $this->dashboard->getDefaultLayout();
}
$layout = $session->dashboardLayout;
-
} else {
$layout = $this->dashboard->getLayoutForUser(Piwik::getCurrentUserLogin(), $idDashboard);
}
@@ -335,7 +336,6 @@ class Piwik_Dashboard_Controller extends Controller
array(25, 25, 25, 25)
);
}
-
}
diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php
index 13d25ee9cb..58618e05b4 100644
--- a/plugins/Dashboard/Dashboard.php
+++ b/plugins/Dashboard/Dashboard.php
@@ -6,19 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Dashboard
+ * @package Dashboard
*/
+namespace Piwik\Plugins\Dashboard;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Plugin;
use Piwik\Site;
use Piwik\Db;
use Piwik\WidgetsList;
+use Zend_Registry;
/**
- * @package Piwik_Dashboard
+ * @package Dashboard
*/
-class Piwik_Dashboard extends Plugin
+class Dashboard extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/DevicesDetection/API.php b/plugins/DevicesDetection/API.php
index 1800849fcf..250919c565 100644
--- a/plugins/DevicesDetection/API.php
+++ b/plugins/DevicesDetection/API.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Piwik - Open source web analytics
*
@@ -7,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DevicesDetection
+ * @package DevicesDetection
*/
+
+namespace Piwik\Plugins\DevicesDetection;
+
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
@@ -17,14 +19,14 @@ use Piwik\DataTable;
/**
* The DevicesDetection API lets you access reports on your visitors devices, brands, models, Operating system, Browsers.
*/
-class Piwik_DevicesDetection_API
+class API
{
static private $instance = null;
/**
- *
- * @return Piwik_DevicesDetection_API
+ *
+ * @return \Piwik\Plugins\DevicesDetection\API
*/
static public function getInstance()
{
@@ -64,9 +66,9 @@ class Piwik_DevicesDetection_API
public function getType($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_types', $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getDeviceTypeLabel'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getDeviceTypeLabel'));
$dataTable->filter('ColumnCallbackReplace', array('label', 'ucfirst'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getDeviceTypeLogo'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getDeviceTypeLogo'));
return $dataTable;
}
@@ -81,8 +83,8 @@ class Piwik_DevicesDetection_API
public function getBrand($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_brands', $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getDeviceBrandLabel'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_GetBrandLogo'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getDeviceBrandLabel'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrandLogo'));
return $dataTable;
}
@@ -97,7 +99,7 @@ class Piwik_DevicesDetection_API
public function getModel($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_models', $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getModelName'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getModelName'));
return $dataTable;
}
@@ -112,8 +114,8 @@ class Piwik_DevicesDetection_API
public function getOsFamilies($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_os', $idSite, $period, $date, $segment);
- $dataTable->filter('GroupBy', array('label', 'Piwik_getOSFamilyFullNameExtended'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getOsFamilyLogoExtended'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getOSFamilyFullNameExtended'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsFamilyLogoExtended'));
return $dataTable;
}
@@ -128,15 +130,15 @@ class Piwik_DevicesDetection_API
public function getOsVersions($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_osVersions', $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getOsLogoExtended'));
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getOsFullNameExtended'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsLogoExtended'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getOsFullNameExtended'));
return $dataTable;
}
/**
* Gets datatable displaying number of visits by Browser family (eg. Firefox, InternetExplorer)
- * @param int $idSite
+ * @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
@@ -145,8 +147,8 @@ class Piwik_DevicesDetection_API
public function getBrowserFamilies($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_browsers', $idSite, $period, $date, $segment);
- $dataTable->filter('GroupBy', array('label', 'Piwik_getBrowserFamilyFullNameExtended'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getBrowserFamilyLogoExtended'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserFamilyFullNameExtended'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowserFamilyLogoExtended'));
return $dataTable;
}
@@ -161,9 +163,8 @@ class Piwik_DevicesDetection_API
public function getBrowserVersions($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_browserVersions', $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getBrowserLogoExtended'));
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getBrowserNameExtended'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowserLogoExtended'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getBrowserNameExtended'));
return $dataTable;
}
-
} \ No newline at end of file
diff --git a/plugins/DevicesDetection/Archiver.php b/plugins/DevicesDetection/Archiver.php
index 73a66fb67d..58b1df2cca 100644
--- a/plugins/DevicesDetection/Archiver.php
+++ b/plugins/DevicesDetection/Archiver.php
@@ -6,13 +6,15 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DevicesDetection
+ * @package DevicesDetection
*/
+namespace Piwik\Plugins\DevicesDetection;
+
use Piwik\Metrics;
use Piwik\PluginsArchiver;
-class Piwik_DevicesDetection_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const DEVICE_TYPE_RECORD_NAME = 'DevicesDetection_types';
const DEVICE_BRAND_RECORD_NAME = 'DevicesDetection_brands';
@@ -32,16 +34,16 @@ class Piwik_DevicesDetection_Archiver extends PluginsArchiver
public function archiveDay()
{
- $this->aggregateByLabel( self::DEVICE_TYPE_FIELD, self::DEVICE_TYPE_RECORD_NAME);
- $this->aggregateByLabel( self::DEVICE_BRAND_FIELD, self::DEVICE_BRAND_RECORD_NAME);
- $this->aggregateByLabel( self::DEVICE_MODEL_FIELD, self::DEVICE_MODEL_RECORD_NAME);
- $this->aggregateByLabel( self::OS_FIELD, self::OS_RECORD_NAME);
- $this->aggregateByLabel( self::OS_VERSION_FIELD, self::OS_VERSION_RECORD_NAME);
- $this->aggregateByLabel( self::BROWSER_FIELD, self::BROWSER_RECORD_NAME);
- $this->aggregateByLabel( self::BROWSER_VERSION_DIMENSION, self::BROWSER_VERSION_RECORD_NAME);
+ $this->aggregateByLabel(self::DEVICE_TYPE_FIELD, self::DEVICE_TYPE_RECORD_NAME);
+ $this->aggregateByLabel(self::DEVICE_BRAND_FIELD, self::DEVICE_BRAND_RECORD_NAME);
+ $this->aggregateByLabel(self::DEVICE_MODEL_FIELD, self::DEVICE_MODEL_RECORD_NAME);
+ $this->aggregateByLabel(self::OS_FIELD, self::OS_RECORD_NAME);
+ $this->aggregateByLabel(self::OS_VERSION_FIELD, self::OS_VERSION_RECORD_NAME);
+ $this->aggregateByLabel(self::BROWSER_FIELD, self::BROWSER_RECORD_NAME);
+ $this->aggregateByLabel(self::BROWSER_VERSION_DIMENSION, self::BROWSER_VERSION_RECORD_NAME);
}
- private function aggregateByLabel( $labelSQL, $recordName)
+ private function aggregateByLabel($labelSQL, $recordName)
{
$metrics = $this->getProcessor()->getMetricsForDimension($labelSQL);
$table = $this->getProcessor()->getDataTableFromDataArray($metrics);
diff --git a/plugins/DevicesDetection/Controller.php b/plugins/DevicesDetection/Controller.php
index 189729e81e..ac0beb50d4 100644
--- a/plugins/DevicesDetection/Controller.php
+++ b/plugins/DevicesDetection/Controller.php
@@ -1,12 +1,4 @@
<?php
-use Piwik\Piwik;
-use Piwik\Common;
-use Piwik\Controller;
-use Piwik\ViewDataTable;
-use Piwik\View;
-use Piwik\Db;
-
-
/**
* Piwik - Open source web analytics
*
@@ -14,9 +6,18 @@ use Piwik\Db;
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DevicesDetection
+ * @package DevicesDetection
*/
-class Piwik_DevicesDetection_Controller extends Controller
+namespace Piwik\Plugins\DevicesDetection;
+
+use Piwik\Piwik;
+use Piwik\Common;
+use Piwik\ViewDataTable;
+use Piwik\View;
+use Piwik\Db;
+use UserAgentParserEnhanced;
+
+class Controller extends \Piwik\Controller
{
public function index($fetch = false)
{
diff --git a/plugins/DevicesDetection/DevicesDetection.php b/plugins/DevicesDetection/DevicesDetection.php
index 35fb148866..d207cdc285 100644
--- a/plugins/DevicesDetection/DevicesDetection.php
+++ b/plugins/DevicesDetection/DevicesDetection.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Piwik - Open source web analytics
*
@@ -7,20 +6,25 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DevicesDetection
+ * @package DevicesDetection
*/
+
+namespace Piwik\Plugins\DevicesDetection;
+
+use Exception;
use Piwik\ArchiveProcessor;
use Piwik\Config;
use Piwik\Common;
-use Piwik\Plugin;
+use Piwik\Plugins\DevicesDetection\Archiver;
use Piwik\WidgetsList;
use Piwik\Db;
-
+use UserAgentParserEnhanced;
+use Zend_Registry;
require_once PIWIK_INCLUDE_PATH . "/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php";
require_once PIWIK_INCLUDE_PATH . '/plugins/DevicesDetection/functions.php';
-class Piwik_DevicesDetection extends Plugin
+class DevicesDetection extends \Piwik\Plugin
{
/** The set of related reports displayed under the 'Operating Systems' header. */
private $osRelatedReports = null;
@@ -45,27 +49,26 @@ class Piwik_DevicesDetection extends Plugin
public function getInformation()
{
return array(
- 'description' => "[Beta Plugin] " . Piwik_Translate("DevicesDetection_description"),
- 'author' => 'Piwik and Clearcode.cc',
+ 'description' => "[Beta Plugin] " . Piwik_Translate("DevicesDetection_description"),
+ 'author' => 'Piwik and Clearcode.cc',
'author_homepage' => 'http://clearcode.cc',
- 'version' => '1.12-b6',
+ 'version' => '1.12-b6',
);
}
-
/**
* @see Piwik_Plugin::getListHooksRegistered
*/
public function getListHooksRegistered()
{
return array(
- 'ArchiveProcessing_Day.compute' => "archiveDay",
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'Menu.add' => 'addMenu',
- 'Tracker.newVisitorInformation' => 'parseMobileVisitData',
- 'WidgetsList.add' => 'addWidgets',
- 'API.getReportMetadata' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ArchiveProcessing_Day.compute' => "archiveDay",
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'Menu.add' => 'addMenu',
+ 'Tracker.newVisitorInformation' => 'parseMobileVisitData',
+ 'WidgetsList.add' => 'addWidgets',
+ 'API.getReportMetadata' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
}
@@ -155,7 +158,6 @@ class Piwik_DevicesDetection extends Plugin
}
}
-
/**
* Get segments meta data
*/
@@ -187,12 +189,12 @@ class Piwik_DevicesDetection extends Plugin
continue;
$report = array(
- 'category' => Piwik_Translate($category),
- 'name' => Piwik_Translate($name),
- 'module' => $apiModule,
- 'action' => $apiAction,
+ 'category' => Piwik_Translate($category),
+ 'name' => Piwik_Translate($name),
+ 'module' => $apiModule,
+ 'action' => $apiAction,
'dimension' => Piwik_Translate($columnName),
- 'order' => $i++
+ 'order' => $i++
);
$translation = $name . 'Documentation';
@@ -201,7 +203,6 @@ class Piwik_DevicesDetection extends Plugin
$report['documentation'] = $translated;
}
-
$reports[] = $report;
}
}
@@ -223,7 +224,7 @@ class Piwik_DevicesDetection extends Plugin
Db::exec($q2);
}
} catch (Exception $e) {
- if (!Zend_Registry::get('db')->isErrNo($e, '1060')) {
+ if (!Zend_Registry::get('db')->isErrNo($e, '1060')) {
throw $e;
}
}
@@ -254,16 +255,16 @@ class Piwik_DevicesDetection extends Plugin
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_DevicesDetection_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_DevicesDetection_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
@@ -287,34 +288,34 @@ class Piwik_DevicesDetection extends Plugin
private function getDisplayPropertiesForGetType()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelTypes"))
+ 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelTypes"))
);
}
private function getDisplayPropertiesForGetBrand()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrands"))
+ 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrands"))
);
}
private function getDisplayPropertiesForGetModel()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelModels"))
+ 'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelModels"))
);
}
private function getDisplayPropertiesForGetOsFamilies()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelSystemFamily")),
'title' => Piwik_Translate('DeviceDetection_OperatingSystemFamilies'),
@@ -325,7 +326,7 @@ class Piwik_DevicesDetection extends Plugin
private function getDisplayPropertiesForGetOsVersions()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelSystemVersion")),
'title' => Piwik_Translate('DeviceDetection_OperatingSystemVersions'),
@@ -336,7 +337,7 @@ class Piwik_DevicesDetection extends Plugin
private function getDisplayPropertiesForGetBrowserFamilies()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrowserFamily")),
'title' => Piwik_Translate('DevicesDetection_BrowsersFamily'),
@@ -347,7 +348,7 @@ class Piwik_DevicesDetection extends Plugin
private function getDisplayPropertiesForGetBrowserVersions()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
'translations' => array('label' => Piwik_Translate("DevicesDetection_dataTableLabelBrowserVersion")),
'related_reports' => $this->getBrowserRelatedReports()
diff --git a/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php b/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php
index d078305d97..a8ec8e2204 100644
--- a/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php
+++ b/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php
@@ -7,7 +7,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DevicesDetection
+ * @package DevicesDetection
*/
//yml parser
require_once(PIWIK_INCLUDE_PATH.'/libs/spyc.php');
diff --git a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/browsers.yml b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/browsers.yml
index 9ab3bc4c1c..351aa7f268 100644
--- a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/browsers.yml
+++ b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/browsers.yml
@@ -5,7 +5,7 @@
# @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
#
# @category Piwik_Plugins
-# @package Piwik_DevicesDetection
+# @package DevicesDetection
###############
# SeaMonkey
diff --git a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/mobiles.yml b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/mobiles.yml
index d9a2a22f88..46ae6b9c97 100644
--- a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/mobiles.yml
+++ b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/mobiles.yml
@@ -5,7 +5,7 @@
# @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
#
# @category Piwik_Plugins
-# @package Piwik_DevicesDetection
+# @package DevicesDetection
###############
# HTC
diff --git a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml
index 71b85f987f..918a00487d 100644
--- a/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml
+++ b/plugins/DevicesDetection/UserAgentParserEnhanced/regexes/oss.yml
@@ -5,7 +5,7 @@
# @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
#
# @category Piwik_Plugins
-# @package Piwik_DevicesDetection
+# @package DevicesDetection
###############
##########
diff --git a/plugins/DevicesDetection/functions.php b/plugins/DevicesDetection/functions.php
index 4819cd6974..92a4b3e84e 100644
--- a/plugins/DevicesDetection/functions.php
+++ b/plugins/DevicesDetection/functions.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Piwik - Open source web analytics
*
@@ -7,9 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DevicesDetection
+ * @package DevicesDetection
*/
-function Piwik_GetBrandLogo($label)
+
+namespace Piwik\Plugins\DevicesDetection;
+
+use UserAgentParserEnhanced;
+
+function getBrandLogo($label)
{
$path = dirname(__FILE__) . '/images/brand/' . $label . '.ico';
if (file_exists($path)) {
@@ -19,7 +23,7 @@ function Piwik_GetBrandLogo($label)
}
}
-function Piwik_getBrowserFamilyFullNameExtended($label)
+function getBrowserFamilyFullNameExtended($label)
{
foreach (UserAgentParserEnhanced::$browserFamilies as $name => $family) {
if (in_array($label, $family)) {
@@ -29,7 +33,7 @@ function Piwik_getBrowserFamilyFullNameExtended($label)
return Piwik_Translate('General_Unknown');
}
-function Piwik_getBrowserFamilyLogoExtended($label)
+function getBrowserFamilyLogoExtended($label)
{
if (array_key_exists($label, UserAgentParserEnhanced::$browserFamilies)) {
$path = 'plugins/UserSettings/images/browsers/' . UserAgentParserEnhanced::$browserFamilies[$label][0] . '.gif';
@@ -39,7 +43,7 @@ function Piwik_getBrowserFamilyLogoExtended($label)
return $path;
}
-function Piwik_getBrowserNameExtended($label)
+function getBrowserNameExtended($label)
{
$short = substr($label, 0, 2);
$ver = substr($label, 3, 10);
@@ -50,17 +54,17 @@ function Piwik_getBrowserNameExtended($label)
}
}
-function Piwik_getBrowserLogoExtended($label)
+function getBrowserLogoExtended($label)
{
$short = substr($label, 0, 2);
- $familyName = Piwik_getBrowserFamilyFullNameExtended($short);
- $path = Piwik_getBrowserFamilyLogoExtended($familyName);
+ $familyName = getBrowserFamilyFullNameExtended($short);
+ $path = getBrowserFamilyLogoExtended($familyName);
return $path;
}
-function Piwik_getDeviceBrandLabel($label)
+function getDeviceBrandLabel($label)
{
if (array_key_exists($label, UserAgentParserEnhanced::$deviceBrands)) {
return ucfirst(UserAgentParserEnhanced::$deviceBrands[$label]);
@@ -69,7 +73,7 @@ function Piwik_getDeviceBrandLabel($label)
}
}
-function Piwik_getDeviceTypeLabel($label)
+function getDeviceTypeLabel($label)
{
if (isset(UserAgentParserEnhanced::$deviceTypes[$label])) {
return UserAgentParserEnhanced::$deviceTypes[$label];
@@ -78,7 +82,7 @@ function Piwik_getDeviceTypeLabel($label)
}
}
-function Piwik_getDeviceTypeLogo($label)
+function getDeviceTypeLogo($label)
{
$deviceTypeLogos = Array(
"Desktop" => "normal.gif",
@@ -97,7 +101,7 @@ function Piwik_getDeviceTypeLogo($label)
return $path;
}
-function Piwik_getModelName($label)
+function getModelName($label)
{
if (!$label) {
return Piwik_Translate('General_Unknown');
@@ -105,7 +109,7 @@ function Piwik_getModelName($label)
return $label;
}
-function Piwik_getOSFamilyFullNameExtended($label)
+function getOSFamilyFullNameExtended($label)
{
foreach (UserAgentParserEnhanced::$osFamilies as $name => $family) {
if (in_array($label, $family)) {
@@ -115,7 +119,7 @@ function Piwik_getOSFamilyFullNameExtended($label)
return Piwik_Translate('General_Unknown');
}
-function Piwik_getOsFamilyLogoExtended($label)
+function getOsFamilyLogoExtended($label)
{
if (array_key_exists($label, UserAgentParserEnhanced::$osFamilies)) {
$path = 'plugins/UserSettings/images/os/' . UserAgentParserEnhanced::$osFamilies[$label][0] . ".gif";
@@ -125,7 +129,7 @@ function Piwik_getOsFamilyLogoExtended($label)
return $path;
}
-function Piwik_getOsFullNameExtended($label)
+function getOsFullNameExtended($label)
{
if (!empty($label) && $label != ";") {
$os = substr($label, 0, 3);
@@ -140,10 +144,10 @@ function Piwik_getOsFullNameExtended($label)
-function Piwik_getOsLogoExtended($label)
+function getOsLogoExtended($label)
{
$short = substr($label, 0, 3);
- $familyName = Piwik_getOsFamilyFullNameExtended($short);
- $path = Piwik_getOsFamilyLogoExtended($familyName);
+ $familyName = getOsFamilyFullNameExtended($short);
+ $path = getOsFamilyLogoExtended($familyName);
return $path;
} \ No newline at end of file
diff --git a/plugins/DoNotTrack/DoNotTrack.php b/plugins/DoNotTrack/DoNotTrack.php
index 8d9a3cf700..1a02788a27 100644
--- a/plugins/DoNotTrack/DoNotTrack.php
+++ b/plugins/DoNotTrack/DoNotTrack.php
@@ -6,9 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_DoNotTrack
+ * @package DoNotTrack
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\DoNotTrack;
+
use Piwik\Common;
use Piwik\Tracker\IgnoreCookie;
use Piwik\Tracker\Request;
@@ -18,9 +19,9 @@ use Piwik\Tracker\Request;
* - X-Do-Not-Track header (used by AdBlockPlus and NoScript)
* - DNT header (used by Mozilla)
*
- * @package Piwik_DoNotTrack
+ * @package DoNotTrack
*/
-class Piwik_DoNotTrack extends Plugin
+class DoNotTrack extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/ExampleAPI/API.php b/plugins/ExampleAPI/API.php
index 214d73eac5..a6c012a644 100644
--- a/plugins/ExampleAPI/API.php
+++ b/plugins/ExampleAPI/API.php
@@ -8,9 +8,11 @@
* @category Piwik_Plugins
* @package Piwik_ExampleAPI
*/
+namespace Piwik\Plugins\ExampleAPI;
+
+use Piwik\DataTable;
use Piwik\DataTable\Row;
use Piwik\Piwik;
-use Piwik\DataTable;
use Piwik\Version;
/**
@@ -19,7 +21,7 @@ use Piwik\Version;
* Please see the <a href='http://dev.piwik.org/trac/browser/trunk/plugins/ExampleAPI/API.php#L1' target='_blank'>source code in in the file plugins/ExampleAPI/API.php</a> for more documentation.
* @package Piwik_ExampleAPI
*/
-class Piwik_ExampleAPI_API
+class API
{
/**
* * This is an example of a basic API file. Each plugin can have one public API.
@@ -38,14 +40,14 @@ class Piwik_ExampleAPI_API
*
* It is highly recommended that all the plugin logic is done inside API implementations, and the
* Controller and other objects would all call the API internally using, eg.
- * Piwik_ExampleAPI_API::getInstance()->getSum(1, 2);
+ * API::getInstance()->getSum(1, 2);
*
*/
static private $instance = null;
/**
* Singleton
- * @return Piwik_ExampleAPI_API
+ * @return \Piwik\Plugins\ExampleAPI\API
*/
static public function getInstance()
{
@@ -80,11 +82,11 @@ class Piwik_ExampleAPI_API
* If used internally, the data structure can be returned untouched by using
* the API parameter 'format=original'
*
- * @return Piwik_MagicObject Will return a standard Piwik error when called from the Web APIs
+ * @return MagicObject Will return a standard Piwik error when called from the Web APIs
*/
public function getObject()
{
- return new Piwik_MagicObject();
+ return new MagicObject();
}
/**
@@ -180,9 +182,9 @@ class Piwik_ExampleAPI_API
/**
* Magic Object
*
- * @package Piwik_ExamplePlugin
+ * @package ExamplePlugin
*/
-class Piwik_MagicObject
+class MagicObject
{
function Incredible()
{
@@ -191,4 +193,4 @@ class Piwik_MagicObject
protected $wonderful = 'magnifique';
public $great = 'formidable';
-}
+} \ No newline at end of file
diff --git a/plugins/ExampleAPI/ExampleAPI.php b/plugins/ExampleAPI/ExampleAPI.php
deleted file mode 100644
index da1c3f4c52..0000000000
--- a/plugins/ExampleAPI/ExampleAPI.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- * @category Piwik_Plugins
- * @package Piwik_ExampleAPI
- */
-use Piwik\Plugin;
-
-/**
- * ExampleAPI plugin
- *
- * @package Piwik_ExampleAPI
- */
-class Piwik_ExampleAPI extends Plugin
-{
-}
diff --git a/plugins/ExamplePlugin/Controller.php b/plugins/ExamplePlugin/Controller.php
index dfb4c18eb5..c13df5baa9 100644
--- a/plugins/ExamplePlugin/Controller.php
+++ b/plugins/ExamplePlugin/Controller.php
@@ -6,21 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExamplePlugin
+ * @package ExamplePlugin
*/
+namespace Piwik\Plugins\ExamplePlugin;
+
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\View;
use Piwik\Db;
use Piwik\WidgetsList;
-
+use Piwik\Plugins\SitesManager\API;
/**
*
- * @package Piwik_ExamplePlugin
+ * @package ExamplePlugin
*/
-class Piwik_ExamplePlugin_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
* Go to /piwik/?module=ExamplePlugin&action=helloWorld to execute this method
@@ -89,7 +90,6 @@ class Piwik_ExamplePlugin_Controller extends Controller
$out .= '<code>WidgetsList::add( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array());</code> - Adds a widget that users can add in the dashboard, or export using the Widgets link at the top of the screen. See the example in the <a href="https://github.com/piwik/piwik/blob/1.0/plugins/UserCountry/UserCountry.php#L70">UserCountry Plugin file</a> or any other plugin)<br />';
$out .= '<code>Common::prefixTable("site")</code> = <b>' . Common::prefixTable("site") . '</b><br />';
-
$out .= '<h2>User access</h2>';
$out .= '<code>Piwik::getCurrentUserLogin()</code> = <b>' . Piwik::getCurrentUserLogin() . '</b><br />';
$out .= '<code>Piwik::isUserHasSomeAdminAccess()</code> = <b>' . self::boolToString(Piwik::isUserHasSomeAdminAccess()) . '</b><br />';
@@ -112,19 +112,19 @@ class Piwik_ExamplePlugin_Controller extends Controller
$out .= 'At this point, we have: <code>$fetched[\'token_auth\'] == <b>' . var_export($token_auth, true) . '</b></code><br />';
$out .= '<h2>Example Sites information API</h2>';
- $out .= '<code>Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess()</code> = <b><pre>' . var_export(Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess(), true) . '</pre></b><br />';
- $out .= '<code>Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess()</code> = <b><pre>' . var_export(Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess(), true) . '</pre></b><br />';
+ $out .= '<code>API::getInstance()->getSitesWithViewAccess()</code> = <b><pre>' . var_export(API::getInstance()->getSitesWithViewAccess(), true) . '</pre></b><br />';
+ $out .= '<code>API::getInstance()->getSitesWithAdminAccess()</code> = <b><pre>' . var_export(API::getInstance()->getSitesWithAdminAccess(), true) . '</pre></b><br />';
$out .= '<h2>Example API Users information</h2>';
$out .= 'View the list of API methods you can call on <a href="http://piwik.org/docs/analytics-api/reference">API reference</a><br />';
- $out .= 'For example you can try <code>Piwik_UsersManager_API::getInstance()->getUsersSitesFromAccess("view");</code> or <code>Piwik_UsersManager_API::getInstance()->deleteUser("userToDelete");</code><br />';
+ $out .= 'For example you can try <code>API::getInstance()->getUsersSitesFromAccess("view");</code> or <code>API::getInstance()->deleteUser("userToDelete");</code><br />';
$out .= '<h2>Javascript in Piwik</h2>';
$out .= '<h3>i18n internationalization</h3>';
$out .= 'In order to translate strings within Javascript code, you can use the javascript function _pk_translate( token );.
<ul><li>The "token" parameter is the string unique key found in the translation file. For this token string to be available in Javascript, you must
suffix your token by "_js" in the language file. For example, you can add <code>\'Goals_AddGoal_js\' => \'Add Goal\',</code> in the lang/en.php file</li>
- <li>You then need to instruct Piwik to load your Javascript translations for your plugin; by default, all translation strings are not loaded in Javascript for performance reasons. This can be done by calling a custom-made Twig modifier before the Javascript code requiring translations, eg.
+ <li>You then need to instruct Piwik to load your Javascript translations for your plugin; by default, all translation strings are not loaded in Javascript for performance reasons. This can be done by calling a custom-made Twig modifier before the Javascript code requiring translations, eg.
<code>{loadJavascriptTranslations plugins=\'$YOUR_PLUGIN_NAME\'}</code>. In our previous example, the $YOUR_PLUGIN_NAME being Goals, we would write <code>{loadJavascriptTranslations plugins=\'Goals\'}</code>
</li><li>You can then print this string from your JS code by doing <code>_pk_translate(\'Goals_AddGoal_js\');</code>.
</li></ul>';
diff --git a/plugins/ExamplePlugin/ExamplePlugin.php b/plugins/ExamplePlugin/ExamplePlugin.php
index 481c324b5d..812898291d 100644
--- a/plugins/ExamplePlugin/ExamplePlugin.php
+++ b/plugins/ExamplePlugin/ExamplePlugin.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExamplePlugin
+ * @package ExamplePlugin
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\ExamplePlugin;
+
use Piwik\WidgetsList;
/**
*
- * @package Piwik_ExamplePlugin
+ * @package ExamplePlugin
*/
-class Piwik_ExamplePlugin extends Plugin
+class ExamplePlugin extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/ExamplePlugin/lang/en.php b/plugins/ExamplePlugin/lang/en.php
index 9be43dddea..eaec0c9940 100644
--- a/plugins/ExamplePlugin/lang/en.php
+++ b/plugins/ExamplePlugin/lang/en.php
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExamplePlugin
+ * @package ExamplePlugin
*/
$translations = array(
diff --git a/plugins/ExampleRssWidget/Controller.php b/plugins/ExampleRssWidget/Controller.php
index ce1806b632..a8a5eb7247 100644
--- a/plugins/ExampleRssWidget/Controller.php
+++ b/plugins/ExampleRssWidget/Controller.php
@@ -6,20 +6,24 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
-use Piwik\Controller;
+
+namespace Piwik\Plugins\ExampleRssWidget;
+
+use Exception;
+use Piwik\Plugins\ExampleRssWidget\RssRenderer;
/**
*
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
-class Piwik_ExampleRssWidget_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function rssPiwik()
{
try {
- $rss = new Piwik_ExampleRssWidget_Rss('http://feeds.feedburner.com/Piwik');
+ $rss = new RssRenderer('http://feeds.feedburner.com/Piwik');
$rss->showDescription(true);
echo $rss->get();
} catch (Exception $e) {
@@ -30,7 +34,7 @@ class Piwik_ExampleRssWidget_Controller extends Controller
public function rssChangelog()
{
try {
- $rss = new Piwik_ExampleRssWidget_Rss('http://feeds.feedburner.com/PiwikReleases');
+ $rss = new RssRenderer('http://feeds.feedburner.com/PiwikReleases');
$rss->setCountPosts(1);
$rss->showDescription(false);
$rss->showContent(true);
diff --git a/plugins/ExampleRssWidget/ExampleRssWidget.php b/plugins/ExampleRssWidget/ExampleRssWidget.php
index a23daf88ee..868913959e 100644
--- a/plugins/ExampleRssWidget/ExampleRssWidget.php
+++ b/plugins/ExampleRssWidget/ExampleRssWidget.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\ExampleRssWidget;
+
use Piwik\WidgetsList;
/**
*
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
-class Piwik_ExampleRssWidget extends Plugin
+class ExampleRssWidget extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/ExampleRssWidget/Rss.php b/plugins/ExampleRssWidget/RssRenderer.php
index ee95a8a56d..1b7baa1ba2 100644
--- a/plugins/ExampleRssWidget/Rss.php
+++ b/plugins/ExampleRssWidget/RssRenderer.php
@@ -6,14 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
+namespace Piwik\Plugins\ExampleRssWidget;
+
+use Zend_Feed;
+use Zend_Feed_Exception;
+
/**
*
- * @package Piwik_ExampleRssWidget
+ * @package ExampleRssWidget
*/
-class Piwik_ExampleRssWidget_Rss
+class RssRenderer
{
protected $url = null;
protected $count = 3;
diff --git a/plugins/ExampleUI/API.php b/plugins/ExampleUI/API.php
index 4fc0c513f8..d2128fa296 100644
--- a/plugins/ExampleUI/API.php
+++ b/plugins/ExampleUI/API.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
+namespace Piwik\Plugins\ExampleUI;
+
use Piwik\Period\Range;
use Piwik\DataTable;
@@ -17,14 +19,14 @@ use Piwik\DataTable;
* The functions listed in this API are returning the data used in the Controller to draw graphs and
* display tables. See also the ExampleAPI plugin for an introduction to Piwik APIs.
*
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
-class Piwik_ExampleUI_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_ExampleUI_API
+ * @return \Piwik\Plugins\ExampleUI\API
*/
static public function getInstance()
{
diff --git a/plugins/ExampleUI/Controller.php b/plugins/ExampleUI/Controller.php
index 5c6f27254c..dc1415b411 100644
--- a/plugins/ExampleUI/Controller.php
+++ b/plugins/ExampleUI/Controller.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
+namespace Piwik\Plugins\ExampleUI;
+
use Piwik\Common;
-use Piwik\Controller;
use Piwik\ViewDataTable;
use Piwik\View;
/**
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
-class Piwik_ExampleUI_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function dataTables()
{
@@ -130,7 +131,7 @@ class Piwik_ExampleUI_Controller extends Controller
if ($serverRequested !== false) {
$view->columns_to_display = array($serverRequested);
}
-
+
echo $view->render();
}
diff --git a/plugins/ExampleUI/ExampleUI.php b/plugins/ExampleUI/ExampleUI.php
index 4e1210cf14..fcd6120cca 100644
--- a/plugins/ExampleUI/ExampleUI.php
+++ b/plugins/ExampleUI/ExampleUI.php
@@ -6,7 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
/*
@@ -18,13 +18,14 @@
- without all columns icon
+ update http://piwik.org/participate/user-interface
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\ExampleUI;
+
/**
*
- * @package Piwik_ExampleUI
+ * @package ExampleUI
*/
-class Piwik_ExampleUI extends Plugin
+class ExampleUI extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/Feedback/Controller.php b/plugins/Feedback/Controller.php
index 3a43559d6f..2b80b18ad2 100644
--- a/plugins/Feedback/Controller.php
+++ b/plugins/Feedback/Controller.php
@@ -6,12 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Feedback
+ * @package Feedback
*/
+namespace Piwik\Plugins\Feedback;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\IP;
use Piwik\Mail;
use Piwik\Nonce;
@@ -21,14 +23,14 @@ use Piwik\Url;
/**
*
- * @package Piwik_Feedback
+ * @package Feedback
*/
-class Piwik_Feedback_Controller extends Controller
+class Controller extends \Piwik\Controller
{
function index()
{
$view = new View('@Feedback/index');
- $view->nonce = Nonce::getNonce('Piwik_Feedback.sendFeedback', 3600);
+ $view->nonce = Nonce::getNonce('Feedback.sendFeedback', 3600);
echo $view->render();
}
@@ -60,10 +62,10 @@ class Piwik_Feedback_Controller extends Controller
if (preg_match('/https?:/i', $body)) {
throw new Exception(Piwik_TranslateException('Feedback_ExceptionNoUrls'));
}
- if (!Nonce::verifyNonce('Piwik_Feedback.sendFeedback', $nonce)) {
+ if (!Nonce::verifyNonce('Feedback.sendFeedback', $nonce)) {
throw new Exception(Piwik_TranslateException('General_ExceptionNonceMismatch'));
}
- Nonce::discardNonce('Piwik_Feedback.sendFeedback');
+ Nonce::discardNonce('Feedback.sendFeedback');
$mail = new Mail();
$mail->setFrom(Common::unsanitizeInputValue($email));
diff --git a/plugins/Feedback/Feedback.php b/plugins/Feedback/Feedback.php
index 522c09fe96..48f8d297f4 100644
--- a/plugins/Feedback/Feedback.php
+++ b/plugins/Feedback/Feedback.php
@@ -6,15 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Feedback
+ * @package Feedback
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\Feedback;
+
/**
*
- * @package Piwik_Feedback
+ * @package Feedback
*/
-class Piwik_Feedback extends Plugin
+class Feedback extends \Piwik\Plugin
{
/**
diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php
index 3eb1a62e28..c80ade9ac3 100644
--- a/plugins/Goals/API.php
+++ b/plugins/Goals/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Goals
+ * @package Goals
*/
+namespace Piwik\Plugins\Goals;
+
+use Exception;
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
@@ -17,6 +20,8 @@ use Piwik\Site;
use Piwik\Db;
use Piwik\Tracker\Cache;
use Piwik\Tracker\GoalManager;
+use Piwik\Plugins\Goals\Goals;
+use Piwik\Plugins\Goals\Archiver;
/**
* Goals API lets you Manage existing goals, via "updateGoal" and "deleteGoal", create new Goals via "addGoal",
@@ -36,14 +41,14 @@ use Piwik\Tracker\GoalManager;
*
* See also the documentation about <a href='http://piwik.org/docs/tracking-goals-web-analytics/' target='_blank'>Tracking Goals</a> in Piwik.
*
- * @package Piwik_Goals
+ * @package Goals
*/
-class Piwik_Goals_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_Goals_API
+ * @return \Piwik\Plugins\Goals\API
*/
static public function getInstance()
{
@@ -199,7 +204,7 @@ class Piwik_Goals_API
Piwik::checkUserHasAdminAccess($idSite);
Db::query("UPDATE " . Common::prefixTable('goal') . "
SET deleted = 1
- WHERE idsite = ?
+ WHERE idsite = ?
AND idgoal = ?",
array($idSite, $idGoal));
Db::deleteAllRows(Common::prefixTable("log_conversion"), "WHERE idgoal = ?", 100000, array($idGoal));
@@ -215,11 +220,11 @@ class Piwik_Goals_API
Piwik::checkUserHasViewAccess($idSite);
$recordNameFinal = $recordName;
if ($abandonedCarts) {
- $recordNameFinal = Piwik_Goals_Archiver::getItemRecordNameAbandonedCart($recordName);
+ $recordNameFinal = Archiver::getItemRecordNameAbandonedCart($recordName);
}
$archive = Archive::build($idSite, $period, $date);
$dataTable = $archive->getDataTable($recordNameFinal);
-
+
$dataTable->filter('Sort', array(Metrics::INDEX_ECOMMERCE_ITEM_REVENUE));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
@@ -238,7 +243,8 @@ class Piwik_Goals_API
$dataTable->queueFilter('ColumnDelete', array('price'));
// Enrich the datatable with Product/Categories views, and conversion rates
- $customVariables = Piwik_CustomVariables_API::getInstance()->getCustomVariables($idSite, $period, $date, $segment = false, $expanded = false, $_leavePiwikCoreVariables = true);
+ $customVariables = \Piwik\Plugins\CustomVariables\API::getInstance()->getCustomVariables($idSite, $period, $date, $segment = false, $expanded = false,
+ $_leavePiwikCoreVariables = true);
$mapping = array(
'Goals_ItemsSku' => '_pks',
'Goals_ItemsName' => '_pkn',
@@ -295,16 +301,15 @@ class Piwik_Goals_API
}
return;
}
- $rowNotDefined = $dataTable->getRowFromLabel(Piwik_CustomVariables_Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED);
+ $rowNotDefined = $dataTable->getRowFromLabel(\Piwik\Plugins\CustomVariables\Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED);
if ($rowNotDefined) {
$rowNotDefined->setColumn('label', $notDefinedStringPretty);
}
}
-
protected function enrichItemsDataTableWithItemsViewMetrics($dataTable, $idSite, $period, $date, $idSubtable)
{
- $ecommerceViews = Piwik_CustomVariables_API::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment = false, $_leavePriceViewedColumn = true);
+ $ecommerceViews = \Piwik\Plugins\CustomVariables\API::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment = false, $_leavePriceViewedColumn = true);
// For Product names and SKU reports, and for Category report
// Use the Price (tracked on page views)
@@ -385,7 +390,7 @@ class Piwik_Goals_API
$idGoal = self::convertSpecialGoalIds($idGoal);
if (empty($columns)) {
- $columns = Piwik_Goals::getGoalColumns($idGoal);
+ $columns = Goals::getGoalColumns($idGoal);
if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
$columns[] = 'avg_order_revenue';
}
@@ -399,7 +404,7 @@ class Piwik_Goals_API
}
$columnsToSelect = array();
foreach ($columns as &$columnName) {
- $columnsToSelect[] = Piwik_Goals_Archiver::getRecordName($columnName, $idGoal);
+ $columnsToSelect[] = Archiver::getRecordName($columnName, $idGoal);
}
$dataTable = $archive->getDataTableFromNumeric($columnsToSelect);
@@ -447,7 +452,7 @@ class Piwik_Goals_API
*/
public function getConversions($idSite, $period, $date, $segment = false, $idGoal = false)
{
- return $this->getNumeric($idSite, $period, $date, $segment, Piwik_Goals_Archiver::getRecordName('nb_conversions', $idGoal));
+ return $this->getNumeric($idSite, $period, $date, $segment, Archiver::getRecordName('nb_conversions', $idGoal));
}
/**
@@ -455,7 +460,7 @@ class Piwik_Goals_API
*/
public function getNbVisitsConverted($idSite, $period, $date, $segment = false, $idGoal = false)
{
- return $this->getNumeric($idSite, $period, $date, $segment, Piwik_Goals_Archiver::getRecordName('nb_visits_converted', $idGoal));
+ return $this->getNumeric($idSite, $period, $date, $segment, Archiver::getRecordName('nb_visits_converted', $idGoal));
}
/**
@@ -463,7 +468,7 @@ class Piwik_Goals_API
*/
public function getConversionRate($idSite, $period, $date, $segment = false, $idGoal = false)
{
- return $this->getNumeric($idSite, $period, $date, $segment, Piwik_Goals_Archiver::getRecordName('conversion_rate', $idGoal));
+ return $this->getNumeric($idSite, $period, $date, $segment, Archiver::getRecordName('conversion_rate', $idGoal));
}
/**
@@ -471,7 +476,7 @@ class Piwik_Goals_API
*/
public function getRevenue($idSite, $period, $date, $segment = false, $idGoal = false)
{
- return $this->getNumeric($idSite, $period, $date, $segment, Piwik_Goals_Archiver::getRecordName('revenue', $idGoal));
+ return $this->getNumeric($idSite, $period, $date, $segment, Archiver::getRecordName('revenue', $idGoal));
}
/**
@@ -498,7 +503,7 @@ class Piwik_Goals_API
$realGoalId = $idGoal != true ? false : self::convertSpecialGoalIds($idGoal);
// get the data table
- $dataTable = $archive->getDataTable(Piwik_Goals_Archiver::getRecordName($recordName, $realGoalId), $idSubtable = null);
+ $dataTable = $archive->getDataTable(Archiver::getRecordName($recordName, $realGoalId), $idSubtable = null);
$dataTable->queueFilter('ReplaceColumnNames');
return $dataTable;
@@ -519,7 +524,7 @@ class Piwik_Goals_API
public function getDaysToConversion($idSite, $period, $date, $segment = false, $idGoal = false)
{
$dataTable = $this->getGoalSpecificDataTable(
- Piwik_Goals_Archiver::DAYS_UNTIL_CONV_RECORD_NAME, $idSite, $period, $date, $segment, $idGoal);
+ Archiver::DAYS_UNTIL_CONV_RECORD_NAME, $idSite, $period, $date, $segment, $idGoal);
$dataTable->queueFilter('Sort', array('label', 'asc', true));
$dataTable->queueFilter(
@@ -543,7 +548,7 @@ class Piwik_Goals_API
public function getVisitsUntilConversion($idSite, $period, $date, $segment = false, $idGoal = false)
{
$dataTable = $this->getGoalSpecificDataTable(
- Piwik_Goals_Archiver::VISITS_UNTIL_RECORD_NAME, $idSite, $period, $date, $segment, $idGoal);
+ Archiver::VISITS_UNTIL_RECORD_NAME, $idSite, $period, $date, $segment, $idGoal);
$dataTable->queueFilter('Sort', array('label', 'asc', true));
$dataTable->queueFilter(
diff --git a/plugins/Goals/Archiver.php b/plugins/Goals/Archiver.php
index cad582453a..efb26854bc 100644
--- a/plugins/Goals/Archiver.php
+++ b/plugins/Goals/Archiver.php
@@ -6,17 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Goals
+ * @package Goals
*/
+namespace Piwik\Plugins\Goals;
+
use Piwik\DataAccess\LogAggregator;
use Piwik\Metrics;
use Piwik\DataTable;
use Piwik\DataArray;
use Piwik\PluginsArchiver;
+use Piwik\PluginsManager;
use Piwik\Tracker\GoalManager;
+use Piwik\Plugins\Goals\Goals;
-class Piwik_Goals_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const VISITS_UNTIL_RECORD_NAME = 'visits_until_conv';
const DAYS_UNTIL_CONV_RECORD_NAME = 'days_until_conv';
@@ -120,7 +124,7 @@ class Piwik_Goals_Archiver extends PluginsArchiver
unset($row['label']);
$values = array();
- foreach($conversionMetrics as $field => $statement) {
+ foreach ($conversionMetrics as $field => $statement) {
$values[$field] = $row[$field];
}
$goals->sumMetrics($idGoal, $values);
@@ -173,7 +177,7 @@ class Piwik_Goals_Archiver extends PluginsArchiver
$recordName = self::getRecordName($metricName, $idGoal);
$numericRecords[$recordName] = $value;
}
- if(!empty($array[Metrics::INDEX_GOAL_NB_VISITS_CONVERTED])) {
+ if (!empty($array[Metrics::INDEX_GOAL_NB_VISITS_CONVERTED])) {
$conversion_rate = $this->getConversionRate($array[Metrics::INDEX_GOAL_NB_VISITS_CONVERTED]);
$recordName = self::getRecordName('conversion_rate', $idGoal);
$numericRecords[$recordName] = $conversion_rate;
@@ -330,8 +334,8 @@ class Piwik_Goals_Archiver extends PluginsArchiver
}
$label = "Value not defined";
// Product Name/Category not defined"
- if (class_exists('Piwik_CustomVariables')) {
- $label = Piwik_CustomVariables_Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED;
+ if (PluginsManager::getInstance()->isPluginActivated('CustomVariables')) {
+ $label = \Piwik\Plugins\CustomVariables\Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED;
}
}
@@ -403,7 +407,7 @@ class Piwik_Goals_Archiver extends PluginsArchiver
$fieldsToSum = array();
foreach ($goalIdsToSum as $goalId) {
- $metricsToSum = Piwik_Goals::getGoalColumns($goalId);
+ $metricsToSum = Goals::getGoalColumns($goalId);
unset($metricsToSum[array_search('conversion_rate', $metricsToSum)]);
foreach ($metricsToSum as $metricName) {
$fieldsToSum[] = self::getRecordName($metricName, $goalId);
@@ -419,13 +423,13 @@ class Piwik_Goals_Archiver extends PluginsArchiver
// sum up the visits to conversion data table & the days to conversion data table
$this->getProcessor()->aggregateDataTableReports(array(
- self::getRecordName(self::VISITS_UNTIL_RECORD_NAME, $goalId),
- self::getRecordName(self::DAYS_UNTIL_CONV_RECORD_NAME, $goalId)));
+ self::getRecordName(self::VISITS_UNTIL_RECORD_NAME, $goalId),
+ self::getRecordName(self::DAYS_UNTIL_CONV_RECORD_NAME, $goalId)));
}
// sum up goal overview reports
$this->getProcessor()->aggregateDataTableReports(array(
- self::getRecordName(self::VISITS_UNTIL_RECORD_NAME),
- self::getRecordName(self::DAYS_UNTIL_CONV_RECORD_NAME)));
+ self::getRecordName(self::VISITS_UNTIL_RECORD_NAME),
+ self::getRecordName(self::DAYS_UNTIL_CONV_RECORD_NAME)));
}
} \ No newline at end of file
diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php
index 0bca7f1403..7cb2353a0b 100644
--- a/plugins/Goals/Controller.php
+++ b/plugins/Goals/Controller.php
@@ -6,24 +6,28 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Goals
+ * @package Goals
*/
+namespace Piwik\Plugins\Goals;
+
+use Exception;
use Piwik\API\Request;
use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\DataTable;
-use Piwik\Controller;
use Piwik\FrontController;
use Piwik\View\ReportsByDimension;
use Piwik\ViewDataTable;
use Piwik\View;
+use Piwik\Plugins\Goals\Goals;
+use Piwik\Plugins\Referers\API as ReferersAPI;
/**
*
- * @package Piwik_Goals
+ * @package Goals
*/
-class Piwik_Goals_Controller extends Controller
+class Controller extends \Piwik\Controller
{
const CONVERSION_RATE_PRECISION = 1;
@@ -58,7 +62,7 @@ class Piwik_Goals_Controller extends Controller
{
parent::__construct();
$this->idSite = Common::getRequestVar('idSite', null, 'int');
- $this->goals = Piwik_Goals_API::getInstance()->getGoals($this->idSite);
+ $this->goals = API::getInstance()->getGoals($this->idSite);
foreach ($this->goals as &$goal) {
$goal['name'] = Common::sanitizeInputValue($goal['name']);
if (isset($goal['pattern'])) {
@@ -137,10 +141,10 @@ class Piwik_Goals_Controller extends Controller
// conversion rate for new and returning visitors
$segment = 'visitorType==returning,visitorType==returningCustomer';
- $conversionRateReturning = Piwik_Goals_API::getInstance()->getConversionRate($this->idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), $segment, $idGoal);
+ $conversionRateReturning = API::getInstance()->getConversionRate($this->idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), $segment, $idGoal);
$view->conversion_rate_returning = $this->formatConversionRate($conversionRateReturning);
$segment = 'visitorType==new';
- $conversionRateNew = Piwik_Goals_API::getInstance()->getConversionRate($this->idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), $segment, $idGoal);
+ $conversionRateNew = API::getInstance()->getConversionRate($this->idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), $segment, $idGoal);
$view->conversion_rate_new = $this->formatConversionRate($conversionRateNew);
$view->goalReportsByDimension = $this->getGoalReportsByDimensionTable(
$view->nb_conversions, isset($ecommerce), !empty($view->cart_nb_conversions));
@@ -150,7 +154,7 @@ class Piwik_Goals_Controller extends Controller
public function index()
{
$view = $this->getOverviewView();
-
+
// unsanitize goal names and other text data (not done in API so as not to break
// any other code/cause security issues)
$goals = $this->goals;
@@ -161,7 +165,7 @@ class Piwik_Goals_Controller extends Controller
}
}
$view->goalsJSON = Common::json_encode($goals);
-
+
$view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite);
$view->ecommerceEnabled = $this->site->isEcommerceEnabled();
$view->displayFullReport = true;
@@ -294,7 +298,6 @@ class Piwik_Goals_Controller extends Controller
return $this->renderView($view, $fetch);
}
-
protected function getTopDimensions($idGoal)
{
$columnNbConversions = 'goal_' . $idGoal . '_nb_conversions';
@@ -310,7 +313,7 @@ class Piwik_Goals_Controller extends Controller
$keywordNotDefinedString = '';
if (\Piwik\PluginsManager::getInstance()->isPluginActivated('Referers')) {
- $keywordNotDefinedString = Piwik_Referers_API::getKeywordNotDefinedString();
+ $keywordNotDefinedString = ReferersAPI::getKeywordNotDefinedString();
$topDimensionsToLoad += array(
'keyword' => 'Referers.getKeywords',
'website' => 'Referers.getWebsites',
@@ -436,12 +439,12 @@ class Piwik_Goals_Controller extends Controller
$customParams['idGoal'] = '0'; // NOTE: Must be string! Otherwise Piwik_View_HtmlTable_Goals fails.
}
- $allReports = Piwik_Goals::getReportsWithGoalMetrics();
+ $allReports = Goals::getReportsWithGoalMetrics();
foreach ($allReports as $category => $reports) {
$categoryText = Piwik_Translate('Goals_ViewGoalsBy', $category);
foreach ($reports as $report) {
$customParams['viewDataTable'] = 'tableGoals';
- if(in_array($report['action'], array('getVisitsUntilConversion', 'getDaysToConversion'))) {
+ if (in_array($report['action'], array('getVisitsUntilConversion', 'getDaysToConversion'))) {
$customParams['viewDataTable'] = 'table';
}
@@ -453,16 +456,16 @@ class Piwik_Goals_Controller extends Controller
return $goalReportsByDimension->render();
}
-
- //
+
+ //
// Report rendering actions
- //
+ //
public function getItemsSku($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
}
-
+
public function getItemsName($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php
index 010f1a6623..f15569affb 100644
--- a/plugins/Goals/Goals.php
+++ b/plugins/Goals/Goals.php
@@ -6,23 +6,26 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Goals
+ * @package Goals
*/
+namespace Piwik\Plugins\Goals;
+
use Piwik\ArchiveProcessor;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Plugins\Goals\API;
+use Piwik\Plugins\Goals\Archiver;
use Piwik\Tracker\GoalManager;
use Piwik\TranslationWriter;
-use Piwik\Plugin;
use Piwik\Site;
use Piwik\WidgetsList;
use Piwik\Db;
/**
*
- * @package Piwik_Goals
+ * @package Goals
*/
-class Piwik_Goals extends Plugin
+class Goals extends \Piwik\Plugin
{
protected $ecommerceReports = array(
array('Goals_ProductSKU', 'Goals', 'getItemsSku'),
@@ -153,7 +156,7 @@ class Piwik_Goals extends Plugin
// If only one website is selected, we add the Goal metrics
if (count($idSites) == 1) {
$idSite = reset($idSites);
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
// Add overall visits to conversion report
$reports[] = array(
@@ -350,7 +353,6 @@ class Piwik_Goals extends Plugin
}
}
}
-
}
static public function getProductReportColumns()
@@ -412,7 +414,7 @@ class Piwik_Goals extends Plugin
public function fetchGoalsFromDb(&$array, $idSite)
{
// add the 'goal' entry in the website array
- $array['goals'] = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $array['goals'] = API::getInstance()->getGoals($idSite);
}
public function addWidgets()
@@ -431,7 +433,7 @@ class Piwik_Goals extends Plugin
// Goals widgets
WidgetsList::add('Goals_Goals', 'Goals_GoalsOverview', 'Goals', 'widgetGoalsOverview');
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
if (count($goals) > 0) {
foreach ($goals as $goal) {
WidgetsList::add('Goals_Goals', Common::sanitizeInputValue($goal['name']), 'Goals', 'widgetGoalReport', array('idGoal' => $goal['idgoal']));
@@ -442,7 +444,7 @@ class Piwik_Goals extends Plugin
function addMenus()
{
$idSite = Common::getRequestVar('idSite', null, 'int');
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
$mainGoalMenu = $this->getGoalCategoryName($idSite);
$site = new Site($idSite);
if (count($goals) == 0) {
@@ -487,8 +489,8 @@ class Piwik_Goals extends Plugin
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_Goals_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
@@ -499,12 +501,12 @@ class Piwik_Goals extends Plugin
*/
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_Goals_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
-
+
public function getReportDisplayProperties(&$properties)
{
$properties['Goals.getItemsSku'] = $this->getDisplayPropertiesForGetItemsSku();
@@ -513,86 +515,86 @@ class Piwik_Goals extends Plugin
$properties['Goals.getVisitsUntilConversion'] = $this->getDisplayPropertiesForGetVisitsUntilConversion();
$properties['Goals.getDaysToConversion'] = $this->getDisplayPropertiesForGetDaysToConversion();
}
-
+
private function getDisplayPropertiesForGetItemsSku()
{
return $this->getDisplayPropertiesForItemsReport(Piwik_Translate('Goals_ProductSKU'));
}
-
+
private function getDisplayPropertiesForGetItemsName()
{
return $this->getDisplayPropertiesForItemsReport(Piwik_Translate('Goals_ProductName'));
}
-
+
private function getDisplayPropertiesForGetItemsCategory()
{
return $this->getDisplayPropertiesForItemsReport(Piwik_Translate('Goals_ProductCategory'));
}
-
+
private function getDisplayPropertiesForGetVisitsUntilConversion()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'show_table_all_columns' => false,
- 'columns_to_display' => array('label', 'nb_conversions'),
- 'filter_sort_column' => 'label',
- 'filter_sort_order' => 'asc',
- 'translations' => array(
- 'label' => Piwik_Translate('Goals_VisitsUntilConv'),
+ 'show_table_all_columns' => false,
+ 'columns_to_display' => array('label', 'nb_conversions'),
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array(
+ 'label' => Piwik_Translate('Goals_VisitsUntilConv'),
'nb_conversions' => Piwik_Translate('Goals_ColumnConversions'),
),
- 'filter_limit' => count(Piwik_Goals_Archiver::$visitCountRanges),
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'show_all_views_icons' => false
+ 'filter_limit' => count(Archiver::$visitCountRanges),
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'show_all_views_icons' => false
);
}
-
+
private function getDisplayPropertiesForGetDaysToConversion()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'show_table_all_columns' => false,
- 'columns_to_display' => array('label', 'nb_conversions'),
- 'filter_sort_column' => 'label',
- 'filter_sort_order' => 'asc',
- 'translations' => array(
- 'label' => Piwik_Translate('Goals_DaysToConv'),
+ 'show_table_all_columns' => false,
+ 'columns_to_display' => array('label', 'nb_conversions'),
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array(
+ 'label' => Piwik_Translate('Goals_DaysToConv'),
'nb_conversions' => Piwik_Translate('Goals_ColumnConversions'),
),
- 'filter_limit' => count(Piwik_Goals_Archiver::$daysToConvRanges),
- 'show_all_views_icons' => false,
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
+ 'filter_limit' => count(Archiver::$daysToConvRanges),
+ 'show_all_views_icons' => false,
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
);
}
-
+
private function getDisplayPropertiesForItemsReport($label)
{
$idSite = Common::getRequestVar('idSite');
-
+
$moneyColumns = array('revenue', 'avg_price');
$prettifyMoneyColumns = array(
'ColumnCallbackReplace', array($moneyColumns, '\Piwik\Piwik::getPrettyMoney', array($idSite)));
-
+
$result = array(
- 'show_ecommerce' => true,
- 'show_all_views_icons' => false,
- 'show_table' => false,
+ 'show_ecommerce' => true,
+ 'show_all_views_icons' => false,
+ 'show_table' => false,
'show_exclude_low_population' => false,
- 'show_table_all_columns' => false,
- 'filter_limit' => 10,
- 'translations' => array('label' => $label),
- 'filter_sort_column' => 'revenue',
- 'filter_sort_order' => 'desc',
- 'filters' => array($prettifyMoneyColumns)
+ 'show_table_all_columns' => false,
+ 'filter_limit' => 10,
+ 'translations' => array('label' => $label),
+ 'filter_sort_column' => 'revenue',
+ 'filter_sort_order' => 'desc',
+ 'filters' => array($prettifyMoneyColumns)
);
-
+
// set columns/translations which differ based on viewDataTable TODO: shouldn't have to do this check... amount of reports should be dynamic, but metadata should be static
- $columns = Piwik_Goals::getProductReportColumns();
-
+ $columns = Goals::getProductReportColumns();
+
$abandonedCart = Common::getRequestVar('viewDataTable', 'ecommerceOrder', 'string') == 'ecommerceAbandonedCart';
if ($abandonedCart) {
$columns['abandoned_carts'] = Piwik_Translate('General_AbandonedCarts');
@@ -601,13 +603,13 @@ class Piwik_Goals extends Plugin
$columns['avg_quantity'] = Piwik_Translate('Goals_LeftInCart', Piwik_Translate('General_AverageQuantity'));
unset($columns['orders']);
unset($columns['conversion_rate']);
-
+
$result['request_parameters_to_modify'] = array('abandonedCarts' => '1');
}
-
+
$result['translations'] = array_merge(array('label' => $label), $columns);
$result['columns_to_display'] = array_keys($result['translations']);
-
+
// set metrics documentation in normal ecommerce report
if (!$abandonedCart) {
$result['metrics_documentation'] = array(
@@ -621,10 +623,10 @@ class Piwik_Goals extends Plugin
'conversion_rate' => Piwik_Translate('Goals_ColumnConversionRateProductDocumentation', $label),
);
}
-
+
$result['custom_parameters']['viewDataTable'] =
$abandonedCart ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART : Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER;
-
+
return $result;
}
}
diff --git a/plugins/ImageGraph/API.php b/plugins/ImageGraph/API.php
index 942a4042bd..64e4fb311f 100644
--- a/plugins/ImageGraph/API.php
+++ b/plugins/ImageGraph/API.php
@@ -6,12 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph
+ * @package ImageGraph
*/
+namespace Piwik\Plugins\ImageGraph;
+
use Piwik\Period;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Translate;
+use Piwik\Plugins\API\API as MetaAPI;
+use Piwik\Plugins\ImageGraph\StaticGraph;
/**
* The ImageGraph.get API call lets you generate beautiful static PNG Graphs for any existing Piwik report.
@@ -24,9 +28,9 @@ use Piwik\Translate;
*
* See also <a href='http://piwik.org/docs/analytics-api/metadata/#toc-static-image-graphs'>How to embed static Image Graphs?</a> for more information.
*
- * @package Piwik_ImageGraph
+ * @package ImageGraph
*/
-class Piwik_ImageGraph_API
+class API
{
const FILENAME_KEY = 'filename';
const TRUNCATE_KEY = 'truncate';
@@ -36,31 +40,31 @@ class Piwik_ImageGraph_API
const MAX_HEIGHT = 2048;
static private $DEFAULT_PARAMETERS = array(
- Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_LINE => array(
+ StaticGraph::GRAPH_TYPE_BASIC_LINE => array(
self::FILENAME_KEY => 'BasicLine',
self::TRUNCATE_KEY => 6,
self::WIDTH_KEY => 1044,
self::HEIGHT_KEY => 290,
),
- Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_VERTICAL_BAR => array(
+ StaticGraph::GRAPH_TYPE_VERTICAL_BAR => array(
self::FILENAME_KEY => 'BasicBar',
self::TRUNCATE_KEY => 6,
self::WIDTH_KEY => 1044,
self::HEIGHT_KEY => 290,
),
- Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR => array(
+ StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR => array(
self::FILENAME_KEY => 'HorizontalBar',
self::TRUNCATE_KEY => null, // horizontal bar graphs are dynamically truncated
self::WIDTH_KEY => 800,
self::HEIGHT_KEY => 290,
),
- Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_3D_PIE => array(
+ StaticGraph::GRAPH_TYPE_3D_PIE => array(
self::FILENAME_KEY => '3DPie',
self::TRUNCATE_KEY => 5,
self::WIDTH_KEY => 1044,
self::HEIGHT_KEY => 290,
),
- Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_PIE => array(
+ StaticGraph::GRAPH_TYPE_BASIC_PIE => array(
self::FILENAME_KEY => 'BasicPie',
self::TRUNCATE_KEY => 5,
self::WIDTH_KEY => 1044,
@@ -71,11 +75,11 @@ class Piwik_ImageGraph_API
static private $DEFAULT_GRAPH_TYPE_OVERRIDE = array(
'UserSettings_getPlugin' => array(
false // override if !$isMultiplePeriod
- => Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR,
+ => StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR,
),
'Referers_getRefererType' => array(
false // override if !$isMultiplePeriod
- => Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR,
+ => StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR,
),
);
@@ -100,7 +104,7 @@ class Piwik_ImageGraph_API
static private $instance = null;
/**
- * @return Piwik_ImageGraph_API
+ * @return \Piwik\Plugins\ImageGraph\API
*/
static public function getInstance()
{
@@ -118,29 +122,31 @@ class Piwik_ImageGraph_API
$apiModule,
$apiAction,
$graphType = false,
- $outputType = Piwik_ImageGraph_API::GRAPH_OUTPUT_INLINE,
+ $outputType = API::GRAPH_OUTPUT_INLINE,
$columns = false,
$labels = false,
$showLegend = true,
$width = false,
$height = false,
- $fontSize = Piwik_ImageGraph_API::DEFAULT_FONT_SIZE,
+ $fontSize = API::DEFAULT_FONT_SIZE,
$legendFontSize = false,
$aliasedGraph = true,
$idGoal = false,
$colors = false,
- $textColor = Piwik_ImageGraph_API::DEFAULT_TEXT_COLOR,
- $backgroundColor = Piwik_ImageGraph_API::DEFAULT_BACKGROUND_COLOR,
- $gridColor = Piwik_ImageGraph_API::DEFAULT_GRID_COLOR,
+ $textColor = API::DEFAULT_TEXT_COLOR,
+ $backgroundColor = API::DEFAULT_BACKGROUND_COLOR,
+ $gridColor = API::DEFAULT_GRID_COLOR,
$idSubtable = false,
$legendAppendMetric = true,
$segment = false
- ) {
+ )
+ {
Piwik::checkUserHasViewAccess($idSite);
// Health check - should we also test for GD2 only?
if (!Piwik::isGdExtensionEnabled()) {
- throw new Exception('Error: To create graphs in Piwik, please enable GD php extension (with Freetype support) in php.ini, and restart your web server.');
+ throw new \Exception('Error: To create graphs in Piwik, please enable GD php extension (with Freetype support) in php.ini,
+ and restart your web server.');
}
$useUnicodeFont = array(
@@ -162,7 +168,7 @@ class Piwik_ImageGraph_API
$apiParameters = array('idGoal' => $idGoal);
}
// Fetch the metadata for given api-action
- $metadata = Piwik_API_API::getInstance()->getMetadata(
+ $metadata = MetaAPI::getInstance()->getMetadata(
$idSite, $apiModule, $apiAction, $apiParameters, $languageLoaded, $period, $date,
$hideMetricsDoc = false, $showSubtableReports = true);
if (!$metadata) {
@@ -184,12 +190,12 @@ class Piwik_ImageGraph_API
if (empty($graphType)) {
if ($isMultiplePeriod) {
- $graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_LINE;
+ $graphType = StaticGraph::GRAPH_TYPE_BASIC_LINE;
} else {
if ($constantRowsCount) {
- $graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_VERTICAL_BAR;
+ $graphType = StaticGraph::GRAPH_TYPE_VERTICAL_BAR;
} else {
- $graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR;
+ $graphType = StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR;
}
}
@@ -198,7 +204,7 @@ class Piwik_ImageGraph_API
$graphType = self::$DEFAULT_GRAPH_TYPE_OVERRIDE[$reportUniqueId][$isMultiplePeriod];
}
} else {
- $availableGraphTypes = Piwik_ImageGraph_StaticGraph::getAvailableStaticGraphTypes();
+ $availableGraphTypes = StaticGraph::getAvailableStaticGraphTypes();
if (!in_array($graphType, $availableGraphTypes)) {
throw new Exception(
Piwik_TranslateException(
@@ -255,8 +261,8 @@ class Piwik_ImageGraph_API
// sort and truncate filters
$defaultFilterTruncate = self::$DEFAULT_PARAMETERS[$graphType][self::TRUNCATE_KEY];
switch ($graphType) {
- case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_3D_PIE:
- case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_PIE:
+ case StaticGraph::GRAPH_TYPE_3D_PIE:
+ case StaticGraph::GRAPH_TYPE_BASIC_PIE:
if (count($ordinateColumns) > 1) {
// pChart doesn't support multiple series on pie charts
@@ -267,8 +273,8 @@ class Piwik_ImageGraph_API
$this->setFilterTruncate($defaultFilterTruncate);
break;
- case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_VERTICAL_BAR:
- case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_LINE:
+ case StaticGraph::GRAPH_TYPE_VERTICAL_BAR:
+ case StaticGraph::GRAPH_TYPE_BASIC_LINE:
if (!$isMultiplePeriod && !$constantRowsCount) {
$this->setFilterTruncate($defaultFilterTruncate);
@@ -294,7 +300,7 @@ class Piwik_ImageGraph_API
}
}
- $processedReport = Piwik_API_API::getInstance()->getRowEvolution(
+ $processedReport = MetaAPI::getInstance()->getRowEvolution(
$idSite,
$period,
$date,
@@ -311,7 +317,7 @@ class Piwik_ImageGraph_API
//@review this test will need to be updated after evaluating the @review comment in API/API.php
if (!$processedReport) {
- throw new Exception(Piwik_Translate('General_NoDataForGraph_js'));
+ throw new \Exception(Piwik_Translate('General_NoDataForGraph_js'));
}
// restoring generic filter parameters
@@ -351,7 +357,7 @@ class Piwik_ImageGraph_API
$ordinateLabels[$plottedMetric] = $processedReport['label'] . ' (' . $metrics[$plottedMetric]['name'] . ')';
}
} else {
- $processedReport = Piwik_API_API::getInstance()->getProcessedReport(
+ $processedReport = MetaAPI::getInstance()->getProcessedReport(
$idSite,
$period,
$date,
@@ -437,7 +443,6 @@ class Piwik_ImageGraph_API
$ordinateSeries[$column][] = $parsedOrdinateValue;
}
-
} else {
foreach ($ordinateColumns as $column) {
$ordinateSeries[$column][] = 0;
@@ -450,11 +455,11 @@ class Piwik_ImageGraph_API
}
if (!$hasData || !$hasNonZeroValue) {
- throw new Exception(Piwik_Translate('General_NoDataForGraph_js'));
+ throw new \Exception(Piwik_Translate('General_NoDataForGraph_js'));
}
//Setup the graph
- $graph = Piwik_ImageGraph_StaticGraph::factory($graphType);
+ $graph = StaticGraph::factory($graphType);
$graph->setWidth($width);
$graph->setHeight($height);
$graph->setFont($font);
@@ -480,10 +485,9 @@ class Piwik_ImageGraph_API
// render graph
$graph->renderGraph();
+ } catch (\Exception $e) {
- } catch (Exception $e) {
-
- $graph = new Piwik_ImageGraph_StaticGraph_Exception();
+ $graph = new \Piwik\Plugins\ImageGraph\StaticGraph\Exception();
$graph->setWidth($width);
$graph->setHeight($height);
$graph->setFont($font);
diff --git a/plugins/ImageGraph/Controller.php b/plugins/ImageGraph/Controller.php
index a36d520b8e..19925fdc41 100644
--- a/plugins/ImageGraph/Controller.php
+++ b/plugins/ImageGraph/Controller.php
@@ -1,9 +1,4 @@
<?php
-use Piwik\Piwik;
-use Piwik\Common;
-use Piwik\Controller;
-use Piwik\View;
-
/**
* Piwik - Open source web analytics
*
@@ -11,10 +6,16 @@ use Piwik\View;
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph
+ * @package ImageGraph
*/
+namespace Piwik\Plugins\ImageGraph;
-class Piwik_ImageGraph_Controller extends Controller
+use Piwik\Piwik;
+use Piwik\Common;
+use Piwik\View;
+use Piwik\Plugins\API\API;
+
+class Controller extends \Piwik\Controller
{
// Call metadata reports, and draw the default graph for each report.
public function index()
@@ -24,7 +25,7 @@ class Piwik_ImageGraph_Controller extends Controller
$period = Common::getRequestVar('period', 'day', 'string');
$date = Common::getRequestVar('date', 'today', 'string');
$_GET['token_auth'] = Piwik::getCurrentUserTokenAuth();
- $reports = Piwik_API_API::getInstance()->getReportMetadata($idSite, $period, $date);
+ $reports = API::getInstance()->getReportMetadata($idSite, $period, $date);
$plot = array();
foreach ($reports as $report) {
if (!empty($report['imageGraphUrl'])) {
@@ -53,7 +54,7 @@ class Piwik_ImageGraph_Controller extends Controller
$date = Common::getRequestVar('date', 'today', 'string');
$_GET['token_auth'] = Piwik::getCurrentUserTokenAuth();
- $availableReports = Piwik_API_API::getInstance()->getReportMetadata($this->idSite, $period, $date);
+ $availableReports = API::getInstance()->getReportMetadata($this->idSite, $period, $date);
$view->availableReports = $availableReports;
$view->graphTypes = array(
'', // default graph type
@@ -73,5 +74,4 @@ class Piwik_ImageGraph_Controller extends Controller
);
echo $view->render();
}
-
}
diff --git a/plugins/ImageGraph/ImageGraph.php b/plugins/ImageGraph/ImageGraph.php
index 6181877fb7..fc992a3425 100644
--- a/plugins/ImageGraph/ImageGraph.php
+++ b/plugins/ImageGraph/ImageGraph.php
@@ -1,12 +1,4 @@
<?php
-use Piwik\Common;
-use Piwik\Period;
-use Piwik\Controller;
-use Piwik\Url;
-use Piwik\Plugin;
-use Piwik\Site;
-use Piwik\Config;
-
/**
* Piwik - Open source web analytics
*
@@ -14,10 +6,17 @@ use Piwik\Config;
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph
+ * @package ImageGraph
*/
+namespace Piwik\Plugins\ImageGraph;
+
+use Piwik\Common;
+use Piwik\Period;
+use Piwik\Url;
+use Piwik\Site;
+use Piwik\Config;
-class Piwik_ImageGraph extends Plugin
+class ImageGraph extends \Piwik\Plugin
{
static private $CONSTANT_ROW_COUNT_REPORT_EXCEPTIONS = array(
'Referers_getRefererType',
@@ -92,7 +91,7 @@ class Piwik_ImageGraph extends Plugin
$dateForMultiplePeriodGraph = $dateForSinglePeriodGraph;
} else {
$periodForMultiplePeriodGraph = $periodForSinglePeriodGraph;
- $dateForMultiplePeriodGraph = Controller::getDateRangeRelativeToEndDate(
+ $dateForMultiplePeriodGraph = \Piwik\Controller::getDateRangeRelativeToEndDate(
$periodForSinglePeriodGraph,
'last' . self::GRAPH_EVOLUTION_LAST_PERIODS,
$dateForSinglePeriodGraph,
@@ -146,8 +145,9 @@ class Piwik_ImageGraph extends Plugin
$reportSupportsEvolution = !in_array($reportUniqueId, self::$REPORTS_DISABLED_EVOLUTION_GRAPH);
- if ( $reportSupportsEvolution
- && $reportWithDimensionsSupportsEvolution) {
+ if ($reportSupportsEvolution
+ && $reportWithDimensionsSupportsEvolution
+ ) {
$parameters['period'] = $periodForMultiplePeriodGraph;
$parameters['date'] = $dateForMultiplePeriodGraph;
$report['imageGraphEvolutionUrl'] = $urlPrefix . Url::getQueryStringFromParameters($parameters);
diff --git a/plugins/ImageGraph/StaticGraph.php b/plugins/ImageGraph/StaticGraph.php
index a3eeee9341..cd4786f090 100644
--- a/plugins/ImageGraph/StaticGraph.php
+++ b/plugins/ImageGraph/StaticGraph.php
@@ -6,22 +6,28 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph
+ * @package ImageGraph
*/
+namespace Piwik\Plugins\ImageGraph;
+
+use Exception;
use Piwik\Loader;
+use Piwik\Plugins\ImageGraph\API;
+use pData;
+use pImage;
require_once PIWIK_INCLUDE_PATH . "/libs/pChart2.1.3/class/pDraw.class.php";
require_once PIWIK_INCLUDE_PATH . "/libs/pChart2.1.3/class/pImage.class.php";
require_once PIWIK_INCLUDE_PATH . "/libs/pChart2.1.3/class/pData.class.php";
/**
- * The Piwik_ImageGraph_StaticGraph abstract class is used as a base class for different types of static graphs.
+ * The StaticGraph abstract class is used as a base class for different types of static graphs.
*
- * @package Piwik_ImageGraph
- * @subpackage Piwik_ImageGraph_StaticGraph
+ * @package ImageGraph
+ * @subpackage StaticGraph
*/
-abstract class Piwik_ImageGraph_StaticGraph
+abstract class StaticGraph
{
const GRAPH_TYPE_BASIC_LINE = "evolution";
const GRAPH_TYPE_VERTICAL_BAR = "verticalBar";
@@ -30,11 +36,11 @@ abstract class Piwik_ImageGraph_StaticGraph
const GRAPH_TYPE_BASIC_PIE = "pie";
static private $availableStaticGraphTypes = array(
- self::GRAPH_TYPE_BASIC_LINE => 'Piwik_ImageGraph_StaticGraph_Evolution',
- self::GRAPH_TYPE_VERTICAL_BAR => 'Piwik_ImageGraph_StaticGraph_VerticalBar',
- self::GRAPH_TYPE_HORIZONTAL_BAR => 'Piwik_ImageGraph_StaticGraph_HorizontalBar',
- self::GRAPH_TYPE_BASIC_PIE => 'Piwik_ImageGraph_StaticGraph_Pie',
- self::GRAPH_TYPE_3D_PIE => 'Piwik_ImageGraph_StaticGraph_3DPie',
+ self::GRAPH_TYPE_BASIC_LINE => 'Evolution',
+ self::GRAPH_TYPE_VERTICAL_BAR => 'VerticalBar',
+ self::GRAPH_TYPE_HORIZONTAL_BAR => 'HorizontalBar',
+ self::GRAPH_TYPE_BASIC_PIE => 'Pie',
+ self::GRAPH_TYPE_3D_PIE => 'Pie3D',
);
const ABSCISSA_SERIE_NAME = 'ABSCISSA';
@@ -73,15 +79,16 @@ abstract class Piwik_ImageGraph_StaticGraph
/**
* Return the StaticGraph according to the static graph type $graphType
*
- * @throws exception If the static graph type is unknown
+ * @throws Exception If the static graph type is unknown
* @param string $graphType
- * @return Piwik_ImageGraph_StaticGraph
+ * @return \Piwik\Plugins\ImageGraph\StaticGraph
*/
public static function factory($graphType)
{
if (isset(self::$availableStaticGraphTypes[$graphType])) {
$className = self::$availableStaticGraphTypes[$graphType];
+ $className = __NAMESPACE__ . "\\StaticGraph\\" . $className;
Loader::loadClass($className);
return new $className;
} else {
@@ -141,7 +148,7 @@ abstract class Piwik_ImageGraph_StaticGraph
public function setFontSize($fontSize)
{
if (!is_numeric($fontSize)) {
- $fontSize = Piwik_ImageGraph_API::DEFAULT_FONT_SIZE;
+ $fontSize = API::DEFAULT_FONT_SIZE;
}
$this->fontSize = $fontSize;
}
@@ -266,8 +273,8 @@ abstract class Piwik_ImageGraph_StaticGraph
$this->pImage->setFontProperties(
array_merge(
array(
- 'FontName' => $this->font,
- 'FontSize' => $this->fontSize,
+ 'FontName' => $this->font,
+ 'FontSize' => $this->fontSize,
),
$this->textColor
)
diff --git a/plugins/ImageGraph/StaticGraph/3DPie.php b/plugins/ImageGraph/StaticGraph/3DPie.php
index 62252c0059..4a7ab3ef06 100644
--- a/plugins/ImageGraph/StaticGraph/3DPie.php
+++ b/plugins/ImageGraph/StaticGraph/3DPie.php
@@ -6,14 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_3DPie extends Piwik_ImageGraph_StaticGraph_PieGraph
+class Pie3D extends PieGraph
{
public function renderGraph()
{
diff --git a/plugins/ImageGraph/StaticGraph/Evolution.php b/plugins/ImageGraph/StaticGraph/Evolution.php
index a4851afaa4..3bc870b9b6 100644
--- a/plugins/ImageGraph/StaticGraph/Evolution.php
+++ b/plugins/ImageGraph/StaticGraph/Evolution.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+use Piwik\Plugins\ImageGraph\StaticGraph\GridGraph;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_Evolution extends Piwik_ImageGraph_StaticGraph_GridGraph
+class Evolution extends GridGraph
{
public function renderGraph()
diff --git a/plugins/ImageGraph/StaticGraph/Exception.php b/plugins/ImageGraph/StaticGraph/Exception.php
index 5140c73eb6..0772e603cf 100644
--- a/plugins/ImageGraph/StaticGraph/Exception.php
+++ b/plugins/ImageGraph/StaticGraph/Exception.php
@@ -6,15 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+use Piwik\Plugins\ImageGraph\StaticGraph;
+use pData;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_Exception extends Piwik_ImageGraph_StaticGraph
+class Exception extends StaticGraph
{
const MESSAGE_RIGHT_MARGIN = 5;
@@ -30,7 +33,6 @@ class Piwik_ImageGraph_StaticGraph_Exception extends Piwik_ImageGraph_StaticGrap
return array();
}
-
public function setWidth($width)
{
if (empty($width)) {
diff --git a/plugins/ImageGraph/StaticGraph/GridGraph.php b/plugins/ImageGraph/StaticGraph/GridGraph.php
index 3efd36bc1a..026c2952bc 100644
--- a/plugins/ImageGraph/StaticGraph/GridGraph.php
+++ b/plugins/ImageGraph/StaticGraph/GridGraph.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+use Piwik\Plugins\ImageGraph\StaticGraph;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-abstract class Piwik_ImageGraph_StaticGraph_GridGraph extends Piwik_ImageGraph_StaticGraph
+abstract class GridGraph extends StaticGraph
{
const GRAPHIC_COLOR_KEY = 'GRAPHIC_COLOR';
@@ -413,7 +415,6 @@ abstract class Piwik_ImageGraph_StaticGraph_GridGraph extends Piwik_ImageGraph_S
}
return $label;
}
-
// display min & max values
// can not currently be used because pChart's label design is not flexible enough
// e.g: it is not possible to remove the box border & the square icon
diff --git a/plugins/ImageGraph/StaticGraph/HorizontalBar.php b/plugins/ImageGraph/StaticGraph/HorizontalBar.php
index fe4cf5b3b4..64ebf2d4e5 100644
--- a/plugins/ImageGraph/StaticGraph/HorizontalBar.php
+++ b/plugins/ImageGraph/StaticGraph/HorizontalBar.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+use Piwik\Plugins\ImageGraph\StaticGraph\GridGraph;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_HorizontalBar extends Piwik_ImageGraph_StaticGraph_GridGraph
+class HorizontalBar extends GridGraph
{
const INTERLEAVE = 0.30;
const PADDING_CHARS = ' ';
@@ -173,7 +175,7 @@ class Piwik_ImageGraph_StaticGraph_HorizontalBar extends Piwik_ImageGraph_Static
- $logoHeight / 2
+ 1;
- if(method_exists($this->pImage, $drawingFunction)) {
+ if (method_exists($this->pImage, $drawingFunction)) {
$this->pImage->$drawingFunction(
$gridLeftMarginBeforePadding,
$logoYPosition,
diff --git a/plugins/ImageGraph/StaticGraph/Pie.php b/plugins/ImageGraph/StaticGraph/Pie.php
index bdfbdef9ab..1626ebd3fc 100644
--- a/plugins/ImageGraph/StaticGraph/Pie.php
+++ b/plugins/ImageGraph/StaticGraph/Pie.php
@@ -6,14 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+
+use Piwik\Plugins\ImageGraph\StaticGraph\PieGraph;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_Pie extends Piwik_ImageGraph_StaticGraph_PieGraph
+class Pie extends PieGraph
{
public function renderGraph()
{
diff --git a/plugins/ImageGraph/StaticGraph/PieGraph.php b/plugins/ImageGraph/StaticGraph/PieGraph.php
index 3f00008f90..86c9852372 100644
--- a/plugins/ImageGraph/StaticGraph/PieGraph.php
+++ b/plugins/ImageGraph/StaticGraph/PieGraph.php
@@ -6,16 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+
+use Piwik\Plugins\ImageGraph\StaticGraph;
+use pPie;
+
require_once PIWIK_INCLUDE_PATH . "/libs/pChart2.1.3/class/pPie.class.php";
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-abstract class Piwik_ImageGraph_StaticGraph_PieGraph extends Piwik_ImageGraph_StaticGraph
+abstract class PieGraph extends StaticGraph
{
const RADIUS_MARGIN = 40;
const PIE_RIGHT_MARGIN = 20;
diff --git a/plugins/ImageGraph/StaticGraph/VerticalBar.php b/plugins/ImageGraph/StaticGraph/VerticalBar.php
index 5bf40df7f8..add00e6423 100644
--- a/plugins/ImageGraph/StaticGraph/VerticalBar.php
+++ b/plugins/ImageGraph/StaticGraph/VerticalBar.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
+namespace Piwik\Plugins\ImageGraph\StaticGraph;
+use Piwik\Plugins\ImageGraph\StaticGraph\GridGraph;
/**
*
- * @package Piwik_ImageGraph_StaticGraph
+ * @package StaticGraph
*/
-class Piwik_ImageGraph_StaticGraph_VerticalBar extends Piwik_ImageGraph_StaticGraph_GridGraph
+class VerticalBar extends GridGraph
{
const INTERLEAVE = 0.10;
diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php
index edf7805509..23333872be 100644
--- a/plugins/Installation/Controller.php
+++ b/plugins/Installation/Controller.php
@@ -6,10 +6,12 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
+namespace Piwik\Plugins\Installation;
+
+use Exception;
use Piwik\API\Request;
-use Piwik\Controller\Admin;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Db\Adapter;
use Piwik\Piwik;
@@ -24,32 +26,39 @@ use Piwik\Version;
use Piwik\Url;
use Piwik\ProxyHeaders;
use Piwik\Db;
+use Piwik\Plugins\Installation\FormDatabaseSetup;
+use Piwik\Plugins\Installation\FormFirstWebsiteSetup;
+use Piwik\Plugins\Installation\FormGeneralSetup;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
+use Zend_Db_Adapter_Exception;
/**
* Installation controller
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
// public so plugins can add/delete installation steps
public $steps = array(
- 'welcome' => 'Installation_Welcome',
- 'systemCheck' => 'Installation_SystemCheck',
- 'databaseSetup' => 'Installation_DatabaseSetup',
- 'databaseCheck' => 'Installation_DatabaseCheck',
- 'tablesCreation' => 'Installation_Tables',
- 'generalSetup' => 'Installation_SuperUser',
- 'firstWebsiteSetup' => 'Installation_SetupWebsite',
- 'trackingCode' => 'Installation_JsTag',
- 'finished' => 'Installation_Congratulations',
+ 'welcome' => 'Installation_Welcome',
+ 'systemCheck' => 'Installation_SystemCheck',
+ 'databaseSetup' => 'Installation_DatabaseSetup',
+ 'databaseCheck' => 'Installation_DatabaseCheck',
+ 'tablesCreation' => 'Installation_Tables',
+ 'generalSetup' => 'Installation_SuperUser',
+ 'firstWebsiteSetup' => 'Installation_SetupWebsite',
+ 'trackingCode' => 'Installation_JsTag',
+ 'finished' => 'Installation_Congratulations',
);
protected $session;
public function __construct()
{
- $this->session = new SessionNamespace('Piwik_Installation');
+ $this->session = new SessionNamespace('Installation');
if (!isset($this->session->currentStepDone)) {
$this->session->currentStepDone = '';
$this->session->skipThisStep = array();
@@ -87,7 +96,7 @@ class Piwik_Installation_Controller extends Admin
// Delete merged js/css files to force regenerations based on updated activated plugin list
Piwik::deleteAllCacheOnUpdate();
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/welcome',
$this->getInstallationSteps(),
__FUNCTION__
@@ -107,7 +116,7 @@ class Piwik_Installation_Controller extends Admin
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/systemCheck',
$this->getInstallationSteps(),
__FUNCTION__
@@ -147,11 +156,11 @@ class Piwik_Installation_Controller extends Admin
// case the user hits the back button
$this->session->skipThisStep = array(
- 'firstWebsiteSetup' => false,
- 'trackingCode' => false,
+ 'firstWebsiteSetup' => false,
+ 'trackingCode' => false,
);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/databaseSetup',
$this->getInstallationSteps(),
__FUNCTION__
@@ -160,7 +169,7 @@ class Piwik_Installation_Controller extends Admin
$view->showNextStep = false;
- $form = new Piwik_Installation_FormDatabaseSetup();
+ $form = new FormDatabaseSetup();
if ($form->validate()) {
try {
@@ -187,7 +196,7 @@ class Piwik_Installation_Controller extends Admin
function databaseCheck()
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/databaseCheck',
$this->getInstallationSteps(),
__FUNCTION__
@@ -246,7 +255,7 @@ class Piwik_Installation_Controller extends Admin
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/tablesCreation',
$this->getInstallationSteps(),
__FUNCTION__
@@ -281,8 +290,8 @@ class Piwik_Installation_Controller extends Admin
Access::getInstance();
Piwik::setUserIsSuperUser();
if ($baseTablesInstalled >= $minimumCountPiwikTables &&
- count(Piwik_SitesManager_API::getInstance()->getAllSitesId()) > 0 &&
- count(Piwik_UsersManager_API::getInstance()->getUsers()) > 0
+ count(SitesManagerAPI::getInstance()->getAllSitesId()) > 0 &&
+ count(SitesManagerAPI::getInstance()->getUsers()) > 0
) {
$view->showReuseExistingTables = true;
// when the user reuses the same tables we skip the website creation step
@@ -313,14 +322,14 @@ class Piwik_Installation_Controller extends Admin
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/generalSetup',
$this->getInstallationSteps(),
__FUNCTION__
);
$this->skipThisStep(__FUNCTION__);
- $form = new Piwik_Installation_FormGeneralSetup();
+ $form = new FormGeneralSetup();
if ($form->validate()) {
$superUserInfos = array(
@@ -370,14 +379,14 @@ class Piwik_Installation_Controller extends Admin
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/firstWebsiteSetup',
$this->getInstallationSteps(),
__FUNCTION__
);
$this->skipThisStep(__FUNCTION__);
- $form = new Piwik_Installation_FormFirstWebsiteSetup();
+ $form = new FormFirstWebsiteSetup();
if (!isset($this->session->generalSetupSuccessMessage)) {
$view->displayGeneralSetupSuccess = true;
$this->session->generalSetupSuccessMessage = true;
@@ -407,7 +416,6 @@ class Piwik_Installation_Controller extends Admin
} catch (Exception $e) {
$view->errorMessage = $e->getMessage();
}
-
}
$view->addForm($form);
echo $view->render();
@@ -420,7 +428,7 @@ class Piwik_Installation_Controller extends Admin
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/trackingCode',
$this->getInstallationSteps(),
__FUNCTION__
@@ -458,7 +466,7 @@ class Piwik_Installation_Controller extends Admin
{
$this->checkPreviousStepIsValid(__FUNCTION__);
- $view = new Piwik_Installation_View(
+ $view = new View(
'@Installation/finished',
$this->getInstallationSteps(),
__FUNCTION__
@@ -562,7 +570,7 @@ class Piwik_Installation_Controller extends Admin
public function saveLanguage()
{
$language = Common::getRequestVar('language');
- Piwik_LanguagesManager::setLanguageForSession($language);
+ LanguagesManager::setLanguageForSession($language);
Url::redirectToReferer();
}
@@ -601,7 +609,7 @@ class Piwik_Installation_Controller extends Admin
}
}
if ($error) {
- Piwik_Login_Controller::clearSession();
+ \Piwik\Plugins\Login\Controller::clearSession();
$message = Piwik_Translate('Installation_ErrorInvalidState',
array('<br /><b>',
'</b>',
@@ -693,20 +701,20 @@ class Piwik_Installation_Controller extends Admin
$directoriesToCheck = array();
- if(!Piwik::isInstalled()) {
+ if (!Piwik::isInstalled()) {
// at install, need /config to be writable (so we can create config.ini.php)
$directoriesToCheck[] = '/config/';
}
$directoriesToCheck = array_merge($directoriesToCheck, array(
- '/tmp/',
- '/tmp/templates_c/',
- '/tmp/cache/',
- '/tmp/assets/',
- '/tmp/latest/',
- '/tmp/tcpdf/',
- '/tmp/sessions/',
- ));
+ '/tmp/',
+ '/tmp/templates_c/',
+ '/tmp/cache/',
+ '/tmp/assets/',
+ '/tmp/latest/',
+ '/tmp/tcpdf/',
+ '/tmp/sessions/',
+ ));
$infos['directories'] = Piwik::checkDirectoriesWritable($directoriesToCheck);
@@ -905,7 +913,6 @@ class Piwik_Installation_Controller extends Admin
$blacklistFunctions = array_map('strtolower', array_map('trim', explode(',', $blacklist)));
return $exists && !in_array($functionName, $blacklistFunctions);
}
-
}
return $exists;
}
diff --git a/plugins/Installation/FormDatabaseSetup.php b/plugins/Installation/FormDatabaseSetup.php
index fc9f3957ee..c67d8b8470 100644
--- a/plugins/Installation/FormDatabaseSetup.php
+++ b/plugins/Installation/FormDatabaseSetup.php
@@ -6,18 +6,24 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
+namespace Piwik\Plugins\Installation;
+
use Piwik\Db\Adapter;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\QuickForm2;
+use Exception;
+use HTML_QuickForm2_DataSource_Array;
+use HTML_QuickForm2_Factory;
+use Zend_Db_Adapter_Exception;
/**
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormDatabaseSetup extends QuickForm2
+class FormDatabaseSetup extends QuickForm2
{
function __construct($id = 'databasesetupform', $method = 'post', $attributes = null, $trackSubmit = false)
{
@@ -26,9 +32,9 @@ class Piwik_Installation_FormDatabaseSetup extends QuickForm2
function init()
{
- HTML_QuickForm2_Factory::registerRule('checkValidFilename', 'Piwik_Installation_FormDatabaseSetup_Rule_checkValidFilename');
+ HTML_QuickForm2_Factory::registerRule('checkValidFilename', 'FormDatabaseSetup_Rule_checkValidFilename');
- $checkUserPrivilegesClass = 'Piwik_Installation_FormDatabaseSetup_Rule_checkUserPrivileges';
+ $checkUserPrivilegesClass = 'Rule_checkUserPrivileges';
HTML_QuickForm2_Factory::registerRule('checkUserPrivileges', $checkUserPrivilegesClass);
$availableAdapters = Adapter::getAdapters();
@@ -44,7 +50,7 @@ class Piwik_Installation_FormDatabaseSetup extends QuickForm2
$user = $this->addElement('text', 'username')
->setLabel(Piwik_Translate('Installation_DatabaseSetupLogin'));
$user->addRule('required', Piwik_Translate('General_Required', Piwik_Translate('Installation_DatabaseSetupLogin')));
- $requiredPrivileges = Piwik_Installation_FormDatabaseSetup_Rule_checkUserPrivileges::getRequiredPrivilegesPretty();
+ $requiredPrivileges = Rule_checkUserPrivileges::getRequiredPrivilegesPretty();
$user->addRule('checkUserPrivileges',
Piwik_Translate('Installation_InsufficientPrivilegesMain', $requiredPrivileges . '<br/><br/>') .
Piwik_Translate('Installation_InsufficientPrivilegesHelp'));
@@ -148,9 +154,9 @@ class Piwik_Installation_FormDatabaseSetup extends QuickForm2
* - DROP
* - CREATE TEMPORARY TABLES
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormDatabaseSetup_Rule_checkUserPrivileges extends HTML_QuickForm2_Rule
+class Rule_checkUserPrivileges extends HTML_QuickForm2_Rule
{
const TEST_TABLE_NAME = 'piwik_test_table';
const TEST_TEMP_TABLE_NAME = 'piwik_test_table_temp';
@@ -228,22 +234,22 @@ class Piwik_Installation_FormDatabaseSetup_Rule_checkUserPrivileges extends HTML
{
return array(
'CREATE' => 'CREATE TABLE ' . self::TEST_TABLE_NAME . ' (
- id INT AUTO_INCREMENT,
- value INT,
- PRIMARY KEY (id),
- KEY index_value (value)
- )',
+ id INT AUTO_INCREMENT,
+ value INT,
+ PRIMARY KEY (id),
+ KEY index_value (value)
+ )',
'ALTER' => 'ALTER TABLE ' . self::TEST_TABLE_NAME . '
- ADD COLUMN other_value INT DEFAULT 0',
+ ADD COLUMN other_value INT DEFAULT 0',
'SELECT' => 'SELECT * FROM ' . self::TEST_TABLE_NAME,
'INSERT' => 'INSERT INTO ' . self::TEST_TABLE_NAME . ' (value) VALUES (123)',
'UPDATE' => 'UPDATE ' . self::TEST_TABLE_NAME . ' SET value = 456 WHERE id = 1',
'DELETE' => 'DELETE FROM ' . self::TEST_TABLE_NAME . ' WHERE id = 1',
'DROP' => 'DROP TABLE ' . self::TEST_TABLE_NAME,
'CREATE TEMPORARY TABLES' => 'CREATE TEMPORARY TABLE ' . self::TEST_TEMP_TABLE_NAME . ' (
- id INT AUTO_INCREMENT,
- PRIMARY KEY (id)
- )',
+ id INT AUTO_INCREMENT,
+ PRIMARY KEY (id)
+ )',
);
}
@@ -294,9 +300,9 @@ class Piwik_Installation_FormDatabaseSetup_Rule_checkUserPrivileges extends HTML
/**
* Filename check for prefix/DB name
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormDatabaseSetup_Rule_checkValidFilename extends HTML_QuickForm2_Rule
+class FormDatabaseSetup_Rule_checkValidFilename extends HTML_QuickForm2_Rule
{
function validateOwner()
{
diff --git a/plugins/Installation/FormFirstWebsiteSetup.php b/plugins/Installation/FormFirstWebsiteSetup.php
index 31c3e4cf4a..2f8a810b1f 100644
--- a/plugins/Installation/FormFirstWebsiteSetup.php
+++ b/plugins/Installation/FormFirstWebsiteSetup.php
@@ -6,15 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
+
+namespace Piwik\Plugins\Installation;
+use HTML_QuickForm2_DataSource_Array;
+use HTML_QuickForm2_Factory;
use Piwik\QuickForm2;
+use Piwik\Plugins\SitesManager\API;
/**
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormFirstWebsiteSetup extends QuickForm2
+class FormFirstWebsiteSetup extends QuickForm2
{
function __construct($id = 'websitesetupform', $method = 'post', $attributes = null, $trackSubmit = false)
{
@@ -23,12 +28,12 @@ class Piwik_Installation_FormFirstWebsiteSetup extends QuickForm2
function init()
{
- HTML_QuickForm2_Factory::registerRule('checkTimezone', 'Piwik_Installation_FormFirstWebsiteSetup_Rule_isValidTimezone');
+ HTML_QuickForm2_Factory::registerRule('checkTimezone', 'Rule_isValidTimezone');
$urlExample = 'http://example.org';
$javascriptOnClickUrlExample = "javascript:if(this.value=='$urlExample'){this.value='http://';} this.style.color='black';";
- $timezones = Piwik_SitesManager_API::getInstance()->getTimezonesList();
+ $timezones = API::getInstance()->getTimezonesList();
$timezones = array_merge(array('No timezone' => Piwik_Translate('SitesManager_SelectACity')), $timezones);
$this->addElement('text', 'siteName')
@@ -66,20 +71,20 @@ class Piwik_Installation_FormFirstWebsiteSetup extends QuickForm2
/**
* Timezone validation rule
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormFirstWebsiteSetup_Rule_isValidTimezone extends HTML_QuickForm2_Rule
+class Rule_isValidTimezone extends HTML_QuickForm2_Rule
{
function validateOwner()
{
try {
$timezone = $this->owner->getValue();
if (!empty($timezone)) {
- Piwik_SitesManager_API::getInstance()->setDefaultTimezone($timezone);
+ API::getInstance()->setDefaultTimezone($timezone);
}
} catch (Exception $e) {
return false;
}
return true;
}
-}
+} \ No newline at end of file
diff --git a/plugins/Installation/FormGeneralSetup.php b/plugins/Installation/FormGeneralSetup.php
index bd2504588a..cfa4ce3c8b 100644
--- a/plugins/Installation/FormGeneralSetup.php
+++ b/plugins/Installation/FormGeneralSetup.php
@@ -6,16 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
-use Piwik\Piwik;
+namespace Piwik\Plugins\Installation;
+
+use HTML_QuickForm2_DataSource_Array;
+use HTML_QuickForm2_Factory;
use Piwik\QuickForm2;
+use Piwik\Piwik;
/**
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormGeneralSetup extends QuickForm2
+class FormGeneralSetup extends QuickForm2
{
function __construct($id = 'generalsetupform', $method = 'post', $attributes = null, $trackSubmit = false)
{
@@ -24,8 +28,8 @@ class Piwik_Installation_FormGeneralSetup extends QuickForm2
function init()
{
- HTML_QuickForm2_Factory::registerRule('checkLogin', 'Piwik_Installation_FormGeneralSetup_Rule_isValidLoginString');
- HTML_QuickForm2_Factory::registerRule('checkEmail', 'Piwik_Installation_FormGeneralSetup_Rule_isValidEmailString');
+ HTML_QuickForm2_Factory::registerRule('checkLogin', 'Rule_isValidLoginString');
+ HTML_QuickForm2_Factory::registerRule('checkEmail', 'Rule_isValidEmailString');
$login = $this->addElement('text', 'login')
->setLabel(Piwik_Translate('Installation_SuperUserLogin'));
@@ -67,9 +71,9 @@ class Piwik_Installation_FormGeneralSetup extends QuickForm2
/**
* Login id validation rule
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormGeneralSetup_Rule_isValidLoginString extends HTML_QuickForm2_Rule
+class Rule_isValidLoginString extends HTML_QuickForm2_Rule
{
function validateOwner()
{
@@ -89,12 +93,12 @@ class Piwik_Installation_FormGeneralSetup_Rule_isValidLoginString extends HTML_Q
/**
* Email address validation rule
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_FormGeneralSetup_Rule_isValidEmailString extends HTML_QuickForm2_Rule
+class Rule_isValidEmailString extends HTML_QuickForm2_Rule
{
function validateOwner()
{
return Piwik::isValidEmailString($this->owner->getValue());
}
-}
+} \ No newline at end of file
diff --git a/plugins/Installation/Installation.php b/plugins/Installation/Installation.php
index 8017e4e535..1fb9a565f9 100644
--- a/plugins/Installation/Installation.php
+++ b/plugins/Installation/Installation.php
@@ -6,20 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
+namespace Piwik\Plugins\Installation;
+
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Plugin;
-use Piwik\Translate;
/**
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation extends Plugin
+class Installation extends \Piwik\Plugin
{
- protected $installationControllerName = 'Piwik_Installation_Controller';
+ protected $installationControllerName = 'Controller';
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/Installation/View.php b/plugins/Installation/View.php
index 84a8d631cf..d5599bed53 100644
--- a/plugins/Installation/View.php
+++ b/plugins/Installation/View.php
@@ -6,15 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Installation
+ * @package Installation
*/
-use Piwik\View;
+namespace Piwik\Plugins\Installation;
+
/**
*
- * @package Piwik_Installation
+ * @package Installation
*/
-class Piwik_Installation_View extends View
+class View extends \Piwik\View
{
public function __construct($subtemplatePath, $installationSteps, $currentStepName)
{
diff --git a/plugins/LanguagesManager/API.php b/plugins/LanguagesManager/API.php
index ee6dd2aaa9..332b68cc9c 100644
--- a/plugins/LanguagesManager/API.php
+++ b/plugins/LanguagesManager/API.php
@@ -6,9 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*
*/
+namespace Piwik\Plugins\LanguagesManager;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Db;
@@ -23,14 +25,14 @@ use Piwik\Db;
* You can also request the default language to load for a user via "getLanguageForUser",
* or update it via "setLanguageForUser".
*
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*/
-class Piwik_LanguagesManager_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_LanguagesManager_API
+ * @return \Piwik\Plugins\LanguagesManager\API
*/
static public function getInstance()
{
diff --git a/plugins/LanguagesManager/Controller.php b/plugins/LanguagesManager/Controller.php
index 212293ce79..3eba8c5097 100644
--- a/plugins/LanguagesManager/Controller.php
+++ b/plugins/LanguagesManager/Controller.php
@@ -6,18 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*
*/
+namespace Piwik\Plugins\LanguagesManager;
+
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\LanguagesManager\API;
use Piwik\Url;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Zend_Registry;
/**
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*/
-class Piwik_LanguagesManager_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
* anonymous = in the session
@@ -31,11 +35,11 @@ class Piwik_LanguagesManager_Controller extends Controller
if (Piwik::isInstalled()) {
$this->checkTokenInUrl();
}
- Piwik_LanguagesManager::setLanguageForSession($language);
+ LanguagesManager::setLanguageForSession($language);
if (Zend_Registry::isRegistered('access')) {
$currentUser = Piwik::getCurrentUserLogin();
if ($currentUser && $currentUser !== 'anonymous') {
- Piwik_LanguagesManager_API::getInstance()->setLanguageForUser($currentUser, $language);
+ API::getInstance()->setLanguageForUser($currentUser, $language);
}
}
Url::redirectToReferer();
diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php
index 6bd1bf553c..004d82ade6 100644
--- a/plugins/LanguagesManager/LanguagesManager.php
+++ b/plugins/LanguagesManager/LanguagesManager.php
@@ -6,23 +6,27 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*
*/
+namespace Piwik\Plugins\LanguagesManager;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Cookie;
+use Piwik\Plugins\LanguagesManager\API;
use Piwik\View;
-use Piwik\Plugin;
use Piwik\Db;
use Piwik\Translate;
+use Zend_Registry;
/**
*
- * @package Piwik_LanguagesManager
+ * @package LanguagesManager
*/
-class Piwik_LanguagesManager extends Plugin
+class LanguagesManager extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -75,7 +79,7 @@ class Piwik_LanguagesManager extends Plugin
private function getLanguagesSelector()
{
$view = new View("@LanguagesManager/getLanguagesSelector");
- $view->languages = Piwik_LanguagesManager_API::getInstance()->getAvailableLanguageNames();
+ $view->languages = API::getInstance()->getAvailableLanguageNames();
$view->currentLanguageCode = self::getLanguageCodeForCurrentUser();
$view->currentLanguageName = self::getLanguageNameForCurrentUser();
return $view->render();
@@ -86,7 +90,7 @@ class Piwik_LanguagesManager extends Plugin
if (empty($language)) {
$language = self::getLanguageCodeForCurrentUser();
}
- if (!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($language)) {
+ if (!API::getInstance()->isLanguageAvailable($language)) {
$language = Translate::getInstance()->getLanguageDefault();
}
}
@@ -132,10 +136,10 @@ class Piwik_LanguagesManager extends Plugin
static public function getLanguageCodeForCurrentUser()
{
$languageCode = self::getLanguageFromPreferences();
- if (!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($languageCode)) {
- $languageCode = Common::extractLanguageCodeFromBrowserLanguage(Common::getBrowserLanguage(), Piwik_LanguagesManager_API::getInstance()->getAvailableLanguages());
+ if (!API::getInstance()->isLanguageAvailable($languageCode)) {
+ $languageCode = Common::extractLanguageCodeFromBrowserLanguage(Common::getBrowserLanguage(), API::getInstance()->getAvailableLanguages());
}
- if (!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($languageCode)) {
+ if (!API::getInstance()->isLanguageAvailable($languageCode)) {
$languageCode = Translate::getInstance()->getLanguageDefault();
}
return $languageCode;
@@ -147,7 +151,7 @@ class Piwik_LanguagesManager extends Plugin
static public function getLanguageNameForCurrentUser()
{
$languageCode = self::getLanguageCodeForCurrentUser();
- $languages = Piwik_LanguagesManager_API::getInstance()->getAvailableLanguageNames();
+ $languages = API::getInstance()->getAvailableLanguageNames();
foreach ($languages as $language) {
if ($language['code'] === $languageCode) {
return $language['name'];
@@ -166,13 +170,12 @@ class Piwik_LanguagesManager extends Plugin
try {
$currentUser = Piwik::getCurrentUserLogin();
- return Piwik_LanguagesManager_API::getInstance()->getLanguageForUser($currentUser);
+ return API::getInstance()->getLanguageForUser($currentUser);
} catch (Exception $e) {
return false;
}
}
-
/**
* Returns the language for the session
*
@@ -196,7 +199,7 @@ class Piwik_LanguagesManager extends Plugin
*/
static public function setLanguageForSession($languageCode)
{
- if (!Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($languageCode)) {
+ if (!API::getInstance()->isLanguageAvailable($languageCode)) {
return false;
}
diff --git a/plugins/Live/API.php b/plugins/Live/API.php
index 8f43f26563..3429892a1c 100644
--- a/plugins/Live/API.php
+++ b/plugins/Live/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Live
+ * @package Live
*/
+namespace Piwik\Plugins\Live;
+
+use Exception;
use Piwik\Config;
use Piwik\DataAccess\LogAggregator;
use Piwik\DataTable\Filter\ColumnDelete;
@@ -24,6 +27,8 @@ use Piwik\Site;
use Piwik\Db;
use Piwik\Tracker\Action;
use Piwik\Tracker\GoalManager;
+use Piwik\Plugins\Live\Visitor;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
* @see plugins/Referers/functions.php
@@ -49,9 +54,9 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/Live/Visitor.php';
* The method "getCounters" is used to return a simple counter: visits, number of actions, number of converted visits, in the last N minutes.
*
* See also the documentation about <a href='http://piwik.org/docs/real-time/' target='_blank'>Real time widget and visitor level reports</a> in Piwik.
- * @package Piwik_Live
+ * @package Live
*/
-class Piwik_Live_API
+class API
{
const VISITOR_PROFILE_MAX_VISITS_TO_AGGREGATE = 100;
const VISITOR_PROFILE_MAX_VISITS_TO_SHOW = 10;
@@ -60,7 +65,7 @@ class Piwik_Live_API
static private $instance = null;
/**
- * @return Piwik_Live_API
+ * @return \Piwik\Plugins\Live\API
*/
static public function getInstance()
{
@@ -344,10 +349,10 @@ class Piwik_Live_API
$site = new Site($idSite);
$timezone = $site->getTimezone();
- $currencies = Piwik_SitesManager_API::getInstance()->getCurrencySymbols();
+ $currencies = SitesManagerAPI::getInstance()->getCurrencySymbols();
foreach ($visitorDetails as $visitorDetail) {
$this->cleanVisitorDetails($visitorDetail, $idSite);
- $visitor = new Piwik_Live_Visitor($visitorDetail);
+ $visitor = new Visitor($visitorDetail);
$visitorDetailsArray = $visitor->getAllVisitorDetails();
$visitorDetailsArray['siteCurrency'] = $site->getCurrency();
@@ -362,11 +367,11 @@ class Piwik_Live_API
$visitorDetailsArray['serverTimePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized('%time%');
$visitorDetailsArray['actionDetails'] = array();
- if(!$doNotFetchActions) {
+ if (!$doNotFetchActions) {
$visitorDetailsArray = $this->enrichVisitorArrayWithActions($visitorDetailsArray, $actionsLimit, $timezone);
}
- if($flat) {
+ if ($flat) {
$visitorDetailsArray = $this->flattenVisitorDetailsArray($visitorDetailsArray);
}
$table->addRowFromArray(array(Row::COLUMNS => $visitorDetailsArray));
@@ -386,7 +391,6 @@ class Piwik_Live_API
return $key;
}
-
/**
* The &flat=1 feature is used by API.getSuggestedValuesForSegment
*
@@ -422,8 +426,8 @@ class Piwik_Live_API
// Flatten Goals
$count = 1;
- foreach($visitorDetailsArray['actionDetails'] as $action) {
- if(!empty($action['goalId'])) {
+ foreach ($visitorDetailsArray['actionDetails'] as $action) {
+ if (!empty($action['goalId'])) {
$flattenedKeyName = 'visitConvertedGoalId' . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['goalId'];
$count++;
@@ -432,18 +436,18 @@ class Piwik_Live_API
// Flatten Page Titles/URLs
$count = 1;
- foreach($visitorDetailsArray['actionDetails'] as $action) {
- if(!empty($action['url'])) {
+ foreach ($visitorDetailsArray['actionDetails'] as $action) {
+ if (!empty($action['url'])) {
$flattenedKeyName = 'pageUrl' . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['url'];
}
- if(!empty($action['pageTitle'])) {
+ if (!empty($action['pageTitle'])) {
$flattenedKeyName = 'pageTitle' . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['pageTitle'];
}
- if(!empty($action['siteSearchKeyword'])) {
+ if (!empty($action['siteSearchKeyword'])) {
$flattenedKeyName = 'siteSearchKeyword' . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['siteSearchKeyword'];
}
@@ -452,25 +456,25 @@ class Piwik_Live_API
// Entry/exit pages
$firstAction = $lastAction = false;
- foreach($visitorDetailsArray['actionDetails'] as $action) {
- if($action['type'] == 'action') {
- if(empty($firstAction)) {
+ foreach ($visitorDetailsArray['actionDetails'] as $action) {
+ if ($action['type'] == 'action') {
+ if (empty($firstAction)) {
$firstAction = $action;
}
$lastAction = $action;
}
}
- if(!empty($firstAction['pageTitle'])) {
+ if (!empty($firstAction['pageTitle'])) {
$visitorDetailsArray['entryPageTitle'] = $firstAction['pageTitle'];
}
- if(!empty($firstAction['url'])) {
+ if (!empty($firstAction['url'])) {
$visitorDetailsArray['entryPageUrl'] = $firstAction['url'];
}
- if(!empty($lastAction['pageTitle'])) {
+ if (!empty($lastAction['pageTitle'])) {
$visitorDetailsArray['exitPageTitle'] = $lastAction['pageTitle'];
}
- if(!empty($lastAction['url'])) {
+ if (!empty($lastAction['url'])) {
$visitorDetailsArray['exitPageUrl'] = $lastAction['url'];
}
@@ -574,8 +578,8 @@ class Piwik_Live_API
// Group by idvisit so that a visitor converting 2 goals only appears once
$sql = "
- SELECT sub.*
- FROM (
+ SELECT sub.*
+ FROM (
" . $subQuery['sql'] . "
$sqlLimit
) AS sub
@@ -680,7 +684,6 @@ class Piwik_Live_API
if (isset($actionDetails[$actionIdx + 1])) {
$actionDetail['timeSpent'] = $actionDetails[$actionIdx + 1]['timeSpentRef'];
$actionDetail['timeSpentPretty'] = Piwik::getPrettyTimeFromSeconds($actionDetail['timeSpent']);
-
}
unset($actionDetails[$actionIdx]['timeSpentRef']); // not needed after timeSpent is added
@@ -826,7 +829,6 @@ class Piwik_Live_API
// Convert datetimes to the site timezone
$dateTimeVisit = Date::factory($details['serverTimePretty'], $timezone);
$details['serverTimePretty'] = $dateTimeVisit->getLocalized(Piwik_Translate('CoreHome_ShortDateFormat') . ' %time%');
-
}
$visitorDetailsArray['goalConversions'] = count($goalDetails);
return $visitorDetailsArray;
diff --git a/plugins/Live/Controller.php b/plugins/Live/Controller.php
index 23ae378074..b8fa0a054c 100644
--- a/plugins/Live/Controller.php
+++ b/plugins/Live/Controller.php
@@ -6,21 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Live
+ * @package Live
*/
+namespace Piwik\Plugins\Live;
+
use Piwik\API\Request;
use Piwik\Common;
use Piwik\Piwik;
use Piwik\Config;
-use Piwik\Controller;
+use Piwik\Plugins\Live\API;
use Piwik\ViewDataTable;
use Piwik\View;
use Piwik\FrontController;
/**
- * @package Piwik_Live
+ * @package Live
*/
-class Piwik_Live_Controller extends Controller
+class Controller extends \Piwik\Controller
{
const SIMPLE_VISIT_COUNT_WIDGET_LAST_MINUTES_CONFIG_KEY = 'live_widget_visitor_count_last_minutes';
@@ -81,7 +83,7 @@ class Piwik_Live_Controller extends Controller
}
echo $rendered;
}
-
+
public function indexVisitorLog()
{
$view = new View('@Live/indexVisitorLog.twig');
@@ -121,9 +123,9 @@ class Piwik_Live_Controller extends Controller
private function setCounters($view)
{
$segment = Request::getRawSegmentFromRequest();
- $last30min = Piwik_Live_API::getInstance()->getCounters($this->idSite, $lastMinutes = 30, $segment);
+ $last30min = API::getInstance()->getCounters($this->idSite, $lastMinutes = 30, $segment);
$last30min = $last30min[0];
- $today = Piwik_Live_API::getInstance()->getCounters($this->idSite, $lastMinutes = 24 * 60, $segment);
+ $today = API::getInstance()->getCounters($this->idSite, $lastMinutes = 24 * 60, $segment);
$today = $today[0];
$view->visitorsCountHalfHour = $last30min['visits'];
$view->visitorsCountToday = $today['visits'];
diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php
index 54820cd836..bbdd142b43 100644
--- a/plugins/Live/Live.php
+++ b/plugins/Live/Live.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Live
+ * @package Live
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\Live;
+
use Piwik\Common;
use Piwik\WidgetsList;
/**
*
- * @package Piwik_Live
+ * @package Live
*/
-class Piwik_Live extends Plugin
+class Live extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -24,10 +25,10 @@ class Piwik_Live extends Plugin
public function getListHooksRegistered()
{
return array(
- 'AssetManager.getJsFiles' => 'getJsFiles',
- 'AssetManager.getCssFiles' => 'getCssFiles',
- 'WidgetsList.add' => 'addWidget',
- 'Menu.add' => 'addMenu',
+ 'AssetManager.getJsFiles' => 'getJsFiles',
+ 'AssetManager.getCssFiles' => 'getCssFiles',
+ 'WidgetsList.add' => 'addWidget',
+ 'Menu.add' => 'addMenu',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
}
@@ -63,14 +64,14 @@ class Piwik_Live extends Plugin
private function getDisplayPropertiesForGetLastVisitsDetails()
{
return array(
- 'datatable_template' => "@Live/getVisitorLog.twig",
- 'disable_generic_filters' => true,
- 'enable_sort' => false,
- 'filter_sort_column' => 'idVisit',
- 'filter_sort_order' => 'asc',
- 'show_search' => false,
- 'filter_limit' => 20,
- 'show_offset_information' => false,
+ 'datatable_template' => "@Live/getVisitorLog.twig",
+ 'disable_generic_filters' => true,
+ 'enable_sort' => false,
+ 'filter_sort_column' => 'idVisit',
+ 'filter_sort_order' => 'asc',
+ 'show_search' => false,
+ 'filter_limit' => 20,
+ 'show_offset_information' => false,
'show_exclude_low_population' => false,
'show_all_views_icons' => false,
'show_table_all_columns' => false,
@@ -78,9 +79,9 @@ class Piwik_Live extends Plugin
'documentation' => Piwik_Translate('Live_VisitorLogDocumentation', array('<br />', '<br />')),
'custom_parameters' => array(
// set a very high row count so that the next link in the footer of the data table is always shown
- 'totalRows' => 10000000,
+ 'totalRows' => 10000000,
- 'filterEcommerce' => Common::getRequestVar('filterEcommerce', 0, 'int'),
+ 'filterEcommerce' => Common::getRequestVar('filterEcommerce', 0, 'int'),
'pageUrlNotDefined' => Piwik_Translate('General_NotDefined', Piwik_Translate('Actions_ColumnPageURL'))
),
'visualization_properties' => array(
diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php
index 5d7441fc38..849521ba3d 100644
--- a/plugins/Live/Visitor.php
+++ b/plugins/Live/Visitor.php
@@ -6,13 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Live
+ * @package Live
*/
+namespace Piwik\Plugins\Live;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\IP;
use Piwik\Tracker;
use Piwik\Tracker\Visit;
+use Piwik\Plugins\API\API as MetaAPI;
+use Piwik\Plugins\Referers\API as ReferersAPI;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
/**
* @see plugins/Referers/functions.php
@@ -27,10 +32,9 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/UserSettings/functions.php';
require_once PIWIK_INCLUDE_PATH . '/plugins/Provider/functions.php';
/**
- *
- * @package Piwik_Live
+ * @package Live
*/
-class Piwik_Live_Visitor
+class Visitor
{
const DELIMITER_PLUGIN_NAME = ", ";
@@ -102,7 +106,7 @@ class Piwik_Live_Visitor
'referrerSearchEngineUrl' => $this->getSearchEngineUrl(),
'referrerSearchEngineIcon' => $this->getSearchEngineIcon(),
'operatingSystem' => $this->getOperatingSystem(),
- 'operatingSystemCode' => $this->getOperatingSystemCode(),
+ 'operatingSystemCode' => $this->getOperatingSystemCode(),
'operatingSystemShortName' => $this->getOperatingSystemShortName(),
'operatingSystemIcon' => $this->getOperatingSystemIcon(),
'browserFamily' => $this->getBrowserFamily(),
@@ -244,17 +248,17 @@ class Piwik_Live_Visitor
function getCountryName()
{
- return Piwik_CountryTranslate($this->getCountryCode());
+ return \Piwik\Plugins\UserCountry\countryTranslate($this->getCountryCode());
}
function getCountryFlag()
{
- return Piwik_getFlagFromCode($this->getCountryCode());
+ return \Piwik\Plugins\UserCountry\getFlagFromCode($this->getCountryCode());
}
function getContinent()
{
- return Piwik_ContinentTranslate($this->getContinentCode());
+ return \Piwik\Plugins\UserCountry\continentTranslate($this->getContinentCode());
}
function getContinentCode()
@@ -274,7 +278,7 @@ class Piwik_Live_Visitor
{
$region = $this->getRegionCode();
if ($region != '' && $region != Visit::UNKNOWN_CODE) {
- return Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes(
+ return GeoIp::getRegionNameFromCodes(
$this->details['location_country'], $region);
}
return null;
@@ -335,12 +339,12 @@ class Piwik_Live_Visitor
function getRefererType()
{
- return Piwik_getRefererTypeFromShortName($this->details['referer_type']);
+ return \Piwik\Plugins\Referers\getRefererTypeFromShortName($this->details['referer_type']);
}
function getRefererTypeName()
{
- return Piwik_getRefererTypeLabel($this->details['referer_type']);
+ return \Piwik\Plugins\Referers\getRefererTypeLabel($this->details['referer_type']);
}
function getKeyword()
@@ -349,7 +353,7 @@ class Piwik_Live_Visitor
if (\Piwik\PluginsManager::getInstance()->isPluginActivated('Referers')
&& $this->getRefererType() == 'search'
) {
- $keyword = Piwik_Referers_API::getCleanKeyword($keyword);
+ $keyword = \Piwik\Plugins\Referers\API::getCleanKeyword($keyword);
}
return urldecode($keyword);
}
@@ -358,7 +362,7 @@ class Piwik_Live_Visitor
{
if ($this->getRefererType() == 'search') {
if (\Piwik\PluginsManager::getInstance()->isPluginActivated('Referers')
- && $this->details['referer_keyword'] == Piwik_Referers_API::LABEL_KEYWORD_NOT_DEFINED
+ && $this->details['referer_keyword'] == ReferersAPI::LABEL_KEYWORD_NOT_DEFINED
) {
return 'http://piwik.org/faq/general/#faq_144';
} // Case URL is google.XX/url.... then we rewrite to the search result page url
@@ -367,7 +371,7 @@ class Piwik_Live_Visitor
) {
$refUrl = @parse_url($this->details['referer_url']);
if (isset($refUrl['host'])) {
- $url = Piwik_getSearchEngineUrlFromUrlAndKeyword('http://google.com', $this->getKeyword());
+ $url = \Piwik\Plugins\Referers\getSearchEngineUrlFromUrlAndKeyword('http://google.com', $this->getKeyword());
$url = str_replace('google.com', $refUrl['host'], $url);
return $url;
}
@@ -406,7 +410,7 @@ class Piwik_Live_Visitor
if ($this->getRefererType() == 'search'
&& !empty($this->details['referer_name'])
) {
- return Piwik_getSearchEngineUrlFromName($this->details['referer_name']);
+ return \Piwik\Plugins\Referers\getSearchEngineUrlFromName($this->details['referer_name']);
}
return null;
}
@@ -415,7 +419,7 @@ class Piwik_Live_Visitor
{
$searchEngineUrl = $this->getSearchEngineUrl();
if (!is_null($searchEngineUrl)) {
- return Piwik_getSearchEngineLogoFromUrl($searchEngineUrl);
+ return \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl($searchEngineUrl);
}
return null;
}
@@ -451,7 +455,7 @@ class Piwik_Live_Visitor
$pluginIcons = array();
foreach ($pluginNames as $plugin) {
- $pluginIcons[] = array("pluginIcon" => Piwik_getPluginsLogo($plugin), "pluginName" => $plugin);
+ $pluginIcons[] = array("pluginIcon" => \Piwik\Plugins\UserSettings\getPluginsLogo($plugin), "pluginName" => $plugin);
}
return $pluginIcons;
}
@@ -465,27 +469,27 @@ class Piwik_Live_Visitor
function getOperatingSystem()
{
- return Piwik_getOSLabel($this->details['config_os']);
+ return \Piwik\Plugins\UserSettings\getOSLabel($this->details['config_os']);
}
function getOperatingSystemShortName()
{
- return Piwik_getOSShortLabel($this->details['config_os']);
+ return \Piwik\Plugins\UserSettings\getOSShortLabel($this->details['config_os']);
}
function getOperatingSystemIcon()
{
- return Piwik_getOSLogo($this->details['config_os']);
+ return \Piwik\Plugins\UserSettings\getOSLogo($this->details['config_os']);
}
function getBrowserFamilyDescription()
{
- return Piwik_getBrowserTypeLabel($this->getBrowserFamily());
+ return \Piwik\Plugins\UserSettings\getBrowserTypeLabel($this->getBrowserFamily());
}
function getBrowserFamily()
{
- return Piwik_getBrowserFamily($this->details['config_browser_name']);
+ return \Piwik\Plugins\UserSettings\getBrowserFamily($this->details['config_browser_name']);
}
function getBrowserCode()
@@ -500,23 +504,23 @@ class Piwik_Live_Visitor
function getBrowser()
{
- return Piwik_getBrowserLabel($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
+ return \Piwik\Plugins\UserSettings\getBrowserLabel($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
}
function getBrowserIcon()
{
- return Piwik_getBrowsersLogo($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
+ return \Piwik\Plugins\UserSettings\getBrowsersLogo($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
}
function getScreenType()
{
- return Piwik_getScreenTypeFromResolution($this->details['config_resolution']);
+ return \Piwik\Plugins\UserSettings\getScreenTypeFromResolution($this->details['config_resolution']);
}
function getDeviceType()
{
- if(\Piwik\PluginsManager::getInstance()->isPluginActivated('DevicesDetection')) {
- return Piwik_getDeviceTypeLabel($this->details['config_device_type']);
+ if (\Piwik\PluginsManager::getInstance()->isPluginActivated('DevicesDetection')) {
+ return \Piwik\Plugins\DevicesDetection\getDeviceTypeLabel($this->details['config_device_type']);
}
return false;
}
@@ -528,9 +532,9 @@ class Piwik_Live_Visitor
function getScreenTypeIcon()
{
- return Piwik_getScreensLogo($this->getScreenType());
+ return \Piwik\Plugins\UserSettings\getScreensLogo($this->getScreenType());
}
-
+
function getProvider()
{
if (isset($this->details['location_provider'])) {
@@ -542,12 +546,12 @@ class Piwik_Live_Visitor
function getProviderName()
{
- return Piwik_Provider_getPrettyProviderName($this->getProvider());
+ return \Piwik\Plugins\Provider\getPrettyProviderName($this->getProvider());
}
function getProviderUrl()
{
- return Piwik_getHostnameUrl(@$this->details['location_provider']);
+ return \Piwik\Plugins\Provider\getHostnameUrl(@$this->details['location_provider']);
}
function getDateTimeLastAction()
@@ -569,7 +573,7 @@ class Piwik_Live_Visitor
function getVisitEcommerceStatus()
{
- return Piwik_API_API::getVisitEcommerceStatusFromId($this->details['visit_goal_buyer']);
+ return MetaAPI::getVisitEcommerceStatusFromId($this->details['visit_goal_buyer']);
}
function getVisitorGoalConvertedIcon()
diff --git a/plugins/Login/Auth.php b/plugins/Login/Auth.php
index 251369e976..10bad0d0ac 100644
--- a/plugins/Login/Auth.php
+++ b/plugins/Login/Auth.php
@@ -6,19 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Login
+ * @package Login
*/
+namespace Piwik\Plugins\Login;
+
use Piwik\Config;
use Piwik\Common;
-use Piwik\Auth;
use Piwik\AuthResult;
use Piwik\Db;
+use Piwik\Plugins\UsersManager\API;
/**
*
- * @package Piwik_Login
+ * @package Login
*/
-class Piwik_Login_Auth implements Auth
+class Auth implements \Piwik\Auth
{
protected $login = null;
protected $token_auth = null;
@@ -42,7 +44,7 @@ class Piwik_Login_Auth implements Auth
{
$rootLogin = Config::getInstance()->superuser['login'];
$rootPassword = Config::getInstance()->superuser['password'];
- $rootToken = Piwik_UsersManager_API::getInstance()->getTokenAuth($rootLogin, $rootPassword);
+ $rootToken = API::getInstance()->getTokenAuth($rootLogin, $rootPassword);
if (is_null($this->login)) {
if ($this->token_auth === $rootToken) {
diff --git a/plugins/Login/Controller.php b/plugins/Login/Controller.php
index 4aebcd3a86..1e440de915 100644
--- a/plugins/Login/Controller.php
+++ b/plugins/Login/Controller.php
@@ -6,12 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Login
+ * @package Login
*/
+namespace Piwik\Plugins\Login;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\Cookie;
use Piwik\IP;
use Piwik\Mail;
@@ -20,15 +22,20 @@ use Piwik\View;
use Piwik\Url;
use Piwik\QuickForm2;
use Piwik\Session;
+use Piwik\Plugins\Login\Login;
+use Piwik\Plugins\Login\FormLogin;
+use Piwik\Plugins\Login\FormResetPassword;
+use Piwik\Plugins\UsersManager\UsersManager;
+use Piwik\Plugins\UsersManager\API;
require_once PIWIK_INCLUDE_PATH . '/core/Config.php';
/**
* Login controller
*
- * @package Piwik_Login
+ * @package Login
*/
-class Piwik_Login_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
* Generate hash on user info and password
@@ -71,10 +78,10 @@ class Piwik_Login_Controller extends Controller
{
self::checkForceSslLogin();
- $form = new Piwik_Login_FormLogin();
+ $form = new FormLogin();
if ($form->validate()) {
$nonce = $form->getSubmitValue('form_nonce');
- if (Nonce::verifyNonce('Piwik_Login.login', $nonce)) {
+ if (Nonce::verifyNonce('Login.login', $nonce)) {
$login = $form->getSubmitValue('form_login');
$password = $form->getSubmitValue('form_password');
$rememberMe = $form->getSubmitValue('form_rememberme') == '1';
@@ -112,7 +119,7 @@ class Piwik_Login_Controller extends Controller
$view->forceSslLogin = Config::getInstance()->General['force_ssl_login'];
// crsf token: don't trust the submitted value; generate/fetch it from session data
- $view->nonce = Nonce::getNonce('Piwik_Login.login');
+ $view->nonce = Nonce::getNonce('Login.login');
}
/**
@@ -162,7 +169,7 @@ class Piwik_Login_Controller extends Controller
'md5Password' => $md5Password,
'rememberMe' => $rememberMe,
);
- Nonce::discardNonce('Piwik_Login.login');
+ Nonce::discardNonce('Login.login');
Piwik_PostEvent('Login.initSession', array(&$info));
Url::redirectToUrl($urlToRedirect);
}
@@ -188,10 +195,10 @@ class Piwik_Login_Controller extends Controller
$infoMessage = null;
$formErrors = null;
- $form = new Piwik_Login_FormResetPassword();
+ $form = new FormResetPassword();
if ($form->validate()) {
$nonce = $form->getSubmitValue('form_nonce');
- if (Nonce::verifyNonce('Piwik_Login.login', $nonce)) {
+ if (Nonce::verifyNonce('Login.login', $nonce)) {
$formErrors = $this->resetPasswordFirstStep($form);
if (empty($formErrors)) {
$infoMessage = Piwik_Translate('Login_ConfirmationLinkSent');
@@ -225,7 +232,7 @@ class Piwik_Login_Controller extends Controller
// check the password
try {
- Piwik_UsersManager::checkPassword($password);
+ UsersManager::checkPassword($password);
} catch (Exception $ex) {
return array($ex->getMessage());
}
@@ -243,14 +250,14 @@ class Piwik_Login_Controller extends Controller
$login = $user['login'];
// if valid, store password information in options table, then...
- Piwik_Login::savePasswordResetInfo($login, $password);
+ Login::savePasswordResetInfo($login, $password);
// ... send email with confirmation link
try {
$this->sendEmailConfirmationLink($user);
} catch (Exception $ex) {
// remove password reset info
- Piwik_Login::removePasswordResetInfo($login);
+ Login::removePasswordResetInfo($login);
return array($ex->getMessage() . '<br/>' . Piwik_Translate('Login_ContactAdmin'));
}
@@ -312,7 +319,7 @@ class Piwik_Login_Controller extends Controller
}
// check that the reset token is valid
- $resetPassword = Piwik_Login::getPasswordToResetTo($login);
+ $resetPassword = Login::getPasswordToResetTo($login);
if ($resetPassword === false || !self::isValidToken($resetToken, $user)) {
throw new Exception(Piwik_Translate('Login_InvalidOrExpiredToken'));
}
@@ -356,7 +363,7 @@ class Piwik_Login_Controller extends Controller
Config::getInstance()->superuser = $user;
Config::getInstance()->forceSave();
} else {
- Piwik_UsersManager_API::getInstance()->updateUser(
+ API::getInstance()->updateUser(
$user['login'], $passwordHash, $email = false, $alias = false, $isPasswordHashed = true);
}
}
@@ -390,10 +397,10 @@ class Piwik_Login_Controller extends Controller
'email' => Piwik::getSuperUserEmail(),
'password' => Config::getInstance()->superuser['password'],
);
- } else if (Piwik_UsersManager_API::getInstance()->userExists($loginMail)) {
- $user = Piwik_UsersManager_API::getInstance()->getUser($loginMail);
- } else if (Piwik_UsersManager_API::getInstance()->userEmailExists($loginMail)) {
- $user = Piwik_UsersManager_API::getInstance()->getUserByEmail($loginMail);
+ } else if (API::getInstance()->userExists($loginMail)) {
+ $user = API::getInstance()->getUser($loginMail);
+ } else if (API::getInstance()->userEmailExists($loginMail)) {
+ $user = API::getInstance()->getUserByEmail($loginMail);
}
return $user;
diff --git a/plugins/Login/FormLogin.php b/plugins/Login/FormLogin.php
index 229288e713..f0f5596fe5 100644
--- a/plugins/Login/FormLogin.php
+++ b/plugins/Login/FormLogin.php
@@ -6,15 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Login
+ * @package Login
*/
+namespace Piwik\Plugins\Login;
+
+use HTML_QuickForm2_DataSource_Array;
use Piwik\QuickForm2;
/**
*
- * @package Piwik_Login
+ * @package Login
*/
-class Piwik_Login_FormLogin extends QuickForm2
+class FormLogin extends QuickForm2
{
function __construct($id = 'login_form', $method = 'post', $attributes = null, $trackSubmit = false)
{
diff --git a/plugins/Login/FormResetPassword.php b/plugins/Login/FormResetPassword.php
index abbe1bd4a1..0f02aaedcf 100644
--- a/plugins/Login/FormResetPassword.php
+++ b/plugins/Login/FormResetPassword.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Login
+ * @package Login
*/
+namespace Piwik\Plugins\Login;
+
use Piwik\QuickForm2;
/**
*
- * @package Piwik_Login
+ * @package Login
*/
-class Piwik_Login_FormResetPassword extends QuickForm2
+class FormResetPassword extends QuickForm2
{
function __construct($id = 'resetpasswordform', $method = 'post', $attributes = null, $trackSubmit = false)
{
diff --git a/plugins/Login/Login.php b/plugins/Login/Login.php
index b1da0954ad..2e511b0a5b 100644
--- a/plugins/Login/Login.php
+++ b/plugins/Login/Login.php
@@ -6,20 +6,26 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Login
+ * @package Login
*/
+namespace Piwik\Plugins\Login;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Cookie;
use Piwik\Option;
+use Piwik\Plugins\Login\Auth;
+use Piwik\Plugins\Login\Controller;
use Piwik\Session;
-use Piwik\Plugin;
+use Piwik\Plugins\UsersManager\UsersManager;
+use Piwik\Plugins\UsersManager\API;
/**
*
- * @package Piwik_Login
+ * @package Login
*/
-class Piwik_Login extends Plugin
+class Login extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -43,7 +49,7 @@ class Piwik_Login extends Plugin
{
$exceptionMessage = $exception->getMessage();
- $controller = new Piwik_Login_Controller();
+ $controller = new Controller();
$controller->login($exceptionMessage, '' /* $exception->getTraceAsString() */);
}
@@ -63,7 +69,7 @@ class Piwik_Login extends Plugin
*/
function initAuthenticationObject($allowCookieAuthentication = false)
{
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
\Zend_Registry::set('auth', $auth);
$action = Piwik::getAction();
@@ -91,7 +97,7 @@ class Piwik_Login extends Plugin
/**
* Authenticate user and initializes the session.
* Listens to Login.initSession hook.
- *
+ *
* @throws Exception
*/
public function initSession($info)
@@ -100,7 +106,7 @@ class Piwik_Login extends Plugin
$md5Password = $info['md5Password'];
$rememberMe = $info['rememberMe'];
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($login, $md5Password);
+ $tokenAuth = API::getInstance()->getTokenAuth($login, $md5Password);
$auth = \Zend_Registry::get('auth');
$auth->setLogin($login);
@@ -137,7 +143,7 @@ class Piwik_Login extends Plugin
public static function savePasswordResetInfo($login, $password)
{
$optionName = self::getPasswordResetInfoOptionName($login);
- $optionData = Piwik_UsersManager::getPasswordHash($password);
+ $optionData = UsersManager::getPasswordHash($password);
Piwik_SetOption($optionName, $optionData);
}
diff --git a/plugins/MobileMessaging/API.php b/plugins/MobileMessaging/API.php
index 491bb46f86..bb2664ffff 100644
--- a/plugins/MobileMessaging/API.php
+++ b/plugins/MobileMessaging/API.php
@@ -6,10 +6,15 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Plugins\MobileMessaging\MobileMessaging;
+use Piwik\Plugins\MobileMessaging\SMSProvider;
+use Piwik\Plugins\PDFReports\API as PDFReportsAPI;
/**
* The MobileMessaging API lets you manage and access all the MobileMessaging plugin features including :
@@ -17,9 +22,9 @@ use Piwik\Common;
* - activate phone numbers
* - check remaining credits
* - send SMS
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging_API
+class API
{
const VERIFICATION_CODE_LENGTH = 5;
const SMS_FROM = 'Piwik';
@@ -27,7 +32,7 @@ class Piwik_MobileMessaging_API
static private $instance = null;
/**
- * @return Piwik_MobileMessaging_API
+ * @return \Piwik\Plugins\MobileMessaging\API
*/
static public function getInstance()
{
@@ -39,11 +44,11 @@ class Piwik_MobileMessaging_API
/**
* @param string $provider
- * @return Piwik_MobileMessaging_SMSProvider
+ * @return SMSProvider
*/
static private function getSMSProviderInstance($provider)
{
- return Piwik_MobileMessaging_SMSProvider::factory($provider);
+ return SMSProvider::factory($provider);
}
/**
@@ -56,17 +61,17 @@ class Piwik_MobileMessaging_API
Piwik::checkUserHasSomeViewAccess();
$credential = $this->getSMSAPICredential();
- return isset($credential[Piwik_MobileMessaging::API_KEY_OPTION]);
+ return isset($credential[MobileMessaging::API_KEY_OPTION]);
}
private function getSMSAPICredential()
{
$settings = $this->getCredentialManagerSettings();
return array(
- Piwik_MobileMessaging::PROVIDER_OPTION =>
- isset($settings[Piwik_MobileMessaging::PROVIDER_OPTION]) ? $settings[Piwik_MobileMessaging::PROVIDER_OPTION] : null,
- Piwik_MobileMessaging::API_KEY_OPTION =>
- isset($settings[Piwik_MobileMessaging::API_KEY_OPTION]) ? $settings[Piwik_MobileMessaging::API_KEY_OPTION] : null,
+ MobileMessaging::PROVIDER_OPTION =>
+ isset($settings[MobileMessaging::PROVIDER_OPTION]) ? $settings[MobileMessaging::PROVIDER_OPTION] : null,
+ MobileMessaging::API_KEY_OPTION =>
+ isset($settings[MobileMessaging::API_KEY_OPTION]) ? $settings[MobileMessaging::API_KEY_OPTION] : null,
);
}
@@ -79,7 +84,7 @@ class Piwik_MobileMessaging_API
{
$this->checkCredentialManagementRights();
$credential = $this->getSMSAPICredential();
- return $credential[Piwik_MobileMessaging::PROVIDER_OPTION];
+ return $credential[MobileMessaging::PROVIDER_OPTION];
}
/**
@@ -99,8 +104,8 @@ class Piwik_MobileMessaging_API
$settings = $this->getCredentialManagerSettings();
- $settings[Piwik_MobileMessaging::PROVIDER_OPTION] = $provider;
- $settings[Piwik_MobileMessaging::API_KEY_OPTION] = $apiKey;
+ $settings[MobileMessaging::PROVIDER_OPTION] = $provider;
+ $settings[MobileMessaging::API_KEY_OPTION] = $apiKey;
$this->setCredentialManagerSettings($settings);
@@ -140,7 +145,7 @@ class Piwik_MobileMessaging_API
$phoneNumbers[$phoneNumber] = $verificationCode;
$this->savePhoneNumbers($phoneNumbers);
- $this->increaseCount(Piwik_MobileMessaging::PHONE_NUMBER_VALIDATION_REQUEST_COUNT_OPTION, $phoneNumber);
+ $this->increaseCount(MobileMessaging::PHONE_NUMBER_VALIDATION_REQUEST_COUNT_OPTION, $phoneNumber);
return true;
}
@@ -171,15 +176,15 @@ class Piwik_MobileMessaging_API
Piwik::checkUserIsNotAnonymous();
$credential = $this->getSMSAPICredential();
- $SMSProvider = self::getSMSProviderInstance($credential[Piwik_MobileMessaging::PROVIDER_OPTION]);
+ $SMSProvider = self::getSMSProviderInstance($credential[MobileMessaging::PROVIDER_OPTION]);
$SMSProvider->sendSMS(
- $credential[Piwik_MobileMessaging::API_KEY_OPTION],
+ $credential[MobileMessaging::API_KEY_OPTION],
$content,
$phoneNumber,
$from
);
- $this->increaseCount(Piwik_MobileMessaging::SMS_SENT_COUNT_OPTION, $phoneNumber);
+ $this->increaseCount(MobileMessaging::SMS_SENT_COUNT_OPTION, $phoneNumber);
return true;
}
@@ -194,9 +199,9 @@ class Piwik_MobileMessaging_API
$this->checkCredentialManagementRights();
$credential = $this->getSMSAPICredential();
- $SMSProvider = self::getSMSProviderInstance($credential[Piwik_MobileMessaging::PROVIDER_OPTION]);
+ $SMSProvider = self::getSMSProviderInstance($credential[MobileMessaging::PROVIDER_OPTION]);
return $SMSProvider->getCreditLeft(
- $credential[Piwik_MobileMessaging::API_KEY_OPTION]
+ $credential[MobileMessaging::API_KEY_OPTION]
);
}
@@ -216,7 +221,7 @@ class Piwik_MobileMessaging_API
$this->savePhoneNumbers($phoneNumbers);
// remove phone number from reports
- $pdfReportsAPIInstance = Piwik_PDFReports_API::getInstance();
+ $pdfReportsAPIInstance = PDFReportsAPI::getInstance();
$reports = $pdfReportsAPIInstance->getReports(
$idSite = false,
$period = false,
@@ -225,9 +230,9 @@ class Piwik_MobileMessaging_API
);
foreach ($reports as $report) {
- if ($report['type'] == Piwik_MobileMessaging::MOBILE_TYPE) {
+ if ($report['type'] == MobileMessaging::MOBILE_TYPE) {
$reportParameters = $report['parameters'];
- $reportPhoneNumbers = $reportParameters[Piwik_MobileMessaging::PHONE_NUMBERS_PARAMETER];
+ $reportPhoneNumbers = $reportParameters[MobileMessaging::PHONE_NUMBERS_PARAMETER];
$updatedPhoneNumbers = array();
foreach ($reportPhoneNumbers as $reportPhoneNumber) {
if ($reportPhoneNumber != $phoneNumber) {
@@ -236,7 +241,7 @@ class Piwik_MobileMessaging_API
}
if (count($updatedPhoneNumbers) != count($reportPhoneNumbers)) {
- $reportParameters[Piwik_MobileMessaging::PHONE_NUMBERS_PARAMETER] = $updatedPhoneNumbers;
+ $reportParameters[MobileMessaging::PHONE_NUMBERS_PARAMETER] = $updatedPhoneNumbers;
// note: reports can end up without any recipients
$pdfReportsAPIInstance->updateReport(
@@ -262,8 +267,8 @@ class Piwik_MobileMessaging_API
$settings = $this->getCurrentUserSettings();
$phoneNumbers = array();
- if (isset($settings[Piwik_MobileMessaging::PHONE_NUMBERS_OPTION])) {
- $phoneNumbers = $settings[Piwik_MobileMessaging::PHONE_NUMBERS_OPTION];
+ if (isset($settings[MobileMessaging::PHONE_NUMBERS_OPTION])) {
+ $phoneNumbers = $settings[MobileMessaging::PHONE_NUMBERS_OPTION];
}
return $phoneNumbers;
@@ -273,7 +278,7 @@ class Piwik_MobileMessaging_API
{
$settings = $this->getCurrentUserSettings();
- $settings[Piwik_MobileMessaging::PHONE_NUMBERS_OPTION] = $phoneNumbers;
+ $settings[MobileMessaging::PHONE_NUMBERS_OPTION] = $phoneNumbers;
$this->setCurrentUserSettings($settings);
}
@@ -383,7 +388,7 @@ class Piwik_MobileMessaging_API
$settings = $this->getCredentialManagerSettings();
- $settings[Piwik_MobileMessaging::API_KEY_OPTION] = null;
+ $settings[MobileMessaging::API_KEY_OPTION] = null;
$this->setCredentialManagerSettings($settings);
@@ -398,7 +403,7 @@ class Piwik_MobileMessaging_API
private function setUserSettings($user, $settings)
{
Piwik_SetOption(
- $user . Piwik_MobileMessaging::USER_SETTINGS_POSTFIX_OPTION,
+ $user . MobileMessaging::USER_SETTINGS_POSTFIX_OPTION,
Common::json_encode($settings)
);
}
@@ -420,7 +425,7 @@ class Piwik_MobileMessaging_API
private function getUserSettings($user)
{
- $optionIndex = $user . Piwik_MobileMessaging::USER_SETTINGS_POSTFIX_OPTION;
+ $optionIndex = $user . MobileMessaging::USER_SETTINGS_POSTFIX_OPTION;
$userSettings = Piwik_GetOption($optionIndex);
if (empty($userSettings)) {
@@ -450,7 +455,7 @@ class Piwik_MobileMessaging_API
public function setDelegatedManagement($delegatedManagement)
{
Piwik::checkUserIsSuperUser();
- Piwik_SetOption(Piwik_MobileMessaging::DELEGATED_MANAGEMENT_OPTION, $delegatedManagement);
+ Piwik_SetOption(MobileMessaging::DELEGATED_MANAGEMENT_OPTION, $delegatedManagement);
}
/**
@@ -461,6 +466,6 @@ class Piwik_MobileMessaging_API
public function getDelegatedManagement()
{
Piwik::checkUserHasSomeViewAccess();
- return Piwik_GetOption(Piwik_MobileMessaging::DELEGATED_MANAGEMENT_OPTION) == 'true';
+ return Piwik_GetOption(MobileMessaging::DELEGATED_MANAGEMENT_OPTION) == 'true';
}
}
diff --git a/plugins/MobileMessaging/APIException.php b/plugins/MobileMessaging/APIException.php
index d48bb0520a..515d872bf0 100644
--- a/plugins/MobileMessaging/APIException.php
+++ b/plugins/MobileMessaging/APIException.php
@@ -6,13 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
+use Exception;
+
/**
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging_APIException extends Exception
+class APIException extends Exception
{
}
diff --git a/plugins/MobileMessaging/Controller.php b/plugins/MobileMessaging/Controller.php
index 0054d62912..7cbf2d3bf2 100644
--- a/plugins/MobileMessaging/Controller.php
+++ b/plugins/MobileMessaging/Controller.php
@@ -6,22 +6,27 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-use Piwik\Controller\Admin;
+namespace Piwik\Plugins\MobileMessaging;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\IP;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Piwik\Plugins\MobileMessaging\API;
use Piwik\View;
+use Piwik\Plugins\MobileMessaging\CountryCallingCodes;
+use Piwik\Plugins\MobileMessaging\SMSProvider;
require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/functions.php';
/**
*
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
/*
* Mobile Messaging Settings tab :
@@ -38,7 +43,7 @@ class Piwik_MobileMessaging_Controller extends Admin
$view->isSuperUser = Piwik::isUserIsSuperUser();
- $mobileMessagingAPI = Piwik_MobileMessaging_API::getInstance();
+ $mobileMessagingAPI = API::getInstance();
$view->delegatedManagement = $mobileMessagingAPI->getDelegatedManagement();
$view->credentialSupplied = $mobileMessagingAPI->areSMSAPICredentialProvided();
$view->accountManagedByCurrentUser = $view->isSuperUser || $view->delegatedManagement;
@@ -48,23 +53,23 @@ class Piwik_MobileMessaging_Controller extends Admin
$view->creditLeft = $mobileMessagingAPI->getCreditLeft();
}
- $view->smsProviders = Piwik_MobileMessaging_SMSProvider::$availableSMSProviders;
+ $view->smsProviders = SMSProvider::$availableSMSProviders;
// construct the list of countries from the lang files
$countries = array();
foreach (Common::getCountriesList() as $countryCode => $continentCode) {
- if (isset(Piwik_MobileMessaging_CountryCallingCodes::$countryCallingCodes[$countryCode])) {
+ if (isset(CountryCallingCodes::$countryCallingCodes[$countryCode])) {
$countries[$countryCode] =
array(
- 'countryName' => Piwik_CountryTranslate($countryCode),
- 'countryCallingCode' => Piwik_MobileMessaging_CountryCallingCodes::$countryCallingCodes[$countryCode],
+ 'countryName' => \Piwik\Plugins\UserCountry\countryTranslate($countryCode),
+ 'countryCallingCode' => CountryCallingCodes::$countryCallingCodes[$countryCode],
);
}
}
$view->countries = $countries;
$view->defaultCountry = Common::getCountry(
- Piwik_LanguagesManager::getLanguageCodeForCurrentUser(),
+ LanguagesManager::getLanguageCodeForCurrentUser(),
true,
IP::getIpFromHeader()
);
diff --git a/plugins/MobileMessaging/CountryCallingCodes.php b/plugins/MobileMessaging/CountryCallingCodes.php
index b1097220f8..b98aa180ad 100644
--- a/plugins/MobileMessaging/CountryCallingCodes.php
+++ b/plugins/MobileMessaging/CountryCallingCodes.php
@@ -6,14 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
/**
*
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging_CountryCallingCodes
+class CountryCallingCodes
{
// list taken from core/DataFiles/Countries.php
public static $countryCallingCodes = array(
diff --git a/plugins/MobileMessaging/GSMCharset.php b/plugins/MobileMessaging/GSMCharset.php
index 4d58c96580..3a8da08290 100644
--- a/plugins/MobileMessaging/GSMCharset.php
+++ b/plugins/MobileMessaging/GSMCharset.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
/**
* GSM 03.38 Charset
*
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging_GSMCharset
+class GSMCharset
{
public static $GSMCharset = array(
diff --git a/plugins/MobileMessaging/MobileMessaging.php b/plugins/MobileMessaging/MobileMessaging.php
index 532e511d73..fecec9de43 100644
--- a/plugins/MobileMessaging/MobileMessaging.php
+++ b/plugins/MobileMessaging/MobileMessaging.php
@@ -6,17 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
use Piwik\Piwik;
+use Piwik\Plugins\MobileMessaging\API as MobileMessagingAPI;
use Piwik\View;
-use Piwik\Plugin;
+use Piwik\Plugins\API\API;
+use Piwik\Plugins\MobileMessaging\ReportRenderer\ReportRendererException;
+use Piwik\Plugins\MobileMessaging\ReportRenderer\Sms;
+use Piwik\Plugins\PDFReports\API as PDFReportsAPI;
/**
*
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
-class Piwik_MobileMessaging extends Plugin
+class MobileMessaging extends \Piwik\Plugin
{
const DELEGATED_MANAGEMENT_OPTION = 'MobileMessaging_DelegatedManagement';
const PROVIDER_OPTION = 'Provider';
@@ -98,12 +104,12 @@ class Piwik_MobileMessaging extends Plugin
{
$cssFiles[] = "plugins/MobileMessaging/stylesheets/MobileMessagingSettings.less";
}
-
+
public function validateReportParameters(&$parameters, $info)
{
if (self::manageEvent($info)) {
// phone number validation
- $availablePhoneNumbers = Piwik_MobileMessaging_API::getInstance()->getActivatedPhoneNumbers();
+ $availablePhoneNumbers = MobileMessagingAPI::getInstance()->getActivatedPhoneNumbers();
$phoneNumbers = $parameters[self::PHONE_NUMBERS_PARAMETER];
foreach ($phoneNumbers as $key => $phoneNumber) {
@@ -121,10 +127,10 @@ class Piwik_MobileMessaging extends Plugin
public function getReportMetadata(&$availableReportMetadata, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $idSite = $notificationInfo[Piwik_PDFReports_API::ID_SITE_INFO_KEY];
+ $idSite = $notificationInfo[PDFReportsAPI::ID_SITE_INFO_KEY];
foreach (self::$availableReports as $availableReport) {
- $reportMetadata = Piwik_API_API::getInstance()->getMetadata(
+ $reportMetadata = API::getInstance()->getMetadata(
$idSite,
$availableReport['module'],
$availableReport['action']
@@ -161,9 +167,9 @@ class Piwik_MobileMessaging extends Plugin
{
if (self::manageEvent($info)) {
if (\Piwik\PluginsManager::getInstance()->isPluginActivated('MultiSites')) {
- $reportRenderer = new Piwik_MobileMessaging_ReportRenderer_Sms();
+ $reportRenderer = new Sms();
} else {
- $reportRenderer = new Piwik_MobileMessaging_ReportRenderer_Exception(
+ $reportRenderer = new ReportRendererException(
Piwik_Translate('MobileMessaging_MultiSites_Must_Be_Activated')
);
}
@@ -180,7 +186,7 @@ class Piwik_MobileMessaging extends Plugin
public function getReportRecipients(&$recipients, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $report = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY];
+ $report = $notificationInfo[PDFReportsAPI::REPORT_KEY];
$recipients = $report['parameters'][self::PHONE_NUMBERS_PARAMETER];
}
}
@@ -188,9 +194,9 @@ class Piwik_MobileMessaging extends Plugin
public function sendReport($notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $report = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY];
- $contents = $notificationInfo[Piwik_PDFReports_API::REPORT_CONTENT_KEY];
- $reportSubject = $notificationInfo[Piwik_PDFReports_API::REPORT_SUBJECT_KEY];
+ $report = $notificationInfo[PDFReportsAPI::REPORT_KEY];
+ $contents = $notificationInfo[PDFReportsAPI::REPORT_CONTENT_KEY];
+ $reportSubject = $notificationInfo[PDFReportsAPI::REPORT_SUBJECT_KEY];
$parameters = $report['parameters'];
$phoneNumbers = $parameters[self::PHONE_NUMBERS_PARAMETER];
@@ -200,7 +206,7 @@ class Piwik_MobileMessaging extends Plugin
$reportSubject = Piwik_Translate('General_Reports');
}
- $mobileMessagingAPI = Piwik_MobileMessaging_API::getInstance();
+ $mobileMessagingAPI = MobileMessagingAPI::getInstance();
foreach ($phoneNumbers as $phoneNumber) {
$mobileMessagingAPI->sendSMS(
$contents,
@@ -219,13 +225,13 @@ class Piwik_MobileMessaging extends Plugin
$view = new View('@MobileMessaging/reportParametersPDFReports');
$view->reportType = self::MOBILE_TYPE;
- $view->phoneNumbers = Piwik_MobileMessaging_API::getInstance()->getActivatedPhoneNumbers();
+ $view->phoneNumbers = MobileMessagingAPI::getInstance()->getActivatedPhoneNumbers();
$out .= $view->render();
}
private static function manageEvent($notificationInfo)
{
- return in_array($notificationInfo[Piwik_PDFReports_API::REPORT_TYPE_INFO_KEY], array_keys(self::$managedReportTypes));
+ return in_array($notificationInfo[PDFReportsAPI::REPORT_TYPE_INFO_KEY], array_keys(self::$managedReportTypes));
}
function install()
@@ -239,11 +245,11 @@ class Piwik_MobileMessaging extends Plugin
function deactivate()
{
// delete all mobile reports
- $pdfReportsAPIInstance = Piwik_PDFReports_API::getInstance();
+ $pdfReportsAPIInstance = PDFReportsAPI::getInstance();
$reports = $pdfReportsAPIInstance->getReports();
foreach ($reports as $report) {
- if ($report['type'] == Piwik_MobileMessaging::MOBILE_TYPE) {
+ if ($report['type'] == MobileMessaging::MOBILE_TYPE) {
$pdfReportsAPIInstance->deleteReport($report['idreport']);
}
}
diff --git a/plugins/MobileMessaging/ReportRenderer/Exception.php b/plugins/MobileMessaging/ReportRenderer/ReportRendererException.php
index cc5b137a38..338dce98f6 100644
--- a/plugins/MobileMessaging/ReportRenderer/Exception.php
+++ b/plugins/MobileMessaging/ReportRenderer/ReportRendererException.php
@@ -8,13 +8,16 @@
* @category Piwik_Plugins
* @package Piwik_MobileMessaging_ReportRenderer
*/
+namespace Piwik\Plugins\MobileMessaging\ReportRenderer;
+
use Piwik\ReportRenderer;
+use Piwik\Plugins\MobileMessaging\ReportRenderer\Sms;
/**
*
* @package Piwik_MobileMessaging_ReportRenderer
*/
-class Piwik_MobileMessaging_ReportRenderer_Exception extends ReportRenderer
+class ReportRendererException extends ReportRenderer
{
private $rendering = "";
@@ -32,7 +35,7 @@ class Piwik_MobileMessaging_ReportRenderer_Exception extends ReportRenderer
{
return ReportRenderer::writeFile(
$filename,
- Piwik_MobileMessaging_ReportRenderer_Sms::SMS_FILE_EXTENSION,
+ Sms::SMS_FILE_EXTENSION,
$this->rendering
);
}
@@ -41,8 +44,8 @@ class Piwik_MobileMessaging_ReportRenderer_Exception extends ReportRenderer
{
ReportRenderer::sendToBrowser(
$filename,
- Piwik_MobileMessaging_ReportRenderer_Sms::SMS_FILE_EXTENSION,
- Piwik_MobileMessaging_ReportRenderer_Sms::SMS_CONTENT_TYPE,
+ Sms::SMS_FILE_EXTENSION,
+ Sms::SMS_CONTENT_TYPE,
$this->rendering
);
}
@@ -50,7 +53,7 @@ class Piwik_MobileMessaging_ReportRenderer_Exception extends ReportRenderer
public function sendToBrowserInline($filename)
{
ReportRenderer::inlineToBrowser(
- Piwik_MobileMessaging_ReportRenderer_Sms::SMS_CONTENT_TYPE,
+ Sms::SMS_CONTENT_TYPE,
$this->rendering
);
}
diff --git a/plugins/MobileMessaging/ReportRenderer/Sms.php b/plugins/MobileMessaging/ReportRenderer/Sms.php
index 5c89166ea2..6d7abbf71c 100644
--- a/plugins/MobileMessaging/ReportRenderer/Sms.php
+++ b/plugins/MobileMessaging/ReportRenderer/Sms.php
@@ -8,7 +8,10 @@
* @category Piwik_Plugins
* @package Piwik_MobileMessaging_ReportRenderer
*/
+namespace Piwik\Plugins\MobileMessaging\ReportRenderer;
+
use Piwik\Common;
+use Piwik\Plugins\MultiSites\API;
use Piwik\View;
use Piwik\ReportRenderer;
use Piwik\Site;
@@ -17,7 +20,7 @@ use Piwik\Site;
*
* @package Piwik_MobileMessaging_ReportRenderer
*/
-class Piwik_MobileMessaging_ReportRenderer_Sms extends ReportRenderer
+class Sms extends ReportRenderer
{
const FLOAT_REGEXP = '/[-+]?[0-9]*[\.,]?[0-9]+/';
const SMS_CONTENT_TYPE = 'text/plain';
@@ -62,9 +65,9 @@ class Piwik_MobileMessaging_ReportRenderer_Sms extends ReportRenderer
$reportData = $processedReport['reportData'];
$evolutionMetrics = array();
- $multiSitesAPIMetrics = Piwik_MultiSites_API::getApiMetrics($enhanced = true);
+ $multiSitesAPIMetrics = API::getApiMetrics($enhanced = true);
foreach ($multiSitesAPIMetrics as $metricSettings) {
- $evolutionMetrics[] = $metricSettings[Piwik_MultiSites_API::METRIC_EVOLUTION_COL_NAME_KEY];
+ $evolutionMetrics[] = $metricSettings[API::METRIC_EVOLUTION_COL_NAME_KEY];
}
// no decimal for all metrics to shorten SMS content (keeps the monetary sign for revenue metrics)
diff --git a/plugins/MobileMessaging/SMSProvider.php b/plugins/MobileMessaging/SMSProvider.php
index 402c135b48..7a9c36bb77 100644
--- a/plugins/MobileMessaging/SMSProvider.php
+++ b/plugins/MobileMessaging/SMSProvider.php
@@ -6,17 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging
+ * @package MobileMessaging
*/
+namespace Piwik\Plugins\MobileMessaging;
+
+use Exception;
use Piwik\Loader;
+use Piwik\Plugins\MobileMessaging\GSMCharset;
/**
- * The Piwik_MobileMessaging_SMSProvider abstract class is used as a base class for SMS provider implementations.
+ * The SMSProvider abstract class is used as a base class for SMS provider implementations.
*
- * @package Piwik_MobileMessaging
- * @subpackage Piwik_MobileMessaging_SMSProvider
+ * @package MobileMessaging
+ * @subpackage SMSProvider
*/
-abstract class Piwik_MobileMessaging_SMSProvider
+abstract class SMSProvider
{
const MAX_GSM_CHARS_IN_ONE_UNIQUE_SMS = 160;
const MAX_GSM_CHARS_IN_ONE_CONCATENATED_SMS = 153;
@@ -26,11 +30,11 @@ abstract class Piwik_MobileMessaging_SMSProvider
static public $availableSMSProviders = array(
'Clockwork' => 'You can use <a target="_blank" href="?module=Proxy&action=redirect&url=http://www.clockworksms.com/platforms/piwik/"><img src="plugins/MobileMessaging/images/Clockwork.png"/></a> to send SMS Reports from Piwik.<br/>
<ul>
- <li> First, <a target="_blank" href="?module=Proxy&action=redirect&url=http://www.clockworksms.com/platforms/piwik/">get an API Key from Clockwork</a> (Signup is free!)
+ <li> First, <a target="_blank" href="?module=Proxy&action=redirect&url=http://www.clockworksms.com/platforms/piwik/">get an API Key from Clockwork</a> (Signup is free!)
</li><li> Enter your Clockwork API Key on this page. </li>
</ul>
<br/><i>About Clockwork: </i><ul>
- <li>Clockwork gives you fast, reliable high quality worldwide SMS delivery, over 450 networks in every corner of the globe.
+ <li>Clockwork gives you fast, reliable high quality worldwide SMS delivery, over 450 networks in every corner of the globe.
</li><li>Cost per SMS message is around ~0.08USD (0.06EUR).
</li><li>Most countries and networks are supported but we suggest you check the latest position on their coverage map <a target="_blank" href="?module=Proxy&action=redirect&url=http://www.clockworksms.com/sms-coverage/">here</a>.
</li>
@@ -41,13 +45,13 @@ abstract class Piwik_MobileMessaging_SMSProvider
/**
* Return the SMSProvider associated to the provider name $providerName
*
- * @throws exception If the provider is unknown
+ * @throws Exception If the provider is unknown
* @param string $providerName
- * @return Piwik_MobileMessaging_SMSProvider
+ * @return \Piwik\Plugins\MobileMessaging\SMSProvider
*/
static public function factory($providerName)
{
- $className = 'Piwik_MobileMessaging_SMSProvider_' . $providerName;
+ $className = __NAMESPACE__ . '\\SMSProvider\\' . $providerName;
try {
Loader::loadClass($className);
@@ -70,7 +74,7 @@ abstract class Piwik_MobileMessaging_SMSProvider
*/
static public function containsUCS2Characters($string)
{
- $GSMCharsetAsString = implode(array_keys(Piwik_MobileMessaging_GSMCharset::$GSMCharset));
+ $GSMCharsetAsString = implode(array_keys(GSMCharset::$GSMCharset));
foreach (self::mb_str_split($string) as $char) {
if (mb_strpos($GSMCharsetAsString, $char) === false) {
@@ -128,7 +132,7 @@ abstract class Piwik_MobileMessaging_SMSProvider
$sizeOfSMSContent = 0;
foreach (self::mb_str_split($smsContent) as $char) {
- $sizeOfSMSContent += Piwik_MobileMessaging_GSMCharset::$GSMCharset[$char];
+ $sizeOfSMSContent += GSMCharset::$GSMCharset[$char];
}
return $sizeOfSMSContent;
}
diff --git a/plugins/MobileMessaging/SMSProvider/Clockwork.php b/plugins/MobileMessaging/SMSProvider/Clockwork.php
index 29a153c6da..da0b07ba1e 100644
--- a/plugins/MobileMessaging/SMSProvider/Clockwork.php
+++ b/plugins/MobileMessaging/SMSProvider/Clockwork.php
@@ -6,17 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging_SMSProvider
+ * @package SMSProvider
*/
+namespace Piwik\Plugins\MobileMessaging\SMSProvider;
+
+use Exception;
use Piwik\Http;
+use Piwik\Plugins\MobileMessaging\APIException;
+use Piwik\Plugins\MobileMessaging\SMSProvider;
require_once PIWIK_INCLUDE_PATH . "/plugins/MobileMessaging/APIException.php";
/**
*
- * @package Piwik_MobileMessaging_SMSProvider
+ * @package SMSProvider
*/
-class Piwik_MobileMessaging_SMSProvider_Clockwork extends Piwik_MobileMessaging_SMSProvider
+class Clockwork extends SMSProvider
{
const SOCKET_TIMEOUT = 15;
@@ -83,12 +88,12 @@ class Piwik_MobileMessaging_SMSProvider_Clockwork extends Piwik_MobileMessaging_
$acceptLanguage = false,
$acceptInvalidSslCertificate = true
);
- } catch(Exception $e) {
+ } catch (Exception $e) {
$result = self::ERROR_STRING . " " . $e->getMessage();
}
if (strpos($result, self::ERROR_STRING) !== false) {
- throw new Piwik_MobileMessaging_APIException(
+ throw new APIException(
'Clockwork API returned the following error message : ' . $result
);
}
diff --git a/plugins/MobileMessaging/SMSProvider/StubbedProvider.php b/plugins/MobileMessaging/SMSProvider/StubbedProvider.php
index 8402eefc51..33a4339f8b 100644
--- a/plugins/MobileMessaging/SMSProvider/StubbedProvider.php
+++ b/plugins/MobileMessaging/SMSProvider/StubbedProvider.php
@@ -6,15 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MobileMessaging_SMSProvider
+ * @package SMSProvider
*/
+namespace Piwik\Plugins\MobileMessaging\SMSProvider;
+
+use Piwik\Plugins\MobileMessaging\SMSProvider;
/**
* Used for testing
*
- * @package Piwik_MobileMessaging_SMSProvider
+ * @package SMSProvider
*/
-class Piwik_MobileMessaging_SMSProvider_StubbedProvider extends Piwik_MobileMessaging_SMSProvider
+class StubbedProvider extends SMSProvider
{
public function verifyCredential($apiKey)
diff --git a/plugins/MultiSites/API.php b/plugins/MultiSites/API.php
index dbaf64e0a4..6b2381c0d5 100755
--- a/plugins/MultiSites/API.php
+++ b/plugins/MultiSites/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MultiSites
+ * @package MultiSites
*/
+namespace Piwik\Plugins\MultiSites;
+
+use Exception;
use Piwik\API\Request;
use Piwik\Archive;
use Piwik\DataTable\Filter\CalculateEvolutionFilter;
@@ -15,13 +18,15 @@ use Piwik\Period\Range;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\DataTable;
+use Piwik\Plugins\Goals\Archiver;
use Piwik\TaskScheduler;
use Piwik\Site;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
* The MultiSites API lets you request the key metrics (visits, page views, revenue) for all Websites in Piwik.
*/
-class Piwik_MultiSites_API
+class API
{
const METRIC_TRANSLATION_KEY = 'translation';
const METRIC_EVOLUTION_COL_NAME_KEY = 'evolution_column_name';
@@ -67,7 +72,7 @@ class Piwik_MultiSites_API
* Returns the singleton instance of this class. The instance is created
* if it hasn't been already.
*
- * @return Piwik_MultiSites_API
+ * @return \Piwik\Plugins\MultiSites\API
*/
static public function getInstance()
{
@@ -107,7 +112,7 @@ class Piwik_MultiSites_API
$idSites = $this->getSitesIdFromPattern($pattern);
- if(empty($idSites)) {
+ if (empty($idSites)) {
return new DataTable();
}
return $this->buildDataTable(
@@ -130,7 +135,7 @@ class Piwik_MultiSites_API
private function getSitesIdFromPattern($pattern)
{
$idSites = 'all';
- if(empty($pattern)) {
+ if (empty($pattern)) {
return $idSites;
}
$idSites = array();
@@ -185,11 +190,11 @@ class Piwik_MultiSites_API
&& !TaskScheduler::isTaskBeingExecuted()
) {
Site::setSites(
- Piwik_SitesManager_API::getInstance()->getAllSites()
+ SitesManagerAPI::getInstance()->getAllSites()
);
} else {
Site::setSitesFromArray(
- Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess($limit = false, $_restrictSitesToLogin)
+ SitesManagerAPI::getInstance()->getSitesWithAtLeastViewAccess($limit = false, $_restrictSitesToLogin)
);
}
}
@@ -207,7 +212,7 @@ class Piwik_MultiSites_API
$fieldsToGet = array();
$columnNameRewrites = array();
$apiECommerceMetrics = array();
- $apiMetrics = Piwik_MultiSites_API::getApiMetrics($enhanced);
+ $apiMetrics = API::getApiMetrics($enhanced);
foreach ($apiMetrics as $metricName => $metricSettings) {
$fieldsToGet[] = $metricSettings[self::METRIC_RECORD_NAME_KEY];
$columnNameRewrites[$metricSettings[self::METRIC_RECORD_NAME_KEY]] = $metricName;
@@ -231,7 +236,7 @@ class Piwik_MultiSites_API
&& $dataTable->getRowsCount() > 0
) {
$firstSite = is_array($sites) ? reset($sites) : $sites;
-
+
$firstDataTableRow = $dataTable->getFirstRow();
$firstDataTableRow->setColumn('label', $firstSite);
}
@@ -252,7 +257,7 @@ class Piwik_MultiSites_API
}
$pastArchive = Archive::build($sites, $period, $strLastDate, $segment, $_restrictSitesToLogin);
$pastData = $pastArchive->getDataTableFromNumeric($fieldsToGet);
-
+
if ($pastData instanceof DataTable\Map
&& $multipleWebsitesRequested
) {
@@ -302,8 +307,9 @@ class Piwik_MultiSites_API
// note: if only one website is queried and there are no visits, we can not remove the row otherwise
// ResponseBuilder throws 'Call to a member function getColumns() on a non-object'
if ($multipleWebsitesRequested
- // We don't delete the 0 visits row, if "Enhanced" mode is on.
- && !$enhanced) {
+ // We don't delete the 0 visits row, if "Enhanced" mode is on.
+ && !$enhanced
+ ) {
$dataTable->filter(
'ColumnCallbackDeleteRow',
array(
@@ -329,10 +335,10 @@ class Piwik_MultiSites_API
private function calculateEvolutionPercentages($currentData, $pastData, $apiMetrics)
{
if (get_class($currentData) != get_class($pastData)) { // sanity check for regressions
- throw new Exception("Expected \$pastData to be of type ".get_class($currentData)." - got "
- . get_class($pastData).".");
+ throw new Exception("Expected \$pastData to be of type " . get_class($currentData) . " - got "
+ . get_class($pastData) . ".");
}
-
+
if ($currentData instanceof DataTable\Map) {
$pastArray = $pastData->getArray();
foreach ($currentData->getArray() as $subTable) {
@@ -370,7 +376,7 @@ class Piwik_MultiSites_API
} else {
$revenueMetric = '';
if (Common::isGoalPluginEnabled()) {
- $revenueMetric = Piwik_Goals_Archiver::getRecordName(self::GOAL_REVENUE_METRIC);
+ $revenueMetric = Archiver::getRecordName(self::GOAL_REVENUE_METRIC);
}
$totals = array();
@@ -442,7 +448,7 @@ class Piwik_MultiSites_API
$metrics[self::GOAL_REVENUE_METRIC] = array(
self::METRIC_TRANSLATION_KEY => 'Goals_ColumnRevenue',
self::METRIC_EVOLUTION_COL_NAME_KEY => self::GOAL_REVENUE_METRIC . '_evolution',
- self::METRIC_RECORD_NAME_KEY => Piwik_Goals_Archiver::getRecordName(self::GOAL_REVENUE_METRIC),
+ self::METRIC_RECORD_NAME_KEY => Archiver::getRecordName(self::GOAL_REVENUE_METRIC),
self::METRIC_IS_ECOMMERCE_KEY => false,
);
@@ -451,7 +457,7 @@ class Piwik_MultiSites_API
$metrics[self::GOAL_CONVERSION_METRIC] = array(
self::METRIC_TRANSLATION_KEY => 'Goals_ColumnConversions',
self::METRIC_EVOLUTION_COL_NAME_KEY => self::GOAL_CONVERSION_METRIC . '_evolution',
- self::METRIC_RECORD_NAME_KEY => Piwik_Goals_Archiver::getRecordName(self::GOAL_CONVERSION_METRIC),
+ self::METRIC_RECORD_NAME_KEY => Archiver::getRecordName(self::GOAL_CONVERSION_METRIC),
self::METRIC_IS_ECOMMERCE_KEY => false,
);
@@ -459,7 +465,7 @@ class Piwik_MultiSites_API
$metrics[self::ECOMMERCE_ORDERS_METRIC] = array(
self::METRIC_TRANSLATION_KEY => 'General_EcommerceOrders',
self::METRIC_EVOLUTION_COL_NAME_KEY => self::ECOMMERCE_ORDERS_METRIC . '_evolution',
- self::METRIC_RECORD_NAME_KEY => Piwik_Goals_Archiver::getRecordName(self::GOAL_CONVERSION_METRIC, 0),
+ self::METRIC_RECORD_NAME_KEY => Archiver::getRecordName(self::GOAL_CONVERSION_METRIC, 0),
self::METRIC_IS_ECOMMERCE_KEY => true,
);
@@ -467,7 +473,7 @@ class Piwik_MultiSites_API
$metrics[self::ECOMMERCE_REVENUE_METRIC] = array(
self::METRIC_TRANSLATION_KEY => 'General_ProductRevenue',
self::METRIC_EVOLUTION_COL_NAME_KEY => self::ECOMMERCE_REVENUE_METRIC . '_evolution',
- self::METRIC_RECORD_NAME_KEY => Piwik_Goals_Archiver::getRecordName(self::GOAL_REVENUE_METRIC, 0),
+ self::METRIC_RECORD_NAME_KEY => Archiver::getRecordName(self::GOAL_REVENUE_METRIC, 0),
self::METRIC_IS_ECOMMERCE_KEY => true,
);
}
diff --git a/plugins/MultiSites/Controller.php b/plugins/MultiSites/Controller.php
index b57f90b020..56ed2351d4 100644
--- a/plugins/MultiSites/Controller.php
+++ b/plugins/MultiSites/Controller.php
@@ -6,22 +6,25 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MultiSites
+ * @package MultiSites
*/
+namespace Piwik\Plugins\MultiSites;
+
use Piwik\Period;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Config;
use Piwik\Date;
-use Piwik\Controller;
+use Piwik\Plugins\MultiSites\API as MultiSitesAPI;
use Piwik\View;
use Piwik\Site;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
*
- * @package Piwik_MultiSites
+ * @package MultiSites
*/
-class Piwik_MultiSites_Controller extends Controller
+class Controller extends \Piwik\Controller
{
protected $orderBy = 'visits';
protected $order = 'desc';
@@ -48,7 +51,6 @@ class Piwik_MultiSites_Controller extends Controller
$this->getSitesInfo($isWidgetized = true);
}
-
public function getSitesInfo($isWidgetized = false)
{
Piwik::checkUserHasSomeViewAccess();
@@ -56,20 +58,19 @@ class Piwik_MultiSites_Controller extends Controller
$date = Common::getRequestVar('date', 'today');
$period = Common::getRequestVar('period', 'day');
- $siteIds = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
+ $siteIds = SitesManagerAPI::getInstance()->getSitesIdWithAtLeastViewAccess();
list($minDate, $maxDate) = $this->getMinMaxDateAcrossWebsites($siteIds);
// overwrites the default Date set in the parent controller
// Instead of the default current website's local date,
// we set "today" or "yesterday" based on the default Piwik timezone
- $piwikDefaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
+ $piwikDefaultTimezone = SitesManagerAPI::getInstance()->getDefaultTimezone();
if ($period != 'range') {
$date = $this->getDateParameterInTimezone($date, $piwikDefaultTimezone);
$this->setDate($date);
$date = $date->toString();
}
- $dataTable = Piwik_MultiSites_API::getInstance()->getAll($period, $date, $segment = false);
-
+ $dataTable = MultiSitesAPI::getInstance()->getAll($period, $date, $segment = false);
// put data into a form the template will understand better
$digestableData = array();
diff --git a/plugins/MultiSites/MultiSites.php b/plugins/MultiSites/MultiSites.php
index 96f14fabce..fab4cd498e 100644
--- a/plugins/MultiSites/MultiSites.php
+++ b/plugins/MultiSites/MultiSites.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_MultiSites
+ * @package MultiSites
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\MultiSites;
+
+use Piwik\Plugins\MultiSites\API;
/**
*
- * @package Piwik_MultiSites
+ * @package MultiSites
*/
-class Piwik_MultiSites extends Plugin
+class MultiSites extends \Piwik\Plugin
{
public function getInformation()
{
@@ -40,11 +42,11 @@ class Piwik_MultiSites extends Plugin
public function getReportMetadata(&$reports)
{
$metadataMetrics = array();
- foreach (Piwik_MultiSites_API::getApiMetrics($enhanced = true) as $metricName => $metricSettings) {
+ foreach (API::getApiMetrics($enhanced = true) as $metricName => $metricSettings) {
$metadataMetrics[$metricName] =
- Piwik_Translate($metricSettings[Piwik_MultiSites_API::METRIC_TRANSLATION_KEY]);
- $metadataMetrics[$metricSettings[Piwik_MultiSites_API::METRIC_EVOLUTION_COL_NAME_KEY]] =
- Piwik_Translate($metricSettings[Piwik_MultiSites_API::METRIC_TRANSLATION_KEY]) . " " . Piwik_Translate('MultiSites_Evolution');
+ Piwik_Translate($metricSettings[API::METRIC_TRANSLATION_KEY]);
+ $metadataMetrics[$metricSettings[API::METRIC_EVOLUTION_COL_NAME_KEY]] =
+ Piwik_Translate($metricSettings[API::METRIC_TRANSLATION_KEY]) . " " . Piwik_Translate('MultiSites_Evolution');
}
$reports[] = array(
diff --git a/plugins/Overlay/API.php b/plugins/Overlay/API.php
index 35e7c681e4..d065b92369 100644
--- a/plugins/Overlay/API.php
+++ b/plugins/Overlay/API.php
@@ -1,10 +1,4 @@
<?php
-use Piwik\Config;
-use Piwik\Piwik;
-use Piwik\Access;
-use Piwik\DataTable;
-use Piwik\Tracker\Action;
-
/**
* Piwik - Open source web analytics
*
@@ -12,17 +6,29 @@ use Piwik\Tracker\Action;
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Overlay
+ * @package Overlay
*/
+namespace Piwik\Plugins\Overlay;
+
+use Exception;
+use Piwik\Config;
+use Piwik\Piwik;
+use Piwik\Access;
+use Piwik\DataTable;
+use Piwik\Tracker\Action;
+use Piwik\Plugins\SitesManager\SitesManager;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
+use Piwik\Plugins\Transitions\API as TransitionsAPI;
+
-class Piwik_Overlay_API
+class API
{
private static $instance = null;
/**
* Get Singleton instance
- * @return Piwik_Overlay_API
+ * @return \Piwik\Plugins\Overlay\API
*/
public static function getInstance()
{
@@ -57,11 +63,11 @@ class Piwik_Overlay_API
{
$this->authenticate($idSite);
- $sitesManager = Piwik_SitesManager_API::getInstance();
+ $sitesManager = SitesManagerAPI::getInstance();
$site = $sitesManager->getSiteFromId($idSite);
try {
- return Piwik_SitesManager::getTrackerExcludedQueryParameters($site);
+ return SitesManager::getTrackerExcludedQueryParameters($site);
} catch (Exception $e) {
// an exception is thrown when the user has no view access.
// do not throw the exception to the outside.
@@ -87,7 +93,7 @@ class Piwik_Overlay_API
try {
$limitBeforeGrouping = Config::getInstance()->General['overlay_following_pages_limit'];
- $transitionsReport = Piwik_Transitions_API::getInstance()->getTransitionsForAction(
+ $transitionsReport = TransitionsAPI::getInstance()->getTransitionsForAction(
$url, $type = 'url', $idSite, $period, $date, $segment, $limitBeforeGrouping,
$part = 'followingActions', $returnNormalizedUrls = true);
} catch (Exception $e) {
@@ -124,5 +130,4 @@ class Piwik_Overlay_API
Piwik::checkUserHasViewAccess($idSite);
}
-
}
diff --git a/plugins/Overlay/Controller.php b/plugins/Overlay/Controller.php
index 2efcfd7057..3721c9b226 100644
--- a/plugins/Overlay/Controller.php
+++ b/plugins/Overlay/Controller.php
@@ -1,13 +1,4 @@
<?php
-use Piwik\API\Request;
-use Piwik\Metrics;
-use Piwik\Piwik;
-use Piwik\Config;
-use Piwik\Common;
-use Piwik\Controller;
-use Piwik\Tracker\Action;
-use Piwik\View;
-
/**
* Piwik - Open source web analytics
*
@@ -15,10 +6,21 @@ use Piwik\View;
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Overlay
+ * @package Overlay
*/
+namespace Piwik\Plugins\Overlay;
-class Piwik_Overlay_Controller extends Controller
+use Piwik\API\Request;
+use Piwik\Metrics;
+use Piwik\Piwik;
+use Piwik\Config;
+use Piwik\Common;
+use Piwik\Plugins\Actions\ArchivingHelper;
+use Piwik\Tracker\Action;
+use Piwik\View;
+use Piwik\Plugins\SitesManager\API;
+
+class Controller extends \Piwik\Controller
{
/** The index of the plugin */
@@ -57,8 +59,8 @@ class Piwik_Overlay_Controller extends Controller
$normalizedCurrentUrl = Common::unsanitizeInputValue($normalizedCurrentUrl);
// load the appropriate row of the page urls report using the label filter
- Piwik_Actions_ArchivingHelper::reloadConfig();
- $path = Piwik_Actions_ArchivingHelper::getActionExplodedNames($normalizedCurrentUrl, Action::TYPE_ACTION_URL);
+ ArchivingHelper::reloadConfig();
+ $path = ArchivingHelper::getActionExplodedNames($normalizedCurrentUrl, Action::TYPE_ACTION_URL);
$path = array_map('urlencode', $path);
$label = implode('>', $path);
$request = new Request(
@@ -79,7 +81,6 @@ class Piwik_Overlay_Controller extends Controller
$showMetrics = array('nb_hits', 'nb_visits', 'nb_uniq_visitors',
'bounce_rate', 'exit_rate', 'avg_time_on_page');
-
foreach ($showMetrics as $metric) {
$value = $row->getColumn($metric);
if ($value === false) {
@@ -127,7 +128,7 @@ class Piwik_Overlay_Controller extends Controller
$idSite = Common::getRequestVar('idsite', 0, 'int');
Piwik::checkUserHasViewAccess($idSite);
- $sitesManager = Piwik_SitesManager_API::getInstance();
+ $sitesManager = API::getInstance();
$site = $sitesManager->getSiteFromId($idSite);
$urls = $sitesManager->getSiteUrlsFromId($idSite);
@@ -142,17 +143,17 @@ class Piwik_Overlay_Controller extends Controller
return url.replace(/https:\/\//i, "http://");
}
}
-
+
function removeUrlPrefix(url) {
return url.replace(/http(s)?:\/\/(www\.)?/i, "");
}
-
+
if (window.location.hash) {
var match = false;
-
+
var urlToRedirect = window.location.hash.substr(1);
var urlToRedirectWithoutPrefix = removeUrlPrefix(urlToRedirect);
-
+
var knownUrls = ' . Common::json_encode($urls) . ';
for (var i = 0; i < knownUrls.length; i++) {
var testUrl = removeUrlPrefix(knownUrls[i]);
@@ -170,12 +171,12 @@ class Piwik_Overlay_Controller extends Controller
break;
}
}
-
+
if (!match) {
var idSite = window.location.href.match(/idSite=([0-9]+)/i)[1];
window.location.href = "index.php?module=Overlay&action=showErrorWrongDomain"
+ "&idSite=" + idSite
- + "&url=" + encodeURIComponent(urlToRedirect);
+ + "&url=" + encodeURIComponent(urlToRedirect);
}
}
else {
@@ -231,5 +232,4 @@ class Piwik_Overlay_Controller extends Controller
$view = new View('@Overlay/notifyParentIframe');
echo $view->render();
}
-
}
diff --git a/plugins/Overlay/Overlay.php b/plugins/Overlay/Overlay.php
index 72a08d5046..b0ba9a2c7b 100644
--- a/plugins/Overlay/Overlay.php
+++ b/plugins/Overlay/Overlay.php
@@ -6,12 +6,13 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Overlay
+ * @package Overlay
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\Overlay;
-class Piwik_Overlay extends Plugin
+
+class Overlay extends \Piwik\Plugin
{
public function getInformation()
{
diff --git a/plugins/PDFReports/API.php b/plugins/PDFReports/API.php
index 716687866b..708dd64ccb 100644
--- a/plugins/PDFReports/API.php
+++ b/plugins/PDFReports/API.php
@@ -6,16 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
+namespace Piwik\Plugins\PDFReports;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
use Piwik\ReportRenderer;
use Piwik\ReportRenderer\Html;
use Piwik\Site;
use Piwik\Translate;
use Piwik\Db;
+use Piwik\Plugins\SegmentEditor\API as SegmentEditorAPI;
+use Zend_Mime;
/**
* The PDFReports API lets you manage Scheduled Email reports, as well as generate, download or email any existing report.
@@ -27,9 +33,9 @@ use Piwik\Db;
* or manage existing reports with "updateReport" and "deleteReport".
* See also the documentation about <a href='http://piwik.org/docs/email-reports/' target='_blank'>Scheduled Email reports</a> in Piwik.
*
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
-class Piwik_PDFReports_API
+class API
{
const VALIDATE_PARAMETERS_EVENT = 'PDFReports.validateReportParameters';
const GET_REPORT_PARAMETERS_EVENT = 'PDFReports.getReportParameters';
@@ -63,7 +69,7 @@ class Piwik_PDFReports_API
static private $instance = null;
/**
- * @return Piwik_PDFReports_API
+ * @return \Piwik\Plugins\PDFReports\API
*/
static public function getInstance()
{
@@ -133,9 +139,9 @@ class Piwik_PDFReports_API
private static function ensureLanguageSetForUser($currentUser)
{
- $lang = Piwik_LanguagesManager_API::getInstance()->getLanguageForUser($currentUser);
+ $lang = \Piwik\Plugins\LanguagesManager\API::getInstance()->getLanguageForUser($currentUser);
if (empty($lang)) {
- Piwik_LanguagesManager_API::getInstance()->setLanguageForUser($currentUser, Piwik_LanguagesManager::getLanguageCodeForCurrentUser());
+ \Piwik\Plugins\LanguagesManager\API::getInstance()->setLanguageForUser($currentUser, LanguagesManager::getLanguageCodeForCurrentUser());
}
}
@@ -330,7 +336,7 @@ class Piwik_PDFReports_API
);
// available reports
- $availableReportMetadata = Piwik_API_API::getInstance()->getReportMetadata($idSite);
+ $availableReportMetadata = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite);
// we need to lookup which reports metadata are registered in this report
$reportMetadata = array();
@@ -377,7 +383,7 @@ class Piwik_PDFReports_API
}
}
- $processedReport = Piwik_API_API::getInstance()->getProcessedReport(
+ $processedReport = \Piwik\Plugins\API\API::getInstance()->getProcessedReport(
$idSite, $period, $date, $apiModule, $apiAction,
$segment != null ? urlencode($segment['definition']) : false,
$apiParameters, $idGoal = false, $language
@@ -504,7 +510,7 @@ class Piwik_PDFReports_API
$date = Date::now()->subPeriod(1, $report['period'])->toString();
}
- $language = Piwik_LanguagesManager_API::getInstance()->getLanguageForUser($report['login']);
+ $language = \Piwik\Plugins\LanguagesManager\API::getInstance()->getLanguageForUser($report['login']);
// generate report
list($outputFilename, $prettyDate, $reportSubject, $reportTitle, $additionalFiles) =
@@ -528,16 +534,16 @@ class Piwik_PDFReports_API
Piwik_PostEvent(
self::SEND_REPORT_EVENT,
array(
- $notificationInfo = array(
- self::REPORT_TYPE_INFO_KEY => $report['type'],
- self::REPORT_KEY => $report,
- self::REPORT_CONTENT_KEY => $contents,
- self::FILENAME_KEY => $filename,
- self::PRETTY_DATE_KEY => $prettyDate,
- self::REPORT_SUBJECT_KEY => $reportSubject,
- self::REPORT_TITLE_KEY => $reportTitle,
- self::ADDITIONAL_FILES_KEY => $additionalFiles,
- )
+ $notificationInfo = array(
+ self::REPORT_TYPE_INFO_KEY => $report['type'],
+ self::REPORT_KEY => $report,
+ self::REPORT_CONTENT_KEY => $contents,
+ self::FILENAME_KEY => $filename,
+ self::PRETTY_DATE_KEY => $prettyDate,
+ self::REPORT_SUBJECT_KEY => $reportSubject,
+ self::REPORT_TITLE_KEY => $reportTitle,
+ self::ADDITIONAL_FILES_KEY => $additionalFiles,
+ )
)
);
@@ -659,11 +665,9 @@ class Piwik_PDFReports_API
if (empty($idSegment) || (is_numeric($idSegment) && $idSegment == 0)) {
$idSegment = null;
-
} elseif (!is_numeric($idSegment)) {
throw new Exception('Invalid segment identifier. Should be an integer.');
-
} elseif (self::getSegment($idSegment) == null) {
throw new Exception('Segment with id ' . $idSegment . ' does not exist or SegmentEditor is not activated.');
@@ -724,10 +728,10 @@ class Piwik_PDFReports_API
Piwik_PostEvent(
self::ALLOW_MULTIPLE_REPORTS_EVENT,
array(
- &$allowMultipleReports,
- $notificationInfo = array(
- self::REPORT_TYPE_INFO_KEY => $reportType,
- )
+ &$allowMultipleReports,
+ $notificationInfo = array(
+ self::REPORT_TYPE_INFO_KEY => $reportType,
+ )
)
);
return $allowMultipleReports;
@@ -754,10 +758,10 @@ class Piwik_PDFReports_API
Piwik_PostEvent(
self::GET_REPORT_FORMATS_EVENT,
array(
- &$reportFormats,
- $notificationInfo = array(
- self::REPORT_TYPE_INFO_KEY => $reportType
- )
+ &$reportFormats,
+ $notificationInfo = array(
+ self::REPORT_TYPE_INFO_KEY => $reportType
+ )
)
);
@@ -788,7 +792,7 @@ class Piwik_PDFReports_API
{
if (self::isSegmentEditorActivated() && !empty($idSegment)) {
- $segment = Piwik_SegmentEditor_API::getInstance()->get($idSegment);
+ $segment = SegmentEditorAPI::getInstance()->get($idSegment);
if ($segment) {
return $segment;
diff --git a/plugins/PDFReports/Controller.php b/plugins/PDFReports/Controller.php
index 3eed377084..67c3ce70a3 100644
--- a/plugins/PDFReports/Controller.php
+++ b/plugins/PDFReports/Controller.php
@@ -6,45 +6,51 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
+namespace Piwik\Plugins\PDFReports;
+
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
+use Piwik\Plugins\PDFReports\API;
use Piwik\View;
+use Piwik\Plugins\PDFReports\PDFReports;
+use Piwik\Plugins\SegmentEditor\API as SegmentEditorAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
*
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
-class Piwik_PDFReports_Controller extends Controller
+class Controller extends \Piwik\Controller
{
- const DEFAULT_REPORT_TYPE = Piwik_PDFReports::EMAIL_TYPE;
+ const DEFAULT_REPORT_TYPE = PDFReports::EMAIL_TYPE;
public function index()
{
$view = new View('@PDFReports/index');
$this->setGeneralVariablesView($view);
- $view->countWebsites = count(Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess());
+ $view->countWebsites = count(SitesManagerAPI::getInstance()->getSitesIdWithAtLeastViewAccess());
// get report types
- $reportTypes = Piwik_PDFReports_API::getReportTypes();
+ $reportTypes = API::getReportTypes();
$view->reportTypes = $reportTypes;
$view->defaultReportType = self::DEFAULT_REPORT_TYPE;
- $view->defaultReportFormat = Piwik_PDFReports::DEFAULT_REPORT_FORMAT;
+ $view->defaultReportFormat = PDFReports::DEFAULT_REPORT_FORMAT;
$reportsByCategoryByType = array();
$reportFormatsByReportType = array();
$allowMultipleReportsByReportType = array();
foreach ($reportTypes as $reportType => $reportTypeIcon) {
// get report formats
- $reportFormatsByReportType[$reportType] = Piwik_PDFReports_API::getReportFormats($reportType);
- $allowMultipleReportsByReportType[$reportType] = Piwik_PDFReports_API::allowMultipleReports($reportType);
+ $reportFormatsByReportType[$reportType] = API::getReportFormats($reportType);
+ $allowMultipleReportsByReportType[$reportType] = API::allowMultipleReports($reportType);
// get report metadata
$reportsByCategory = array();
- $availableReportMetadata = Piwik_PDFReports_API::getReportMetadata($this->idSite, $reportType);
+ $availableReportMetadata = API::getReportMetadata($this->idSite, $reportType);
foreach ($availableReportMetadata as $reportMetadata) {
$reportsByCategory[$reportMetadata['category']][] = $reportMetadata;
}
@@ -57,28 +63,28 @@ class Piwik_PDFReports_Controller extends Controller
$reports = array();
$reportsById = array();
if (!Piwik::isUserIsAnonymous()) {
- $reports = Piwik_PDFReports_API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true);
+ $reports = API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true);
foreach ($reports as &$report) {
- $report['recipients'] = Piwik_PDFReports_API::getReportRecipients($report);
+ $report['recipients'] = API::getReportRecipients($report);
$reportsById[$report['idreport']] = $report;
}
}
$view->reports = $reports;
$view->reportsJSON = Common::json_encode($reportsById);
- $view->downloadOutputType = Piwik_PDFReports_API::OUTPUT_INLINE;
+ $view->downloadOutputType = API::OUTPUT_INLINE;
- $view->periods = Piwik_PDFReports::getPeriodToFrequency();
- $view->defaultPeriod = Piwik_PDFReports::DEFAULT_PERIOD;
- $view->defaultHour = Piwik_PDFReports::DEFAULT_HOUR;
+ $view->periods = PDFReports::getPeriodToFrequency();
+ $view->defaultPeriod = PDFReports::DEFAULT_PERIOD;
+ $view->defaultHour = PDFReports::DEFAULT_HOUR;
- $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
$view->segmentEditorActivated = false;
- if (Piwik_PDFReports_API::isSegmentEditorActivated()) {
+ if (API::isSegmentEditorActivated()) {
$savedSegmentsById = array();
- foreach (Piwik_SegmentEditor_API::getInstance()->getAll($this->idSite) as $savedSegment) {
+ foreach (SegmentEditorAPI::getInstance()->getAll($this->idSite) as $savedSegment) {
$savedSegmentsById[$savedSegment['idsegment']] = $savedSegment['name'];
}
$view->savedSegmentsById = $savedSegmentsById;
diff --git a/plugins/PDFReports/PDFReports.php b/plugins/PDFReports/PDFReports.php
index 74c5a0110f..edd053cca4 100644
--- a/plugins/PDFReports/PDFReports.php
+++ b/plugins/PDFReports/PDFReports.php
@@ -6,26 +6,34 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
+namespace Piwik\Plugins\PDFReports;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Config;
use Piwik\Date;
use Piwik\Mail;
+use Piwik\Plugins\MobileMessaging\API as MobileMessagingAPI;
+use Piwik\Plugins\MobileMessaging\MobileMessaging;
use Piwik\View;
use Piwik\ScheduledTime;
use Piwik\ScheduledTask;
use Piwik\ReportRenderer;
-use Piwik\Plugin;
use Piwik\Site;
use Piwik\Db;
+use Piwik\Plugins\SegmentEditor\API as SegmentEditorAPI;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
+use Zend_Mime;
+use Zend_Registry;
/**
*
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
-class Piwik_PDFReports extends Plugin
+class PDFReports extends \Piwik\Plugin
{
const MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY = 'MobileMessaging_TopMenu';
const PDF_REPORTS_TOP_MENU_TRANSLATION_KEY = 'PDFReports_EmailReports';
@@ -87,7 +95,7 @@ class Piwik_PDFReports extends Plugin
'template_reportParametersPDFReports' => 'template_reportParametersPDFReports',
'UsersManager.deleteUser' => 'deleteUserReport',
'SitesManager.deleteSite' => 'deleteSiteReport',
- Piwik_SegmentEditor_API::DELETE_SEGMENT_EVENT => 'segmentDeletion',
+ SegmentEditorAPI::DELETE_SEGMENT_EVENT => 'segmentDeletion',
);
}
@@ -96,11 +104,11 @@ class Piwik_PDFReports extends Plugin
*/
public function deleteSiteReport(&$idSite)
{
- $idReports = Piwik_PDFReports_API::getInstance()->getReports($idSite);
+ $idReports = API::getInstance()->getReports($idSite);
foreach ($idReports as $report) {
$idReport = $report['idreport'];
- Piwik_PDFReports_API::getInstance()->deleteReport($idReport);
+ API::getInstance()->deleteReport($idReport);
}
}
@@ -154,9 +162,9 @@ class Piwik_PDFReports extends Plugin
public function getReportMetadata(&$reportMetadata, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $idSite = $notificationInfo[Piwik_PDFReports_API::ID_SITE_INFO_KEY];
+ $idSite = $notificationInfo[API::ID_SITE_INFO_KEY];
- $availableReportMetadata = Piwik_API_API::getInstance()->getReportMetadata($idSite);
+ $availableReportMetadata = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite);
$filteredReportMetadata = array();
foreach ($availableReportMetadata as $reportMetadata) {
@@ -195,7 +203,7 @@ class Piwik_PDFReports extends Plugin
public function processReports(&$processedReports, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $report = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY];
+ $report = $notificationInfo[API::REPORT_KEY];
$displayFormat = $report['parameters'][self::DISPLAY_FORMAT_PARAMETER];
$evolutionGraph = $report['parameters'][self::EVOLUTION_GRAPH_PARAMETER];
@@ -222,8 +230,8 @@ class Piwik_PDFReports extends Plugin
if ($metadata['module'] == 'MultiSites') {
$columns = $processedReport['columns'];
- foreach (Piwik_MultiSites_API::getApiMetrics($enhanced = true) as $metricSettings) {
- unset($columns[$metricSettings[Piwik_MultiSites_API::METRIC_EVOLUTION_COL_NAME_KEY]]);
+ foreach (\Piwik\Plugins\MultiSites\API::getApiMetrics($enhanced = true) as $metricSettings) {
+ unset($columns[$metricSettings[\Piwik\Plugins\MultiSites\API::METRIC_EVOLUTION_COL_NAME_KEY]]);
}
$processedReport['metadata'] = $metadata;
@@ -236,13 +244,13 @@ class Piwik_PDFReports extends Plugin
public function getRendererInstance(&$reportRenderer, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $reportFormat = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY]['format'];
- $outputType = $notificationInfo[Piwik_PDFReports_API::OUTPUT_TYPE_INFO_KEY];
+ $reportFormat = $notificationInfo[API::REPORT_KEY]['format'];
+ $outputType = $notificationInfo[API::OUTPUT_TYPE_INFO_KEY];
$reportRenderer = ReportRenderer::factory($reportFormat);
if ($reportFormat == ReportRenderer::HTML_FORMAT) {
- $reportRenderer->setRenderImageInline($outputType != Piwik_PDFReports_API::OUTPUT_SAVE_ON_DISK);
+ $reportRenderer->setRenderImageInline($outputType != API::OUTPUT_SAVE_ON_DISK);
}
}
}
@@ -257,12 +265,12 @@ class Piwik_PDFReports extends Plugin
public function sendReport($notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $report = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY];
- $reportTitle = $notificationInfo[Piwik_PDFReports_API::REPORT_TITLE_KEY];
- $prettyDate = $notificationInfo[Piwik_PDFReports_API::PRETTY_DATE_KEY];
- $contents = $notificationInfo[Piwik_PDFReports_API::REPORT_CONTENT_KEY];
- $filename = $notificationInfo[Piwik_PDFReports_API::FILENAME_KEY];
- $additionalFiles = $notificationInfo[Piwik_PDFReports_API::ADDITIONAL_FILES_KEY];
+ $report = $notificationInfo[API::REPORT_KEY];
+ $reportTitle = $notificationInfo[API::REPORT_TITLE_KEY];
+ $prettyDate = $notificationInfo[API::PRETTY_DATE_KEY];
+ $contents = $notificationInfo[API::REPORT_CONTENT_KEY];
+ $filename = $notificationInfo[API::FILENAME_KEY];
+ $additionalFiles = $notificationInfo[API::ADDITIONAL_FILES_KEY];
$periods = self::getPeriodToFrequencyAsAdjective();
$message = Piwik_Translate('PDFReports_EmailHello');
@@ -279,8 +287,8 @@ class Piwik_PDFReports extends Plugin
$displaySegmentInfo = false;
$segmentInfo = null;
- $segment = Piwik_PDFReports_API::getSegment($report['idsegment']);
- if($segment != null) {
+ $segment = API::getSegment($report['idsegment']);
+ if ($segment != null) {
$displaySegmentInfo = true;
$segmentInfo = Piwik_Translate('PDFReports_SegmentAppliedToReports', $segment['name']);
}
@@ -292,7 +300,7 @@ class Piwik_PDFReports extends Plugin
$mail->setType(Zend_Mime::MULTIPART_RELATED);
$message .= "<br/>" . Piwik_Translate('PDFReports_PleaseFindBelow', array($periods[$report['period']], $reportTitle));
- if($displaySegmentInfo) {
+ if ($displaySegmentInfo) {
$message .= " " . $segmentInfo;
}
@@ -303,7 +311,7 @@ class Piwik_PDFReports extends Plugin
case 'pdf':
$message .= "\n" . Piwik_Translate('PDFReports_PleaseFindAttachedFile', array($periods[$report['period']], $reportTitle));
- if($displaySegmentInfo) {
+ if ($displaySegmentInfo) {
$message .= " " . $segmentInfo;
}
@@ -347,7 +355,7 @@ class Piwik_PDFReports extends Plugin
$emails[] = Piwik::getSuperUserEmail();
} else {
try {
- $user = Piwik_UsersManager_API::getInstance()->getUser($report['login']);
+ $user = UsersManagerAPI::getInstance()->getUser($report['login']);
} catch (Exception $e) {
return;
}
@@ -380,7 +388,7 @@ class Piwik_PDFReports extends Plugin
public function getReportRecipients(&$recipients, $notificationInfo)
{
if (self::manageEvent($notificationInfo)) {
- $report = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY];
+ $report = $notificationInfo[API::REPORT_KEY];
$parameters = $report['parameters'];
$eMailMe = $parameters[self::EMAIL_ME_PARAMETER];
@@ -411,7 +419,7 @@ class Piwik_PDFReports extends Plugin
private static function manageEvent($info)
{
return in_array(
- $info[Piwik_PDFReports_API::REPORT_TYPE_INFO_KEY],
+ $info[API::REPORT_TYPE_INFO_KEY],
array_keys(self::$managedReportTypes)
);
}
@@ -419,7 +427,7 @@ class Piwik_PDFReports extends Plugin
public function getScheduledTasks(&$tasks)
{
$arbitraryDateInUTC = Date::factory('2011-01-01');
- foreach (Piwik_PDFReports_API::getInstance()->getReports() as $report) {
+ foreach (API::getInstance()->getReports() as $report) {
if (!$report['deleted'] && $report['period'] != ScheduledTime::PERIOD_NEVER) {
$midnightInSiteTimezone =
date(
@@ -435,7 +443,7 @@ class Piwik_PDFReports extends Plugin
$schedule = ScheduledTime::getScheduledTimeForPeriod($report['period']);
$schedule->setHour($hourInUTC);
$tasks[] = new ScheduledTask (
- Piwik_PDFReports_API::getInstance(),
+ API::getInstance(),
'sendReport',
$report['idreport'], $schedule
);
@@ -445,7 +453,7 @@ class Piwik_PDFReports extends Plugin
public function segmentDeletion(&$idSegment)
{
- $reportsUsingSegment = Piwik_PDFReports_API::getInstance()->getReports(false, false, false, true, $idSegment);
+ $reportsUsingSegment = API::getInstance()->getReports(false, false, false, true, $idSegment);
if (count($reportsUsingSegment) > 0) {
@@ -486,19 +494,19 @@ class Piwik_PDFReports extends Plugin
return self::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY;
}
- $reports = Piwik_PDFReports_API::getInstance()->getReports();
+ $reports = API::getInstance()->getReports();
$reportCount = count($reports);
// if there are no reports and the mobile account is
// not configured, display 'Email reports'
// configured, display 'Email & SMS reports'
if ($reportCount == 0)
- return Piwik_MobileMessaging_API::getInstance()->areSMSAPICredentialProvided() ?
+ return MobileMessagingAPI::getInstance()->areSMSAPICredentialProvided() ?
self::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY : self::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY;
$anyMobileReport = false;
foreach ($reports as $report) {
- if ($report['type'] == Piwik_MobileMessaging::MOBILE_TYPE) {
+ if ($report['type'] == MobileMessaging::MOBILE_TYPE) {
$anyMobileReport = true;
break;
}
@@ -600,7 +608,7 @@ class Piwik_PDFReports extends Plugin
ScheduledTime::PERIOD_DAY => Piwik_Translate('General_DailyReport'),
ScheduledTime::PERIOD_WEEK => Piwik_Translate('General_WeeklyReport'),
ScheduledTime::PERIOD_MONTH => Piwik_Translate('General_MonthlyReport'),
- ScheduledTime::PERIOD_YEAR => Piwik_Translate('General_YearlyReport'),
+ ScheduledTime::PERIOD_YEAR => Piwik_Translate('General_YearlyReport'),
ScheduledTime::PERIOD_RANGE => Piwik_Translate('General_RangeReports'),
);
}
diff --git a/plugins/PDFReports/config/tcpdf_config.php b/plugins/PDFReports/config/tcpdf_config.php
index 096171d164..f9b2de9a6f 100644
--- a/plugins/PDFReports/config/tcpdf_config.php
+++ b/plugins/PDFReports/config/tcpdf_config.php
@@ -6,13 +6,13 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
/**
* Override settings in libs/tcpdf_config.php
*
- * @package Piwik_PDFReports
+ * @package PDFReports
*/
define('K_PATH_MAIN', PIWIK_INCLUDE_PATH . '/libs/tcpdf/');
diff --git a/plugins/PleineLune/PleineLune.php b/plugins/PleineLune/PleineLune.php
deleted file mode 100644
index b19ed3e288..0000000000
--- a/plugins/PleineLune/PleineLune.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- * @category Piwik_Plugins
- * @package Piwik_PleineLune
- */
-use Piwik\AssetManager;
-use Piwik\Plugin;
-
-/**
- *
- * @package Piwik_PleineLune
- */
-class Piwik_PleineLune extends Plugin
-{
- public function getListHooksRegistered()
- {
- return array(
- AssetManager::CSS_IMPORT_EVENT => 'getCssFiles',
- );
- }
-
- public function getCssFiles(&$cssFiles)
- {
- $cssFiles[] = "plugins/PleineLune/stylesheets/theme.less";
- }
-}
diff --git a/plugins/PleineLune/plugin.piwik.json b/plugins/PleineLune/plugin.piwik.json
index d0718e1737..b3ab4ac732 100644
--- a/plugins/PleineLune/plugin.piwik.json
+++ b/plugins/PleineLune/plugin.piwik.json
@@ -1,5 +1,6 @@
{
"name": "PleineLune",
"description": "A dark theme for Piwik, ideal to view your analytics reports before sunrise.",
- "theme": true
+ "theme": true,
+ "stylesheet": "stylesheets/theme.less"
} \ No newline at end of file
diff --git a/plugins/PrivacyManager/Controller.php b/plugins/PrivacyManager/Controller.php
index c11fb5d7f0..8bf89fa479 100644
--- a/plugins/PrivacyManager/Controller.php
+++ b/plugins/PrivacyManager/Controller.php
@@ -6,21 +6,27 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
+namespace Piwik\Plugins\PrivacyManager;
+
use Piwik\Config;
-use Piwik\Controller\Admin;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
+use Piwik\Plugins\DBStats\MySQLMetadataProvider;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
use Piwik\View;
use Piwik\TaskScheduler;
+use Piwik\Plugins\PrivacyManager\PrivacyManager;
+use Piwik\Plugins\PrivacyManager\LogDataPurger;
+use Piwik\Plugins\PrivacyManager\ReportsPurger;
/**
*
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
-class Piwik_PrivacyManager_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
const ANONYMIZE_IP_PLUGIN_NAME = "AnonymizeIP";
@@ -42,7 +48,7 @@ class Piwik_PrivacyManager_Controller extends Admin
case("formDeleteSettings"):
$settings = $this->getPurgeSettingsFromRequest();
- Piwik_PrivacyManager::savePurgeDataSettings($settings);
+ PrivacyManager::savePurgeDataSettings($settings);
break;
default: //do nothing
@@ -81,7 +87,7 @@ class Piwik_PrivacyManager_Controller extends Admin
$settings['delete_reports_keep_range_reports'] = Common::getRequestVar("deleteReportsKeepRange", 0);
$settings['delete_reports_keep_segment_reports'] = Common::getRequestVar("deleteReportsKeepSegments", 0);
- $settings['delete_logs_max_rows_per_query'] = Piwik_PrivacyManager::DEFAULT_MAX_ROWS_PER_QUERY;
+ $settings['delete_logs_max_rows_per_query'] = PrivacyManager::DEFAULT_MAX_ROWS_PER_QUERY;
return $settings;
}
@@ -97,7 +103,7 @@ class Piwik_PrivacyManager_Controller extends Admin
$forceEstimate = Common::getRequestVar('forceEstimate', 0);
$view->dbStats = $this->getDeleteDBSizeEstimate($getSettingsFromQuery = true, $forceEstimate);
- $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
echo $view->render();
}
@@ -124,7 +130,7 @@ class Piwik_PrivacyManager_Controller extends Admin
$view->canDeleteLogActions = Piwik::isLockPrivilegeGranted();
$view->dbUser = Config::getInstance()->database['username'];
}
- $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
+ $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
$this->displayWarningIfConfigFileNotWritable($view);
$this->setBasicVariablesView($view);
echo $view->render();
@@ -146,14 +152,14 @@ class Piwik_PrivacyManager_Controller extends Admin
return $this->redirectToIndex('PrivacyManager', 'privacySettings');
}
- $settings = Piwik_PrivacyManager::getPurgeDataSettings();
+ $settings = PrivacyManager::getPurgeDataSettings();
if ($settings['delete_logs_enable']) {
- $logDataPurger = Piwik_PrivacyManager_LogDataPurger::make($settings);
+ $logDataPurger = LogDataPurger::make($settings);
$logDataPurger->purgeData();
}
if ($settings['delete_reports_enable']) {
- $reportsPurger = Piwik_PrivacyManager_ReportsPurger::make(
- $settings, Piwik_PrivacyManager::getAllMetricsToKeep());
+ $reportsPurger = ReportsPurger::make(
+ $settings, PrivacyManager::getAllMetricsToKeep());
$reportsPurger->purgeData(true);
}
}
@@ -164,13 +170,13 @@ class Piwik_PrivacyManager_Controller extends Admin
if ($getSettingsFromQuery) {
$settings = $this->getPurgeSettingsFromRequest();
} else {
- $settings = Piwik_PrivacyManager::getPurgeDataSettings();
+ $settings = PrivacyManager::getPurgeDataSettings();
}
$doDatabaseSizeEstimate = Config::getInstance()->Deletelogs['enable_auto_database_size_estimate'];
// determine the DB size & purged DB size
- $metadataProvider = new Piwik_DBStats_MySQLMetadataProvider();
+ $metadataProvider = new MySQLMetadataProvider();
$tableStatuses = $metadataProvider->getAllTablesStatus();
$totalBytes = 0;
@@ -186,7 +192,7 @@ class Piwik_PrivacyManager_Controller extends Admin
if ($doDatabaseSizeEstimate || $forceEstimate == 1) {
// maps tables whose data will be deleted with number of rows that will be deleted
// if a value is -1, it means the table will be dropped.
- $deletedDataSummary = Piwik_PrivacyManager::getPurgeEstimate($settings);
+ $deletedDataSummary = PrivacyManager::getPurgeEstimate($settings);
$totalAfterPurge = $totalBytes;
foreach ($tableStatuses as $status) {
@@ -195,7 +201,7 @@ class Piwik_PrivacyManager_Controller extends Admin
$tableTotalBytes = $status['Data_length'] + $status['Index_length'];
// if dropping the table
- if ($deletedDataSummary[$tableName] === Piwik_PrivacyManager_ReportsPurger::DROP_TABLE) {
+ if ($deletedDataSummary[$tableName] === ReportsPurger::DROP_TABLE) {
$totalAfterPurge -= $tableTotalBytes;
} else // if just deleting rows
{
@@ -233,11 +239,11 @@ class Piwik_PrivacyManager_Controller extends Admin
Piwik::checkUserIsSuperUser();
$deleteDataInfos = array();
$taskScheduler = new TaskScheduler();
- $deleteDataInfos["config"] = Piwik_PrivacyManager::getPurgeDataSettings();
+ $deleteDataInfos["config"] = PrivacyManager::getPurgeDataSettings();
$deleteDataInfos["deleteTables"] =
- "<br/>" . implode(", ", Piwik_PrivacyManager_LogDataPurger::getDeleteTableLogTables());
+ "<br/>" . implode(", ", LogDataPurger::getDeleteTableLogTables());
- $scheduleTimetable = $taskScheduler->getScheduledTimeForMethod("Piwik_PrivacyManager", "deleteLogTables");
+ $scheduleTimetable = $taskScheduler->getScheduledTimeForMethod("PrivacyManager", "deleteLogTables");
$optionTable = Piwik_GetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS);
@@ -278,7 +284,7 @@ class Piwik_PrivacyManager_Controller extends Admin
protected function handlePluginState($state = 0)
{
- $pluginController = new Piwik_CorePluginsAdmin_Controller();
+ $pluginController = new \Piwik\Plugins\CorePluginsAdmin\Controller();
if ($state == 1 && !\Piwik\PluginsManager::getInstance()->isPluginActivated(self::ANONYMIZE_IP_PLUGIN_NAME)) {
$pluginController->activate($redirectAfter = false);
diff --git a/plugins/PrivacyManager/LogDataPurger.php b/plugins/PrivacyManager/LogDataPurger.php
index d4fa491b43..b08216314f 100755
--- a/plugins/PrivacyManager/LogDataPurger.php
+++ b/plugins/PrivacyManager/LogDataPurger.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
+namespace Piwik\Plugins\PrivacyManager;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
@@ -16,7 +18,7 @@ use Piwik\Db;
/**
* Purges the log_visit, log_conversion and related tables of old visit data.
*/
-class Piwik_PrivacyManager_LogDataPurger
+class LogDataPurger
{
const TEMP_TABLE_NAME = 'tmp_log_actions_to_keep';
@@ -312,11 +314,11 @@ class Piwik_PrivacyManager_LogDataPurger
*
* @param array $settings Array of settings
* @param bool $useRealTable
- * @return Piwik_PrivacyManager_LogDataPurger
+ * @return \Piwik\Plugins\PrivacyManager\LogDataPurger
*/
public static function make($settings, $useRealTable = false)
{
- return new Piwik_PrivacyManager_LogDataPurger(
+ return new LogDataPurger(
$settings['delete_logs_older_than'],
$settings['delete_logs_max_rows_per_query']
);
diff --git a/plugins/PrivacyManager/PrivacyManager.php b/plugins/PrivacyManager/PrivacyManager.php
index 517b410bfe..2208156584 100644
--- a/plugins/PrivacyManager/PrivacyManager.php
+++ b/plugins/PrivacyManager/PrivacyManager.php
@@ -6,18 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
+namespace Piwik\Plugins\PrivacyManager;
+
+use Exception;
use Piwik\Config;
use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
+use Piwik\Plugins\Goals\Archiver;
+use Piwik\Plugins\PrivacyManager\LogDataPurger;
use Piwik\ScheduledTask;
-use Piwik\Plugin;
use Piwik\Db;
use Piwik\ScheduledTime\Daily;
use Piwik\Tracker\GoalManager;
+use Piwik\Plugins\PrivacyManager\ReportsPurger;
/**
* @see plugins/PrivacyManager/LogDataPurger.php
@@ -31,9 +36,9 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/PrivacyManager/ReportsPurger.php';
/**
*
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
-class Piwik_PrivacyManager extends Plugin
+class PrivacyManager extends \Piwik\Plugin
{
const OPTION_LAST_DELETE_PIWIK_LOGS = "lastDelete_piwik_logs";
const OPTION_LAST_DELETE_PIWIK_REPORTS = 'lastDelete_piwik_reports';
@@ -197,7 +202,7 @@ class Piwik_PrivacyManager extends Plugin
// set last run time
Piwik_SetOption(self::OPTION_LAST_DELETE_PIWIK_REPORTS, Date::factory('today')->getTimestamp());
- Piwik_PrivacyManager_ReportsPurger::make($settings, self::getAllMetricsToKeep())->purgeData();
+ ReportsPurger::make($settings, self::getAllMetricsToKeep())->purgeData();
}
/**
@@ -236,7 +241,7 @@ class Piwik_PrivacyManager extends Plugin
Piwik_SetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDeleteDate);
// execute the purge
- Piwik_PrivacyManager_LogDataPurger::make($settings)->purgeData();
+ LogDataPurger::make($settings)->purgeData();
}
/**
@@ -259,12 +264,12 @@ class Piwik_PrivacyManager extends Plugin
$result = array();
if ($settings['delete_logs_enable']) {
- $logDataPurger = Piwik_PrivacyManager_LogDataPurger::make($settings);
+ $logDataPurger = LogDataPurger::make($settings);
$result = array_merge($result, $logDataPurger->getPurgeEstimate());
}
if ($settings['delete_reports_enable']) {
- $reportsPurger = Piwik_PrivacyManager_ReportsPurger::make($settings, self::getAllMetricsToKeep());
+ $reportsPurger = ReportsPurger::make($settings, self::getAllMetricsToKeep());
$result = array_merge($result, $reportsPurger->getPurgeEstimate());
}
@@ -303,7 +308,7 @@ class Piwik_PrivacyManager extends Plugin
$reportsOlderThan = Date::factory('today')->subMonth(1 + $reportsOlderThan);
}
- return Piwik_PrivacyManager_ReportsPurger::shouldReportBePurged(
+ return ReportsPurger::shouldReportBePurged(
$reportDateYear, $reportDateMonth, $reportsOlderThan);
}
@@ -347,12 +352,12 @@ class Piwik_PrivacyManager extends Plugin
foreach ($goalMetricsToKeep as $metric) {
for ($i = 1; $i <= $maxGoalId; ++$i) // maxGoalId can be 0
{
- $metricsToKeep[] = Piwik_Goals_Archiver::getRecordName($metric, $i);
+ $metricsToKeep[] = Archiver::getRecordName($metric, $i);
}
- $metricsToKeep[] = Piwik_Goals_Archiver::getRecordName($metric);
- $metricsToKeep[] = Piwik_Goals_Archiver::getRecordName($metric, GoalManager::IDGOAL_ORDER);
- $metricsToKeep[] = Piwik_Goals_Archiver::getRecordName($metric, GoalManager::IDGOAL_CART);
+ $metricsToKeep[] = Archiver::getRecordName($metric);
+ $metricsToKeep[] = Archiver::getRecordName($metric, GoalManager::IDGOAL_ORDER);
+ $metricsToKeep[] = Archiver::getRecordName($metric, GoalManager::IDGOAL_CART);
}
}
diff --git a/plugins/PrivacyManager/ReportsPurger.php b/plugins/PrivacyManager/ReportsPurger.php
index af527b6142..6b81139830 100755
--- a/plugins/PrivacyManager/ReportsPurger.php
+++ b/plugins/PrivacyManager/ReportsPurger.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_PrivacyManager
+ * @package PrivacyManager
*/
+namespace Piwik\Plugins\PrivacyManager;
+
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Piwik;
use Piwik\Date;
@@ -16,7 +18,7 @@ use Piwik\Db;
/**
* Purges archived reports and metrics that are considered old.
*/
-class Piwik_PrivacyManager_ReportsPurger
+class ReportsPurger
{
// constant used in database purging estimate to signify a table should be dropped
const DROP_TABLE = -1;
@@ -213,7 +215,7 @@ class Piwik_PrivacyManager_ReportsPurger
$oldBlobTables = array();
foreach (Piwik::getTablesInstalled() as $table) {
$type = ArchiveTableCreator::getTypeFromTableName($table);
- if($type === false) {
+ if ($type === false) {
continue;
}
$date = ArchiveTableCreator::getDateFromTableName($table);
@@ -347,7 +349,7 @@ class Piwik_PrivacyManager_ReportsPurger
*/
public static function make($settings, $metricsToKeep)
{
- return new Piwik_PrivacyManager_ReportsPurger(
+ return new ReportsPurger(
$settings['delete_reports_older_than'],
$settings['delete_reports_keep_basic_metrics'] == 1,
self::getReportPeriodsToKeep($settings),
diff --git a/plugins/Provider/API.php b/plugins/Provider/API.php
index 63565b5301..88eb4b473b 100644
--- a/plugins/Provider/API.php
+++ b/plugins/Provider/API.php
@@ -6,11 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Provider
+ * @package Provider
*/
+namespace Piwik\Plugins\Provider;
+
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
+use Piwik\Plugins\Provider\Archiver;
/**
* @see plugins/Provider/functions.php
@@ -20,9 +23,9 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/Provider/functions.php';
/**
* The Provider API lets you access reports for your visitors Internet Providers.
*
- * @package Piwik_Provider
+ * @package Provider
*/
-class Piwik_Provider_API
+class API
{
static private $instance = null;
@@ -38,10 +41,10 @@ class Piwik_Provider_API
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Archive::build($idSite, $period, $date, $segment);
- $dataTable = $archive->getDataTable(Piwik_Provider_Archiver::PROVIDER_RECORD_NAME);
+ $dataTable = $archive->getDataTable(Archiver::PROVIDER_RECORD_NAME);
$dataTable->filter('Sort', array(Metrics::INDEX_NB_VISITS));
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_getHostnameUrl'));
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_Provider_getPrettyProviderName'));
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\getHostnameUrl'));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getPrettyProviderName'));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
diff --git a/plugins/Provider/Archiver.php b/plugins/Provider/Archiver.php
index bd9a4fa456..a449a9f4e8 100644
--- a/plugins/Provider/Archiver.php
+++ b/plugins/Provider/Archiver.php
@@ -6,12 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Provider
+ * @package Provider
*/
+namespace Piwik\Plugins\Provider;
+
use Piwik\Metrics;
use Piwik\PluginsArchiver;
-class Piwik_Provider_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const PROVIDER_RECORD_NAME = 'Provider_hostnameExt';
const PROVIDER_FIELD = "location_provider";
diff --git a/plugins/Provider/Controller.php b/plugins/Provider/Controller.php
index c51d7ccf4a..6d79bd3d1a 100644
--- a/plugins/Provider/Controller.php
+++ b/plugins/Provider/Controller.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Provider
+ * @package Provider
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\Provider;
+
use Piwik\ViewDataTable;
/**
*
- * @package Piwik_Provider
+ * @package Provider
*/
-class Piwik_Provider_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
* Provider
diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php
index f20e823b95..f2562e9485 100644
--- a/plugins/Provider/Provider.php
+++ b/plugins/Provider/Provider.php
@@ -6,21 +6,25 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Provider
+ * @package Provider
*/
+namespace Piwik\Plugins\Provider;
+
+use Exception;
use Piwik\Common;
use Piwik\FrontController;
use Piwik\IP;
-use Piwik\Plugin;
use Piwik\ArchiveProcessor;
use Piwik\Db;
+use Piwik\Plugins\Provider\Archiver;
use Piwik\WidgetsList;
+use Zend_Registry;
/**
*
- * @package Piwik_Provider
+ * @package Provider
*/
-class Piwik_Provider extends Plugin
+class Provider extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -28,13 +32,13 @@ class Piwik_Provider extends Plugin
public function getListHooksRegistered()
{
$hooks = array(
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'Tracker.newVisitorInformation' => 'logProviderInfo',
- 'WidgetsList.add' => 'addWidget',
- 'Menu.add' => 'addMenu',
- 'API.getReportMetadata' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'Tracker.newVisitorInformation' => 'logProviderInfo',
+ 'WidgetsList.add' => 'addWidget',
+ 'Menu.add' => 'addMenu',
+ 'API.getReportMetadata' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
return $hooks;
@@ -78,7 +82,6 @@ class Piwik_Provider extends Plugin
throw $e;
}
}
-
}
public function uninstall()
@@ -101,7 +104,7 @@ class Piwik_Provider extends Plugin
public function postLoad()
{
- Piwik_AddAction('template_footerUserCountry', array('Piwik_Provider', 'footerUserCountry'));
+ Piwik_AddAction('template_footerUserCountry', array('Piwik\Plugins\Provider\Provider', 'footerUserCountry'));
}
/**
@@ -201,16 +204,16 @@ class Piwik_Provider extends Plugin
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_Provider_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_Provider_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
diff --git a/plugins/Provider/functions.php b/plugins/Provider/functions.php
index 540060db4b..51a85e15d1 100644
--- a/plugins/Provider/functions.php
+++ b/plugins/Provider/functions.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Provider
+ * @package Provider
*/
+namespace Piwik\Plugins\Provider;
+
use Piwik\Common;
use Piwik\DataTable;
@@ -17,7 +19,7 @@ use Piwik\DataTable;
* @param string $in
* @return string Host name, IP (if IP address didn't resolve), or Unknown
*/
-function Piwik_getHostnameName($in)
+function getHostnameName($in)
{
if (empty($in)) {
return Piwik_Translate('General_Unknown');
@@ -37,7 +39,7 @@ function Piwik_getHostnameName($in)
* @param string $in hostname
* @return string URL
*/
-function Piwik_getHostnameUrl($in)
+function getHostnameUrl($in)
{
if ($in == DataTable::LABEL_SUMMARY_ROW) {
return false;
@@ -63,9 +65,9 @@ function Piwik_getHostnameUrl($in)
* @param string $in hostname
* @return string Real ISP name, IP (if IP address didn't resolve), or Unknown
*/
-function Piwik_Provider_getPrettyProviderName( $in )
+function getPrettyProviderName( $in )
{
- $providerName = Piwik_getHostnameName($in);
+ $providerName = getHostnameName($in);
$prettyNames = Common::getProviderNames();
diff --git a/plugins/Proxy/Controller.php b/plugins/Proxy/Controller.php
index cf1b362c7b..d358908805 100644
--- a/plugins/Proxy/Controller.php
+++ b/plugins/Proxy/Controller.php
@@ -6,20 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Proxy
+ * @package Proxy
*/
+namespace Piwik\Plugins\Proxy;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\AssetManager;
-use Piwik\Controller;
use Piwik\Url;
/**
* Controller for proxy services
*
- * @package Piwik_Proxy
+ * @package Proxy
*/
-class Piwik_Proxy_Controller extends Controller
+class Controller extends \Piwik\Controller
{
const TRANSPARENT_PNG_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=';
diff --git a/plugins/Proxy/Proxy.php b/plugins/Proxy/Proxy.php
index 47d085a70c..7c7959d0e1 100644
--- a/plugins/Proxy/Proxy.php
+++ b/plugins/Proxy/Proxy.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Proxy
+ * @package Proxy
*/
+namespace Piwik\Plugins\Proxy;
+
use Piwik\Version;
-use Piwik\Plugin;
/**
* Proxy services for the UI
*
- * @package Piwik_Proxy
+ * @package Proxy
*/
-class Piwik_Proxy extends Plugin
+class Proxy extends \Piwik\Plugin
{
/**
* Return information about this plugin.
diff --git a/plugins/Referers/API.php b/plugins/Referers/API.php
index f48d961acd..8e65899d1e 100644
--- a/plugins/Referers/API.php
+++ b/plugins/Referers/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Referers
+ * @package Referers
*/
+namespace Piwik\Plugins\Referers;
+
+use Exception;
use Piwik\API\ResponseBuilder;
use Piwik\Archive;
use Piwik\DataTable\Row;
@@ -16,6 +19,7 @@ use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
use Piwik\DataTable;
+use Piwik\Plugins\Referers\Archiver;
/**
* The Referrers API lets you access reports about Websites, Search engines, Keywords, Campaigns used to access your website.
@@ -25,9 +29,9 @@ use Piwik\DataTable;
*
* The methods "getKeywordsForPageUrl" and "getKeywordsForPageTitle" are used to output the top keywords used to find a page.
* Check out the widget <a href='http://demo.piwik.org/index.php?module=Widgetize&action=iframe&moduleToWidgetize=Referers&actionToWidgetize=getKeywordsForPage&idSite=7&period=day&date=2011-02-15&disableLink=1' target='_blank'>"Top keywords used to find this page"</a> that you can easily re-use on your website.
- * @package Piwik_Referers
+ * @package Referers
*/
-class Piwik_Referers_API
+class API
{
static private $instance = null;
@@ -78,7 +82,7 @@ class Piwik_Referers_API
* @return DataTable
*/
public function getRefererType($idSite, $period, $date, $segment = false, $typeReferer = false,
- $idSubtable = false, $expanded = false)
+ $idSubtable = false, $expanded = false)
{
// if idSubtable is supplied, interpret idSubtable as referrer type and return correct report
if ($idSubtable !== false) {
@@ -103,7 +107,7 @@ class Piwik_Referers_API
}
// get visits by referrer type
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::REFERER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::REFERER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
if ($typeReferer !== false) // filter for a specific referrer type
{
@@ -117,7 +121,7 @@ class Piwik_Referers_API
}
// set referrer type column to readable value
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getRefererTypeLabel'));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getRefererTypeLabel'));
return $dataTable;
}
@@ -144,14 +148,14 @@ class Piwik_Referers_API
public function getKeywords($idSite, $period, $date, $segment = false, $expanded = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::KEYWORDS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
+ $dataTable = $this->getDataTable(Archiver::KEYWORDS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
$dataTable = $this->handleKeywordNotDefined($dataTable);
return $dataTable;
}
protected function handleKeywordNotDefined($dataTable)
{
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', array('Piwik_Referers_API', 'getCleanKeyword')));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\API::getCleanKeyword'));
return $dataTable;
}
@@ -182,7 +186,6 @@ class Piwik_Referers_API
$table = $this->getKeywords($idSite, $period, $date, $segment);
$this->filterOutKeywordNotDefined($table);
return $this->getLabelsFromTable($table);
-
}
public function getKeywordsForPageTitle($idSite, $period, $date, $title)
@@ -227,31 +230,31 @@ class Piwik_Referers_API
public function getSearchEnginesFromKeywordId($idSite, $period, $date, $idSubtable, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::KEYWORDS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_getSearchEngineUrlFromName'));
- $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', 'Piwik_getSearchEngineLogoFromUrl'));
+ $dataTable = $this->getDataTable(Archiver::KEYWORDS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\getSearchEngineUrlFromName'));
+ $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', __NAMESPACE__ . '\getSearchEngineLogoFromUrl'));
// get the keyword and create the URL to the search result page
$keywords = $this->getKeywords($idSite, $period, $date, $segment);
$subTable = $keywords->getRowFromIdSubDataTable($idSubtable);
if ($subTable) {
$keyword = $subTable->getColumn('label');
- $dataTable->queueFilter('MetadataCallbackReplace', array('url', 'Piwik_getSearchEngineUrlFromUrlAndKeyword', array($keyword)));
+ $dataTable->queueFilter('MetadataCallbackReplace', array('url', __NAMESPACE__ . '\getSearchEngineUrlFromUrlAndKeyword', array($keyword)));
}
return $dataTable;
}
public function getSearchEngines($idSite, $period, $date, $segment = false, $expanded = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::SEARCH_ENGINES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_getSearchEngineUrlFromName'));
- $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', 'Piwik_getSearchEngineLogoFromUrl'));
+ $dataTable = $this->getDataTable(Archiver::SEARCH_ENGINES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\getSearchEngineUrlFromName'));
+ $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', __NAMESPACE__ . '\getSearchEngineLogoFromUrl'));
return $dataTable;
}
public function getKeywordsFromSearchEngineId($idSite, $period, $date, $idSubtable, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::SEARCH_ENGINES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
+ $dataTable = $this->getDataTable(Archiver::SEARCH_ENGINES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
// get the search engine and create the URL to the search result page
$searchEngines = $this->getSearchEngines($idSite, $period, $date, $segment);
@@ -274,7 +277,7 @@ class Piwik_Referers_API
if (!empty($subTableRow)) {
$searchEngineUrl = $subTableRow->getMetadata('url');
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_getSearchEngineUrlFromKeywordAndUrl', array($searchEngineUrl)));
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\getSearchEngineUrlFromKeywordAndUrl', array($searchEngineUrl)));
}
$dataTable = $this->handleKeywordNotDefined($dataTable);
return $dataTable;
@@ -282,29 +285,29 @@ class Piwik_Referers_API
public function getCampaigns($idSite, $period, $date, $segment = false, $expanded = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::CAMPAIGNS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
+ $dataTable = $this->getDataTable(Archiver::CAMPAIGNS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
return $dataTable;
}
public function getKeywordsFromCampaignId($idSite, $period, $date, $idSubtable, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::CAMPAIGNS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
+ $dataTable = $this->getDataTable(Archiver::CAMPAIGNS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
return $dataTable;
}
public function getWebsites($idSite, $period, $date, $segment = false, $expanded = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
+ $dataTable = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
return $dataTable;
}
public function getUrlsFromWebsiteId($idSite, $period, $date, $idSubtable, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_Referers_Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
+ $dataTable = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = false, $idSubtable);
// the htmlspecialchars_decode call is for BC for before 1.1
// as the Referrer URL was previously encoded in the log tables, but is now recorded raw
$dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', create_function('$label', 'return htmlspecialchars_decode($label);')));
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getPathFromUrl'));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getPathFromUrl'));
return $dataTable;
}
@@ -323,17 +326,17 @@ class Piwik_Referers_API
{
require PIWIK_INCLUDE_PATH . '/core/DataFiles/Socials.php';
- $dataTable = $this->getDataTable( Piwik_Referers_Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
+ $dataTable = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded);
- $dataTable->filter('ColumnCallbackDeleteRow', array('label', 'Piwik_Referrers_isSocialUrl'));
+ $dataTable->filter('ColumnCallbackDeleteRow', array('label', __NAMESPACE__ . '\isSocialUrl'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_Referrers_cleanSocialUrl'));
- $dataTable->filter('GroupBy', array('label', 'Piwik_Referrers_getSocialNetworkFromDomain'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'url', __NAMESPACE__ . '\cleanSocialUrl'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getSocialNetworkFromDomain'));
$this->setSocialIdSubtables($dataTable);
$this->removeSubtableMetadata($dataTable);
- $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', 'Piwik_getSocialsLogoFromUrl'));
+ $dataTable->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', __NAMESPACE__ . '\getSocialsLogoFromUrl'));
return $dataTable;
}
@@ -356,7 +359,7 @@ class Piwik_Referers_API
{
require PIWIK_INCLUDE_PATH . '/core/DataFiles/Socials.php';
- $dataTable = $this->getDataTable( Piwik_Referers_Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = true);
+ $dataTable = $this->getDataTable(Archiver::WEBSITES_RECORD_NAME, $idSite, $period, $date, $segment, $expanded = true);
// get the social network domain referred to by $idSubtable
$social = false;
@@ -372,7 +375,7 @@ class Piwik_Referers_API
}
// filter out everything but social network indicated by $idSubtable
- $dataTable->filter('ColumnCallbackDeleteRow', array('label', 'Piwik_Referrers_isSocialUrl', array($social)));
+ $dataTable->filter('ColumnCallbackDeleteRow', array('label', __NAMESPACE__ . '\isSocialUrl', array($social)));
// merge the datatable's subtables which contain the individual URLs
$dataTable = $dataTable->mergeSubtables();
@@ -381,7 +384,7 @@ class Piwik_Referers_API
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'url'));
// prettify the DataTable
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_Referrers_removeUrlProtocol'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\removeUrlProtocol'));
$dataTable->filter('Sort', array(Metrics::INDEX_NB_VISITS, 'desc', $naturalSort = false, $expanded));
$dataTable->queueFilter('ReplaceColumnNames');
@@ -390,27 +393,27 @@ class Piwik_Referers_API
public function getNumberOfDistinctSearchEngines($idSite, $period, $date, $segment = false)
{
- return $this->getNumeric(Piwik_Referers_Archiver::METRIC_DISTINCT_SEARCH_ENGINE_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getNumeric(Archiver::METRIC_DISTINCT_SEARCH_ENGINE_RECORD_NAME, $idSite, $period, $date, $segment);
}
public function getNumberOfDistinctKeywords($idSite, $period, $date, $segment = false)
{
- return $this->getNumeric(Piwik_Referers_Archiver::METRIC_DISTINCT_KEYWORD_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getNumeric(Archiver::METRIC_DISTINCT_KEYWORD_RECORD_NAME, $idSite, $period, $date, $segment);
}
public function getNumberOfDistinctCampaigns($idSite, $period, $date, $segment = false)
{
- return $this->getNumeric(Piwik_Referers_Archiver::METRIC_DISTINCT_CAMPAIGN_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getNumeric(Archiver::METRIC_DISTINCT_CAMPAIGN_RECORD_NAME, $idSite, $period, $date, $segment);
}
public function getNumberOfDistinctWebsites($idSite, $period, $date, $segment = false)
{
- return $this->getNumeric(Piwik_Referers_Archiver::METRIC_DISTINCT_WEBSITE_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getNumeric(Archiver::METRIC_DISTINCT_WEBSITE_RECORD_NAME, $idSite, $period, $date, $segment);
}
public function getNumberOfDistinctWebsitesUrls($idSite, $period, $date, $segment = false)
{
- return $this->getNumeric(Piwik_Referers_Archiver::METRIC_DISTINCT_URLS_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getNumeric(Archiver::METRIC_DISTINCT_URLS_RECORD_NAME, $idSite, $period, $date, $segment);
}
private function getNumeric($name, $idSite, $period, $date, $segment)
diff --git a/plugins/Referers/Archiver.php b/plugins/Referers/Archiver.php
index 4da6a19d07..5c7d700eea 100644
--- a/plugins/Referers/Archiver.php
+++ b/plugins/Referers/Archiver.php
@@ -1,10 +1,4 @@
<?php
-use Piwik\Common;
-use Piwik\Config;
-use Piwik\Metrics;
-use Piwik\DataArray;
-use Piwik\PluginsArchiver;
-
/**
* Piwik - Open source web analytics
*
@@ -12,10 +6,20 @@ use Piwik\PluginsArchiver;
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Referers
+ * @package Referers
*/
+namespace Piwik\Plugins\Referers;
+
+use Exception;
+use Piwik\Common;
+use Piwik\Config;
+use Piwik\Metrics;
+use Piwik\DataArray;
+use Piwik\Plugins\Referers\API;
+use Piwik\PluginsArchiver;
+
-class Piwik_Referers_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const SEARCH_ENGINES_RECORD_NAME = 'Referers_keywordBySearchEngine';
const KEYWORDS_RECORD_NAME = 'Referers_searchEngineByKeyword';
@@ -88,7 +92,7 @@ class Piwik_Referers_Archiver extends PluginsArchiver
switch ($row['referer_type']) {
case Common::REFERER_TYPE_SEARCH_ENGINE:
if (empty($row['referer_keyword'])) {
- $row['referer_keyword'] = Piwik_Referers_API::LABEL_KEYWORD_NOT_DEFINED;
+ $row['referer_keyword'] = API::LABEL_KEYWORD_NOT_DEFINED;
}
$searchEnginesArray = $this->getDataArray(self::SEARCH_ENGINES_RECORD_NAME);
$searchEnginesArray->sumMetricsVisits($row['referer_name'], $row);
@@ -161,7 +165,7 @@ class Piwik_Referers_Archiver extends PluginsArchiver
switch ($row['referer_type']) {
case Common::REFERER_TYPE_SEARCH_ENGINE:
if (empty($row['referer_keyword'])) {
- $row['referer_keyword'] = Piwik_Referers_API::LABEL_KEYWORD_NOT_DEFINED;
+ $row['referer_keyword'] = API::LABEL_KEYWORD_NOT_DEFINED;
}
$this->getDataArray(self::SEARCH_ENGINES_RECORD_NAME)->sumMetricsGoals($row['referer_name'], $row);
diff --git a/plugins/Referers/Controller.php b/plugins/Referers/Controller.php
index 1e31b6dd41..17da96fe90 100644
--- a/plugins/Referers/Controller.php
+++ b/plugins/Referers/Controller.php
@@ -6,23 +6,24 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Referers
+ * @package Referers
*/
+namespace Piwik\Plugins\Referers;
+
use Piwik\API\Request;
use Piwik\Metrics;
use Piwik\Period\Range;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\ViewDataTable;
use Piwik\View;
use Piwik\Url;
/**
*
- * @package Piwik_Referers
+ * @package Referers
*/
-class Piwik_Referers_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
@@ -305,7 +306,7 @@ class Piwik_Referers_Controller extends Controller
$view->documentation = Piwik_Translate('Referers_EvolutionDocumentation') . '<br />'
. Piwik_Translate('General_BrokenDownReportDocumentation') . '<br />'
. Piwik_Translate('Referers_EvolutionDocumentationMoreInfo', '&quot;'
- . Piwik_Translate('Referers_DetailsByRefererType') . '&quot;');
+ . Piwik_Translate('Referers_DetailsByRefererType') . '&quot;');
return $this->renderView($view, $fetch);
}
@@ -414,7 +415,7 @@ function DisplayTopKeywords($url = "")
<p>
<b>Example API URL</b> - For example if you would like to get the top 10 keywords, used last week, to land on the page <a target='_blank' href='$topPageUrl'>$topPageUrl</a>,
in format JSON: you would dynamically fetch the data using <a target='_blank' href='$jsonRequest&url=" . urlencode($topPageUrl) . "'>this API request URL</a>. Make sure you encode the 'url' parameter in the URL.</p>
-
+
<p><b>PHP Function ready to use!</b> - If you use PHP on your website, we have prepared a small code snippet that you can copy paste in your Website PHP files. You can then simply call the function <code>DisplayTopKeywords();</code> anywhere in your template, at the bottom of the content or in your blog sidebar.
If you run this code in your page $topPageUrl, it would output the following:";
@@ -458,7 +459,6 @@ function DisplayTopKeywords($url = "")
<br/>On medium to large traffic websites, we recommend to cache this data, as to minimize the performance impact of calling the Piwik API on each page view.
</p>
";
-
}
/**
@@ -469,7 +469,7 @@ function DisplayTopKeywords($url = "")
*/
public static function getTranslatedReferrerTypeLabel($typeReferrer)
{
- $label = Piwik_getRefererTypeLabel($typeReferrer);
+ $label = getRefererTypeLabel($typeReferrer);
return Piwik_Translate($label);
}
diff --git a/plugins/Referers/Referers.php b/plugins/Referers/Referers.php
index cd8ce1844e..5f6451548b 100644
--- a/plugins/Referers/Referers.php
+++ b/plugins/Referers/Referers.php
@@ -6,12 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Referers
+ * @package Referers
*/
+namespace Piwik\Plugins\Referers;
+
use Piwik\ArchiveProcessor;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Plugin;
+use Piwik\Plugins\Referers\Archiver;
use Piwik\WidgetsList;
/**
@@ -20,9 +22,9 @@ use Piwik\WidgetsList;
require_once PIWIK_INCLUDE_PATH . '/plugins/Referers/functions.php';
/**
- * @package Piwik_Referers
+ * @package Referers
*/
-class Piwik_Referers extends Plugin
+class Referers extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -30,13 +32,13 @@ class Piwik_Referers extends Plugin
public function getListHooksRegistered()
{
$hooks = array(
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenus',
- 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
- 'API.getReportMetadata' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenus',
+ 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
+ 'API.getReportMetadata' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
return $hooks;
@@ -178,7 +180,7 @@ class Piwik_Referers extends Plugin
'segment' => 'referrerType',
'acceptedValues' => 'direct, search, website, campaign',
'sqlSegment' => 'log_visit.referer_type',
- 'sqlFilter' => 'Piwik_getRefererTypeFromShortName',
+ 'sqlFilter' => __NAMESPACE__ . '\getRefererTypeFromShortName',
);
$segments[] = array(
'type' => 'dimension',
@@ -274,7 +276,7 @@ class Piwik_Referers extends Plugin
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_Referers_Archiver($archiveProcessor);
+ $archiving = new Archiver($archiveProcessor);
if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
@@ -286,8 +288,8 @@ class Piwik_Referers extends Plugin
*/
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_Referers_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
@@ -381,9 +383,9 @@ class Piwik_Referers extends Plugin
private function getDisplayPropertiesForGetSearchEnginesFromKeywordId()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnSearchEngine'))
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnSearchEngine'))
);
}
@@ -407,9 +409,9 @@ class Piwik_Referers extends Plugin
private function getDisplayPropertiesForGetKeywordsFromSearchEngineId()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnKeyword'))
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnKeyword'))
);
}
@@ -457,20 +459,20 @@ class Piwik_Referers extends Plugin
{
return array(
'show_exclude_low_population' => false,
- 'filter_limit' => 10,
- 'show_goals' => true,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnWebsitePage'))
+ 'filter_limit' => 10,
+ 'show_goals' => true,
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnWebsitePage'))
);
}
private function getDisplayPropertiesForGetCampaigns()
{
$result = array(
- 'subtable_controller_action' => 'getKeywordsFromCampaignId',
+ 'subtable_controller_action' => 'getKeywordsFromCampaignId',
'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'filter_limit' => 25,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnCampaign')),
+ 'show_goals' => true,
+ 'filter_limit' => 25,
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnCampaign')),
);
if (Common::getRequestVar('viewDataTable', false) != 'graphEvolution') {
@@ -487,19 +489,19 @@ class Piwik_Referers extends Plugin
private function getDisplayPropertiesForGetKeywordsFromCampaignId()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnKeyword'))
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnKeyword'))
);
}
private function getDisplayPropertiesForGetUrlsFromWebsiteId()
{
return array(
- 'show_search' => false,
+ 'show_search' => false,
'show_exclude_low_population' => false,
- 'translations' => array('label' => Piwik_Translate('Referers_ColumnWebsitePage')),
- 'tooltip_metadata_name' => 'url'
+ 'translations' => array('label' => Piwik_Translate('Referers_ColumnWebsitePage')),
+ 'tooltip_metadata_name' => 'url'
);
}
diff --git a/plugins/Referers/functions.php b/plugins/Referers/functions.php
index b7038fb360..0a6a50a72c 100644
--- a/plugins/Referers/functions.php
+++ b/plugins/Referers/functions.php
@@ -6,9 +6,12 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Referers
+ * @package Referers
*/
+namespace Piwik\Plugins\Referers;
+
use Piwik\Common;
+use Piwik\Plugins\Referers\API;
/**
* Returns path component from a URL
@@ -16,7 +19,7 @@ use Piwik\Common;
* @param string $url
* @return string path
*/
-function Piwik_getPathFromUrl($url)
+function getPathFromUrl($url)
{
$path = Common::getPathAndQueryFromUrl($url);
if (empty($path)) {
@@ -31,7 +34,7 @@ function Piwik_getPathFromUrl($url)
* @param string $url e.g. http://www.facebook.com/?sdlfk=lksdfj
* @return string|false e.g. facebook.com
*/
-function Piwik_Referrers_cleanSocialUrl($url)
+function cleanSocialUrl($url)
{
$segment = '[^.:\/]+';
preg_match('/(?:https?:\/\/)?(?:' . $segment . '\.)?(' . $segment . '(?:\.' . $segment . ')+)/', $url, $matches);
@@ -44,9 +47,9 @@ function Piwik_Referrers_cleanSocialUrl($url)
* @param string $url
* @return string
*/
-function Piwik_Referrers_getSocialNetworkFromDomain($url)
+function getSocialNetworkFromDomain($url)
{
- $domain = Piwik_Referrers_cleanSocialUrl($url);
+ $domain = cleanSocialUrl($url);
if (isset($GLOBALS['Piwik_socialUrl'][$domain])) {
return $GLOBALS['Piwik_socialUrl'][$domain];
@@ -63,9 +66,9 @@ function Piwik_Referrers_getSocialNetworkFromDomain($url)
* for any.
* @return bool
*/
-function Piwik_Referrers_isSocialUrl($url, $socialName = false)
+function isSocialUrl($url, $socialName = false)
{
- $domain = Piwik_Referrers_cleanSocialUrl($url);
+ $domain = cleanSocialUrl($url);
if (isset($GLOBALS['Piwik_socialUrl'][$domain])
&& ($socialName === false
@@ -83,9 +86,9 @@ function Piwik_Referrers_isSocialUrl($url, $socialName = false)
* @return string path
* @see plugins/Referers/images/socials/
*/
-function Piwik_getSocialsLogoFromUrl($domain)
+function getSocialsLogoFromUrl($domain)
{
- $domain = Piwik_Referrers_cleanSocialUrl($domain);
+ $domain = cleanSocialUrl($domain);
if (isset($GLOBALS['Piwik_socialUrl'][$domain])) {
// image names are by first domain in list, so make sure we use the first if $domain isn't it
@@ -112,7 +115,7 @@ function Piwik_getSocialsLogoFromUrl($domain)
* @param string $name
* @return string URL
*/
-function Piwik_getSearchEngineUrlFromName($name)
+function getSearchEngineUrlFromName($name)
{
$searchEngineNames = Common::getSearchEngineNames();
if (isset($searchEngineNames[$name])) {
@@ -129,7 +132,7 @@ function Piwik_getSearchEngineUrlFromName($name)
* @param string $url
* @return string host
*/
-function Piwik_getSearchEngineHostFromUrl($url)
+function getSearchEngineHostFromUrl($url)
{
$url = substr($url, strpos($url, '//') + 2);
if (($p = strpos($url, '/')) !== false) {
@@ -145,10 +148,10 @@ function Piwik_getSearchEngineHostFromUrl($url)
* @return string path
* @see plugins/Referers/images/searchEnginges/
*/
-function Piwik_getSearchEngineLogoFromUrl($url)
+function getSearchEngineLogoFromUrl($url)
{
$pathInPiwik = 'plugins/Referers/images/searchEngines/%s.png';
- $pathWithCode = sprintf($pathInPiwik, Piwik_getSearchEngineHostFromUrl($url));
+ $pathWithCode = sprintf($pathInPiwik, getSearchEngineHostFromUrl($url));
$absolutePath = PIWIK_INCLUDE_PATH . '/' . $pathWithCode;
if (file_exists($absolutePath)) {
return $pathWithCode;
@@ -162,7 +165,7 @@ function Piwik_getSearchEngineLogoFromUrl($url)
* @param string $url
* @return string host
*/
-function Piwik_getSearchEngineHostPathFromUrl($url)
+function getSearchEngineHostPathFromUrl($url)
{
$url = substr($url, strpos($url, '//') + 2);
return $url;
@@ -177,15 +180,15 @@ function Piwik_getSearchEngineHostPathFromUrl($url)
* @param string $keyword Keyword, e.g., web+analytics
* @return string URL, e.g., http://search.piwik.org/q=web+analytics
*/
-function Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword)
+function getSearchEngineUrlFromUrlAndKeyword($url, $keyword)
{
- if ($keyword === Piwik_Referers_API::LABEL_KEYWORD_NOT_DEFINED) {
+ if ($keyword === API::LABEL_KEYWORD_NOT_DEFINED) {
return 'http://piwik.org/faq/general/#faq_144';
}
$searchEngineUrls = Common::getSearchEngineUrls();
$keyword = urlencode($keyword);
$keyword = str_replace(urlencode('+'), urlencode(' '), $keyword);
- $path = @$searchEngineUrls[Piwik_getSearchEngineHostPathFromUrl($url)][2];
+ $path = @$searchEngineUrls[getSearchEngineHostPathFromUrl($url)][2];
if (empty($path)) {
return false;
}
@@ -196,15 +199,15 @@ function Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword)
/**
* Return search engine URL for keyword and URL
*
- * @see Piwik_getSearchEngineUrlFromUrlAndKeyword()
+ * @see Piwik_getSearchEngineUrlFromUrlAndKeyword(getSearchEngineUrlFromUrlAndKeyword
*
* @param string $keyword Keyword, e.g., web+analytics
* @param string $url Domain name, e.g., search.piwik.org
* @return string URL, e.g., http://search.piwik.org/q=web+analytics
*/
-function Piwik_getSearchEngineUrlFromKeywordAndUrl($keyword, $url)
+function getSearchEngineUrlFromKeywordAndUrl($keyword, $url)
{
- return Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword);
+ return getSearchEngineUrlFromUrlAndKeyword($url, $keyword);
}
/**
@@ -213,7 +216,7 @@ function Piwik_getSearchEngineUrlFromKeywordAndUrl($keyword, $url)
* @param string $label
* @return string Referrer type
*/
-function Piwik_getRefererTypeLabel($label)
+function getRefererTypeLabel($label)
{
$indexTranslation = '';
switch ($label) {
@@ -243,7 +246,7 @@ function Piwik_getRefererTypeLabel($label)
* @throws Exception
* @return string
*/
-function Piwik_getRefererTypeFromShortName($name)
+function getRefererTypeFromShortName($name)
{
$map = array(
Common::REFERER_TYPE_SEARCH_ENGINE => 'search',
@@ -257,7 +260,7 @@ function Piwik_getRefererTypeFromShortName($name)
if ($found = array_search($name, $map)) {
return $found;
}
- throw new Exception("Referrer type '$name' is not valid.");
+ throw new \Exception("Referrer type '$name' is not valid.");
}
/**
@@ -266,7 +269,7 @@ function Piwik_getRefererTypeFromShortName($name)
* @param string $url
* @return string
*/
-function Piwik_Referrers_removeUrlProtocol($url)
+function removeUrlProtocol($url)
{
if (preg_match('/^[a-zA-Z_-]+:\/\//', $url, $matches)) {
return substr($url, strlen($matches[0]));
diff --git a/plugins/SEO/API.php b/plugins/SEO/API.php
index 185561df44..74dd10ac56 100644
--- a/plugins/SEO/API.php
+++ b/plugins/SEO/API.php
@@ -6,10 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SEO
+ * @package SEO
*/
+namespace Piwik\Plugins\SEO;
+
use Piwik\Piwik;
use Piwik\DataTable;
+use Piwik\Plugins\SEO\MajesticClient;
+use Piwik\Plugins\SEO\RankChecker;
/**
* @see plugins/Referers/functions.php
@@ -20,14 +24,14 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/Referers/functions.php';
* The SEO API lets you access a list of SEO metrics for the specified URL: Google Pagerank, Goolge/Bing indexed pages
* Alexa Rank, age of the Domain name and count of DMOZ entries.
*
- * @package Piwik_SEO
+ * @package SEO
*/
-class Piwik_SEO_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_SEO_API
+ * @return \Piwik\Plugins\SEO\API
*/
static public function getInstance()
{
@@ -46,29 +50,29 @@ class Piwik_SEO_API
public function getRank($url)
{
Piwik::checkUserHasSomeViewAccess();
- $rank = new Piwik_SEO_RankChecker($url);
+ $rank = new RankChecker($url);
- $linkToMajestic = Piwik_SEO_MajesticClient::getLinkForUrl($url);
+ $linkToMajestic = MajesticClient::getLinkForUrl($url);
$data = array(
'Google PageRank' => array(
'rank' => $rank->getPageRank(),
- 'logo' => Piwik_getSearchEngineLogoFromUrl('http://google.com'),
+ 'logo' => \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl('http://google.com'),
'id' => 'pagerank'
),
Piwik_Translate('SEO_Google_IndexedPages') => array(
'rank' => $rank->getIndexedPagesGoogle(),
- 'logo' => Piwik_getSearchEngineLogoFromUrl('http://google.com'),
+ 'logo' => \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl('http://google.com'),
'id' => 'google-index',
),
Piwik_Translate('SEO_Bing_IndexedPages') => array(
'rank' => $rank->getIndexedPagesBing(),
- 'logo' => Piwik_getSearchEngineLogoFromUrl('http://bing.com'),
+ 'logo' => \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl('http://bing.com'),
'id' => 'bing-index',
),
Piwik_Translate('SEO_AlexaRank') => array(
'rank' => $rank->getAlexaRank(),
- 'logo' => Piwik_getSearchEngineLogoFromUrl('http://alexa.com'),
+ 'logo' => \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl('http://alexa.com'),
'id' => 'alexa',
),
Piwik_Translate('SEO_DomainAge') => array(
@@ -95,7 +99,7 @@ class Piwik_SEO_API
// Add DMOZ only if > 0 entries found
$dmozRank = array(
'rank' => $rank->getDmoz(),
- 'logo' => Piwik_getSearchEngineLogoFromUrl('http://dmoz.org'),
+ 'logo' => \Piwik\Plugins\Referers\getSearchEngineLogoFromUrl('http://dmoz.org'),
'id' => 'dmoz',
);
if ($dmozRank['rank'] > 0) {
diff --git a/plugins/SEO/Controller.php b/plugins/SEO/Controller.php
index fc51c128f9..ee23bde1f4 100644
--- a/plugins/SEO/Controller.php
+++ b/plugins/SEO/Controller.php
@@ -6,18 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SEO
+ * @package SEO
*/
+namespace Piwik\Plugins\SEO;
+
use Piwik\Common;
use Piwik\DataTable\Renderer;
-use Piwik\Controller;
+use Piwik\Plugins\SEO\API;
use Piwik\View;
use Piwik\Site;
+use Piwik\Plugins\SEO\RankChecker;
/**
- * @package Piwik_SEO
+ * @package SEO
*/
-class Piwik_SEO_Controller extends Controller
+class Controller extends \Piwik\Controller
{
function getRank()
{
@@ -34,10 +37,10 @@ class Piwik_SEO_Controller extends Controller
$url = $site->getMainUrl();
}
- $dataTable = Piwik_SEO_API::getInstance()->getRank($url);
+ $dataTable = API::getInstance()->getRank($url);
$view = new View('@SEO/getRank');
- $view->urlToRank = Piwik_SEO_RankChecker::extractDomainFromUrl($url);
+ $view->urlToRank = RankChecker::extractDomainFromUrl($url);
/** @var \Piwik\DataTable\Renderer\Php $renderer */
$renderer = Renderer::factory('php');
diff --git a/plugins/SEO/MajesticClient.php b/plugins/SEO/MajesticClient.php
index 34f16a038e..1f89009121 100644
--- a/plugins/SEO/MajesticClient.php
+++ b/plugins/SEO/MajesticClient.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SEO
+ * @package SEO
*/
+namespace Piwik\Plugins\SEO;
+
use Piwik\Common;
use Piwik\Http;
@@ -16,7 +18,7 @@ use Piwik\Http;
*
* Hides the HTTP request sending logic.
*/
-class Piwik_SEO_MajesticClient
+class MajesticClient
{
const API_BASE = 'http://simpleapi.majesticseo.com/sapi/';
const API_KEY = 'ETHPYY'; // please only use this key within Piwik
diff --git a/plugins/SEO/RankChecker.php b/plugins/SEO/RankChecker.php
index cdc858176c..74d8afda3b 100644
--- a/plugins/SEO/RankChecker.php
+++ b/plugins/SEO/RankChecker.php
@@ -6,10 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SEO
+ * @package SEO
*/
+namespace Piwik\Plugins\SEO;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Http;
+use Piwik\Plugins\SEO\MajesticClient;
/**
* The functions below are derived/adapted from GetRank.org's
@@ -18,9 +22,9 @@ use Piwik\Http;
* @copyright Copyright (C) 2007 - 2010 GetRank.Org All rights reserved.
* @link http://www.getrank.org/free-pagerank-script/
* @license GPL
- * @package Piwik_SEO
+ * @package SEO
*/
-class Piwik_SEO_RankChecker
+class RankChecker
{
private $url;
private $majesticInfo = null;
@@ -185,7 +189,7 @@ class Piwik_SEO_RankChecker
try {
$majesticInfo = $this->getMajesticInfo();
return $majesticInfo['backlink_count'];
- } catch(Exception $e) {
+ } catch (Exception $e) {
Piwik::log($e->getMessage());
return 0;
}
@@ -201,7 +205,7 @@ class Piwik_SEO_RankChecker
try {
$majesticInfo = $this->getMajesticInfo();
return $majesticInfo['referrer_domains_count'];
- } catch(Exception $e) {
+ } catch (Exception $e) {
Piwik::log($e->getMessage());
return 0;
}
@@ -366,7 +370,7 @@ class Piwik_SEO_RankChecker
private function getMajesticInfo()
{
if ($this->majesticInfo === null) {
- $client = new Piwik_SEO_MajesticClient();
+ $client = new MajesticClient();
$this->majesticInfo = $client->getBacklinkStats($this->url);
}
diff --git a/plugins/SEO/SEO.php b/plugins/SEO/SEO.php
index 505f8de521..dd488bef97 100644
--- a/plugins/SEO/SEO.php
+++ b/plugins/SEO/SEO.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SEO
+ * @package SEO
*/
+namespace Piwik\Plugins\SEO;
+
use Piwik\Version;
-use Piwik\Plugin;
use Piwik\WidgetsList;
/**
- * @package Piwik_SEO
+ * @package SEO
*/
-class Piwik_SEO extends Plugin
+class SEO extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getInformation
diff --git a/plugins/SecurityInfo/Controller.php b/plugins/SecurityInfo/Controller.php
index 7195185fdd..fd7c29c981 100644
--- a/plugins/SecurityInfo/Controller.php
+++ b/plugins/SecurityInfo/Controller.php
@@ -6,16 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SecurityInfo
+ * @package SecurityInfo
*/
-use Piwik\Controller\Admin;
+namespace Piwik\Plugins\SecurityInfo;
+
+use PhpSecInfo;
use Piwik\Piwik;
use Piwik\View;
/**
- * @package Piwik_SecurityInfo
+ * @package SecurityInfo
*/
-class Piwik_SecurityInfo_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
function index()
{
diff --git a/plugins/SecurityInfo/SecurityInfo.php b/plugins/SecurityInfo/SecurityInfo.php
index 785247d2a2..4d5bacf07d 100644
--- a/plugins/SecurityInfo/SecurityInfo.php
+++ b/plugins/SecurityInfo/SecurityInfo.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SecurityInfo
+ * @package SecurityInfo
*/
+namespace Piwik\Plugins\SecurityInfo;
+
use Piwik\Piwik;
-use Piwik\Plugin;
/**
*
- * @package Piwik_SecurityInfo
+ * @package SecurityInfo
*/
-class Piwik_SecurityInfo extends Plugin
+class SecurityInfo extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/SegmentEditor/API.php b/plugins/SegmentEditor/API.php
index c8bb844a09..1dbc8b0811 100644
--- a/plugins/SegmentEditor/API.php
+++ b/plugins/SegmentEditor/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
+namespace Piwik\Plugins\SegmentEditor;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
@@ -16,16 +19,16 @@ use Piwik\Segment;
/**
* The SegmentEditor API lets you add, update, delete custom Segments, and list saved segments.a
*
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
-class Piwik_SegmentEditor_API
+class API
{
const DELETE_SEGMENT_EVENT = 'SegmentEditor.delete';
static private $instance = null;
/**
- * @return Piwik_SegmentEditor_API
+ * @return \Piwik\Plugins\SegmentEditor\API
*/
static public function getInstance()
{
@@ -116,7 +119,7 @@ class Piwik_SegmentEditor_API
protected function checkUserIsNotAnonymous()
{
- if(Piwik::isUserIsAnonymous()) {
+ if (Piwik::isUserIsAnonymous()) {
throw new Exception("To create, edit or delete Custom Segments, please sign in first.");
}
}
@@ -229,8 +232,8 @@ class Piwik_SegmentEditor_API
throw new Exception("idSegment should be numeric.");
}
$segment = \Zend_Registry::get('db')->fetchRow("SELECT * " .
- " FROM " . Common::prefixTable("segment") .
- " WHERE idsegment = ?", $idSegment);
+ " FROM " . Common::prefixTable("segment") .
+ " WHERE idsegment = ?", $idSegment);
if (empty($segment)) {
return false;
@@ -257,7 +260,7 @@ class Piwik_SegmentEditor_API
*/
public function getAll($idSite = false, $returnOnlyAutoArchived = false)
{
- if(!empty($idSite) ) {
+ if (!empty($idSite)) {
Piwik::checkUserHasViewAccess($idSite);
} else {
Piwik::checkUserHasSomeViewAccess();
@@ -266,7 +269,7 @@ class Piwik_SegmentEditor_API
// Build basic segment filtering
$whereIdSite = '';
- if(!empty($idSite)) {
+ if (!empty($idSite)) {
$whereIdSite = 'enable_only_idsite = ? OR ';
$bind[] = $idSite;
}
@@ -274,14 +277,14 @@ class Piwik_SegmentEditor_API
$bind[] = Piwik::getCurrentUserLogin();
$extraWhere = '';
- if($returnOnlyAutoArchived) {
+ if ($returnOnlyAutoArchived) {
$extraWhere = ' AND auto_archive = 1';
}
// Query
$sql = "SELECT * " .
- " FROM " . Common::prefixTable("segment") .
- " WHERE ($whereIdSite enable_only_idsite = 0)
+ " FROM " . Common::prefixTable("segment") .
+ " WHERE ($whereIdSite enable_only_idsite = 0)
AND (enable_all_users = 1 OR login = ?)
AND deleted = 0
$extraWhere
diff --git a/plugins/SegmentEditor/Controller.php b/plugins/SegmentEditor/Controller.php
index 4083369ece..55b406cf53 100644
--- a/plugins/SegmentEditor/Controller.php
+++ b/plugins/SegmentEditor/Controller.php
@@ -6,17 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
+namespace Piwik\Plugins\SegmentEditor;
+
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\SegmentEditor\API;
use Piwik\View;
+use Piwik\Plugins\API\API as MetaAPI;
/**
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
-class Piwik_SegmentEditor_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function getSelector()
@@ -24,12 +27,13 @@ class Piwik_SegmentEditor_Controller extends Controller
$view = new View('@SegmentEditor/getSelector');
$idSite = Common::getRequestVar('idSite');
$this->setGeneralVariablesView($view);
- $segments = Piwik_API_API::getInstance()->getSegmentsMetadata($idSite);
+ $segments = MetaAPI::getInstance()->getSegmentsMetadata($idSite);
$segmentsByCategory = $customVariablesSegments = array();
- foreach($segments as $segment) {
- if($segment['category'] == Piwik_Translate('General_Visit')
- && $segment['type'] == 'metric') {
+ foreach ($segments as $segment) {
+ if ($segment['category'] == Piwik_Translate('General_Visit')
+ && $segment['type'] == 'metric'
+ ) {
$metricsLabel = Piwik_Translate('General_Metrics');
$metricsLabel[0] = strtolower($metricsLabel[0]);
$segment['category'] .= ' (' . $metricsLabel . ')';
@@ -40,8 +44,8 @@ class Piwik_SegmentEditor_Controller extends Controller
$view->segmentsByCategory = $segmentsByCategory;
- $savedSegments = Piwik_SegmentEditor_API::getInstance()->getAll($idSite);
- foreach($savedSegments as &$savedSegment) {
+ $savedSegments = API::getInstance()->getAll($idSite);
+ foreach ($savedSegments as &$savedSegment) {
$savedSegment['name'] = Common::sanitizeInputValue($savedSegment['name']);
}
$view->savedSegmentsJson = Common::json_encode($savedSegments);
@@ -55,7 +59,7 @@ class Piwik_SegmentEditor_Controller extends Controller
public function sortSegmentCategories($a, $b)
{
// Custom Variables last
- if($a == Piwik_Translate('CustomVariables_CustomVariables')) {
+ if ($a == Piwik_Translate('CustomVariables_CustomVariables')) {
return 1;
}
return 0;
@@ -86,7 +90,7 @@ class Piwik_SegmentEditor_Controller extends Controller
'',
'',
);
- foreach($translationKeys as $key) {
+ foreach ($translationKeys as $key) {
$translations[$key] = Piwik_Translate($key);
}
return $translations;
diff --git a/plugins/SegmentEditor/SegmentEditor.php b/plugins/SegmentEditor/SegmentEditor.php
index 48359598a6..1c588a483d 100644
--- a/plugins/SegmentEditor/SegmentEditor.php
+++ b/plugins/SegmentEditor/SegmentEditor.php
@@ -6,17 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
+namespace Piwik\Plugins\SegmentEditor;
+
+use Exception;
use Piwik\Common;
+use Piwik\Plugins\SegmentEditor\API;
+use Piwik\Plugins\SegmentEditor\Controller;
use Piwik\Version;
-use Piwik\Plugin;
use Piwik\Db;
+use Zend_Registry;
/**
- * @package Piwik_SegmentEditor
+ * @package SegmentEditor
*/
-class Piwik_SegmentEditor extends Plugin
+class SegmentEditor extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getInformation
@@ -47,13 +52,13 @@ class Piwik_SegmentEditor extends Plugin
function getSegmentEditorHtml(&$out)
{
- $controller = new Piwik_SegmentEditor_Controller();
+ $controller = new Controller();
$out .= $controller->getSelector();
}
public function getKnownSegmentsToArchiveAllSites(&$segments)
{
- $segmentsToAutoArchive = Piwik_SegmentEditor_API::getInstance()->getAll($idSite = false, $returnAutoArchived = true);
+ $segmentsToAutoArchive = API::getInstance()->getAll($idSite = false, $returnAutoArchived = true);
foreach ($segmentsToAutoArchive as $segment) {
$segments[] = $segment['definition'];
}
@@ -61,7 +66,7 @@ class Piwik_SegmentEditor extends Plugin
public function getKnownSegmentsToArchiveForSite(&$segments, $idSite)
{
- $segmentToAutoArchive = Piwik_SegmentEditor_API::getInstance()->getAll($idSite, $returnAutoArchived = true);
+ $segmentToAutoArchive = API::getInstance()->getAll($idSite, $returnAutoArchived = true);
foreach ($segmentToAutoArchive as $segmentInfo) {
$segments[] = $segmentInfo['definition'];
diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php
index 18f22d8278..5ca3382826 100644
--- a/plugins/SitesManager/API.php
+++ b/plugins/SitesManager/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
+namespace Piwik\Plugins\SitesManager;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Access;
@@ -18,6 +21,7 @@ use Piwik\Tracker\Cache;
use Piwik\Url;
use Piwik\TaskScheduler;
use Piwik\Site;
+use false;
/**
* The SitesManager API gives you full control on Websites in Piwik (create, update and delete), and many methods to retrieve websites based on various attributes.
@@ -33,15 +37,15 @@ use Piwik\Site;
* "setGlobalExcludedQueryParameters" will set the list of URL parameters to remove from URLs for all websites.
* The existing values can be fetched via "getExcludedIpsGlobal" and "getExcludedQueryParametersGlobal".
* See also the documentation about <a href='http://piwik.org/docs/manage-websites/' target='_blank'>Managing Websites</a> in Piwik.
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
-class Piwik_SitesManager_API
+class API
{
static private $instance = null;
const DEFAULT_SEARCH_KEYWORD_PARAMETERS = 'q,query,s,search,searchword,k,keyword';
/**
- * @return Piwik_SitesManager_API
+ * @return \Piwik\Plugins\SitesManager\API
*/
static public function getInstance()
{
@@ -209,8 +213,8 @@ class Piwik_SitesManager_API
{
Piwik::checkUserIsSuperUser();
try {
- return Piwik_SitesManager_API::getInstance()->getSitesId();
- } catch(Exception $e) {
+ return API::getInstance()->getSitesId();
+ } catch (Exception $e) {
// can be called before Piwik tables are created so return empty
return array();
}
@@ -236,7 +240,7 @@ class Piwik_SitesManager_API
FROM
" . Common::prefixTable('site') . " s
WHERE EXISTS (
- SELECT 1
+ SELECT 1
FROM " . Common::prefixTable('log_visit') . " v
WHERE v.idsite = s.idsite
AND visit_last_action_time > ?
@@ -250,7 +254,6 @@ class Piwik_SitesManager_API
return $idSites;
}
-
/**
* Returns the list of websites with the 'admin' access for the current user.
* For the superUser it returns all the websites in the database.
@@ -344,7 +347,7 @@ class Piwik_SitesManager_API
* The user access is not checked in this method so the ID have to be accessible by the user!
*
* @param array $idSites list of website ID
- * @param bool $limit
+ * @param bool $limit
* @return array
*/
private function getSitesFromIds($idSites, $limit = false)
@@ -566,7 +569,7 @@ class Piwik_SitesManager_API
{
Piwik::checkUserIsSuperUser();
- $idSites = Piwik_SitesManager_API::getInstance()->getSitesId();
+ $idSites = API::getInstance()->getSitesId();
if (!in_array($idSite, $idSites)) {
throw new Exception("website id = $idSite not found");
}
@@ -592,7 +595,6 @@ class Piwik_SitesManager_API
Piwik_PostEvent('SitesManager.deleteSite', array($idSite));
}
-
/**
* Checks that the array has at least one element
*
@@ -659,7 +661,7 @@ class Piwik_SitesManager_API
* If some URLs given in parameter are already recorded as alias URLs for this website,
* they won't be duplicated. The 'main_url' of the website won't be affected by this method.
*
- * @param int $idSite
+ * @param int $idSite
* @param array|string $urls
* @return int the number of inserted URLs
*/
@@ -985,7 +987,7 @@ class Piwik_SitesManager_API
{
Piwik::checkUserHasAdminAccess($idSite);
- $idSites = Piwik_SitesManager_API::getInstance()->getSitesId();
+ $idSites = API::getInstance()->getSitesId();
if (!in_array($idSite, $idSites)) {
throw new Exception("website id = $idSite not found");
}
@@ -1187,9 +1189,9 @@ class Piwik_SitesManager_API
$db = \Zend_Registry::get('db');
foreach ($urls as $url) {
$db->insert(Common::prefixTable("site_url"), array(
- 'idsite' => $idSite,
- 'url' => $url
- )
+ 'idsite' => $idSite,
+ 'url' => $url
+ )
);
}
}
@@ -1258,7 +1260,6 @@ class Piwik_SitesManager_API
}
}
-
private function checkSiteSearch($siteSearch)
{
if ($siteSearch === null) {
@@ -1348,10 +1349,10 @@ class Piwik_SitesManager_API
}
$sites = $db->fetchAll("SELECT idsite, name, main_url
FROM " . Common::prefixTable('site') . " s
- WHERE ( s.name like ?
+ WHERE ( s.name like ?
OR s.main_url like ?
- $where )
- AND idsite in ($ids_str)
+ $where )
+ AND idsite in ($ids_str)
LIMIT " . Piwik::getWebsitesCountToDisplay(),
$bind);
return $sites;
diff --git a/plugins/SitesManager/Controller.php b/plugins/SitesManager/Controller.php
index 3a8f339693..7a03152256 100644
--- a/plugins/SitesManager/Controller.php
+++ b/plugins/SitesManager/Controller.php
@@ -6,24 +6,27 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
+namespace Piwik\Plugins\SitesManager;
+
+use Exception;
use Piwik\API\ResponseBuilder;
-use Piwik\Controller\Admin;
use Piwik\DataTable\Renderer\Json;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
use Piwik\IP;
+use Piwik\Plugins\SitesManager\API;
use Piwik\View;
use Piwik\Url;
use Piwik\Site;
/**
*
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
-class Piwik_SitesManager_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
/**
* Main view showing listing of websites and settings
@@ -33,16 +36,16 @@ class Piwik_SitesManager_Controller extends Admin
$view = new View('@SitesManager/index');
if (Piwik::isUserIsSuperUser()) {
- $sites = Piwik_SitesManager_API::getInstance()->getAllSites();
+ $sites = API::getInstance()->getAllSites();
Site::setSites($sites);
$sites = array_values($sites);
} else {
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
+ $sites = API::getInstance()->getSitesWithAdminAccess();
Site::setSitesFromArray($sites);
}
foreach ($sites as &$site) {
- $site['alias_urls'] = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($site['idsite']);
+ $site['alias_urls'] = API::getInstance()->getSiteUrlsFromId($site['idsite']);
$site['excluded_ips'] = explode(',', $site['excluded_ips']);
$site['excluded_parameters'] = explode(',', $site['excluded_parameters']);
$site['excluded_user_agents'] = explode(',', $site['excluded_user_agents']);
@@ -50,30 +53,30 @@ class Piwik_SitesManager_Controller extends Admin
$view->adminSites = $sites;
$view->adminSitesCount = count($sites);
- $timezones = Piwik_SitesManager_API::getInstance()->getTimezonesList();
+ $timezones = API::getInstance()->getTimezonesList();
$view->timezoneSupported = Piwik::isTimezoneSupportEnabled();
$view->timezones = Common::json_encode($timezones);
- $view->defaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
+ $view->defaultTimezone = API::getInstance()->getDefaultTimezone();
- $view->currencies = Common::json_encode(Piwik_SitesManager_API::getInstance()->getCurrencyList());
- $view->defaultCurrency = Piwik_SitesManager_API::getInstance()->getDefaultCurrency();
+ $view->currencies = Common::json_encode(API::getInstance()->getCurrencyList());
+ $view->defaultCurrency = API::getInstance()->getDefaultCurrency();
$view->utcTime = Date::now()->getDatetime();
- $excludedIpsGlobal = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
+ $excludedIpsGlobal = API::getInstance()->getExcludedIpsGlobal();
$view->globalExcludedIps = str_replace(',', "\n", $excludedIpsGlobal);
- $excludedQueryParametersGlobal = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
+ $excludedQueryParametersGlobal = API::getInstance()->getExcludedQueryParametersGlobal();
$view->globalExcludedQueryParameters = str_replace(',', "\n", $excludedQueryParametersGlobal);
- $globalExcludedUserAgents = Piwik_SitesManager_API::getInstance()->getExcludedUserAgentsGlobal();
+ $globalExcludedUserAgents = API::getInstance()->getExcludedUserAgentsGlobal();
$view->globalExcludedUserAgents = str_replace(',', "\n", $globalExcludedUserAgents);
- $view->globalSearchKeywordParameters = Piwik_SitesManager_API::getInstance()->getSearchKeywordParametersGlobal();
- $view->globalSearchCategoryParameters = Piwik_SitesManager_API::getInstance()->getSearchCategoryParametersGlobal();
+ $view->globalSearchKeywordParameters = API::getInstance()->getSearchKeywordParametersGlobal();
+ $view->globalSearchCategoryParameters = API::getInstance()->getSearchCategoryParametersGlobal();
$view->isSearchCategoryTrackingEnabled = \Piwik\PluginsManager::getInstance()->isPluginActivated('CustomVariables');
$view->allowSiteSpecificUserAgentExclude =
- Piwik_SitesManager_API::getInstance()->isSiteSpecificUserAgentExcludeEnabled();
+ API::getInstance()->isSiteSpecificUserAgentExcludeEnabled();
- $view->globalKeepURLFragments = Piwik_SitesManager_API::getInstance()->getKeepURLFragmentsGlobal();
+ $view->globalKeepURLFragments = API::getInstance()->getKeepURLFragmentsGlobal();
$view->currentIpAddress = IP::getIpFromHeader();
@@ -102,7 +105,7 @@ class Piwik_SitesManager_Controller extends Admin
$enableSiteUserAgentExclude = Common::getRequestVar('enableSiteUserAgentExclude', $default = 0);
$keepURLFragments = Common::getRequestVar('keepURLFragments', $default = 0);
- $api = Piwik_SitesManager_API::getInstance();
+ $api = API::getInstance();
$api->setDefaultTimezone($timezone);
$api->setDefaultCurrency($currency);
$api->setGlobalExcludedQueryParameters($excludedQueryParameters);
@@ -170,7 +173,7 @@ class Piwik_SitesManager_Controller extends Admin
function getSitesForAutocompleter()
{
$pattern = Common::getRequestVar('term');
- $sites = Piwik_SitesManager_API::getInstance()->getPatternMatchSites($pattern);
+ $sites = API::getInstance()->getPatternMatchSites($pattern);
$pattern = str_replace('%', '', $pattern);
if (!count($sites)) {
$results[] = array('label' => Piwik_Translate('SitesManager_NotFound') . "&nbsp;<span class='autocompleteMatched'>$pattern</span>.", 'id' => '#');
diff --git a/plugins/SitesManager/SitesManager.php b/plugins/SitesManager/SitesManager.php
index 7b21bbafd1..cdc3a92f2b 100644
--- a/plugins/SitesManager/SitesManager.php
+++ b/plugins/SitesManager/SitesManager.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
+namespace Piwik\Plugins\SitesManager;
+
use Piwik\Piwik;
-use Piwik\Plugin;
/**
*
- * @package Piwik_SitesManager
+ * @package SitesManager
*/
-class Piwik_SitesManager extends Plugin
+class SitesManager extends \Piwik\Plugin
{
const KEEP_URL_FRAGMENT_USE_DEFAULT = 0;
const KEEP_URL_FRAGMENT_YES = 1;
@@ -64,17 +65,17 @@ class Piwik_SitesManager extends Plugin
* Will record in the tracker config file all data needed for this website in Tracker.
*
* @param array $array
- * @param int $idSite
+ * @param int $idSite
* @return void
*/
public function recordWebsiteDataInCache(&$array, $idSite)
{
$idSite = (int)$idSite;
-
+
// add the 'hosts' entry in the website array
$array['hosts'] = $this->getTrackerHosts($idSite);
- $website = Piwik_SitesManager_API::getInstance()->getSiteFromId($idSite);
+ $website = API::getInstance()->getSiteFromId($idSite);
$array['excluded_ips'] = $this->getTrackerExcludedIps($website);
$array['excluded_parameters'] = self::getTrackerExcludedQueryParameters($website);
$array['excluded_user_agents'] = self::getExcludedUserAgents($website);
@@ -98,14 +99,14 @@ class Piwik_SitesManager extends Plugin
return false;
}
- return Piwik_SitesManager_API::getInstance()->getKeepURLFragmentsGlobal();
+ return API::getInstance()->getKeepURLFragmentsGlobal();
}
private function getTrackerSearchKeywordParameters($website)
{
$searchParameters = $website['sitesearch_keyword_parameters'];
if (empty($searchParameters)) {
- $searchParameters = Piwik_SitesManager_API::getInstance()->getSearchKeywordParametersGlobal();
+ $searchParameters = API::getInstance()->getSearchKeywordParametersGlobal();
}
return explode(",", $searchParameters);
}
@@ -114,7 +115,7 @@ class Piwik_SitesManager extends Plugin
{
$searchParameters = $website['sitesearch_category_parameters'];
if (empty($searchParameters)) {
- $searchParameters = Piwik_SitesManager_API::getInstance()->getSearchCategoryParametersGlobal();
+ $searchParameters = API::getInstance()->getSearchCategoryParametersGlobal();
}
return explode(",", $searchParameters);
}
@@ -128,13 +129,13 @@ class Piwik_SitesManager extends Plugin
private function getTrackerExcludedIps($website)
{
$excludedIps = $website['excluded_ips'];
- $globalExcludedIps = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
+ $globalExcludedIps = API::getInstance()->getExcludedIpsGlobal();
$excludedIps .= ',' . $globalExcludedIps;
$ipRanges = array();
foreach (explode(',', $excludedIps) as $ip) {
- $ipRange = Piwik_SitesManager_API::getInstance()->getIpsForRange($ip);
+ $ipRange = API::getInstance()->getIpsForRange($ip);
if ($ipRange !== false) {
$ipRanges[] = $ipRange;
}
@@ -151,8 +152,8 @@ class Piwik_SitesManager extends Plugin
*/
private static function getExcludedUserAgents($website)
{
- $excludedUserAgents = Piwik_SitesManager_API::getInstance()->getExcludedUserAgentsGlobal();
- if (Piwik_SitesManager_API::getInstance()->isSiteSpecificUserAgentExcludeEnabled()) {
+ $excludedUserAgents = API::getInstance()->getExcludedUserAgentsGlobal();
+ if (API::getInstance()->isSiteSpecificUserAgentExcludeEnabled()) {
$excludedUserAgents .= ',' . $website['excluded_user_agents'];
}
return self::filterBlankFromCommaSepList($excludedUserAgents);
@@ -167,7 +168,7 @@ class Piwik_SitesManager extends Plugin
public static function getTrackerExcludedQueryParameters($website)
{
$excludedQueryParameters = $website['excluded_parameters'];
- $globalExcludedQueryParameters = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
+ $globalExcludedQueryParameters = API::getInstance()->getExcludedQueryParametersGlobal();
$excludedQueryParameters .= ',' . $globalExcludedQueryParameters;
return self::filterBlankFromCommaSepList($excludedQueryParameters);
@@ -195,7 +196,7 @@ class Piwik_SitesManager extends Plugin
*/
private function getTrackerHosts($idSite)
{
- $urls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idSite);
+ $urls = API::getInstance()->getSiteUrlsFromId($idSite);
$hosts = array();
foreach ($urls as $url) {
$url = parse_url($url);
diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php
index c676e51fe7..e019005aed 100644
--- a/plugins/Transitions/API.php
+++ b/plugins/Transitions/API.php
@@ -6,9 +6,12 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Transitions
+ * @package Transitions
*/
+namespace Piwik\Plugins\Transitions;
+
+use Exception;
use Piwik\ArchiveProcessor;
use Piwik\DataAccess\LogAggregator;
use Piwik\DataTable\Manager;
@@ -20,16 +23,19 @@ use Piwik\Piwik;
use Piwik\Common;
use Piwik\DataTable;
use Piwik\DataArray;
+use Piwik\Plugins\Actions\Actions;
+use Piwik\Plugins\Actions\ArchivingHelper;
use Piwik\RankingQuery;
use Piwik\Segment;
use Piwik\SegmentExpression;
use Piwik\Site;
use Piwik\Tracker\Action;
+use Piwik\Plugins\Transitions\Controller;
/**
- * @package Piwik_Transitions
+ * @package Transitions
*/
-class Piwik_Transitions_API
+class API
{
static private $instance = null;
@@ -139,7 +145,7 @@ class Piwik_Transitions_API
*/
private function deriveIdAction($actionName, $actionType)
{
- $actionsPlugin = new Piwik_Actions;
+ $actionsPlugin = new Actions;
switch ($actionType) {
case 'url':
$originalActionName = $actionName;
@@ -158,7 +164,7 @@ class Piwik_Transitions_API
$id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_name', SegmentExpression::MATCH_EQUAL, 'pageTitle');
if ($id < 0) {
- $unknown = Piwik_Actions_ArchivingHelper::getUnknownActionName(
+ $unknown = ArchivingHelper::getUnknownActionName(
Action::TYPE_ACTION_NAME);
if (trim($actionName) == trim($unknown)) {
@@ -221,14 +227,12 @@ class Piwik_Transitions_API
}
}
-
-
/**
* Get information about the following actions (following pages, site searches, outlinks, downloads)
*
* @param $idaction
* @param $actionType
- * @param LogAggregator $logAggregator
+ * @param LogAggregator $logAggregator
* @param $limitBeforeGrouping
* @param $includeLoops
* @return array(followingPages:DataTable, outlinks:DataTable, downloads:DataTable)
@@ -311,11 +315,11 @@ class Piwik_Transitions_API
foreach ($data[$type] as &$record) {
$actions = intval($record[Metrics::INDEX_NB_ACTIONS]);
$dataTable->addRow(new Row(array(
- Row::COLUMNS => array(
- 'label' => $this->getPageLabel($record, $isTitle),
- Metrics::INDEX_NB_ACTIONS => $actions
- )
- )));
+ Row::COLUMNS => array(
+ 'label' => $this->getPageLabel($record, $isTitle),
+ Metrics::INDEX_NB_ACTIONS => $actions
+ )
+ )));
$this->totalTransitionsToFollowingActions += $actions;
}
}
@@ -325,7 +329,6 @@ class Piwik_Transitions_API
return $dataTables;
}
-
/**
* After calling this method, the query*()-Methods will return urls in their
* normalized form (without the prefix reconstructed)
@@ -389,7 +392,7 @@ class Piwik_Transitions_API
foreach ($subData as &$row) {
if ($referrerType == Common::REFERER_TYPE_SEARCH_ENGINE && empty($row['referrer_data'])) {
- $row['referrer_data'] = Piwik_Referers_API::LABEL_KEYWORD_NOT_DEFINED;
+ $row['referrer_data'] = \Piwik\Plugins\Referers\API::LABEL_KEYWORD_NOT_DEFINED;
}
$referrerData[$referrerType][Metrics::INDEX_NB_VISITS] += $row[Metrics::INDEX_NB_VISITS];
@@ -466,11 +469,11 @@ class Piwik_Transitions_API
foreach ($data['result'][1] as &$page) {
$nbActions = intval($page[Metrics::INDEX_NB_ACTIONS]);
$previousPagesDataTable->addRow(new Row(array(
- Row::COLUMNS => array(
- 'label' => $this->getPageLabel($page, $isTitle),
- Metrics::INDEX_NB_ACTIONS => $nbActions
- )
- )));
+ Row::COLUMNS => array(
+ 'label' => $this->getPageLabel($page, $isTitle),
+ Metrics::INDEX_NB_ACTIONS => $nbActions
+ )
+ )));
$nbPageviews += $nbActions;
}
}
@@ -480,11 +483,11 @@ class Piwik_Transitions_API
foreach ($data['result'][2] as &$search) {
$nbActions = intval($search[Metrics::INDEX_NB_ACTIONS]);
$previousSearchesDataTable->addRow(new Row(array(
- Row::COLUMNS => array(
- 'label' => $search['name'],
- Metrics::INDEX_NB_ACTIONS => $nbActions
- )
- )));
+ Row::COLUMNS => array(
+ 'label' => $search['name'],
+ Metrics::INDEX_NB_ACTIONS => $nbActions
+ )
+ )));
$nbPageviews += $nbActions;
}
}
@@ -513,7 +516,7 @@ class Piwik_Transitions_API
if ($isTitle) {
$label = $pageRecord['name'];
if (empty($label)) {
- $label = Piwik_Actions_ArchivingHelper::getUnknownActionName(
+ $label = ArchivingHelper::getUnknownActionName(
Action::TYPE_ACTION_NAME);
}
return $label;
@@ -538,7 +541,6 @@ class Piwik_Transitions_API
private $returnNormalizedUrls = false;
-
/**
* Get the sum of all transitions to following actions (pages, outlinks, downloads).
* Only works if queryFollowingActions() has been used directly before.
@@ -552,7 +554,7 @@ class Piwik_Transitions_API
* Add the external referrers to the report:
* direct entries, websites, campaigns, search engines
*
- * @param LogAggregator $logAggregator
+ * @param LogAggregator $logAggregator
* @param $report
* @param $idaction
* @param string $actionType
@@ -583,7 +585,7 @@ class Piwik_Transitions_API
}
$report['referrers'][] = array(
'label' => $this->getReferrerLabel($referrerId),
- 'shortName' => Piwik_getRefererTypeFromShortName($referrerId),
+ 'shortName' => \Piwik\Plugins\Referers\getRefererTypeFromShortName($referrerId),
'visits' => $visits,
'details' => $details
);
@@ -597,7 +599,7 @@ class Piwik_Transitions_API
if (count($report['referrers']) == 0) {
$report['referrers'][] = array(
'label' => $this->getReferrerLabel(Common::REFERER_TYPE_DIRECT_ENTRY),
- 'shortName' => Piwik_getRefererTypeLabel(Common::REFERER_TYPE_DIRECT_ENTRY),
+ 'shortName' => \Piwik\Plugins\Referers\getRefererTypeLabel(Common::REFERER_TYPE_DIRECT_ENTRY),
'visits' => 0
);
}
@@ -607,13 +609,13 @@ class Piwik_Transitions_API
{
switch ($referrerId) {
case Common::REFERER_TYPE_DIRECT_ENTRY:
- return Piwik_Transitions_Controller::getTranslation('directEntries');
+ return Controller::getTranslation('directEntries');
case Common::REFERER_TYPE_SEARCH_ENGINE:
- return Piwik_Transitions_Controller::getTranslation('fromSearchEngines');
+ return Controller::getTranslation('fromSearchEngines');
case Common::REFERER_TYPE_WEBSITE:
- return Piwik_Transitions_Controller::getTranslation('fromWebsites');
+ return Controller::getTranslation('fromWebsites');
case Common::REFERER_TYPE_CAMPAIGN:
- return Piwik_Transitions_Controller::getTranslation('fromCampaigns');
+ return Controller::getTranslation('fromCampaigns');
default:
return Piwik_Translate('General_Others');
}
@@ -621,8 +623,7 @@ class Piwik_Transitions_API
public function getTranslations()
{
- $controller = new Piwik_Transitions_Controller();
+ $controller = new Controller();
return $controller->getTranslations();
}
-
} \ No newline at end of file
diff --git a/plugins/Transitions/Controller.php b/plugins/Transitions/Controller.php
index 5178b1923f..172f7f1e90 100644
--- a/plugins/Transitions/Controller.php
+++ b/plugins/Transitions/Controller.php
@@ -6,15 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Transitions
+ * @package Transitions
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\Transitions;
+
use Piwik\View;
/**
- * @package Piwik_Transitions
+ * @package Transitions
*/
-class Piwik_Transitions_Controller extends Controller
+class Controller extends \Piwik\Controller
{
/**
@@ -89,5 +90,4 @@ class Piwik_Transitions_Controller extends Controller
}
return $translations;
}
-
}
diff --git a/plugins/Transitions/Transitions.php b/plugins/Transitions/Transitions.php
index b47db2e436..d0ea42d9b7 100644
--- a/plugins/Transitions/Transitions.php
+++ b/plugins/Transitions/Transitions.php
@@ -6,14 +6,15 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Transitions
+ * @package Transitions
*/
-use Piwik\Plugin;
+
+namespace Piwik\Plugins\Transitions;
/**
- * @package Piwik_Transitions
+ * @package Transitions
*/
-class Piwik_Transitions extends Plugin
+class Transitions extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/UserCountry/API.php b/plugins/UserCountry/API.php
index 62b472bbaa..a621b9344c 100644
--- a/plugins/UserCountry/API.php
+++ b/plugins/UserCountry/API.php
@@ -6,12 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry;
+
+use Exception;
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\DataTable;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\Archiver;
use Piwik\Tracker\Visit;
/**
@@ -21,9 +26,9 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/functions.php';
/**
* The UserCountry API lets you access reports about your visitors' Countries and Continents.
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_API
+class API
{
static private $instance = null;
@@ -37,12 +42,12 @@ class Piwik_UserCountry_API
public function getCountry($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserCountry_Archiver::COUNTRY_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::COUNTRY_RECORD_NAME, $idSite, $period, $date, $segment);
// apply filter on the whole datatable in order the inline search to work (searches are done on "beautiful" label)
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'code'));
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getFlagFromCode'));
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_CountryTranslate'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getFlagFromCode'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\countryTranslate'));
$dataTable->queueFilter('AddConstantMetadata', array('logoWidth', 16));
$dataTable->queueFilter('AddConstantMetadata', array('logoHeight', 11));
@@ -51,12 +56,12 @@ class Piwik_UserCountry_API
public function getContinent($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserCountry_Archiver::COUNTRY_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::COUNTRY_RECORD_NAME, $idSite, $period, $date, $segment);
$getContinent = array('Piwik\Common', 'getContinent');
$dataTable->filter('GroupBy', array('label', $getContinent));
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_ContinentTranslate'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\continentTranslate'));
$dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'code'));
return $dataTable;
@@ -73,31 +78,31 @@ class Piwik_UserCountry_API
*/
public function getRegion($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserCountry_Archiver::REGION_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::REGION_RECORD_NAME, $idSite, $period, $date, $segment);
- $separator = Piwik_UserCountry_Archiver::LOCATION_SEPARATOR;
+ $separator = Archiver::LOCATION_SEPARATOR;
$unk = Visit::UNKNOWN_CODE;
// split the label and put the elements into the 'region' and 'country' metadata fields
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'region', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 0, $unk)));
+ array('label', 'region', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 0, $unk)));
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'country', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 1, $unk)));
+ array('label', 'country', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 1, $unk)));
// add country name metadata
$dataTable->filter('MetadataCallbackAddMetadata',
- array('country', 'country_name', 'Piwik_CountryTranslate', $applyToSummaryRow = false));
+ array('country', 'country_name', __NAMESPACE__ . '\CountryTranslate', $applyToSummaryRow = false));
// get the region name of each row and put it into the 'region_name' metadata
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'region_name', 'Piwik_UserCountry_getRegionName', $params = null,
+ array('label', 'region_name', __NAMESPACE__ . '\getRegionName', $params = null,
$applyToSummaryRow = false));
// add the country flag as a url to the 'logo' metadata field
- $dataTable->filter('MetadataCallbackAddMetadata', array('country', 'logo', 'Piwik_getFlagFromCode'));
+ $dataTable->filter('MetadataCallbackAddMetadata', array('country', 'logo', __NAMESPACE__ . '\getFlagFromCode'));
// prettify the region label
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_UserCountry_getPrettyRegionName'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getPrettyRegionName'));
$dataTable->queueFilter('ReplaceSummaryRowLabel');
@@ -115,43 +120,43 @@ class Piwik_UserCountry_API
*/
public function getCity($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserCountry_Archiver::CITY_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::CITY_RECORD_NAME, $idSite, $period, $date, $segment);
- $separator = Piwik_UserCountry_Archiver::LOCATION_SEPARATOR;
+ $separator = Archiver::LOCATION_SEPARATOR;
$unk = Visit::UNKNOWN_CODE;
// split the label and put the elements into the 'city_name', 'region', 'country',
// 'lat' & 'long' metadata fields
$strUnknown = Piwik_Translate('General_Unknown');
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'city_name', 'Piwik_UserCountry_getElementFromStringArray',
+ array('label', 'city_name', __NAMESPACE__ . '\getElementFromStringArray',
array($separator, 0, $strUnknown)));
$dataTable->filter('MetadataCallbackAddMetadata',
array('city_name', 'city', create_function('$city', ' if ($city == "' . $strUnknown . '") { return "xx"; } else { return false; } ')));
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'region', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 1, $unk)));
+ array('label', 'region', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 1, $unk)));
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'country', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 2, $unk)));
+ array('label', 'country', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 2, $unk)));
// backwards compatibility: for reports that have lat|long in label
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'lat', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 3, false)));
+ array('label', 'lat', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 3, false)));
$dataTable->filter('ColumnCallbackAddMetadata',
- array('label', 'long', 'Piwik_UserCountry_getElementFromStringArray', array($separator, 4, false)));
+ array('label', 'long', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 4, false)));
// add country name & region name metadata
$dataTable->filter('MetadataCallbackAddMetadata',
- array('country', 'country_name', 'Piwik_CountryTranslate', $applyToSummaryRow = false));
+ array('country', 'country_name', __NAMESPACE__ . '\countryTranslate', $applyToSummaryRow = false));
- $getRegionName = array('Piwik_UserCountry_LocationProvider_GeoIp', 'getRegionNameFromCodes');
+ $getRegionName = '\\Piwik\\Plugins\\UserCountry\\LocationProvider\\GeoIp::getRegionNameFromCodes';
$dataTable->filter('MetadataCallbackAddMetadata', array(
array('country', 'region'), 'region_name', $getRegionName, $applyToSummaryRow = false));
// add the country flag as a url to the 'logo' metadata field
- $dataTable->filter('MetadataCallbackAddMetadata', array('country', 'logo', 'Piwik_getFlagFromCode'));
+ $dataTable->filter('MetadataCallbackAddMetadata', array('country', 'logo', __NAMESPACE__ . '\getFlagFromCode'));
// prettify the label
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_UserCountry_getPrettyCityName'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getPrettyCityName'));
$dataTable->queueFilter('ReplaceSummaryRowLabel');
@@ -161,7 +166,7 @@ class Piwik_UserCountry_API
/**
* Uses a location provider to find/guess the location of an IP address.
*
- * See Piwik_UserCountry_LocationProvider::getLocation to see the details
+ * See LocationProvider::getLocation to see the details
* of the result of this function.
*
* @param string $ip The IP address.
@@ -175,10 +180,10 @@ class Piwik_UserCountry_API
Piwik::checkUserHasSomeViewAccess();
if ($provider === false) {
- $provider = Piwik_UserCountry_LocationProvider::getCurrentProviderId();
+ $provider = LocationProvider::getCurrentProviderId();
}
- $oProvider = Piwik_UserCountry_LocationProvider::getProviderById($provider);
+ $oProvider = LocationProvider::getProviderById($provider);
if ($oProvider === false) {
throw new Exception("Cannot find the '$provider' provider. It is either an invalid provider "
. "ID or the ID of a provider that is not working.");
@@ -206,6 +211,6 @@ class Piwik_UserCountry_API
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Archive::build($idSite, $period, $date, $segment);
- return $archive->getDataTableFromNumeric(Piwik_UserCountry_Archiver::DISTINCT_COUNTRIES_METRIC);
+ return $archive->getDataTableFromNumeric(Archiver::DISTINCT_COUNTRIES_METRIC);
}
}
diff --git a/plugins/UserCountry/Archiver.php b/plugins/UserCountry/Archiver.php
index 656239ac24..5485d2fe98 100644
--- a/plugins/UserCountry/Archiver.php
+++ b/plugins/UserCountry/Archiver.php
@@ -6,16 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry;
+
use Piwik\ArchiveProcessor;
use Piwik\Metrics;
use Piwik\DataTable;
use Piwik\DataArray;
+use Piwik\Plugins\UserCountry\LocationProvider;
use Piwik\PluginsArchiver;
-class Piwik_UserCountry_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const COUNTRY_RECORD_NAME = 'UserCountry_country';
const REGION_RECORD_NAME = 'UserCountry_region';
@@ -35,16 +38,15 @@ class Piwik_UserCountry_Archiver extends PluginsArchiver
const CITY_FIELD = 'location_city';
- protected $dimensions = array( self::COUNTRY_FIELD, self::REGION_FIELD, self::CITY_FIELD );
+ protected $dimensions = array(self::COUNTRY_FIELD, self::REGION_FIELD, self::CITY_FIELD);
protected $arrays;
const LATITUDE_FIELD = 'location_latitude';
const LONGITUDE_FIELD = 'location_longitude';
-
public function archiveDay()
{
- foreach($this->dimensions as $dimension) {
+ foreach ($this->dimensions as $dimension) {
$this->arrays[$dimension] = new DataArray();
}
$this->aggregateFromVisits();
@@ -95,11 +97,12 @@ class Piwik_UserCountry_Archiver extends PluginsArchiver
protected function rememberCityLatLong($row)
{
- if ( !empty($row[self::CITY_FIELD])
+ if (!empty($row[self::CITY_FIELD])
&& !empty($row[self::LATITUDE_FIELD])
&& !empty($row[self::LONGITUDE_FIELD])
- && empty($this->latLongForCities[$row[self::CITY_FIELD]])) {
- $this->latLongForCities[$row[self::CITY_FIELD]] = array($row[self::LATITUDE_FIELD], $row[self::LONGITUDE_FIELD]);
+ && empty($this->latLongForCities[$row[self::CITY_FIELD]])
+ ) {
+ $this->latLongForCities[$row[self::CITY_FIELD]] = array($row[self::LATITUDE_FIELD], $row[self::LONGITUDE_FIELD]);
}
}
@@ -153,8 +156,8 @@ class Piwik_UserCountry_Archiver extends PluginsArchiver
if (isset($this->latLongForCities[$label])) {
// get lat/long for city
list($lat, $long) = $this->latLongForCities[$label];
- $lat = round($lat, Piwik_UserCountry_LocationProvider::GEOGRAPHIC_COORD_PRECISION);
- $long = round($long, Piwik_UserCountry_LocationProvider::GEOGRAPHIC_COORD_PRECISION);
+ $lat = round($lat, LocationProvider::GEOGRAPHIC_COORD_PRECISION);
+ $long = round($long, LocationProvider::GEOGRAPHIC_COORD_PRECISION);
// set latitude + longitude metadata
$row->setMetadata('lat', $lat);
@@ -175,5 +178,4 @@ class Piwik_UserCountry_Archiver extends PluginsArchiver
$this->getProcessor()->insertNumericRecord(self::DISTINCT_COUNTRIES_METRIC,
$nameToCount[self::COUNTRY_RECORD_NAME]['level0']);
}
-
} \ No newline at end of file
diff --git a/plugins/UserCountry/Controller.php b/plugins/UserCountry/Controller.php
index 1654885001..8fc88f80b5 100644
--- a/plugins/UserCountry/Controller.php
+++ b/plugins/UserCountry/Controller.php
@@ -6,23 +6,32 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-use Piwik\Controller\Admin;
+namespace Piwik\Plugins\UserCountry;
+
+use Admin;
+use Exception;
use Piwik\DataTable\Renderer\Json;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Http;
use Piwik\IP;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\GeoIPAutoUpdater;
use Piwik\ViewDataTable;
use Piwik\View;
use Piwik\Url;
+use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Pecl;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\ServerBased;
/**
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_Controller extends Admin
+class Controller extends \Piwik\Controller\Admin
{
public function index()
{
@@ -44,19 +53,19 @@ class Piwik_UserCountry_Controller extends Admin
Piwik::checkUserIsSuperUser();
$view = new View('@UserCountry/adminIndex');
- $allProviderInfo = Piwik_UserCountry_LocationProvider::getAllProviderInfo(
+ $allProviderInfo = LocationProvider::getAllProviderInfo(
$newline = '<br/>', $includeExtra = true);
$view->locationProviders = $allProviderInfo;
- $view->currentProviderId = Piwik_UserCountry_LocationProvider::getCurrentProviderId();
+ $view->currentProviderId = LocationProvider::getCurrentProviderId();
$view->thisIP = IP::getIpFromHeader();
- $geoIPDatabasesInstalled = Piwik_UserCountry_LocationProvider_GeoIp::isDatabaseInstalled();
+ $geoIPDatabasesInstalled = GeoIp::isDatabaseInstalled();
$view->geoIPDatabasesInstalled = $geoIPDatabasesInstalled;
// check if there is a working provider (that isn't the default one)
$isThereWorkingProvider = false;
foreach ($allProviderInfo as $id => $provider) {
- if ($id != Piwik_UserCountry_LocationProvider_Default::ID
- && $provider['status'] == Piwik_UserCountry_LocationProvider::INSTALLED
+ if ($id != DefaultProvider::ID
+ && $provider['status'] == LocationProvider::INSTALLED
) {
$isThereWorkingProvider = true;
break;
@@ -67,11 +76,11 @@ class Piwik_UserCountry_Controller extends Admin
// if using either the Apache or PECL module, they are working and there are no databases
// in misc, then the databases are located outside of Piwik, so we cannot update them
$view->showGeoIPUpdateSection = true;
- $currentProviderId = Piwik_UserCountry_LocationProvider::getCurrentProviderId();
+ $currentProviderId = LocationProvider::getCurrentProviderId();
if (!$geoIPDatabasesInstalled
- && ($currentProviderId == Piwik_UserCountry_LocationProvider_GeoIp_ServerBased::ID
- || $currentProviderId == Piwik_UserCountry_LocationProvider_GeoIp_Pecl::ID)
- && $allProviderInfo[$currentProviderId]['status'] == Piwik_UserCountry_LocationProvider::INSTALLED
+ && ($currentProviderId == ServerBased::ID
+ || $currentProviderId == Pecl::ID)
+ && $allProviderInfo[$currentProviderId]['status'] == LocationProvider::INSTALLED
) {
$view->showGeoIPUpdateSection = false;
}
@@ -106,23 +115,23 @@ class Piwik_UserCountry_Controller extends Admin
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
Json::sendHeaderJSON();
- $outputPath = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase('GeoIPCity.dat') . '.gz';
+ $outputPath = GeoIp::getPathForGeoIpDatabase('GeoIPCity.dat') . '.gz';
try {
$result = Http::downloadChunk(
- $url = Piwik_UserCountry_LocationProvider_GeoIp::GEO_LITE_URL,
+ $url = GeoIp::GEO_LITE_URL,
$outputPath,
$continue = Common::getRequestVar('continue', true, 'int')
);
// if the file is done
if ($result['current_size'] >= $result['expected_file_size']) {
- Piwik_UserCountry_GeoIPAutoUpdater::unzipDownloadedFile($outputPath, $unlink = true);
+ GeoIPAutoUpdater::unzipDownloadedFile($outputPath, $unlink = true);
// setup the auto updater
- Piwik_UserCountry_GeoIPAutoUpdater::setUpdaterOptions(array(
- 'loc_db' => Piwik_UserCountry_LocationProvider_GeoIp::GEO_LITE_URL,
- 'period' => Piwik_UserCountry_GeoIPAutoUpdater::SCHEDULE_PERIOD_MONTHLY,
- ));
+ GeoIPAutoUpdater::setUpdaterOptions(array(
+ 'loc_db' => GeoIp::GEO_LITE_URL,
+ 'period' => GeoIPAutoUpdater::SCHEDULE_PERIOD_MONTHLY,
+ ));
// make sure to echo out the geoip updater management screen
$result['next_screen'] = $this->getGeoIpUpdaterManageScreen();
@@ -155,16 +164,16 @@ class Piwik_UserCountry_Controller extends Admin
*/
private function setUpdaterManageVars($view)
{
- $urls = Piwik_UserCountry_GeoIPAutoUpdater::getConfiguredUrls();
+ $urls = GeoIPAutoUpdater::getConfiguredUrls();
$view->geoIPLocUrl = $urls['loc'];
$view->geoIPIspUrl = $urls['isp'];
$view->geoIPOrgUrl = $urls['org'];
- $view->geoIPUpdatePeriod = Piwik_UserCountry_GeoIPAutoUpdater::getSchedulePeriod();
+ $view->geoIPUpdatePeriod = GeoIPAutoUpdater::getSchedulePeriod();
- $view->geoLiteUrl = Piwik_UserCountry_LocationProvider_GeoIp::GEO_LITE_URL;
+ $view->geoLiteUrl = GeoIp::GEO_LITE_URL;
- $lastRunTime = Piwik_UserCountry_GeoIPAutoUpdater::getLastRunTime();
+ $lastRunTime = GeoIPAutoUpdater::getLastRunTime();
if ($lastRunTime !== false) {
$view->lastTimeUpdaterRun = '<strong><em>' . $lastRunTime->toString() . '</em></strong>';
}
@@ -191,7 +200,7 @@ class Piwik_UserCountry_Controller extends Admin
try {
$this->checkTokenInUrl();
- Piwik_UserCountry_GeoIPAutoUpdater::setUpdaterOptionsFromUrl();
+ GeoIPAutoUpdater::setUpdaterOptionsFromUrl();
// if there is a updater URL for a database, but its missing from the misc dir, tell
// the browser so it can download it next
@@ -237,15 +246,15 @@ class Piwik_UserCountry_Controller extends Admin
// based on the database type (provided by the 'key' query param) determine the
// url & output file name
$key = Common::getRequestVar('key', null, 'string');
- $url = Piwik_UserCountry_GeoIPAutoUpdater::getConfiguredUrl($key);
+ $url = GeoIPAutoUpdater::getConfiguredUrl($key);
- $ext = Piwik_UserCountry_GeoIPAutoUpdater::getGeoIPUrlExtension($url);
- $filename = Piwik_UserCountry_LocationProvider_GeoIp::$dbNames[$key][0] . '.' . $ext;
+ $ext = GeoIPAutoUpdater::getGeoIPUrlExtension($url);
+ $filename = GeoIp::$dbNames[$key][0] . '.' . $ext;
if (substr($filename, 0, 15) == 'GeoLiteCity.dat') {
$filename = 'GeoIPCity.dat' . substr($filename, 15);
}
- $outputPath = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase($filename);
+ $outputPath = GeoIp::getPathForGeoIpDatabase($filename);
// download part of the file
$result = Http::downloadChunk(
@@ -253,7 +262,7 @@ class Piwik_UserCountry_Controller extends Admin
// if the file is done
if ($result['current_size'] >= $result['expected_file_size']) {
- Piwik_UserCountry_GeoIPAutoUpdater::unzipDownloadedFile($outputPath, $unlink = true);
+ GeoIPAutoUpdater::unzipDownloadedFile($outputPath, $unlink = true);
$info = $this->getNextMissingDbUrlInfo();
if ($info !== false) {
@@ -285,7 +294,7 @@ class Piwik_UserCountry_Controller extends Admin
$this->checkTokenInUrl();
$providerId = Common::getRequestVar('id');
- $provider = Piwik_UserCountry_LocationProvider::setCurrentProvider($providerId);
+ $provider = LocationProvider::setCurrentProvider($providerId);
if ($provider === false) {
throw new Exception("Invalid provider ID: '$providerId'.");
}
@@ -305,7 +314,7 @@ class Piwik_UserCountry_Controller extends Admin
public function getLocationUsingProvider()
{
$providerId = Common::getRequestVar('id');
- $provider = $provider = Piwik_UserCountry_LocationProvider::getProviderById($providerId);
+ $provider = $provider = LocationProvider::getProviderById($providerId);
if ($provider === false) {
throw new Exception("Invalid provider ID: '$providerId'.");
}
@@ -313,7 +322,7 @@ class Piwik_UserCountry_Controller extends Admin
$location = $provider->getLocation(array('ip' => IP::getIpFromHeader(),
'lang' => Common::getBrowserLanguage(),
'disable_fallbacks' => true));
- $location = Piwik_UserCountry_LocationProvider::prettyFormatLocation(
+ $location = LocationProvider::prettyFormatLocation(
$location, $newline = '<br/>', $includeExtra = true);
echo $location;
@@ -370,11 +379,11 @@ class Piwik_UserCountry_Controller extends Admin
*/
private function getNextMissingDbUrlInfo()
{
- $missingDbs = Piwik_UserCountry_GeoIPAutoUpdater::getMissingDatabases();
+ $missingDbs = GeoIPAutoUpdater::getMissingDatabases();
if (!empty($missingDbs)) {
$missingDbKey = $missingDbs[0];
- $missingDbName = Piwik_UserCountry_LocationProvider_GeoIp::$dbNames[$missingDbKey][0];
- $url = Piwik_UserCountry_GeoIPAutoUpdater::getConfiguredUrl($missingDbKey);
+ $missingDbName = GeoIp::$dbNames[$missingDbKey][0];
+ $url = GeoIPAutoUpdater::getConfiguredUrl($missingDbKey);
$link = '<a href="' . $url . '">' . $missingDbName . '</a>';
diff --git a/plugins/UserCountry/GeoIPAutoUpdater.php b/plugins/UserCountry/GeoIPAutoUpdater.php
index 66ec7bd343..86383ed4d8 100755
--- a/plugins/UserCountry/GeoIPAutoUpdater.php
+++ b/plugins/UserCountry/GeoIPAutoUpdater.php
@@ -6,22 +6,28 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
use Piwik\Http;
+use Piwik\Plugins\UserCountry\LocationProvider;
use Piwik\ScheduledTime\Monthly;
use Piwik\ScheduledTime\Weekly;
use Piwik\Unzip;
use Piwik\ScheduledTask;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Php;
/**
* Used to automatically update installed GeoIP databases, and manages the updater's
* scheduled task.
*/
-class Piwik_UserCountry_GeoIPAutoUpdater
+class GeoIPAutoUpdater
{
const SCHEDULE_PERIOD_MONTHLY = 'month';
const SCHEDULE_PERIOD_WEEKLY = 'week';
@@ -71,7 +77,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater
$this->downloadFile('org', $orgUrl);
}
} catch (Exception $ex) {
- // message will already be prefixed w/ 'Piwik_UserCountry_GeoIPAutoUpdater: '
+ // message will already be prefixed w/ 'GeoIPAutoUpdater: '
Piwik::log($ex->getMessage());
$this->performRedundantDbChecks();
throw $ex;
@@ -94,34 +100,34 @@ class Piwik_UserCountry_GeoIPAutoUpdater
*/
protected function downloadFile($dbType, $url)
{
- $ext = Piwik_UserCountry_GeoIPAutoUpdater::getGeoIPUrlExtension($url);
- $zippedFilename = Piwik_UserCountry_LocationProvider_GeoIp::$dbNames[$dbType][0] . '.' . $ext;
+ $ext = GeoIPAutoUpdater::getGeoIPUrlExtension($url);
+ $zippedFilename = GeoIp::$dbNames[$dbType][0] . '.' . $ext;
- $zippedOutputPath = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase($zippedFilename);
+ $zippedOutputPath = GeoIp::getPathForGeoIpDatabase($zippedFilename);
// download zipped file to misc dir
try {
$success = Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath);
} catch (Exception $ex) {
- throw new Exception("Piwik_UserCountry_GeoIPAutoUpdater: failed to download '$url' to "
+ throw new Exception("GeoIPAutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath': " . $ex->getMessage());
}
if ($success !== true) {
- throw new Exception("Piwik_UserCountry_GeoIPAutoUpdater: failed to download '$url' to "
+ throw new Exception("GeoIPAutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath'! (Unknown error)");
}
- Piwik::log(sprintf("Piwik_UserCountry_GeoIPAutoUpdater: successfully downloaded '%s'", $url));
+ Piwik::log(sprintf("GeoIPAutoUpdater: successfully downloaded '%s'", $url));
try {
self::unzipDownloadedFile($zippedOutputPath, $unlink = true);
} catch (Exception $ex) {
- throw new Exception("Piwik_UserCountry_GeoIPAutoUpdater: failed to unzip '$zippedOutputPath' after "
+ throw new Exception("GeoIPAutoUpdater: failed to unzip '$zippedOutputPath' after "
. "downloading " . "'$url': " . $ex->getMessage());
}
- Piwik::log(sprintf("Piwik_UserCountry_GeoIPAutoUpdater: successfully updated GeoIP database '%s'", $url));
+ Piwik::log(sprintf("GeoIPAutoUpdater: successfully updated GeoIP database '%s'", $url));
}
/**
@@ -138,7 +144,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater
$dbFilename = $filenameStart . '.dat';
$tempFilename = $filenameStart . '.dat.new';
- $outputPath = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase($tempFilename);
+ $outputPath = GeoIp::getPathForGeoIpDatabase($tempFilename);
// extract file
if (substr($path, -7, 7) == '.tar.gz') {
@@ -191,7 +197,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater
try {
// test that the new archive is a valid GeoIP database
- $dbType = Piwik_UserCountry_LocationProvider_GeoIp::getGeoIPDatabaseTypeFromFilename($dbFilename);
+ $dbType = GeoIp::getGeoIPDatabaseTypeFromFilename($dbFilename);
if ($dbType === false) // sanity check
{
throw new Exception("Unexpected GeoIP archive file name '$path'.");
@@ -204,7 +210,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater
);
$customDbNames[$dbType] = array($tempFilename);
- $phpProvider = new Piwik_UserCountry_LocationProvider_GeoIp_Php($customDbNames);
+ $phpProvider = new Php($customDbNames);
$location = self::getTestLocationCatchPhpErrors($phpProvider);
@@ -213,7 +219,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater
) {
if (self::$unzipPhpError !== null) {
list($errno, $errstr, $errfile, $errline) = self::$unzipPhpError;
- Piwik::log("Piwik_UserCountry_GeoIPAutoUpdater: Encountered PHP error when testing newly downloaded" .
+ Piwik::log("GeoIPAutoUpdater: Encountered PHP error when testing newly downloaded" .
" GeoIP database: $errno: $errstr on line $errline of $errfile.");
}
@@ -221,12 +227,12 @@ class Piwik_UserCountry_GeoIPAutoUpdater
}
// delete the existing GeoIP database (if any) and rename the downloaded file
- $oldDbFile = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase($dbFilename);
+ $oldDbFile = GeoIp::getPathForGeoIpDatabase($dbFilename);
if (file_exists($oldDbFile)) {
unlink($oldDbFile);
}
- $tempFile = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase($tempFilename);
+ $tempFile = GeoIp::getPathForGeoIpDatabase($tempFilename);
rename($existing = $tempFile, $newName = $oldDbFile);
// delete original archive
@@ -251,7 +257,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater
*/
public static function makeScheduledTask()
{
- $instance = new Piwik_UserCountry_GeoIPAutoUpdater();
+ $instance = new GeoIPAutoUpdater();
$schedulePeriodStr = self::getSchedulePeriod();
@@ -379,7 +385,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater
*/
public static function performUpdate()
{
- $instance = new Piwik_UserCountry_GeoIPAutoUpdater();
+ $instance = new GeoIPAutoUpdater();
$instance->update();
}
@@ -412,8 +418,8 @@ class Piwik_UserCountry_GeoIPAutoUpdater
if (!empty($url)) {
// if a database of the type does not exist, but there's a url to update, then
// a database is missing
- $path = Piwik_UserCountry_LocationProvider_GeoIp::getPathToGeoIpDatabase(
- Piwik_UserCountry_LocationProvider_GeoIp::$dbNames[$key]);
+ $path = GeoIp::getPathToGeoIpDatabase(
+ GeoIp::$dbNames[$key]);
if ($path === false) {
$result[] = $key;
}
@@ -465,7 +471,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater
* Tests a location provider using a test IP address and catches PHP errors
* (ie, notices) if they occur. PHP error information is held in self::$unzipPhpError.
*
- * @param Piwik_UserCountry_LocationProvider $provider The provider to test.
+ * @param LocationProvider $provider The provider to test.
* @return array|false $location The result of geolocation. False if no location
* can be found.
*/
@@ -475,9 +481,9 @@ class Piwik_UserCountry_GeoIPAutoUpdater
// in order to delete the files in such a case (which can be caused by a man-in-the-middle attack)
// we need to catch them, so we set a new error handler.
self::$unzipPhpError = null;
- set_error_handler(array('Piwik_UserCountry_GeoIPAutoUpdater', 'catchGeoIPError'));
+ set_error_handler(array('Piwik\Plugins\UserCountry\GeoIPAutoUpdater', 'catchGeoIPError'));
- $location = $provider->getLocation(array('ip' => Piwik_UserCountry_LocationProvider_GeoIp::TEST_IP));
+ $location = $provider->getLocation(array('ip' => GeoIp::TEST_IP));
restore_error_handler();
@@ -496,7 +502,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater
*/
protected function performRedundantDbChecks()
{
- $databaseTypes = array_keys(Piwik_UserCountry_LocationProvider_GeoIp::$dbNames);
+ $databaseTypes = array_keys(GeoIp::$dbNames);
foreach ($databaseTypes as $type) {
$customNames = array(
@@ -504,16 +510,16 @@ class Piwik_UserCountry_GeoIPAutoUpdater
'isp' => array(),
'org' => array()
);
- $customNames[$type] = Piwik_UserCountry_LocationProvider_GeoIp::$dbNames[$type];
+ $customNames[$type] = GeoIp::$dbNames[$type];
// create provider that only uses the DB type we're testing
- $provider = new Piwik_UserCountry_LocationProvider_GeoIp_Php($customNames);
+ $provider = new Php($customNames);
// test the provider. on error, we rename the broken DB.
self::getTestLocationCatchPhpErrors($provider);
if (self::$unzipPhpError !== null) {
list($errno, $errstr, $errfile, $errline) = self::$unzipPhpError;
- Piwik::log("Piwik_UserCountry_GeoIPAutoUpdater: Encountered PHP error when performing redundant " .
+ Piwik::log("GeoIPAutoUpdater: Encountered PHP error when performing redundant " .
"tests on GeoIP $type database: $errno: $errstr on line $errline of $errfile.");
// get the current filename for the DB and an available new one to rename it to
@@ -543,7 +549,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater
*/
private function getOldAndNewPathsForBrokenDb($possibleDbNames)
{
- $pathToDb = Piwik_UserCountry_LocationProvider_GeoIp::getPathToGeoIpDatabase($possibleDbNames);
+ $pathToDb = GeoIp::getPathToGeoIpDatabase($possibleDbNames);
$newPath = false;
if ($pathToDb !== false) {
diff --git a/plugins/UserCountry/LocationProvider.php b/plugins/UserCountry/LocationProvider.php
index bb82ebc9f5..946e131f19 100755
--- a/plugins/UserCountry/LocationProvider.php
+++ b/plugins/UserCountry/LocationProvider.php
@@ -6,11 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry;
+
+use Exception;
use Piwik\Common;
use Piwik\IP;
use Piwik\Tracker\Cache;
+use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider;
+use ReflectionClass;
/**
* @see plugins/UserCountry/LocationProvider/Default.php
@@ -29,7 +34,7 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/LocationProvider/GeoIp.p
* visitor info. All LocationProviders require a visitor's IP address, some
* require more, such as the browser language.
*/
-abstract class Piwik_UserCountry_LocationProvider
+abstract class LocationProvider
{
const NOT_INSTALLED = 0;
const INSTALLED = 1;
@@ -139,7 +144,7 @@ abstract class Piwik_UserCountry_LocationProvider
if (is_null(self::$providers)) {
self::$providers = array();
foreach (get_declared_classes() as $klass) {
- if (is_subclass_of($klass, 'Piwik_UserCountry_LocationProvider')) {
+ if (is_subclass_of($klass, 'Piwik\Plugins\UserCountry\LocationProvider')) {
$klassInfo = new ReflectionClass($klass);
if ($klassInfo->isAbstract()) {
continue;
@@ -188,7 +193,7 @@ abstract class Piwik_UserCountry_LocationProvider
* 'geoip_php' => array('id' => 'geoip_php',
* 'title' => '...',
* 'desc' => '...',
- * 'status' => Piwik_UserCountry_LocationProvider_GeoIp::BROKEN,
+ * 'status' => GeoIp::BROKEN,
* 'statusMessage' => '...',
* 'location' => '...')
* 'geoip_serverbased' => array(...)
@@ -259,7 +264,7 @@ abstract class Piwik_UserCountry_LocationProvider
public static function getCurrentProviderId()
{
$optionValue = Piwik_GetOption(self::CURRENT_PROVIDER_OPTION_NAME);
- return $optionValue === false ? Piwik_UserCountry_LocationProvider_Default::ID : $optionValue;
+ return $optionValue === false ? DefaultProvider::ID : $optionValue;
}
/**
@@ -267,7 +272,7 @@ abstract class Piwik_UserCountry_LocationProvider
*
* This function should not be called by the Tracker.
*
- * @return Piwik_UserCountry_LocationProvider
+ * @return \Piwik\Plugins\UserCountry\LocationProvider
*/
public static function getCurrentProvider()
{
@@ -278,7 +283,7 @@ abstract class Piwik_UserCountry_LocationProvider
* Sets the provider to use when tracking.
*
* @param string $providerId The ID of the provider to use.
- * @return Piwik_UserCountry_LocationProvider The new current provider.
+ * @return \Piwik\Plugins\UserCountry\LocationProvider The new current provider.
* @throws Exception If the provider ID is invalid.
*/
public static function setCurrentProvider($providerId)
@@ -297,7 +302,7 @@ abstract class Piwik_UserCountry_LocationProvider
* Returns a provider instance by ID or false if the ID is invalid or unavailable.
*
* @param string $providerId
- * @return Piwik_UserCountry_LocationProvider|false
+ * @return \Piwik\Plugins\UserCountry\LocationProvider|false
*/
public static function getProviderById($providerId)
{
diff --git a/plugins/UserCountry/LocationProvider/Default.php b/plugins/UserCountry/LocationProvider/Default.php
index f5956076b6..a8eeb1688d 100755
--- a/plugins/UserCountry/LocationProvider/Default.php
+++ b/plugins/UserCountry/LocationProvider/Default.php
@@ -6,18 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry\LocationProvider;
+
use Piwik\Config;
use Piwik\Common;
+use Piwik\Plugins\UserCountry\LocationProvider;
/**
* The default LocationProvider, this LocationProvider guesses a visitor's country
* using the language they use. This provider is not very accurate.
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_LocationProvider_Default extends Piwik_UserCountry_LocationProvider
+class DefaultProvider extends LocationProvider
{
const ID = 'default';
const TITLE = 'General_Default';
diff --git a/plugins/UserCountry/LocationProvider/GeoIp.php b/plugins/UserCountry/LocationProvider/GeoIp.php
index 5cf139ac12..b40783d7c4 100755
--- a/plugins/UserCountry/LocationProvider/GeoIp.php
+++ b/plugins/UserCountry/LocationProvider/GeoIp.php
@@ -6,15 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry\LocationProvider;
+
+use Exception;
+use Piwik\Plugins\UserCountry\LocationProvider;
/**
* Base type for all GeoIP LocationProviders.
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-abstract class Piwik_UserCountry_LocationProvider_GeoIp extends Piwik_UserCountry_LocationProvider
+abstract class GeoIp extends LocationProvider
{
/* For testing, use: 'http://piwik-team.s3.amazonaws.com/GeoLiteCity.dat.gz' */
const GEO_LITE_URL = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz';
@@ -255,7 +259,6 @@ abstract class Piwik_UserCountry_LocationProvider_GeoIp extends Piwik_UserCountr
}
}
-
/**
* @see plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php
*/
diff --git a/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php b/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php
index 9ffc4ffa0a..c4113fd9e8 100755
--- a/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php
+++ b/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
/**
* A LocationProvider that uses the PECL implementation of GeoIP.
@@ -15,9 +18,9 @@
* FIXME: For some reason, if the PECL module is loaded & an organization DB is available, the PHP
* module won't return organization info. If the PECL module is not loaded, organization info is returned.
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_LocationProvider_GeoIp_Pecl extends Piwik_UserCountry_LocationProvider_GeoIp
+class Pecl extends GeoIp
{
const ID = 'geoip_pecl';
const TITLE = 'GeoIP (PECL)';
diff --git a/plugins/UserCountry/LocationProvider/GeoIp/Php.php b/plugins/UserCountry/LocationProvider/GeoIp/Php.php
index 001b7f8c4e..dc54f5b29c 100755
--- a/plugins/UserCountry/LocationProvider/GeoIp/Php.php
+++ b/plugins/UserCountry/LocationProvider/GeoIp/Php.php
@@ -6,16 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+
use Piwik\Piwik;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
/**
* A LocationProvider that uses the PHP implementation of GeoIP.
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_LocationProvider_GeoIp_Php extends Piwik_UserCountry_LocationProvider_GeoIp
+class Php extends GeoIp
{
const ID = 'geoip_php';
const TITLE = 'GeoIP (Php)';
@@ -38,7 +41,7 @@ class Piwik_UserCountry_LocationProvider_GeoIp_Php extends Piwik_UserCountry_Loc
* This variable is an array mapping either the 'loc', 'isp' or 'org' strings with
* an array of filenames.
*
- * By default, this will be set to Piwik_UserCountry_LocationProvider_GeoIp_Php::$dbNames.
+ * By default, this will be set to Php::$dbNames.
*
* @var array
*/
diff --git a/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php b/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php
index ab3942974f..7d2be065d2 100755
--- a/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php
+++ b/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php
@@ -6,11 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+
use Piwik\Common;
use Piwik\IP;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Pecl;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Php;
/**
* A LocationProvider that uses an GeoIP module installed in an HTTP Server.
@@ -18,9 +24,9 @@ use Piwik\IP;
* To make this provider available, make sure the GEOIP_ADDR server
* variable is set.
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry_LocationProvider_GeoIp_ServerBased extends Piwik_UserCountry_LocationProvider_GeoIp
+class ServerBased extends GeoIp
{
const ID = 'geoip_serverbased';
const TITLE = 'GeoIP (%s)';
@@ -74,11 +80,11 @@ class Piwik_UserCountry_LocationProvider_GeoIp_ServerBased extends Piwik_UserCou
) {
Common::printDebug("The request is for IP address: " . $info['ip'] . " but your IP is: $myIP. GeoIP Server Module (apache/nginx) does not support this use case... ");
$fallbacks = array(
- Piwik_UserCountry_LocationProvider_GeoIp_Pecl::ID,
- Piwik_UserCountry_LocationProvider_GeoIp_Php::ID
+ Pecl::ID,
+ Php::ID
);
foreach ($fallbacks as $fallbackProviderId) {
- $otherProvider = Piwik_UserCountry_LocationProvider::getProviderById($fallbackProviderId);
+ $otherProvider = LocationProvider::getProviderById($fallbackProviderId);
if ($otherProvider) {
Common::printDebug("Used $fallbackProviderId to detect this visitor IP");
return $otherProvider->getLocation($info);
diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php
index 282c433563..a2fcc00992 100644
--- a/plugins/UserCountry/UserCountry.php
+++ b/plugins/UserCountry/UserCountry.php
@@ -6,13 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+namespace Piwik\Plugins\UserCountry;
+
use Piwik\ArchiveProcessor;
use Piwik\Common;
use Piwik\Piwik;
-use Piwik\Plugin;
use Piwik\WidgetsList;
+use Piwik_Url;
+use Piwik\Plugins\UserCountry\Archiver;
+use Piwik\Plugins\UserCountry\GeoIPAutoUpdater;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
/**
* @see plugins/UserCountry/GeoIPAutoUpdater.php
@@ -21,9 +28,9 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/GeoIPAutoUpdater.php';
/**
*
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
-class Piwik_UserCountry extends Plugin
+class UserCountry extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -31,18 +38,18 @@ class Piwik_UserCountry extends Plugin
public function getListHooksRegistered()
{
$hooks = array(
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenu',
- 'AdminMenu.add' => 'addAdminMenu',
- 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
- 'API.getReportMetadata' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
- 'AssetManager.getCssFiles' => 'getCssFiles',
- 'AssetManager.getJsFiles' => 'getJsFiles',
- 'Tracker.getVisitorLocation' => 'getVisitorLocation',
- 'TaskScheduler.getScheduledTasks' => 'getScheduledTasks',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenu',
+ 'AdminMenu.add' => 'addAdminMenu',
+ 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
+ 'API.getReportMetadata' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'AssetManager.getCssFiles' => 'getCssFiles',
+ 'AssetManager.getJsFiles' => 'getJsFiles',
+ 'Tracker.getVisitorLocation' => 'getVisitorLocation',
+ 'TaskScheduler.getScheduledTasks' => 'getScheduledTasks',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
return $hooks;
@@ -51,7 +58,7 @@ class Piwik_UserCountry extends Plugin
public function getScheduledTasks(&$tasks)
{
// add the auto updater task
- $tasks[] = Piwik_UserCountry_GeoIPAutoUpdater::makeScheduledTask();
+ $tasks[] = GeoIPAutoUpdater::makeScheduledTask();
}
public function getCssFiles(&$cssFiles)
@@ -69,10 +76,10 @@ class Piwik_UserCountry extends Plugin
require_once PIWIK_INCLUDE_PATH . "/plugins/UserCountry/LocationProvider.php";
$id = Common::getCurrentLocationProviderId();
- $provider = Piwik_UserCountry_LocationProvider::getProviderById($id);
+ $provider = LocationProvider::getProviderById($id);
if ($provider === false) {
- $id = Piwik_UserCountry_LocationProvider_Default::ID;
- $provider = Piwik_UserCountry_LocationProvider::getProviderById($id);
+ $id = DefaultProvider::ID;
+ $provider = LocationProvider::getProviderById($id);
Common::printDebug("GEO: no current location provider sent, falling back to default '$id' one.");
}
@@ -80,8 +87,8 @@ class Piwik_UserCountry extends Plugin
// if we can't find a location, use default provider
if ($location === false) {
- $defaultId = Piwik_UserCountry_LocationProvider_Default::ID;
- $provider = Piwik_UserCountry_LocationProvider::getProviderById($defaultId);
+ $defaultId = DefaultProvider::ID;
+ $provider = LocationProvider::getProviderById($defaultId);
$location = $provider->getLocation($visitorInfo);
Common::printDebug("GEO: couldn't find a location with Geo Module '$id', using Default '$defaultId' provider as fallback...");
$id = $defaultId;
@@ -139,7 +146,7 @@ class Piwik_UserCountry extends Plugin
'segment' => 'continentCode',
'sqlSegment' => 'log_visit.location_country',
'acceptedValues' => 'eur, asi, amc, amn, ams, afr, ant, oce',
- 'sqlFilter' => array('Piwik_UserCountry', 'getCountriesForContinent'),
+ 'sqlFilter' => __NAMESPACE__ . '\UserCountry::getCountriesForContinent',
);
$segments[] = array(
'type' => 'dimension',
@@ -250,21 +257,20 @@ class Piwik_UserCountry extends Plugin
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_UserCountry_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_UserCountry_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
-
/**
* Returns a list of country codes for a given continent code.
*
@@ -296,10 +302,10 @@ class Piwik_UserCountry extends Plugin
{
return array(
'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'filter_limit' => 5,
- 'translations' => array('label' => Piwik_Translate('UserCountry_Country')),
- 'documentation' => Piwik_Translate('UserCountry_getCountryDocumentation')
+ 'show_goals' => true,
+ 'filter_limit' => 5,
+ 'translations' => array('label' => Piwik_Translate('UserCountry_Country')),
+ 'documentation' => Piwik_Translate('UserCountry_getCountryDocumentation')
);
}
@@ -307,12 +313,12 @@ class Piwik_UserCountry extends Plugin
{
return array(
'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'show_search' => false,
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'translations' => array('label' => Piwik_Translate('UserCountry_Continent')),
- 'documentation' => Piwik_Translate('UserCountry_getContinentDocumentation')
+ 'show_goals' => true,
+ 'show_search' => false,
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'translations' => array('label' => Piwik_Translate('UserCountry_Continent')),
+ 'documentation' => Piwik_Translate('UserCountry_getContinentDocumentation')
);
}
@@ -320,11 +326,11 @@ class Piwik_UserCountry extends Plugin
{
$result = array(
'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'filter_limit' => 5,
- 'translations' => array('label' => Piwik_Translate('UserCountry_Region')),
- 'documentation' => Piwik_Translate('UserCountry_getRegionDocumentation') . '<br/>'
- . $this->getGeoIPReportDocSuffix()
+ 'show_goals' => true,
+ 'filter_limit' => 5,
+ 'translations' => array('label' => Piwik_Translate('UserCountry_Region')),
+ 'documentation' => Piwik_Translate('UserCountry_getRegionDocumentation') . '<br/>'
+ . $this->getGeoIPReportDocSuffix()
);
$this->checkIfNoDataForGeoIpReport($result);
return $result;
@@ -334,11 +340,11 @@ class Piwik_UserCountry extends Plugin
{
$result = array(
'show_exclude_low_population' => false,
- 'show_goals' => true,
- 'filter_limit' => 5,
- 'translations' => array('label' => Piwik_Translate('UserCountry_City')),
- 'documentation' => Piwik_Translate('UserCountry_getCityDocumentation') . '<br/>'
- . $this->getGeoIPReportDocSuffix()
+ 'show_goals' => true,
+ 'filter_limit' => 5,
+ 'translations' => array('label' => Piwik_Translate('UserCountry_City')),
+ 'documentation' => Piwik_Translate('UserCountry_getCityDocumentation') . '<br/>'
+ . $this->getGeoIPReportDocSuffix()
);
$this->checkIfNoDataForGeoIpReport($result);
return $result;
@@ -393,8 +399,8 @@ class Piwik_UserCountry extends Plugin
*/
public function isGeoIPWorking()
{
- $provider = Piwik_UserCountry_LocationProvider::getCurrentProvider();
- return $provider instanceof Piwik_UserCountry_LocationProvider_GeoIp
+ $provider = LocationProvider::getCurrentProvider();
+ return $provider instanceof GeoIp
&& $provider->isAvailable() === true
&& $provider->isWorking() === true;
}
diff --git a/plugins/UserCountry/functions.php b/plugins/UserCountry/functions.php
index cdc408a273..cae545f521 100644
--- a/plugins/UserCountry/functions.php
+++ b/plugins/UserCountry/functions.php
@@ -6,9 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountry
+ * @package UserCountry
*/
+
+namespace Piwik\Plugins\UserCountry;
+
use Piwik\DataTable;
+use Piwik\Plugins\UserCountry\Archiver;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
use Piwik\Tracker\Visit;
/**
@@ -17,7 +22,7 @@ use Piwik\Tracker\Visit;
* @param string $code ISO country code
* @return string Flag image path
*/
-function Piwik_getFlagFromCode($code)
+function getFlagFromCode($code)
{
$pathInPiwik = 'plugins/UserCountry/images/flags/%s.png';
$pathWithCode = sprintf($pathInPiwik, $code);
@@ -34,7 +39,7 @@ function Piwik_getFlagFromCode($code)
* @param string $label Continent code
* @return string Continent name
*/
-function Piwik_ContinentTranslate($label)
+function continentTranslate($label)
{
if ($label == 'unk' || $label == '') {
return Piwik_Translate('General_Unknown');
@@ -48,7 +53,7 @@ function Piwik_ContinentTranslate($label)
* @param string $label country code
* @return string Country name
*/
-function Piwik_CountryTranslate($label)
+function countryTranslate($label)
{
if ($label == Visit::UNKNOWN_CODE || $label == '') {
return Piwik_Translate('General_Unknown');
@@ -67,7 +72,7 @@ function Piwik_CountryTranslate($label)
* @return string|false Returns false if $label == DataTable::LABEL_SUMMARY_ROW, otherwise
* explode($separator, $label)[$index].
*/
-function Piwik_UserCountry_getElementFromStringArray($label, $separator, $index, $emptyValue = false)
+function getElementFromStringArray($label, $separator, $index, $emptyValue = false)
{
if ($label == DataTable::LABEL_SUMMARY_ROW) {
return false; // so no metadata/column is added
@@ -84,7 +89,7 @@ function Piwik_UserCountry_getElementFromStringArray($label, $separator, $index,
* 'P3|GB'.
* @return string|false The region name or false if $label == DataTable::LABEL_SUMMARY_ROW.
*/
-function Piwik_UserCountry_getRegionName($label)
+function getRegionName($label)
{
if ($label == DataTable::LABEL_SUMMARY_ROW) {
return false; // so no metadata/column is added
@@ -94,8 +99,8 @@ function Piwik_UserCountry_getRegionName($label)
return Piwik_Translate('General_Unknown');
}
- list($regionCode, $countryCode) = explode(Piwik_UserCountry_Archiver::LOCATION_SEPARATOR, $label);
- return Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
+ list($regionCode, $countryCode) = explode(Archiver::LOCATION_SEPARATOR, $label);
+ return GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
}
/**
@@ -106,7 +111,7 @@ function Piwik_UserCountry_getRegionName($label)
* 'P3|GB'.
* @return string|false eg. 'Ile de France, France' or false if $label == DataTable::LABEL_SUMMARY_ROW.
*/
-function Piwik_UserCountry_getPrettyRegionName($label)
+function getPrettyRegionName($label)
{
if ($label == DataTable::LABEL_SUMMARY_ROW) {
return $label;
@@ -116,11 +121,11 @@ function Piwik_UserCountry_getPrettyRegionName($label)
return Piwik_Translate('General_Unknown');
}
- list($regionCode, $countryCode) = explode(Piwik_UserCountry_Archiver::LOCATION_SEPARATOR, $label);
+ list($regionCode, $countryCode) = explode(Archiver::LOCATION_SEPARATOR, $label);
- $result = Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
+ $result = GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
if ($countryCode != Visit::UNKNOWN_CODE && $countryCode != '') {
- $result .= ', ' . Piwik_CountryTranslate($countryCode);
+ $result .= ', ' . countryTranslate($countryCode);
}
return $result;
}
@@ -134,7 +139,7 @@ function Piwik_UserCountry_getPrettyRegionName($label)
* @return string|false eg. 'Paris, Ile de France, France' or false if $label ==
* DataTable::LABEL_SUMMARY_ROW.
*/
-function Piwik_UserCountry_getPrettyCityName($label)
+function getPrettyCityName($label)
{
if ($label == DataTable::LABEL_SUMMARY_ROW) {
return $label;
@@ -145,7 +150,7 @@ function Piwik_UserCountry_getPrettyCityName($label)
}
// get city name, region code & country code
- $parts = explode(Piwik_UserCountry_Archiver::LOCATION_SEPARATOR, $label);
+ $parts = explode(Archiver::LOCATION_SEPARATOR, $label);
$cityName = $parts[0];
$regionCode = $parts[1];
$countryCode = @$parts[2];
@@ -157,10 +162,10 @@ function Piwik_UserCountry_getPrettyCityName($label)
$result = $cityName;
if ($countryCode != Visit::UNKNOWN_CODE && $countryCode != '') {
if ($regionCode != '' && $regionCode != Visit::UNKNOWN_CODE) {
- $regionName = Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
+ $regionName = GeoIp::getRegionNameFromCodes($countryCode, $regionCode);
$result .= ', ' . $regionName;
}
- $result .= ', ' . Piwik_CountryTranslate($countryCode);
+ $result .= ', ' . countryTranslate($countryCode);
}
return $result;
}
diff --git a/plugins/UserCountryMap/Controller.php b/plugins/UserCountryMap/Controller.php
index d057c728c7..d81f4003d8 100644
--- a/plugins/UserCountryMap/Controller.php
+++ b/plugins/UserCountryMap/Controller.php
@@ -6,12 +6,15 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountryMap
+ * @package UserCountryMap
*/
+namespace Piwik\Plugins\UserCountryMap;
+
+use Exception;
use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
+use Piwik\Plugins\Goals\API;
use Piwik\ViewDataTable;
use Piwik\View;
use Piwik\Site;
@@ -19,9 +22,9 @@ use Piwik\Config;
/**
*
- * @package Piwik_UserCountryMap
+ * @package UserCountryMap
*/
-class Piwik_UserCountryMap_Controller extends Controller
+class Controller extends \Piwik\Controller
{
// By default plot up to the last 30 days of visitors on the map, for low traffic sites
@@ -65,16 +68,16 @@ class Piwik_UserCountryMap_Controller extends Controller
// some translations
$view->localeJSON = Common::json_encode(array(
- 'nb_visits' => Piwik_Translate('VisitsSummary_NbVisits'),
- 'one_visit' => Piwik_Translate('General_OneVisit'),
- 'no_visit' => Piwik_Translate('UserCountryMap_NoVisit'),
- 'nb_actions' => Piwik_Translate('VisitsSummary_NbActionsDescription'),
- 'nb_actions_per_visit' => Piwik_Translate('VisitsSummary_NbActionsPerVisit'),
- 'bounce_rate' => Piwik_Translate('VisitsSummary_NbVisitsBounced'),
- 'avg_time_on_site' => Piwik_Translate('VisitsSummary_AverageVisitDuration'),
- 'and_n_others' => Piwik_Translate('UserCountryMap_AndNOthers'),
- 'no_data' => Piwik_Translate('CoreHome_ThereIsNoDataForThisReport')
- ));
+ 'nb_visits' => Piwik_Translate('VisitsSummary_NbVisits'),
+ 'one_visit' => Piwik_Translate('General_OneVisit'),
+ 'no_visit' => Piwik_Translate('UserCountryMap_NoVisit'),
+ 'nb_actions' => Piwik_Translate('VisitsSummary_NbActionsDescription'),
+ 'nb_actions_per_visit' => Piwik_Translate('VisitsSummary_NbActionsPerVisit'),
+ 'bounce_rate' => Piwik_Translate('VisitsSummary_NbVisitsBounced'),
+ 'avg_time_on_site' => Piwik_Translate('VisitsSummary_AverageVisitDuration'),
+ 'and_n_others' => Piwik_Translate('UserCountryMap_AndNOthers'),
+ 'no_data' => Piwik_Translate('CoreHome_ThereIsNoDataForThisReport')
+ ));
$view->reqParamsJSON = $this->getEnrichedRequest($params = array(
'period' => $period,
@@ -126,7 +129,7 @@ class Piwik_UserCountryMap_Controller extends Controller
$view->defaultMetric = 'nb_visits';
$view->liveRefreshAfterMs = (int)Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000;
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
$site = new Site($idSite);
$view->hasGoals = !empty($goals) || $site->isEcommerceEnabled() ? 'true' : 'false';
@@ -151,11 +154,11 @@ class Piwik_UserCountryMap_Controller extends Controller
));
$view->reqParamsJSON = $this->getEnrichedRequest(array(
- 'period' => 'range',
- 'idSite' => $idSite,
- 'date' => self::REAL_TIME_WINDOW,
- 'token_auth' => $token_auth,
- ));
+ 'period' => 'range',
+ 'idSite' => $idSite,
+ 'date' => self::REAL_TIME_WINDOW,
+ 'token_auth' => $token_auth,
+ ));
echo $view->render();
}
@@ -165,16 +168,13 @@ class Piwik_UserCountryMap_Controller extends Controller
$params['format'] = 'json';
$params['showRawMetrics'] = 1;
$segment = \Piwik\API\Request::getRawSegmentFromRequest();
- if (!empty($segment)
- && !empty($params['segment'])
- ) {
+ if (!empty($segment)) {
$params['segment'] = $segment;
}
return Common::json_encode($params);
}
-
private function checkUserCountryPluginEnabled()
{
if (!\Piwik\PluginsManager::getInstance()->isPluginActivated('UserCountry')) {
@@ -236,4 +236,4 @@ class Piwik_UserCountryMap_Controller extends Controller
return $this->getApiRequestUrl('API', 'getProcessedReport&apiModule=' . $module . '&apiAction=' . $action,
$idSite, $period, $date, $token_auth, $filter_by_country, $segmentOverride);
}
-} \ No newline at end of file
+}
diff --git a/plugins/UserCountryMap/UserCountryMap.php b/plugins/UserCountryMap/UserCountryMap.php
index 19e0c34590..66da62b137 100644
--- a/plugins/UserCountryMap/UserCountryMap.php
+++ b/plugins/UserCountryMap/UserCountryMap.php
@@ -6,18 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserCountryMap
+ * @package UserCountryMap
*/
+namespace Piwik\Plugins\UserCountryMap;
+
use Piwik\FrontController;
use Piwik\Version;
use Piwik\WidgetsList;
-use Piwik\Plugin;
/**
*
- * @package Piwik_UserCountryMap
+ * @package UserCountryMap
*/
-class Piwik_UserCountryMap extends Plugin
+class UserCountryMap extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getInformation
@@ -38,7 +39,7 @@ class Piwik_UserCountryMap extends Plugin
WidgetsList::add('General_Visitors', Piwik_Translate('UserCountryMap_VisitorMap'), 'UserCountryMap', 'visitorMap');
WidgetsList::add('Live!', Piwik_Translate('UserCountryMap_RealTimeMap'), 'UserCountryMap', 'realtimeMap');
- Piwik_AddAction('template_leftColumnUserCountry', array('Piwik_UserCountryMap', 'insertMapInLocationReport'));
+ Piwik_AddAction('template_leftColumnUserCountry', array('Piwik\Plugins\UserCountryMap\UserCountryMap', 'insertMapInLocationReport'));
}
static public function insertMapInLocationReport(&$out)
diff --git a/plugins/UserSettings/API.php b/plugins/UserSettings/API.php
index c1c5535c1c..9e0fdf12f3 100644
--- a/plugins/UserSettings/API.php
+++ b/plugins/UserSettings/API.php
@@ -6,12 +6,15 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
+namespace Piwik\Plugins\UserSettings;
+
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\DataTable;
+use Piwik\Plugins\UserSettings\Archiver;
/**
* @see plugins/UserSettings/functions.php
@@ -22,9 +25,9 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/UserSettings/functions.php';
* The UserSettings API lets you access reports about your Visitors technical settings: browsers, browser types (rendering engine),
* operating systems, plugins supported in their browser, Screen resolution and Screen types (normal, widescreen, dual screen or mobile).
*
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
-class Piwik_UserSettings_API
+class API
{
static private $instance = null;
@@ -49,27 +52,27 @@ class Piwik_UserSettings_API
public function getResolution($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::RESOLUTION_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::RESOLUTION_RECORD_NAME, $idSite, $period, $date, $segment);
return $dataTable;
}
public function getConfiguration($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::CONFIGURATION_RECORD_NAME, $idSite, $period, $date, $segment);
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getConfigurationLabel'));
+ $dataTable = $this->getDataTable(Archiver::CONFIGURATION_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getConfigurationLabel'));
return $dataTable;
}
public function getOS($idSite, $period, $date, $segment = false, $addShortLabel = true)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::OS_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::OS_RECORD_NAME, $idSite, $period, $date, $segment);
// these filters are applied directly so other API methods can use GroupBy on the result of this method
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getOSLogo'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOSLogo'));
if ($addShortLabel) {
$dataTable->filter(
- 'ColumnCallbackAddMetadata', array('label', 'shortLabel', 'Piwik_getOSShortLabel'));
+ 'ColumnCallbackAddMetadata', array('label', 'shortLabel', __NAMESPACE__ . '\getOSShortLabel'));
}
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getOSLabel'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getOSLabel'));
return $dataTable;
}
@@ -80,7 +83,7 @@ class Piwik_UserSettings_API
public function getOSFamily($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getOS($idSite, $period, $date, $segment, $addShortLabel = false);
- $dataTable->filter('GroupBy', array('label', 'Piwik_UserSettings_getOSFamily'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getOSFamily'));
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_Translate'));
return $dataTable;
}
@@ -91,12 +94,12 @@ class Piwik_UserSettings_API
public function getMobileVsDesktop($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getOS($idSite, $period, $date, $segment, $addShortLabel = false);
- $dataTable->filter('GroupBy', array('label', 'Piwik_UserSettings_getDeviceTypeFromOS'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getDeviceTypeFromOS'));
$this->ensureDefaultRowsInTable($dataTable);
// set the logo metadata
$dataTable->queueFilter('MetadataCallbackReplace',
- array('logo', 'Piwik_UserSettings_getDeviceTypeImg', null, array('label')));
+ array('logo', __NAMESPACE__ . '\getDeviceTypeImg', null, array('label')));
// translate the labels
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_Translate'));
@@ -133,15 +136,15 @@ class Piwik_UserSettings_API
public function getBrowserVersion($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getBrowserTable($idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'shortLabel', 'Piwik_getBrowserShortLabel'));
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'shortLabel', __NAMESPACE__ . '\getBrowserShortLabel'));
return $dataTable;
}
protected function getBrowserTable($idSite, $period, $date, $segment)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::BROWSER_RECORD_NAME, $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getBrowsersLogo'));
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getBrowserLabel'));
+ $dataTable = $this->getDataTable(Archiver::BROWSER_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowsersLogo'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getBrowserLabel'));
return $dataTable;
}
@@ -152,22 +155,22 @@ class Piwik_UserSettings_API
public function getBrowser($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getBrowserTable($idSite, $period, $date, $segment);
- $dataTable->filter('GroupBy', array('label', 'Piwik_UserSettings_getBrowserFromBrowserVersion'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserFromBrowserVersion'));
return $dataTable;
}
public function getBrowserType($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::BROWSER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::BROWSER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
$dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'shortLabel', 'ucfirst'));
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getBrowserTypeLabel'));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getBrowserTypeLabel'));
return $dataTable;
}
public function getWideScreen($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::SCREEN_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getScreensLogo'));
+ $dataTable = $this->getDataTable(Archiver::SCREEN_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getScreensLogo'));
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'ucfirst'));
return $dataTable;
}
@@ -175,8 +178,8 @@ class Piwik_UserSettings_API
public function getPlugin($idSite, $period, $date, $segment = false)
{
// fetch all archive data required
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::PLUGIN_RECORD_NAME, $idSite, $period, $date, $segment);
- $browserTypes = $this->getDataTable(Piwik_UserSettings_Archiver::BROWSER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::PLUGIN_RECORD_NAME, $idSite, $period, $date, $segment);
+ $browserTypes = $this->getDataTable(Archiver::BROWSER_TYPE_RECORD_NAME, $idSite, $period, $date, $segment);
$archive = Archive::build($idSite, $period, $date, $segment);
$visitsSums = $archive->getDataTableFromNumeric('nb_visits');
@@ -225,7 +228,6 @@ class Piwik_UserSettings_API
$visitsSum = $visitsSumTotal - $ieVisits;
-
// When Truncate filter is applied, it will call AddSummaryRow which tries to sum all rows.
// We tell the object to skip the column nb_visits_percentage when aggregating (since it's not correct to sum % values)
$table->setColumnAggregationOperation('nb_visits_percentage', 'skip');
@@ -236,7 +238,7 @@ class Piwik_UserSettings_API
$table->filter('RangeCheck', array('nb_visits_percentage'));
}
- $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getPluginsLogo'));
+ $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getPluginsLogo'));
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'ucfirst'));
return $dataTable;
@@ -244,8 +246,8 @@ class Piwik_UserSettings_API
public function getLanguage($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_UserSettings_Archiver::LANGUAGE_RECORD_NAME, $idSite, $period, $date, $segment);
- $dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_LanguageTranslate'));
+ $dataTable = $this->getDataTable(Archiver::LANGUAGE_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\languageTranslate'));
$dataTable->filter('ReplaceColumnNames');
return $dataTable;
}
diff --git a/plugins/UserSettings/Archiver.php b/plugins/UserSettings/Archiver.php
index d6ff51d459..d25420ec20 100644
--- a/plugins/UserSettings/Archiver.php
+++ b/plugins/UserSettings/Archiver.php
@@ -6,9 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
+namespace Piwik\Plugins\UserSettings;
+
use Piwik\Common;
use Piwik\DataAccess\LogAggregator;
use Piwik\Metrics;
@@ -23,7 +25,7 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/UserSettings/functions.php';
*
* @see PluginsArchiver
*/
-class Piwik_UserSettings_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const LANGUAGE_RECORD_NAME = 'UserSettings_language';
const PLUGIN_RECORD_NAME = 'UserSettings_plugin';
@@ -80,7 +82,7 @@ class Piwik_UserSettings_Archiver extends PluginsArchiver
protected function aggregateByBrowserType(DataTable $tableBrowser)
{
- $tableBrowser->filter('GroupBy', array('label', 'Piwik_getBrowserFamily'));
+ $tableBrowser->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserFamily'));
$this->insertTable(self::BROWSER_TYPE_RECORD_NAME, $tableBrowser);
}
@@ -94,14 +96,14 @@ class Piwik_UserSettings_Archiver extends PluginsArchiver
{
$metrics = $this->getProcessor()->getMetricsForDimension(self::RESOLUTION_DIMENSION);
$table = $this->getProcessor()->getDataTableFromDataArray($metrics);
- $table->filter('ColumnCallbackDeleteRow', array('label', 'Piwik_UserSettings_keepStrlenGreater'));
+ $table->filter('ColumnCallbackDeleteRow', array('label', __NAMESPACE__ . '\keepStrlenGreater'));
$this->insertTable(self::RESOLUTION_RECORD_NAME, $table);
return $table;
}
protected function aggregateByScreenType(DataTable $resolutions)
{
- $resolutions->filter('GroupBy', array('label', 'Piwik_getScreenTypeFromResolution'));
+ $resolutions->filter('GroupBy', array('label', __NAMESPACE__ . '\getScreenTypeFromResolution'));
$this->insertTable(self::SCREEN_TYPE_RECORD_NAME, $resolutions);
}
@@ -129,7 +131,7 @@ class Piwik_UserSettings_Archiver extends PluginsArchiver
protected function aggregateByLanguage()
{
- $query = $this->getLogAggregator()->queryVisitsByDimension( array("label" => self::LANGUAGE_DIMENSION) );
+ $query = $this->getLogAggregator()->queryVisitsByDimension(array("label" => self::LANGUAGE_DIMENSION));
$languageCodes = array_keys(Common::getLanguagesList());
$metricsByLanguage = new DataArray();
while ($row = $query->fetch()) {
diff --git a/plugins/UserSettings/Controller.php b/plugins/UserSettings/Controller.php
index b5180359f8..3bdd3e8f5d 100644
--- a/plugins/UserSettings/Controller.php
+++ b/plugins/UserSettings/Controller.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\UserSettings;
+
use Piwik\ViewDataTable;
use Piwik\View;
/**
*
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
-class Piwik_UserSettings_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
@@ -33,12 +34,12 @@ class Piwik_UserSettings_Controller extends Controller
echo $view->render();
}
-
+
public function getResolution($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
}
-
+
public function getConfiguration($fetch = false)
{
return ViewDataTable::renderReport($this->pluginName, __FUNCTION__, $fetch);
diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php
index 46568956f9..ba52b97d0d 100644
--- a/plugins/UserSettings/UserSettings.php
+++ b/plugins/UserSettings/UserSettings.php
@@ -6,17 +6,19 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
+namespace Piwik\Plugins\UserSettings;
+
use Piwik\ArchiveProcessor;
-use Piwik\Plugin;
+use Piwik\Plugins\UserSettings\Archiver;
use Piwik\WidgetsList;
/**
*
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
-class Piwik_UserSettings extends Plugin
+class UserSettings extends \Piwik\Plugin
{
/**
* Mapping between the browser family shortcode and the displayed name
@@ -433,8 +435,8 @@ class Piwik_UserSettings extends Plugin
*/
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_UserSettings_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
@@ -444,8 +446,8 @@ class Piwik_UserSettings extends Plugin
*/
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_UserSettings_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
diff --git a/plugins/UserSettings/functions.php b/plugins/UserSettings/functions.php
index 41269b773b..28215d2e44 100644
--- a/plugins/UserSettings/functions.php
+++ b/plugins/UserSettings/functions.php
@@ -6,17 +6,22 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UserSettings
+ * @package UserSettings
*/
+
+namespace Piwik\Plugins\UserSettings;
+
use Piwik\Piwik;
+use Piwik\Plugins\UserSettings\UserSettings;
use Piwik\Tracker\Request;
+use UserAgentParser;
/**
* @see libs/UserAgentParser/UserAgentParser.php
*/
require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php';
-function Piwik_getPluginsLogo($oldLabel)
+function getPluginsLogo($oldLabel)
{
if($oldLabel == Piwik_Translate('General_Others')) {
return false;
@@ -24,7 +29,7 @@ function Piwik_getPluginsLogo($oldLabel)
return 'plugins/UserSettings/images/plugins/' . $oldLabel . '.gif';
}
-function Piwik_getOSLabel($osId)
+function getOSLabel($osId)
{
$osName = UserAgentParser::getOperatingSystemNameFromId($osId);
if ($osName !== false) {
@@ -36,7 +41,7 @@ function Piwik_getOSLabel($osId)
return $osId;
}
-function Piwik_getOSShortLabel($osId)
+function getOSShortLabel($osId)
{
$osShortName = UserAgentParser::getOperatingSystemShortNameFromId($osId);
if ($osShortName !== false) {
@@ -49,7 +54,7 @@ function Piwik_getOSShortLabel($osId)
}
-function Piwik_UserSettings_getOSFamily($osLabel)
+function getOSFamily($osLabel)
{
$osId = UserAgentParser::getOperatingSystemIdFromName($osLabel);
$osFamily = UserAgentParser::getOperatingSystemFamilyFromId($osId);
@@ -63,7 +68,7 @@ function Piwik_UserSettings_getOSFamily($osLabel)
return $osFamily;
}
-function Piwik_UserSettings_getDeviceTypeFromOS($osLabel)
+function getDeviceTypeFromOS($osLabel)
{
$osId = UserAgentParser::getOperatingSystemIdFromName($osLabel);
$osFamily = UserAgentParser::getOperatingSystemFamilyFromId($osId);
@@ -88,10 +93,10 @@ function Piwik_UserSettings_getDeviceTypeFromOS($osLabel)
}
}
-function Piwik_getBrowserTypeLabel($oldLabel)
+function getBrowserTypeLabel($oldLabel)
{
- if (isset(Piwik_UserSettings::$browserType_display[$oldLabel])) {
- return Piwik_UserSettings::$browserType_display[$oldLabel];
+ if (isset(UserSettings::$browserType_display[$oldLabel])) {
+ return UserSettings::$browserType_display[$oldLabel];
}
if ($oldLabel == 'unknown') {
return Piwik_Translate('General_Unknown');
@@ -100,14 +105,14 @@ function Piwik_getBrowserTypeLabel($oldLabel)
}
-function Piwik_getConfigurationLabel($str)
+function getConfigurationLabel($str)
{
if (strpos($str, ';') === false) {
return $str;
}
$values = explode(";", $str);
- $os = Piwik_getOSLabel($values[0]);
+ $os = getOSLabel($values[0]);
$name = $values[1];
$browser = UserAgentParser::getBrowserNameFromId($name);
if ($browser === false) {
@@ -117,10 +122,10 @@ function Piwik_getConfigurationLabel($str)
return $os . " / " . $browser . " / " . $resolution;
}
-function Piwik_getBrowserLabel($oldLabel)
+function getBrowserLabel($oldLabel)
{
- $browserId = Piwik_getBrowserId($oldLabel);
- $version = Piwik_getBrowserVersion($oldLabel);
+ $browserId = getBrowserId($oldLabel);
+ $version = getBrowserVersion($oldLabel);
$browserName = UserAgentParser::getBrowserNameFromId($browserId);
if ($browserName !== false) {
return $browserName . " " . $version;
@@ -131,10 +136,10 @@ function Piwik_getBrowserLabel($oldLabel)
return $oldLabel;
}
-function Piwik_getBrowserShortLabel($oldLabel)
+function getBrowserShortLabel($oldLabel)
{
- $browserId = Piwik_getBrowserId($oldLabel);
- $version = Piwik_getBrowserVersion($oldLabel);
+ $browserId = getBrowserId($oldLabel);
+ $version = getBrowserVersion($oldLabel);
$browserName = UserAgentParser::getBrowserShortNameFromId($browserId);
if ($browserName !== false) {
return $browserName . " " . $version;
@@ -145,17 +150,17 @@ function Piwik_getBrowserShortLabel($oldLabel)
return $oldLabel;
}
-function Piwik_getBrowserId($str)
+function getBrowserId($str)
{
return substr($str, 0, strpos($str, ';'));
}
-function Piwik_getBrowserVersion($str)
+function getBrowserVersion($str)
{
return substr($str, strpos($str, ';') + 1);
}
-function Piwik_getLogoImageFromId($dir, $id)
+function getLogoImageFromId($dir, $id)
{
$path = $dir.'/'.$id.'.gif';
if (file_exists(PIWIK_INCLUDE_PATH . '/' . $path)) {
@@ -165,31 +170,31 @@ function Piwik_getLogoImageFromId($dir, $id)
}
}
-function Piwik_getBrowsersLogo($label)
+function getBrowsersLogo($label)
{
- $id = Piwik_getBrowserId($label);
+ $id = getBrowserId($label);
// For aggregated row 'Others'
if (empty($id)) {
$id = 'UNK';
}
- return Piwik_getLogoImageFromId('plugins/UserSettings/images/browsers', $id);
+ return getLogoImageFromId('plugins/UserSettings/images/browsers', $id);
}
-function Piwik_getOSLogo($label)
+function getOSLogo($label)
{
// For aggregated row 'Others'
if (empty($label)) {
$label = 'UNK';
}
- return Piwik_getLogoImageFromId('plugins/UserSettings/images/os', $label);
+ return getLogoImageFromId('plugins/UserSettings/images/os', $label);
}
-function Piwik_getScreensLogo($label)
+function getScreensLogo($label)
{
return 'plugins/UserSettings/images/screens/' . $label . '.gif';
}
-function Piwik_UserSettings_getDeviceTypeImg($oldOSImage, $osFamilyLabel)
+function getDeviceTypeImg($oldOSImage, $osFamilyLabel)
{
switch ($osFamilyLabel) {
case 'General_Desktop':
@@ -202,12 +207,12 @@ function Piwik_UserSettings_getDeviceTypeImg($oldOSImage, $osFamilyLabel)
}
}
-function Piwik_UserSettings_keepStrlenGreater($value)
+function keepStrlenGreater($value)
{
return strlen($value) > 5;
}
-function Piwik_getScreenTypeFromResolution($resolution)
+function getScreenTypeFromResolution($resolution)
{
if ($resolution === Request::UNKNOWN_RESOLUTION) {
return $resolution;
@@ -229,7 +234,7 @@ function Piwik_getScreenTypeFromResolution($resolution)
return $name;
}
-function Piwik_getBrowserFamily($browserLabel)
+function getBrowserFamily($browserLabel)
{
$familyNameToUse = UserAgentParser::getBrowserFamilyFromId(substr($browserLabel, 0, 2));
return $familyNameToUse;
@@ -238,7 +243,7 @@ function Piwik_getBrowserFamily($browserLabel)
/**
* Extracts the browser name from a string with the browser name and version.
*/
-function Piwik_UserSettings_getBrowserFromBrowserVersion($browserWithVersion)
+function getBrowserFromBrowserVersion($browserWithVersion)
{
if (preg_match("/(.+) [0-9]+(?:\.[0-9]+)?$/", $browserWithVersion, $matches) === 0) {
return $browserWithVersion;
@@ -254,7 +259,7 @@ function Piwik_UserSettings_getBrowserFromBrowserVersion($browserWithVersion)
*
* @return string
*/
-function Piwik_LanguageTranslate($label)
+function languageTranslate($label)
{
if ($label == '' || $label == 'xx') {
return Piwik_Translate('General_Unknown');
diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php
index 104961c951..1649cdaca7 100644
--- a/plugins/UsersManager/API.php
+++ b/plugins/UsersManager/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
+namespace Piwik\Plugins\UsersManager;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
@@ -16,6 +19,7 @@ use Piwik\Date;
use Piwik\Site;
use Piwik\Db;
use Piwik\Tracker\Cache;
+use Piwik\Plugins\UsersManager\UsersManager;
/**
* The UsersManager API lets you Manage Users and their permissions to access specific websites.
@@ -28,13 +32,13 @@ use Piwik\Tracker\Cache;
* or you can list all users and websites for a given permission via "getUsersSitesFromAccess". Permissions are set and updated
* via the method "setUserAccess".
* See also the documentation about <a href='http://piwik.org/docs/manage-users/' target='_blank'>Managing Users</a> in Piwik.
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
-class Piwik_UsersManager_API
+class API
{
const PREFERENCE_DEFAULT_REPORT = 'defaultReport';
const PREFERENCE_DEFAULT_REPORT_DATE = 'defaultReportDate';
-
+
static private $instance = null;
/**
@@ -45,15 +49,15 @@ class Piwik_UsersManager_API
* \Zend_Registry::set('UsersManager_API',Piwik_MyCustomUsersManager_API::getInstance());
*
* @throws Exception
- * @return Piwik_UsersManager_API
+ * @return \Piwik\Plugins\UsersManager\API
*/
static public function getInstance()
{
try {
$instance = \Zend_Registry::get('UsersManager_API');
- if (!($instance instanceof Piwik_UsersManager_API)) {
+ if (!($instance instanceof API)) {
// Exception is caught below and corrected
- throw new Exception('UsersManager_API must inherit Piwik_UsersManager_API');
+ throw new Exception('UsersManager_API must inherit API');
}
self::$instance = $instance;
} catch (Exception $e) {
@@ -85,7 +89,7 @@ class Piwik_UsersManager_API
public function getUserPreference($userLogin, $preferenceName)
{
Piwik::checkUserIsSuperUserOrTheUser($userLogin);
-
+
$optionValue = Piwik_GetOption($this->getPreferenceId($userLogin, $preferenceName));
if ($optionValue !== false) {
return $optionValue;
@@ -97,12 +101,12 @@ class Piwik_UsersManager_API
{
return $login . '_' . $preference;
}
-
+
private function getDefaultUserPreference($preferenceName, $login)
{
switch ($preferenceName) {
case self::PREFERENCE_DEFAULT_REPORT:
- $viewableSiteIds = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess($login);
+ $viewableSiteIds = \Piwik\Plugins\SitesManager\API::getInstance()->getSitesIdWithAtLeastViewAccess($login);
return reset($viewableSiteIds);
case self::PREFERENCE_DEFAULT_REPORT_DATE:
return Config::getInstance()->General['default_day'];
@@ -131,7 +135,7 @@ class Piwik_UsersManager_API
$db = \Zend_Registry::get('db');
$users = $db->fetchAll("SELECT *
FROM " . Common::prefixTable("user") . "
- $where
+ $where
ORDER BY login ASC", $bind);
// Non Super user can only access login & alias
if (!Piwik::isUserIsSuperUser()) {
@@ -193,7 +197,6 @@ class Piwik_UsersManager_API
$return[$user['login']][] = $user['idsite'];
}
return $return;
-
}
/**
@@ -373,23 +376,23 @@ class Piwik_UsersManager_API
$this->checkEmail($email);
$password = Common::unsanitizeInputValue($password);
- Piwik_UsersManager::checkPassword($password);
+ UsersManager::checkPassword($password);
$alias = $this->getCleanAlias($alias, $userLogin);
- $passwordTransformed = Piwik_UsersManager::getPasswordHash($password);
+ $passwordTransformed = UsersManager::getPasswordHash($password);
$token_auth = $this->getTokenAuth($userLogin, $passwordTransformed);
$db = \Zend_Registry::get('db');
$db->insert(Common::prefixTable("user"), array(
- 'login' => $userLogin,
- 'password' => $passwordTransformed,
- 'alias' => $alias,
- 'email' => $email,
- 'token_auth' => $token_auth,
- 'date_registered' => Date::now()->getDatetime()
- )
+ 'login' => $userLogin,
+ 'password' => $passwordTransformed,
+ 'alias' => $alias,
+ 'email' => $email,
+ 'token_auth' => $token_auth,
+ 'date_registered' => Date::now()->getDatetime()
+ )
);
// we reload the access list which doesn't yet take in consideration this new user
@@ -420,8 +423,8 @@ class Piwik_UsersManager_API
} else {
$password = Common::unsanitizeInputValue($password);
if (!$_isPasswordHashed) {
- Piwik_UsersManager::checkPassword($password);
- $password = Piwik_UsersManager::getPasswordHash($password);
+ UsersManager::checkPassword($password);
+ $password = UsersManager::getPasswordHash($password);
}
}
@@ -541,7 +544,7 @@ class Piwik_UsersManager_API
// in case idSites is null we grant access to all the websites on which the current connected user
// has an 'admin' access
if ($idSites === 'all') {
- $idSites = Piwik_SitesManager_API::getInstance()->getSitesIdWithAdminAccess();
+ $idSites = \Piwik\Plugins\SitesManager\API::getInstance()->getSitesIdWithAdminAccess();
} // in case the idSites is an integer we build an array
else {
$idSites = Site::getIdSitesFromIdSitesString($idSites);
@@ -643,7 +646,6 @@ class Piwik_UsersManager_API
Piwik_PostEvent('UsersManager.deleteUser', array($userLogin));
}
-
/**
* Delete the user access for the given websites.
* The array of idsite must be either null OR the values must have been checked before for their validity!
diff --git a/plugins/UsersManager/Controller.php b/plugins/UsersManager/Controller.php
index bedf2bb5fb..1ead3ed8eb 100644
--- a/plugins/UsersManager/Controller.php
+++ b/plugins/UsersManager/Controller.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
+namespace Piwik\Plugins\UsersManager;
+
+use Exception;
use Piwik\API\ResponseBuilder;
use Piwik\Controller\Admin;
use Piwik\Piwik;
@@ -17,12 +20,14 @@ use Piwik\Tracker\IgnoreCookie;
use Piwik\View;
use Piwik\Url;
use Piwik\Site;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
/**
*
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
-class Piwik_UsersManager_Controller extends Admin
+class Controller extends Admin
{
static function orderByName($a, $b)
{
@@ -38,7 +43,7 @@ class Piwik_UsersManager_Controller extends Admin
$view = new View('@UsersManager/index');
- $IdSitesAdmin = Piwik_SitesManager_API::getInstance()->getSitesIdWithAdminAccess();
+ $IdSitesAdmin = SitesManagerAPI::getInstance()->getSitesIdWithAdminAccess();
$idSiteSelected = 1;
if (count($IdSitesAdmin) > 0) {
@@ -50,13 +55,13 @@ class Piwik_UsersManager_Controller extends Admin
$usersAccessByWebsite = array();
$defaultReportSiteName = Piwik_Translate('UsersManager_ApplyToAllWebsites');
} else {
- $usersAccessByWebsite = Piwik_UsersManager_API::getInstance()->getUsersAccessFromSite($idSiteSelected);
+ $usersAccessByWebsite = UsersManagerAPI::getInstance()->getUsersAccessFromSite($idSiteSelected);
$defaultReportSiteName = Site::getNameFor($idSiteSelected);
}
// we dont want to display the user currently logged so that the user can't change his settings from admin to view...
$currentlyLogged = Piwik::getCurrentUserLogin();
- $usersLogin = Piwik_UsersManager_API::getInstance()->getUsersLogin();
+ $usersLogin = UsersManagerAPI::getInstance()->getUsersLogin();
foreach ($usersLogin as $login) {
if (!isset($usersAccessByWebsite[$login])) {
$usersAccessByWebsite[$login] = 'noaccess';
@@ -64,7 +69,6 @@ class Piwik_UsersManager_Controller extends Admin
}
unset($usersAccessByWebsite[$currentlyLogged]);
-
// $usersAccessByWebsite is not supposed to contain unexistant logins, but it does when upgrading from some old Piwik version
foreach ($usersAccessByWebsite as $login => $access) {
if (!in_array($login, $usersLogin)) {
@@ -78,7 +82,7 @@ class Piwik_UsersManager_Controller extends Admin
$users = array();
$usersAliasByLogin = array();
if (Piwik::isUserHasSomeAdminAccess()) {
- $users = Piwik_UsersManager_API::getInstance()->getUsers();
+ $users = UsersManagerAPI::getInstance()->getUsers();
foreach ($users as $user) {
$usersAliasByLogin[$user['login']] = $user['alias'];
}
@@ -90,8 +94,8 @@ class Piwik_UsersManager_Controller extends Admin
$view->usersAliasByLogin = $usersAliasByLogin;
$view->usersCount = count($users) - 1;
$view->usersAccessByWebsite = $usersAccessByWebsite;
- $websites = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
- uasort($websites, array('Piwik_UsersManager_Controller', 'orderByName'));
+ $websites = SitesManagerAPI::getInstance()->getSitesWithAdminAccess();
+ uasort($websites, array('Piwik\Plugins\UsersManager\Controller', 'orderByName'));
$view->websites = $websites;
$this->setBasicVariablesView($view);
echo $view->render();
@@ -118,7 +122,7 @@ class Piwik_UsersManager_Controller extends Admin
*/
protected function getDefaultDateForUser($user)
{
- return Piwik_UsersManager_API::getInstance()->getUserPreference($user, Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE);
+ return UsersManagerAPI::getInstance()->getUserPreference($user, UsersManagerAPI::PREFERENCE_DEFAULT_REPORT_DATE);
}
/**
@@ -135,14 +139,13 @@ class Piwik_UsersManager_Controller extends Admin
$view->userAlias = $userLogin;
$view->userEmail = Piwik::getSuperUserEmail();
$this->displayWarningIfConfigFileNotWritable($view);
-
} else {
- $user = Piwik_UsersManager_API::getInstance()->getUser($userLogin);
+ $user = UsersManagerAPI::getInstance()->getUser($userLogin);
$view->userAlias = $user['alias'];
$view->userEmail = $user['email'];
}
- $defaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference($userLogin, Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
+ $defaultReport = UsersManagerAPI::getInstance()->getUserPreference($userLogin, UsersManagerAPI::PREFERENCE_DEFAULT_REPORT);
if ($defaultReport === false) {
$defaultReport = $this->getDefaultWebsiteId();
}
@@ -196,11 +199,11 @@ class Piwik_UsersManager_Controller extends Admin
$userLogin = 'anonymous';
// Which websites are available to the anonymous users?
- $anonymousSitesAccess = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser($userLogin);
+ $anonymousSitesAccess = UsersManagerAPI::getInstance()->getSitesAccessFromUser($userLogin);
$anonymousSites = array();
foreach ($anonymousSitesAccess as $info) {
$idSite = $info['site'];
- $site = Piwik_SitesManager_API::getInstance()->getSiteFromId($idSite);
+ $site = SitesManagerAPI::getInstance()->getSiteFromId($idSite);
// Work around manual website deletion
if (!empty($site)) {
$anonymousSites[$idSite] = $site;
@@ -209,7 +212,7 @@ class Piwik_UsersManager_Controller extends Admin
$view->anonymousSites = $anonymousSites;
// Which report is displayed by default to the anonymous user?
- $anonymousDefaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference($userLogin, Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
+ $anonymousDefaultReport = UsersManagerAPI::getInstance()->getUserPreference($userLogin, UsersManagerAPI::PREFERENCE_DEFAULT_REPORT);
if ($anonymousDefaultReport === false) {
if (empty($anonymousSites)) {
$anonymousDefaultReport = Piwik::getLoginPluginName();
@@ -239,11 +242,11 @@ class Piwik_UsersManager_Controller extends Admin
$anonymousDefaultReport = Common::getRequestVar('anonymousDefaultReport');
$anonymousDefaultDate = Common::getRequestVar('anonymousDefaultDate');
$userLogin = 'anonymous';
- Piwik_UsersManager_API::getInstance()->setUserPreference($userLogin,
- Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT,
+ UsersManagerAPI::getInstance()->setUserPreference($userLogin,
+ UsersManagerAPI::PREFERENCE_DEFAULT_REPORT,
$anonymousDefaultReport);
- Piwik_UsersManager_API::getInstance()->setUserPreference($userLogin,
- Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE,
+ UsersManagerAPI::getInstance()->setUserPreference($userLogin,
+ UsersManagerAPI::PREFERENCE_DEFAULT_REPORT_DATE,
$anonymousDefaultDate);
$toReturn = $response->getResponse();
} catch (Exception $e) {
@@ -306,7 +309,7 @@ class Piwik_UsersManager_Controller extends Admin
Config::getInstance()->forceSave();
}
} else {
- Piwik_UsersManager_API::getInstance()->updateUser($userLogin, $newPassword, $email, $alias);
+ UsersManagerAPI::getInstance()->updateUser($userLogin, $newPassword, $email, $alias);
if ($newPassword !== false) {
$newPassword = Common::unsanitizeInputValue($newPassword);
}
@@ -322,11 +325,11 @@ class Piwik_UsersManager_Controller extends Admin
Piwik_PostEvent('Login.initSession', array($info));
}
- Piwik_UsersManager_API::getInstance()->setUserPreference($userLogin,
- Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT,
+ UsersManagerAPI::getInstance()->setUserPreference($userLogin,
+ UsersManagerAPI::PREFERENCE_DEFAULT_REPORT,
$defaultReport);
- Piwik_UsersManager_API::getInstance()->setUserPreference($userLogin,
- Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE,
+ UsersManagerAPI::getInstance()->setUserPreference($userLogin,
+ UsersManagerAPI::PREFERENCE_DEFAULT_REPORT_DATE,
$defaultDate);
$toReturn = $response->getResponse();
} catch (Exception $e) {
diff --git a/plugins/UsersManager/UsersManager.php b/plugins/UsersManager/UsersManager.php
index a0828d7904..905f23cc2f 100644
--- a/plugins/UsersManager/UsersManager.php
+++ b/plugins/UsersManager/UsersManager.php
@@ -6,18 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
+namespace Piwik\Plugins\UsersManager;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Option;
-use Piwik\Plugin;
+use Piwik\Plugins\UsersManager\API;
/**
* Manage Piwik users
*
- * @package Piwik_UsersManager
+ * @package UsersManager
*/
-class Piwik_UsersManager extends Plugin
+class UsersManager extends \Piwik\Plugin
{
const PASSWORD_MIN_LENGTH = 6;
const PASSWORD_MAX_LENGTH = 26;
@@ -36,7 +39,6 @@ class Piwik_UsersManager extends Plugin
);
}
-
/**
* Hooks when a website tracker cache is flushed (website/user updated, cache deleted, or empty cache)
* Will record in the tracker config file the list of Admin token_auth for this website. This
@@ -49,7 +51,7 @@ class Piwik_UsersManager extends Plugin
public function recordAdminUsersInCache(&$array, $idSite)
{
// add the 'hosts' entry in the website array
- $users = Piwik_UsersManager_API::getInstance()->getUsersWithSiteAccess($idSite, 'admin');
+ $users = API::getInstance()->getUsersWithSiteAccess($idSite, 'admin');
$tokens = array();
foreach ($users as $user) {
@@ -62,7 +64,7 @@ class Piwik_UsersManager extends Plugin
*/
public function deleteSite(&$idSite)
{
- Option::getInstance()->deleteLike('%\_' . Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT, $idSite);
+ Option::getInstance()->deleteLike('%\_' . API::PREFERENCE_DEFAULT_REPORT, $idSite);
}
/**
diff --git a/plugins/VisitFrequency/API.php b/plugins/VisitFrequency/API.php
index 141a1acee3..9d10395ba5 100644
--- a/plugins/VisitFrequency/API.php
+++ b/plugins/VisitFrequency/API.php
@@ -6,22 +6,26 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
+namespace Piwik\Plugins\VisitFrequency;
+
use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\SegmentExpression;
+use Piwik\Plugins\VisitsSummary\API as VisitsSummaryAPI;
/**
* VisitFrequency API lets you access a list of metrics related to Returning Visitors.
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
-class Piwik_VisitFrequency_API
+class API
{
const RETURNING_VISITOR_SEGMENT = "visitorType==returning";
const COLUMN_SUFFIX = "_returning";
static private $instance = null;
+
static public function getInstance()
{
if (self::$instance == null) {
@@ -79,7 +83,7 @@ class Piwik_VisitFrequency_API
protected function prefixColumns($table, $period)
{
$rename = array();
- foreach (Piwik_VisitsSummary_API::getInstance()->getColumns($period) as $oldColumn) {
+ foreach (VisitsSummaryAPI::getInstance()->getColumns($period) as $oldColumn) {
$rename[$oldColumn] = $oldColumn . self::COLUMN_SUFFIX;
}
$table->filter('ReplaceColumnNames', array($rename));
diff --git a/plugins/VisitFrequency/Controller.php b/plugins/VisitFrequency/Controller.php
index 77baa6b539..b83a117840 100644
--- a/plugins/VisitFrequency/Controller.php
+++ b/plugins/VisitFrequency/Controller.php
@@ -6,19 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
+namespace Piwik\Plugins\VisitFrequency;
+
use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\View;
/**
*
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
-class Piwik_VisitFrequency_Controller extends Controller
+class Controller extends \Piwik\Controller
{
function index()
{
@@ -96,7 +97,6 @@ class Piwik_VisitFrequency_Controller extends Controller
$view->avgVisitDurationReturning = $dataRow->getColumn('avg_time_on_site_returning');
$nbBouncedReturningVisits = $dataRow->getColumn('bounce_count_returning');
$view->bounceRateReturning = Piwik::getPercentageSafe($nbBouncedReturningVisits, $nbVisitsReturning);
-
}
protected function getSummary()
diff --git a/plugins/VisitFrequency/VisitFrequency.php b/plugins/VisitFrequency/VisitFrequency.php
index 07b1735159..90a5929760 100644
--- a/plugins/VisitFrequency/VisitFrequency.php
+++ b/plugins/VisitFrequency/VisitFrequency.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\VisitFrequency;
+
use Piwik\WidgetsList;
/**
*
- * @package Piwik_VisitFrequency
+ * @package VisitFrequency
*/
-class Piwik_VisitFrequency extends Plugin
+class VisitFrequency extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -23,9 +24,9 @@ class Piwik_VisitFrequency extends Plugin
public function getListHooksRegistered()
{
$hooks = array(
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenu',
- 'API.getReportMetadata' => 'getReportMetadata',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenu',
+ 'API.getReportMetadata' => 'getReportMetadata',
);
return $hooks;
}
diff --git a/plugins/VisitTime/API.php b/plugins/VisitTime/API.php
index 76e9b5652b..25d1ae8a81 100644
--- a/plugins/VisitTime/API.php
+++ b/plugins/VisitTime/API.php
@@ -6,8 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
+namespace Piwik\Plugins\VisitTime;
+
+use Exception;
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Period;
@@ -15,13 +18,16 @@ use Piwik\Piwik;
use Piwik\Date;
use Piwik\DataTable;
use Piwik\Site;
+use Piwik\Plugins\VisitTime\Archiver;
+
+require_once PIWIK_INCLUDE_PATH . '/plugins/VisitTime/functions.php';
/**
* VisitTime API lets you access reports by Hour (Server time), and by Hour Local Time of your visitors.
*
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
-class Piwik_VisitTime_API
+class API
{
static private $instance = null;
@@ -39,19 +45,19 @@ class Piwik_VisitTime_API
$archive = Archive::build($idSite, $period, $date, $segment);
$dataTable = $archive->getDataTable($name);
$dataTable->filter('Sort', array('label', 'asc', true));
- $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getTimeLabel'));
+ $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ .'\getTimeLabel'));
$dataTable->queueFilter('ReplaceColumnNames');
return $dataTable;
}
public function getVisitInformationPerLocalTime($idSite, $period, $date, $segment = false)
{
- return $this->getDataTable(Piwik_VisitTime_Archiver::LOCAL_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
+ return $this->getDataTable(Archiver::LOCAL_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
}
public function getVisitInformationPerServerTime($idSite, $period, $date, $segment = false, $hideFutureHoursWhenToday = false)
{
- $table = $this->getDataTable(Piwik_VisitTime_Archiver::SERVER_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
+ $table = $this->getDataTable(Archiver::SERVER_TIME_RECORD_NAME, $idSite, $period, $date, $segment);
if ($hideFutureHoursWhenToday) {
$table = $this->removeHoursInFuture($table, $idSite, $period, $date);
}
@@ -76,7 +82,7 @@ class Piwik_VisitTime_API
// metrics to query
$metrics = Metrics::getVisitsMetricNames();
unset($metrics[Metrics::INDEX_MAX_ACTIONS]);
-
+
// disabled for multiple dates
if (Period::isMultiplePeriod($date, $period)) {
throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates.");
@@ -100,7 +106,7 @@ class Piwik_VisitTime_API
}
// group by the day of the week (see below for dayOfWeekFromDate function)
- $dataTable->filter('GroupBy', array('label', 'Piwik_VisitTime_dayOfWeekFromDate'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\dayOfWeekFromDate'));
// create new datatable w/ empty rows, then add calculated datatable
$rows = array();
@@ -115,7 +121,7 @@ class Piwik_VisitTime_API
$result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week'));
// translate labels
- $result->filter('ColumnCallbackReplace', array('label', 'Piwik_VisitTime_translateDayOfWeek'));
+ $result->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\translateDayOfWeek'));
// set datatable metadata for period start & finish
$result->setMetadata('date_start', $oPeriod->getDateStart());
@@ -161,31 +167,3 @@ class Piwik_VisitTime_API
return $table;
}
}
-
-function Piwik_getTimeLabel($label)
-{
- return sprintf(Piwik_Translate('VisitTime_NHour'), $label);
-}
-
-/**
- * Returns the day of the week for a date string, without creating a new
- * Date instance.
- *
- * @param string $dateStr
- * @return int The day of the week (1-7)
- */
-function Piwik_VisitTime_dayOfWeekFromDate($dateStr)
-{
- return date('N', strtotime($dateStr));
-}
-
-/**
- * Returns translated long name of a day of the week.
- *
- * @param int $dayOfWeek 1-7, for Sunday-Saturday
- * @return string
- */
-function Piwik_VisitTime_translateDayOfWeek($dayOfWeek)
-{
- return Piwik_Translate('General_LongDay_' . $dayOfWeek);
-}
diff --git a/plugins/VisitTime/Archiver.php b/plugins/VisitTime/Archiver.php
index 77b7659d9b..c51c082967 100644
--- a/plugins/VisitTime/Archiver.php
+++ b/plugins/VisitTime/Archiver.php
@@ -6,14 +6,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
+namespace Piwik\Plugins\VisitTime;
+
use Piwik\Date;
use Piwik\DataArray;
use Piwik\PluginsArchiver;
-class Piwik_VisitTime_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
const SERVER_TIME_RECORD_NAME = 'VisitTime_serverTime';
const LOCAL_TIME_RECORD_NAME = 'VisitTime_localTime';
@@ -26,8 +28,8 @@ class Piwik_VisitTime_Archiver extends PluginsArchiver
protected function aggregateByServerTime()
{
- $array = $this->getProcessor()->getMetricsForDimension( array("label" => "HOUR(log_visit.visit_last_action_time)" )) ;
- $query = $this->getLogAggregator()->queryConversionsByDimension( array("label" => "HOUR(log_conversion.server_time)") );
+ $array = $this->getProcessor()->getMetricsForDimension(array("label" => "HOUR(log_visit.visit_last_action_time)"));
+ $query = $this->getLogAggregator()->queryConversionsByDimension(array("label" => "HOUR(log_conversion.server_time)"));
if ($query === false) {
return;
}
@@ -62,13 +64,12 @@ class Piwik_VisitTime_Archiver extends PluginsArchiver
return new DataArray($converted);
}
-
- private function ensureAllHoursAreSet( DataArray &$array)
+ private function ensureAllHoursAreSet(DataArray &$array)
{
$data = $array->getDataArray();
for ($i = 0; $i <= 23; $i++) {
if (empty($data[$i])) {
- $array->sumMetricsVisits( $i, DataArray::makeEmptyRow());
+ $array->sumMetricsVisits($i, DataArray::makeEmptyRow());
}
}
}
diff --git a/plugins/VisitTime/Controller.php b/plugins/VisitTime/Controller.php
index 4c4fa760db..dcc89ac9fb 100644
--- a/plugins/VisitTime/Controller.php
+++ b/plugins/VisitTime/Controller.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
-use Piwik\Controller;
+namespace Piwik\Plugins\VisitTime;
+
use Piwik\ViewDataTable;
use Piwik\View;
/**
*
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
-class Piwik_VisitTime_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php
index e9873ae05c..8e047803da 100644
--- a/plugins/VisitTime/VisitTime.php
+++ b/plugins/VisitTime/VisitTime.php
@@ -6,20 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
+namespace Piwik\Plugins\VisitTime;
+
+use Exception;
use Piwik\ArchiveProcessor;
use Piwik\Common;
use Piwik\Period;
-use Piwik\Plugin;
+use Piwik\Plugins\VisitTime\Archiver;
use Piwik\Site;
use Piwik\WidgetsList;
/**
*
- * @package Piwik_VisitTime
+ * @package VisitTime
*/
-class Piwik_VisitTime extends Plugin
+class VisitTime extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -116,7 +119,7 @@ class Piwik_VisitTime extends Plugin
'acceptedValues' => $acceptedValues
);
}
-
+
public function getReportDisplayProperties(&$properties)
{
$commonProperties = array(
@@ -128,7 +131,7 @@ class Piwik_VisitTime extends Plugin
'show_pagination_control' => false,
'default_view_type' => 'graphVerticalBar'
);
-
+
$properties['VisitTime.getVisitInformationPerServerTime'] = array_merge($commonProperties, array(
'filter_limit' => 24,
'show_goals' => true,
@@ -176,21 +179,20 @@ class Piwik_VisitTime extends Plugin
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_VisitTime_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
-
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_VisitTime_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
-
+
private static function getDateRangeForFooterMessage()
{
// get query params
diff --git a/plugins/VisitTime/functions.php b/plugins/VisitTime/functions.php
new file mode 100644
index 0000000000..f4ccb20d46
--- /dev/null
+++ b/plugins/VisitTime/functions.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ * @category Piwik_Plugins
+ * @package VisitTime
+ */
+
+namespace Piwik\Plugins\VisitTime;
+
+function getTimeLabel($label)
+{
+ return sprintf(Piwik_Translate('VisitTime_NHour'), $label);
+}
+
+/**
+ * Returns the day of the week for a date string, without creating a new
+ * Date instance.
+ *
+ * @param string $dateStr
+ * @return int The day of the week (1-7)
+ */
+function dayOfWeekFromDate($dateStr)
+{
+ return date('N', strtotime($dateStr));
+}
+
+/**
+ * Returns translated long name of a day of the week.
+ *
+ * @param int $dayOfWeek 1-7, for Sunday-Saturday
+ * @return string
+ */
+function translateDayOfWeek($dayOfWeek)
+{
+ return Piwik_Translate('General_LongDay_' . $dayOfWeek);
+}
diff --git a/plugins/VisitorGenerator/Controller.php b/plugins/VisitorGenerator/Controller.php
index f0275b3348..bf344be4f3 100644
--- a/plugins/VisitorGenerator/Controller.php
+++ b/plugins/VisitorGenerator/Controller.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitorGenerator
+ * @package VisitorGenerator
*/
+namespace Piwik\Plugins\VisitorGenerator;
+
use Piwik\ArchiveProcessor\Rules;
use Piwik\Controller\Admin;
use Piwik\Piwik;
@@ -19,23 +21,25 @@ use Piwik\View;
use Piwik\Url;
use Piwik\Timer;
use Piwik\Site;
+use Piwik\Plugins\CoreAdminHome\API as CoreAdminHomeAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
*
- * @package Piwik_VisitorGenerator
+ * @package VisitorGenerator
*/
-class Piwik_VisitorGenerator_Controller extends Admin
+class Controller extends Admin
{
public function index()
{
Piwik::checkUserIsSuperUser();
- $sitesList = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
+ $sitesList = SitesManagerAPI::getInstance()->getSitesWithAdminAccess();
$view = new View('@VisitorGenerator/index');
$this->setBasicVariablesView($view);
$view->assign('sitesList', $sitesList);
- $view->nonce = Nonce::getNonce('Piwik_VisitorGenerator.generate');
+ $view->nonce = Nonce::getNonce('VisitorGenerator.generate');
$view->countActionsPerRun = count($this->getAccessLog());
$view->accessLogPath = $this->getAccessLogPath();
echo $view->render();
@@ -57,11 +61,11 @@ class Piwik_VisitorGenerator_Controller extends Admin
Piwik::checkUserIsSuperUser();
$nonce = Common::getRequestVar('form_nonce', '', 'string', $_POST);
if (Common::getRequestVar('choice', 'no') != 'yes' ||
- !Nonce::verifyNonce('Piwik_VisitorGenerator.generate', $nonce)
+ !Nonce::verifyNonce('VisitorGenerator.generate', $nonce)
) {
Piwik::redirectToModule('VisitorGenerator', 'index');
}
- Nonce::discardNonce('Piwik_VisitorGenerator.generate');
+ Nonce::discardNonce('VisitorGenerator.generate');
$daysToCompute = Common::getRequestVar('daysToCompute', 1, 'int');
@@ -83,7 +87,7 @@ class Piwik_VisitorGenerator_Controller extends Admin
$nbActionsTotal += $nbActionsTotalThisDay;
}
- $api = Piwik_CoreAdminHome_API::getInstance();
+ $api = CoreAdminHomeAPI::getInstance();
$api->invalidateArchivedReports($idSite, implode($dates, ","));
$browserArchiving = Rules::isBrowserTriggerEnabled();
diff --git a/plugins/VisitorGenerator/VisitorGenerator.php b/plugins/VisitorGenerator/VisitorGenerator.php
index 9ad4fa3d66..4e3c13e677 100644
--- a/plugins/VisitorGenerator/VisitorGenerator.php
+++ b/plugins/VisitorGenerator/VisitorGenerator.php
@@ -6,16 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitorGenerator
+ * @package VisitorGenerator
*/
+namespace Piwik\Plugins\VisitorGenerator;
+
use Piwik\Piwik;
-use Piwik\Plugin;
/**
*
- * @package Piwik_VisitorGenerator
+ * @package VisitorGenerator
*/
-class Piwik_VisitorGenerator extends Plugin
+class VisitorGenerator extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/VisitorInterest/API.php b/plugins/VisitorInterest/API.php
index 8f34623fec..7a6f925254 100644
--- a/plugins/VisitorInterest/API.php
+++ b/plugins/VisitorInterest/API.php
@@ -6,20 +6,23 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
+namespace Piwik\Plugins\VisitorInterest;
+
use Piwik\Archive;
use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\DataTable;
+use Piwik\Plugins\VisitorInterest\Archiver;
/**
* VisitorInterest API lets you access two Visitor Engagement reports: number of visits per number of pages,
* and number of visits per visit duration.
*
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
-class Piwik_VisitorInterest_API
+class API
{
static private $instance = null;
@@ -42,7 +45,7 @@ class Piwik_VisitorInterest_API
public function getNumberOfVisitsPerVisitDuration($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_VisitorInterest_Archiver::TIME_SPENT_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::TIME_SPENT_RECORD_NAME, $idSite, $period, $date, $segment);
$dataTable->queueFilter('Sort', array('label', 'asc', true));
$dataTable->queueFilter('BeautifyTimeRangeLabels', array(
Piwik_Translate('VisitorInterest_BetweenXYSeconds'),
@@ -53,7 +56,7 @@ class Piwik_VisitorInterest_API
public function getNumberOfVisitsPerPage($idSite, $period, $date, $segment = false)
{
- $dataTable = $this->getDataTable(Piwik_VisitorInterest_Archiver::PAGES_VIEWED_RECORD_NAME, $idSite, $period, $date, $segment);
+ $dataTable = $this->getDataTable(Archiver::PAGES_VIEWED_RECORD_NAME, $idSite, $period, $date, $segment);
$dataTable->queueFilter('Sort', array('label', 'asc', true));
$dataTable->queueFilter('BeautifyRangeLabels', array(
Piwik_Translate('VisitorInterest_OnePage'),
@@ -74,7 +77,7 @@ class Piwik_VisitorInterest_API
public function getNumberOfVisitsByDaysSinceLast($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable(
- Piwik_VisitorInterest_Archiver::DAYS_SINCE_LAST_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS);
+ Archiver::DAYS_SINCE_LAST_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS);
$dataTable->queueFilter('BeautifyRangeLabels', array(Piwik_Translate('General_OneDay'), Piwik_Translate('General_NDays')));
return $dataTable;
}
@@ -92,7 +95,7 @@ class Piwik_VisitorInterest_API
public function getNumberOfVisitsByVisitCount($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable(
- Piwik_VisitorInterest_Archiver::VISITS_COUNT_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS);
+ Archiver::VISITS_COUNT_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS);
$dataTable->queueFilter('BeautifyRangeLabels', array(
Piwik_Translate('General_OneVisit'), Piwik_Translate('General_NVisits')));
diff --git a/plugins/VisitorInterest/Archiver.php b/plugins/VisitorInterest/Archiver.php
index 18449cbf4c..d6aa1a29ba 100644
--- a/plugins/VisitorInterest/Archiver.php
+++ b/plugins/VisitorInterest/Archiver.php
@@ -6,15 +6,17 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
+namespace Piwik\Plugins\VisitorInterest;
+
use Piwik\DataAccess\LogAggregator;
use Piwik\Metrics;
use Piwik\DataTable;
use Piwik\PluginsArchiver;
-class Piwik_VisitorInterest_Archiver extends PluginsArchiver
+class Archiver extends PluginsArchiver
{
// third element is unit (s for seconds, default is munutes)
const TIME_SPENT_RECORD_NAME = 'VisitorInterest_timeGap';
@@ -90,9 +92,9 @@ class Piwik_VisitorInterest_Archiver extends PluginsArchiver
// these prefixes are prepended to the 'SELECT as' parts of each SELECT expression. detecting
// these prefixes allows us to get all the data in one query.
$prefixes = array(
- self::TIME_SPENT_RECORD_NAME => 'tg',
- self::PAGES_VIEWED_RECORD_NAME => 'pg',
- self::VISITS_COUNT_RECORD_NAME => 'vbvn',
+ self::TIME_SPENT_RECORD_NAME => 'tg',
+ self::PAGES_VIEWED_RECORD_NAME => 'pg',
+ self::VISITS_COUNT_RECORD_NAME => 'vbvn',
self::DAYS_SINCE_LAST_RECORD_NAME => 'dslv',
);
@@ -105,13 +107,13 @@ class Piwik_VisitorInterest_Archiver extends PluginsArchiver
),
);
$selects = array();
- foreach($aggregatesMetadata as $aggregateMetadata) {
+ foreach ($aggregatesMetadata as $aggregateMetadata) {
$selectsFromRangedColumn = LogAggregator::getSelectsFromRangedColumn($aggregateMetadata);
- $selects = array_merge( $selects, $selectsFromRangedColumn);
+ $selects = array_merge($selects, $selectsFromRangedColumn);
}
$query = $this->getLogAggregator()->queryVisitsByDimension(array(), $where = false, $selects, array());
$row = $query->fetch();
- foreach($prefixes as $recordName => $selectAsPrefix) {
+ foreach ($prefixes as $recordName => $selectAsPrefix) {
$cleanRow = LogAggregator::makeArrayOneColumn($row, Metrics::INDEX_NB_VISITS, $selectAsPrefix);
$dataTable = DataTable::makeFromIndexedArray($cleanRow);
$this->getProcessor()->insertBlobRecord($recordName, $dataTable->getSerialized());
diff --git a/plugins/VisitorInterest/Controller.php b/plugins/VisitorInterest/Controller.php
index d7a505d6b4..5475d6cba8 100644
--- a/plugins/VisitorInterest/Controller.php
+++ b/plugins/VisitorInterest/Controller.php
@@ -6,17 +6,18 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
+namespace Piwik\Plugins\VisitorInterest;
+
use Piwik\Metrics;
-use Piwik\Controller;
use Piwik\ViewDataTable;
use Piwik\View;
/**
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
-class Piwik_VisitorInterest_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
diff --git a/plugins/VisitorInterest/VisitorInterest.php b/plugins/VisitorInterest/VisitorInterest.php
index 569d482480..0692649e33 100644
--- a/plugins/VisitorInterest/VisitorInterest.php
+++ b/plugins/VisitorInterest/VisitorInterest.php
@@ -6,19 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
+namespace Piwik\Plugins\VisitorInterest;
+
use Piwik\ArchiveProcessor;
use Piwik\FrontController;
-use Piwik\Plugin;
use Piwik\Metrics;
+use Piwik\Plugins\VisitorInterest\Archiver;
use Piwik\WidgetsList;
/**
*
- * @package Piwik_VisitorInterest
+ * @package VisitorInterest
*/
-class Piwik_VisitorInterest extends Plugin
+class VisitorInterest extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -26,11 +28,11 @@ class Piwik_VisitorInterest extends Plugin
public function getListHooksRegistered()
{
$hooks = array(
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenu',
- 'API.getReportMetadata' => 'getReportMetadata',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenu',
+ 'API.getReportMetadata' => 'getReportMetadata',
'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
return $hooks;
@@ -113,22 +115,22 @@ class Piwik_VisitorInterest extends Plugin
function postLoad()
{
- Piwik_AddAction('template_headerVisitsFrequency', array('Piwik_VisitorInterest', 'headerVisitsFrequency'));
- Piwik_AddAction('template_footerVisitsFrequency', array('Piwik_VisitorInterest', 'footerVisitsFrequency'));
+ Piwik_AddAction('template_headerVisitsFrequency', array('Piwik\Plugins\VisitorInterest\VisitorInterest', 'headerVisitsFrequency'));
+ Piwik_AddAction('template_footerVisitsFrequency', array('Piwik\Plugins\VisitorInterest\VisitorInterest', 'footerVisitsFrequency'));
}
public function archivePeriod(ArchiveProcessor\Period $archiveProcessor)
{
- $archiving = new Piwik_VisitorInterest_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archivePeriod();
}
}
public function archiveDay(ArchiveProcessor\Day $archiveProcessor)
{
- $archiving = new Piwik_VisitorInterest_Archiver($archiveProcessor);
- if($archiving->shouldArchive()) {
+ $archiving = new Archiver($archiveProcessor);
+ if ($archiving->shouldArchive()) {
$archiving->archiveDay();
}
}
@@ -204,36 +206,36 @@ class Piwik_VisitorInterest extends Plugin
private function getDisplayPropertiesForGetNumberOfVisitsByVisitCount()
{
return array(
- 'columns_to_display' => array('label', 'nb_visits', 'nb_visits_percentage'),
- 'filter_sort_column' => 'label',
- 'filter_sort_order' => 'asc',
- 'translations' => array('label' => Piwik_Translate('VisitorInterest_VisitNum'),
- 'nb_visits_percentage' => Metrics::getPercentVisitColumn()),
+ 'columns_to_display' => array('label', 'nb_visits', 'nb_visits_percentage'),
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array('label' => Piwik_Translate('VisitorInterest_VisitNum'),
+ 'nb_visits_percentage' => Metrics::getPercentVisitColumn()),
'show_exclude_low_population' => false,
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'filter_limit' => 15,
- 'show_search' => false,
- 'enable_sort' => false,
- 'show_table_all_columns' => false,
- 'show_all_views_icons' => false,
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'filter_limit' => 15,
+ 'show_search' => false,
+ 'enable_sort' => false,
+ 'show_table_all_columns' => false,
+ 'show_all_views_icons' => false,
);
}
private function getDisplayPropertiesForGetNumberOfVisitsByDaysSinceLast()
{
return array(
- 'filter_sort_column' => 'label',
- 'filter_sort_order' => 'asc',
- 'translations' => array('label' => Piwik_Translate('General_DaysSinceLastVisit')),
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array('label' => Piwik_Translate('General_DaysSinceLastVisit')),
'show_exclude_low_population' => false,
- 'show_offset_information' => false,
- 'show_pagination_control' => false,
- 'show_all_views_icons' => false,
- 'filter_limit' => 15,
- 'show_search' => false,
- 'enable_sort' => false,
- 'show_table_all_columns' => false
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'show_all_views_icons' => false,
+ 'filter_limit' => 15,
+ 'show_search' => false,
+ 'enable_sort' => false,
+ 'show_table_all_columns' => false
);
}
}
diff --git a/plugins/VisitsSummary/API.php b/plugins/VisitsSummary/API.php
index 71b1775e78..831828b775 100644
--- a/plugins/VisitsSummary/API.php
+++ b/plugins/VisitsSummary/API.php
@@ -6,8 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
+namespace Piwik\Plugins\VisitsSummary;
+
use Piwik\Archive;
use Piwik\Piwik;
@@ -15,14 +17,14 @@ use Piwik\Piwik;
* VisitsSummary API lets you access the core web analytics metrics (visits, unique visitors,
* count of actions (page views & downloads & clicks on outlinks), time on site, bounces and converted visits.
*
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
-class Piwik_VisitsSummary_API
+class API
{
static private $instance = null;
/**
- * @return Piwik_VisitsSummary_API
+ * @return \Piwik\Plugins\VisitsSummary\API
*/
static public function getInstance()
{
diff --git a/plugins/VisitsSummary/Controller.php b/plugins/VisitsSummary/Controller.php
index 4bc553a94d..2594a9689c 100644
--- a/plugins/VisitsSummary/Controller.php
+++ b/plugins/VisitsSummary/Controller.php
@@ -6,23 +6,25 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
+namespace Piwik\Plugins\VisitsSummary;
+
use Piwik\API\Request;
use Piwik\DataTable\Row;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\DataTable;
-use Piwik\Controller;
+use Piwik\Plugins\Actions\API;
use Piwik\ViewDataTable;
use Piwik\View;
use Piwik\Site;
/**
*
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
-class Piwik_VisitsSummary_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
@@ -126,7 +128,7 @@ class Piwik_VisitsSummary_Controller extends Controller
$view->urlSparklineMaxActions = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('max_actions')));
$view->urlSparklineActionsPerVisit = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_actions_per_visit')));
$view->urlSparklineBounceRate = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('bounce_rate')));
- $view->urlSparklineAvgGenerationTime = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('avg_time_generation')));
+ $view->urlSparklineAvgGenerationTime = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('avg_time_generation')));
$idSite = Common::getRequestVar('idSite');
$displaySiteSearch = Site::isSiteSearchEnabledFor($idSite);
@@ -138,7 +140,7 @@ class Piwik_VisitsSummary_Controller extends Controller
$dataTableVisit = self::getVisitsSummary();
$dataRow = $dataTableVisit->getRowsCount() == 0 ? new Row() : $dataTableVisit->getFirstRow();
- $dataTableActions = Piwik_Actions_API::getInstance()->get($idSite, Common::getRequestVar('period'), Common::getRequestVar('date'),
+ $dataTableActions = API::getInstance()->get($idSite, Common::getRequestVar('period'), Common::getRequestVar('date'),
\Piwik\API\Request::getRawSegmentFromRequest());
$dataActionsRow =
$dataTableActions->getRowsCount() == 0 ? new Row() : $dataTableActions->getFirstRow();
@@ -157,7 +159,7 @@ class Piwik_VisitsSummary_Controller extends Controller
$view->bounceRate = Piwik::getPercentageSafe($nbBouncedVisits, $nbVisits);
$view->maxActions = (int)$dataRow->getColumn('max_actions');
$view->nbActionsPerVisit = $dataRow->getColumn('nb_actions_per_visit');
- $view->averageGenerationTime = $dataActionsRow->getColumn('avg_time_generation');
+ $view->averageGenerationTime = $dataActionsRow->getColumn('avg_time_generation');
if ($displaySiteSearch) {
$view->nbSearches = (int)$dataActionsRow->getColumn('nb_searches');
diff --git a/plugins/VisitsSummary/VisitsSummary.php b/plugins/VisitsSummary/VisitsSummary.php
index 91e4a65661..3ef1a89f0d 100644
--- a/plugins/VisitsSummary/VisitsSummary.php
+++ b/plugins/VisitsSummary/VisitsSummary.php
@@ -6,9 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
-use Piwik\Plugin;
+namespace Piwik\Plugins\VisitsSummary;
+
use Piwik\WidgetsList;
/**
@@ -17,9 +18,9 @@ use Piwik\WidgetsList;
* Day class directly.
* These metrics can be used by other Plugins so they need to be processed up front.
*
- * @package Piwik_VisitsSummary
+ * @package VisitsSummary
*/
-class Piwik_VisitsSummary extends Plugin
+class VisitsSummary extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/Widgetize/Controller.php b/plugins/Widgetize/Controller.php
index c49fa226d3..1dea78feb4 100644
--- a/plugins/Widgetize/Controller.php
+++ b/plugins/Widgetize/Controller.php
@@ -6,20 +6,21 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Widgetize
+ * @package Widgetize
*/
+namespace Piwik\Plugins\Widgetize;
+
use Piwik\API\Request;
use Piwik\Common;
-use Piwik\Controller;
use Piwik\FrontController;
use Piwik\View;
use Piwik\WidgetsList;
/**
*
- * @package Piwik_Widgetize
+ * @package Widgetize
*/
-class Piwik_Widgetize_Controller extends Controller
+class Controller extends \Piwik\Controller
{
public function index()
{
diff --git a/plugins/Widgetize/Widgetize.php b/plugins/Widgetize/Widgetize.php
index 27a002ccb9..b47fdf9e21 100644
--- a/plugins/Widgetize/Widgetize.php
+++ b/plugins/Widgetize/Widgetize.php
@@ -7,15 +7,16 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
- * @package Piwik_Widgetize
+ * @package Widgetize
*/
-use Piwik\Plugin;
+
+namespace Piwik\Plugins\Widgetize;
/**
*
- * @package Piwik_Widgetize
+ * @package Widgetize
*/
-class Piwik_Widgetize extends Plugin
+class Widgetize extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
diff --git a/plugins/Zeitgeist/stylesheets/base.css b/plugins/Zeitgeist/stylesheets/base.css
index 75a146eb12..3eea5ab03a 100644
--- a/plugins/Zeitgeist/stylesheets/base.css
+++ b/plugins/Zeitgeist/stylesheets/base.css
@@ -1,3 +1,4 @@
+/* TO GENERATE: lessc plugins/Zeitgeist/stylesheets/base.less plugins/Zeitgeist/stylesheets/base.css */
/* base.less is a standalone Less file */
/* base.css is automatically generated. DO NOT MODIFY */
/* General styles */
diff --git a/plugins/Zeitgeist/stylesheets/base.less b/plugins/Zeitgeist/stylesheets/base.less
index 3d8406e360..f4afcc6220 100644
--- a/plugins/Zeitgeist/stylesheets/base.less
+++ b/plugins/Zeitgeist/stylesheets/base.less
@@ -1,3 +1,4 @@
+/* TO GENERATE: lessc plugins/Zeitgeist/stylesheets/base.less plugins/Zeitgeist/stylesheets/base.css */
/* base.less is a standalone Less file */
/* base.css is automatically generated. DO NOT MODIFY */
diff --git a/tests/PHPUnit/BaseFixture.php b/tests/PHPUnit/BaseFixture.php
index 70e9e87e5b..cf57226d8b 100644
--- a/tests/PHPUnit/BaseFixture.php
+++ b/tests/PHPUnit/BaseFixture.php
@@ -9,6 +9,12 @@ use Piwik\Config;
use Piwik\Common;
use Piwik\Access;
use Piwik\Date;
+use Piwik\Plugins\MobileMessaging\MobileMessaging;
+use Piwik\Plugins\PDFReports\API as PDFReportsAPI;
+use Piwik\Plugins\PDFReports\PDFReports;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
use Piwik\Url;
use Piwik\ReportRenderer;
use Piwik\Site;
@@ -57,7 +63,7 @@ abstract class Test_Piwik_BaseFixture extends PHPUnit_Framework_Assert
$siteSearch = 1, $searchKeywordParameters = null,
$searchCategoryParameters = null)
{
- $idSite = Piwik_SitesManager_API::getInstance()->addSite(
+ $idSite = SitesManagerAPI::getInstance()->addSite(
$siteName,
$siteUrl === false ? "http://piwik.net/" : $siteUrl,
$ecommerce,
@@ -166,12 +172,12 @@ abstract class Test_Piwik_BaseFixture extends PHPUnit_Framework_Assert
public static function makeLocation($city, $region, $country, $lat = null, $long = null, $isp = null)
{
- return array(Piwik_UserCountry_LocationProvider::CITY_NAME_KEY => $city,
- Piwik_UserCountry_LocationProvider::REGION_CODE_KEY => $region,
- Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY => $country,
- Piwik_UserCountry_LocationProvider::LATITUDE_KEY => $lat,
- Piwik_UserCountry_LocationProvider::LONGITUDE_KEY => $long,
- Piwik_UserCountry_LocationProvider::ISP_KEY => $isp);
+ return array(LocationProvider::CITY_NAME_KEY => $city,
+ LocationProvider::REGION_CODE_KEY => $region,
+ LocationProvider::COUNTRY_CODE_KEY => $country,
+ LocationProvider::LATITUDE_KEY => $lat,
+ LocationProvider::LONGITUDE_KEY => $long,
+ LocationProvider::ISP_KEY => $isp);
}
/**
@@ -182,7 +188,7 @@ abstract class Test_Piwik_BaseFixture extends PHPUnit_Framework_Assert
*/
public static function getTokenAuth()
{
- return Piwik_UsersManager_API::getInstance()->getTokenAuth(
+ return UsersManagerAPI::getInstance()->getTokenAuth(
Config::getInstance()->superuser['login'],
Config::getInstance()->superuser['password']
);
@@ -208,7 +214,7 @@ abstract class Test_Piwik_BaseFixture extends PHPUnit_Framework_Assert
Access::setSingletonInstance($pseudoMockAccess);
// retrieve available reports
- $availableReportMetadata = Piwik_PDFReports_API::getReportMetadata($idSite, Piwik_PDFReports::EMAIL_TYPE);
+ $availableReportMetadata = PDFReportsAPI::getReportMetadata($idSite, PDFReports::EMAIL_TYPE);
$availableReportIds = array();
foreach ($availableReportMetadata as $reportMetadata) {
@@ -217,66 +223,66 @@ abstract class Test_Piwik_BaseFixture extends PHPUnit_Framework_Assert
//@review should we also test evolution graphs?
// set-up mail report
- Piwik_PDFReports_API::getInstance()->addReport(
+ PDFReportsAPI::getInstance()->addReport(
$idSite,
'Mail Test report',
'day', // overridden in getApiForTestingScheduledReports()
0,
- Piwik_PDFReports::EMAIL_TYPE,
+ PDFReports::EMAIL_TYPE,
ReportRenderer::HTML_FORMAT, // overridden in getApiForTestingScheduledReports()
$availableReportIds,
- array(Piwik_PDFReports::DISPLAY_FORMAT_PARAMETER => Piwik_PDFReports::DISPLAY_FORMAT_TABLES_ONLY)
+ array(PDFReports::DISPLAY_FORMAT_PARAMETER => PDFReports::DISPLAY_FORMAT_TABLES_ONLY)
);
// set-up sms report for one website
- Piwik_PDFReports_API::getInstance()->addReport(
+ PDFReportsAPI::getInstance()->addReport(
$idSite,
'SMS Test report, one website',
'day', // overridden in getApiForTestingScheduledReports()
0,
- Piwik_MobileMessaging::MOBILE_TYPE,
- Piwik_MobileMessaging::SMS_FORMAT,
+ MobileMessaging::MOBILE_TYPE,
+ MobileMessaging::SMS_FORMAT,
array("MultiSites_getOne"),
array("phoneNumbers" => array())
);
// set-up sms report for all websites
- Piwik_PDFReports_API::getInstance()->addReport(
+ PDFReportsAPI::getInstance()->addReport(
$idSite,
'SMS Test report, all websites',
'day', // overridden in getApiForTestingScheduledReports()
0,
- Piwik_MobileMessaging::MOBILE_TYPE,
- Piwik_MobileMessaging::SMS_FORMAT,
+ MobileMessaging::MOBILE_TYPE,
+ MobileMessaging::SMS_FORMAT,
array("MultiSites_getAll"),
array("phoneNumbers" => array())
);
if (self::canImagesBeIncludedInScheduledReports()) {
// set-up mail report with images
- Piwik_PDFReports_API::getInstance()->addReport(
+ PDFReportsAPI::getInstance()->addReport(
$idSite,
'Mail Test report',
'day', // overridden in getApiForTestingScheduledReports()
0,
- Piwik_PDFReports::EMAIL_TYPE,
+ PDFReports::EMAIL_TYPE,
ReportRenderer::HTML_FORMAT, // overridden in getApiForTestingScheduledReports()
$availableReportIds,
- array(Piwik_PDFReports::DISPLAY_FORMAT_PARAMETER => Piwik_PDFReports::DISPLAY_FORMAT_TABLES_AND_GRAPHS)
+ array(PDFReports::DISPLAY_FORMAT_PARAMETER => PDFReports::DISPLAY_FORMAT_TABLES_AND_GRAPHS)
);
// set-up mail report with one row evolution based png graph
- Piwik_PDFReports_API::getInstance()->addReport(
+ PDFReportsAPI::getInstance()->addReport(
$idSite,
'Mail Test report',
'day',
0,
- Piwik_PDFReports::EMAIL_TYPE,
+ PDFReports::EMAIL_TYPE,
ReportRenderer::HTML_FORMAT,
array('Actions_getPageTitles'),
array(
- Piwik_PDFReports::DISPLAY_FORMAT_PARAMETER => Piwik_PDFReports::DISPLAY_FORMAT_GRAPHS_ONLY,
- Piwik_PDFReports::EVOLUTION_GRAPH_PARAMETER => 'true',
+ PDFReports::DISPLAY_FORMAT_PARAMETER => PDFReports::DISPLAY_FORMAT_GRAPHS_ONLY,
+ PDFReports::EVOLUTION_GRAPH_PARAMETER => 'true',
)
);
}
diff --git a/tests/PHPUnit/BenchmarkTestCase.php b/tests/PHPUnit/BenchmarkTestCase.php
index d62038a8e9..42b54260e6 100755
--- a/tests/PHPUnit/BenchmarkTestCase.php
+++ b/tests/PHPUnit/BenchmarkTestCase.php
@@ -8,6 +8,7 @@
use Piwik\Config;
use Piwik\Db;
use Piwik\Common;
+use Piwik\Plugins\Goals\API;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/IntegrationTestCase.php';
require_once PIWIK_INCLUDE_PATH . '/tests/LocalTracker.php';
@@ -107,7 +108,7 @@ class Piwik_Test_Fixture_EmptyOneSite
$this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
// add two goals
- $goals = Piwik_Goals_API::getInstance();
+ $goals = API::getInstance();
$goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
$goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains');
}
diff --git a/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php b/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php
index adf616fa27..2dcdbbec18 100644
--- a/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php
+++ b/tests/PHPUnit/Benchmarks/ArchiveQueryBenchmark.php
@@ -9,6 +9,7 @@ use Piwik\ArchiveProcessor\Rules;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Period;
use Piwik\Date;
+use Piwik\Plugins\VisitsSummary\API;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/BenchmarkTestCase.php';
@@ -24,7 +25,7 @@ class ArchiveQueryBenchmark extends BenchmarkTestCase
$archivingTables = ArchiveTableCreator::getTablesArchivesInstalled();
if (empty($archivingTables)) {
$this->archivingLaunched = true;
- Piwik_VisitsSummary_API::getInstance()->get(
+ API::getInstance()->get(
self::$fixture->idSite, self::$fixture->period, self::$fixture->date);
}
}
@@ -44,6 +45,6 @@ class ArchiveQueryBenchmark extends BenchmarkTestCase
$period = Period::factory(self::$fixture->period, Date::factory(self::$fixture->date));
$dateRange = $period->getDateStart().','.$period->getDateEnd();
- Piwik_VisitsSummary_API::getInstance()->get(self::$fixture->idSite, 'day', $dateRange);
+ API::getInstance()->get(self::$fixture->idSite, 'day', $dateRange);
}
}
diff --git a/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php b/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php
index ad5d4504f8..294ec73a12 100755
--- a/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php
+++ b/tests/PHPUnit/Benchmarks/ArchivingProcessBenchmark.php
@@ -5,6 +5,8 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\VisitsSummary\API;
+
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/BenchmarkTestCase.php';
/**
@@ -23,7 +25,7 @@ class ArchivingProcessBenchmark extends BenchmarkTestCase
*/
public function testArchivingProcess()
{
- Piwik_VisitsSummary_API::getInstance()->get(
+ API::getInstance()->get(
self::$fixture->idSite, self::$fixture->period, self::$fixture->date);
}
}
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php b/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
index 83569527d0..8f8fb4ef02 100644
--- a/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/ManyThousandSitesOneVisitEach.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Reusable fixture. Adds 20,000 sites and tracks one pageview for each on one day.
@@ -23,7 +24,7 @@ class Piwik_Test_Fixture_ManyThousandSitesOneVisitEach
$idSite = Test_Piwik_BaseFixture::createWebsite(
$this->date, $ecommerce = 1, $siteName = "Site #$i", $siteUrl = "http://site$i.com/");
- Piwik_Goals_API::getInstance()->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5);
+ API::getInstance()->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5);
}
// track one visit for each site
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
index 7696cda917..42b3718212 100644
--- a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteThousandsOfDistinctUrlsOverMonth.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds one site and 1000 actions for every day of one month (January). Each
@@ -25,7 +26,7 @@ class Piwik_Test_Fixture_OneSiteThousandsOfDistinctUrlsOverMonth
$this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
// add two goals
- $goals = Piwik_Goals_API::getInstance();
+ $goals = API::getInstance();
$goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
$goals->addGoal($this->idSite, 'all', 'url', 'thing2', 'contains');
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
index 743a77bad9..1d7ea0462b 100755
--- a/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/OneSiteTwelveThousandVisitsOneYear.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Reusable fixture. Tracks twelve thousand page views over a year for one site.
@@ -25,7 +26,7 @@ class Piwik_Test_Fixture_OneSiteTwelveThousandVisitsOneYear
$this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
// add two goals
- $goals = Piwik_Goals_API::getInstance();
+ $goals = API::getInstance();
$goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
$goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains');
diff --git a/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php b/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
index e56a16a5df..2186c9e39c 100755
--- a/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
+++ b/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API as GoalsAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
* Reusable fixture. Tracks twelve thousand page views for 1000 sites on one day.
@@ -18,8 +20,7 @@ class Piwik_Test_Fixture_ThousandSitesTwelveVisitsEachOneDay
public function setUp()
{
- $sitesManager = Piwik_SitesManager_API::getInstance();
- $goals = Piwik_Goals_API::getInstance();
+ $goals = GoalsAPI::getInstance();
// add one thousand sites
$allIdSites = array();
diff --git a/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php b/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php
index a1390fc67a..1954ba168d 100644
--- a/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php
+++ b/tests/PHPUnit/Benchmarks/MultiSitesBenchmark.php
@@ -7,6 +7,8 @@
*/
use Piwik\ArchiveProcessor\Rules;
use Piwik\DataAccess\ArchiveTableCreator;
+use Piwik\Plugins\MultiSites\API as MultiSitesAPI;
+use Piwik\Plugins\VisitsSummary\API as VisitsSummaryAPI;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/BenchmarkTestCase.php';
@@ -22,7 +24,7 @@ class MultiSitesBenchmark extends BenchmarkTestCase
$archivingTables = ArchiveTableCreator::getTablesArchivesInstalled();
if (empty($archivingTables)) {
$this->archivingLaunched = true;
- Piwik_VisitsSummary_API::getInstance()->get(
+ VisitsSummaryAPI::getInstance()->get(
self::$fixture->idSite, self::$fixture->period, self::$fixture->date);
}
}
@@ -38,6 +40,6 @@ class MultiSitesBenchmark extends BenchmarkTestCase
}
Rules::$archivingDisabledByTests = true;
- Piwik_MultiSites_API::getInstance()->getAll(self::$fixture->period, self::$fixture->date);
+ MultiSitesAPI::getInstance()->getAll(self::$fixture->period, self::$fixture->date);
}
}
diff --git a/tests/PHPUnit/Core/AccessTest.php b/tests/PHPUnit/Core/AccessTest.php
index 30e252732f..732d8636e0 100644
--- a/tests/PHPUnit/Core/AccessTest.php
+++ b/tests/PHPUnit/Core/AccessTest.php
@@ -396,11 +396,13 @@ class AccessTest extends DatabaseTestCase
*/
public function testReloadAccessWithMockedAuthValid()
{
- $mock = $this->getMock('Piwik_Login_Auth', array('authenticate'));
+ $mock = $this->getMock('\\Piwik\\Auth', array('authenticate', 'getName'));
$mock->expects($this->once())
->method('authenticate')
->will($this->returnValue(new AuthResult(AuthResult::SUCCESS, 'login', 'token')));
+ $mock->expects($this->any())->method('getName')->will($this->returnValue("test name"));
+
$access = Access::getInstance();
$this->assertTrue($access->reloadAccess($mock));
$this->assertFalse($access->isSuperUser());
@@ -412,11 +414,12 @@ class AccessTest extends DatabaseTestCase
*/
public function testReloadAccessWithMockedAuthSuperUser()
{
- $mock = $this->getMock('Piwik_Login_Auth', array('authenticate'));
+ $mock = $this->getMock('\\Piwik\\Auth', array('authenticate', 'getName'));
$mock->expects($this->once())
->method('authenticate')
->will($this->returnValue(new AuthResult(AuthResult::SUCCESS_SUPERUSER_AUTH_CODE, 'superuser', 'superusertoken')));
+ $mock->expects($this->any())->method('getName')->will($this->returnValue("test name"));
$access = Access::getInstance();
$this->assertTrue($access->reloadAccess($mock));
$this->assertTrue($access->isSuperUser());
@@ -428,11 +431,12 @@ class AccessTest extends DatabaseTestCase
*/
public function testReloadAccessWithMockedAuthInvalidUser()
{
- $mock = $this->getMock('Piwik_Login_Auth', array('authenticate'));
+ $mock = $this->getMock('\\Piwik\\Auth', array('authenticate', 'getName'));
$mock->expects($this->once())
->method('authenticate')
->will($this->returnValue(new AuthResult(AuthResult::FAILURE_CREDENTIAL_INVALID, null, null)));
+ $mock->expects($this->any())->method('getName')->will($this->returnValue("test name"));
$access = Access::getInstance();
$this->assertFalse($access->reloadAccess($mock));
}
diff --git a/tests/PHPUnit/Core/ArchiveProcessingTest.php b/tests/PHPUnit/Core/ArchiveProcessingTest.php
index b341c6960a..657741eef2 100644
--- a/tests/PHPUnit/Core/ArchiveProcessingTest.php
+++ b/tests/PHPUnit/Core/ArchiveProcessingTest.php
@@ -15,6 +15,7 @@ use Piwik\Common;
use Piwik\Access;
use Piwik\Date;
use Piwik\ArchiveProcessor;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Segment;
use Piwik\Site;
use Piwik\Db;
@@ -39,7 +40,7 @@ class ArchiveProcessingTest extends DatabaseTestCase
*/
private function _createWebsite($timezone = 'UTC')
{
- $idSite = Piwik_SitesManager_API::getInstance()->addSite(
+ $idSite = API::getInstance()->addSite(
"site1",
array("http://piwik.net"),
$ecommerce = 0,
diff --git a/tests/PHPUnit/Core/PiwikTest.php b/tests/PHPUnit/Core/PiwikTest.php
index 26a0339309..d9ae053b25 100644
--- a/tests/PHPUnit/Core/PiwikTest.php
+++ b/tests/PHPUnit/Core/PiwikTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Piwik;
use Piwik\Access;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Translate;
class PiwikTest extends DatabaseTestCase
@@ -217,7 +218,7 @@ class PiwikTest extends DatabaseTestCase
$access = Access::getInstance();
$access->setSuperUser(true);
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("test", "http://test");
+ $idsite = API::getInstance()->addSite("test", "http://test");
$this->assertEquals(
$expected,
diff --git a/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php b/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php
index 31b2cfc06c..b246fa20c6 100644
--- a/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php
+++ b/tests/PHPUnit/Core/PluginsFunctions/WidgetsListTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Access;
+use Piwik\Plugins\Goals\API;
use Piwik\WidgetsList;
class WidgetsListTest extends DatabaseTestCase
@@ -70,7 +71,7 @@ class WidgetsListTest extends DatabaseTestCase
Access::setSingletonInstance($pseudoMockAccess);
Test_Piwik_BaseFixture::createWebsite('2009-01-04 00:11:42');
- Piwik_Goals_API::getInstance()->addGoal(1, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 1);
+ API::getInstance()->addGoal(1, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 1);
$_GET['idSite'] = 1;
@@ -107,7 +108,7 @@ class WidgetsListTest extends DatabaseTestCase
Access::setSingletonInstance($pseudoMockAccess);
Test_Piwik_BaseFixture::createWebsite('2009-01-04 00:11:42', true);
- Piwik_Goals_API::getInstance()->addGoal(1, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 1);
+ API::getInstance()->addGoal(1, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 1);
$_GET['idSite'] = 1;
diff --git a/tests/PHPUnit/Core/ScheduledTaskTest.php b/tests/PHPUnit/Core/ScheduledTaskTest.php
index 7bb26624d9..48602d9d96 100644
--- a/tests/PHPUnit/Core/ScheduledTaskTest.php
+++ b/tests/PHPUnit/Core/ScheduledTaskTest.php
@@ -5,6 +5,7 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\PDFReports\PDFReports;
use Piwik\ScheduledTask;
require_once PIWIK_INCLUDE_PATH . '/plugins/PDFReports/PDFReports.php';
@@ -17,8 +18,8 @@ class ScheduledTaskTest extends PHPUnit_Framework_TestCase
*/
public function testGetClassName()
{
- $scheduledTask = new ScheduledTask (new Piwik_PDFReports(), null, null, null);
- $this->assertEquals('Piwik_PDFReports', $scheduledTask->getClassName());
+ $scheduledTask = new ScheduledTask (new PDFReports(), null, null, null);
+ $this->assertEquals('PDFReports', $scheduledTask->getClassName());
}
/**
@@ -27,10 +28,10 @@ class ScheduledTaskTest extends PHPUnit_Framework_TestCase
public function getTaskNameTestCases()
{
return array(
- array('Piwik_CoreAdminHome.purgeOutdatedArchives', 'Piwik_CoreAdminHome', 'purgeOutdatedArchives', null),
- array('Piwik_CoreAdminHome.purgeOutdatedArchives_previous30', 'Piwik_CoreAdminHome', 'purgeOutdatedArchives', 'previous30'),
- array('Piwik_PDFReports.weeklySchedule', 'Piwik_PDFReports', 'weeklySchedule', null),
- array('Piwik_PDFReports.weeklySchedule_1', 'Piwik_PDFReports', 'weeklySchedule', 1),
+ array('CoreAdminHome.purgeOutdatedArchives', 'CoreAdminHome', 'purgeOutdatedArchives', null),
+ array('CoreAdminHome.purgeOutdatedArchives_previous30', 'CoreAdminHome', 'purgeOutdatedArchives', 'previous30'),
+ array('PDFReports.weeklySchedule', 'PDFReports', 'weeklySchedule', null),
+ array('PDFReports.weeklySchedule_1', 'PDFReports', 'weeklySchedule', 1),
);
}
diff --git a/tests/PHPUnit/Core/TaskSchedulerTest.php b/tests/PHPUnit/Core/TaskSchedulerTest.php
index ae6a80ba4b..1e16e0c8a0 100644
--- a/tests/PHPUnit/Core/TaskSchedulerTest.php
+++ b/tests/PHPUnit/Core/TaskSchedulerTest.php
@@ -15,8 +15,8 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase
private static function getTestTimetable()
{
return array(
- 'Piwik_CoreAdminHome.purgeOutdatedArchives' => 1355529607,
- 'Piwik_PrivacyManager.deleteReportData_1' => 1322229607,
+ 'CoreAdminHome.purgeOutdatedArchives' => 1355529607,
+ 'PrivacyManager.deleteReportData_1' => 1322229607,
);
}
@@ -37,10 +37,10 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase
// valid serialized array
array(
array(
- 'Piwik_CoreAdminHome.purgeOutdatedArchives' => 1355529607,
- 'Piwik_PrivacyManager.deleteReportData' => 1355529607,
+ 'CoreAdminHome.purgeOutdatedArchives' => 1355529607,
+ 'PrivacyManager.deleteReportData' => 1355529607,
),
- 'a:2:{s:41:"Piwik_CoreAdminHome.purgeOutdatedArchives";i:1355529607;s:37:"Piwik_PrivacyManager.deleteReportData";i:1355529607;}'
+ 'a:2:{s:35:"CoreAdminHome.purgeOutdatedArchives";i:1355529607;s:31:"PrivacyManager.deleteReportData";i:1355529607;}'
),
);
}
@@ -53,10 +53,9 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase
public function testGetTimetableFromOptionValue($expectedTimetable, $option)
{
$getTimetableFromOptionValue = new ReflectionMethod(
- '\Piwik\TaskScheduler', 'getTimetableFromOptionValue'
+ '\\Piwik\\TaskScheduler', 'getTimetableFromOptionValue'
);
$getTimetableFromOptionValue->setAccessible(true);
-
$this->assertEquals($expectedTimetable, $getTimetableFromOptionValue->invoke(new TaskScheduler(), $option));
}
@@ -68,9 +67,9 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase
$timetable = self::getTestTimetable();
return array(
- array(true, 'Piwik_CoreAdminHome.purgeOutdatedArchives', $timetable),
- array(true, 'Piwik_PrivacyManager.deleteReportData_1', $timetable),
- array(false, 'Piwik_PDFReports.weeklySchedule"', $timetable)
+ array(true, 'CoreAdminHome.purgeOutdatedArchives', $timetable),
+ array(true, 'PrivacyManager.deleteReportData_1', $timetable),
+ array(false, 'PDFReports.weeklySchedule"', $timetable)
);
}
@@ -97,9 +96,9 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase
$timetable = serialize(self::getTestTimetable());
return array(
- array(1355529607, 'Piwik_CoreAdminHome', 'purgeOutdatedArchives', null, $timetable),
- array(1322229607, 'Piwik_PrivacyManager', 'deleteReportData', 1, $timetable),
- array(false, 'Piwik_PDFReports', 'weeklySchedule', null, $timetable)
+ array(1355529607, 'CoreAdminHome', 'purgeOutdatedArchives', null, $timetable),
+ array(1322229607, 'PrivacyManager', 'deleteReportData', 1, $timetable),
+ array(false, 'PDFReports', 'weeklySchedule', null, $timetable)
);
}
@@ -125,15 +124,15 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase
$timetable = self::getTestTimetable();
// set a date in the future (should not run)
- $timetable['Piwik_CoreAdminHome.purgeOutdatedArchives'] = time() + 60000;
+ $timetable['CoreAdminHome.purgeOutdatedArchives'] = time() + 60000;
// set now (should run)
- $timetable['Piwik_PrivacyManager.deleteReportData_1'] = time();
+ $timetable['PrivacyManager.deleteReportData_1'] = time();
return array(
- array(false, 'Piwik_CoreAdminHome.purgeOutdatedArchives', $timetable),
- array(true, 'Piwik_PrivacyManager.deleteReportData_1', $timetable),
- array(false, 'Piwik_PDFReports.weeklySchedule"', $timetable)
+ array(false, 'CoreAdminHome.purgeOutdatedArchives', $timetable),
+ array(true, 'PrivacyManager.deleteReportData_1', $timetable),
+ array(false, 'PDFReports.weeklySchedule"', $timetable)
);
}
@@ -308,7 +307,7 @@ class TaskSchedulerTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expectedExecutedTasks, $executedTasks);
// assert the timetable is correctly updated
- $getTimetableFromOptionTable = new ReflectionMethod('\Piwik\TaskScheduler', 'getTimetableFromOptionTable');
+ $getTimetableFromOptionTable = new ReflectionMethod('\\Piwik\\TaskScheduler', 'getTimetableFromOptionTable');
$getTimetableFromOptionTable->setAccessible(true);
$this->assertEquals($expectedTimetable, $getTimetableFromOptionTable->invoke(new TaskScheduler()));
diff --git a/tests/PHPUnit/Core/Tracker/ActionTest.php b/tests/PHPUnit/Core/Tracker/ActionTest.php
index f04bfafea5..95a0444d4b 100644
--- a/tests/PHPUnit/Core/Tracker/ActionTest.php
+++ b/tests/PHPUnit/Core/Tracker/ActionTest.php
@@ -1,6 +1,7 @@
<?php
use Piwik\Config;
use Piwik\Access;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Tracker\Action;
use Piwik\Tracker\Request;
use Piwik\Translate;
@@ -113,7 +114,7 @@ class Tracker_ActionTest extends DatabaseTestCase
public function testExcludeQueryParametersNone($url, $filteredUrl)
{
$this->setUpRootAccess();
- $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
+ $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null,
$excludedIps = '', $excludedQueryParameters = '', $timezone = null, $currency = null,
$group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1);
@@ -157,7 +158,7 @@ class Tracker_ActionTest extends DatabaseTestCase
{
$excludedQueryParameters = 'p4, p2, var[value][date]';
$this->setUpRootAccess();
- $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
+ $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null,
$excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null,
$group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1);
@@ -177,11 +178,11 @@ class Tracker_ActionTest extends DatabaseTestCase
$excludedQueryParameters = 'P2,var[value][date]';
$excludedGlobalParameters = 'blabla, P4';
$this->setUpRootAccess();
- $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
+ $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null,
$excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null,
$group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1);
- Piwik_SitesManager_API::getInstance()->setGlobalExcludedQueryParameters($excludedGlobalParameters);
+ API::getInstance()->setGlobalExcludedQueryParameters($excludedGlobalParameters);
$this->assertEquals($filteredUrl[1], Action::excludeQueryParametersFromUrl($url, $idSite));
}
@@ -366,7 +367,7 @@ class Tracker_ActionTest extends DatabaseTestCase
public function testExtractUrlAndActionNameFromRequest($request, $expected)
{
$this->setUpRootAccess();
- $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'));
+ $idSite = API::getInstance()->addSite("site1", array('http://example.org'));
$request['idsite'] = $idSite;
$request = new Request($request);
$action = new Test_Piwik_TrackerAction_extractUrlAndActionNameFromRequest($request);
diff --git a/tests/PHPUnit/Core/Tracker/VisitTest.php b/tests/PHPUnit/Core/Tracker/VisitTest.php
index dd5490f2ff..0de590116c 100644
--- a/tests/PHPUnit/Core/Tracker/VisitTest.php
+++ b/tests/PHPUnit/Core/Tracker/VisitTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Access;
use Piwik\IP;
+use Piwik\Plugins\SitesManager\API;
use Piwik\Tracker\VisitExcluded;
use Piwik\Tracker\Request;
@@ -74,7 +75,7 @@ class Tracker_VisitTest extends DatabaseTestCase
*/
public function testIsVisitorIpExcluded($excludedIp, $tests)
{
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0,
+ $idsite = API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIp);
$request = new Request(array('idsite' => $idsite));
@@ -121,9 +122,9 @@ class Tracker_VisitTest extends DatabaseTestCase
*/
public function testIsVisitorUserAgentExcluded($excludedUserAgent, $tests)
{
- Piwik_SitesManager_API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(true);
+ API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(true);
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0,
+ $idsite = API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIp = null,
$excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null,
$excludedUserAgent);
diff --git a/tests/PHPUnit/DatabaseTestCase.php b/tests/PHPUnit/DatabaseTestCase.php
index 47a34f8bbe..39395c375d 100644
--- a/tests/PHPUnit/DatabaseTestCase.php
+++ b/tests/PHPUnit/DatabaseTestCase.php
@@ -10,6 +10,7 @@ use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\DataTable\Manager;
use Piwik\Piwik;
use Piwik\Option;
+use Piwik\Plugins\PDFReports\API;
use Piwik\Site;
use Piwik\Tracker\Cache;
@@ -71,7 +72,7 @@ class DatabaseTestCase extends PHPUnit_Framework_TestCase
Piwik::dropDatabase();
Manager::getInstance()->deleteAll();
Option::getInstance()->clearCache();
- Piwik_PDFReports_API::$cache = array();
+ API::$cache = array();
Site::clearCache();
Cache::deleteTrackerCache();
Config::getInstance()->clear();
diff --git a/tests/PHPUnit/FakeAccess.php b/tests/PHPUnit/FakeAccess.php
index 0498531052..5b72265dff 100644
--- a/tests/PHPUnit/FakeAccess.php
+++ b/tests/PHPUnit/FakeAccess.php
@@ -5,6 +5,7 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\SitesManager\API;
use Piwik\Site;
/**
@@ -64,7 +65,7 @@ class FakeAccess
if (!self::$superUser) {
$websitesAccess = self::$idSitesAdmin;
} else {
- $websitesAccess = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $websitesAccess = API::getInstance()->getAllSitesId();
}
$idSites = Site::getIdSitesFromIdSitesString($idSites);
@@ -81,12 +82,12 @@ class FakeAccess
if (!self::$superUser) {
$websitesAccess = array_merge(self::$idSitesView, self::$idSitesAdmin);
} else {
- $websitesAccess = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $websitesAccess = API::getInstance()->getAllSitesId();
}
if (!is_array($idSites)) {
if ($idSites == 'all') {
- $idSites = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $idSites = API::getInstance()->getAllSitesId();
} else {
$idSites = explode(',', $idSites);
}
@@ -134,7 +135,7 @@ class FakeAccess
public static function getSitesIdWithAdminAccess()
{
if (self::$superUser) {
- return Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ return API::getInstance()->getAllSitesId();
}
return self::$idSitesAdmin;
}
@@ -142,7 +143,7 @@ class FakeAccess
public static function getSitesIdWithViewAccess()
{
if (self::$superUser) {
- return Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ return API::getInstance()->getAllSitesId();
}
return self::$idSitesView;
}
@@ -150,7 +151,7 @@ class FakeAccess
public static function getSitesIdWithAtLeastViewAccess()
{
if (self::$superUser) {
- return Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ return API::getInstance()->getAllSitesId();
}
return array_merge(self::$idSitesView, self::$idSitesAdmin);
}
diff --git a/tests/PHPUnit/Fixtures/InvalidVisits.php b/tests/PHPUnit/Fixtures/InvalidVisits.php
index 144227e1c0..8e31367b58 100644
--- a/tests/PHPUnit/Fixtures/InvalidVisits.php
+++ b/tests/PHPUnit/Fixtures/InvalidVisits.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Http;
+use Piwik\Plugins\SitesManager\API;
/**
* Adds one site and sends several invalid tracking requests. The result should be
@@ -43,8 +44,8 @@ class Test_Piwik_Fixture_InvalidVisits extends Test_Piwik_BaseFixture
$dateTime = $this->dateTime;
$idSite = $this->idSite;
- Piwik_SitesManager_API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(true);
- Piwik_SitesManager_API::getInstance()->setGlobalExcludedUserAgents('globalexcludeduseragent');
+ API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(true);
+ API::getInstance()->setGlobalExcludedUserAgents('globalexcludeduseragent');
// Trigger empty request
$trackerUrl = self::getTrackerUrl();
@@ -60,7 +61,7 @@ class Test_Piwik_Fixture_InvalidVisits extends Test_Piwik_BaseFixture
// Test IP Exclusion works with or without IP exclusion
foreach (array(false, true) as $enable) {
$excludedIp = '154.1.12.34';
- Piwik_SitesManager_API::getInstance()->updateSite($idSite, 'new site name', $url = array('http://site.com'), $ecommerce = 0, $ss = 1, $ss_kwd = '', $ss_cat = '', $excludedIp . ',1.2.3.4', $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = 'excludeduseragentstring');
+ API::getInstance()->updateSite($idSite, 'new site name', $url = array('http://site.com'), $ecommerce = 0, $ss = 1, $ss_kwd = '', $ss_cat = '', $excludedIp . ',1.2.3.4', $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = 'excludeduseragentstring');
// Enable IP Anonymization
$t->DEBUG_APPEND_URL = '&forceIpAnonymization=' . (int)$enable;
@@ -82,7 +83,7 @@ class Test_Piwik_Fixture_InvalidVisits extends Test_Piwik_BaseFixture
// test with global list of excluded IPs
$excludedIpBis = '145.5.3.4';
- Piwik_SitesManager_API::getInstance()->setGlobalExcludedIps($excludedIpBis);
+ API::getInstance()->setGlobalExcludedIps($excludedIpBis);
$t->setIp($excludedIpBis);
self::checkResponse($t->doTrackPageView('visit from IP globally excluded'));
}
diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
index 8cd88282d5..00195af780 100644
--- a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
+++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
@@ -6,6 +6,10 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Access;
+use Piwik\Plugins\Goals\API as GoalsAPI;
+use Piwik\Plugins\SegmentEditor\API as SegmentEditorAPI;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
/**
* Imports visits from several log files using the python log importer.
@@ -25,9 +29,9 @@ class Test_Piwik_Fixture_ManySitesImportedLogs extends Test_Piwik_BaseFixture
$this->setUpWebsitesAndGoals();
self::downloadGeoIpDbs();
- Piwik_UserCountry_LocationProvider::$providers = null;
- Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
- Piwik_UserCountry_LocationProvider::setCurrentProvider('geoip_php');
+ LocationProvider::$providers = null;
+ GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
+ LocationProvider::setCurrentProvider('geoip_php');
$this->trackVisits();
$this->setupSegments();
@@ -35,16 +39,16 @@ class Test_Piwik_Fixture_ManySitesImportedLogs extends Test_Piwik_BaseFixture
public function tearDown()
{
- Piwik_UserCountry_LocationProvider::$providers = null;
- Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
- Piwik_UserCountry_LocationProvider::setCurrentProvider('default');
+ LocationProvider::$providers = null;
+ GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
+ LocationProvider::setCurrentProvider('default');
}
public function setUpWebsitesAndGoals()
{
// for conversion testing
self::createWebsite($this->dateTime);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
+ GoalsAPI::getInstance()->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'Piwik test two',
$siteUrl = 'http://example-site-two.com');
}
@@ -101,7 +105,7 @@ class Test_Piwik_Fixture_ManySitesImportedLogs extends Test_Piwik_BaseFixture
$enabledAllUsers = $info['enabledAllUsers'];
}
- Piwik_SegmentEditor_API::getInstance()->add(
+ SegmentEditorAPI::getInstance()->add(
$segmentName, $info['definition'], $idSite, $autoArchive, $enabledAllUsers);
}
}
diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
index 9e41a64955..57611b8c04 100644
--- a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
+++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php
@@ -7,6 +7,9 @@
*/
use Piwik\Common;
use Piwik\FrontController;
+use Piwik\Plugins\Annotations\API as AnnotationsAPI;
+use Piwik\Plugins\Goals\API as GoalsAPI;
+use Piwik\Plugins\SegmentEditor\API as SegmentEditorAPI;
use Piwik\WidgetsList;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php';
@@ -31,7 +34,7 @@ class Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts extends Test_Piwik
// for conversion testing
$siteName = self::makeXssContent("site name", $sanitize = true);
self::createWebsite($this->dateTime, $ecommerce = 1, $siteName);
- Piwik_Goals_API::getInstance()->addGoal(
+ GoalsAPI::getInstance()->addGoal(
$this->idSite, self::makeXssContent("goal name"), 'url', 'http', 'contains', false, 5);
self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'Piwik test two',
@@ -101,16 +104,16 @@ class Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts extends Test_Piwik
{
$segmentName = self::makeXssContent('segment');
$segmentDefinition = "browserCode==FF";
- Piwik_SegmentEditor_API::getInstance()->add(
+ SegmentEditorAPI::getInstance()->add(
$segmentName, $segmentDefinition, $this->idSite, $autoArchive = true, $enabledAllUsers = true);
}
public function addAnnotations()
{
- Piwik_Annotations_API::getInstance()->add($this->idSite, '2012-08-09', "Note 1", $starred = 1);
- Piwik_Annotations_API::getInstance()->add(
+ AnnotationsAPI::getInstance()->add($this->idSite, '2012-08-09', "Note 1", $starred = 1);
+ AnnotationsAPI::getInstance()->add(
$this->idSite, '2012-08-08', self::makeXssContent("annotation"), $starred = 0);
- Piwik_Annotations_API::getInstance()->add($this->idSite, '2012-08-10', "Note 3", $starred = 1);
+ AnnotationsAPI::getInstance()->add($this->idSite, '2012-08-10', "Note 3", $starred = 1);
}
// NOTE: since API_Request does sanitization, API methods do not. when calling them, we must
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
index 074433d85f..916a7b4660 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php
@@ -7,6 +7,9 @@
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php';
@@ -63,8 +66,8 @@ class Test_Piwik_Fixture_ManyVisitsWithGeoIP extends Test_Piwik_BaseFixture
private function setUpWebsitesAndGoals()
{
self::createWebsite($this->dateTime, 0, "Site 1");
- $this->idGoal = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
- $this->idGoal2 = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'two', 'url', 'xxxxxxxxxxxxx', 'contains', false, 5);
+ $this->idGoal = API::getInstance()->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
+ $this->idGoal2 = API::getInstance()->addGoal($this->idSite, 'two', 'url', 'xxxxxxxxxxxxx', 'contains', false, 5);
}
private function trackVisits($visitorCount, $setIp = false, $useLocal = true, $doBulk = false)
@@ -167,25 +170,25 @@ class Test_Piwik_Fixture_ManyVisitsWithGeoIP extends Test_Piwik_BaseFixture
private function setLocationProvider($file)
{
- Piwik_UserCountry_LocationProvider_GeoIp::$dbNames['loc'] = array($file);
- Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
- Piwik_UserCountry_LocationProvider::$providers = null;
- Piwik_UserCountry_LocationProvider::setCurrentProvider(self::GEOIP_IMPL_TO_TEST);
+ GeoIp::$dbNames['loc'] = array($file);
+ GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
+ LocationProvider::$providers = null;
+ LocationProvider::setCurrentProvider(self::GEOIP_IMPL_TO_TEST);
- if (Piwik_UserCountry_LocationProvider::getCurrentProviderId() !== self::GEOIP_IMPL_TO_TEST) {
+ if (LocationProvider::getCurrentProviderId() !== self::GEOIP_IMPL_TO_TEST) {
throw new Exception("Failed to set the current location provider to '" . self::GEOIP_IMPL_TO_TEST . "'.");
}
- $possibleFiles = Piwik_UserCountry_LocationProvider_GeoIp::$dbNames['loc'];
- if (Piwik_UserCountry_LocationProvider_GeoIp::getPathToGeoIpDatabase($possibleFiles) === false) {
+ $possibleFiles = GeoIp::$dbNames['loc'];
+ if (GeoIp::getPathToGeoIpDatabase($possibleFiles) === false) {
throw new Exception("The GeoIP location provider cannot find the '$file' file! Tests will fail.");
}
}
private function setMockLocationProvider()
{
- Piwik_UserCountry_LocationProvider::$providers = null;
- Piwik_UserCountry_LocationProvider::setCurrentProvider('mock_provider');
+ LocationProvider::$providers = null;
+ LocationProvider::setCurrentProvider('mock_provider');
MockLocationProvider::$locations = array(
self::makeLocation('Stratford-upon-Avon', 'P3', 'gb', 123.456, 21.321), // template location
@@ -217,7 +220,7 @@ class Test_Piwik_Fixture_ManyVisitsWithGeoIP extends Test_Piwik_BaseFixture
private function unsetLocationProvider()
{
- Piwik_UserCountry_LocationProvider::setCurrentProvider('default');
+ LocationProvider::setCurrentProvider('default');
}
}
diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
index be3d29c30f..e3a0997340 100644
--- a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
+++ b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php
@@ -7,6 +7,7 @@
*/
use Piwik\Date;
+use Piwik\Plugins\UserCountry\LocationProvider;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php';
@@ -204,7 +205,7 @@ class Test_Piwik_Fixture_ManyVisitsWithMockLocationProvider extends Test_Piwik_B
private function setMockLocationProvider()
{
- Piwik_UserCountry_LocationProvider::setCurrentProvider('mock_provider');
+ LocationProvider::setCurrentProvider('mock_provider');
MockLocationProvider::$locations = array(
self::makeLocation('Toronto', 'ON', 'CA', $lat = null, $long = null, $isp = 'comcast.net'),
@@ -218,6 +219,6 @@ class Test_Piwik_Fixture_ManyVisitsWithMockLocationProvider extends Test_Piwik_B
private function unsetMockLocationProvider()
{
- Piwik_UserCountry_LocationProvider::setCurrentProvider('default');
+ LocationProvider::setCurrentProvider('default');
}
}
diff --git a/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php b/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
index 64c3312628..e2323cd60e 100644
--- a/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
+++ b/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API as GoalsAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
* This fixture adds one website and tracks two visits by one visitor.
@@ -41,7 +43,7 @@ class Test_Piwik_Fixture_OneVisitorTwoVisits extends Test_Piwik_BaseFixture
$idSite = $this->idSite;
if ($this->excludeMozilla) {
- Piwik_SitesManager_API::getInstance()->setSiteSpecificUserAgentExcludeEnabled(false);
+ SitesManagerAPI::getInstance()->setSiteSpecificUserAgentExcludeEnabled(false);
}
$t = self::getTracker($idSite, $dateTime, $defaultInit = true);
@@ -56,7 +58,7 @@ class Test_Piwik_Fixture_OneVisitorTwoVisits extends Test_Piwik_BaseFixture
// testing URL excluded parameters
$parameterToExclude = 'excluded_parameter';
- Piwik_SitesManager_API::getInstance()->updateSite(
+ SitesManagerAPI::getInstance()->updateSite(
$idSite,
'new name',
$url = array('http://site.com'),
@@ -102,7 +104,7 @@ class Test_Piwik_Fixture_OneVisitorTwoVisits extends Test_Piwik_BaseFixture
self::checkResponse($t->doTrackAction('http://dev.piwik.org/svn', 'link'));
// Create Goal 1: Triggered by JS, after 18 minutes
- $idGoal = Piwik_Goals_API::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
+ $idGoal = GoalsAPI::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.3)->getDatetime());
// Change to Thai browser to ensure the conversion is credited to FR instead (the visitor initial country)
@@ -139,7 +141,7 @@ class Test_Piwik_Fixture_OneVisitorTwoVisits extends Test_Piwik_BaseFixture
// End of first visit: 24min
// Create Goal 2: Matching on URL
- Piwik_Goals_API::getInstance()->addGoal($idSite, 'matching purchase.htm', 'url', '(.*)store\/purchase\.(.*)', 'regex', false, $revenue = 1);
+ GoalsAPI::getInstance()->addGoal($idSite, 'matching purchase.htm', 'url', '(.*)store\/purchase\.(.*)', 'regex', false, $revenue = 1);
// -
// Start of returning visit, 1 hour after first page view
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php b/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
index ad47b32696..272a809154 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds one site and tracks a couple conversions.
@@ -33,13 +34,13 @@ class Piwik_Test_Fixture_SomeVisitsAllConversions extends Test_Piwik_BaseFixture
self::createWebsite($this->dateTime);
// First, a goal that is only recorded once per visit
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal(
$this->idSite, 'triggered js ONCE', 'title', 'Thank you', 'contains', $caseSensitive = false,
$revenue = 10, $allowMultipleConversions = false
);
// Second, a goal allowing multiple conversions
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal(
$this->idSite, 'triggered js MULTIPLE ALLOWED', 'manually', '', '', $caseSensitive = false,
$revenue = 10, $allowMultipleConversions = true
);
@@ -68,10 +69,10 @@ class Piwik_Test_Fixture_SomeVisitsAllConversions extends Test_Piwik_BaseFixture
self::checkResponse($t->doTrackGoal($idGoal_MultipleConversionPerVisit, $revenue = 366));
// Update & set to not allow multiple
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
$goal = $goals[$idGoal_OneConversionPerVisit];
self::assertTrue($goal['allow_multiple'] == 0);
- Piwik_Goals_API::getInstance()->updateGoal($idSite, $idGoal_OneConversionPerVisit, $goal['name'], @$goal['match_attribute'], @$goal['pattern'], @$goal['pattern_type'], @$goal['case_sensitive'], $goal['revenue'], $goal['allow_multiple'] = 1);
+ API::getInstance()->updateGoal($idSite, $idGoal_OneConversionPerVisit, $goal['name'], @$goal['match_attribute'], @$goal['pattern'], @$goal['pattern_type'], @$goal['case_sensitive'], $goal['revenue'], $goal['allow_multiple'] = 1);
self::assertTrue($goal['allow_multiple'] == 1);
// 1st goal should Now be tracked
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
index be0e42eed9..57f7826bd1 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Add one site and track many visits with custom variables & campaign IDs and
@@ -31,7 +32,7 @@ class Test_Piwik_Fixture_SomeVisitsCustomVariablesCampaignsNotHeuristics extends
private function setUpWebsitesAndGoals()
{
self::createWebsite($this->dateTime);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
+ API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
}
private function trackVisits()
diff --git a/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php b/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
index 199fc69123..23819ec4e3 100644
--- a/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
+++ b/tests/PHPUnit/Fixtures/SomeVisitsWithNonUnicodePageTitles.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\SitesManager\API;
/**
* Adds one website and some visits with non unicode page titles.
@@ -33,7 +34,7 @@ class Test_Piwik_Fixture_SomeVisitsWithNonUnicodePageTitles extends Test_Piwik_B
*/
private function setUpWebsites()
{
- Piwik_SitesManager_API::getInstance()->setGlobalSearchParameters($searchKeywordParameters = 'gkwd', $searchCategoryParameters = 'gcat');
+ API::getInstance()->setGlobalSearchParameters($searchKeywordParameters = 'gkwd', $searchCategoryParameters = 'gcat');
self::createWebsite(Date::factory($this->dateTime)->getDatetime(), 0, "Site 1 - Site search", $siteurl = false, $search = 1, $searchKwd = 'q,mykwd,p', $searchCat = 'cats');
}
diff --git a/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php b/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
index 3ef00a5188..71d0be9fb0 100644
--- a/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
+++ b/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Fixture that adds one site with three goals and tracks one pageview & one manual
@@ -33,17 +34,17 @@ class Test_Piwik_Fixture_ThreeGoalsOnePageview extends Test_Piwik_BaseFixture
private function setUpWebsitesAndGoals()
{
self::createWebsite($this->dateTime, $ecommerce = 1);
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal(
$this->idSite, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false,
$revenue = 10, $allowMultipleConversions = 1
);
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal(
$this->idSite, 'Goal 2 - Hello', 'url', 'hellow', 'contains', $caseSensitive = false,
$revenue = 10, $allowMultipleConversions = 0
);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
+ API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
}
private function trackVisits()
diff --git a/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php b/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
index a5b747debf..cecddf208a 100644
--- a/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
+++ b/tests/PHPUnit/Fixtures/ThreeSitesWithManyVisitsWithSiteSearch.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\SitesManager\API;
/**
* Adds three websites with different site search configurations and adds
@@ -36,7 +37,7 @@ class Test_Piwik_Fixture_ThreeSitesWithManyVisitsWithSiteSearch extends Test_Piw
*/
protected function setUpWebsites()
{
- Piwik_SitesManager_API::getInstance()->setGlobalSearchParameters($searchKeywordParameters = 'gkwd', $searchCategoryParameters = 'gcat');
+ API::getInstance()->setGlobalSearchParameters($searchKeywordParameters = 'gkwd', $searchCategoryParameters = 'gcat');
self::createWebsite(Date::factory($this->dateTime)->subHour(200)->getDatetime(), 0, "Site 1 - Site search", $siteurl = false, $search = 1, $searchKwd = 'q,mykwd,p', $searchCat = 'cats');
self::createWebsite(Date::factory($this->dateTime)->subHour(400)->getDatetime(), 0, "Site 2 - Site search use default", $siteurl = false, $search = 1, $searchKwd = '', $searchCat = '');
self::createWebsite(Date::factory($this->dateTime)->subHour(600)->getDatetime(), 0, "Site 3 - No site search", $siteurl = false, $search = 0);
diff --git a/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php b/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
index 33e244d7ca..675bf59fa7 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds two sites and tracks some visits with ecommerce orders.
@@ -33,7 +34,7 @@ class Test_Piwik_Fixture_TwoSitesEcommerceOrderWithItems extends Test_Piwik_Base
{
self::createWebsite($this->dateTime, $ecommerce = 1);
self::createWebsite($this->dateTime);
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal(
$this->idSite, 'title match, triggered ONCE', 'title', 'incredible', 'contains',
$caseSensitive = false, $revenue = 10, $allowMultipleConversions = true
);
diff --git a/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php b/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
index a122bb5436..4ff6ab125c 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds one website and tracks visits on different days over a month
@@ -38,8 +39,8 @@ class Test_Piwik_Fixture_TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferr
$siteCreated = '2010-02-01 11:22:33';
self::createWebsite($siteCreated);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'triggered php', 'manually', '', '');
- Piwik_Goals_API::getInstance()->addGoal(
+ API::getInstance()->addGoal($this->idSite, 'triggered php', 'manually', '', '');
+ API::getInstance()->addGoal(
$this->idSite, 'another triggered php', 'manually', '', '', false, false, true);
self::createWebsite($siteCreated);
diff --git a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
index ad7dfa0476..bac08e4346 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API as GoalsAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
/**
* Adds two websites and tracks visits from two visitors on different days.
@@ -41,16 +43,16 @@ class Test_Piwik_Fixture_TwoSitesTwoVisitorsDifferentDays extends Test_Piwik_Bas
self::createWebsite($this->dateTime, 0, "Site 2");
if ($this->allowConversions) {
- Piwik_Goals_API::getInstance()->addGoal($this->idSite1, 'all', 'url', 'http', 'contains', false, 5);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite2, 'all', 'url', 'http', 'contains');
+ GoalsAPI::getInstance()->addGoal($this->idSite1, 'all', 'url', 'http', 'contains', false, 5);
+ GoalsAPI::getInstance()->addGoal($this->idSite2, 'all', 'url', 'http', 'contains');
}
- Piwik_SitesManager_API::getInstance()->updateSite(
+ SitesManagerAPI::getInstance()->updateSite(
$this->idSite1, "Site 1", $urls = null, $ecommerce = null, $siteSearch = null,
$searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null,
$excludedQueryParameters = null, $timezone = null, $currency = null, $group = null,
$startDate = null, $excludedUserAgents = null, $keepURLFragments = 2); // KEEP_URL_FRAGMENT_NO No for idSite 1
- Piwik_SitesManager_API::getInstance()->updateSite(
+ SitesManagerAPI::getInstance()->updateSite(
$this->idSite2, "Site 2", $urls = null, $ecommerce = null, $siteSearch = null,
$searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null,
$excludedQueryParameters = null, $timezone = null, $currency = null, $group = null,
diff --git a/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php b/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
index 83b4eded01..29f9d75da8 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesWithAnnotations.php
@@ -7,6 +7,7 @@
*/
use Piwik\Access;
use Piwik\Date;
+use Piwik\Plugins\Annotations\API;
/**
* A fixture that adds two websites and annotations for each website.
@@ -45,8 +46,8 @@ class Test_Piwik_Fixture_TwoSitesWithAnnotations extends Test_Piwik_BaseFixture
$site1Text = "$count: Site 1 annotation for " . $dateStart->toString();
$site2Text = "$count: Site 2 annotation for " . $dateStart->toString();
- Piwik_Annotations_API::getInstance()->add($this->idSite1, $dateStart->toString(), $site1Text, $starred);
- Piwik_Annotations_API::getInstance()->add($this->idSite2, $dateStart->toString(), $site2Text, $starred);
+ API::getInstance()->add($this->idSite1, $dateStart->toString(), $site1Text, $starred);
+ API::getInstance()->add($this->idSite2, $dateStart->toString(), $site2Text, $starred);
$nextDay = $dateStart->addDay(1);
++$count;
@@ -55,8 +56,8 @@ class Test_Piwik_Fixture_TwoSitesWithAnnotations extends Test_Piwik_BaseFixture
$site1Text = "$count: Site 1 annotation for " . $nextDay->toString();
$site2Text = "$count: Site 2 annotation for " . $nextDay->toString();
- Piwik_Annotations_API::getInstance()->add($this->idSite1, $nextDay->toString(), $site1Text, $starred);
- Piwik_Annotations_API::getInstance()->add($this->idSite2, $nextDay->toString(), $site2Text, $starred);
+ API::getInstance()->add($this->idSite1, $nextDay->toString(), $site1Text, $starred);
+ API::getInstance()->add($this->idSite2, $nextDay->toString(), $site2Text, $starred);
$dateStart = $dateStart->addPeriod(1, 'WEEK');
++$count;
diff --git a/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php b/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
index fe28c492d9..2e69bacded 100644
--- a/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
+++ b/tests/PHPUnit/Fixtures/TwoVisitsNoKeywordWithBot.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds one site and tracks two visits. One visit is a bot and one has no keyword
@@ -49,7 +50,7 @@ class Test_Piwik_Fixture_TwoVisitsNoKeywordWithBot extends Test_Piwik_BaseFixtur
$t->setUrlReferrer('http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC&url=http%3A%2F%2Fpiwik.org%2F&ei=&usg=');
$t->setUrl('http://example.org/this%20is%20cool!');
self::checkResponse($t->doTrackPageView('incredible title!'));
- $idGoal = Piwik_Goals_API::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
+ $idGoal = API::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.3)->getDatetime());
self::checkResponse($t->doTrackGoal($idGoal, $revenue = 42));
diff --git a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
index 5ab144c115..735d2bf726 100644
--- a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
+++ b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Date;
+use Piwik\Plugins\Goals\API;
/**
* Adds one site with two goals and tracks two visits with custom variables.
@@ -39,8 +40,8 @@ class Test_Piwik_Fixture_TwoVisitsWithCustomVariables extends Test_Piwik_BaseFix
{
// tests run in UTC, the Tracker in UTC
self::createWebsite($this->dateTime);
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
- Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'second goal', 'manually', '', '');
+ API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
+ API::getInstance()->addGoal($this->idSite, 'second goal', 'manually', '', '');
}
private function trackVisits()
diff --git a/tests/PHPUnit/Integration/AnnotationsTest.php b/tests/PHPUnit/Integration/AnnotationsTest.php
index b7322b5a92..5d7b29ccb9 100755
--- a/tests/PHPUnit/Integration/AnnotationsTest.php
+++ b/tests/PHPUnit/Integration/AnnotationsTest.php
@@ -8,6 +8,7 @@
use Piwik\API\Request;
use Piwik\Access;
+use Piwik\Plugins\Annotations\API;
class AnnotationsTest extends IntegrationTestCase
{
@@ -94,7 +95,7 @@ class AnnotationsTest extends IntegrationTestCase
public function testAddMultipleSitesFail()
{
try {
- Piwik_Annotations_API::getInstance()->add("1,2,3", "2012-01-01", "whatever");
+ API::getInstance()->add("1,2,3", "2012-01-01", "whatever");
$this->fail("add should fail when given multiple sites in idSite");
} catch (Exception $ex) {
// pass
@@ -108,7 +109,7 @@ class AnnotationsTest extends IntegrationTestCase
public function testAddInvalidDateFail()
{
try {
- Piwik_Annotations_API::getInstance()->add(self::$fixture->idSite1, "invaliddate", "whatever");
+ API::getInstance()->add(self::$fixture->idSite1, "invaliddate", "whatever");
$this->fail("add should fail when given invalid date");
} catch (Exception $ex) {
// pass
@@ -122,7 +123,7 @@ class AnnotationsTest extends IntegrationTestCase
public function testSaveMultipleSitesFail()
{
try {
- Piwik_Annotations_API::getInstance()->save("1,2,3", 0);
+ API::getInstance()->save("1,2,3", 0);
$this->fail("save should fail when given multiple sites");
} catch (Exception $ex) {
// pass
@@ -136,7 +137,7 @@ class AnnotationsTest extends IntegrationTestCase
public function testSaveInvalidDateFail()
{
try {
- Piwik_Annotations_API::getInstance()->save(self::$fixture->idSite1, 0, "invaliddate");
+ API::getInstance()->save(self::$fixture->idSite1, 0, "invaliddate");
$this->fail("save should fail when given an invalid date");
} catch (Exception $ex) {
// pass
@@ -150,7 +151,7 @@ class AnnotationsTest extends IntegrationTestCase
public function testSaveInvalidNoteIdFail()
{
try {
- Piwik_Annotations_API::getInstance()->save(self::$fixture->idSite1, -1);
+ API::getInstance()->save(self::$fixture->idSite1, -1);
$this->fail("save should fail when given an invalid note id");
} catch (Exception $ex) {
// pass
@@ -164,7 +165,7 @@ class AnnotationsTest extends IntegrationTestCase
public function testDeleteMultipleSitesFail()
{
try {
- Piwik_Annotations_API::getInstance()->delete("1,2,3", 0);
+ API::getInstance()->delete("1,2,3", 0);
$this->fail("delete should fail when given multiple site IDs");
} catch (Exception $ex) {
// pass
@@ -178,7 +179,7 @@ class AnnotationsTest extends IntegrationTestCase
public function testDeleteInvalidNoteIdFail()
{
try {
- Piwik_Annotations_API::getInstance()->delete(self::$fixture->idSite1, -1);
+ API::getInstance()->delete(self::$fixture->idSite1, -1);
$this->fail("delete should fail when given an invalid site ID");
} catch (Exception $ex) {
// pass
@@ -192,7 +193,7 @@ class AnnotationsTest extends IntegrationTestCase
public function testGetMultipleSitesFail()
{
try {
- Piwik_Annotations_API::getInstance()->get("1,2,3", 0);
+ API::getInstance()->get("1,2,3", 0);
$this->fail("get should fail when given multiple site IDs");
} catch (Exception $ex) {
// pass
@@ -206,7 +207,7 @@ class AnnotationsTest extends IntegrationTestCase
public function testGetInvalidNoteIdFail()
{
try {
- Piwik_Annotations_API::getInstance()->get(self::$fixture->idSite1, -1);
+ API::getInstance()->get(self::$fixture->idSite1, -1);
$this->fail("get should fail when given an invalid note ID");
} catch (Exception $ex) {
// pass
@@ -219,7 +220,7 @@ class AnnotationsTest extends IntegrationTestCase
*/
public function testSaveSuccess()
{
- Piwik_Annotations_API::getInstance()->save(
+ API::getInstance()->save(
self::$fixture->idSite1, 0, $date = '2011-04-01', $note = 'new note text', $starred = 1);
$expectedAnnotation = array(
@@ -230,7 +231,7 @@ class AnnotationsTest extends IntegrationTestCase
'idNote' => 0,
'canEditOrDelete' => true
);
- $this->assertEquals($expectedAnnotation, Piwik_Annotations_API::getInstance()->get(self::$fixture->idSite1, 0));
+ $this->assertEquals($expectedAnnotation, API::getInstance()->get(self::$fixture->idSite1, 0));
}
/**
@@ -239,7 +240,7 @@ class AnnotationsTest extends IntegrationTestCase
*/
public function testSaveNoChangesSuccess()
{
- Piwik_Annotations_API::getInstance()->save(self::$fixture->idSite1, 1);
+ API::getInstance()->save(self::$fixture->idSite1, 1);
$expectedAnnotation = array(
'date' => '2011-12-02',
@@ -249,7 +250,7 @@ class AnnotationsTest extends IntegrationTestCase
'idNote' => 1,
'canEditOrDelete' => true
);
- $this->assertEquals($expectedAnnotation, Piwik_Annotations_API::getInstance()->get(self::$fixture->idSite1, 1));
+ $this->assertEquals($expectedAnnotation, API::getInstance()->get(self::$fixture->idSite1, 1));
}
/**
@@ -258,10 +259,10 @@ class AnnotationsTest extends IntegrationTestCase
*/
public function testDeleteSuccess()
{
- Piwik_Annotations_API::getInstance()->delete(self::$fixture->idSite1, 1);
+ API::getInstance()->delete(self::$fixture->idSite1, 1);
try {
- Piwik_Annotations_API::getInstance()->get(self::$fixture->idSite1, 1);
+ API::getInstance()->get(self::$fixture->idSite1, 1);
$this->fail("failed to delete annotation");
} catch (Exception $ex) {
// pass
diff --git a/tests/PHPUnit/Integration/ArchiveCronTest.php b/tests/PHPUnit/Integration/ArchiveCronTest.php
index bd036cd3e0..8e95298147 100644
--- a/tests/PHPUnit/Integration/ArchiveCronTest.php
+++ b/tests/PHPUnit/Integration/ArchiveCronTest.php
@@ -8,6 +8,7 @@
use Piwik\Piwik;
use Piwik\Access;
use Piwik\Date;
+use Piwik\Plugins\SitesManager\API;
/**
* Tests the archive.php cron script.
@@ -90,7 +91,7 @@ class Test_Piwik_Integration_ArchiveCronTest extends IntegrationTestCase
private function setLastRunArchiveOptions()
{
$periodTypes = array('day', 'periods');
- $idSites = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $idSites = API::getInstance()->getAllSitesId();
$time = Date::factory(self::$fixture->dateTime)->subDay(1)->getTimestamp();
@@ -130,4 +131,4 @@ class Test_Piwik_Integration_ArchiveCronTest extends IntegrationTestCase
}
Test_Piwik_Integration_ArchiveCronTest::$fixture = new Test_Piwik_Fixture_ManySitesImportedLogs();
-Test_Piwik_Integration_ArchiveCronTest::$fixture->addSegments = true; \ No newline at end of file
+Test_Piwik_Integration_ArchiveCronTest::$fixture->addSegments = true;
diff --git a/tests/PHPUnit/Integration/AutoSuggestAPITest.php b/tests/PHPUnit/Integration/AutoSuggestAPITest.php
index 1433c3ce66..838cce31f4 100644
--- a/tests/PHPUnit/Integration/AutoSuggestAPITest.php
+++ b/tests/PHPUnit/Integration/AutoSuggestAPITest.php
@@ -42,7 +42,7 @@ class Test_Piwik_Integration_AutoSuggestAPITest extends IntegrationTestCase
$idSite = self::$fixture->idSite;
$apiForTesting = array();
- $segments = Piwik_API_API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
+ $segments = \Piwik\Plugins\API\API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
foreach ($segments as $segment) {
$apiForTesting[] = $this->getApiForTestingForSegment($idSite, $segment['segment']);
}
@@ -102,7 +102,7 @@ class Test_Piwik_Integration_AutoSuggestAPITest extends IntegrationTestCase
public function getAnotherApiForTesting()
{
$apiForTesting = array();
- $segments = Piwik_API_API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
+ $segments = \Piwik\Plugins\API\API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
foreach ($segments as $segment) {
$apiForTesting[] = array('VisitsSummary.get',
array('idSite' => self::$fixture->idSite,
diff --git a/tests/PHPUnit/Integration/BlobReportLimitingTest.php b/tests/PHPUnit/Integration/BlobReportLimitingTest.php
index 367bfd21bf..835822ed6a 100755
--- a/tests/PHPUnit/Integration/BlobReportLimitingTest.php
+++ b/tests/PHPUnit/Integration/BlobReportLimitingTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Config;
+use Piwik\Plugins\Actions\ArchivingHelper;
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/MockLocationProvider.php';
@@ -109,7 +110,7 @@ class Test_Piwik_Integration_BlobReportLimitingTest extends IntegrationTestCase
$generalConfig['datatable_archiving_maximum_rows_subtable_custom_variables'] = 4;
$generalConfig['datatable_archiving_maximum_rows_standard'] = 4;
Config::getInstance()->General['archiving_ranking_query_row_limit'] = 3;
- Piwik_Actions_ArchivingHelper::reloadConfig();
+ ArchivingHelper::reloadConfig();
foreach ($this->getApiForTesting() as $pair) {
list($apiToCall, $params) = $pair;
diff --git a/tests/PHPUnit/Integration/ImportLogsTest.php b/tests/PHPUnit/Integration/ImportLogsTest.php
index 795cece9df..cbb79e257d 100755
--- a/tests/PHPUnit/Integration/ImportLogsTest.php
+++ b/tests/PHPUnit/Integration/ImportLogsTest.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Access;
+use Piwik\Plugins\SitesManager\API;
/**
* Tests the log importer.
@@ -58,13 +59,13 @@ class Test_Piwik_Integration_ImportLogs extends IntegrationTestCase
Access::getInstance()->setSuperUser(true);
// make sure sites aren't created twice
- $piwikDotNet = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
+ $piwikDotNet = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
$this->assertEquals(1, count($piwikDotNet));
- $anothersiteDotCom = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://anothersite.com');
+ $anothersiteDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://anothersite.com');
$this->assertEquals(1, count($anothersiteDotCom));
- $whateverDotCom = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://whatever.com');
+ $whateverDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://whatever.com');
$this->assertEquals(1, count($whateverDotCom));
}
diff --git a/tests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php b/tests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php
index 1c7b05699f..828f0334ef 100755
--- a/tests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php
+++ b/tests/PHPUnit/Integration/TrackGoals_AllowMultipleConversionsPerVisitTest.php
@@ -5,6 +5,7 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\Goals\API;
/**
* Tests API methods with goals that do and don't allow multiple
@@ -34,11 +35,11 @@ class Test_Piwik_Integration_TrackGoals_AllowMultipleConversionsPerVisit extends
$idSite = self::$fixture->idSite;
// test delete is working as expected
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ $goals = API::getInstance()->getGoals($idSite);
$this->assertTrue(2 == count($goals));
- Piwik_Goals_API::getInstance()->deleteGoal($idSite, self::$fixture->idGoal_OneConversionPerVisit);
- Piwik_Goals_API::getInstance()->deleteGoal($idSite, self::$fixture->idGoal_MultipleConversionPerVisit);
- $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
+ API::getInstance()->deleteGoal($idSite, self::$fixture->idGoal_OneConversionPerVisit);
+ API::getInstance()->deleteGoal($idSite, self::$fixture->idGoal_MultipleConversionPerVisit);
+ $goals = API::getInstance()->getGoals($idSite);
$this->assertTrue(empty($goals));
}
diff --git a/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ConversionsTest.php b/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ConversionsTest.php
index 0af36e21f9..122d527fc0 100755
--- a/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ConversionsTest.php
+++ b/tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ConversionsTest.php
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\Goals\Archiver;
+
require_once 'Goals/Goals.php';
/**
@@ -91,7 +93,7 @@ class Test_Piwik_Integration_TwoVisitors_TwoWebsites_DifferentDays_Conversions e
// Tests that getting a visits summary metric (nb_visits) & a Goal's metric (Goal_revenue)
// at the same time works.
$dateTime = '2010-01-03,2010-01-06';
- $columns = 'nb_visits,' . Piwik_Goals_Archiver::getRecordName('conversion_rate');
+ $columns = 'nb_visits,' . Archiver::getRecordName('conversion_rate');
$result[] = array(
'VisitsSummary.get', array('idSite' => 'all', 'date' => $dateTime, 'periods' => 'range',
diff --git a/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchNONETest.php b/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchNONETest.php
index 3ec0be949b..9a57a57c55 100755
--- a/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchNONETest.php
+++ b/tests/PHPUnit/Integration/TwoVisitsWithCustomVariables_SegmentMatchNONETest.php
@@ -5,6 +5,7 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\API\API;
/**
* testing a segment containing all supported fields
@@ -41,7 +42,7 @@ class Test_Piwik_Integration_TwoVisitsWithCustomVariables_SegmentMatchNONE exten
public function getSegmentToTest()
{
// Segment matching NONE
- $segments = Piwik_API_API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
+ $segments = API::getInstance()->getSegmentsMetadata(self::$fixture->idSite);
$minimumExpectedSegmentsCount = 55; // as of Piwik 1.12
$this->assertTrue( count($segments) >= $minimumExpectedSegmentsCount);
diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php
index a9f183652e..cfcf72c581 100755
--- a/tests/PHPUnit/IntegrationTestCase.php
+++ b/tests/PHPUnit/IntegrationTestCase.php
@@ -17,6 +17,7 @@ use Piwik\Piwik;
use Piwik\Common;
use Piwik\Access;
use Piwik\Option;
+use Piwik\Plugins\LanguagesManager\API;
use Piwik\ReportRenderer;
use Piwik\Site;
use Piwik\Tracker\Cache;
@@ -196,7 +197,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
// Make sure translations are loaded to check messages in English
Translate::getInstance()->reloadLanguage('en');
- Piwik_LanguagesManager_API::getInstance()->setLanguageForUser('superUserLogin', 'en');
+ API::getInstance()->setLanguageForUser('superUserLogin', 'en');
// List of Modules, or Module.Method that should not be called as part of the XML output compare
// Usually these modules either return random changing data, or are already tested in specific unit tests.
@@ -238,7 +239,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
Cache::deleteTrackerCache();
Config::getInstance()->clear();
ArchiveTableCreator::clear();
- Piwik_PDFReports_API::$cache = array();
+ \Piwik\Plugins\PDFReports\API::$cache = array();
\Zend_Registry::_unsetInstance();
$_GET = $_REQUEST = array();
@@ -361,7 +362,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
'otherRequestParameters' => array(
'idReport' => 1,
'reportFormat' => ReportRenderer::HTML_FORMAT,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
@@ -384,7 +385,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
'otherRequestParameters' => array(
'idReport' => 1,
'reportFormat' => ReportRenderer::PDF_FORMAT,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
@@ -404,7 +405,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
'fileExtension' => 'sms.txt',
'otherRequestParameters' => array(
'idReport' => 2,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
@@ -423,7 +424,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
'fileExtension' => 'sms.txt',
'otherRequestParameters' => array(
'idReport' => 3,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
@@ -444,7 +445,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
'otherRequestParameters' => array(
'idReport' => 4,
'reportFormat' => ReportRenderer::HTML_FORMAT,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
@@ -463,7 +464,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
'fileExtension' => 'html',
'otherRequestParameters' => array(
'idReport' => 5,
- 'outputType' => Piwik_PDFReports_API::OUTPUT_RETURN
+ 'outputType' => \Piwik\Plugins\PDFReports\API::OUTPUT_RETURN
)
)
)
diff --git a/tests/PHPUnit/MockLocationProvider.php b/tests/PHPUnit/MockLocationProvider.php
index 68c1c43502..d4a202ece0 100755
--- a/tests/PHPUnit/MockLocationProvider.php
+++ b/tests/PHPUnit/MockLocationProvider.php
@@ -6,7 +6,9 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
-class MockLocationProvider extends Piwik_UserCountry_LocationProvider
+use Piwik\Plugins\UserCountry\LocationProvider;
+
+class MockLocationProvider extends LocationProvider
{
public static $locations = array();
private $currentLocation = 0;
diff --git a/tests/PHPUnit/Plugins/ActionsTest.php b/tests/PHPUnit/Plugins/ActionsTest.php
index c6c3465fa9..3945605875 100644
--- a/tests/PHPUnit/Plugins/ActionsTest.php
+++ b/tests/PHPUnit/Plugins/ActionsTest.php
@@ -5,6 +5,7 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\Actions\ArchivingHelper;
use Piwik\Tracker\Action;
use Piwik\Translate;
@@ -115,8 +116,8 @@ class ActionsTests extends PHPUnit_Framework_TestCase
*/
public function testGetActionExplodedNames($params, $expected)
{
- Piwik_Actions_ArchivingHelper::reloadConfig();
- $processed = Piwik_Actions_ArchivingHelper::getActionExplodedNames($params['name'], $params['type'], (isset($params['urlPrefix']) ? $params['urlPrefix'] : null));
+ ArchivingHelper::reloadConfig();
+ $processed = ArchivingHelper::getActionExplodedNames($params['name'], $params['type'], (isset($params['urlPrefix']) ? $params['urlPrefix'] : null));
$this->assertEquals($expected, $processed);
}
}
diff --git a/tests/PHPUnit/Plugins/AnonymizeIPTest.php b/tests/PHPUnit/Plugins/AnonymizeIPTest.php
index c9a18a45cd..0c52d7954b 100644
--- a/tests/PHPUnit/Plugins/AnonymizeIPTest.php
+++ b/tests/PHPUnit/Plugins/AnonymizeIPTest.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\IP;
+use Piwik\Plugins\AnonymizeIP\AnonymizeIP;
require_once 'AnonymizeIP/AnonymizeIP.php';
@@ -41,21 +42,21 @@ class AnonymizeIPTest extends PHPUnit_Framework_TestCase
{
// each IP is tested with 0 to 4 octets masked
for ($maskLength = 0; $maskLength <= 4; $maskLength++) {
- $res = Piwik_AnonymizeIP::applyIPMask(IP::P2N($ip), $maskLength);
+ $res = AnonymizeIP::applyIPMask(IP::P2N($ip), $maskLength);
$this->assertEquals($expected[$maskLength], $res, "Got " . bin2hex($res) . ", Expected " . bin2hex($expected[$maskLength]));
}
// edge case (bounds check)
- $this->assertEquals("\x00\x00\x00\x00", Piwik_AnonymizeIP::applyIPMask(IP::P2N($ip), 5));
+ $this->assertEquals("\x00\x00\x00\x00", AnonymizeIP::applyIPMask(IP::P2N($ip), 5));
// mask IPv4 mapped addresses
for ($maskLength = 0; $maskLength <= 4; $maskLength++) {
- $res = Piwik_AnonymizeIP::applyIPMask(IP::P2N('::ffff:' . $ip), $maskLength);
+ $res = AnonymizeIP::applyIPMask(IP::P2N('::ffff:' . $ip), $maskLength);
$this->assertEquals($res, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff" . $expected[$maskLength], "Got " . bin2hex($res) . ", Expected " . bin2hex($expected[$maskLength]));
}
- $this->assertEquals("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x00", Piwik_AnonymizeIP::applyIPMask(IP::P2N('::ffff:' . $ip), 5));
+ $this->assertEquals("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x00", AnonymizeIP::applyIPMask(IP::P2N('::ffff:' . $ip), 5));
// edge case (bounds check)
- $this->assertEquals("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", Piwik_AnonymizeIP::applyIPMask(IP::P2N('2001::ffff:' . $ip), 17));
+ $this->assertEquals("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", AnonymizeIP::applyIPMask(IP::P2N('2001::ffff:' . $ip), 17));
}
}
diff --git a/tests/PHPUnit/Plugins/LanguagesManagerTest.php b/tests/PHPUnit/Plugins/LanguagesManagerTest.php
index fb0ca7012c..ac7d2de015 100755
--- a/tests/PHPUnit/Plugins/LanguagesManagerTest.php
+++ b/tests/PHPUnit/Plugins/LanguagesManagerTest.php
@@ -6,6 +6,7 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Common;
+use Piwik\Plugins\LanguagesManager\API;
use Piwik\TranslationWriter;
require_once 'LanguagesManager/API.php';
@@ -32,7 +33,7 @@ class Test_LanguagesManager extends PHPUnit_Framework_TestCase
self::$englishStringsWithParameters = array();
self::$englishStringsIndexed = array();
self::$expectedLanguageKeys = array();
- $englishStrings = Piwik_LanguagesManager_API::getInstance()->getTranslationsForLanguage('en');
+ $englishStrings = API::getInstance()->getTranslationsForLanguage('en');
foreach ($englishStrings as $englishString) {
$stringLabel = $englishString['label'];
$stringValue = $englishString['value'];
@@ -45,7 +46,7 @@ class Test_LanguagesManager extends PHPUnit_Framework_TestCase
}
// we also test that none of the language php files outputs any character on the screen (eg. space before the <?php)
- $languages = Piwik_LanguagesManager_API::getInstance()->getAvailableLanguages();
+ $languages = API::getInstance()->getAvailableLanguages();
$return = array();
foreach ($languages AS $language) {
@@ -68,7 +69,7 @@ class Test_LanguagesManager extends PHPUnit_Framework_TestCase
self::$errors = array();
ob_start();
$writeCleanedFile = false;
- $strings = Piwik_LanguagesManager_API::getInstance()->getTranslationsForLanguage($language);
+ $strings = API::getInstance()->getTranslationsForLanguage($language);
$content = ob_get_flush();
$serializedStrings = serialize($strings);
$invalids = array("<script", 'document.', 'javascript:', 'src=', 'BACKGROUND=', 'onload=');
@@ -236,7 +237,7 @@ class Test_LanguagesManager extends PHPUnit_Framework_TestCase
*/
function testGetTranslationsForLanguagesNot()
{
- $this->assertFalse(Piwik_LanguagesManager_API::getInstance()->getTranslationsForLanguage("../no-language"));
+ $this->assertFalse(API::getInstance()->getTranslationsForLanguage("../no-language"));
}
/**
@@ -247,7 +248,7 @@ class Test_LanguagesManager extends PHPUnit_Framework_TestCase
*/
function testGetLanguageNamesInEnglish()
{
- $languages = Piwik_LanguagesManager_API::getInstance()->getAvailableLanguages();
+ $languages = API::getInstance()->getAvailableLanguages();
foreach ($languages as $language) {
require PIWIK_INCLUDE_PATH . "/lang/$language.php";
$name = $translations['General_EnglishLanguageName'];
diff --git a/tests/PHPUnit/Plugins/LoginTest.php b/tests/PHPUnit/Plugins/LoginTest.php
index b9977cc0a3..15a7182c80 100644
--- a/tests/PHPUnit/Plugins/LoginTest.php
+++ b/tests/PHPUnit/Plugins/LoginTest.php
@@ -9,6 +9,8 @@ use Piwik\Config;
use Piwik\Piwik;
use Piwik\Access;
use Piwik\AuthResult;
+use Piwik\Plugins\Login\Auth;
+use Piwik\Plugins\UsersManager\API;
require_once 'Login/Auth.php';
@@ -42,7 +44,7 @@ class LoginTest extends DatabaseTestCase
public function testAuthenticateFailureNoLoginNoTokenAuth()
{
// no login; no token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$rc = $auth->authenticate();
$this->assertEquals(AuthResult::FAILURE, $rc->getCode());
}
@@ -54,7 +56,7 @@ class LoginTest extends DatabaseTestCase
public function testAuthenticateFailureEmptyLoginNoTokenAuth()
{
// empty login; no token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin('');
$rc = $auth->authenticate();
$this->assertEquals(AuthResult::FAILURE, $rc->getCode());
@@ -67,7 +69,7 @@ class LoginTest extends DatabaseTestCase
public function testAuthenticateFailureNonExistentUser()
{
// non-existent user
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin('nobody');
$rc = $auth->authenticate();
$this->assertEquals(AuthResult::FAILURE, $rc->getCode());
@@ -80,7 +82,7 @@ class LoginTest extends DatabaseTestCase
public function testAuthenticateFailureAnonymousNotExisting()
{
// anonymous user doesn't exist yet
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin('anonymous');
$auth->setTokenAuth('');
$rc = $auth->authenticate();
@@ -94,7 +96,7 @@ class LoginTest extends DatabaseTestCase
public function testAuthenticateFailureAnonymousNotExistentEmptyLogin()
{
// empty login; anonymous user doesn't exist yet
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin('');
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
@@ -108,7 +110,7 @@ class LoginTest extends DatabaseTestCase
public function testAuthenticateFailureAnonymousNotExistentEmptyLoginWithTokenAuth()
{
// API authentication; anonymous user doesn't exist yet
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin(null);
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
@@ -122,7 +124,7 @@ class LoginTest extends DatabaseTestCase
public function testAuthenticateFailureAnonymousNotExistentWithLoginAndTokenAuth()
{
// anonymous user doesn't exist yet
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin('anonymous');
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
@@ -138,7 +140,7 @@ class LoginTest extends DatabaseTestCase
Piwik::createAnonymousUser();
// missing token_auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin('anonymous');
$auth->setTokenAuth('');
$rc = $auth->authenticate();
@@ -154,7 +156,7 @@ class LoginTest extends DatabaseTestCase
Piwik::createAnonymousUser();
// empty login
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin('');
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
@@ -170,7 +172,7 @@ class LoginTest extends DatabaseTestCase
Piwik::createAnonymousUser();
// not equal
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin('anonymous');
$auth->setTokenAuth(0);
$rc = $auth->authenticate();
@@ -186,7 +188,7 @@ class LoginTest extends DatabaseTestCase
Piwik::createAnonymousUser();
// API authentication
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin(null);
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
@@ -202,7 +204,7 @@ class LoginTest extends DatabaseTestCase
Piwik::createAnonymousUser();
// valid login & token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin('anonymous');
$auth->setTokenAuth('anonymous');
$rc = $auth->authenticate();
@@ -215,9 +217,9 @@ class LoginTest extends DatabaseTestCase
'password' => "geqgeagae",
'email' => "test@test.com",
'alias' => "alias");
- Piwik_UsersManager_API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
+ API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
$password = md5($user['password']);
- $user['tokenAuth'] = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
+ $user['tokenAuth'] = API::getInstance()->getTokenAuth($user['login'], $password);
return $user;
}
@@ -230,7 +232,7 @@ class LoginTest extends DatabaseTestCase
$user = $this->_setUpUser();
// empty token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$auth->setTokenAuth('');
$rc = $auth->authenticate();
@@ -246,7 +248,7 @@ class LoginTest extends DatabaseTestCase
$user = $this->_setUpUser();
// not a token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$auth->setTokenAuth($user['password']);
$rc = $auth->authenticate();
@@ -262,7 +264,7 @@ class LoginTest extends DatabaseTestCase
$user = $this->_setUpUser();
// not a token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$auth->setTokenAuth(md5($user['password']));
$rc = $auth->authenticate();
@@ -278,7 +280,7 @@ class LoginTest extends DatabaseTestCase
$user = $this->_setUpUser();
// empty login
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin('');
$auth->setTokenAuth($user['tokenAuth']);
$rc = $auth->authenticate();
@@ -294,7 +296,7 @@ class LoginTest extends DatabaseTestCase
$user = $this->_setUpUser();
// not equal
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin(0);
$auth->setTokenAuth(0);
$rc = $auth->authenticate();
@@ -310,7 +312,7 @@ class LoginTest extends DatabaseTestCase
$user = $this->_setUpUser();
// not equal
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin(0);
$auth->setTokenAuth($user['tokenAuth']);
$rc = $auth->authenticate();
@@ -326,7 +328,7 @@ class LoginTest extends DatabaseTestCase
$user = $this->_setUpUser();
// not equal
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$auth->setTokenAuth(0);
$rc = $auth->authenticate();
@@ -342,7 +344,7 @@ class LoginTest extends DatabaseTestCase
$user = $this->_setUpUser();
// API authentication
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin(null);
$auth->setTokenAuth($user['tokenAuth']);
$rc = $auth->authenticate();
@@ -358,7 +360,7 @@ class LoginTest extends DatabaseTestCase
$user = $this->_setUpUser();
// valid login & token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$auth->setTokenAuth($user['tokenAuth']);
$rc = $auth->authenticate();
@@ -374,7 +376,7 @@ class LoginTest extends DatabaseTestCase
$user = $this->_setUpUser();
// valid login & hashed token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$hash = $auth->getHashTokenAuth($user['login'], $user['tokenAuth']);
$auth->setTokenAuth($hash);
@@ -390,10 +392,10 @@ class LoginTest extends DatabaseTestCase
{
$user = Config::getInstance()->superuser;
$password = $user['password'];
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
+ $tokenAuth = API::getInstance()->getTokenAuth($user['login'], $password);
// empty token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$auth->setTokenAuth('');
$rc = $auth->authenticate();
@@ -408,10 +410,10 @@ class LoginTest extends DatabaseTestCase
{
$user = Config::getInstance()->superuser;
$password = $user['password'];
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
+ $tokenAuth = API::getInstance()->getTokenAuth($user['login'], $password);
// not a token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$auth->setTokenAuth($user['password']);
$rc = $auth->authenticate();
@@ -426,10 +428,10 @@ class LoginTest extends DatabaseTestCase
{
$user = Config::getInstance()->superuser;
$password = $user['password'];
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
+ $tokenAuth = API::getInstance()->getTokenAuth($user['login'], $password);
// not a token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$auth->setTokenAuth($password);
$rc = $auth->authenticate();
@@ -444,10 +446,10 @@ class LoginTest extends DatabaseTestCase
{
$user = Config::getInstance()->superuser;
$password = $user['password'];
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
+ $tokenAuth = API::getInstance()->getTokenAuth($user['login'], $password);
// empty login
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin('');
$auth->setTokenAuth($tokenAuth);
$rc = $auth->authenticate();
@@ -462,10 +464,10 @@ class LoginTest extends DatabaseTestCase
{
$user = Config::getInstance()->superuser;
$password = $user['password'];
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
+ $tokenAuth = API::getInstance()->getTokenAuth($user['login'], $password);
// not equal
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$auth->setTokenAuth(0);
$rc = $auth->authenticate();
@@ -480,10 +482,10 @@ class LoginTest extends DatabaseTestCase
{
$user = Config::getInstance()->superuser;
$password = $user['password'];
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
+ $tokenAuth = API::getInstance()->getTokenAuth($user['login'], $password);
// API authentication
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin(null);
$auth->setTokenAuth($tokenAuth);
$rc = $auth->authenticate();
@@ -498,10 +500,10 @@ class LoginTest extends DatabaseTestCase
{
$user = Config::getInstance()->superuser;
$password = $user['password'];
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
+ $tokenAuth = API::getInstance()->getTokenAuth($user['login'], $password);
// valid login & token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$auth->setTokenAuth($tokenAuth);
$rc = $auth->authenticate();
@@ -516,10 +518,10 @@ class LoginTest extends DatabaseTestCase
{
$user = Config::getInstance()->superuser;
$password = $user['password'];
- $tokenAuth = Piwik_UsersManager_API::getInstance()->getTokenAuth($user['login'], $password);
+ $tokenAuth = API::getInstance()->getTokenAuth($user['login'], $password);
// valid login & hashed token auth
- $auth = new Piwik_Login_Auth();
+ $auth = new Auth();
$auth->setLogin($user['login']);
$hash = $auth->getHashTokenAuth($user['login'], $tokenAuth);
$auth->setTokenAuth($hash);
diff --git a/tests/PHPUnit/Plugins/MobileMessagingTest.php b/tests/PHPUnit/Plugins/MobileMessagingTest.php
index 29620e6245..64a93bea32 100644
--- a/tests/PHPUnit/Plugins/MobileMessagingTest.php
+++ b/tests/PHPUnit/Plugins/MobileMessagingTest.php
@@ -7,6 +7,11 @@
*/
use Piwik\Access;
+use Piwik\Plugins\MobileMessaging\API as MobileMessagingAPI;
+use Piwik\Plugins\MobileMessaging\MobileMessaging;
+use Piwik\Plugins\MobileMessaging\SMSProvider;
+use Piwik\Plugins\PDFReports\API as PDFReportsAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
class MobileMessagingTest extends DatabaseTestCase
{
@@ -22,7 +27,7 @@ class MobileMessagingTest extends DatabaseTestCase
//finally we set the user as a super user by default
Access::setSingletonInstance($pseudoMockAccess);
- $this->idSiteAccess = Piwik_SitesManager_API::getInstance()->addSite("test", "http://test");
+ $this->idSiteAccess = SitesManagerAPI::getInstance()->addSite("test", "http://test");
\Piwik\PluginsManager::getInstance()->loadPlugins(array('PDFReports', 'MobileMessaging', 'MultiSites'));
\Piwik\PluginsManager::getInstance()->installLoadedPlugins();
@@ -41,7 +46,7 @@ class MobileMessagingTest extends DatabaseTestCase
\Piwik\PluginsManager::getInstance()->loadPlugins(array('PDFReports', 'MobileMessaging'));
$this->assertFalse(\Piwik\PluginsManager::getInstance()->isPluginActivated('MultiSites'));
- $PdfReportsAPIInstance = Piwik_PDFReports_API::getInstance();
+ $PdfReportsAPIInstance = PDFReportsAPI::getInstance();
$reportId = $PdfReportsAPIInstance->addReport(
$this->idSiteAccess,
'description',
@@ -162,7 +167,7 @@ class MobileMessagingTest extends DatabaseTestCase
{
$this->assertEquals(
$expected,
- Piwik_MobileMessaging_SMSProvider::truncate($stringToTruncate, $maximumNumberOfConcatenatedSMS, $appendedString)
+ SMSProvider::truncate($stringToTruncate, $maximumNumberOfConcatenatedSMS, $appendedString)
);
}
@@ -189,7 +194,7 @@ class MobileMessagingTest extends DatabaseTestCase
{
$this->assertEquals(
$expected,
- Piwik_MobileMessaging_SMSProvider::containsUCS2Characters($stringToTest)
+ SMSProvider::containsUCS2Characters($stringToTest)
);
}
@@ -199,7 +204,7 @@ class MobileMessagingTest extends DatabaseTestCase
*/
public function testSanitizePhoneNumber()
{
- $this->assertEquals('676932647', Piwik_MobileMessaging_API::sanitizePhoneNumber(' 6 76 93 26 47'));
+ $this->assertEquals('676932647', MobileMessagingAPI::sanitizePhoneNumber(' 6 76 93 26 47'));
}
/**
@@ -208,7 +213,7 @@ class MobileMessagingTest extends DatabaseTestCase
*/
public function testPhoneNumberIsSanitized()
{
- $mobileMessagingAPI = new Piwik_MobileMessaging_API();
+ $mobileMessagingAPI = new MobileMessagingAPI();
$mobileMessagingAPI->setSMSAPICredential('StubbedProvider', '');
$mobileMessagingAPI->addPhoneNumber(' 6 76 93 26 47');
$this->assertEquals('676932647', key($mobileMessagingAPI->getPhoneNumbers()));
@@ -233,29 +238,29 @@ class MobileMessagingTest extends DatabaseTestCase
public function testSendReport($expectedReportContent, $expectedPhoneNumber, $expectedFrom, $reportContent, $phoneNumber, $reportSubject)
{
$notificationInfo = array(
- Piwik_PDFReports_API::REPORT_CONTENT_KEY => $reportContent,
- Piwik_PDFReports_API::REPORT_SUBJECT_KEY => $reportSubject,
- Piwik_PDFReports_API::REPORT_TYPE_INFO_KEY => Piwik_MobileMessaging::MOBILE_TYPE,
- Piwik_PDFReports_API::REPORT_KEY => array(
- 'parameters' => array(Piwik_MobileMessaging::PHONE_NUMBERS_PARAMETER => array($phoneNumber)),
+ PDFReportsAPI::REPORT_CONTENT_KEY => $reportContent,
+ PDFReportsAPI::REPORT_SUBJECT_KEY => $reportSubject,
+ PDFReportsAPI::REPORT_TYPE_INFO_KEY => MobileMessaging::MOBILE_TYPE,
+ PDFReportsAPI::REPORT_KEY => array(
+ 'parameters' => array(MobileMessaging::PHONE_NUMBERS_PARAMETER => array($phoneNumber)),
),
);
- $stubbedMobileMessagingAPI = $this->getMock('Piwik_MobileMessaging_API');
+ $stubbedMobileMessagingAPI = $this->getMock('\\Piwik\\Plugins\\MobileMessaging\\API');
$stubbedMobileMessagingAPI->expects($this->once())->method('sendSMS')->with(
$this->equalTo($expectedReportContent, 0),
$this->equalTo($expectedPhoneNumber, 1),
$this->equalTo($expectedFrom, 2)
);
- $stubbedMobileMessagingAPIClass = new ReflectionProperty('Piwik_MobileMessaging_API', 'instance');
+ $stubbedMobileMessagingAPIClass = new ReflectionProperty('\\Piwik\\Plugins\\MobileMessaging\\API', 'instance');
$stubbedMobileMessagingAPIClass->setAccessible(true);
$stubbedMobileMessagingAPIClass->setValue($stubbedMobileMessagingAPI);
- $mobileMessaging = new Piwik_MobileMessaging();
+ $mobileMessaging = new MobileMessaging();
$mobileMessaging->sendReport($notificationInfo);
- // restore Piwik_MobileMessaging_API
+ // restore API
$stubbedMobileMessagingAPIClass->setValue(null);
}
}
diff --git a/tests/PHPUnit/Plugins/MultiSitesTest.php b/tests/PHPUnit/Plugins/MultiSitesTest.php
index e71f2e1031..e42ed68fe4 100644
--- a/tests/PHPUnit/Plugins/MultiSitesTest.php
+++ b/tests/PHPUnit/Plugins/MultiSitesTest.php
@@ -7,6 +7,8 @@
*/
use Piwik\Access;
+use Piwik\Plugins\MultiSites\API as MultiSitesAPI;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
class MultiSitesTest extends DatabaseTestCase
{
@@ -19,7 +21,7 @@ class MultiSitesTest extends DatabaseTestCase
$access = Access::getInstance();
$access->setSuperUser(true);
- $this->idSiteAccess = Piwik_SitesManager_API::getInstance()->addSite("test", "http://test");
+ $this->idSiteAccess = SitesManagerAPI::getInstance()->addSite("test", "http://test");
\Piwik\PluginsManager::getInstance()->loadPlugins(array('MultiSites', 'VisitsSummary', 'Actions'));
\Piwik\PluginsManager::getInstance()->installLoadedPlugins();
@@ -35,7 +37,7 @@ class MultiSitesTest extends DatabaseTestCase
*/
public function testWhenNoDataGetOneReturnsRow()
{
- $dataTable = Piwik_MultiSites_API::getInstance()->getOne($this->idSiteAccess, 'month', '01-01-2010');
+ $dataTable = MultiSitesAPI::getInstance()->getOne($this->idSiteAccess, 'month', '01-01-2010');
$this->assertEquals(1, $dataTable->getRowsCount());
// safety net
diff --git a/tests/PHPUnit/Plugins/PDFReportsTest.php b/tests/PHPUnit/Plugins/PDFReportsTest.php
index 85b32a89c9..127d9e7dd8 100644
--- a/tests/PHPUnit/Plugins/PDFReportsTest.php
+++ b/tests/PHPUnit/Plugins/PDFReportsTest.php
@@ -6,6 +6,11 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Access;
+use Piwik\Plugins\MobileMessaging\API as MobileMessagingAPI;
+use Piwik\Plugins\MobileMessaging\MobileMessaging;
+use Piwik\Plugins\PDFReports\API as PDFReportsAPI;
+use Piwik\Plugins\PDFReports\PDFReports;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
use Piwik\ScheduledTime;
use Piwik\ScheduledTask;
use Piwik\ScheduledTime\Daily;
@@ -27,11 +32,11 @@ class PDFReportsTest extends DatabaseTestCase
\Piwik\PluginsManager::getInstance()->loadPlugins(array('API', 'UserCountry', 'PDFReports', 'MobileMessaging'));
\Piwik\PluginsManager::getInstance()->installLoadedPlugins();
- Piwik_SitesManager_API::getInstance()->addSite("Test", array("http://piwik.net"));
+ SitesManagerAPI::getInstance()->addSite("Test", array("http://piwik.net"));
- Piwik_SitesManager_API::getInstance()->addSite("Test", array("http://piwik.net"));
+ SitesManagerAPI::getInstance()->addSite("Test", array("http://piwik.net"));
FakeAccess::setIdSitesView(array($this->idSite, 2));
- Piwik_PDFReports_API::$cache = array();
+ PDFReportsAPI::$cache = array();
}
/**
@@ -63,29 +68,29 @@ class PDFReportsTest extends DatabaseTestCase
self::addReport($dataWebsiteTwo);
// Testing getReports without parameters
- $tmp = Piwik_PDFReports_API::getInstance()->getReports();
+ $tmp = PDFReportsAPI::getInstance()->getReports();
$report = reset($tmp);
$this->assertReportsEqual($report, $dataWebsiteTwo);
$idReport = self::addReport($data);
// Passing 3 parameters
- $tmp = Piwik_PDFReports_API::getInstance()->getReports($this->idSite, $data['period'], $idReport);
+ $tmp = PDFReportsAPI::getInstance()->getReports($this->idSite, $data['period'], $idReport);
$report = reset($tmp);
$this->assertReportsEqual($report, $data);
// Passing only idsite
- $tmp = Piwik_PDFReports_API::getInstance()->getReports($this->idSite);
+ $tmp = PDFReportsAPI::getInstance()->getReports($this->idSite);
$report = reset($tmp);
$this->assertReportsEqual($report, $data);
// Passing only period
- $tmp = Piwik_PDFReports_API::getInstance()->getReports($idSite = false, $data['period']);
+ $tmp = PDFReportsAPI::getInstance()->getReports($idSite = false, $data['period']);
$report = reset($tmp);
$this->assertReportsEqual($report, $data);
// Passing only idreport
- $tmp = Piwik_PDFReports_API::getInstance()->getReports($idSite = false, $period = false, $idReport);
+ $tmp = PDFReportsAPI::getInstance()->getReports($idSite = false, $period = false, $idReport);
$report = reset($tmp);
$this->assertReportsEqual($report, $data);
}
@@ -97,7 +102,7 @@ class PDFReportsTest extends DatabaseTestCase
public function testGetReportsIdReportNotFound()
{
try {
- Piwik_PDFReports_API::getInstance()->getReports($idSite = false, $period = false, $idReport = 1);
+ PDFReportsAPI::getInstance()->getReports($idSite = false, $period = false, $idReport = 1);
} catch (Exception $e) {
return;
}
@@ -111,7 +116,7 @@ class PDFReportsTest extends DatabaseTestCase
public function testGetReportsInvalidPermission()
{
try {
- Piwik_PDFReports_API::getInstance()->getReports(
+ PDFReportsAPI::getInstance()->getReports(
$idSite = 44,
$period = false,
self::addReport(self::getDailyPDFReportData($this->idSite))
@@ -164,7 +169,7 @@ class PDFReportsTest extends DatabaseTestCase
self::updateReport($idReport, $dataAfter);
- $reports = Piwik_PDFReports_API::getInstance()->getReports($idSite = false, $period = false, $idReport);
+ $reports = PDFReportsAPI::getInstance()->getReports($idSite = false, $period = false, $idReport);
$this->assertReportsEqual(
reset($reports),
@@ -180,15 +185,15 @@ class PDFReportsTest extends DatabaseTestCase
{
// Deletes non existing report throws exception
try {
- Piwik_PDFReports_API::getInstance()->deleteReport($idReport = 1);
+ PDFReportsAPI::getInstance()->deleteReport($idReport = 1);
$this->fail('Exception not raised');
} catch (Exception $e) {
}
$idReport = self::addReport(self::getMonthlyEmailReportData($this->idSite));
- $this->assertEquals(1, count(Piwik_PDFReports_API::getInstance()->getReports()));
- Piwik_PDFReports_API::getInstance()->deleteReport($idReport);
- $this->assertEquals(0, count(Piwik_PDFReports_API::getInstance()->getReports()));
+ $this->assertEquals(1, count(PDFReportsAPI::getInstance()->getReports()));
+ PDFReportsAPI::getInstance()->deleteReport($idReport);
+ $this->assertEquals(0, count(PDFReportsAPI::getInstance()->getReports()));
}
/**
@@ -200,9 +205,9 @@ class PDFReportsTest extends DatabaseTestCase
// unload MobileMessaging plugin
\Piwik\PluginsManager::getInstance()->loadPlugins(array('PDFReports'));
- $pdfReportPlugin = new Piwik_PDFReports();
+ $pdfReportPlugin = new PDFReports();
$this->assertEquals(
- Piwik_PDFReports::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY,
+ PDFReports::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY,
$pdfReportPlugin->getTopMenuTranslationKey()
);
}
@@ -217,9 +222,9 @@ class PDFReportsTest extends DatabaseTestCase
FakeAccess::$identity = 'anonymous';
Access::setSingletonInstance($anonymousAccess);
- $pdfReportPlugin = new Piwik_PDFReports();
+ $pdfReportPlugin = new PDFReports();
$this->assertEquals(
- Piwik_PDFReports::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY,
+ PDFReports::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY,
$pdfReportPlugin->getTopMenuTranslationKey()
);
}
@@ -235,11 +240,11 @@ class PDFReportsTest extends DatabaseTestCase
{
// set mobile provider account
self::setSuperUser();
- Piwik_MobileMessaging_API::getInstance()->setSMSAPICredential('StubbedProvider', '');
+ MobileMessagingAPI::getInstance()->setSMSAPICredential('StubbedProvider', '');
- $pdfReportPlugin = new Piwik_PDFReports();
+ $pdfReportPlugin = new PDFReports();
$this->assertEquals(
- Piwik_PDFReports::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY,
+ PDFReports::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY,
$pdfReportPlugin->getTopMenuTranslationKey()
);
}
@@ -253,9 +258,9 @@ class PDFReportsTest extends DatabaseTestCase
*/
public function testGetTopMenuTranslationKeyNoReportMobileAccountKO()
{
- $pdfReportPlugin = new Piwik_PDFReports();
+ $pdfReportPlugin = new PDFReports();
$this->assertEquals(
- Piwik_PDFReports::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY,
+ PDFReports::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY,
$pdfReportPlugin->getTopMenuTranslationKey()
);
}
@@ -269,22 +274,22 @@ class PDFReportsTest extends DatabaseTestCase
*/
public function testGetTopMenuTranslationKeyOneSMSReportMobileAccountKO()
{
- Piwik_PDFReports_API::getInstance()->addReport(
+ PDFReportsAPI::getInstance()->addReport(
1,
'',
ScheduledTime::PERIOD_DAY,
0,
- Piwik_MobileMessaging::MOBILE_TYPE,
- Piwik_MobileMessaging::SMS_FORMAT,
+ MobileMessaging::MOBILE_TYPE,
+ MobileMessaging::SMS_FORMAT,
array(),
array(
- Piwik_MobileMessaging::PHONE_NUMBERS_PARAMETER => array()
+ MobileMessaging::PHONE_NUMBERS_PARAMETER => array()
)
);
- $pdfReportPlugin = new Piwik_PDFReports();
+ $pdfReportPlugin = new PDFReports();
$this->assertEquals(
- Piwik_PDFReports::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY,
+ PDFReports::MOBILE_MESSAGING_TOP_MENU_TRANSLATION_KEY,
$pdfReportPlugin->getTopMenuTranslationKey()
);
}
@@ -300,13 +305,13 @@ class PDFReportsTest extends DatabaseTestCase
{
// set mobile provider account
self::setSuperUser();
- Piwik_MobileMessaging_API::getInstance()->setSMSAPICredential('StubbedProvider', '');
+ MobileMessagingAPI::getInstance()->setSMSAPICredential('StubbedProvider', '');
self::addReport(self::getMonthlyEmailReportData($this->idSite));
- $pdfReportPlugin = new Piwik_PDFReports();
+ $pdfReportPlugin = new PDFReports();
$this->assertEquals(
- Piwik_PDFReports::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY,
+ PDFReports::PDF_REPORTS_TOP_MENU_TRANSLATION_KEY,
$pdfReportPlugin->getTopMenuTranslationKey()
);
}
@@ -317,7 +322,7 @@ class PDFReportsTest extends DatabaseTestCase
*/
public function testGetScheduledTasks()
{
- // stub Piwik_PDFReports_API to control getReports() return values
+ // stub API to control getReports() return values
$report1 = self::getDailyPDFReportData($this->idSite);
$report1['idreport'] = 1;
$report1['hour'] = 0;
@@ -351,12 +356,12 @@ class PDFReportsTest extends DatabaseTestCase
$report6['period'] = ScheduledTime::PERIOD_NEVER;
$report6['deleted'] = 0;
- $stubbedPDFReportsAPI = $this->getMock('Piwik_PDFReports_API');
+ $stubbedPDFReportsAPI = $this->getMock('\\Piwik\\Plugins\\PDFReports\\API');
$stubbedPDFReportsAPI->expects($this->any())->method('getReports')->will($this->returnValue(
array($report1, $report2, $report3, $report4, $report5, $report6))
);
- $stubbedPDFReportsAPIClass = new ReflectionProperty('Piwik_PDFReports_API', 'instance');
+ $stubbedPDFReportsAPIClass = new ReflectionProperty('\\Piwik\\Plugins\\PDFReports\\API', 'instance');
$stubbedPDFReportsAPIClass->setAccessible(true);
$stubbedPDFReportsAPIClass->setValue($stubbedPDFReportsAPI);
@@ -380,18 +385,18 @@ class PDFReportsTest extends DatabaseTestCase
$scheduleTask4->setHour(15); // site is UTC-6.5, configured to be sent at 8h
$expectedTasks = array(
- new ScheduledTask (Piwik_PDFReports_API::getInstance(), 'sendReport', 1, $scheduleTask1),
- new ScheduledTask (Piwik_PDFReports_API::getInstance(), 'sendReport', 2, $scheduleTask2),
- new ScheduledTask (Piwik_PDFReports_API::getInstance(), 'sendReport', 4, $scheduleTask3),
- new ScheduledTask (Piwik_PDFReports_API::getInstance(), 'sendReport', 5, $scheduleTask4),
+ new ScheduledTask (PDFReportsAPI::getInstance(), 'sendReport', 1, $scheduleTask1),
+ new ScheduledTask (PDFReportsAPI::getInstance(), 'sendReport', 2, $scheduleTask2),
+ new ScheduledTask (PDFReportsAPI::getInstance(), 'sendReport', 4, $scheduleTask3),
+ new ScheduledTask (PDFReportsAPI::getInstance(), 'sendReport', 5, $scheduleTask4),
);
- $pdfReportPlugin = new Piwik_PDFReports();
+ $pdfReportPlugin = new PDFReports();
$tasks = array();
$pdfReportPlugin->getScheduledTasks($tasks);
$this->assertEquals($expectedTasks, $tasks);
- // restore Piwik_PDFReports_API
+ // restore API
$stubbedPDFReportsAPIClass->setValue(null);
}
@@ -415,11 +420,11 @@ class PDFReportsTest extends DatabaseTestCase
public function testGetReportSubjectAndReportTitle($expectedReportSubject, $expectedReportTitle, $websiteName, $reports)
{
$getReportSubjectAndReportTitle = new ReflectionMethod(
- 'Piwik_PDFReports_API', 'getReportSubjectAndReportTitle'
+ '\\Piwik\\Plugins\\PDFReports\\API', 'getReportSubjectAndReportTitle'
);
$getReportSubjectAndReportTitle->setAccessible(true);
- list($reportSubject, $reportTitle) = $getReportSubjectAndReportTitle->invoke(new Piwik_PDFReports_API(), $websiteName, $reports);
+ list($reportSubject, $reportTitle) = $getReportSubjectAndReportTitle->invoke(new PDFReportsAPI(), $websiteName, $reports);
$this->assertEquals($expectedReportSubject, $reportSubject);
$this->assertEquals($expectedReportTitle, $reportTitle);
}
@@ -434,7 +439,7 @@ class PDFReportsTest extends DatabaseTestCase
private static function addReport($data)
{
- $idReport = Piwik_PDFReports_API::getInstance()->addReport(
+ $idReport = PDFReportsAPI::getInstance()->addReport(
$data['idsite'],
$data['description'],
$data['period'],
@@ -487,7 +492,7 @@ class PDFReportsTest extends DatabaseTestCase
private static function updateReport($idReport, $data)
{
- $idReport = Piwik_PDFReports_API::getInstance()->updateReport(
+ $idReport = PDFReportsAPI::getInstance()->updateReport(
$idReport,
$data['idsite'],
$data['description'],
diff --git a/tests/PHPUnit/Plugins/PrivacyManagerTest.php b/tests/PHPUnit/Plugins/PrivacyManagerTest.php
index 17ca9d2c8c..ff040d5b44 100755
--- a/tests/PHPUnit/Plugins/PrivacyManagerTest.php
+++ b/tests/PHPUnit/Plugins/PrivacyManagerTest.php
@@ -14,6 +14,12 @@ use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
use Piwik\Option;
+use Piwik\Plugins\Goals\API as GoalsAPI;
+use Piwik\Plugins\Goals\Archiver;
+use Piwik\Plugins\PrivacyManager\LogDataPurger;
+use Piwik\Plugins\PrivacyManager\ReportsPurger;
+use Piwik\Plugins\PrivacyManager\PrivacyManager;
+use Piwik\Plugins\VisitorInterest\API as VisitorInterestAPI;
use Piwik\Site;
use Piwik\Db;
use Piwik\Tracker\Cache;
@@ -45,7 +51,7 @@ class PrivacyManagerTest extends IntegrationTestCase
private static $dbData = null;
/**
- * @var Piwik_PrivacyManager
+ * @var PrivacyManager
*/
private $instance = null;
private $settings = null;
@@ -72,8 +78,8 @@ class PrivacyManagerTest extends IntegrationTestCase
{
parent::setUp();
- Piwik_PrivacyManager_LogDataPurger::$selectSegmentSize = 2;
- Piwik_PrivacyManager_ReportsPurger::$selectSegmentSize = 2;
+ LogDataPurger::$selectSegmentSize = 2;
+ ReportsPurger::$selectSegmentSize = 2;
Piwik::$lockPrivilegeGranted = null;
self::restoreDbTables(self::$dbData);
@@ -106,9 +112,9 @@ class PrivacyManagerTest extends IntegrationTestCase
$settings['delete_reports_keep_year_reports'] = 0;
$settings['delete_reports_keep_range_reports'] = 0;
$settings['delete_reports_keep_segment_reports'] = 0;
- Piwik_PrivacyManager::savePurgeDataSettings($settings);
+ PrivacyManager::savePurgeDataSettings($settings);
$this->settings = $settings;
- $this->instance = new Piwik_PrivacyManager();
+ $this->instance = new PrivacyManager();
}
public function tearDown()
@@ -120,7 +126,7 @@ class PrivacyManagerTest extends IntegrationTestCase
Cache::deleteTrackerCache();
ArchiveTableCreator::clear();
- $tempTableName = Common::prefixTable(Piwik_PrivacyManager_LogDataPurger::TEMP_TABLE_NAME);
+ $tempTableName = Common::prefixTable(LogDataPurger::TEMP_TABLE_NAME);
Db::query("DROP TABLE IF EXISTS " . $tempTableName);
}
@@ -136,7 +142,7 @@ class PrivacyManagerTest extends IntegrationTestCase
// check that initial option is set
$this->assertEquals(
- 1, Piwik_GetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL));
+ 1, Piwik_GetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL));
// perform other checks
$this->_checkNoDataChanges();
@@ -153,7 +159,7 @@ class PrivacyManagerTest extends IntegrationTestCase
$this->instance->deleteReportData();
// check that initial option is set
- $this->assertEquals(1, Piwik_GetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL));
+ $this->assertEquals(1, Piwik_GetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL));
// perform other checks
$this->_checkNoDataChanges();
@@ -169,9 +175,9 @@ class PrivacyManagerTest extends IntegrationTestCase
{
$yesterdaySecs = Date::factory('yesterday')->getTimestamp();
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS, $yesterdaySecs);
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_REPORTS, $yesterdaySecs);
+ Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
+ Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS, $yesterdaySecs);
+ Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_REPORTS, $yesterdaySecs);
$this->instance->deleteLogData();
$this->instance->deleteReportData();
@@ -188,7 +194,7 @@ class PrivacyManagerTest extends IntegrationTestCase
public function testPurgeDataNotInitialAndTimeToRun()
{
// get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
+ $prediction = PrivacyManager::getPurgeEstimate();
// perform checks on prediction
$expectedPrediction = array(
@@ -234,13 +240,13 @@ class PrivacyManagerTest extends IntegrationTestCase
*/
public function testPurgeDataBothDisabled()
{
- Piwik_PrivacyManager::savePurgeDataSettings(array(
+ PrivacyManager::savePurgeDataSettings(array(
'delete_logs_enable' => 0,
'delete_reports_enable' => 0
));
// get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
+ $prediction = PrivacyManager::getPurgeEstimate();
// perform checks on prediction
$expectedPrediction = array();
@@ -269,7 +275,7 @@ class PrivacyManagerTest extends IntegrationTestCase
}
// get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
+ $prediction = PrivacyManager::getPurgeEstimate();
// perform checks on prediction
$expectedPrediction = array();
@@ -301,12 +307,12 @@ class PrivacyManagerTest extends IntegrationTestCase
*/
public function testPurgeDataDeleteReportsKeepBasicMetrics()
{
- Piwik_PrivacyManager::savePurgeDataSettings(array(
+ PrivacyManager::savePurgeDataSettings(array(
'delete_reports_keep_basic_metrics' => 1
));
// get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
+ $prediction = PrivacyManager::getPurgeEstimate();
// perform checks on prediction
$expectedPrediction = array(
@@ -358,12 +364,12 @@ class PrivacyManagerTest extends IntegrationTestCase
*/
public function testPurgeDataDeleteReportsKeepDailyReports()
{
- Piwik_PrivacyManager::savePurgeDataSettings(array(
+ PrivacyManager::savePurgeDataSettings(array(
'delete_reports_keep_day_reports' => 1
));
// get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
+ $prediction = PrivacyManager::getPurgeEstimate();
// perform checks on prediction
$unexplained = 0;//-2;
@@ -395,12 +401,12 @@ class PrivacyManagerTest extends IntegrationTestCase
*/
public function testPurgeDataDeleteReportsKeepWeeklyReports()
{
- Piwik_PrivacyManager::savePurgeDataSettings(array(
+ PrivacyManager::savePurgeDataSettings(array(
'delete_reports_keep_week_reports' => 1
));
// get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
+ $prediction = PrivacyManager::getPurgeEstimate();
// perform checks on prediction
$unexplained = 0;//-2;
@@ -432,12 +438,12 @@ class PrivacyManagerTest extends IntegrationTestCase
*/
public function testPurgeDataDeleteReportsKeepMonthlyReports()
{
- Piwik_PrivacyManager::savePurgeDataSettings(array(
+ PrivacyManager::savePurgeDataSettings(array(
'delete_reports_keep_month_reports' => 1
));
// get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
+ $prediction = PrivacyManager::getPurgeEstimate();
$unexplained = 0;//-1;
// perform checks on prediction
@@ -469,12 +475,12 @@ class PrivacyManagerTest extends IntegrationTestCase
*/
public function testPurgeDataDeleteReportsKeepYearlyReports()
{
- Piwik_PrivacyManager::savePurgeDataSettings(array(
+ PrivacyManager::savePurgeDataSettings(array(
'delete_reports_keep_year_reports' => 1
));
// get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
+ $prediction = PrivacyManager::getPurgeEstimate();
// perform checks on prediction
$unexplained = 0;//-1;
@@ -508,7 +514,7 @@ class PrivacyManagerTest extends IntegrationTestCase
{
Piwik_AddAction("LogDataPurger.actionsToKeepInserted.olderThan", array($this, 'addReferenceToUnusedAction'));
- $purger = Piwik_PrivacyManager_LogDataPurger::make($this->settings, true);
+ $purger = LogDataPurger::make($this->settings, true);
$this->unusedIdAction = Db::fetchOne(
"SELECT idaction FROM " . Common::prefixTable('log_action') . " WHERE name = ?",
@@ -538,12 +544,12 @@ class PrivacyManagerTest extends IntegrationTestCase
*/
public function testPurgeDataDeleteReportsKeepRangeReports()
{
- Piwik_PrivacyManager::savePurgeDataSettings(array(
+ PrivacyManager::savePurgeDataSettings(array(
'delete_reports_keep_range_reports' => 1
));
// get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
+ $prediction = PrivacyManager::getPurgeEstimate();
// perform checks on prediction
$unexplained = 0;//-2;
@@ -575,13 +581,13 @@ class PrivacyManagerTest extends IntegrationTestCase
*/
public function testPurgeDataDeleteReportsKeepSegmentsReports()
{
- Piwik_PrivacyManager::savePurgeDataSettings(array(
+ PrivacyManager::savePurgeDataSettings(array(
'delete_reports_keep_day_reports' => 1,
'delete_reports_keep_segment_reports' => 1
));
// get purge data prediction
- $prediction = Piwik_PrivacyManager::getPurgeEstimate();
+ $prediction = PrivacyManager::getPurgeEstimate();
// perform checks on prediction
$unexplained = 0;//-2;
@@ -635,7 +641,7 @@ class PrivacyManagerTest extends IntegrationTestCase
$start = Date::factory(self::$dateTime);
self::$idSite = Test_Piwik_BaseFixture::createWebsite('2012-01-01', $ecommerce = 1);
- $idGoal = Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'match all', 'url', 'http', 'contains');
+ $idGoal = GoalsAPI::getInstance()->addGoal(self::$idSite, 'match all', 'url', 'http', 'contains');
$t = Test_Piwik_BaseFixture::getTracker(self::$idSite, $start, $defaultInit = true);
$t->enableBulkTracking();
@@ -670,8 +676,8 @@ class PrivacyManagerTest extends IntegrationTestCase
$archive = Archive::build(self::$idSite, 'year', $date);
- Piwik_VisitorInterest_API::getInstance()->getNumberOfVisitsPerVisitDuration(self::$idSite, 'year', $date);
-// Piwik_Goals_API::getInstance()->get(self::$idSite, 'month', $date, $segment = false, self::$idSite);
+ VisitorInterestAPI::getInstance()->getNumberOfVisitsPerVisitDuration(self::$idSite, 'year', $date);
+// VisitorInterestAPI::getInstance()->get(self::$idSite, 'month', $date, $segment = false, self::$idSite);
// months are added via the 'year' period, but weeks must be done manually
for ($daysAgo = self::$daysAgoStart; $daysAgo > 0; $daysAgo -= 7) // every week
@@ -681,7 +687,7 @@ class PrivacyManagerTest extends IntegrationTestCase
$archive = Archive::build(self::$idSite, 'week', $dateTime);
$archive->getNumeric('nb_visits');
- Piwik_VisitorInterest_API::getInstance()->getNumberOfVisitsPerVisitDuration(
+ VisitorInterestAPI::getInstance()->getNumberOfVisitsPerVisitDuration(
self::$idSite, 'week', $dateTime);
}
@@ -689,7 +695,7 @@ class PrivacyManagerTest extends IntegrationTestCase
$archive = Archive::build(self::$idSite, 'day', '2012-01-14', 'browserCode==FF');
$archive->getNumeric('nb_visits', 'nb_hits');
- Piwik_VisitorInterest_API::getInstance()->getNumberOfVisitsPerVisitDuration(
+ VisitorInterestAPI::getInstance()->getNumberOfVisitsPerVisitDuration(
self::$idSite, 'day', '2012-01-14', 'browserCode==FF');
// add range within January
@@ -700,7 +706,7 @@ class PrivacyManagerTest extends IntegrationTestCase
$rangeArchive = Archive::build(self::$idSite, 'range', $range);
$rangeArchive->getNumeric('nb_visits', 'nb_hits');
- Piwik_VisitorInterest_API::getInstance()->getNumberOfVisitsPerVisitDuration(self::$idSite, 'range', $range);
+ VisitorInterestAPI::getInstance()->getNumberOfVisitsPerVisitDuration(self::$idSite, 'range', $range);
// add range between January & February
$rangeStart = $rangeEnd;
@@ -710,7 +716,7 @@ class PrivacyManagerTest extends IntegrationTestCase
$rangeArchive = Archive::build(self::$idSite, 'range', $range);
$rangeArchive->getNumeric('nb_visits', 'nb_hits');
- Piwik_VisitorInterest_API::getInstance()->getNumberOfVisitsPerVisitDuration(self::$idSite, 'range', $range);
+ VisitorInterestAPI::getInstance()->getNumberOfVisitsPerVisitDuration(self::$idSite, 'range', $range);
// when archiving is initiated, the archive metrics & reports for EVERY loaded plugin
// are archived. don't want this test to depend on every possible metric, so get rid of
@@ -718,9 +724,9 @@ class PrivacyManagerTest extends IntegrationTestCase
$metricsToSave = array(
'nb_visits',
'nb_actions',
- Piwik_Goals_Archiver::getRecordName('revenue'),
- Piwik_Goals_Archiver::getRecordName('nb_conversions', 1),
- Piwik_Goals_Archiver::getRecordName('revenue', GoalManager::IDGOAL_ORDER)
+ Archiver::getRecordName('revenue'),
+ Archiver::getRecordName('nb_conversions', 1),
+ Archiver::getRecordName('revenue', GoalManager::IDGOAL_ORDER)
);
$archiveTables = self::_getArchiveTableNames();
@@ -827,7 +833,7 @@ class PrivacyManagerTest extends IntegrationTestCase
return;
}
- $tempTableName = Common::prefixTable(Piwik_PrivacyManager_LogDataPurger::TEMP_TABLE_NAME);
+ $tempTableName = Common::prefixTable(LogDataPurger::TEMP_TABLE_NAME);
$logLinkVisitActionTable = Common::prefixTable("log_link_visit_action");
$sql = "INSERT INTO $logLinkVisitActionTable
@@ -843,9 +849,9 @@ class PrivacyManagerTest extends IntegrationTestCase
{
$lastDateSecs = Date::factory('today')->subDay(8)->getTimestamp();
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDateSecs);
- Piwik_SetOption(Piwik_PrivacyManager::OPTION_LAST_DELETE_PIWIK_REPORTS, $lastDateSecs);
+ Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
+ Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS, $lastDateSecs);
+ Piwik_SetOption(PrivacyManager::OPTION_LAST_DELETE_PIWIK_REPORTS, $lastDateSecs);
}
protected function _getTableCount($tableName, $where = '')
diff --git a/tests/PHPUnit/Plugins/ProxyTest.php b/tests/PHPUnit/Plugins/ProxyTest.php
index 31a67aa0d9..b21c13a28f 100644
--- a/tests/PHPUnit/Plugins/ProxyTest.php
+++ b/tests/PHPUnit/Plugins/ProxyTest.php
@@ -5,6 +5,8 @@
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
+use Piwik\Plugins\Proxy\Controller;
+
class ProxyTest extends PHPUnit_Framework_TestCase
{
public function getAcceptableRemoteUrls()
@@ -33,7 +35,7 @@ class ProxyTest extends PHPUnit_Framework_TestCase
*/
public function testIsAcceptableRemoteUrl($url, $expected)
{
- $this->assertEquals($expected, Piwik_Proxy_Controller::isPiwikUrl($url));
+ $this->assertEquals($expected, Controller::isPiwikUrl($url));
}
}
diff --git a/tests/PHPUnit/Plugins/ReferersTest.php b/tests/PHPUnit/Plugins/ReferersTest.php
index 547ec37576..e6af334cb3 100644
--- a/tests/PHPUnit/Plugins/ReferersTest.php
+++ b/tests/PHPUnit/Plugins/ReferersTest.php
@@ -111,8 +111,8 @@ class ReferersTest extends PHPUnit_Framework_TestCase
);
foreach ($data as $url => $expected) {
- $this->assertEquals($expected[0], Piwik_getSearchEngineHostFromUrl($url));
- $this->assertEquals($expected[1], Piwik_getSearchEngineHostPathFromUrl($url));
+ $this->assertEquals($expected[0], \Piwik\Plugins\Referers\getSearchEngineHostFromUrl($url));
+ $this->assertEquals($expected[1], \Piwik\Plugins\Referers\getSearchEngineHostPathFromUrl($url));
}
}
@@ -138,6 +138,6 @@ class ReferersTest extends PHPUnit_Framework_TestCase
public function testGetSearchEngineUrlFromUrlAndKeyword($url, $keyword, $expected)
{
include PIWIK_PATH_TEST_TO_ROOT . '/core/DataFiles/SearchEngines.php';
- $this->assertEquals($expected, Piwik_getSearchEngineUrlFromUrlAndKeyword($url, $keyword));
+ $this->assertEquals($expected, \Piwik\Plugins\Referers\getSearchEngineUrlFromUrlAndKeyword($url, $keyword));
}
}
diff --git a/tests/PHPUnit/Plugins/SEOTest.php b/tests/PHPUnit/Plugins/SEOTest.php
index cf4c7d1ff5..3d55311c58 100644
--- a/tests/PHPUnit/Plugins/SEOTest.php
+++ b/tests/PHPUnit/Plugins/SEOTest.php
@@ -7,6 +7,7 @@
*/
use Piwik\Access;
use Piwik\DataTable\Renderer;
+use Piwik\Plugins\SEO\API;
class SEOTest extends PHPUnit_Framework_TestCase
{
@@ -42,7 +43,7 @@ class SEOTest extends PHPUnit_Framework_TestCase
public function test_API()
{
try {
- $dataTable = Piwik_SEO_API::getInstance()->getRank('http://www.microsoft.com/');
+ $dataTable = API::getInstance()->getRank('http://www.microsoft.com/');
} catch(Exception $e) {
$this->markTestSkipped('A SEO http request failed, Skipping this test for now. Error was: '.$e->getMessage());
}
diff --git a/tests/PHPUnit/Plugins/SegmentEditorTest.php b/tests/PHPUnit/Plugins/SegmentEditorTest.php
index e35ffe7b21..696f19bcbc 100644
--- a/tests/PHPUnit/Plugins/SegmentEditorTest.php
+++ b/tests/PHPUnit/Plugins/SegmentEditorTest.php
@@ -8,7 +8,8 @@
use Piwik\Piwik;
use Piwik\Access;
use Piwik\Date;
-
+use Piwik\Plugins\SegmentEditor\API;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
class SegmentEditorTest extends DatabaseTestCase
{
@@ -29,18 +30,18 @@ class SegmentEditorTest extends DatabaseTestCase
FakeAccess::$superUserLogin = 'superusertest';
Access::setSingletonInstance($pseudoMockAccess);
- Piwik_SitesManager_API::getInstance()->addSite('test', 'http://example.org');
+ SitesManagerAPI::getInstance()->addSite('test', 'http://example.org');
}
public function testAddInvalidSegment_ShouldThrow()
{
try {
- Piwik_SegmentEditor_API::getInstance()->add('name', 'test==test2');
+ API::getInstance()->add('name', 'test==test2');
$this->fail("Exception not raised.");
} catch (Exception $expected) {
}
try {
- Piwik_SegmentEditor_API::getInstance()->add('name', 'test');
+ API::getInstance()->add('name', 'test');
$this->fail("Exception not raised.");
} catch (Exception $expected) {
}
@@ -50,9 +51,9 @@ class SegmentEditorTest extends DatabaseTestCase
{
$name = 'name';
$definition = 'searches>1,visitIp!=127.0.0.1';
- $idSegment = Piwik_SegmentEditor_API::getInstance()->add($name, $definition);
+ $idSegment = API::getInstance()->add($name, $definition);
$this->assertEquals($idSegment, 1);
- $segment = Piwik_SegmentEditor_API::getInstance()->get($idSegment);
+ $segment = API::getInstance()->get($idSegment);
unset($segment['ts_created']);
$expected = array(
'idsegment' => 1,
@@ -73,11 +74,11 @@ class SegmentEditorTest extends DatabaseTestCase
{
$name = 'name';
$definition = 'searches>1,visitIp!=127.0.0.1';
- $idSegment = Piwik_SegmentEditor_API::getInstance()->add($name, $definition, $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
+ $idSegment = API::getInstance()->add($name, $definition, $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
$this->assertEquals($idSegment, 1);
// Testing get()
- $segment = Piwik_SegmentEditor_API::getInstance()->get($idSegment);
+ $segment = API::getInstance()->get($idSegment);
$expected = array(
'idsegment' => '1',
'name' => $name,
@@ -93,20 +94,20 @@ class SegmentEditorTest extends DatabaseTestCase
$this->assertEquals($segment, $expected);
// There is a segment to process for this particular site
- $segments = Piwik_SegmentEditor_API::getInstance()->getAll($idSite, $autoArchived = true);
+ $segments = API::getInstance()->getAll($idSite, $autoArchived = true);
unset($segments[0]['ts_created']);
$this->assertEquals($segments, array($expected));
// There is no segment to process for a non existing site
try {
- $segments = Piwik_SegmentEditor_API::getInstance()->getAll(33, $autoArchived = true);
+ $segments = API::getInstance()->getAll(33, $autoArchived = true);
$this->fail();
} catch(Exception $e) {
// expected
}
// There is no segment to process across all sites
- $segments = Piwik_SegmentEditor_API::getInstance()->getAll($idSite = false, $autoArchived = true);
+ $segments = API::getInstance()->getAll($idSite = false, $autoArchived = true);
$this->assertEquals($segments, array());
}
@@ -115,8 +116,8 @@ class SegmentEditorTest extends DatabaseTestCase
$name = 'name"';
$definition = 'searches>1,visitIp!=127.0.0.1';
$nameSegment1 = 'hello';
- $idSegment1 = Piwik_SegmentEditor_API::getInstance()->add($nameSegment1, 'searches==0', $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
- $idSegment2 = Piwik_SegmentEditor_API::getInstance()->add($name, $definition, $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
+ $idSegment1 = API::getInstance()->add($nameSegment1, 'searches==0', $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
+ $idSegment2 = API::getInstance()->add($name, $definition, $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
$updatedSegment = array(
'idsegment' => $idSegment2,
@@ -130,7 +131,7 @@ class SegmentEditorTest extends DatabaseTestCase
'login' => Piwik::getCurrentUserLogin(),
'deleted' => '0',
);
- Piwik_SegmentEditor_API::getInstance()->update($idSegment2,
+ API::getInstance()->update($idSegment2,
$updatedSegment['name'],
$updatedSegment['definition'],
$updatedSegment['enable_only_idsite'],
@@ -138,29 +139,29 @@ class SegmentEditorTest extends DatabaseTestCase
$updatedSegment['enable_all_users']
);
- $newSegment = Piwik_SegmentEditor_API::getInstance()->get($idSegment2);
+ $newSegment = API::getInstance()->get($idSegment2);
$this->assertEquals($newSegment, $updatedSegment);
// Check the other segmenet was not updated
- $newSegment = Piwik_SegmentEditor_API::getInstance()->get($idSegment1);
+ $newSegment = API::getInstance()->get($idSegment1);
$this->assertEquals($newSegment['name'], $nameSegment1);
}
public function test_deleteSegment()
{
- $idSegment1 = Piwik_SegmentEditor_API::getInstance()->add('name 1', 'searches==0', $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
- $idSegment2 = Piwik_SegmentEditor_API::getInstance()->add('name 2', 'searches>1,visitIp!=127.0.0.1', $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
+ $idSegment1 = API::getInstance()->add('name 1', 'searches==0', $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
+ $idSegment2 = API::getInstance()->add('name 2', 'searches>1,visitIp!=127.0.0.1', $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
- $deleted = Piwik_SegmentEditor_API::getInstance()->delete($idSegment2);
+ $deleted = API::getInstance()->delete($idSegment2);
$this->assertTrue($deleted);
try {
- Piwik_SegmentEditor_API::getInstance()->get($idSegment2);
+ API::getInstance()->get($idSegment2);
$this->fail("getting deleted segment should have failed");
} catch(Exception $e) {
// expected
}
// and this should work
- Piwik_SegmentEditor_API::getInstance()->get($idSegment1);
+ API::getInstance()->get($idSegment1);
}
}
diff --git a/tests/PHPUnit/Plugins/SitesManagerTest.php b/tests/PHPUnit/Plugins/SitesManagerTest.php
index 74d7ca265d..b7b6046394 100644
--- a/tests/PHPUnit/Plugins/SitesManagerTest.php
+++ b/tests/PHPUnit/Plugins/SitesManagerTest.php
@@ -6,6 +6,8 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Access;
+use Piwik\Plugins\SitesManager\API;
+use Piwik\Plugins\UsersManager\API as UsersManagerAPI;
use Piwik\Site;
class SitesManagerTest extends DatabaseTestCase
@@ -29,7 +31,7 @@ class SitesManagerTest extends DatabaseTestCase
public function testAddSiteEmptyName()
{
try {
- Piwik_SitesManager_API::getInstance()->addSite("", array("http://piwik.net"));
+ API::getInstance()->addSite("", array("http://piwik.net"));
} catch (Exception $e) {
return;
}
@@ -60,7 +62,7 @@ class SitesManagerTest extends DatabaseTestCase
public function testAddSiteWrongUrls($url)
{
try {
- Piwik_SitesManager_API::getInstance()->addSite("name", $url);
+ API::getInstance()->addSite("name", $url);
} catch (Exception $e) {
return;
}
@@ -82,10 +84,10 @@ class SitesManagerTest extends DatabaseTestCase
$expectedExcludedQueryParameters = 'p1,P2,P33333';
$excludedUserAgents = " p1,P2, \nP3333 ";
$expectedExcludedUserAgents = "p1,P2,P3333";
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 1,
+ $idsite = API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 1,
$siteSearch = 1, $searchKeywordParameters = 'search,param', $searchCategoryParameters = 'cat,category',
$ips, $excludedQueryParameters, $timezone, $currency, $group = null, $startDate = null, $excludedUserAgents);
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
+ $siteInfo = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($ips, $siteInfo['excluded_ips']);
$this->assertEquals($timezone, $siteInfo['timezone']);
$this->assertEquals($currency, $siteInfo['currency']);
@@ -125,7 +127,7 @@ class SitesManagerTest extends DatabaseTestCase
public function testAddSiteExcludedIpsNotValid($ip)
{
try {
- Piwik_SitesManager_API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0,
+ API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $ip);
} catch (Exception $e) {
return;
@@ -143,14 +145,14 @@ class SitesManagerTest extends DatabaseTestCase
{
$url = "http://piwik.net/";
$urlOK = "http://piwik.net";
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("name", $url);
+ $idsite = API::getInstance()->addSite("name", $url);
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $idsite);
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
+ $siteInfo = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($urlOK, $siteInfo['main_url']);
$this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($siteInfo['ts_created'])));
- $siteUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $siteUrls = API::getInstance()->getSiteUrlsFromId($idsite);
$this->assertEquals(1, count($siteUrls));
}
@@ -164,13 +166,13 @@ class SitesManagerTest extends DatabaseTestCase
{
$urls = array("http://piwik.net/", "http://piwik.com", "https://piwik.net/test/");
$urlsOK = array("http://piwik.net", "http://piwik.com", "https://piwik.net/test");
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("super website", $urls);
+ $idsite = API::getInstance()->addSite("super website", $urls);
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $idsite);
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
+ $siteInfo = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($urlsOK[0], $siteInfo['main_url']);
- $siteUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $siteUrls = API::getInstance()->getSiteUrlsFromId($idsite);
$this->assertEquals($urlsOK, $siteUrls);
}
@@ -183,10 +185,10 @@ class SitesManagerTest extends DatabaseTestCase
public function testAddSiteStrangeName()
{
$name = "supertest(); ~@@()''!£\$'%%^'!£ போ";
- $idsite = Piwik_SitesManager_API::getInstance()->addSite($name, "http://piwik.net");
+ $idsite = API::getInstance()->addSite($name, "http://piwik.net");
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $idsite);
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
+ $siteInfo = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($name, $siteInfo['name']);
}
@@ -198,14 +200,14 @@ class SitesManagerTest extends DatabaseTestCase
protected function _addSite()
{
$name = "website ";
- $idsite = Piwik_SitesManager_API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/"));
+ $idsite = API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/"));
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $idsite);
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
+ $siteInfo = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($name, $siteInfo['name']);
$this->assertEquals("http://piwik.net", $siteInfo['main_url']);
- $siteUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $siteUrls = API::getInstance()->getSiteUrlsFromId($idsite);
$this->assertEquals(array("http://piwik.net", "http://piwik.com/test"), $siteUrls);
return $idsite;
@@ -221,7 +223,7 @@ class SitesManagerTest extends DatabaseTestCase
{
$idsite = $this->_addSite();
- $siteUrlsBefore = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $siteUrlsBefore = API::getInstance()->getSiteUrlsFromId($idsite);
$toAdd = array("http://piwik1.net",
"http://piwik2.net",
@@ -239,10 +241,10 @@ class SitesManagerTest extends DatabaseTestCase
"http://l42578gqege.f4",
"http://super.com/test/test/atqata675675/te");
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
+ $insertedUrls = API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
$this->assertEquals(count($toAdd), $insertedUrls);
- $siteUrlsAfter = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $siteUrlsAfter = API::getInstance()->getSiteUrlsFromId($idsite);
$shouldHave = array_merge($siteUrlsBefore, $toAddValid);
sort($shouldHave);
@@ -262,14 +264,14 @@ class SitesManagerTest extends DatabaseTestCase
{
$idsite = $this->_addSite();
- $siteUrlsBefore = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $siteUrlsBefore = API::getInstance()->getSiteUrlsFromId($idsite);
$toAdd = array_merge($siteUrlsBefore, array("http://piwik1.net", "http://piwik2.net"));
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
+ $insertedUrls = API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
$this->assertEquals(count($toAdd) - count($siteUrlsBefore), $insertedUrls);
- $siteUrlsAfter = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $siteUrlsAfter = API::getInstance()->getSiteUrlsFromId($idsite);
$shouldHave = $toAdd;
sort($shouldHave);
@@ -289,14 +291,14 @@ class SitesManagerTest extends DatabaseTestCase
{
$idsite = $this->_addSite();
- $siteUrlsBefore = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $siteUrlsBefore = API::getInstance()->getSiteUrlsFromId($idsite);
$toAdd = array();
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
+ $insertedUrls = API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
$this->assertEquals(count($toAdd), $insertedUrls);
- $siteUrlsAfter = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $siteUrlsAfter = API::getInstance()->getSiteUrlsFromId($idsite);
$shouldHave = $siteUrlsBefore;
sort($shouldHave);
@@ -316,14 +318,14 @@ class SitesManagerTest extends DatabaseTestCase
{
$idsite = $this->_addSite();
- $siteUrlsBefore = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $siteUrlsBefore = API::getInstance()->getSiteUrlsFromId($idsite);
$toAdd = $siteUrlsBefore;
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
+ $insertedUrls = API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
$this->assertEquals(0, $insertedUrls);
- $siteUrlsAfter = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $siteUrlsAfter = API::getInstance()->getSiteUrlsFromId($idsite);
$shouldHave = $siteUrlsBefore;
sort($shouldHave);
@@ -344,7 +346,7 @@ class SitesManagerTest extends DatabaseTestCase
try {
$idsite = $this->_addSite();
$toAdd = array("http:mpigeq");
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
+ $insertedUrls = API::getInstance()->addSiteAliasUrls($idsite, $toAdd);
} catch (Exception $e) {
return;
}
@@ -361,7 +363,7 @@ class SitesManagerTest extends DatabaseTestCase
{
try {
$toAdd = array("http://pigeq.com/test");
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls(-1, $toAdd);
+ $insertedUrls = API::getInstance()->addSiteAliasUrls(-1, $toAdd);
} catch (Exception $e) {
return;
}
@@ -378,7 +380,7 @@ class SitesManagerTest extends DatabaseTestCase
{
try {
$toAdd = array("http://pigeq.com/test");
- $insertedUrls = Piwik_SitesManager_API::getInstance()->addSiteAliasUrls(155, $toAdd);
+ $insertedUrls = API::getInstance()->addSiteAliasUrls(155, $toAdd);
} catch (Exception $e) {
return;
}
@@ -393,7 +395,7 @@ class SitesManagerTest extends DatabaseTestCase
*/
public function testGetAllSitesIdNoId()
{
- $ids = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $ids = API::getInstance()->getAllSitesId();
$this->assertEquals(array(), $ids);
}
@@ -407,14 +409,14 @@ class SitesManagerTest extends DatabaseTestCase
{
$name = "tetq";
$idsites = array(
- Piwik_SitesManager_API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/")),
- Piwik_SitesManager_API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/")),
- Piwik_SitesManager_API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/")),
- Piwik_SitesManager_API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/")),
- Piwik_SitesManager_API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/")),
+ API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/")),
+ API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/")),
+ API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/")),
+ API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/")),
+ API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/")),
);
- $ids = Piwik_SitesManager_API::getInstance()->getAllSitesId();
+ $ids = API::getInstance()->getAllSitesId();
$this->assertEquals($idsites, $ids);
}
@@ -427,7 +429,7 @@ class SitesManagerTest extends DatabaseTestCase
public function testGetSiteFromIdWrongId1()
{
try {
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId(0);
+ $siteInfo = API::getInstance()->getSiteFromId(0);
} catch (Exception $e) {
return;
}
@@ -443,7 +445,7 @@ class SitesManagerTest extends DatabaseTestCase
public function testGetSiteFromIdWrongId2()
{
try {
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId("x1");
+ $siteInfo = API::getInstance()->getSiteFromId("x1");
} catch (Exception $e) {
return;
}
@@ -458,7 +460,7 @@ class SitesManagerTest extends DatabaseTestCase
*/
public function testGetSiteFromIdWrongId3()
{
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site", array("http://piwik.net", "http://piwik.com/test/"));
+ $idsite = API::getInstance()->addSite("site", array("http://piwik.net", "http://piwik.com/test/"));
$this->assertEquals(1, $idsite);
// set noaccess to site 1
@@ -466,7 +468,7 @@ class SitesManagerTest extends DatabaseTestCase
FakeAccess::setIdSitesAdmin(array());
try {
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId(1);
+ $siteInfo = API::getInstance()->getSiteFromId(1);
} catch (Exception $e) {
return;
}
@@ -482,10 +484,10 @@ class SitesManagerTest extends DatabaseTestCase
public function testGetSiteFromIdNormalId()
{
$name = "website ''";
- $idsite = Piwik_SitesManager_API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/"));
+ $idsite = API::getInstance()->addSite($name, array("http://piwik.net", "http://piwik.com/test/"));
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_INT, $idsite);
- $siteInfo = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
+ $siteInfo = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($name, $siteInfo['name']);
$this->assertEquals("http://piwik.net", $siteInfo['main_url']);
}
@@ -501,7 +503,7 @@ class SitesManagerTest extends DatabaseTestCase
{
FakeAccess::setIdSitesAdmin(array());
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
+ $sites = API::getInstance()->getSitesWithAdminAccess();
$this->assertEquals(array(), $sites);
}
@@ -513,9 +515,9 @@ class SitesManagerTest extends DatabaseTestCase
*/
public function testGetSitesWithAdminAccess()
{
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2", array("http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3", array("http://piwik.org"));
+ $idsite = API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/"));
+ $idsite = API::getInstance()->addSite("site2", array("http://piwik.com/test/"));
+ $idsite = API::getInstance()->addSite("site3", array("http://piwik.org"));
$resultWanted = array(
0 => array("idsite" => 1, "name" => "site1", "main_url" => "http://piwik.net", "ecommerce" => 0, "excluded_ips" => "", 'sitesearch' => 1, 'sitesearch_keyword_parameters' => '', 'sitesearch_category_parameters' => '', 'excluded_parameters' => '', 'excluded_user_agents' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => '', 'keep_url_fragment' => 0),
@@ -524,7 +526,7 @@ class SitesManagerTest extends DatabaseTestCase
FakeAccess::setIdSitesAdmin(array(1, 3));
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
+ $sites = API::getInstance()->getSitesWithAdminAccess();
// we dont test the ts_created
unset($sites[0]['ts_created']);
@@ -543,7 +545,7 @@ class SitesManagerTest extends DatabaseTestCase
FakeAccess::setIdSitesView(array());
FakeAccess::setIdSitesAdmin(array());
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess();
+ $sites = API::getInstance()->getSitesWithViewAccess();
$this->assertEquals(array(), $sites);
}
@@ -555,9 +557,9 @@ class SitesManagerTest extends DatabaseTestCase
*/
public function testGetSitesWithViewAccess()
{
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2", array("http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3", array("http://piwik.org"));
+ $idsite = API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/"));
+ $idsite = API::getInstance()->addSite("site2", array("http://piwik.com/test/"));
+ $idsite = API::getInstance()->addSite("site3", array("http://piwik.org"));
$resultWanted = array(
0 => array("idsite" => 1, "name" => "site1", "main_url" => "http://piwik.net", "ecommerce" => 0, 'sitesearch' => 1, 'sitesearch_keyword_parameters' => '', 'sitesearch_category_parameters' => '', "excluded_ips" => "", 'excluded_parameters' => '', 'excluded_user_agents' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => '', 'keep_url_fragment' => 0),
@@ -567,7 +569,7 @@ class SitesManagerTest extends DatabaseTestCase
FakeAccess::setIdSitesView(array(1, 3));
FakeAccess::setIdSitesAdmin(array());
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithViewAccess();
+ $sites = API::getInstance()->getSitesWithViewAccess();
// we dont test the ts_created
unset($sites[0]['ts_created']);
unset($sites[1]['ts_created']);
@@ -585,7 +587,7 @@ class SitesManagerTest extends DatabaseTestCase
FakeAccess::setIdSitesView(array());
FakeAccess::setIdSitesAdmin(array());
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess();
+ $sites = API::getInstance()->getSitesWithAtLeastViewAccess();
$this->assertEquals(array(), $sites);
}
@@ -597,9 +599,9 @@ class SitesManagerTest extends DatabaseTestCase
*/
public function testGetSitesWithAtLeastViewAccess()
{
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/"), $ecommerce = 1);
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2", array("http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3", array("http://piwik.org"));
+ $idsite = API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/"), $ecommerce = 1);
+ $idsite = API::getInstance()->addSite("site2", array("http://piwik.com/test/"));
+ $idsite = API::getInstance()->addSite("site3", array("http://piwik.org"));
$resultWanted = array(
0 => array("idsite" => 1, "name" => "site1", "main_url" => "http://piwik.net", "ecommerce" => 1, "excluded_ips" => "", 'sitesearch' => 1, 'sitesearch_keyword_parameters' => '', 'sitesearch_category_parameters' => '', 'excluded_parameters' => '', 'excluded_user_agents' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => '', 'keep_url_fragment' => 0),
@@ -609,7 +611,7 @@ class SitesManagerTest extends DatabaseTestCase
FakeAccess::setIdSitesView(array(1, 3));
FakeAccess::setIdSitesAdmin(array());
- $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess();
+ $sites = API::getInstance()->getSitesWithAtLeastViewAccess();
// we dont test the ts_created
unset($sites[0]['ts_created']);
unset($sites[1]['ts_created']);
@@ -624,9 +626,9 @@ class SitesManagerTest extends DatabaseTestCase
*/
public function testGetSiteUrlsFromIdNoUrls()
{
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array("http://piwik.net"));
+ $idsite = API::getInstance()->addSite("site1", array("http://piwik.net"));
- $urls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $urls = API::getInstance()->getSiteUrlsFromId($idsite);
$this->assertEquals(array("http://piwik.net"), $urls);
}
@@ -644,13 +646,13 @@ class SitesManagerTest extends DatabaseTestCase
"http://piwik.com");
sort($site);
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", $site);
+ $idsite = API::getInstance()->addSite("site1", $site);
$siteWanted = array("http://piwik.net",
"http://piwik.org",
"http://piwik.com");
sort($siteWanted);
- $urls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $urls = API::getInstance()->getSiteUrlsFromId($idsite);
$this->assertEquals($siteWanted, $urls);
@@ -667,7 +669,7 @@ class SitesManagerTest extends DatabaseTestCase
try {
FakeAccess::setIdSitesView(array(3));
FakeAccess::setIdSitesAdmin(array());
- Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId(1);
+ API::getInstance()->getSiteUrlsFromId(1);
} catch (Exception $e) {
return;
}
@@ -686,34 +688,34 @@ class SitesManagerTest extends DatabaseTestCase
"http://piwiknew.net",
"http://piwiknew.org",
"http://piwiknew.fr");
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", $urls);
+ $idsite = API::getInstance()->addSite("site1", $urls);
$newMainUrl = "http://main.url";
// Also test that the group was set to empty, and is searchable
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup('');
+ $websites = API::getInstance()->getSitesFromGroup('');
$this->assertEquals(1, count($websites));
// the Update doesn't change the group field
- Piwik_SitesManager_API::getInstance()->updateSite($idsite, "test toto@{}", $newMainUrl);
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup('');
+ API::getInstance()->updateSite($idsite, "test toto@{}", $newMainUrl);
+ $websites = API::getInstance()->getSitesFromGroup('');
$this->assertEquals(1, count($websites));
// Updating the group to something
$group = 'something';
- Piwik_SitesManager_API::getInstance()->updateSite($idsite, "test toto@{}", $newMainUrl, $ecommerce = 0, $ss = true, $ss_kwd = null, $ss_cat = '', $ips = null, $parametersExclude = null, $timezone = null, $currency = null, $group);
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup($group);
+ API::getInstance()->updateSite($idsite, "test toto@{}", $newMainUrl, $ecommerce = 0, $ss = true, $ss_kwd = null, $ss_cat = '', $ips = null, $parametersExclude = null, $timezone = null, $currency = null, $group);
+ $websites = API::getInstance()->getSitesFromGroup($group);
$this->assertEquals(1, count($websites));
$this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($websites[0]['ts_created'])));
// Updating the group to nothing
$group = '';
- Piwik_SitesManager_API::getInstance()->updateSite($idsite, "test toto@{}", $newMainUrl, $ecommerce = 0, $ss = false, $ss_kwd = '', $ss_cat = null, $ips = null, $parametersExclude = null, $timezone = null, $currency = null, $group, $startDate = '2010-01-01');
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup($group);
+ API::getInstance()->updateSite($idsite, "test toto@{}", $newMainUrl, $ecommerce = 0, $ss = false, $ss_kwd = '', $ss_cat = null, $ips = null, $parametersExclude = null, $timezone = null, $currency = null, $group, $startDate = '2010-01-01');
+ $websites = API::getInstance()->getSitesFromGroup($group);
$this->assertEquals(1, count($websites));
$this->assertEquals('2010-01-01', date('Y-m-d', strtotime($websites[0]['ts_created'])));
- $allUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $allUrls = API::getInstance()->getSiteUrlsFromId($idsite);
$this->assertEquals($newMainUrl, $allUrls[0]);
$aliasUrls = array_slice($allUrls, 1);
$this->assertEquals(array(), $aliasUrls);
@@ -727,12 +729,12 @@ class SitesManagerTest extends DatabaseTestCase
*/
public function testUpdateSiteStrangeNameNoUrl()
{
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", "http://main.url");
+ $idsite = API::getInstance()->addSite("site1", "http://main.url");
$newName = "test toto@{'786'}";
- Piwik_SitesManager_API::getInstance()->updateSite($idsite, $newName);
+ API::getInstance()->updateSite($idsite, $newName);
- $site = Piwik_SitesManager_API::getInstance()->getSiteFromId($idsite);
+ $site = API::getInstance()->getSiteFromId($idsite);
$this->assertEquals($newName, $site['name']);
// url didn't change because parameter url NULL in updateSite
@@ -754,11 +756,11 @@ class SitesManagerTest extends DatabaseTestCase
"http://piwiknew.fr");
$group = 'GROUP Before';
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", $urls, $ecommerce = 1,
+ $idsite = API::getInstance()->addSite("site1", $urls, $ecommerce = 1,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null,
$excludedIps = null, $excludedQueryParameters = null, $timezone = null, $currency = null, $group, $startDate = '2011-01-01');
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup($group);
+ $websites = API::getInstance()->getSitesFromGroup($group);
$this->assertEquals(1, count($websites));
$newurls = array("http://piwiknew2.com",
@@ -767,25 +769,25 @@ class SitesManagerTest extends DatabaseTestCase
"http://piwiknew2.fr");
$groupAfter = ' GROUP After';
- Piwik_SitesManager_API::getInstance()->updateSite($idsite, "test toto@{}", $newurls, $ecommerce = 0,
+ API::getInstance()->updateSite($idsite, "test toto@{}", $newurls, $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null,
$excludedIps = null, $excludedQueryParameters = null, $timezone = null, $currency = null, $groupAfter);
// no result for the group before update
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup($group);
+ $websites = API::getInstance()->getSitesFromGroup($group);
$this->assertEquals(0, count($websites));
// Testing that the group was updated properly (and testing that the group value is trimmed before inserted/searched)
- $websites = Piwik_SitesManager_API::getInstance()->getSitesFromGroup($groupAfter . ' ');
+ $websites = API::getInstance()->getSitesFromGroup($groupAfter . ' ');
$this->assertEquals(1, count($websites));
$this->assertEquals('2011-01-01', date('Y-m-d', strtotime($websites[0]['ts_created'])));
// Test fetch website groups
$expectedGroups = array(trim($groupAfter));
- $fetched = Piwik_SitesManager_API::getInstance()->getSitesGroups();
+ $fetched = API::getInstance()->getSitesGroups();
$this->assertEquals($expectedGroups, $fetched);
- $allUrls = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($idsite);
+ $allUrls = API::getInstance()->getSiteUrlsFromId($idsite);
sort($allUrls);
sort($newurls);
$this->assertEquals($newurls, $allUrls);
@@ -801,10 +803,10 @@ class SitesManagerTest extends DatabaseTestCase
$groups = array('group1', ' group1 ', '', 'group2');
$expectedGroups = array('group1', '', 'group2');
foreach ($groups as $group) {
- Piwik_SitesManager_API::getInstance()->addSite("test toto@{}", 'http://example.org', $ecommerce = 1, $siteSearch = null, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, $excludedQueryParameters = null, $timezone = null, $currency = null, $group);
+ API::getInstance()->addSite("test toto@{}", 'http://example.org', $ecommerce = 1, $siteSearch = null, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, $excludedQueryParameters = null, $timezone = null, $currency = null, $group);
}
- $this->assertEquals($expectedGroups, Piwik_SitesManager_API::getInstance()->getSitesGroups());
+ $this->assertEquals($expectedGroups, API::getInstance()->getSitesGroups());
}
@@ -825,7 +827,7 @@ class SitesManagerTest extends DatabaseTestCase
public function testAddSitesInvalidTimezone($timezone)
{
try {
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
+ $idsite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $ip = '', $params = '', $timezone);
} catch (Exception $e) {
return;
@@ -842,7 +844,7 @@ class SitesManagerTest extends DatabaseTestCase
{
try {
$invalidCurrency = '€';
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
+ $idsite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
$siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, '', 'UTC', $invalidCurrency);
} catch (Exception $e) {
return;
@@ -858,17 +860,17 @@ class SitesManagerTest extends DatabaseTestCase
public function testSetDefaultTimezoneAndCurrencyAndExcludedQueryParametersAndExcludedIps()
{
// test that they return default values
- $defaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
+ $defaultTimezone = API::getInstance()->getDefaultTimezone();
$this->assertEquals('UTC', $defaultTimezone);
- $defaultCurrency = Piwik_SitesManager_API::getInstance()->getDefaultCurrency();
+ $defaultCurrency = API::getInstance()->getDefaultCurrency();
$this->assertEquals('USD', $defaultCurrency);
- $excludedIps = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
+ $excludedIps = API::getInstance()->getExcludedIpsGlobal();
$this->assertEquals('', $excludedIps);
- $excludedQueryParameters = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
+ $excludedQueryParameters = API::getInstance()->getExcludedQueryParametersGlobal();
$this->assertEquals('', $excludedQueryParameters);
// test that when not specified, defaults are set as expected
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'));
+ $idsite = API::getInstance()->addSite("site1", array('http://example.org'));
$site = new Site($idsite);
$this->assertEquals('UTC', $site->getTimezone());
$this->assertEquals('USD', $site->getCurrency());
@@ -878,33 +880,33 @@ class SitesManagerTest extends DatabaseTestCase
// set the global timezone and get it
$newDefaultTimezone = 'UTC+5.5';
- Piwik_SitesManager_API::getInstance()->setDefaultTimezone($newDefaultTimezone);
- $defaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
+ API::getInstance()->setDefaultTimezone($newDefaultTimezone);
+ $defaultTimezone = API::getInstance()->getDefaultTimezone();
$this->assertEquals($newDefaultTimezone, $defaultTimezone);
// set the default currency and get it
$newDefaultCurrency = 'EUR';
- Piwik_SitesManager_API::getInstance()->setDefaultCurrency($newDefaultCurrency);
- $defaultCurrency = Piwik_SitesManager_API::getInstance()->getDefaultCurrency();
+ API::getInstance()->setDefaultCurrency($newDefaultCurrency);
+ $defaultCurrency = API::getInstance()->getDefaultCurrency();
$this->assertEquals($newDefaultCurrency, $defaultCurrency);
// set the global IPs to exclude and get it
$newGlobalExcludedIps = '1.1.1.*,1.1.*.*,150.1.1.1';
- Piwik_SitesManager_API::getInstance()->setGlobalExcludedIps($newGlobalExcludedIps);
- $globalExcludedIps = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
+ API::getInstance()->setGlobalExcludedIps($newGlobalExcludedIps);
+ $globalExcludedIps = API::getInstance()->getExcludedIpsGlobal();
$this->assertEquals($newGlobalExcludedIps, $globalExcludedIps);
// set the global URL query params to exclude and get it
$newGlobalExcludedQueryParameters = 'PHPSESSID,blabla, TesT';
// removed the space
$expectedGlobalExcludedQueryParameters = 'PHPSESSID,blabla,TesT';
- Piwik_SitesManager_API::getInstance()->setGlobalExcludedQueryParameters($newGlobalExcludedQueryParameters);
- $globalExcludedQueryParameters = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
+ API::getInstance()->setGlobalExcludedQueryParameters($newGlobalExcludedQueryParameters);
+ $globalExcludedQueryParameters = API::getInstance()->getExcludedQueryParametersGlobal();
$this->assertEquals($expectedGlobalExcludedQueryParameters, $globalExcludedQueryParameters);
// create a website and check that default currency and default timezone are set
// however, excluded IPs and excluded query Params are not returned
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
+ $idsite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0,
$siteSearch = 0, $searchKeywordParameters = 'test1,test2', $searchCategoryParameters = 'test2,test1',
'', '', $newDefaultTimezone);
$site = new Site($idsite);
@@ -928,20 +930,20 @@ class SitesManagerTest extends DatabaseTestCase
*/
public function testGetSitesIdFromSiteUrlSuperUser()
{
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2", array("http://piwik.com", "http://piwik.net"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3", array("http://piwik.com", "http://piwik.org"));
+ $idsite = API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com"));
+ $idsite = API::getInstance()->addSite("site2", array("http://piwik.com", "http://piwik.net"));
+ $idsite = API::getInstance()->addSite("site3", array("http://piwik.com", "http://piwik.org"));
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.org');
+ $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.org');
$this->assertTrue(count($idsites) == 1);
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://www.piwik.org');
+ $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://www.piwik.org');
$this->assertTrue(count($idsites) == 1);
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
+ $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
$this->assertTrue(count($idsites) == 2);
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
+ $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
$this->assertTrue(count($idsites) == 3);
}
@@ -952,22 +954,22 @@ class SitesManagerTest extends DatabaseTestCase
*/
public function testGetSitesIdFromSiteUrlUser()
{
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array("http://www.piwik.net", "http://piwik.com"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2", array("http://piwik.com", "http://piwik.net"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3", array("http://piwik.com", "http://piwik.org"));
+ $idsite = API::getInstance()->addSite("site1", array("http://www.piwik.net", "http://piwik.com"));
+ $idsite = API::getInstance()->addSite("site2", array("http://piwik.com", "http://piwik.net"));
+ $idsite = API::getInstance()->addSite("site3", array("http://piwik.com", "http://piwik.org"));
$saveAccess = Access::getInstance();
- Piwik_UsersManager_API::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->setUserAccess("user1", "view", array(1));
+ UsersManagerAPI::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
+ UsersManagerAPI::getInstance()->setUserAccess("user1", "view", array(1));
- Piwik_UsersManager_API::getInstance()->addUser("user2", "geqgegagae", "tegst2@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->setUserAccess("user2", "view", array(1));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user2", "admin", array(3));
+ UsersManagerAPI::getInstance()->addUser("user2", "geqgegagae", "tegst2@tesgt.com", "alias");
+ UsersManagerAPI::getInstance()->setUserAccess("user2", "view", array(1));
+ UsersManagerAPI::getInstance()->setUserAccess("user2", "admin", array(3));
- Piwik_UsersManager_API::getInstance()->addUser("user3", "geqgegagae", "tegst3@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->setUserAccess("user3", "view", array(1, 2));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user3", "admin", array(3));
+ UsersManagerAPI::getInstance()->addUser("user3", "geqgegagae", "tegst3@tesgt.com", "alias");
+ UsersManagerAPI::getInstance()->setUserAccess("user3", "view", array(1, 2));
+ UsersManagerAPI::getInstance()->setUserAccess("user3", "admin", array(3));
$pseudoMockAccess = new FakeAccess;
FakeAccess::$superUser = false;
@@ -975,13 +977,13 @@ class SitesManagerTest extends DatabaseTestCase
FakeAccess::setIdSitesView(array(1));
FakeAccess::setIdSitesAdmin(array());
Access::setSingletonInstance($pseudoMockAccess);
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
+ $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
$this->assertEquals(1, count($idsites));
// testing URL normalization
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://www.piwik.com');
+ $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://www.piwik.com');
$this->assertEquals(1, count($idsites));
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
+ $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
$this->assertEquals(1, count($idsites));
$pseudoMockAccess = new FakeAccess;
@@ -990,7 +992,7 @@ class SitesManagerTest extends DatabaseTestCase
FakeAccess::setIdSitesView(array(1));
FakeAccess::setIdSitesAdmin(array(3));
Access::setSingletonInstance($pseudoMockAccess);
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
+ $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
$this->assertEquals(2, count($idsites));
$pseudoMockAccess = new FakeAccess;
@@ -999,7 +1001,7 @@ class SitesManagerTest extends DatabaseTestCase
FakeAccess::setIdSitesView(array(1, 2));
FakeAccess::setIdSitesAdmin(array(3));
Access::setSingletonInstance($pseudoMockAccess);
- $idsites = Piwik_SitesManager_API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
+ $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
$this->assertEquals(3, count($idsites));
Access::setSingletonInstance($saveAccess);
@@ -1012,11 +1014,11 @@ class SitesManagerTest extends DatabaseTestCase
*/
public function testGetSitesFromTimezones()
{
- $idsite1 = Piwik_SitesManager_API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'UTC');
- $idsite2 = Piwik_SitesManager_API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'Pacific/Auckland');
- $idsite3 = Piwik_SitesManager_API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'Pacific/Auckland');
- $idsite4 = Piwik_SitesManager_API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'UTC+10');
- $result = Piwik_SitesManager_API::getInstance()->getSitesIdFromTimezones(array('UTC+10', 'Pacific/Auckland'));
+ $idsite1 = API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'UTC');
+ $idsite2 = API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'Pacific/Auckland');
+ $idsite3 = API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'Pacific/Auckland');
+ $idsite4 = API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'UTC+10');
+ $result = API::getInstance()->getSitesIdFromTimezones(array('UTC+10', 'Pacific/Auckland'));
$this->assertEquals(array($idsite2, $idsite3, $idsite4), $result);
}
}
diff --git a/tests/PHPUnit/Plugins/UserCountryTest.php b/tests/PHPUnit/Plugins/UserCountryTest.php
index effc0b64a9..4d1be73b94 100644
--- a/tests/PHPUnit/Plugins/UserCountryTest.php
+++ b/tests/PHPUnit/Plugins/UserCountryTest.php
@@ -6,9 +6,13 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
use Piwik\Piwik;
+use Piwik\Plugins\UserCountry;
+use Piwik\Plugins\UserCountry\LocationProvider;
+use Piwik\Plugins\UserCountry\GeoIPAutoUpdater;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/UserCountry.php';
-require_once 'UserCountry/functions.php';
+require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/functions.php';
require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/Countries.php';
class Test_Piwik_UserCountry extends PHPUnit_Framework_Testcase
@@ -20,7 +24,7 @@ class Test_Piwik_UserCountry extends PHPUnit_Framework_Testcase
*/
public function testGetFlagFromCode()
{
- $flag = Piwik_getFlagFromCode("us");
+ $flag = \Piwik\Plugins\UserCountry\getFlagFromCode("us");
$this->assertEquals(basename($flag), "us.png");
}
@@ -31,7 +35,7 @@ class Test_Piwik_UserCountry extends PHPUnit_Framework_Testcase
*/
public function testGetFlagFromInvalidCode()
{
- $flag = Piwik_getFlagFromCode("foo");
+ $flag = \Piwik\Plugins\UserCountry\getFlagFromCode("foo");
$this->assertEquals(basename($flag), "xx.png");
}
@@ -79,8 +83,8 @@ class Test_Piwik_UserCountry extends PHPUnit_Framework_Testcase
*/
public function testGeoIpUpdaterRedundantChecks()
{
- Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
- Piwik_UserCountry_LocationProvider::$providers = null;
+ GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
+ LocationProvider::$providers = null;
// create empty ISP & Org files
$this->createEmptyISPOrgFiles();
@@ -166,7 +170,7 @@ class Test_Piwik_UserCountry extends PHPUnit_Framework_Testcase
}
}
-class Piwik_UserCountry_GeoIPAutoUpdater_publictest extends Piwik_UserCountry_GeoIPAutoUpdater
+class Piwik_UserCountry_GeoIPAutoUpdater_publictest extends GeoIPAutoUpdater
{
public function performRedundantDbChecks()
{
diff --git a/tests/PHPUnit/Plugins/UserSettingsTest.php b/tests/PHPUnit/Plugins/UserSettingsTest.php
index fb99c787a6..6f9ac3d2d6 100644
--- a/tests/PHPUnit/Plugins/UserSettingsTest.php
+++ b/tests/PHPUnit/Plugins/UserSettingsTest.php
@@ -1005,7 +1005,7 @@ class UserSettingsTest extends PHPUnit_Framework_TestCase
if ($res === false)
$this->assertFalse($expected[0]);
else {
- $family = Piwik_getBrowserFamily($res['id']);
+ $family = \Piwik\Plugins\UserSettings\getBrowserFamily($res['id']);
$this->assertEquals($expected[0][0], $res['id']);
$this->assertEquals($expected[0][1], $res['name']);
$this->assertEquals($expected[0][2], $res['short_name']);
diff --git a/tests/PHPUnit/Plugins/UsersManagerTest.php b/tests/PHPUnit/Plugins/UsersManagerTest.php
index eb37aafd76..c24d9fdeac 100644
--- a/tests/PHPUnit/Plugins/UsersManagerTest.php
+++ b/tests/PHPUnit/Plugins/UsersManagerTest.php
@@ -1,6 +1,8 @@
<?php
use Piwik\Config;
use Piwik\Access;
+use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
+use Piwik\Plugins\UsersManager\API;
/**
* Piwik - Open source web analytics
@@ -54,12 +56,12 @@ class UsersManagerTest extends DatabaseTestCase
if (is_null($newAlias)) {
$newAlias = $user['alias'];
}
- $userAfter = Piwik_UsersManager_API::getInstance()->getUser($user["login"]);
+ $userAfter = API::getInstance()->getUser($user["login"]);
unset($userAfter['date_registered']);
// we now compute what the token auth should be, it should always be a hash of the login and the current password
// if the password has changed then the token_auth has changed!
- $user['token_auth'] = Piwik_UsersManager_API::getInstance()->getTokenAuth($user["login"], md5($newPassword));
+ $user['token_auth'] = API::getInstance()->getTokenAuth($user["login"], md5($newPassword));
$user['password'] = md5($newPassword);
$user['email'] = $newEmail;
@@ -84,29 +86,29 @@ class UsersManagerTest extends DatabaseTestCase
'password' => "geqgeagae",
'email' => "test@test.com",
'alias' => "alias");
- Piwik_UsersManager_API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
+ API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
$exceptionNotRaised = false;
try {
- Piwik_UsersManager_API::getInstance()->addUser('superusertest', 'te', 'fake@fale.co', 'ega');
+ API::getInstance()->addUser('superusertest', 'te', 'fake@fale.co', 'ega');
$exceptionNotRaised = true;
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionSuperUser)", $expected->getMessage());
}
try {
- Piwik_UsersManager_API::getInstance()->updateUser('superusertest', 'te', 'fake@fale.co', 'ega');
+ API::getInstance()->updateUser('superusertest', 'te', 'fake@fale.co', 'ega');
$exceptionNotRaised = true;
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionSuperUser)", $expected->getMessage());
}
try {
- Piwik_UsersManager_API::getInstance()->deleteUser('superusertest', 'te', 'fake@fale.co', 'ega');
+ API::getInstance()->deleteUser('superusertest', 'te', 'fake@fale.co', 'ega');
$exceptionNotRaised = true;
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionSuperUser)", $expected->getMessage());
}
try {
- Piwik_UsersManager_API::getInstance()->deleteUser('superusertest', 'te', 'fake@fale.co', 'ega');
+ API::getInstance()->deleteUser('superusertest', 'te', 'fake@fale.co', 'ega');
$exceptionNotRaised = true;
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionSuperUser)", $expected->getMessage());
@@ -130,11 +132,11 @@ class UsersManagerTest extends DatabaseTestCase
'email' => "test@test.com",
'alias' => "alias");
- Piwik_UsersManager_API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
+ API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
try {
- Piwik_UsersManager_API::getInstance()->updateUser($login, "pas");
+ API::getInstance()->updateUser($login, "pas");
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionInvalidPassword)", $expected->getMessage());
@@ -167,7 +169,7 @@ class UsersManagerTest extends DatabaseTestCase
public function testAddUserWrongLogin($userLogin, $password, $email, $alias)
{
try {
- Piwik_UsersManager_API::getInstance()->addUser($userLogin, $password, $email, $alias);
+ API::getInstance()->addUser($userLogin, $password, $email, $alias);
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionInvalidLogin)", $expected->getMessage());
return;
@@ -184,8 +186,8 @@ class UsersManagerTest extends DatabaseTestCase
public function testAddUserExistingLogin()
{
try {
- Piwik_UsersManager_API::getInstance()->addUser("test", "password", "email@email.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("test", "password2", "em2ail@email.com", "al2ias");
+ API::getInstance()->addUser("test", "password", "email@email.com", "alias");
+ API::getInstance()->addUser("test", "password2", "em2ail@email.com", "al2ias");
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionLoginExists)", $expected->getMessage());
return;
@@ -215,7 +217,7 @@ class UsersManagerTest extends DatabaseTestCase
public function testAddUserWrongPassword($userLogin, $password, $email, $alias)
{
try {
- Piwik_UsersManager_API::getInstance()->addUser($userLogin, $password, $email, $alias);
+ API::getInstance()->addUser($userLogin, $password, $email, $alias);
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionInvalidPassword)", $expected->getMessage());
return;
@@ -245,7 +247,7 @@ class UsersManagerTest extends DatabaseTestCase
public function testAddUserWrongEmail($userLogin, $password, $email, $alias)
{
try {
- Piwik_UsersManager_API::getInstance()->addUser($userLogin, $password, $email, $alias);
+ API::getInstance()->addUser($userLogin, $password, $email, $alias);
} catch (Exception $expected) {
$this->assertRegExp("(mail)", $expected->getMessage());
return;
@@ -263,7 +265,7 @@ class UsersManagerTest extends DatabaseTestCase
{
try {
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "", "alias");
+ API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "", "alias");
} catch (Exception $expected) {
$this->assertRegExp("(mail)", $expected->getMessage());
return;
@@ -280,8 +282,8 @@ class UsersManagerTest extends DatabaseTestCase
public function testAddUserEmptyAlias()
{
$login = "geggeqgeqag";
- Piwik_UsersManager_API::getInstance()->addUser($login, "geqgeagae", "mgeagi@geq.com", "");
- $user = Piwik_UsersManager_API::getInstance()->getUser($login);
+ API::getInstance()->addUser($login, "geqgeagae", "mgeagi@geq.com", "");
+ $user = API::getInstance()->getUser($login);
$this->assertEquals($login, $user['alias']);
$this->assertEquals($login, $user['login']);
}
@@ -295,8 +297,8 @@ class UsersManagerTest extends DatabaseTestCase
public function testAddUserNoAliasSpecified()
{
$login = "geggeqg455eqag";
- Piwik_UsersManager_API::getInstance()->addUser($login, "geqgeagae", "mgeagi@geq.com");
- $user = Piwik_UsersManager_API::getInstance()->getUser($login);
+ API::getInstance()->addUser($login, "geqgeagae", "mgeagi@geq.com");
+ $user = API::getInstance()->getUser($login);
$this->assertEquals($login, $user['alias']);
$this->assertEquals($login, $user['login']);
}
@@ -315,8 +317,8 @@ class UsersManagerTest extends DatabaseTestCase
$alias = "her is my alias )(&|\" '£%*(&%+))";
$time = time();
- Piwik_UsersManager_API::getInstance()->addUser($login, $password, $email, $alias);
- $user = Piwik_UsersManager_API::getInstance()->getUser($login);
+ API::getInstance()->addUser($login, $password, $email, $alias);
+ $user = API::getInstance()->getUser($login);
// check that the date registered is correct
$this->assertTrue($time <= strtotime($user['date_registered']) && strtotime($user['date_registered']) <= time(),
@@ -344,10 +346,10 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testSeleteUserDoesntExist()
{
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "test@test.com", "alias");
+ API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "test@test.com", "alias");
try {
- Piwik_UsersManager_API::getInstance()->deleteUser("geggeqggnew");
+ API::getInstance()->deleteUser("geggeqggnew");
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionDeleteDoesNotExist)", $expected->getMessage());
return;
@@ -364,7 +366,7 @@ class UsersManagerTest extends DatabaseTestCase
public function testDeleteUserEmptyUser()
{
try {
- Piwik_UsersManager_API::getInstance()->deleteUser("");
+ API::getInstance()->deleteUser("");
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionDeleteDoesNotExist)", $expected->getMessage());
return;
@@ -381,7 +383,7 @@ class UsersManagerTest extends DatabaseTestCase
public function testDeleteUserNullUser()
{
try {
- Piwik_UsersManager_API::getInstance()->deleteUser(null);
+ API::getInstance()->deleteUser(null);
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionDeleteDoesNotExist)", $expected->getMessage());
return;
@@ -398,35 +400,35 @@ class UsersManagerTest extends DatabaseTestCase
public function testDeleteUser()
{
//create the 3 websites
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site2", array("http://piwik.com/test/"));
- $idsite = Piwik_SitesManager_API::getInstance()->addSite("site3", array("http://piwik.org"));
+ $idsite = SitesManagerAPI::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/"));
+ $idsite = SitesManagerAPI::getInstance()->addSite("site2", array("http://piwik.com/test/"));
+ $idsite = SitesManagerAPI::getInstance()->addSite("site3", array("http://piwik.org"));
//add user and set some rights
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "test@test.com", "alias");
- Piwik_UsersManager_API::getInstance()->setUserAccess("geggeqgeqag", "view", array(1, 2));
- Piwik_UsersManager_API::getInstance()->setUserAccess("geggeqgeqag", "admin", array(1, 3));
+ API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "test@test.com", "alias");
+ API::getInstance()->setUserAccess("geggeqgeqag", "view", array(1, 2));
+ API::getInstance()->setUserAccess("geggeqgeqag", "admin", array(1, 3));
// check rights are set
- $this->assertNotEquals(array(), Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("geggeqgeqag"));
+ $this->assertNotEquals(array(), API::getInstance()->getSitesAccessFromUser("geggeqgeqag"));
// delete the user
- Piwik_UsersManager_API::getInstance()->deleteUser("geggeqgeqag");
+ API::getInstance()->deleteUser("geggeqgeqag");
// try to get it, it should raise an exception
try {
- $user = Piwik_UsersManager_API::getInstance()->getUser("geggeqgeqag");
+ $user = API::getInstance()->getUser("geggeqgeqag");
$this->fail("Exception not raised.");
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionUserDoesNotExist)", $expected->getMessage());
}
// add the same user
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "test@test.com", "alias");
+ API::getInstance()->addUser("geggeqgeqag", "geqgeagae", "test@test.com", "alias");
//checks access have been deleted
//to do so we recreate the same user login and check if the rights are still there
- $this->assertEquals(array(), Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("geggeqgeqag"));
+ $this->assertEquals(array(), API::getInstance()->getSitesAccessFromUser("geggeqgeqag"));
}
@@ -440,7 +442,7 @@ class UsersManagerTest extends DatabaseTestCase
{
// try to get it, it should raise an exception
try {
- $user = Piwik_UsersManager_API::getInstance()->getUser("geggeqgeqag");
+ $user = API::getInstance()->getUser("geggeqgeqag");
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionUserDoesNotExist)", $expected->getMessage());
return;
@@ -462,8 +464,8 @@ class UsersManagerTest extends DatabaseTestCase
$email = "mgeag4544i@geq.com";
$alias = "";
- Piwik_UsersManager_API::getInstance()->addUser($login, $password, $email, $alias);
- $user = Piwik_UsersManager_API::getInstance()->getUser($login);
+ API::getInstance()->addUser($login, $password, $email, $alias);
+ $user = API::getInstance()->getUser($login);
// check that all fields are the same
$this->assertEquals($login, $user['login']);
@@ -483,7 +485,7 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testGetUsersNoUser()
{
- $this->assertEquals(Piwik_UsersManager_API::getInstance()->getUsers(), array());
+ $this->assertEquals(API::getInstance()->getUsers(), array());
}
/**
@@ -495,19 +497,19 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testGetUsers()
{
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("geggeqge632ge56a4qag", "geqgegeagae", "tesggt@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqagqegg", "geqgeaggggae", "tesgggt@tesgt.com");
+ API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
+ API::getInstance()->addUser("geggeqge632ge56a4qag", "geqgegeagae", "tesggt@tesgt.com", "alias");
+ API::getInstance()->addUser("geggeqgeqagqegg", "geqgeaggggae", "tesgggt@tesgt.com");
- $users = Piwik_UsersManager_API::getInstance()->getUsers();
+ $users = API::getInstance()->getUsers();
$users = $this->_removeNonTestableFieldsFromUsers($users);
$user1 = array('login' => "gegg4564eqgeqag", 'password' => md5("geqgegagae"), 'alias' => "alias", 'email' => "tegst@tesgt.com");
$user2 = array('login' => "geggeqge632ge56a4qag", 'password' => md5("geqgegeagae"), 'alias' => "alias", 'email' => "tesggt@tesgt.com");
$user3 = array('login' => "geggeqgeqagqegg", 'password' => md5("geqgeaggggae"), 'alias' => 'geggeqgeqagqegg', 'email' => "tesgggt@tesgt.com");
$expectedUsers = array($user1, $user2, $user3);
$this->assertEquals($expectedUsers, $users);
- $this->assertEquals(array($user1), $this->_removeNonTestableFieldsFromUsers(Piwik_UsersManager_API::getInstance()->getUsers('gegg4564eqgeqag')));
- $this->assertEquals(array($user1, $user2), $this->_removeNonTestableFieldsFromUsers(Piwik_UsersManager_API::getInstance()->getUsers('gegg4564eqgeqag,geggeqge632ge56a4qag')));
+ $this->assertEquals(array($user1), $this->_removeNonTestableFieldsFromUsers(API::getInstance()->getUsers('gegg4564eqgeqag')));
+ $this->assertEquals(array($user1, $user2), $this->_removeNonTestableFieldsFromUsers(API::getInstance()->getUsers('gegg4564eqgeqag,geggeqge632ge56a4qag')));
}
@@ -529,11 +531,11 @@ class UsersManagerTest extends DatabaseTestCase
public function testGetUsersLogin()
{
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("geggeqge632ge56a4qag", "geqgegeagae", "tesggt@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("geggeqgeqagqegg", "geqgeaggggae", "tesgggt@tesgt.com");
+ API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
+ API::getInstance()->addUser("geggeqge632ge56a4qag", "geqgegeagae", "tesggt@tesgt.com", "alias");
+ API::getInstance()->addUser("geggeqgeqagqegg", "geqgeaggggae", "tesgggt@tesgt.com");
- $logins = Piwik_UsersManager_API::getInstance()->getUsersLogin();
+ $logins = API::getInstance()->getUsersLogin();
$this->assertEquals(array("gegg4564eqgeqag", "geggeqge632ge56a4qag", "geggeqgeqagqegg"), $logins);
}
@@ -549,7 +551,7 @@ class UsersManagerTest extends DatabaseTestCase
{
// try to get it, it should raise an exception
try {
- Piwik_UsersManager_API::getInstance()->setUserAccess("nologin", "view", 1);
+ API::getInstance()->setUserAccess("nologin", "view", 1);
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionUserDoesNotExist)", $expected->getMessage());
return;
@@ -565,11 +567,11 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testSetUserAccessWrongAccess()
{
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
+ API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
// try to get it, it should raise an exception
try {
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "viewnotknown", 1);
+ API::getInstance()->setUserAccess("gegg4564eqgeqag", "viewnotknown", 1);
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionAccessValues)", $expected->getMessage());
return;
@@ -585,14 +587,14 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testSetUserAccessIdsitesIsAll()
{
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
+ API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
FakeAccess::$superUser = false;
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", "all");
+ API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", "all");
FakeAccess::$superUser = true;
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
+ $access = API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
$access = $this->_flatten($access);
FakeAccess::$superUser = false;
@@ -613,16 +615,16 @@ class UsersManagerTest extends DatabaseTestCase
{
FakeAccess::$superUser = true;
- $id1 = Piwik_SitesManager_API::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
- $id2 = Piwik_SitesManager_API::getInstance()->addSite("test2", array("http://piwik.net", "http://piwik.com/test/"));
- $id3 = Piwik_SitesManager_API::getInstance()->addSite("test3", array("http://piwik.net", "http://piwik.com/test/"));
- $id4 = Piwik_SitesManager_API::getInstance()->addSite("test4", array("http://piwik.net", "http://piwik.com/test/"));
- $id5 = Piwik_SitesManager_API::getInstance()->addSite("test5", array("http://piwik.net", "http://piwik.com/test/"));
+ $id1 = SitesManagerAPI::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
+ $id2 = SitesManagerAPI::getInstance()->addSite("test2", array("http://piwik.net", "http://piwik.com/test/"));
+ $id3 = SitesManagerAPI::getInstance()->addSite("test3", array("http://piwik.net", "http://piwik.com/test/"));
+ $id4 = SitesManagerAPI::getInstance()->addSite("test4", array("http://piwik.net", "http://piwik.com/test/"));
+ $id5 = SitesManagerAPI::getInstance()->addSite("test5", array("http://piwik.net", "http://piwik.com/test/"));
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", "all");
+ API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
+ API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", "all");
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
+ $access = API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
$access = $this->_flatten($access);
$this->assertEquals(array($id1, $id2, $id3, $id4, $id5), array_keys($access));
@@ -636,11 +638,11 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testSetUserAccessIdsitesEmpty()
{
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
+ API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
try {
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array());
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
+ API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array());
+ $access = API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
} catch (Exception $e) {
return;
}
@@ -655,12 +657,12 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testSetUserAccessIdsitesOneSite()
{
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- $id1 = Piwik_SitesManager_API::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
+ API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
+ $id1 = SitesManagerAPI::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array(1));
+ API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array(1));
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
+ $access = API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
$access = $this->_flatten($access);
$this->assertEquals(array(1), array_keys($access));
}
@@ -674,14 +676,14 @@ class UsersManagerTest extends DatabaseTestCase
public function testSetUserAccessIdsitesMultipleSites()
{
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- $id1 = Piwik_SitesManager_API::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
- $id2 = Piwik_SitesManager_API::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
- $id3 = Piwik_SitesManager_API::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
+ API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
+ $id1 = SitesManagerAPI::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
+ $id2 = SitesManagerAPI::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
+ $id3 = SitesManagerAPI::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array($id1, $id3));
+ API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array($id1, $id3));
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
+ $access = API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
$access = $this->_flatten($access);
$this->assertEquals(array($id1, $id3), array_keys($access));
@@ -695,14 +697,14 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testSetUserAccessWithIdSitesIsStringCommaSeparated()
{
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- $id1 = Piwik_SitesManager_API::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
- $id2 = Piwik_SitesManager_API::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
- $id3 = Piwik_SitesManager_API::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
+ API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
+ $id1 = SitesManagerAPI::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
+ $id2 = SitesManagerAPI::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
+ $id3 = SitesManagerAPI::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", "1,3");
+ API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", "1,3");
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
+ $access = API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
$access = $this->_flatten($access);
$this->assertEquals(array($id1, $id3), array_keys($access));
}
@@ -715,14 +717,14 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testSetUserAccessMultipleCallDistinctAccessSameUser()
{
- Piwik_UsersManager_API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
- $id1 = Piwik_SitesManager_API::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
- $id2 = Piwik_SitesManager_API::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
+ API::getInstance()->addUser("gegg4564eqgeqag", "geqgegagae", "tegst@tesgt.com", "alias");
+ $id1 = SitesManagerAPI::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
+ $id2 = SitesManagerAPI::getInstance()->addSite("test", array("http://piwik.net", "http://piwik.com/test/"));
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array($id1));
- Piwik_UsersManager_API::getInstance()->setUserAccess("gegg4564eqgeqag", "admin", array($id2));
+ API::getInstance()->setUserAccess("gegg4564eqgeqag", "view", array($id1));
+ API::getInstance()->setUserAccess("gegg4564eqgeqag", "admin", array($id2));
- $access = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
+ $access = API::getInstance()->getSitesAccessFromUser("gegg4564eqgeqag");
$access = $this->_flatten($access);
$this->assertEquals(array($id1 => 'view', $id2 => 'admin'), $access);
}
@@ -735,19 +737,19 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testSetUserAccessMultipleCallDistinctAccessMultipleUser()
{
- Piwik_UsersManager_API::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
- Piwik_UsersManager_API::getInstance()->addUser("user2", "geqgegagae", "tegst2@tesgt.com", "alias");
- $id1 = Piwik_SitesManager_API::getInstance()->addSite("test1", array("http://piwik.net", "http://piwik.com/test/"));
- $id2 = Piwik_SitesManager_API::getInstance()->addSite("test2", array("http://piwik.net", "http://piwik.com/test/"));
- $id3 = Piwik_SitesManager_API::getInstance()->addSite("test2", array("http://piwik.net", "http://piwik.com/test/"));
+ API::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
+ API::getInstance()->addUser("user2", "geqgegagae", "tegst2@tesgt.com", "alias");
+ $id1 = SitesManagerAPI::getInstance()->addSite("test1", array("http://piwik.net", "http://piwik.com/test/"));
+ $id2 = SitesManagerAPI::getInstance()->addSite("test2", array("http://piwik.net", "http://piwik.com/test/"));
+ $id3 = SitesManagerAPI::getInstance()->addSite("test2", array("http://piwik.net", "http://piwik.com/test/"));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user1", "view", array($id1, $id2));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user2", "admin", array($id1));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user2", "view", array($id3, $id2));
+ API::getInstance()->setUserAccess("user1", "view", array($id1, $id2));
+ API::getInstance()->setUserAccess("user2", "admin", array($id1));
+ API::getInstance()->setUserAccess("user2", "view", array($id3, $id2));
- $access1 = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("user1");
+ $access1 = API::getInstance()->getSitesAccessFromUser("user1");
$access1 = $this->_flatten($access1);
- $access2 = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("user2");
+ $access2 = API::getInstance()->getSitesAccessFromUser("user2");
$access2 = $this->_flatten($access2);
$wanted1 = array($id1 => 'view', $id2 => 'view',);
$wanted2 = array($id1 => 'admin', $id2 => 'view', $id3 => 'view');
@@ -756,9 +758,9 @@ class UsersManagerTest extends DatabaseTestCase
$this->assertEquals($wanted2, $access2);
- $access1 = Piwik_UsersManager_API::getInstance()->getUsersAccessFromSite($id1);
- $access2 = Piwik_UsersManager_API::getInstance()->getUsersAccessFromSite($id2);
- $access3 = Piwik_UsersManager_API::getInstance()->getUsersAccessFromSite($id3);
+ $access1 = API::getInstance()->getUsersAccessFromSite($id1);
+ $access2 = API::getInstance()->getUsersAccessFromSite($id2);
+ $access3 = API::getInstance()->getUsersAccessFromSite($id3);
$wanted1 = array('user1' => 'view', 'user2' => 'admin',);
$wanted2 = array('user1' => 'view', 'user2' => 'view');
$wanted3 = array('user2' => 'view');
@@ -767,8 +769,8 @@ class UsersManagerTest extends DatabaseTestCase
$this->assertEquals($wanted2, $access2);
$this->assertEquals($wanted3, $access3);
- $access1 = Piwik_UsersManager_API::getInstance()->getUsersSitesFromAccess('view');
- $access2 = Piwik_UsersManager_API::getInstance()->getUsersSitesFromAccess('admin');
+ $access1 = API::getInstance()->getUsersSitesFromAccess('view');
+ $access2 = API::getInstance()->getUsersSitesFromAccess('admin');
$wanted1 = array('user1' => array($id1, $id2), 'user2' => array($id2, $id3));
$wanted2 = array('user2' => array($id1));
@@ -776,15 +778,15 @@ class UsersManagerTest extends DatabaseTestCase
$this->assertEquals($wanted2, $access2);
// Test getUsersWithSiteAccess
- $users = Piwik_UsersManager_API::getInstance()->getUsersWithSiteAccess($id1, $access = 'view');
+ $users = API::getInstance()->getUsersWithSiteAccess($id1, $access = 'view');
$this->assertEquals(1, count($users));
$this->assertEquals('user1', $users[0]['login']);
- $users = Piwik_UsersManager_API::getInstance()->getUsersWithSiteAccess($id2, $access = 'view');
+ $users = API::getInstance()->getUsersWithSiteAccess($id2, $access = 'view');
$this->assertEquals(2, count($users));
- $users = Piwik_UsersManager_API::getInstance()->getUsersWithSiteAccess($id1, $access = 'admin');
+ $users = API::getInstance()->getUsersWithSiteAccess($id1, $access = 'admin');
$this->assertEquals(1, count($users));
$this->assertEquals('user2', $users[0]['login']);
- $users = Piwik_UsersManager_API::getInstance()->getUsersWithSiteAccess($id3, $access = 'admin');
+ $users = API::getInstance()->getUsersWithSiteAccess($id3, $access = 'admin');
$this->assertEquals(0, count($users));
}
@@ -796,15 +798,15 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testSetUserAccessMultipleCallOverwriteSingleUserOneSite()
{
- Piwik_UsersManager_API::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
+ API::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
- $id1 = Piwik_SitesManager_API::getInstance()->addSite("test1", array("http://piwik.net", "http://piwik.com/test/"));
- $id2 = Piwik_SitesManager_API::getInstance()->addSite("test2", array("http://piwik.net", "http://piwik.com/test/"));
+ $id1 = SitesManagerAPI::getInstance()->addSite("test1", array("http://piwik.net", "http://piwik.com/test/"));
+ $id2 = SitesManagerAPI::getInstance()->addSite("test2", array("http://piwik.net", "http://piwik.com/test/"));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user1", "view", array($id1, $id2));
- Piwik_UsersManager_API::getInstance()->setUserAccess("user1", "admin", array($id1));
+ API::getInstance()->setUserAccess("user1", "view", array($id1, $id2));
+ API::getInstance()->setUserAccess("user1", "admin", array($id1));
- $access1 = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("user1");
+ $access1 = API::getInstance()->getSitesAccessFromUser("user1");
$access1 = $this->_flatten($access1);
$wanted1 = array($id1 => 'admin', $id2 => 'view',);
@@ -820,7 +822,7 @@ class UsersManagerTest extends DatabaseTestCase
public function testGetSitesAccessFromUserWrongUser()
{
try {
- $access1 = Piwik_UsersManager_API::getInstance()->getSitesAccessFromUser("user1");
+ $access1 = API::getInstance()->getSitesAccessFromUser("user1");
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionUserDoesNotExist)", $expected->getMessage());
return;
@@ -837,7 +839,7 @@ class UsersManagerTest extends DatabaseTestCase
public function testGetUsersAccessFromSiteWrongSite()
{
try {
- $access1 = Piwik_UsersManager_API::getInstance()->getUsersAccessFromSite(1);
+ $access1 = API::getInstance()->getUsersAccessFromSite(1);
} catch (Exception $e) {
return;
}
@@ -853,7 +855,7 @@ class UsersManagerTest extends DatabaseTestCase
public function testGetUsersSitesFromAccessWrongSite()
{
try {
- $access1 = Piwik_UsersManager_API::getInstance()->getUsersSitesFromAccess('unknown');
+ $access1 = API::getInstance()->getUsersSitesFromAccess('unknown');
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionAccessValues)", $expected->getMessage());
return;
@@ -870,7 +872,7 @@ class UsersManagerTest extends DatabaseTestCase
public function testUpdateUserWrongLogin()
{
try {
- Piwik_UsersManager_API::getInstance()->updateUser("lolgin", "password");
+ API::getInstance()->updateUser("lolgin", "password");
} catch (Exception $expected) {
$this->assertRegExp("(UsersManager_ExceptionUserDoesNotExist)", $expected->getMessage());
return;
@@ -893,9 +895,9 @@ class UsersManagerTest extends DatabaseTestCase
'email' => "test@test.com",
'alias' => "alias");
- Piwik_UsersManager_API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
+ API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
- Piwik_UsersManager_API::getInstance()->updateUser($login, "passowordOK");
+ API::getInstance()->updateUser($login, "passowordOK");
$this->_checkUserHasNotChanged($user, "passowordOK");
}
@@ -914,9 +916,9 @@ class UsersManagerTest extends DatabaseTestCase
'email' => "test@test.com",
'alias' => "alias");
- Piwik_UsersManager_API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
+ API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
- Piwik_UsersManager_API::getInstance()->updateUser($login, "passowordOK", null, "newalias");
+ API::getInstance()->updateUser($login, "passowordOK", null, "newalias");
$this->_checkUserHasNotChanged($user, "passowordOK", null, "newalias");
}
@@ -935,9 +937,9 @@ class UsersManagerTest extends DatabaseTestCase
'email' => "test@test.com",
'alias' => "alias");
- Piwik_UsersManager_API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
+ API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
- Piwik_UsersManager_API::getInstance()->updateUser($login, "passowordOK", "email@geaga.com");
+ API::getInstance()->updateUser($login, "passowordOK", "email@geaga.com");
$this->_checkUserHasNotChanged($user, "passowordOK", "email@geaga.com");
}
@@ -986,9 +988,9 @@ class UsersManagerTest extends DatabaseTestCase
'email' => "test@test.com",
'alias' => "alias");
- Piwik_UsersManager_API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
+ API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
- Piwik_UsersManager_API::getInstance()->updateUser($login, "passowordOK", "email@geaga.com", "NEW ALIAS");
+ API::getInstance()->updateUser($login, "passowordOK", "email@geaga.com", "NEW ALIAS");
$this->_checkUserHasNotChanged($user, "passowordOK", "email@geaga.com", "NEW ALIAS");
}
@@ -1002,7 +1004,7 @@ class UsersManagerTest extends DatabaseTestCase
public function testGetUserByEmailInvalidMail()
{
try {
- $userByMail = Piwik_UsersManager_API::getInstance()->getUserByEmail('email@test.com');
+ $userByMail = API::getInstance()->getUserByEmail('email@test.com');
} catch (Exception $e) {
return;
}
@@ -1022,9 +1024,9 @@ class UsersManagerTest extends DatabaseTestCase
'email' => "test@test.com",
'alias' => "alias");
- Piwik_UsersManager_API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
+ API::getInstance()->addUser($user['login'], $user['password'], $user['email'], $user['alias']);
- $userByMail = Piwik_UsersManager_API::getInstance()->getUserByEmail($user['email']);
+ $userByMail = API::getInstance()->getUserByEmail($user['email']);
$this->assertEquals($user['login'], $userByMail['login']);
$this->assertEquals($user['email'], $userByMail['email']);
@@ -1037,12 +1039,12 @@ class UsersManagerTest extends DatabaseTestCase
*/
public function testGetUserPreferenceDefault()
{
- $defaultReportPref = Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT;
- $defaultReportDatePref = Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT_DATE;
+ $defaultReportPref = API::PREFERENCE_DEFAULT_REPORT;
+ $defaultReportDatePref = API::PREFERENCE_DEFAULT_REPORT_DATE;
$this->assertEquals(1,
- Piwik_UsersManager_API::getInstance()->getUserPreference('someUser', $defaultReportPref));
+ API::getInstance()->getUserPreference('someUser', $defaultReportPref));
$this->assertEquals('yesterday',
- Piwik_UsersManager_API::getInstance()->getUserPreference('someUser', $defaultReportDatePref));
+ API::getInstance()->getUserPreference('someUser', $defaultReportDatePref));
}
}
diff --git a/tests/PHPUnit/UI/UIIntegrationTest.php b/tests/PHPUnit/UI/UIIntegrationTest.php
index 4571227247..7d63301b8e 100644
--- a/tests/PHPUnit/UI/UIIntegrationTest.php
+++ b/tests/PHPUnit/UI/UIIntegrationTest.php
@@ -8,6 +8,7 @@
use Piwik\Piwik;
use Piwik\Access;
use Piwik\AssetManager;
+use Piwik\Plugins\VisitsSummary\API;
/**
* Tests UI code by grabbing screenshots of webpages and comparing with expected files.
@@ -46,7 +47,7 @@ class Test_Piwik_Integration_UIIntegrationTest extends IntegrationTestCase
AssetManager::removeMergedAssets();
// launch archiving so tests don't run out of time
- Piwik_VisitsSummary_API::getInstance()->get(self::$fixture->idSite, 'year', '2012-08-09');
+ API::getInstance()->get(self::$fixture->idSite, 'year', '2012-08-09');
}
public static function tearDownAfterClass()
@@ -264,4 +265,4 @@ class Test_Piwik_Integration_UIIntegrationTest extends IntegrationTestCase
}
}
-Test_Piwik_Integration_UIIntegrationTest::$fixture = new Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts(); \ No newline at end of file
+Test_Piwik_Integration_UIIntegrationTest::$fixture = new Test_Piwik_Fixture_ManySitesImportedLogsWithXssAttempts();
diff --git a/tests/PHPUnit/proxy/piwik.php b/tests/PHPUnit/proxy/piwik.php
index 2a72cfbd88..977a490394 100755
--- a/tests/PHPUnit/proxy/piwik.php
+++ b/tests/PHPUnit/proxy/piwik.php
@@ -14,6 +14,7 @@
use Piwik\Config;
use Piwik\DataTable\Manager;
use Piwik\Option;
+use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
use Piwik\Tracker;
use Piwik\Site;
use Piwik\Tracker\Cache;
@@ -39,7 +40,7 @@ try {
}
$trackerPlugins[] = 'DevicesDetection';
Config::getInstance()->Plugins_Tracker['Plugins_Tracker'] = $trackerPlugins;
-Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
+GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
Tracker::setTestEnvironment();
Manager::getInstance()->deleteAll();