1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
detector.php
См. документацию.
1
<?php
2
9
10
namespace
Bitrix\Main\Web\UserAgent;
11
12
class
Detector
implements
DetectorInterface
13
{
17
public
function
detectBrowser
(?
string
$userAgent):
Browser
18
{
19
$browser = $this->
getKnownAgent
($userAgent);
20
21
if
($browser ===
null
)
22
{
23
if
(ini_get(
'browscap'
) !=
''
)
24
{
25
$info
= get_browser($userAgent);
26
27
if
(
$info
)
28
{
29
$deviceType = $this->
getDeviceType
(
$info
);
30
$browser =
new
Browser
(
$info
->browser,
$info
->platform, $deviceType);
31
}
32
}
33
}
34
35
if
($browser ===
null
)
36
{
37
$browser =
new
Browser
();
38
}
39
40
$browser->setUserAgent($userAgent);
41
42
return
$browser;
43
}
44
45
protected
function
getKnownAgent
(?
string
$userAgent)
46
{
47
if
($userAgent !==
null
)
48
{
49
if
(str_contains($userAgent,
'Bitrix24.Disk'
))
50
{
51
if
(str_contains($userAgent,
'Windows'
))
52
{
53
$platform
=
'Windows'
;
54
}
55
elseif
(str_contains($userAgent,
'Linux'
))
56
{
57
$platform
=
'Linux'
;
58
}
59
else
60
{
61
$platform
=
'macOS'
;
62
}
63
64
return
new
Browser
(
'Bitrix24.Disk'
,
$platform
,
DeviceType::DESKTOP
);
65
}
66
67
if
(str_contains($userAgent,
'BitrixDesktop'
))
68
{
69
if
(str_contains($userAgent,
'Windows'
))
70
{
71
$platform
=
'Windows'
;
72
}
73
elseif
(str_contains($userAgent,
'Mac OS'
))
74
{
75
$platform
=
'macOS'
;
76
}
77
else
78
{
79
$platform
=
'Linux'
;
80
}
81
82
return
new
Browser
(
'Bitrix24.Desktop'
,
$platform
,
DeviceType::DESKTOP
);
83
}
84
85
if
(str_contains($userAgent,
'BitrixMobile'
) || str_contains($userAgent,
'Bitrix24/'
))
86
{
87
if
(str_contains($userAgent,
'iPhone'
) || str_contains($userAgent,
'iPad'
) || str_contains($userAgent,
'Darwin'
))
88
{
89
$device = (str_contains($userAgent,
'iPad'
) ?
DeviceType::TABLET
:
DeviceType::MOBILE_PHONE
);
90
return
new
Browser
(
'Bitrix24.Mobile'
,
'iOS'
, $device);
91
}
92
93
$device = (str_contains($userAgent,
'Tablet'
) ?
DeviceType::TABLET
:
DeviceType::MOBILE_PHONE
);
94
return
new
Browser
(
'Bitrix24.Mobile'
,
'Android'
, $device);
95
}
96
97
if
(str_contains($userAgent,
'CardDavBitrix24'
))
98
{
99
return
new
Browser
(
'Bitrix24.DAV'
,
'Android'
,
DeviceType::MOBILE_PHONE
);
100
}
101
}
102
return
null
;
103
}
104
105
protected
function
getDeviceType
(
$info
)
106
{
107
if
(
$info
->istablet)
108
{
109
$deviceType =
DeviceType::TABLET
;
110
}
111
elseif
(
$info
->ismobiledevice)
112
{
113
$deviceType =
DeviceType::MOBILE_PHONE
;
114
}
115
elseif
(
$info
->device_type ==
'TV Device'
)
116
{
117
$deviceType =
DeviceType::TV
;
118
}
119
elseif
(
$info
->device_type ==
'Desktop'
)
120
{
121
$deviceType =
DeviceType::DESKTOP
;
122
}
123
else
124
{
125
$deviceType =
DeviceType::UNKNOWN
;
126
}
127
128
return
$deviceType;
129
}
130
}
Bitrix\Main\Web\UserAgent\Browser
Определения
browser.php:16
Bitrix\Main\Web\UserAgent\Detector
Определения
detector.php:13
Bitrix\Main\Web\UserAgent\Detector\getKnownAgent
getKnownAgent(?string $userAgent)
Определения
detector.php:45
Bitrix\Main\Web\UserAgent\Detector\getDeviceType
getDeviceType($info)
Определения
detector.php:105
Bitrix\Main\Web\UserAgent\Detector\detectBrowser
detectBrowser(?string $userAgent)
Определения
detector.php:17
Bitrix\Main\Web\UserAgent\DeviceType\MOBILE_PHONE
const MOBILE_PHONE
Определения
devicetype.php:18
Bitrix\Main\Web\UserAgent\DeviceType\DESKTOP
const DESKTOP
Определения
devicetype.php:17
Bitrix\Main\Web\UserAgent\DeviceType\TV
const TV
Определения
devicetype.php:20
Bitrix\Main\Web\UserAgent\DeviceType\TABLET
const TABLET
Определения
devicetype.php:19
Bitrix\Main\Web\UserAgent\DeviceType\UNKNOWN
const UNKNOWN
Определения
devicetype.php:16
Bitrix\Main\Web\UserAgent\DetectorInterface
Определения
detectorinterface.php:13
$info
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
Определения
backup.php:924
$platform
$platform
Определения
settings.php:7
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
bitrix
modules
main
lib
web
useragent
detector.php
Создано системой
1.14.0