blob: 603a8dfc94324fb06842bdf950c042fc5d70085e (
plain)
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
|
<?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_Provider
*/
/**
* @see plugins/Provider/functions.php
*/
require_once PIWIK_INCLUDE_PATH . '/plugins/Provider/functions.php';
/**
* The Provider API lets you access reports for your visitors Internet Providers.
*
* @package Piwik_Provider
*/
class Piwik_Provider_API
{
static private $instance = null;
static public function getInstance()
{
if (self::$instance == null) {
self::$instance = new self;
}
return self::$instance;
}
public function getProvider($idSite, $period, $date, $segment = false)
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Piwik_Archive::build($idSite, $period, $date, $segment);
$dataTable = $archive->getDataTable('Provider_hostnameExt');
$dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS));
$dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_getHostnameUrl'));
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_Provider_getPrettyProviderName'));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
}
}
|