• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/site_template.php
  • Класс: CSiteTemplate
  • Вызов: CSiteTemplate::DirsRecursive
static function DirsRecursive($ID, $path="", $depth=0, $maxDepth=1)
{
	$arRes = array();
	$depth++;

	$templPath = getLocalPath("templates/".$ID, BX_PERSONAL_ROOT);
	if($templPath === false)
	{
		return $arRes;
	}

	GetDirList($templPath."/".$path, $arDirsTmp, $arResTmp);

	foreach($arResTmp as $file)
	{
		switch($file["NAME"])
		{
			case "chain_template.php":
				$file["DESCRIPTION"] = GetMessage("MAIN_TEMPLATE_NAV");
				break;
			case "":
				$file["DESCRIPTION"] = "";
				break;
			default:
				if(($p = mb_strpos($file["NAME"], ".menu_template.php"))!==false)
					$file["DESCRIPTION"] = str_replace("#MENU_TYPE#", mb_substr($file["NAME"], 0, $p), GetMessage("MAIN_TEMPLATE_MENU"));
				elseif(($p = mb_strpos($file["NAME"], "authorize_registration.php"))!==false)
					$file["DESCRIPTION"] = GetMessage("MAIN_TEMPLATE_AUTH_REG");
				elseif(($p = mb_strpos($file["NAME"], "forgot_password.php"))!==false)
					$file["DESCRIPTION"] = GetMessage("MAIN_TEMPLATE_SEND_PWD");
				elseif(($p = mb_strpos($file["NAME"], "change_password.php"))!==false)
					$file["DESCRIPTION"] = GetMessage("MAIN_TEMPLATE_CHN_PWD");
				elseif(($p = mb_strpos($file["NAME"], "authorize.php"))!==false)
					$file["DESCRIPTION"] = GetMessage("MAIN_TEMPLATE_AUTH");
				elseif(($p = mb_strpos($file["NAME"], "registration.php"))!==false)
					$file["DESCRIPTION"] = GetMessage("MAIN_TEMPLATE_REG");
		}
		$arRes[] = $file;
	}

	$nTemplateLen = mb_strlen($templPath."/");
	foreach($arDirsTmp as $dir)
	{
		$arDir = $dir;
		$arDir["DEPTH_LEVEL"] = $depth;
		$arRes[] = $arDir;

		if($depth < $maxDepth)
		{
			$dirPath = mb_substr($arDir["ABS_PATH"], $nTemplateLen);
			$arRes = array_merge($arRes, CSiteTemplate::DirsRecursive($ID, $dirPath, $depth, $maxDepth));
		}
	}
	return $arRes;
}