Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
yacounter.php
1
<?php
2
namespace
Bitrix\Landing\Hook\Page
;
3
4
use \Bitrix\Landing\Field;
5
use \Bitrix\Main\Localization\Loc;
6
use \Bitrix\Landing\Manager;
7
8
Loc::loadMessages
(__FILE__);
9
10
class
YaCounter
extends
\Bitrix\Landing\Hook\Page
11
{
16
protected
function
getMap
()
17
{
18
$helpUrl = \Bitrix\Landing\Help::getHelpUrl(
'YACOUNTER'
);
19
return
array(
20
'USE'
=>
new
Field
\
Checkbox
(
'USE'
, array(
21
'title'
=>
Loc::getMessage
(
'LANDING_HOOK_YACOUNTER_USE'
)
22
)),
23
'COUNTER'
=>
new
Field
\
Text
(
'COUNTER'
, array(
24
'title'
=>
Loc::getMessage
(
'LANDING_HOOK_YACOUNTER_COUNTER'
),
25
'placeholder'
=>
Loc::getMessage
(
'LANDING_HOOK_YACOUNTER_PLACEHOLDER'
),
26
'help'
=> $helpUrl
27
?
'<a href="'
. $helpUrl .
'" target="_blank">'
.
28
Loc::getMessage
(
'LANDING_HOOK_DETAIL_HELP'
) .
29
'</a>'
30
:
''
31
))
32
);
33
}
34
39
public
function
isFree
()
40
{
41
return
false
;
42
}
43
48
public
function
isLocked
()
49
{
50
return
!\Bitrix\Landing\Restriction\Manager::isAllowed(
51
'limit_sites_google_analytics'
52
);
53
}
54
59
public
function
enabled
()
60
{
61
if
($this->
isLocked
())
62
{
63
return
false
;
64
}
65
66
if
($this->
issetCustomExec
())
67
{
68
return
true
;
69
}
70
71
return
$this->fields[
'USE'
]->getValue() ==
'Y'
;
72
}
73
78
public
function
enabledInEditMode
()
79
{
80
return
false
;
81
}
82
87
public
function
exec
()
88
{
89
if
($this->
execCustom
())
90
{
91
return
;
92
}
93
94
if
($this->fields[
'USE'
]->getValue() !=
'Y'
)
95
{
96
return
;
97
}
98
99
$this->
setCounter
($this->fields[
'COUNTER'
]);
100
}
101
107
public
static
function
setCounter
(
string
$counter): void
108
{
109
$counter = \htmlspecialcharsbx(trim($counter));
110
$counter = \CUtil::jsEscape($counter);
111
if
(!$counter)
112
{
113
return
;
114
}
115
116
Cookies::addCookieScript
(
117
'ym'
,
118
'(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
119
m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
120
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
121
ym(\''
. $counter .
'\'
,
"init"
, {
122
id:\
''
. $counter .
'\'
,
123
clickmap:
true
,
124
trackLinks:
true
,
125
accurateTrackBounce:
true
,
126
webvisor:
true
,
127
trackHash:
true
128
});
'
129
);
130
Manager::setPageView(
131
'
Noscript
',
132
'
<noscript>
133
<img src=
"https://mc.yandex.ru/watch/' . $counter . '"
style=
"position:absolute; left:-9999px;"
alt=
""
/>
134
</noscript>
'
135
);
136
}
137
}
Bitrix\Landing\Field\Checkbox
Definition
checkbox.php:5
Bitrix\Landing\Field\Text
Definition
text.php:5
Bitrix\Landing\Field
Definition
field.php:5
Bitrix\Landing\Hook\Page\Cookies\addCookieScript
static addCookieScript(string $cookieCode, string $functionBody)
Definition
cookies.php:167
Bitrix\Landing\Hook\Page\YaCounter
Definition
yacounter.php:11
Bitrix\Landing\Hook\Page\YaCounter\isLocked
isLocked()
Definition
yacounter.php:48
Bitrix\Landing\Hook\Page\YaCounter\setCounter
static setCounter(string $counter)
Definition
yacounter.php:107
Bitrix\Landing\Hook\Page\YaCounter\getMap
getMap()
Definition
yacounter.php:16
Bitrix\Landing\Hook\Page\YaCounter\enabledInEditMode
enabledInEditMode()
Definition
yacounter.php:78
Bitrix\Landing\Hook\Page\YaCounter\enabled
enabled()
Definition
yacounter.php:59
Bitrix\Landing\Hook\Page\YaCounter\exec
exec()
Definition
yacounter.php:87
Bitrix\Landing\Hook\Page\YaCounter\isFree
isFree()
Definition
yacounter.php:39
Bitrix\Landing\Hook\Page
Definition
page.php:7
Bitrix\Landing\Hook\Page\issetCustomExec
issetCustomExec()
Definition
page.php:253
Bitrix\Landing\Hook\Page\execCustom
execCustom()
Definition
page.php:262
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\Landing\Hook\Page
Definition
b24button.php:2
modules
landing
lib
hook
page
yacounter.php
Создано системой
1.10.0