Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
sitespeed.php
1
<?php
2
namespace
Bitrix\Main\Analytics
;
3
4
use
Bitrix\Main\Application
;
5
use
Bitrix\Main\IO\Directory
;
6
use
Bitrix\Main\Localization\Loc
;
7
use
Bitrix\Main\Config\Configuration
;
8
use
Bitrix\Main\Config\Option
;
9
use
Bitrix\Main\ModuleManager
;
10
11
Loc::loadMessages
(__FILE__);
12
13
class
SiteSpeed
14
{
15
public
static
function
onBuildGlobalMenu
(&$arGlobalMenu, &$arModuleMenu)
16
{
17
$siteSpeedItem = array(
18
"text"
=>
Loc::getMessage
(
"MAIN_ANALYTICS_MENU_SITE_SPEED"
),
19
"url"
=>
"site_speed.php?lang="
.LANGUAGE_ID,
20
"more_url"
=> array(
"site_speed.php"
),
21
"title"
=>
Loc::getMessage
(
"MAIN_ANALYTICS_MENU_SITE_SPEED_ALT"
),
22
);
23
24
$found =
false
;
25
foreach
($arModuleMenu as &$arMenuItem)
26
{
27
if
(!isset($arMenuItem[
"items_id"
]) || $arMenuItem[
"items_id"
] !==
"menu_perfmon"
)
28
{
29
continue
;
30
}
31
32
if
(isset($arMenuItem[
"items"
]) && is_array($arMenuItem[
"items"
]))
33
{
34
array_unshift($arMenuItem[
"items"
], $siteSpeedItem);
35
}
36
else
37
{
38
$arMenuItem[
"items"
] = array($siteSpeedItem);
39
}
40
41
$found =
true
;
42
break
;
43
}
44
45
if
(!$found)
46
{
47
$arModuleMenu[] = array(
48
"parent_menu"
=>
"global_menu_settings"
,
49
"section"
=>
"perfmon"
,
50
"sort"
=> 1850,
51
"text"
=>
Loc::getMessage
(
"MAIN_ANALYTICS_MENU_PERFORMANCE"
),
52
"title"
=>
Loc::getMessage
(
"MAIN_ANALYTICS_MENU_PERFORMANCE"
),
53
"icon"
=>
"perfmon_menu_icon"
,
54
"page_icon"
=>
"perfmon_page_icon"
,
55
"items_id"
=>
"menu_perfmon"
,
56
"items"
=> array($siteSpeedItem),
57
);
58
}
59
}
60
64
public
static
function
isRussianSiteManager
()
65
{
66
return
(
67
Directory::isDirectoryExists
(
Application::getDocumentRoot
().
"/bitrix/modules/main/lang/ru"
)
68
||
Directory::isDirectoryExists
(
Application::getDocumentRoot
().
"/bitrix/modules/main/lang/ua"
)
69
);
70
}
71
81
public
static
function
isIntranetSite
($siteId)
82
{
83
if
(defined(
"ADMIN_SECTION"
) && ADMIN_SECTION ===
true
)
84
{
85
return
false
;
86
}
87
88
$portalSiteList = [];
89
$siteList = \Bitrix\Main\SiteTable::getList([
90
"select"
=> [
"LID"
],
91
"cache"
=> [
"ttl"
=> 86400],
92
])->fetchAll();
93
foreach
($siteList as $site)
94
{
95
if
(Option::get(
"main"
,
"wizard_firstportal_"
.$site[
"LID"
],
false
, $site[
"LID"
]) !==
false
)
96
{
97
$portalSiteList[] = $site[
"LID"
];
98
}
99
else
if
(Option::get(
"main"
,
"wizard_firstbitrix24_"
.$site[
"LID"
],
false
, $site[
"LID"
]) !==
false
)
100
{
101
$portalSiteList[] = $site[
"LID"
];
102
}
103
}
104
105
if
($extranetSiteId = Option::get(
"extranet"
,
"extranet_site"
,
false
))
106
{
107
$portalSiteList[] = $extranetSiteId;
108
}
109
110
return
in_array($siteId, $portalSiteList);
111
}
112
113
public
static
function
canGatherStat
()
114
{
115
$enabled = !
Application::getInstance
()->getLicense()->isDemoKey();
116
if
($enabled)
117
{
118
$settings = Configuration::getValue(
"analytics_counter"
);
119
if
(isset($settings[
"enabled"
]) && $settings[
"enabled"
] ===
false
)
120
{
121
$enabled =
false
;
122
}
123
}
124
return
$enabled;
125
}
126
127
public
static
function
isOn
()
128
{
129
return
self::isRussianSiteManager
() &&
self::canGatherStat
();
130
}
131
}
Bitrix\Main\Analytics\SiteSpeed
Definition
sitespeed.php:14
Bitrix\Main\Analytics\SiteSpeed\isIntranetSite
static isIntranetSite($siteId)
Definition
sitespeed.php:81
Bitrix\Main\Analytics\SiteSpeed\isOn
static isOn()
Definition
sitespeed.php:127
Bitrix\Main\Analytics\SiteSpeed\canGatherStat
static canGatherStat()
Definition
sitespeed.php:113
Bitrix\Main\Analytics\SiteSpeed\onBuildGlobalMenu
static onBuildGlobalMenu(&$arGlobalMenu, &$arModuleMenu)
Definition
sitespeed.php:15
Bitrix\Main\Analytics\SiteSpeed\isRussianSiteManager
static isRussianSiteManager()
Definition
sitespeed.php:64
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getDocumentRoot
static getDocumentRoot()
Definition
application.php:717
Bitrix\Main\Application\getInstance
static getInstance()
Definition
application.php:95
Bitrix\Main\Config\Configuration
Definition
configuration.php:7
Bitrix\Main\Config\Option
Definition
option.php:15
Bitrix\Main\IO\Directory
Definition
directory.php:6
Bitrix\Main\IO\Directory\isDirectoryExists
static isDirectoryExists($path)
Definition
directory.php:162
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ModuleManager
Definition
modulemanager.php:5
Bitrix\Main\Analytics
Definition
analyticsevent.php:5
modules
main
lib
analytics
sitespeed.php
Создано системой
1.10.0