1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
pixelfb.php
См. документацию.
1
<?php
2
namespace
Bitrix\Landing\Hook\Page;
3
4
use \Bitrix\Seo\BusinessSuite\ExtensionFacade;
5
use \Bitrix\Main\Loader;
6
use \Bitrix\Main\Localization\Loc;
7
use \Bitrix\Main\Config\Option;
8
use \Bitrix\Landing\Field;
9
use \Bitrix\Landing\Manager;
10
11
Loc::loadMessages(__FILE__);
12
13
class
PixelFb
extends
\Bitrix\Landing\Hook\Page
14
{
19
protected
function
getMap
()
20
{
21
$helpUrl =
\Bitrix\Landing\Help::getHelpUrl
(
'PIXEL'
);
22
return
array
(
23
'USE'
=>
new
Field
\
Checkbox
(
'USE'
,
array
(
24
'title'
=> Loc::getMessage(
'LANDING_HOOK_PIXEL_FB_USE'
)
25
)),
26
'COUNTER'
=>
new
Field
\
Text
(
'COUNTER'
,
array
(
27
'title'
=> Loc::getMessage(
'LANDING_HOOK_PIXEL_FB_COUNTER'
),
28
'placeholder'
=> Loc::getMessage(
'LANDING_HOOK_PIXEL_FB_PLACEHOLDER2'
),
29
'help'
=> $helpUrl
30
?
'<a href="'
. $helpUrl .
'" target="_blank">'
.
31
Loc::getMessage(
'LANDING_HOOK_PIXEL_FB_HELP'
) .
32
'</a>'
33
:
''
34
))
35
);
36
}
37
42
public
function
enabledInEditMode
()
43
{
44
return
false
;
45
}
46
51
public
function
enabled
()
52
{
53
if
($this->
issetCustomExec
())
54
{
55
return
true
;
56
}
57
58
if
(!$this->
isPage
() &&
Manager::isB24
())
59
{
60
return
true
;
61
}
62
63
return
$this->fields[
'USE'
]->getValue() ==
'Y'
;
64
}
65
70
private
static
function
getBusinessPixelFromSeo(): ?string
71
{
72
if
(\
Bitrix
\
Main
\Loader::includeModule(
'seo'
))
73
{
74
$businessSuite =
ExtensionFacade::getInstance
();
75
if
($businessSuite->isInstalled())
76
{
77
return
$businessSuite->getCurrentInstalls()->getPixel();
78
}
79
}
80
81
return
null
;
82
}
83
88
private
function
getBusinessPixel(): ?string
89
{
90
$pixelStored =
Manager::getOption
(
'business_pixel'
);
91
if
($pixelStored ===
null
)
92
{
93
$pixelStored = $this->getBusinessPixelFromSeo();
94
Manager::setOption
(
'business_pixel'
, $pixelStored);
95
}
96
97
return
$pixelStored;
98
}
99
104
public
static
function
changeBusinessPixel
(): void
105
{
106
if
(self::getBusinessPixelFromSeo() !==
Manager::getOption
(
'business_pixel'
))
107
{
108
Option::delete(
'landing'
, [
'name'
=>
'business_pixel'
]);
109
Manager::clearCache
();
110
}
111
}
112
117
public
function
exec
()
118
{
119
if
($this->
execCustom
())
120
{
121
return
;
122
}
123
124
$zone =
''
;
125
if
(Loader::includeModule(
'bitrix24'
))
126
{
127
$zone = \CBitrix24::getPortalZone();
128
}
129
elseif
(file_exists(
$_SERVER
[
"DOCUMENT_ROOT"
].
"/bitrix/modules/main/lang/ru"
)
130
&& !file_exists(
$_SERVER
[
"DOCUMENT_ROOT"
].
"/bitrix/modules/main/lang/ua"
))
131
{
132
$zone =
'ru'
;
133
}
134
if
($zone ===
'ru'
)
135
{
136
return
;
137
}
138
139
$counter
=
null
;
140
$businessPixel = $this->getBusinessPixel();
141
142
if
($this->fields[
'USE'
]->getValue() ===
'Y'
)
143
{
144
$counter
=
\htmlspecialcharsbx
(trim($this->fields[
'COUNTER'
]));
145
$counter
= \CUtil::jsEscape(
$counter
);
146
}
147
148
if
(!
$counter
||
$counter
=== $businessPixel)
149
{
150
$counter
= $businessPixel;
151
$businessPixel =
null
;
152
}
153
154
if
(
$counter
)
155
{
156
Cookies::addCookieScript
(
157
'fbp'
,
158
'!function(f,b,e,v,n,t,s)
159
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
160
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
161
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version=\'2.0\';n.agent=\'plbitrix\';
162
n.queue=[];t=b.createElement(e);t.async=!0;
163
t.src=v;s=b.getElementsByTagName(e)[0];
164
s.parentNode.insertBefore(t,s)}(window, document,\'script\',
165
\'https://connect.facebook.net/en_US/fbevents.js\');
166
fbq(\'init\', \''
.
$counter
.
'\'
);
167
fbq(\
'track\', \'PageView\');'
.
168
($businessPixel
169
?
"\n fbq('init', '{$businessPixel}');"
.
170
"\n fbq('track', 'PageView');"
171
:
''
)
172
);
173
Manager::setPageView
(
174
'Noscript'
,
175
'<noscript>
176
<img height="1" width="1" style="display:none" alt="" src="https://www.facebook.com/tr?id='
.
$counter
.
'&ev=PageView&noscript=1"/>
177
</noscript>'
178
);
179
}
180
}
181
}
Bitrix\Landing\Field\Checkbox
Определения
checkbox.php:5
Bitrix\Landing\Help\getHelpUrl
static getHelpUrl(string $code)
Определения
help.php:174
Bitrix\Landing\Hook\Page\Cookies\addCookieScript
static addCookieScript(string $cookieCode, string $functionBody)
Определения
cookies.php:167
Bitrix\Landing\Hook\Page\PixelFb
Определения
pixelfb.php:14
Bitrix\Landing\Hook\Page\PixelFb\getMap
getMap()
Определения
pixelfb.php:19
Bitrix\Landing\Hook\Page\PixelFb\enabledInEditMode
enabledInEditMode()
Определения
pixelfb.php:42
Bitrix\Landing\Hook\Page\PixelFb\enabled
enabled()
Определения
pixelfb.php:51
Bitrix\Landing\Hook\Page\PixelFb\changeBusinessPixel
static changeBusinessPixel()
Определения
pixelfb.php:104
Bitrix\Landing\Hook\Page\PixelFb\exec
exec()
Определения
pixelfb.php:117
Bitrix\Landing\Hook\Page\isPage
isPage()
Определения
page.php:66
Bitrix\Landing\Hook\Page\issetCustomExec
issetCustomExec()
Определения
page.php:253
Bitrix\Landing\Hook\Page\execCustom
execCustom()
Определения
page.php:262
Bitrix\Landing\Manager\isB24
static isB24()
Определения
manager.php:1135
Bitrix\Landing\Manager\getOption
static getOption($code, $default=null)
Определения
manager.php:160
Bitrix\Landing\Manager\setOption
static setOption($code, $value)
Определения
manager.php:171
Bitrix\Landing\Manager\setPageView
static setPageView(string $marker, string $content, bool $skipTrim=false)
Определения
manager.php:470
Bitrix\Landing\Manager\clearCache
static clearCache()
Определения
manager.php:1435
Bitrix\Seo\BusinessSuite\ExtensionFacade\getInstance
static getInstance()
Определения
extensionfacade.php:25
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$_SERVER
$_SERVER["DOCUMENT_ROOT"]
Определения
cron_frame.php:9
htmlspecialcharsbx
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения
tools.php:2701
Bitrix\Landing\Field
Определения
checkbox.php:2
Bitrix\Landing\Hook\Page
Определения
b24button.php:2
Bitrix\Main\Text
Определения
base32.php:2
Bitrix\Main
Bitrix
$counter
$counter
Определения
options.php:5
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
bitrix
modules
landing
lib
hook
page
pixelfb.php
Создано системой
1.14.0