本文整理汇总了PHP中CComponentUtil::__BuildTree方法的典型用法代码示例。如果您正苦于以下问题:PHP CComponentUtil::__BuildTree方法的具体用法?PHP CComponentUtil::__BuildTree怎么用?PHP CComponentUtil::__BuildTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComponentUtil
的用法示例。
在下文中一共展示了CComponentUtil::__BuildTree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __GetComponentsTree
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) {
//.........这里部分代码省略.........
示例2: __GetComponentsTree
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";
//.........这里部分代码省略.........