• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/vk/sectionslist.php
  • Класс: BitrixSaleTradingPlatformVkSectionsList
  • Вызов: SectionsList::sortMapElementItems
static function sortMapElementItems($sectionsFormatted)
{
	$sectionsSorted = array();
	foreach ($sectionsFormatted as $albumKey => $album)
	{
		if (!empty($album["ITEMS"]))
		{
			ksort($album["ITEMS"]);
//				add tabs to name, by depth level. Can't use base DEPTH_LEVEL, need rematch
			$prevDepthLevel = false;
			$tabsCount = 0;
			foreach ($album["ITEMS"] as &$item)
			{
				if (!$prevDepthLevel)
				{
					$prevDepthLevel = $item["DEPTH_LEVEL"];
				}    //first item
				if ($item["DEPTH_LEVEL"] > $prevDepthLevel)
				{
					$tabsCount++;
					$prevDepthLevel = $item["DEPTH_LEVEL"];
				}
				elseif ($item["DEPTH_LEVEL"] < $prevDepthLevel)
				{
					$tabsCount--;
					$prevDepthLevel = $item["DEPTH_LEVEL"];
				}
				$item["NAME"] = str_repeat('- ', $tabsCount) . $item["NAME"];
			}
		}

		$sectionsSorted[$albumKey] = $album;
	}

	return $sectionsSorted;
}