• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/file_dialog.php
  • Класс: CAdminFileDialog
  • Вызов: CAdminFileDialog::GetItems
static function GetItems($Params)
{
	global $APPLICATION, $USER;
	static $checkChildren, $genTmb;

	if (!isset($checkChildren, $genTmb))
	{
		$checkChildren = COption::GetOptionString("fileman", "file_dialog_check_children", "Y") == 'Y';
		$genTmb = COption::GetOptionString("fileman", "file_dialog_gen_thumb", "Y") == 'Y';
	}

	if(mb_strlen($Params["site"]) > 2)
	{
		if (!$USER->CanDoOperation('clouds_browse'))
		{
			$APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_ACCESS_DENIED'), 'access_denied');
			return;
		}

		if($Params['operation'] !== 'O')
		{
			$APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT').' [clouds 04]', 'path_corrupt');
			return;
		}

		if(!CModule::IncludeModule('clouds'))
		{
			$APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT').' [clouds 01]', 'path_corrupt');
			return;
		}

		$obBucket = null;
		foreach(CCloudStorageBucket::GetAllBuckets() as $arBucket)
		{
			if($arBucket["ACTIVE"] == "Y" && $arBucket["BUCKET"] === $Params["site"])
				$obBucket = new CCloudStorageBucket($arBucket["ID"]);
		}

		if(!$obBucket)
		{
			$APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT').' [clouds 02]', 'path_corrupt');
			return;
		}

		if(!$obBucket->Init())
		{
			$APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT').' [clouds 03]', 'path_corrupt');
			return;
		}

		$path = preg_replace("#[\\\/]+#", "/", "/".$APPLICATION->UnJSEscape($Params['path']));
		$path_js = $path == "" ? "/" : addslashes(htmlspecialcharsex($path));
		$path_js = str_replace("//", "/", $path_js);

		$arFiles = $obBucket->ListFiles($path);
		if(!is_array($arFiles))
		{
			$APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT').' [clouds 05]', 'path_corrupt');
			return;
		}
?>
arFDDirs[''] = [];
arFDFiles[''] = [];
 $dir)
		{
?>
arFDDirs[''][] =
{
name : '',
path : '',
empty: false,
permission : {del : false, ren : false},
date : '',
timestamp : '',
size : 0
};
 $file)
			{
?>
arFDFiles[''][] =
{
name : '',
path : 'GetFileSRC($path."/".$file))?>',
permission : {del : false, ren : false},
date : '',
timestamp : '',
size : ''
};

arFDPermission[''] = {
new_folder : false,
upload : false
};
CombinePath("/", $APPLICATION->UnJSEscape($Params['path']));
	$path_js = $path == "" ? "/" : addslashes(htmlspecialcharsex($path));
	$path_js = str_replace("//", "/", $path_js);
	$bCheckEmpty = $Params['bCheckEmpty'];

	$rootPath = CSite::GetSiteDocRoot($site);
	if (!$io->FileExists($rootPath.$path) && !$io->DirectoryExists($rootPath.$path) && $Params['bThrowException'] === true)
	{
		$APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT'), 'path_corrupt');
		return;
	}
	elseif (!$USER->CanDoFileOperation('fm_view_listing', array($site, $path)))
	{
		$APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_ACCESS_DENIED'), 'access_denied');
		return;
	}

	$arDirs = array(); $arFiles = array();
	GetDirList(array($site, $path), $arDirs, $arFiles, array(), array("name_nat" => "asc"), "DF", false, true);
?>
arFDDirs[''] = [];
arFDFiles[''] = [];
CanDoFileOperation('fm_view_listing', $arPath_i))
			continue;
		$ind++;

		$empty = true;
		if ($bCheckEmpty) // Find subfolders inside
		{
			$dirTmp = $io->GetDirectory($rootPath.$path.'/'.$name);
			$arDirTmpChildren = $dirTmp->GetChildren();
			foreach ($arDirTmpChildren as $child)
			{
				if(!$child->IsDirectory())
					continue;
				$empty = false;
				break;
			}
		}
		$perm_del = $USER->CanDoFileOperation('fm_delete_folder', $arPath_i) ? 'true' : 'false';
		$perm_ren = $USER->CanDoFileOperation('fm_rename_folder', $arPath_i) ? 'true' : 'false';

?>
arFDDirs[''][] =
{
name : '',
path : '',
empty: ,
permission : {del : , ren : },
date : '',
timestamp : '',
size : 0
};
CanDoFileOperation('fm_view_file', $arPath_i))
				continue;
			$ind++;

			$perm_del = $USER->CanDoFileOperation('fm_delete_file', $arPath_i) ? 'true' : 'false';
			$perm_ren = $USER->CanDoFileOperation('fm_rename_file', $arPath_i) ? 'true' : 'false';

			$imageAddProps = '';
			if ($genTmb)
			{
				$ext = mb_strtolower(GetFileExtension($name));
				if (in_array($ext, array('gif','jpg','jpeg','png','jpe','bmp'))) // It is image
				{
					$upload_dir = COption::GetOptionString("main", "upload_dir", "upload");
					$tmbPath = "/".$upload_dir."/tmp/fd_tmb".$path_i;
					$destinationFile = $rootPath.$tmbPath;
					if (!file_exists($destinationFile))
					{
						$sourceFile = $File['PATH'];
						if (CFile::ResizeImageFile($sourceFile, $destinationFile, array('width' => 140, 'height' => 110)))
							$imageAddProps = ",n".'tmb_src : ''.CUtil::JSEscape($tmbPath).''';
					}
					else
						$imageAddProps = ",n".'tmb_src : ''.CUtil::JSEscape($tmbPath).''';
				}
			}
?>
arFDFiles[''][] =
{
name : '',
path : '',
permission : {del : , ren : },
date : '',
timestamp : '',
size : ''
};

arFDPermission[''] = {
new_folder : CanDoFileOperation('fm_create_new_folder',$arPath) ? 'true' : 'false');?>,
upload : CanDoFileOperation('fm_upload_file',$arPath) ? 'true' : 'false');?>
};