• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/wizard_site.php
  • Класс: CWizard
  • Вызов: CWizard::__GetTemplates
function __GetTemplates()
{
	$settingFile = $_SERVER["DOCUMENT_ROOT"].$this->path."/.templates.php";
	$arWizardTemplates = Array();
	if (is_file($settingFile))
	{
		$this->IncludeWizardLang(".templates.php");
		include($settingFile);
	}

	$relativePath = $this->__GetTemplatesPath();
	$absolutePath = $_SERVER["DOCUMENT_ROOT"].$relativePath;
	$absolutePath = str_replace("\", "/", $absolutePath);

	if ($handle  = @opendir($absolutePath))
	{
		while(($dirName = @readdir($handle)) !== false)
		{
			if ($dirName == "." || $dirName == ".." || !is_dir($absolutePath."/".$dirName))
				continue;

			$arTemplate = Array(
				"DESCRIPTION"=>"",
				"NAME" => $dirName,
			);

			if (file_exists($absolutePath."/".$dirName."/description.php"))
			{
				if (LANGUAGE_ID != "en" && LANGUAGE_ID != "ru")
				{
					if (file_exists(($fname = $absolutePath."/".$dirName."/lang/".LangSubst(LANGUAGE_ID)."/description.php")))
						__IncludeLang($fname, false, true);
				}

				if (file_exists(($fname = $absolutePath."/".$dirName."/lang/".LANGUAGE_ID."/description.php")))
						__IncludeLang($fname, false, true);

				include($absolutePath."/".$dirName."/description.php");
			}

			$arTemplate["ID"] = $dirName;
			$arTemplate["PATH"] = $this->path."/".$dirName;
			$arTemplate["SITE_ID"] = "";
			$arTemplate["SORT"] = 0;
			$arTemplate["GROUP_ID"] = "";

			if (file_exists($absolutePath."/".$dirName."/screen.gif"))
				$arTemplate["SCREENSHOT"] = $relativePath."/".$dirName."/screen.gif";
			else
				$arTemplate["SCREENSHOT"] = false;

			if (file_exists($absolutePath."/".$dirName."/preview.gif"))
				$arTemplate["PREVIEW"] = $relativePath."/".$dirName."/preview.gif";
			else
				$arTemplate["PREVIEW"] = false;

			if (array_key_exists("TEMPLATES", $arWizardTemplates) && array_key_exists($dirName, $arWizardTemplates["TEMPLATES"]))
				$arTemplate = array_merge($arTemplate, $arWizardTemplates["TEMPLATES"][$dirName]);

			$this->arTemplates[$arTemplate["ID"]] = $arTemplate;
		}
		closedir($handle);
	}

	uasort(
		$this->arTemplates,
		function ($a, $b) {
			return strcmp($a["SORT"], $b["SORT"]);
		}
	);

	if (array_key_exists("GROUPS", $arWizardTemplates) && is_array($arWizardTemplates["GROUPS"]))
		$this->arTemplateGroups = $arWizardTemplates["GROUPS"];
}