• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/templates.php
  • Класс: CTemplates
  • Вызов: CTemplates::GetFolderList
static function GetFolderList($template_id = false)
{
	$arTemplateFolders = array();
	$arTemplateFoldersSort = array();
	$path = "/bitrix/modules";
	if($handle = @opendir($_SERVER["DOCUMENT_ROOT"].$path))
	{
		while(($module_name = readdir($handle)) !== false)
		{
			if($module_name == "." || $module_name == "..") continue;
			if(is_dir($_SERVER["DOCUMENT_ROOT"].$path."/".$module_name))
			{
				$path_mod = $path."/".$module_name."/install/templates";
				if(file_exists($_SERVER["DOCUMENT_ROOT"].$path_mod))
				{
					if($handle_mod = @opendir($_SERVER["DOCUMENT_ROOT"].$path_mod))
					{
						while(($file_templ = readdir($handle_mod)) !== false)
						{
							if($file_templ == "." || $file_templ == ".." || $file_templ=="lang")
								continue;
							if(is_dir($_SERVER["DOCUMENT_ROOT"].$path_mod."/".$file_templ))
							{
								$sSectionName = false;
								$iSort = 500;
								if(file_exists($_SERVER["DOCUMENT_ROOT"].$path_mod."/".$file_templ."/.description.php"))
								{
									if(file_exists(($fname = $_SERVER["DOCUMENT_ROOT"].$path_mod."/lang/".LangSubst(LANGUAGE_ID)."/".$module_name."/.description.php")))
										__IncludeLang($fname);
									if(LANGUAGE_ID <> "ru" && file_exists(($fname = $_SERVER["DOCUMENT_ROOT"].$path_mod."/lang/".LANGUAGE_ID."/".$module_name."/.description.php")))
										__IncludeLang($fname);
									include($_SERVER["DOCUMENT_ROOT"].$path_mod."/".$file_templ."/.description.php");
								}
								if($sSectionName)
								{
									$arTemplateFolders[$module_name] = $sSectionName;
									$arTemplateFoldersSort[$module_name] = $iSort;
								}
							}
						}
						@closedir($handle_mod);
					}
				}
			}
		}
		@closedir($handle);
	}

	$arPath = array(BX_PERSONAL_ROOT."/templates/.default");
	if($template_id)
		$arPath[] = BX_PERSONAL_ROOT."/templates/".$template_id;

	foreach($arPath as $path)
	{
		if($handle = @opendir($_SERVER["DOCUMENT_ROOT"].$path))
		{
			while(($folder_name = readdir($handle)) !== false)
			{
				if($folder_name == "." || $folder_name == ".." || $folder_name=="lang")
					continue;
				if(is_dir($_SERVER["DOCUMENT_ROOT"].$path."/".$folder_name))
				{
					$sSectionName = false;
					$iSort = 500;
					if(file_exists($_SERVER["DOCUMENT_ROOT"].$path."/".$folder_name."/.description.php"))
						include($_SERVER["DOCUMENT_ROOT"].$path."/".$folder_name."/.description.php");
					if($sSectionName)
					{
						$arTemplateFolders[$folder_name] = $sSectionName;
						$arTemplateFoldersSort[$folder_name] = $iSort;
					}
				}
			}
			@closedir($handle);
		}
	}
	array_multisort($arTemplateFoldersSort, $arTemplateFolders);

	return $arTemplateFolders;
}