public static function Delete($Params) { global $APPLICATION; $snPath = BX_PERSONAL_ROOT."/templates/".CFileMan::SecurePathVar($Params['template'])."/snippets"; $contPath = $_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($contPath."/.content.php")) { @include($contPath."/.content.php"); $contentSrc = '<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>'.chr(10); $contentSrc .= '<?'.chr(10).'$SNIPPETS = Array();'.chr(10); foreach ($SNIPPETS as $k=>$_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($contPath."/.content.php", $contentSrc); } CSnippets::ClearCache(); ?> <script> window.operation_success = true; </script> <? }
public static function GetGroupList($Params) { global $CACHE_MANAGER; $template = CFileMan::SecurePathVar($Params['template']); $arGroups = false; $CACHE_SNIPPETS = array(); if ($Params['bClearCache']) { CSnippets::ClearCache(); } $ttl = 30 * 24 * 60 * 60; // 30 days if ($CACHE_MANAGER->Read($ttl, "fileman_snippet_group")) { $CACHE_SNIPPETS = $CACHE_MANAGER->Get("fileman_snippet_group"); if (isset($CACHE_SNIPPETS[$template])) { $arGroups = $CACHE_SNIPPETS[$template]; } } if (!$arGroups || !is_array($arGroups)) { $arGroups = array(); CSnippets::InspectDir($arGroups, "", $template); $CACHE_SNIPPETS[$template] = $arGroups; $CACHE_MANAGER->Set("fileman_snippet_group", $CACHE_SNIPPETS); } return $arGroups; }
public static function GetGroupList($Params) { $template = CFileMan::SecurePathVar($Params['template']); $arGroups = false; $CACHE_SNIPPETS = Array(); if ($Params['bClearCache']) CSnippets::ClearCache(); if (!$arGroups || !is_array($arGroups)) { $arGroups = Array(); CSnippets::InspectDir($arGroups, "", $template); $CACHE_SNIPPETS[$template] = $arGroups; } return $arGroups; }
public static function RemoveCategory($params) { $res = false; if (is_array($params) && isset($params['path'])) { $path = CFileMan::SecurePathVar($params['path']); $template = isset($params['template']) && $params['template'] !== '' ? CFileMan::SecurePathVar($params['template']) : '.default'; $basePath = $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/" . $template . "/snippets"; $categoryPath = $basePath . '/' . $path; $io = CBXVirtualIo::GetInstance(); if ($io->DirectoryExists($categoryPath)) { $res = $io->Delete($categoryPath); } CSnippets::ClearCache(); } return $res; }