• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/checklist.php
  • Класс: CAutoCheck
  • Вызов: CAutoCheck::CheckCustomComponents
static function CheckCustomComponents($arParams)
{
	$arResult["STATUS"] = false;
	$arComponentFolders = array(
		"/bitrix/components",
		"/local/components"
	);
	$components = array();
	foreach($arComponentFolders as $componentFolder)
	{
		if (file_exists($_SERVER['DOCUMENT_ROOT'].$componentFolder) && ($handle = opendir($_SERVER['DOCUMENT_ROOT'].$componentFolder)))
		{
			while (($file = readdir($handle)) !== false)
			{
				if ($file == "bitrix" || $file ==".." || $file == ".")
					continue;

				$dir = $componentFolder."/".$file;
				if (is_dir($_SERVER['DOCUMENT_ROOT'].$dir))
				{
					if(CComponentUtil::isComponent($dir))
					{
						$components[] = array(
							"path" => $dir,
							"name" => $file,
						);
					}
					elseif($comp_handle = opendir($_SERVER['DOCUMENT_ROOT'].$dir))
					{
						while (($subdir = readdir($comp_handle)) !== false)
						{
							if ($subdir == ".." || $subdir == "." || $subdir == ".svn")
								continue;

							if(CComponentUtil::isComponent($dir."/".$subdir))
							{
								$components[] = array(
									"path" => $dir."/".$subdir,
									"name" => $file.":".$subdir,
								);
							}
						}
						closedir($comp_handle);
					}
				}
			}
			closedir($handle);
		}
	}
	if (isset($arParams["ACTION"]) && $arParams["ACTION"] == "FIND")
	{
		foreach($components as $component)
		{
			$arResult["MESSAGE"]["DETAIL"] .= $component["name"]." n";
		}

		if ($arResult["MESSAGE"]["DETAIL"] == '')
		{
			$arResult["MESSAGE"]["PREVIEW"] = GetMessage("CL_HAVE_NO_CUSTOM_COMPONENTS");
		}
		else
		{
			$arResult = array(
				"STATUS" => true,
				"MESSAGE" => array(
					"PREVIEW" => GetMessage("CL_HAVE_CUSTOM_COMPONENTS")." (".count($components).")",
					"DETAIL" => $arResult["MESSAGE"]["DETAIL"]
				)
			);
		}
	}
	else
	{
		foreach($components as $component)
		{
			$desc = $_SERVER['DOCUMENT_ROOT'].$component["path"]."/.description.php";
			if (!file_exists($desc) || filesize($desc) === 0)
				$arResult["MESSAGE"]["DETAIL"] .= GetMessage("CL_EMPTY_DESCRIPTION")." ".$component["name"]." n";
		}

		if (!isset($arResult["MESSAGE"]["DETAIL"]) || $arResult["MESSAGE"]["DETAIL"] == '')
		{
			$arResult["STATUS"] = true;
			$arResult["MESSAGE"]["PREVIEW"] = GetMessage("CL_HAVE_CUSTOM_COMPONENTS_DESC");
		}
		else
		{
			$arResult = array(
				"STATUS" => false,
				"MESSAGE" => array(
					"PREVIEW" => GetMessage("CL_ERROR_FOUND_SHORT"),
					"DETAIL" => $arResult["MESSAGE"]["DETAIL"]
				)
			);
		}
	}
	return $arResult;
}