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

API.php « VisitsSummary « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: baf3945a870bf53c242cfb46171d6b1ef6e2073a (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
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
<?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$
 * 
 * @package Piwik_VisitsSummary
 */


/**
 * 
 * @package Piwik_VisitsSummary
 */
class Piwik_VisitsSummary_API extends Piwik_Apiable
{
	static private $instance = null;
	protected function __construct()
	{
		parent::__construct();
	}
	
	static public function getInstance()
	{
		if (self::$instance == null)
		{            
			$c = __CLASS__;
			self::$instance = new $c();
		}
		return self::$instance;
	}
	
	public function get( $idSite, $period, $date )
	{
		Piwik::checkUserHasViewAccess( $idSite );
		$archive = Piwik_Archive::build($idSite, $period, $date );
	
		$toFetch = array( 	'max_actions',
						'nb_uniq_visitors', 
						'nb_visits',
						'nb_actions', 
						'sum_visit_length',
						'bounce_count',
					);
		$dataTable = $archive->getDataTableFromNumeric($toFetch);

		return $dataTable;
	}
	protected function getNumeric( $idSite, $period, $date, $toFetch )
	{
		Piwik::checkUserHasViewAccess( $idSite );
		$archive = Piwik_Archive::build($idSite, $period, $date );
		$dataTable = $archive->getNumeric($toFetch);
		return $dataTable;		
	}

	public function getVisits( $idSite, $period, $date )
	{
		return $this->getNumeric( $idSite, $period, $date, 'nb_visits');
	}
	public function getUniqueVisitors( $idSite, $period, $date )
	{
		return $this->getNumeric( $idSite, $period, $date, 'nb_uniq_visitors');
	}
	public function getActions( $idSite, $period, $date )
	{
		return $this->getNumeric( $idSite, $period, $date, 'nb_actions');
	}
	public function getMaxActions( $idSite, $period, $date )
	{
		return $this->getNumeric( $idSite, $period, $date, 'max_actions');
	}
	public function getSumVisitsLength( $idSite, $period, $date )
	{
		return $this->getNumeric( $idSite, $period, $date, 'sum_visit_length');
	}
	public function getBounceCount( $idSite, $period, $date )
	{
		return $this->getNumeric( $idSite, $period, $date, 'bounce_count');
	}
	
}