<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<?if (!empty($arResult)):?>
<? $parentsMap = array(); ?>
<div class="menu-sitemap-tree">
<ul>
<?$previousLevel = 0;foreach($arResult as $arItem):?>
<? $tmp = split('SECTION_ID=',$arItem["LINK"]); $thisID = $tmp[1]; ?>
<? if ($previousLevel < $arItem["DEPTH_LEVEL"]) {
$parentsMap[$thisID]=$previousID;
} elseif ($previousLevel == $arItem["DEPTH_LEVEL"]) {
$parentsMap[$thisID]=$parentsMap[$previousID];
} else {
$diff = $previousLevel - $arItem["DEPTH_LEVEL"]; $i=0;
$prevParent = $parentsMap[$previousID];
while ($i<$diff)
{
$prevParent = $parentsMap[$prevParent];
$i++;
}
$parentsMap[$thisID] = $prevParent;
}
?>
<? if ($arItem["IS_PARENT"]) $parentID = $thisID; ?>
<?if ($previousLevel && $arItem["DEPTH_LEVEL"] < $previousLevel):?>
<?=str_repeat("</ul></li>", ($previousLevel - $arItem["DEPTH_LEVEL"]));?>
<?endif?>
<?if ($arItem["IS_PARENT"]):?>
<li class="close">
<div class="folder" onClick="OpenMenuNode(this)" id="FLD<? echo $thisID; ?>"></div>
<div class="item-text"><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a></div>
<ul>
<?else:?>
<?if ($arItem["PERMISSION"] > "D"):?>
<li>
<div class="page"></div>
<div class="item-text"><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a></div>
</li>
<?endif?>
<?endif?>
<? if ($GLOBALS["SECTION_ID"]==$thisID):?>
<? $cPar = $thisID; $que = array(); ?>
<? while ($parentsMap[$cPar])
{
$cPar=$parentsMap[$cPar];
$que[]=$cPar;
}
$que = array_reverse($que);
foreach ($que as $elm)
{
?><script> OpenMenuNode(document.getElementById("FLD<? echo $elm; ?>")); </script><?
} ?>
<?endif ?>
<?$previousLevel = $arItem["DEPTH_LEVEL"];?>
<?$previousID = $thisID;?>
<?endforeach?>
<?if ($previousLevel > 1)://close last item tags?>
<?=str_repeat("</ul></li>", ($previousLevel-1) );?>
<?endif?>
</ul>
</div>
<?endif?> |