1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
yacounter.php
См. документацию.
1<?php
2namespace Bitrix\Landing\Hook\Page;
3
4use \Bitrix\Landing\Field;
5use \Bitrix\Main\Localization\Loc;
6use \Bitrix\Landing\Manager;
7
8Loc::loadMessages(__FILE__);
9
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 {
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 {
110 $counter = \CUtil::jsEscape($counter);
111 if (!$counter)
112 {
113 return;
114 }
115
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();
120 for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
121 k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
122 (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
123 ym(\'' . $counter . '\', "init", {
124 clickmap:true,
125 trackLinks:true,
126 accurateTrackBounce:true,
127 webvisor:true,
128 trackHash:true,
129 ecommerce:"dataLayer"
130 });'
131 );
132 Manager::setPageView(
133 'Noscript',
134 '<noscript>
135 <div><img src="https://mc.yandex.ru/watch/' . $counter . '" style="position:absolute; left:-9999px;" alt="" /></div>
136 </noscript>'
137 );
138 }
139}
static getHelpUrl(string $code)
Определения help.php:174
static addCookieScript(string $cookieCode, string $functionBody)
Определения cookies.php:167
static setCounter(string $counter)
Определения yacounter.php:107
issetCustomExec()
Определения page.php:253
execCustom()
Определения page.php:262
static isAllowed(string $code, array $params=[], string $cacheSalt='')
Определения manager.php:214
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
Определения checkbox.php:2
Определения base32.php:2
$counter
Определения options.php:5
font style
Определения invoice.php:442