• Модуль: webdav
  • Путь к файлу: ~/bitrix/modules/webdav/classes/iblock.php
  • Класс: CWebDavIblock
  • Вызов: CWebDavIblock::GetNavChain
function GetNavChain($options = array(), $for_url = false)
{
	static $nav_chain = array();
	$bReturn = (mb_strtoupper($for_url) === "ARRAY" ? "ARRAY" :
		($for_url === true ? "URL" : "SITE"));
	if (empty($options) && isset($this->arParams["dir_array"])) // === to deal with 0 at the root of IB
		$options["section_id"] = intval($this->arParams["dir_array"]["ID"]);
	elseif (isset($options['section_id']))
		$options['section_id'] = intval($options['section_id']);

	//mixin iblock id for symlinksection
	$dataCache = $options;
	$dataCache['IBLOCK_ID'] = $this->IBLOCK_ID;
	$dataCache['ROOT_SECTION_ID'] = empty($this->arRootSection['ID'])? 0 : $this->arRootSection['ID'];
	$id = md5(serialize($dataCache));
	if (!array_key_exists($id, $nav_chain))
	{
		if ($this->CACHE_OBJ && $this->CACHE_OBJ->InitCache($this->CACHE_TIME, $id, $this->CACHE_PATH."nav_chain"))
		{
			$nav_chain[$id] = $this->CACHE_OBJ->GetVars();
		}
		else
		{
			$options['check_permissions'] = false;
			$arObject = $this->GetObject($options);
			$nav_chain[$id] = array("URL" => array(), "SITE" => array(), "ARRAY" => array());
			if ($arObject["not_found"] == false && intval($arObject["item_id"]) > 0)
			{
				$arFile = array();
				$section_id = $arObject["item_id"];
				if ($arObject["is_file"])
				{
					$arFile = $arObject["element_array"];
					$section_id = $arFile["IBLOCK_SECTION_ID"];
					$sectionData = $this->getSectionDataForLinkAnalyze($arFile['IBLOCK_SECTION_ID'], array(
						'ID' => $arFile['IBLOCK_SECTION_ID'],
						'IBLOCK_ID' => $arObject['element_array']['IBLOCK_ID'],
					));
				}
				else
				{
					$sectionData = $this->getSectionDataForLinkAnalyze($arObject["item_id"], array(
						'ID' => $arObject["item_id"],
						'IBLOCK_ID' => empty($arObject['dir_array']['IBLOCK_ID'])? $this->IBLOCK_ID : $arObject['dir_array']['IBLOCK_ID'],
					));
				}

				//simple detect link
				list($contextType, $contextEntityId) = $this->getContextData();
				$isSymlink = !$this->_symlinkMode && CWebDavSymlinkHelper::isLink($contextType, $contextEntityId, $sectionData);
				if($isSymlink)
				{
					$symlinkSectionData = CWebDavSymlinkHelper::getLinkData($contextType, $contextEntityId, $sectionData);
				}

				if($this->_symlinkMode)
				{
					$bRootFounded = (empty($this->_symlinkRealRootSectionData) ? true : false);
					foreach (CWebDavSymlinkHelper::getNavChain($this->_symlinkSectionData['IBLOCK_ID'], $this->_symlinkSectionData['ID']) as $res)
					{
						$this->MetaNames($res);
						if (!$bRootFounded && $res["ID"] == $this->_symlinkRealRootSectionData["ID"])
						{
							$bRootFounded = true;
							continue;
						}
						if (!$bRootFounded)
							continue;

						$url = $this->_uencode($res["NAME"], array("utf8" => "Y", "convert" => "full"));
						$nav_chain[$id]["URL"][] = $url;
						$nav_chain[$id]["SITE"][] = $res["NAME"];
						$nav_chain[$id]["ARRAY"][] = ($res + array("URL" => $url));
					}
				}

				$iblockId = $this->IBLOCK_ID;
				$sectionId = $section_id;
				if($isSymlink)
				{
					$iblockId = $symlinkSectionData['IBLOCK_ID'];
					$sectionId = $symlinkSectionData['ID'];
				}
				$bRootFounded = (empty($this->arRootSection) ? true : false);
				foreach (CWebDavSymlinkHelper::getNavChain($iblockId, $sectionId) as $res)
				{
					$this->MetaNames($res);
					if (!$bRootFounded && $res["ID"] == $this->arRootSection["ID"])
					{
						$bRootFounded = true;
						continue;
					}
					if (!$bRootFounded)
						continue;

					$url = $this->_uencode($res["NAME"], array("utf8" => "Y", "convert" => "full"));
					$nav_chain[$id]["URL"][] = $url;
					$nav_chain[$id]["SITE"][] = $res["NAME"];
					$nav_chain[$id]["ARRAY"][] = ($res + array("URL" => $url));
				}

				if($isSymlink)
				{
					$bRootFounded = (empty($symlinkSectionData[self::UF_LINK_SECTION_ID]) ? true : false);
					foreach (CWebDavSymlinkHelper::getNavChain($symlinkSectionData[self::UF_LINK_IBLOCK_ID], $section_id) as $res)
					{
						$this->MetaNames($res);
						if (!$bRootFounded && $res["ID"] == $symlinkSectionData[self::UF_LINK_SECTION_ID])
						{
							$bRootFounded = true;
							continue;
						}
						if (!$bRootFounded)
							continue;

						$url = $this->_uencode($res["NAME"], array("utf8" => "Y", "convert" => "full"));
						$nav_chain[$id]["URL"][] = $url;
						$nav_chain[$id]["SITE"][] = $res["NAME"];
						$nav_chain[$id]["ARRAY"][] = ($res + array("URL" => $url));
					}
				}

				if (!empty($arFile))
				{
					$url = $this->_uencode($res["NAME"], array("utf8" => "Y", "convert" => "full"));
					$nav_chain[$id]["URL"][] = $url;
					$nav_chain[$id]["SITE"][] = $arFile["NAME"];
					$nav_chain[$id]["ARRAY"][] = ($arFile + array("URL" => $url));
				}
			}
			if ($this->CACHE_OBJ)
			{
				$this->CACHE_OBJ->StartDataCache($this->CACHE_TIME, $id, $this->CACHE_PATH."_nav_chain");
				$this->CACHE_OBJ->EndDataCache($nav_chain[$id]);
			}
		}
	}
	$res = $nav_chain[$id][$bReturn];
	return (is_array($res) ? $res : array());
}