• Модуль: fileman
  • Путь к файлу: ~/bitrix/modules/fileman/classes/general/snippets.php
  • Класс: CSnippets
  • Вызов: CSnippets::Delete
static function Delete($Params)
{
	global $APPLICATION;

	$io = CBXVirtualIo::GetInstance();
	if($io->DirectoryExists($_SERVER["DOCUMENT_ROOT"]."/local/templates/".$Params['template']."/snippets"))
	{
		$snPath = "/local/templates/".$Params['template']."/snippets";
	}
	else
	{
		$snPath = BX_PERSONAL_ROOT."/templates/".$Params['template']."/snippets";
	}

	$basePath = $_SERVER["DOCUMENT_ROOT"].$snPath;
	$path = CFileMan::SecurePathVar($Params["path"]);
	$key = $Params["path"].($Params["path"] == '' ? '' : '/').CFileMan::SecurePathVar($Params["name"]);

	//Delete snippet file
	CFileman::DeleteFile(Array($Params["site"], $snPath.'/'.$key));

	//Delete thumbnail
	if ($Params["thumb"] != '')
	{
		CFileman::DeleteFile(Array($Params["site"], $snPath.'/images/'.$path.($path == '' ?  '' : '/').CFileMan::SecurePathVar($Params["thumb"])));
	}

	if (file_exists($basePath."/.content.php"))
	{
		@include($basePath."/.content.php");
		$contentSrc = ''.chr(10);
		$contentSrc .= '$_arSn)
		{
			if ($k != $key && CSnippets::CheckFile(array('site' => $Params["site"], 'template' => $Params['template'], 'path' => $k)))
				$contentSrc .= '$SNIPPETS[''.CUtil::JSEscape($k).''] = Array("title"=>''.CUtil::JSEscape($_arSn['title']).'', "description"=>''.CUtil::JSEscape($_arSn['description']).'');'.chr(10);
		}
		$contentSrc .= '?>';
		$APPLICATION->SaveFileContent($basePath."/.content.php", $contentSrc);
	}

	CSnippets::ClearCache();
?>