public static function __GetComponentsTree($filterNamespace = false, $arNameFilter = false) { $arTree = array(); $io = CBXVirtualIo::GetInstance(); $folders = array("/local/components", "/bitrix/components"); foreach ($folders as $componentFolder) { if ($handle = @opendir($_SERVER["DOCUMENT_ROOT"] . $componentFolder)) { while (($file = readdir($handle)) !== false) { if ($file == "." || $file == "..") { continue; } if (is_dir($_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file)) { if (CComponentUtil::isComponent($componentFolder . "/" . $file)) { // It's component if ($filterNamespace !== false && strlen($filterNamespace) > 0) { continue; } if ($arNameFilter !== false && !CComponentUtil::CheckComponentName($file, $arNameFilter)) { continue; } if (file_exists($_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file . "/.description.php")) { CComponentUtil::__IncludeLang($componentFolder . "/" . $file, ".description.php"); $arComponentDescription = array(); include $_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file . "/.description.php"; if (array_key_exists("PATH", $arComponentDescription) && array_key_exists("ID", $arComponentDescription["PATH"])) { $arComponent = array(); $arComponent["NAME"] = $file; $arComponent["NAMESPACE"] = ""; $arComponent["TITLE"] = trim($arComponentDescription["NAME"]); $arComponent["DESCRIPTION"] = $arComponentDescription["DESCRIPTION"]; if (array_key_exists("ICON", $arComponentDescription)) { $arComponentDescription["ICON"] = ltrim($arComponentDescription["ICON"], "/"); if ($arComponentDescription["ICON"] != "" && $io->FileExists($io->RelativeToAbsolutePath($componentFolder . "/" . $file . "/" . $arComponentDescription["ICON"]))) { $arComponent["ICON"] = $componentFolder . "/" . $file . "/" . $arComponentDescription["ICON"]; } else { $arComponent["ICON"] = "/bitrix/images/fileman/htmledit2/component.gif"; } } if (array_key_exists("COMPLEX", $arComponentDescription) && $arComponentDescription["COMPLEX"] == "Y") { $arComponent["COMPLEX"] = "Y"; } else { $arComponent["COMPLEX"] = "N"; } $arComponent["SORT"] = IntVal($arComponentDescription["SORT"]); if ($arComponent["SORT"] <= 0) { $arComponent["SORT"] = 100; } $arComponent["SCREENSHOT"] = array(); if (array_key_exists("SCREENSHOT", $arComponentDescription)) { if (!is_array($arComponentDescription["SCREENSHOT"])) { $arComponentDescription["SCREENSHOT"] = array($arComponentDescription["SCREENSHOT"]); } for ($i = 0, $cnt = count($arComponentDescription["SCREENSHOT"]); $i < $cnt; $i++) { $arComponent["SCREENSHOT"][] = $componentFolder . "/" . $file . $arComponentDescription["SCREENSHOT"][$i]; } } CComponentUtil::__BuildTree($arComponentDescription["PATH"], $arTree, $arComponent); } } } else { // It's not a component if ($filterNamespace !== false && (strlen($filterNamespace) <= 0 || $filterNamespace != $file)) { continue; } if ($handle1 = @opendir($_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file)) { while (($file1 = readdir($handle1)) !== false) { if ($file1 == "." || $file1 == "..") { continue; } if (is_dir($_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file . "/" . $file1)) { if (CComponentUtil::isComponent($componentFolder . "/" . $file . "/" . $file1)) { if ($arNameFilter !== false && !CComponentUtil::CheckComponentName($file1, $arNameFilter)) { continue; } // It's component if (file_exists($_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file . "/" . $file1 . "/.description.php")) { CComponentUtil::__IncludeLang($componentFolder . "/" . $file . "/" . $file1, ".description.php"); $arComponentDescription = array(); include $_SERVER["DOCUMENT_ROOT"] . $componentFolder . "/" . $file . "/" . $file1 . "/.description.php"; if (array_key_exists("PATH", $arComponentDescription) && array_key_exists("ID", $arComponentDescription["PATH"])) { $arComponent = array(); $arComponent["NAME"] = $file . ":" . $file1; $arComponent["NAMESPACE"] = $file; $arComponent["TITLE"] = trim($arComponentDescription["NAME"]); $arComponent["DESCRIPTION"] = $arComponentDescription["DESCRIPTION"]; if (array_key_exists("ICON", $arComponentDescription)) { $arComponentDescription["ICON"] = ltrim($arComponentDescription["ICON"], "/"); if ($arComponentDescription["ICON"] != "" && $io->FileExists($io->RelativeToAbsolutePath($componentFolder . "/" . $file . "/" . $file1 . "/" . $arComponentDescription["ICON"]))) { $arComponent["ICON"] = $componentFolder . "/" . $file . "/" . $file1 . "/" . $arComponentDescription["ICON"]; } else { $arComponent["ICON"] = "/bitrix/images/fileman/htmledit2/component.gif"; } } if (array_key_exists("COMPLEX", $arComponentDescription) && $arComponentDescription["COMPLEX"] == "Y") { $arComponent["COMPLEX"] = "Y"; } else { $arComponent["COMPLEX"] = "N"; } $arComponent["SORT"] = IntVal($arComponentDescription["SORT"]); if ($arComponent["SORT"] <= 0) { $arComponent["SORT"] = 100; } $arComponent["SCREENSHOT"] = array(); if (array_key_exists("SCREENSHOT", $arComponentDescription)) { if (!is_array($arComponentDescription["SCREENSHOT"])) { $arComponentDescription["SCREENSHOT"] = array($arComponentDescription["SCREENSHOT"]); } for ($i = 0, $cnt = count($arComponentDescription["SCREENSHOT"]); $i < $cnt; $i++) { $arComponent["SCREENSHOT"][] = $componentFolder . "/" . $file . "/" . $file1 . $arComponentDescription["SCREENSHOT"][$i]; } } CComponentUtil::__BuildTree($arComponentDescription["PATH"], $arTree, $arComponent); } } } } } @closedir($handle1); } } } } @closedir($handle); } } return $arTree; }
function __GetComponentsTree($filterNamespace = False, $arNameFilter = False) { $arTree = array(); if ($handle = @opendir($_SERVER["DOCUMENT_ROOT"]."/bitrix/components")) { while (($file = readdir($handle)) !== false) { if ($file == "." || $file == "..") continue; if (is_dir($_SERVER["DOCUMENT_ROOT"]."/bitrix/components/".$file)) { if (CComponentUtil::isComponent("/bitrix/components/".$file)) { // It's component if ($filterNamespace !== False && StrLen($filterNamespace) > 0) continue; if ($arNameFilter !== False && !CComponentUtil::CheckComponentName($file, $arNameFilter)) continue; if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/components/".$file."/.description.php")) { CComponentUtil::__IncludeLang("/bitrix/components/".$file, ".description.php"); $arComponentDescription = array(); $componentName = $file; include($_SERVER["DOCUMENT_ROOT"]."/bitrix/components/".$file."/.description.php"); if (array_key_exists("PATH", $arComponentDescription) && array_key_exists("ID", $arComponentDescription["PATH"])) { $arComponent = array(); $arComponent["NAME"] = $file; $arComponent["NAMESPACE"] = ""; $arComponent["TITLE"] = Trim($arComponentDescription["NAME"]); $arComponent["DESCRIPTION"] = $arComponentDescription["DESCRIPTION"]; if (array_key_exists("ICON", $arComponentDescription)) $arComponent["ICON"] = "/bitrix/components/".$file.$arComponentDescription["ICON"]; if (array_key_exists("COMPLEX", $arComponentDescription) && $arComponentDescription["COMPLEX"] == "Y") $arComponent["COMPLEX"] = "Y"; else $arComponent["COMPLEX"] = "N"; $arComponent["SORT"] = IntVal($arComponentDescription["SORT"]); if ($arComponent["SORT"] <= 0) $arComponent["SORT"] = 100; $arComponent["SCREENSHOT"] = array(); if (array_key_exists("SCREENSHOT", $arComponentDescription)) { if (!is_array($arComponentDescription["SCREENSHOT"])) $arComponentDescription["SCREENSHOT"] = array($arComponentDescription["SCREENSHOT"]); for ($i = 0, $cnt = count($arComponentDescription["SCREENSHOT"]); $i < $cnt; $i++) $arComponent["SCREENSHOT"][] = "/bitrix/components/".$file.$arComponentDescription["SCREENSHOT"][$i]; } CComponentUtil::__BuildTree($arComponentDescription["PATH"], $arTree, $arComponent); } } } else { // It's not a component if ($filterNamespace !== False && (StrLen($filterNamespace) <= 0 || $filterNamespace != $file)) continue; if ($handle1 = @opendir($_SERVER["DOCUMENT_ROOT"]."/bitrix/components/".$file)) { while (($file1 = readdir($handle1)) !== false) { if ($file1 == "." || $file1 == "..") continue; if (is_dir($_SERVER["DOCUMENT_ROOT"]."/bitrix/components/".$file."/".$file1)) { if (CComponentUtil::isComponent("/bitrix/components/".$file."/".$file1)) { if ($arNameFilter !== False && !CComponentUtil::CheckComponentName($file1, $arNameFilter)) continue; // It's component if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/components/".$file."/".$file1."/.description.php")) { CComponentUtil::__IncludeLang("/bitrix/components/".$file."/".$file1, ".description.php"); $arComponentDescription = array(); $componentName = $file.":".$file1; include($_SERVER["DOCUMENT_ROOT"]."/bitrix/components/".$file."/".$file1."/.description.php"); if (array_key_exists("PATH", $arComponentDescription) && array_key_exists("ID", $arComponentDescription["PATH"])) { $arComponent = array(); $arComponent["NAME"] = $file.":".$file1; $arComponent["NAMESPACE"] = $file; $arComponent["TITLE"] = Trim($arComponentDescription["NAME"]); $arComponent["DESCRIPTION"] = $arComponentDescription["DESCRIPTION"]; if (array_key_exists("ICON", $arComponentDescription)) $arComponent["ICON"] = "/bitrix/components/".$file."/".$file1.$arComponentDescription["ICON"]; if (array_key_exists("COMPLEX", $arComponentDescription) && $arComponentDescription["COMPLEX"] == "Y") $arComponent["COMPLEX"] = "Y"; else $arComponent["COMPLEX"] = "N"; $arComponent["SORT"] = IntVal($arComponentDescription["SORT"]); if ($arComponent["SORT"] <= 0) $arComponent["SORT"] = 100; $arComponent["SCREENSHOT"] = array(); if (array_key_exists("SCREENSHOT", $arComponentDescription)) { if (!is_array($arComponentDescription["SCREENSHOT"])) $arComponentDescription["SCREENSHOT"] = array($arComponentDescription["SCREENSHOT"]); for ($i = 0, $cnt = count($arComponentDescription["SCREENSHOT"]); $i < $cnt; $i++) $arComponent["SCREENSHOT"][] = "/bitrix/components/".$file."/".$file1.$arComponentDescription["SCREENSHOT"][$i]; } CComponentUtil::__BuildTree($arComponentDescription["PATH"], $arTree, $arComponent); } } } } } @closedir($handle1); } } } } @closedir($handle); } return $arTree; }