• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/component_util.php
  • Класс: CComponentUtil
  • Вызов: CComponentUtil::__BuildTree
static function __BuildTree($arPath, &$arTree, &$arComponent, $level = 1)
{
	$arBXTopComponentCatalogLevel = array("content", "service", "communication", "e-store", "utility");
	$arBXTopComponentCatalogLevelSort = array(600, 700, 800, 900, 1000);

	if (!isset($arTree["#"]) || !is_array($arTree["#"]))
		$arTree["#"] = array();

	if (!array_key_exists($arPath["ID"], $arTree["#"]))
	{
		$arTree["#"][$arPath["ID"]] = array();
		$arTree["#"][$arPath["ID"]]["@"] = array();
		$arTree["#"][$arPath["ID"]]["@"]["NAME"] = "";
		$arTree["#"][$arPath["ID"]]["@"]["SORT"] = intval($arPath["SORT"] ?? 0);
		if ($level == 1 && in_array($arPath["ID"], $arBXTopComponentCatalogLevel))
		{
			$arTree["#"][$arPath["ID"]]["@"]["NAME"] = GetMessage("VRT_COMP_CAT_".mb_strtoupper($arPath["ID"]));
			$arTree["#"][$arPath["ID"]]["@"]["SORT"] = intval($arBXTopComponentCatalogLevelSort[array_search($arPath["ID"], $arBXTopComponentCatalogLevel)]);
		}
		if ($arTree["#"][$arPath["ID"]]["@"]["NAME"] == '')
			$arTree["#"][$arPath["ID"]]["@"]["NAME"] = $arPath["NAME"] ?? '';
		if ($arTree["#"][$arPath["ID"]]["@"]["SORT"] <= 0)
			$arTree["#"][$arPath["ID"]]["@"]["SORT"] = 100;
	}

	if (array_key_exists("CHILD", $arPath))
	{
		CComponentUtil::__BuildTree($arPath["CHILD"], $arTree["#"][$arPath["ID"]], $arComponent, $level + 1);
	}
	else
	{
		if (!isset($arTree["#"][$arPath["ID"]]["*"]) || !is_array($arTree["#"][$arPath["ID"]]["*"]))
			$arTree["#"][$arPath["ID"]]["*"] = array();

		$arTree["#"][$arPath["ID"]]["*"][$arComponent["NAME"]] = $arComponent;
	}
}