ShopBuilder::getContextMenuItems

  1. Bitrix24 API (v. 23.675.0)
  2. catalog
  3. ShopBuilder
  4. getContextMenuItems
  • Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/url/shopbuilder.php
  • Класс: BitrixCatalogUrlShopBuilder
  • Вызов: ShopBuilder::getContextMenuItems
public function getContextMenuItems(string $pageType, array $items = [], array $options = []): ?array
{
	if ($pageType !== self::PAGE_ELEMENT_LIST && $pageType !== self::PAGE_SECTION_LIST)
	{
		return null;
	}

	if (!Loader::includeModule('crm'))
	{
		return null;
	}

	$result = [];

	if (AccessController::getCurrent()->check(ActionDictionary::ACTION_CATALOG_SETTINGS_ACCESS))
	{
		if (!CCrmSaleHelper::isWithOrdersMode())
		{
			Extension::load(['crm.config.catalog']);

			$result[] = [
				'TEXT' => Loc::getMessage('CATALOG_SHOP_BUILDER_CONTEXT_MENU_ITEM_INVENTORY_MANAGEMENT_SETTINGS'),
				'TITLE' => Loc::getMessage('CATALOG_SHOP_BUILDER_CONTEXT_MENU_ITEM_INVENTORY_MANAGEMENT_SETTINGS'),
				'ONCLICK' => 'BX.Crm.Config.Catalog.Slider.open('shop')',
			];
		}

		if (
			CatalogConfigFeature::isInventoryManagementEnabled()
			&& !CatalogComponentUseStore::isUsed()
		)
		{
			Extension::load(['catalog.store-use']);

			$sliderPath = CComponentEngine::makeComponentPath('bitrix:catalog.warehouse.master.clear');
			$sliderPath = getLocalPath('components' . $sliderPath . '/slider.php');

			$result[] = [
				'TEXT' => Loc::getMessage('CATALOG_SHOP_BUILDER_CONTEXT_MENU_ITEM_WAREHOUSE_Y'),
				'TITLE' => Loc::getMessage('CATALOG_SHOP_BUILDER_CONTEXT_MENU_ITEM_WAREHOUSE_Y'),
				'ONCLICK' => "BX.Catalog.StoreUse.ProductGridMenu.openWarehousePanel('" . $sliderPath . "')"
			];

			unset($sliderPath);
		}
	}

	if (CatalogConfigFeature::isAccessControllerCheckingEnabled())
	{
		Extension::load('sidepanel');

		$result[] = [
			'TEXT' => Loc::getMessage('CATALOG_SHOP_BUILDER_CONTEXT_MENU_ITEM_ACCESS_RIGHTS'),
			'TITLE' => Loc::getMessage('CATALOG_SHOP_BUILDER_CONTEXT_MENU_ITEM_ACCESS_RIGHTS'),
			'ONCLICK' => "BX.SidePanel.Instance.open('" . CUtil::JSEscape('/shop/settings/permissions/') . "')"
		];
	}
	else
	{
		$helpLink = CatalogConfigFeature::getAccessControllerHelpLink();
		if (!empty($helpLink))
		{
			CatalogConfigFeature::initUiHelpScope();
			$result[] = [
				'TEXT' => Loc::getMessage('CATALOG_SHOP_BUILDER_CONTEXT_MENU_ITEM_ACCESS_RIGHTS'),
				'TITLE' => Loc::getMessage('CATALOG_SHOP_BUILDER_CONTEXT_MENU_ITEM_ACCESS_RIGHTS'),
				$helpLink['TYPE'] => $helpLink['LINK'],
			];
		}
		unset($helpLink);
	}

	$result[] = [
		'TEXT' => Loc::getMessage('CATALOG_SHOP_BUILDER_CONTEXT_MENU_ITEM_SEO'),
		'TITLE' => Loc::getMessage('CATALOG_SHOP_BUILDER_CONTEXT_MENU_ITEM_SEO'),
		'ONCLICK' => "BX.SidePanel.Instance.open('"
			. CUtil::JSEscape($this->getCatalogSeoUrl())
			. "', {cacheable: false, allowChangeHistory: false, width: 1000})"
		,
	];

	if (!empty($items))
	{
		$result = array_merge($result, $items);
	}

	return (!empty($result) ? $result: null);
}

Добавить комментарий