Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
headblock.php
1
<?php
2
namespace
Bitrix\Landing\Hook\Page
;
3
4
use \Bitrix\Landing\Field;
5
use \Bitrix\Landing\Manager;
6
use \Bitrix\Main\ModuleManager;
7
use \Bitrix\Main\Localization\Loc;
8
9
Loc::loadMessages
(__FILE__);
10
11
class
HeadBlock
extends
\Bitrix\Landing\Hook\Page
12
{
17
protected
static
$lastInsertedCode
=
null
;
18
23
protected
function
getMap
()
24
{
25
return
array(
26
'USE'
=>
new
Field
\
Checkbox
(
'USE'
, array(
27
'title'
=>
Loc::getMessage
(
'LANDING_HOOK_HEADBLOCK_USE2'
)
28
)),
29
'CODE'
=>
new
Field
\
Textarea
(
'CODE'
, array(
30
'title'
=>
Loc::getMessage
(
'LANDING_HOOK_HEADBLOCK_CODE'
),
31
'help'
=>
Loc::getMessage
(
'LANDING_HOOK_HEADBLOCK_CODE_HELP3'
),
32
'placeholder'
=>
'<script>
33
var googletag = googletag || {};
34
googletag.cmd = googletag.cmd || [];
35
</script>'
36
))
37
);
38
}
39
44
public
static
function
getLastInsertedCode
()
45
{
46
return
self::$lastInsertedCode
;
47
}
48
53
public
function
isFree
()
54
{
55
return
false
;
56
}
57
62
public
function
isLocked
()
63
{
64
return
$this->
isLockedFeature
();
65
}
66
71
public
static
function
isLockedFeature
()
72
{
73
if
(ModuleManager::isModuleInstalled(
'bitrix24'
))
74
{
75
$checkFeature = \Bitrix\Landing\Restriction\Manager::isAllowed(
76
'limit_sites_html_js'
77
);
78
if
($checkFeature)
79
{
80
return
false
;
81
}
82
$dateCreate = \Bitrix\Main\Config\Option::get(
83
'main'
,
'~controller_date_create'
84
);
85
// for all portals early than 01.07.2019, feature are available
86
if
($dateCreate < 1562000000)
87
{
88
// this option will be set after downgrade in bitrix24
89
return
Manager::getOption
(
'html_disabled'
,
'N'
) ==
'Y'
;
90
}
91
else
92
{
93
return
true
;
94
}
95
}
96
97
return
false
;
98
}
99
104
public
function
getTitle
()
105
{
106
return
Loc::getMessage
(
'LANDING_HOOK_HEADBLOCK_NAME2'
);
107
}
108
113
public
function
getSort
()
114
{
115
return
500;
116
}
117
122
public
function
enabled
()
123
{
124
if
($this->
isLocked
())
125
{
126
return
false
;
127
}
128
129
if
($this->
issetCustomExec
())
130
{
131
return
true
;
132
}
133
134
return
$this->fields[
'USE'
]->getValue() ==
'Y'
;
135
}
136
141
public
function
enabledInEditMode
()
142
{
143
return
false
;
144
}
145
150
public
function
exec
()
151
{
152
if
($this->
isLocked
())
153
{
154
return
;
155
}
156
157
if
($this->
execCustom
())
158
{
159
return
;
160
}
161
162
$code = trim($this->fields[
'CODE'
]);
163
164
if
($code !=
''
)
165
{
166
self::$lastInsertedCode = $code;
167
$code = str_replace(
168
'<script'
,
169
'<script data-skip-moving="true"'
, $code
170
);
171
\Bitrix\Main\Page\Asset::getInstance()->addString($code);
172
}
173
}
174
}
Bitrix\Landing\Field\Checkbox
Definition
checkbox.php:5
Bitrix\Landing\Field\Textarea
Definition
textarea.php:5
Bitrix\Landing\Field
Definition
field.php:5
Bitrix\Landing\Hook\Page\HeadBlock
Definition
headblock.php:12
Bitrix\Landing\Hook\Page\HeadBlock\isLocked
isLocked()
Definition
headblock.php:62
Bitrix\Landing\Hook\Page\HeadBlock\isLockedFeature
static isLockedFeature()
Definition
headblock.php:71
Bitrix\Landing\Hook\Page\HeadBlock\getMap
getMap()
Definition
headblock.php:23
Bitrix\Landing\Hook\Page\HeadBlock\getTitle
getTitle()
Definition
headblock.php:104
Bitrix\Landing\Hook\Page\HeadBlock\getSort
getSort()
Definition
headblock.php:113
Bitrix\Landing\Hook\Page\HeadBlock\enabledInEditMode
enabledInEditMode()
Definition
headblock.php:141
Bitrix\Landing\Hook\Page\HeadBlock\getLastInsertedCode
static getLastInsertedCode()
Definition
headblock.php:44
Bitrix\Landing\Hook\Page\HeadBlock\enabled
enabled()
Definition
headblock.php:122
Bitrix\Landing\Hook\Page\HeadBlock\exec
exec()
Definition
headblock.php:150
Bitrix\Landing\Hook\Page\HeadBlock\$lastInsertedCode
static $lastInsertedCode
Definition
headblock.php:17
Bitrix\Landing\Hook\Page\HeadBlock\isFree
isFree()
Definition
headblock.php:53
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\Landing\Manager\getOption
static getOption($code, $default=null)
Definition
manager.php:160
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
headblock.php
Создано системой
1.10.0