-
Notifications
You must be signed in to change notification settings - Fork 1
/
API.php
139 lines (135 loc) · 5.22 KB
/
API.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
* @version $Id: API.php 2967 2010-09-21 21:26:01 terawurfl $
*
* @category Piwik_Plugins
* @package Piwik_MobileAnalytics
*/
/**
*
* @package Piwik_MobileAnalytics
*/
class Piwik_MobileAnalytics_API{
static private $instance = null;
static public function getInstance(){
if (self::$instance == null){
$c = __CLASS__;
self::$instance = new $c();
}
return self::$instance;
}
// Devices by Model Name
public function getDeviceName( $idSite, $period, $date ){
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
$dataTable = $archive->getDataTable('MobileAnalytics_mobileDevices');
$dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
}
// Devices by Brand Name
public function getDeviceBrand( $idSite, $period, $date ){
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
$dataTable = $archive->getDataTable('MobileAnalytics_mobileBrands');
$dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
}
// Devices by Browser
public function getDeviceBrowser( $idSite, $period, $date ){
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
$dataTable = $archive->getDataTable('MobileAnalytics_mobileBrowser');
$dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
}
// Devices by Resolution
public function getDeviceResolution( $idSite, $period, $date ){
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
$dataTable = $archive->getDataTable('MobileAnalytics_mobileResolution');
$dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
}
// Devices by JavaScript Support
public function getDeviceJS( $idSite, $period, $date ){
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
$dataTable = $archive->getDataTable('MobileAnalytics_mobileJS');
$dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS));
$dataTable->queueFilter('ColumnCallbackReplace', array('label', array('Piwik_MobileAnalytics_API','labelBoolSupported')));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
}
// Devices by Flash Support
public function getDeviceFlash( $idSite, $period, $date ){
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
$dataTable = $archive->getDataTable('MobileAnalytics_mobileFlash');
$dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
}
// Devices by OS
public function getDeviceOS( $idSite, $period, $date ){
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
$dataTable = $archive->getDataTable('MobileAnalytics_mobileOS');
$dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
}
// Devices by AJAX Support
public function getDeviceAJAX( $idSite, $period, $date ){
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
$dataTable = $archive->getDataTable('MobileAnalytics_mobileAJAX');
$dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS));
$dataTable->queueFilter('ColumnCallbackReplace', array('label', array('Piwik_MobileAnalytics_API','labelBoolSupported')));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
}
// Mobile vs. Non-Mobile
public function getDeviceMobile( $idSite, $period, $date ){
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
$dataTable = $archive->getDataTable('MobileAnalytics_mobile');
$dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS));
$dataTable->queueFilter('ColumnCallbackReplace', array('label', array('Piwik_MobileAnalytics_API','mobileLabel')));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
}
// Callbacks
public static function mobileLabel($in){
switch($in){
case "0":
return "Desktop";
break;
case "1":
return "Mobile";
break;
default:
return "Unknown";
break;
}
}
public static function labelBoolSupported($in){
return ($in)? "Supported": "Unsupported";
}
}