• Модуль: webdav
  • Путь к файлу: ~/bitrix/modules/webdav/classes/virtual.php
  • Класс: CWebDavVirtual
  • Вызов: CWebDavVirtual::IsDir
function IsDir($options = array(), $replace_symbols = false)
{
	global $DB;
	$options = (is_array($options) ? $options : array());
	$path = $this->_udecode(array_key_exists("path", $options) ? $options["path"] : $this->_path);

	foreach ($this->arStructure as $arNode)
	{
		if ($arNode['DEPTH_LEVEL'] == 0)
			$path = str_replace($arNode['NAME'], $arNode['PATH'], $path);
	}
	$path = str_replace(array('////', '///','//'),'/', $path);

	if (is_set($options, "section_id"))
		$path = $options["section_id"]; 
	elseif (is_set($options, "element_id"))
		$path = $options["element_id"]; 
	if (mb_substr($path, 0, 1) != "/")
		$path = "/".$path; 
	$id = md5($path);

	if (in_array($id, $this->CACHE))
	{
		$this->arParams = array_merge($this->arParams, $this->CACHE[$id]);
		return $this->arParams["is_dir"];
	}
	$path_copy = $path;
	
	$path = str_replace(array("////", "///", "//"), "/", $this->real_path_full."/".$path); 
	$params = array(
		"item_id" => "/", 
		"not_found" => false, 
		"is_dir" => false, 
		"is_file" => false, 
		"parent_id" => false, 
		"base_name" => mb_substr(strrchr($path, '/'), 1));
	
	$res = explode("/", $path_copy); 
	// only folders supported right now !
	$found = false;
	foreach ($this->arStructure as $nodeID => $arNode)
	{
		if ($arNode["PATH"] == $path) {
			$found = $nodeID;
			break;
		}
	}
	if ($found !== false)
	{
		$params["item_id"] = $path_copy;
		$params["is_dir"] = true;
		$res = explode('/', $this->arStructure[$found]['PATH']); 
		$name = array_pop($res);
		if ($name)
		{
			$params["dir_array"] = array(
				"ID" => $found, 
				"NAME" => $name);
			$params["parent_id"] = implode("/", $res); 
		}
	}
	else 
	{
		array_pop($res); 
		$params["not_found"] = true;
		$params["parent_id"] = implode("/", $res); 
	}
	
	$this->arParams = $params;
	$this->CACHE[$id] = $params;
	return $params["is_dir"];
}