2namespace Bitrix\Landing\PublicAction;
5use Bitrix\Landing\Error;
6use Bitrix\Landing\PublicAction;
7use Bitrix\Landing\Subtype;
8use Bitrix\Landing\Manager;
9use Bitrix\Landing\PublicActionResult;
10use Bitrix\Landing\Site\Scope;
12use Bitrix\Main\Loader;
13use Bitrix\Main\Localization\Loc;
14use Bitrix\Main\Web\HttpClient;
15use Bitrix\Rest\UsageStatTable;
22 private const SUBTYPE_WIDGET =
'widgetvue';
33 if (!isset(
$fields[
'WIDGET_PARAMS']) && !is_array(
$fields[
'WIDGET_PARAMS']))
36 'REQUIRED_FIELD_NO_EXISTS',
37 Loc::getMessage(
'LANDING_WIDGET_FIELD_NO_EXISTS', [
'#field#' =>
'WIDGET_PARAMS'])
48 foreach ($requiredParams as $param)
50 if (!isset(
$fields[
'WIDGET_PARAMS'][$param]))
53 'REQUIRED_PARAM_NO_EXISTS',
54 Loc::getMessage(
'LANDING_WIDGET_PARAM_NO_EXISTS', [
'#param#' => $param])
64 $manifest[
'block'][
'type'] = mb_strtolower(
Landing\
Site\Type::SCOPE_CODE_MAINPAGE);
65 $manifest[
'block'][
'subtype'] = self::SUBTYPE_WIDGET;
66 $manifest[
'block'][
'subtype_params'] = [
67 'rootNode' =>
$fields[
'WIDGET_PARAMS'][
'rootNode'] ??
null,
68 'demoData' =>
$fields[
'WIDGET_PARAMS'][
'demoData'] ??
null,
69 'handler' =>
$fields[
'WIDGET_PARAMS'][
'handler'] ??
null,
70 'style' =>
$fields[
'WIDGET_PARAMS'][
'style'] ??
null,
71 'lang' =>
$fields[
'WIDGET_PARAMS'][
'lang'] ??
null,
94 Loc::getMessage(
'LANDING_WIDGET_BLOCK_NOT_FOUND')
101 if (!Loader::includeModule(
'rest'))
105 Loc::getMessage(
'LANDING_WIDGET_REST_NOT_FOUND')
113 $repoId = $block->getRepoId();
118 || !isset(
$app[
'CLIENT_ID'])
123 Loc::getMessage(
'LANDING_WIDGET_APP_NOT_FOUND')
131 $manifest = $block->getManifest();
133 !in_array(self::SUBTYPE_WIDGET, (
array)$manifest[
'block'][
'subtype'],
true)
134 || !is_array($manifest[
'block'][
'subtype_params'])
135 || !isset($manifest[
'block'][
'subtype_params'][
'handler'])
140 Loc::getMessage(
'LANDING_WIDGET_HANDLER_NOT_FOUND_2')
154 if (isset(
$auth[
'error']))
157 'APP_AUTH_ERROR__' .
$auth[
'error'],
158 $auth[
'error_description'] ??
''
167 $url = (string)$manifest[
'block'][
'subtype_params'][
'handler'];
174 if ($http->getStatus() !== 200)
178 Loc::getMessage(
'LANDING_WIDGET_HANDLER_NOT_ALLOW')
186 UsageStatTable::logLandingWidget(
$app[
'CLIENT_ID'],
$type);
187 UsageStatTable::finalize();
189 if (isset(
$data[
'error']))
193 $data[
'error_description'] ??
''
214 $error = new \Bitrix\Landing\Error;
217 $app = PublicAction::restApplication();
220 && isset(
$app[
'CODE'])
231 Loc::getMessage(
'LANDING_WIDGET_APP_NOT_FOUND')
247 $error = new \Bitrix\Landing\Error;
250 Loc::getMessage(
'LANDING_WIDGET_METHOD_NOT_AVAILABLE')
265 $error = new \Bitrix\Landing\Error;
268 Loc::getMessage(
'LANDING_WIDGET_METHOD_NOT_AVAILABLE')
284 $error = new \Bitrix\Landing\Error;
287 Loc::getMessage(
'LANDING_WIDGET_METHOD_NOT_AVAILABLE')
302 $listRes = parent::getList(
$params);
303 if ($listRes->isSuccess())
307 $listAll = $listRes->getResult();
308 if (is_array($listAll) && !empty($listAll))
310 $listAll = array_filter($listAll,
function ($item) {
311 $isType = isset($item[
'MANIFEST'][
'block'][
'type'])
313 mb_strtolower(
Landing\
Site\Type::SCOPE_CODE_MAINPAGE),
314 (
array)$item[
'MANIFEST'][
'block'][
'type'],
320 isset($item[
'MANIFEST'][
'block'][
'subtype'])
322 self::SUBTYPE_WIDGET,
323 (
array)$item[
'MANIFEST'][
'block'][
'subtype'],
328 return $isType && $isSubtype;
static getAppByCode($code)
static getAppInfo(array|int $id)
static prepareBlockManifest(array $manifest)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']