Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
headblock.php
1<?php
3
4use \Bitrix\Landing\Field;
5use \Bitrix\Landing\Manager;
6use \Bitrix\Main\ModuleManager;
7use \Bitrix\Main\Localization\Loc;
8
9Loc::loadMessages(__FILE__);
10
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 {
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}
static getOption($code, $default=null)
Definition manager.php:160
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29