blob: 260e45c03bcfad9c56afa9c4075db2984ac51985 (
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
|
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
class MockLocationProvider extends Piwik_UserCountry_LocationProvider
{
private $locations = array();
private $currentLocation = 0;
private $ipToLocations = array();
public function setLocations( $locations )
{
$this->locations = $locations;
}
public function getLocation( $info )
{
$ip = $info['ip'];
if (isset($this->ipToLocations[$ip]))
{
$result = $this->ipToLocations[$ip];
}
else
{
$result = $this->locations[$this->currentLocation];
$this->currentLocation = ($this->currentLocation + 1) % count($this->locations);
$this->ipToLocations[$ip] = $result;
}
$this->completeLocationResult($result);
return $result;
}
public function getInfo()
{
return array('id' => 'mock_provider', 'title' => 'mock provider', 'description' => 'mock provider');
}
public function isAvailable()
{
return true;
}
public function isWorking()
{
return true;
}
public function getSupportedLocationInfo()
{
return array(); // unimplemented
}
}
|