• Модуль: fileman
  • Путь к файлу: ~/bitrix/modules/fileman/classes/general/snippets.php
  • Класс: CSnippets
  • Вызов: CSnippets::Remove
static function Remove($params = array())
{
	global $APPLICATION;
	$res = false;
	$template = CFileMan::SecurePathVar($params['template']);
	$path = CFileMan::SecurePathVar($params["path"]);
	$basePath = self::GetBasePath($template);
	$snippetPath = $basePath.($path == '' ? '' : '/'.$path);

	$io = CBXVirtualIo::GetInstance();
	if (!$io->ValidatePathString('/'.$path) ||
		IsFileUnsafe($path) ||
		HasScriptExtension($path))
	{
		return false;
	}

	//Delete snippet file
	if($io->FileExists($snippetPath))
	{
		$res = $io->Delete($snippetPath);
	}

	$SNIPPETS = array();
	if ($io->FileExists($basePath."/.content.php"))
		@include($basePath."/.content.php");

	$contentSrc = ''.chr(10);
	$contentSrc .= ' $snip)
	{
		if($io->FileExists(CFileMan::SecurePathVar($basePath.'/'.$k)))
		{
			$contentSrc .= '$SNIPPETS[''.CUtil::addslashes($k).''] = Array(';

			if (isset($snip['title']) && $snip['title'] !== '')
			{
				$contentSrc .= ''title' => ''.Cutil::addslashes($snip['title']).''';
				if (isset($snip['description']) && $snip['description'] !== '')
					$contentSrc .= ', ';
			}
			if (isset($snip['description']) && $snip['description'] !== '')
			{
				$contentSrc .= ''description' => ''.Cutil::addslashes($snip['description']).''';
			}
			$contentSrc .= ');'.chr(10);
		}
	}
	$contentSrc .= '?>';
	$APPLICATION->SaveFileContent($basePath."/.content.php", $contentSrc);

	CSnippets::ClearCache();

	return $res;
}