Server IP : 85.193.89.191 / Your IP : 3.144.92.77 Web Server : Apache System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : bitrix ( 600) PHP Version : 8.1.27 Disable Function : NONE MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/bitrix/www/bitrix/components/bitrix/landing.pub/templates/.default/ |
Upload File : |
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die(); } use \Bitrix\Landing\Hook\Page; /** @var array $arResult */ // Web forms backward compatibility hooks. if (($arResult['SPECIAL_TYPE'] ?? null) != 'crm_forms') { return; } $eventManager = \Bitrix\Main\EventManager::getInstance(); $eventManager->addEventHandler('landing', 'onHookExec', function(\Bitrix\Main\Event $event) use ($arResult) { $result = new \Bitrix\Main\Entity\EventResult; /** * Returns web form data for current page. * @return array */ $getFormData = function() use($arResult) { static $data = null; if ($data !== null) { return $data; } $data = []; if (!\Bitrix\Main\Loader::includeModule('crm')) { return $data; } $res = \Bitrix\Crm\WebForm\Internals\FormTable::getList([ 'select' => [ 'BACKGROUND_IMAGE', 'GOOGLE_ANALYTICS_ID', 'YANDEX_METRIC_ID' ], 'filter' => [ 'LANDING.LANDING_ID' => $arResult['LANDING']->getId() ] ]); if ($row = $res->fetch()) { $data = $row; } return $data; }; $result->modifyFields([ 'BACKGROUND' => function(Page $hook) use($getFormData) { $fields = $hook->getFields(); $use = $fields['USE']->getValue(); $picture = \htmlspecialcharsbx(trim($fields['PICTURE']->getValue())); $color = \htmlspecialcharsbx(trim($fields['COLOR']->getValue())); $position = trim($fields['POSITION']->getValue()); if ($use != 'Y') { $data = $getFormData(); if ($data['BACKGROUND_IMAGE'] ?? false) { $picture = $data['BACKGROUND_IMAGE']; $picture = \CFile::getPath($picture); $color = $position = null; $use = 'Y'; } } if ($use == 'Y') { Page\Background::setBackground( $picture, $color, $position ); } return true; }, 'GACOUNTER' => function(Page $hook) use($getFormData) { $fields = $hook->getFields(); $use = $fields['USE']->getValue(); if ($use != 'Y') { $data = $getFormData(); if ($data['GOOGLE_ANALYTICS_ID'] ?? false) { Page\GaCounter::setCounter($data['GOOGLE_ANALYTICS_ID']); return true; } } return false; }, 'YACOUNTER' => function(Page $hook) use($getFormData) { $fields = $hook->getFields(); $use = $fields['USE']->getValue(); if ($use != 'Y') { $data = $getFormData(); if ($data['YANDEX_METRIC_ID'] ?? false) { Page\YaCounter::setCounter($data['YANDEX_METRIC_ID']); return true; } } return false; } ]); return $result; } );