• Модуль: webdav
  • Путь к файлу: ~/bitrix/modules/webdav/classes/file.php
  • Класс: CWebDavFile
  • Вызов: CWebDavFile::IsDir
function IsDir($options = array())
{
	global $DB;
	$io = self::GetIo();
	$options = (is_array($options) ? $options : array());
	$path = $this->_udecode(array_key_exists("path", $options) ? $options["path"] : $this->_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;

	$path = $this->MetaNamesReverse(explode("/", $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 = $io->CombinePath("/", $path);
	if(!$io->ValidatePathString($path))
	{
		return false;
	}
	$path_copy = $path;

	$path = $io->CombinePath($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 = array_filter(explode("/", $path_copy));
	if ($io->DirectoryExists($path))
	{
		$params["item_id"] = $path_copy;
		$params["is_dir"] = true;
		$name = array_pop($res);
		if ($name)
		{
			$params["dir_array"] = array(
				"ID" => $params["item_id"],
				"IBLOCK_SECTION_ID" => implode("/", $res),
				"NAME" => $name
			);
			$params["parent_id"] = implode("/", $res);
		}
	}
	elseif ($io->FileExists($path))
	{
		$ioFile = $io->GetFile($path);
		$params["item_id"] = $path_copy;
		$params["is_file"] = true;
		$params["element_array"] = array(
			"ID" => $params["item_id"],
			"NAME" => array_pop($res),
			"TIMESTAMP_X" => $ioFile->GetModificationTime() + CTimeZone::GetOffset()
		);

		$params["element_array"]["EXTENTION"] = mb_strtolower(strrchr($params["element_array"]["NAME"], '.'));
		if ($params["element_array"]["EXTENTION"] == $params["element_array"]["NAME"])
			$params["element_array"]["EXTENTION"] = "";

		$params["parent_id"] = implode("/", $res);
		$params["element_name"] = $params["element_array"]["NAME"];
		$params["file_name"] = $params["element_array"]["NAME"];
		$params["file_extention"] = mb_strtolower(strrchr($params["element_array"]["NAME"], '.'));
	}
	else
	{
		array_pop($res);
		$params["not_found"] = true;
		$params["parent_id"] = '/'.implode("/", $res);
	}

	$params["element_array"]["SHOW"] = ($this->permission >= "W" ? array("EDIT" => "Y", "DELETE" => "Y") : array());

	if ($params["parent_id"])
	{
		$params["parent_id"] = $this->_slashify($io->CombinePath("/", $params["parent_id"]));
	}

	$this->arParams = $params;
	$this->CACHE[$id] = $params;
	return $params["is_dir"];
}