• Модуль: fileman
  • Путь к файлу: ~/bitrix/modules/fileman/classes/general/snippets.php
  • Класс: CSnippets
  • Вызов: CSnippets::CreateCategory
static function CreateCategory($params = array())
{
	$res = false;
	if (is_array($params) && isset($params['name']))
	{
		$name = CFileMan::SecurePathVar($params['name']);
		$template = (isset($params['template']) && $params['template'] !== '') ? CFileMan::SecurePathVar($params['template']) : '.default';
		$basePath = self::GetBasePath($template);
		$templatePath = mb_substr($basePath, 0, -9);

		$io = CBXVirtualIo::GetInstance();
		if($io->DirectoryExists($templatePath))
		{
			if(!$io->DirectoryExists($basePath))
			{
				$io->CreateDirectory($basePath);
			}

			$parentPath = (isset($params['parent']) && $params['parent'] !== '') ? '/'.CFileMan::SecurePathVar($params['parent']) : '';
			$categoryPath = $basePath.$parentPath.'/'.$name;
			if (!$io->DirectoryExists($categoryPath))
			{
				$res = $io->CreateDirectory($categoryPath);
			}
		}
		CSnippets::ClearCache();
	}
	return $res;
}