blob: a582bffed0551eb7fd458aa1f2ca176502d65507 (
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
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
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\DevicesDetection;
use DeviceDetector\DeviceDetector;
use Piwik\Common;
use Piwik\Db;
use Piwik\Piwik;
use Piwik\Plugin\ControllerAdmin;
use Piwik\Plugin\Report;
use Piwik\View;
class Controller extends \Piwik\Plugin\Controller
{
public function detection()
{
Piwik::checkUserHasSomeAdminAccess();
$view = new View('@DevicesDetection/detection');
$this->setBasicVariablesView($view);
ControllerAdmin::setBasicVariablesAdminView($view);
$userAgent = Common::getRequestVar('ua', $_SERVER['HTTP_USER_AGENT'], 'string');
$uaParser = new DeviceDetector($userAgent);
$uaParser->parse();
$view->userAgent = $userAgent;
$view->bot_info = $uaParser->getBot();
$view->browser_name = $uaParser->getClient('name');
$view->browser_short_name = $uaParser->getClient('short_name');
$view->browser_version = $uaParser->getClient('version');
$view->browser_logo = getBrowserLogo($uaParser->getClient('short_name'));
$view->browser_family = \DeviceDetector\Parser\Client\Browser::getBrowserFamily($uaParser->getClient('short_name'));
$view->browser_family_logo = getBrowserFamilyLogo($view->browser_family);
$view->os_name = $uaParser->getOs('name');
$view->os_logo = getOsLogo($uaParser->getOs('short_name'));
$view->os_short_name = $uaParser->getOs('short_name');
$view->os_family = \DeviceDetector\Parser\OperatingSystem::getOsFamily($uaParser->getOs('short_name'));
$view->os_family_logo = getOsFamilyLogo($view->os_family);
$view->os_version = $uaParser->getOs('version');
$view->device_type = getDeviceTypeLabel($uaParser->getDeviceName());
$view->device_type_logo = getDeviceTypeLogo($uaParser->getDeviceName());
$view->device_model = $uaParser->getModel();
$view->device_brand = getDeviceBrandLabel($uaParser->getBrand());
$view->device_brand_logo = getBrandLogo($view->device_brand);
return $view->render();
}
public function showList()
{
Piwik::checkUserHasSomeAdminAccess();
$view = new View('@DevicesDetection/list');
$type = Common::getRequestVar('type', 'brands', 'string');
$list = array();
switch ($type) {
case 'brands':
$availableBrands = \DeviceDetector\Parser\Device\DeviceParserAbstract::$deviceBrands;
foreach ($availableBrands as $short => $name) {
if ($name != 'Unknown') {
$list[$name] = getBrandLogo($name);
}
}
break;
case 'browsers':
$availableBrowsers = \DeviceDetector\Parser\Client\Browser::getAvailableBrowsers();
foreach ($availableBrowsers as $short => $name) {
$list[$name] = getBrowserLogo($short);
}
break;
case 'browserfamilies':
$availableBrowserFamilies = \DeviceDetector\Parser\Client\Browser::getAvailableBrowserFamilies();
foreach ($availableBrowserFamilies as $name => $browsers) {
$list[$name] = getBrowserFamilyLogo($name);
}
break;
case 'os':
$availableOSs = \DeviceDetector\Parser\OperatingSystem::getAvailableOperatingSystems();
foreach ($availableOSs as $short => $name) {
$list[$name] = getOsLogo($short);
}
break;
case 'osfamilies':
$osFamilies = \DeviceDetector\Parser\OperatingSystem::getAvailableOperatingSystemFamilies();
foreach ($osFamilies as $name => $oss) {
$list[$name] = getOsFamilyLogo($name);
}
break;
case 'devicetypes':
$deviceTypes = \DeviceDetector\Parser\Device\DeviceParserAbstract::getAvailableDeviceTypes();
foreach ($deviceTypes as $name => $id) {
$list[$name] = getDeviceTypeLogo($name);
}
break;
}
$view->itemList = $list;
return $view->render();
}
}
|