4use \Bitrix\Landing\Block;
5use \Bitrix\Landing\Node;
6use \Bitrix\Landing\Config;
7use \Bitrix\Landing\Manager;
8use \Bitrix\Landing\Assets;
9use \Bitrix\Landing\Internals\BlockTable;
10use \Bitrix\Main\IO\File;
35 'fa-500px' => [
'vendor' =>
'fab'],
36 'fa-adn' => [
'vendor' =>
'fab'],
37 'fa-amazon' => [
'vendor' =>
'fab'],
38 'fa-android' => [
'vendor' =>
'fab'],
39 'fa-angellist' => [
'vendor' =>
'fab'],
40 'fa-apple' => [
'vendor' =>
'fab'],
41 'fa-bandcamp' => [
'vendor' =>
'fab'],
42 'fa-behance' => [
'vendor' =>
'fab'],
43 'fa-behance-square' => [
'vendor' =>
'fab'],
44 'fa-bitbucket' => [
'vendor' =>
'fab'],
45 'fa-bitbucket-square' => [
47 'content' =>
'\\f171',
51 'content' =>
'\\f379',
53 'fa-black-tie' => [
'vendor' =>
'fab'],
54 'fa-bluetooth' => [
'vendor' =>
'fab'],
55 'fa-bluetooth-b' => [
'vendor' =>
'fab'],
56 'fa-btc' => [
'vendor' =>
'fab'],
57 'fa-buysellads' => [
'vendor' =>
'fab'],
58 'fa-cc-amex' => [
'vendor' =>
'fab'],
59 'fa-cc-diners-club' => [
'vendor' =>
'fab'],
60 'fa-cc-discover' => [
'vendor' =>
'fab'],
61 'fa-cc-jcb' => [
'vendor' =>
'fab'],
62 'fa-cc-mastercard' => [
'vendor' =>
'fab'],
63 'fa-cc-paypal' => [
'vendor' =>
'fab'],
64 'fa-cc-stripe' => [
'vendor' =>
'fab'],
65 'fa-cc-visa' => [
'vendor' =>
'fab'],
66 'fa-chrome' => [
'vendor' =>
'fab'],
67 'fa-codepen' => [
'vendor' =>
'fab'],
68 'fa-codiepie' => [
'vendor' =>
'fab'],
69 'fa-connectdevelop' => [
'vendor' =>
'fab'],
70 'fa-contao' => [
'vendor' =>
'fab'],
71 'fa-creative-commons' => [
'vendor' =>
'fab'],
72 'fa-css3' => [
'vendor' =>
'fab'],
73 'fa-dashcube' => [
'vendor' =>
'fab'],
74 'fa-delicious' => [
'vendor' =>
'fab'],
75 'fa-deviantart' => [
'vendor' =>
'fab'],
76 'fa-digg' => [
'vendor' =>
'fab'],
77 'fa-dribbble' => [
'vendor' =>
'fab'],
78 'fa-dropbox' => [
'vendor' =>
'fab'],
79 'fa-drupal' => [
'vendor' =>
'fab'],
80 'fa-edge' => [
'vendor' =>
'fab'],
83 'content' =>
'\\f2da',
85 'fa-empire' => [
'vendor' =>
'fab'],
86 'fa-envira' => [
'vendor' =>
'fab'],
87 'fa-etsy' => [
'vendor' =>
'fab'],
88 'fa-expeditedssl' => [
'vendor' =>
'fab'],
91 'content' =>
'\\f2b4',
93 'fa-facebook' => [
'vendor' =>
'fab'],
96 'content' =>
'\\f39e',
98 'fa-facebook-official' => [
100 'content' =>
'\\f09a',
102 'fa-facebook-square' => [
'vendor' =>
'fab'],
103 'fa-firefox' => [
'vendor' =>
'fab'],
104 'fa-first-order' => [
'vendor' =>
'fab'],
105 'fa-flickr' => [
'vendor' =>
'fab'],
106 'fa-font-awesome' => [
'vendor' =>
'fab'],
107 'fa-fonticons' => [
'vendor' =>
'fab'],
108 'fa-fort-awesome' => [
'vendor' =>
'fab'],
109 'fa-forumbee' => [
'vendor' =>
'fab'],
110 'fa-foursquare' => [
'vendor' =>
'fab'],
111 'fa-free-code-camp' => [
'vendor' =>
'fab'],
114 'content' =>
'\\f1d1',
116 'fa-get-pocket' => [
'vendor' =>
'fab'],
117 'fa-gg' => [
'vendor' =>
'fab'],
118 'fa-gg-circle' => [
'vendor' =>
'fab'],
119 'fa-git' => [
'vendor' =>
'fab'],
120 'fa-git-square' => [
'vendor' =>
'fab'],
121 'fa-github' => [
'vendor' =>
'fab'],
122 'fa-github-alt' => [
'vendor' =>
'fab'],
123 'fa-github-square' => [
'vendor' =>
'fab'],
124 'fa-gitlab' => [
'vendor' =>
'fab'],
127 'content' =>
'\\f184',
129 'fa-glide' => [
'vendor' =>
'fab'],
130 'fa-glide-g' => [
'vendor' =>
'fab'],
131 'fa-google' => [
'vendor' =>
'fab'],
132 'fa-google-plus' => [
134 'content' =>
'\\f2b3',
136 'fa-google-plus-circle' => [
138 'content' =>
'\\f2b3',
140 'fa-google-plus-official' => [
142 'content' =>
'\\f2b3',
144 'fa-google-plus-square' => [
'vendor' =>
'fab'],
145 'fa-google-wallet' => [
'vendor' =>
'fab'],
146 'fa-gratipay' => [
'vendor' =>
'fab'],
147 'fa-grav' => [
'vendor' =>
'fab'],
148 'fa-hacker-news' => [
'vendor' =>
'fab'],
149 'fa-houzz' => [
'vendor' =>
'fab'],
150 'fa-html5' => [
'vendor' =>
'fab'],
151 'fa-imdb' => [
'vendor' =>
'fab'],
152 'fa-instagram' => [
'vendor' =>
'fab'],
153 'fa-internet-explorer' => [
'vendor' =>
'fab'],
154 'fa-ioxhost' => [
'vendor' =>
'fab'],
155 'fa-joomla' => [
'vendor' =>
'fab'],
156 'fa-jsfiddle' => [
'vendor' =>
'fab'],
157 'fa-lastfm' => [
'vendor' =>
'fab'],
158 'fa-lastfm-square' => [
'vendor' =>
'fab'],
159 'fa-leanpub' => [
'vendor' =>
'fab'],
162 'content' =>
'\\f08c',
164 'fa-linkedin-square' => [
166 'content' =>
'\\f08c',
168 'fa-linode' => [
'vendor' =>
'fab'],
169 'fa-linux' => [
'vendor' =>
'fab'],
170 'fa-maxcdn' => [
'vendor' =>
'fab'],
173 'content' =>
'\\f2b4',
175 'fa-medium' => [
'vendor' =>
'fab'],
176 'fa-meetup' => [
'vendor' =>
'fab'],
177 'fa-mixcloud' => [
'vendor' =>
'fab'],
178 'fa-modx' => [
'vendor' =>
'fab'],
179 'fa-odnoklassniki' => [
'vendor' =>
'fab'],
180 'fa-odnoklassniki-square' => [
'vendor' =>
'fab'],
181 'fa-opencart' => [
'vendor' =>
'fab'],
182 'fa-openid' => [
'vendor' =>
'fab'],
183 'fa-opera' => [
'vendor' =>
'fab'],
184 'fa-optin-monster' => [
'vendor' =>
'fab'],
185 'fa-pagelines' => [
'vendor' =>
'fab'],
186 'fa-paypal' => [
'vendor' =>
'fab'],
187 'fa-pied-piper' => [
'vendor' =>
'fab'],
188 'fa-pied-piper-alt' => [
'vendor' =>
'fab'],
189 'fa-pied-piper-pp' => [
'vendor' =>
'fab'],
190 'fa-pinterest' => [
'vendor' =>
'fab'],
191 'fa-pinterest-p' => [
'vendor' =>
'fab'],
192 'fa-pinterest-square' => [
'vendor' =>
'fab'],
193 'fa-product-hunt' => [
'vendor' =>
'fab'],
194 'fa-qq' => [
'vendor' =>
'fab'],
195 'fa-quora' => [
'vendor' =>
'fab'],
198 'content' =>
'\\f1d0',
200 'fa-ravelry' => [
'vendor' =>
'fab'],
201 'fa-rebel' => [
'vendor' =>
'fab'],
202 'fa-reddit' => [
'vendor' =>
'fab'],
203 'fa-reddit-alien' => [
'vendor' =>
'fab'],
204 'fa-reddit-square' => [
'vendor' =>
'fab'],
205 'fa-renren' => [
'vendor' =>
'fab'],
208 'content' =>
'\\f1d0',
210 'fa-safari' => [
'vendor' =>
'fab'],
211 'fa-scribd' => [
'vendor' =>
'fab'],
212 'fa-sellsy' => [
'vendor' =>
'fab'],
213 'fa-shirtsinbulk' => [
'vendor' =>
'fab'],
214 'fa-simplybuilt' => [
'vendor' =>
'fab'],
215 'fa-skyatlas' => [
'vendor' =>
'fab'],
216 'fa-skype' => [
'vendor' =>
'fab'],
217 'fa-slack' => [
'vendor' =>
'fab'],
218 'fa-slideshare' => [
'vendor' =>
'fab'],
219 'fa-snapchat' => [
'vendor' =>
'fab'],
220 'fa-snapchat-ghost' => [
222 'content' =>
'\\f2ab',
224 'fa-snapchat-square' => [
'vendor' =>
'fab'],
225 'fa-soundcloud' => [
'vendor' =>
'fab'],
226 'fa-spotify' => [
'vendor' =>
'fab'],
227 'fa-stack-exchange' => [
'vendor' =>
'fab'],
228 'fa-stack-overflow' => [
'vendor' =>
'fab'],
229 'fa-steam' => [
'vendor' =>
'fab'],
230 'fa-steam-square' => [
'vendor' =>
'fab'],
231 'fa-stumbleupon' => [
'vendor' =>
'fab'],
232 'fa-stumbleupon-circle' => [
'vendor' =>
'fab'],
233 'fa-superpowers' => [
'vendor' =>
'fab'],
234 'fa-telegram' => [
'vendor' =>
'fab'],
235 'fa-tencent-weibo' => [
'vendor' =>
'fab'],
236 'fa-themeisle' => [
'vendor' =>
'fab'],
237 'fa-trello' => [
'vendor' =>
'fab'],
238 'fa-tumblr' => [
'vendor' =>
'fab'],
239 'fa-tumblr-square' => [
'vendor' =>
'fab'],
240 'fa-twitch' => [
'vendor' =>
'fab'],
241 'fa-twitter' => [
'vendor' =>
'fab'],
242 'fa-twitter-square' => [
'vendor' =>
'fab'],
243 'fa-usb' => [
'vendor' =>
'fab'],
244 'fa-viacoin' => [
'vendor' =>
'fab'],
245 'fa-viadeo' => [
'vendor' =>
'fab'],
246 'fa-viadeo-square' => [
'vendor' =>
'fab'],
249 'content' =>
'\\f40a',
251 'fa-vimeo-square' => [
'vendor' =>
'fab'],
252 'fa-vine' => [
'vendor' =>
'fab'],
253 'fa-vk' => [
'vendor' =>
'fab'],
256 'content' =>
'\\f1d7',
258 'fa-weibo' => [
'vendor' =>
'fab'],
259 'fa-weixin' => [
'vendor' =>
'fab'],
260 'fa-whatsapp' => [
'vendor' =>
'fab'],
261 'fa-wikipedia-w' => [
'vendor' =>
'fab'],
262 'fa-windows' => [
'vendor' =>
'fab'],
263 'fa-wordpress' => [
'vendor' =>
'fab'],
264 'fa-wpbeginner' => [
'vendor' =>
'fab'],
265 'fa-wpexplorer' => [
'vendor' =>
'fab'],
266 'fa-wpforms' => [
'vendor' =>
'fab'],
267 'fa-xing' => [
'vendor' =>
'fab'],
268 'fa-xing-square' => [
'vendor' =>
'fab'],
269 'fa-y-combinator' => [
'vendor' =>
'fab'],
270 'fa-y-combinator-square' => [
272 'content' =>
'\\f1d4',
274 'fa-yahoo' => [
'vendor' =>
'fab'],
277 'content' =>
'\\f1d4',
281 'content' =>
'\\f1d4',
283 'fa-yelp' => [
'vendor' =>
'fab'],
284 'fa-yoast' => [
'vendor' =>
'fab'],
285 'fa-youtube' => [
'vendor' =>
'fab'],
286 'fa-youtube-play' => [
288 'content' =>
'\\f167',
290 'fa-youtube-square' => [
292 'content' =>
'\\f431',
295 'fa-plus' => [
'content' =>
'\2b'],
296 'fa-usd' => [
'content' =>
'\24'],
297 'fa-dollar' => [
'content' =>
'\24'],
298 'fa-rupee' => [
'content' =>
'\e1bc'],
299 'fa-inr' => [
'content' =>
'\e1bc'],
300 'fa-wheelchair-alt' => [
'content' =>
'\\e2ce',],
313 if (is_dir($iconSrc))
328 static $vendorContent = [];
330 if (!array_key_exists($vendorName, $vendorContent))
332 $vendorContent[$vendorName] = [];
337 if (File::isFileExists($cssFileName))
339 $cssContent = File::getFileContents($cssFileName);
342 $classPrefix = $vendorName;
343 $iconVendorsConfig =
Config::get(
'icon_vendors_config');
344 if ($iconVendorsConfig && isset ($iconVendorsConfig[$vendorName][
'class_prefix']))
346 $classPrefix = $iconVendorsConfig[$vendorName][
'class_prefix'];
348 $found = preg_match_all(
349 '/\.(' . $classPrefix .
'-[^:]+):{1,2}before\s*{\s*content:\s*["\']((?:\\\\.|[^\\\\])*?)["\'];\s*}/',
355 foreach ($matches[1] as $i => $match)
357 $vendorContent[$vendorName][$match] = $matches[2][$i];
365 return $vendorContent[$vendorName];
378 return $contentAll[$className] ??
null;
392 if (!$iconSrc || !$iconVendors || !$blockContent)
398 $iconVendors = (array)$iconVendors;
399 $vendorsStr =
'(' . implode(
'|', $iconVendors) .
')';
400 $prefixesStr = $vendorsStr;
402 $iconVendorsConfig =
Config::get(
'icon_vendors_config');
403 if ($iconVendorsConfig && !empty($iconVendorsConfig))
405 $classPrefixes = $iconVendors;
406 foreach ($iconVendorsConfig as $vendor => $config)
408 $classPrefixes[array_search($vendor, $classPrefixes,
true)] = $config[
'class_prefix'];
410 $prefixesStr =
'(' . implode(
'|', array_unique($classPrefixes)) .
')';
412 $found = preg_match_all(
413 '/(?<=[\s"])' . $vendorsStr .
'?\s*(' . $prefixesStr .
'-([^\s"\/\\\]+))/s',
419 foreach ($matches[0] as $i => $full)
421 $vendor = $matches[1][$i]
422 ? trim($matches[1][$i])
423 : trim($matches[3][$i]);
424 $class = trim($matches[2][$i]);
426 if (!isset($assetsIcon[$vendor]))
428 $assetsIcon[$vendor] = [];
434 if ($assetsIcon[$vendor][$class] ===
null)
436 unset($assetsIcon[$vendor][$class]);
438 if (!$assetsIcon[$vendor])
440 unset($assetsIcon[$vendor]);
446 'icon' => $assetsIcon
468 $res = BlockTable::getList([
477 while ($row = $res->fetch())
479 $block =
new Block($row[
'ID']);
493 if (isset($blockAssets[
'icon']) && !empty($blockAssets[
'icon']))
495 $assetsManager = Assets\Manager::getInstance();
501 $stylesString =
'<style>';
503 foreach ($blockAssets[
'icon'] as $vendorName => $icons)
506 $assetsManager->addAsset($fontFile);
508 $assetsManager->addAsset($fontFile2);
511 $assetsManager->addAsset($stylesFile);
513 foreach ($icons as $className => $content)
515 $stylesString .=
'.' . $className .
':before{content:"' . $content .
'";}';
518 $stylesString .=
'</style>';
519 $assetsManager->addString($stylesString);
525 $newIcons = $iconData;
527 foreach ($iconData as $vendor => $icons)
529 if (!isset(self::VENDOR_UPDATES[$vendor]))
534 $newVendor = self::VENDOR_UPDATES[$vendor];
536 foreach ($icons as $icon => $content)
538 if (isset(self::ICON_UPDATES[$vendor]))
540 $currVendor = self::ICON_UPDATES[$vendor][$icon][
'vendor'] ?? $newVendor;
541 $newContent = self::ICON_UPDATES[$vendor][$icon][
'content'] ?? $content;
542 $newIcons[$currVendor][$icon] = $newContent;
544 unset($newIcons[$vendor][$icon]);
545 if (empty($newIcons[$vendor]))
547 unset($newIcons[$vendor]);
558 $newVendor = self::VENDOR_UPDATES[$vendor] ?? $vendor;
560 if (isset(self::ICON_UPDATES[$vendor]))
562 $newVendor = self::ICON_UPDATES[$vendor][$class][
'vendor'] ?? $newVendor;
565 return [$newVendor, $newClass];
static saveAssets(Block $block)
static updateIconsBeforeView($iconData)
static processingLanding(int $landingId)
static view(Block $block)
const ICON_FONT_FILE_NAME_2
static processing(Block $block)
static getIconsPath(string $vendorName)
const RULE_ICON_FILE_NAME
static getIconContentByClass(string $className, string $vendorName)
static getIconsContentByVendor(string $vendorName)
static updateIconsBeforeSave(string $vendor, string $class)
const CONTENT_ICON_FILE_NAME
const ICON_FONT_FILE_NAME
saveAssets(array $assets)