1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
snippets.php
См. документацию.
1<?php
2
4{
5 public static function LoadList($Params)
6 {
7 global $CACHE_MANAGER;
8
9 $template = CFileMan::SecurePathVar($Params["template"]);
10 if ($template == '')
11 $template = '.default';
12
13 $arSNIPPETS = false;
14 $CACHE_SNIPPETS = Array();
15
16 if ($Params['bClearCache'])
18
19 $ttl = 30 * 24 * 60 * 60; // 30 days
20 if($CACHE_MANAGER->Read($ttl, "fileman_snippet_array"))
21 {
22 $CACHE_SNIPPETS = $CACHE_MANAGER->Get("fileman_snippet_array");
23 if (isset($CACHE_SNIPPETS[$template]))
24 $arSNIPPETS = $CACHE_SNIPPETS[$template];
25 }
26
27 if (!$arSNIPPETS || !is_array($arSNIPPETS))
28 {
29 $arSNIPPETS = Array();
30 $arTemplateKeys = Array(); //Array contain keys of snippets for each template for correct writing .content.php
31
32 CSnippets::HandleForTemplate('.default', $arSNIPPETS, $arTemplateKeys);
33 if ($template != '.default')
34 CSnippets::HandleForTemplate($template, $arSNIPPETS, $arTemplateKeys);
35
36 $CACHE_SNIPPETS[$template] = $arSNIPPETS;
37 $CACHE_MANAGER->Set("fileman_snippet_array", $CACHE_SNIPPETS);
38 }
39
40 if ($Params['returnArray'] ?? null)
41 {
42 return $arSNIPPETS;
43 }
44 else
45 {
46 ?><script>window.arSnippets = <?= CUtil::PhpToJSObject($arSNIPPETS)?>; </script><?
47 }
48 }
49
50 public static function HandleForTemplate($template, &$arSNIPPETS, &$arTemplateKeys)
51 {
52 $arTemplateKeys[$template] = Array();
53 CSnippets::ReadDir($arSNIPPETS, $arTemplateKeys[$template], "", $template);
54
55 if (count($arSNIPPETS) > 0)
56 CSnippets::UpdateContentInfo($arSNIPPETS, $arTemplateKeys[$template], $template);
57 }
58
59 public static function ReadDir(&$arSNIPPETS, &$arKeys, $path, $template, $level = 0, $parent = "")
60 {
61 $basePath = self::GetBasePath($template);
63 if(!$io->DirectoryExists($basePath))
64 return;
65
66 $imagesPath = $basePath."/images";
67
68 CSnippets::WriteHtaccess($imagesPath);
69 $bpPath = $basePath.($path == "" ? "" : "/").$path;
70
71 $d = $io->GetDirectory($bpPath);
72 $arChildren = $d->GetChildren();
73 foreach ($arChildren as $child)
74 {
75 $file = $child->GetName();
76 if($file == ".htaccess" || $file == ".content.php" || ($level == 0 && $file == "images"))
77 continue;
78
79 $filePath = $child->GetPathWithName();
80 if($child->IsDirectory()) //if this is subfolder
81 {
82 $new_path = "".$path.($path == "" ? "" : "/").$file;
83 CSnippets::ReadDir($arSNIPPETS, $arKeys, $new_path, $template, $level + 1, $file);
84 }
85 else // File
86 {
87 $name = $file;
88 $ext = $child->GetExtension();
89
90 // Rename file *.* => *.snp
91 if ($ext != 'snp')
92 {
93 $name = str_replace($ext, "snp", $name);
94 if (mb_strpos($name, ".snp") === false)
95 {
96 $name = $name.".snp";
97 }
98
99 if (!$io->FileExists($bpPath."/".$name))
100 {
101 $io->Rename($filePath, $bpPath."/".$name);
102 }
103 else
104 {
105 for ($n = 1; $n < 256; $n++)
106 {
107 $name_ = str_replace(".snp", "(".$n.").snp", $name);
108 if (!$io->FileExists($bpPath."/".$name_))
109 {
110 $name = $name_;
111 $io->Rename($filePath, $bpPath."/".$name);
112 break;
113 }
114 }
115 }
116 }
117
118 $key = $path.($path != '' ? '/' : '').$name;
119 $arSNIPPETS[$key] = Array(
120 'name' => $name,
121 'path' => $path,
122 'title' => $name,
123 'thumb' => '',
124 'code' => CSnippets::GetCode($bpPath."/".$name),
125 'description' => "",
126 'template' => $template,
127 'level' => $level,
128 'parent' => $parent
129 );
130
131 $arKeys[$key] = Array(
132 'name' => $name,
133 'path' => $path,
134 'title' => $name,
135 'description' => ""
136 );
137 }
138 }
139 }
140
141 public static function UpdateContentInfo(&$ar, &$arKeys, $template)
142 {
143 $basePath = self::GetBasePath($template);
144
145 if (file_exists($basePath."/.content.php"))
146 {
147 @include($basePath."/.content.php");
148 $arK = array_keys($SNIPPETS);
149 for ($i=0, $len = count($arK); $i<$len;$i++)
150 {
151 $name = $arK[$i];
152 $pos = mb_strrpos($name, ".");
153 $f_name = ($pos !== FALSE)? mb_substr($name, 0, $pos) : $name;
154 if ($ar[$f_name.".snp"])
155 {
156 $ar[$f_name.".snp"]['title'] = stripslashes($SNIPPETS[$name]['title']);
157 $ar[$f_name.".snp"]['description'] = stripslashes($SNIPPETS[$name]['description'] ?? '');
158 }
159 }
160 }
161 }
162
163 public static function WriteHtaccess($path)
164 {
166 if($io->DirectoryExists($path) && !$io->FileExists($path."/.htaccess"))
167 $GLOBALS['APPLICATION']->SaveFileContent($path."/.htaccess", "Allow from All");
168 }
169
170 public static function ClearCache()
171 {
172 global $CACHE_MANAGER;
173 $CACHE_MANAGER->Clean("fileman_snippet_array");
174 $CACHE_MANAGER->Clean("fileman_snippet_group");
175 }
176
177 public static function GetCode($path)
178 {
180 return $io->FileExists($path) ? $GLOBALS['APPLICATION']->GetFileContent($path) : '';
181 }
182
183 public static function Edit($Params)
184 {
185 global $APPLICATION;
186 $name = CFileMan::SecurePathVar($Params['name']);
187 $title = $Params['title'];
188 $description = $Params['description'];
189 $path = CFileMan::SecurePathVar($Params['path']);
190 $template = CFileMan::SecurePathVar($Params['template']);
191 $site = $Params['site'];
192 $code = $Params['code'];
193 $basePath = self::GetBasePath($template);
194 $templatePath = mb_substr($basePath, 0, -9);
195 $thumb = $Params['thumb'] === false ? false : CFileMan::SecurePathVar($Params['thumb']);
196
197 if (!file_exists($templatePath))
198 {
199 ?><script>alert('Error: Incorrect template Id: <?= CUtil::JSEscape($template)?>');</script><?
200 return;
201 }
202
203 if ($Params['bNew'])
204 {
205 $location = CUtil::addslashes(CFileMan::SecurePathVar($Params["location"]));
206 $newGroup = CUtil::addslashes(CFileMan::SecurePathVar($Params["newGroup"]));
207 $path = trim(($location ? $location.'/' : '').($newGroup ? $newGroup.'/' : ''), ' /');
208
209 if ($name == '')
210 {
212 ?><script>window.__bx_res_sn_filename = "<?= CUtil::JSEscape($name);?>";</script><?
213 }
214 $name = $name.'.snp';
215 }
216 $key = $path.($path != '' ? '/' : '').$name;
217
218 // 1. Save new snippet with new content
219 if ($code)
220 $APPLICATION->SaveFileContent($basePath.'/'.$key, $code);
221
222 // 2. Rewrite title & description in .content.php
223 if ($title || $description)
224 {
225 if (file_exists($basePath."/.content.php"))
226 @include($basePath."/.content.php");
227 else
228 $SNIPPETS = array();
229
230 if ($title)
231 $SNIPPETS[$key]['title'] = $title;
232 if ($description)
233 $SNIPPETS[$key]['description'] = $description;
234
235 $contentSrc = '<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>'.chr(10);
236 $contentSrc .= '<?'.chr(10).'$SNIPPETS = Array();'.chr(10);
237 foreach ($SNIPPETS as $k=>$_arSn)
238 {
239 if (CSnippets::CheckFile(array('site' => $Params["site"], 'template' => $Params['template'], 'path' => $k)))
240 $contentSrc .= '$SNIPPETS[\''.CUtil::addslashes($k).'\'] = Array("title"=>\''.Cutil::addslashes($_arSn['title'] ?? null).'\', "description"=>\''.Cutil::addslashes($_arSn['description'] ?? null).'\');'.chr(10);
241 }
242 $contentSrc .= '?>';
243
244 $APPLICATION->SaveFileContent($basePath."/.content.php", $contentSrc);
245 }
246
247 CSnippets::ClearCache();
248
249 // 3. Handle thumbnail
250 if ($thumb !== false)
251 {
252 if (mb_substr($thumb, 0, 1) == '/')
253 $thumb = mb_substr($thumb, 1);
254
255 $pos = mb_strrpos($name, ".");
256 if ($pos === FALSE)
257 return true;
258
259 //delete existent thumbnail
260 $f_name = mb_substr($name, 0, $pos);
261 $img_path1 = BX_PERSONAL_ROOT.'/templates/'.$template.'/snippets/images/'.$path.($path == '' ? '' : '/').$f_name;
262 $DOC_ROOT = CSite::GetSiteDocRoot($site);
263 $arExt = array("gif", "jpg", "jpeg", "png", "bmp");
264 for ($i = 0, $c = count($arExt); $i < $c; $i++)
265 {
266 $p_ = $img_path1.".".$arExt[$i];
267 if(file_exists($DOC_ROOT.$p_))
268 CFileman::DeleteFile(Array($site, $p_));
269 }
270
271 if (empty($thumb) || mb_strrpos($thumb, '.') === FALSE)
272 return true;
273
274 // Copy Thumbnail
275 $path_from_1 = $DOC_ROOT."/".$thumb;
276 $path_from = '/'.$thumb;
277
278 if (file_exists($path_from_1))
279 {
280 $pos = mb_strrpos($thumb, ".");
281 $f_ext = ($pos !== FALSE)? mb_strtolower(mb_substr($thumb, $pos + 1)) : '';
282
283 if (in_array($f_ext, $arExt))
284 {
285 $path_to = $img_path1.'.'.$f_ext;
286 $strWarning_tmp = CFileMan::CopyEx(Array($site, $path_from), Array($site, $path_to));
287 }
288 }
289 }
290 }
291
292 public static function Delete($Params)
293 {
294 global $APPLICATION;
295
296 $io = CBXVirtualIo::GetInstance();
297 if($io->DirectoryExists($_SERVER["DOCUMENT_ROOT"]."/local/templates/".$Params['template']."/snippets"))
298 {
299 $snPath = "/local/templates/".$Params['template']."/snippets";
300 }
301 else
302 {
303 $snPath = BX_PERSONAL_ROOT."/templates/".$Params['template']."/snippets";
304 }
305
306 $basePath = $_SERVER["DOCUMENT_ROOT"].$snPath;
307 $path = CFileMan::SecurePathVar($Params["path"]);
308 $key = $Params["path"].($Params["path"] == '' ? '' : '/').CFileMan::SecurePathVar($Params["name"]);
309
310 //Delete snippet file
311 CFileman::DeleteFile(Array($Params["site"], $snPath.'/'.$key));
312
313 //Delete thumbnail
314 if ($Params["thumb"] != '')
315 {
316 CFileman::DeleteFile(Array($Params["site"], $snPath.'/images/'.$path.($path == '' ? '' : '/').CFileMan::SecurePathVar($Params["thumb"])));
317 }
318
319 if (file_exists($basePath."/.content.php"))
320 {
321 @include($basePath."/.content.php");
322 $contentSrc = '<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>'.chr(10);
323 $contentSrc .= '<?'.chr(10).'$SNIPPETS = Array();'.chr(10);
324 foreach ($SNIPPETS as $k=>$_arSn)
325 {
326 if ($k != $key && CSnippets::CheckFile(array('site' => $Params["site"], 'template' => $Params['template'], 'path' => $k)))
327 $contentSrc .= '$SNIPPETS[\''.CUtil::JSEscape($k).'\'] = Array("title"=>\''.CUtil::JSEscape($_arSn['title']).'\', "description"=>\''.CUtil::JSEscape($_arSn['description']).'\');'.chr(10);
328 }
329 $contentSrc .= '?>';
330 $APPLICATION->SaveFileContent($basePath."/.content.php", $contentSrc);
331 }
332
333 CSnippets::ClearCache();
334?>
335<script>
336window.operation_success = true;
337</script>
338<?
339 }
340
341 public static function CheckFile($params)
342 {
343 $basePath = self::GetBasePath($params['template']);
344 return file_exists(CFileMan::SecurePathVar($basePath.'/'.$params['path']));
345 }
346
347 public static function GetGroups($Params)
348 {
349 $template = CFileMan::SecurePathVar($Params['template']);
350 $arSnGroups = Array();
351 CSnippets::InspectDir($arSnGroups, "", $template);
352 CSnippets::DisplayJSGroups($template, $arSnGroups);
353 }
354
355 public static function GetGroupList($Params)
356 {
357 global $CACHE_MANAGER;
358 $template = CFileMan::SecurePathVar($Params['template']);
359
360 $arGroups = false;
361 $CACHE_SNIPPETS = Array();
362
363 if ($Params['bClearCache'])
364 CSnippets::ClearCache();
365
366 $ttl = 30 * 24 * 60 * 60; // 30 days
367 if($CACHE_MANAGER->Read($ttl, "fileman_snippet_group"))
368 {
369 $CACHE_SNIPPETS = $CACHE_MANAGER->Get("fileman_snippet_group");
370 if (isset($CACHE_SNIPPETS[$template]))
371 $arGroups = $CACHE_SNIPPETS[$template];
372 }
373
374 if (!$arGroups || !is_array($arGroups))
375 {
376 $arGroups = Array();
377 CSnippets::InspectDir($arGroups, "", $template);
378 $CACHE_SNIPPETS[$template] = $arGroups;
379 $CACHE_MANAGER->Set("fileman_snippet_group", $CACHE_SNIPPETS);
380 }
381 return $arGroups;
382 }
383
384 public static function SaveGroupList($Params)
385 {
386
387 }
388
389 public static function InspectDir(&$arSnGroups, $path, $template, $level = 0, $parent = '')
390 {
391 $io = CBXVirtualIo::GetInstance();
392 $basePath = self::GetBasePath($template);
393 if(!$io->DirectoryExists($basePath))
394 return;
395
396 $bpPath = $basePath.($path == "" ? "" : "/").$path;
397 if (!$level)
398 $level = 0;
399
400 $d = $io->GetDirectory($bpPath);
401 $arChildren = $d->GetChildren();
402 foreach ($arChildren as $child)
403 {
404 $file = $child->GetName();
405 if($file == ".htaccess" || $file == ".content.php" || ($level == 0 && $file == "images") || !$child->IsDirectory())
406 continue;
407
408 $filePath = $child->GetPathWithName();
409 $arSnGroups[] = Array
410 (
411 'path' => $path,
412 'name' => $file,
413 'level' => $level,
414 'default_name' => CSnippets::GetDefaultFileName($filePath)
415 );
416
417 $new_path = "".$path.($path == "" ? "" : "/").$file;
418 CSnippets::InspectDir($arSnGroups, $new_path, $template, $level + 1, $parent);
419 }
420 }
421
422 public static function GetDefaultFileName($path)
423 {
424 $io = CBXVirtualIo::GetInstance();
425 for ($i = 1; $i <= 9999; $i++)
426 {
427 $name = 'snippet'.str_pad($i, 4, "0", STR_PAD_LEFT);
428 if (!$io->FileExists($path.'/'.$name.'.snp'))
429 break;
430 }
431 return $name;
432 }
433
434 public static function DisplayJSGroups($template, $ar = array())
435 {
436 $template = CUtil::JSEscape(htmlspecialcharsex($template));
437 $basePath = self::GetBasePath($template);
438 ?><script>
439 window.arSnGroups['<?= $template?>'] = {};
440 window.rootDefaultName['<?= $template?>'] = '<?= CSnippets::GetDefaultFileName($basePath)?>';
441 <?
442 for($i=0,$len = count($ar); $i < $len; $i++)
443 {
444 $key = CUtil::JSEscape($ar[$i]['path'].($ar[$i]['path'] != '' ? '/' : '').$ar[$i]['name']);
445 ?>
446window.arSnGroups['<?=$template?>']['<?= $key?>'] =
447{
448 name: '<?=CUtil::JSEscape($ar[$i]['name'])?>',
449 path: '<?=CUtil::JSEscape($ar[$i]['path'])?>',
450 level: '<?=CUtil::JSEscape($ar[$i]['level'])?>',
451 default_name: '<?=CUtil::JSEscape($ar[$i]['default_name'])?>'
452};
453 <?
454 }
455 ?></script><?
456 }
457
464 public static function Add($params = array())
465 {
466 $params['new'] = true;
467 return self::Update($params);
468 }
469
476 public static function Update($params = array())
477 {
478 global $APPLICATION;
479 $res = false;
480 $title = $params['title'];
481 $description = $params['description'];
482 $currentPath = $params['new'] ? '' : CFileMan::SecurePathVar($params['current_path']);
483 $path = CFileMan::SecurePathVar($params['path']);
484 $template = CFileMan::SecurePathVar($params['template']);
485 $code = $params['code'];
486 $basePath = self::GetBasePath($template);
487 $snippetPath = $basePath.($path == '' ? '' : '/'.$path);
488
489 $io = CBXVirtualIo::GetInstance();
490 if(!$io->DirectoryExists($basePath))
491 {
492 $io->CreateDirectory($basePath);
493 }
494
495 if ($params['new'])
496 {
497 $fileName = CSnippets::GetDefaultFileName($snippetPath).'.snp';
498 }
499 else
500 {
501 $currentPath = $basePath.'/'.$currentPath;
502 $oldSnippetPath = $io->ExtractPathFromPath($currentPath);
503
504 if ($snippetPath !== $oldSnippetPath && $io->FileExists($currentPath))
505 {
506 $io->Delete($currentPath);
507 $fileName = CSnippets::GetDefaultFileName($snippetPath).'.snp';
508 }
509 else
510 {
511 $fileName = $io->ExtractNameFromPath($currentPath);
512 }
513 }
514 $key = ($path === '' ? '' : $path.'/').$fileName;
515
516 if (!$io->ValidatePathString('/'.$fileName) ||
517 IsFileUnsafe($snippetPath.'/'.$fileName) ||
518 HasScriptExtension($snippetPath.'/'.$fileName))
519 {
520 return false;
521 }
522
523 // 1. Save new snippet with new content
524 if ($code)
525 {
526 $APPLICATION->SaveFileContent($snippetPath.'/'.$fileName, $code);
527 }
528
529 // 2. Rewrite title & description in .content.php
530 if ($title || $description)
531 {
532 $SNIPPETS = array();
533 if ($io->FileExists($basePath."/.content.php"))
534 @include($basePath."/.content.php");
535
536 if ($title)
537 $SNIPPETS[$key]['title'] = $title;
538 if ($description)
539 $SNIPPETS[$key]['description'] = $description;
540
541 $contentSrc = '<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>'.chr(10);
542 $contentSrc .= '<?'.chr(10).'$SNIPPETS = Array();'.chr(10);
543 foreach ($SNIPPETS as $k => $snip)
544 {
545 if($io->FileExists(CFileMan::SecurePathVar($basePath.'/'.$k)))
546 {
547 $contentSrc .= '$SNIPPETS[\''.CUtil::addslashes($k).'\'] = Array(';
548
549 if (isset($snip['title']) && $snip['title'] !== '')
550 {
551 $contentSrc .= '\'title\' => \''.Cutil::addslashes($snip['title']).'\'';
552 if (isset($snip['description']) && $snip['description'] !== '')
553 $contentSrc .= ', ';
554 }
555 if (isset($snip['description']) && $snip['description'] !== '')
556 {
557 $contentSrc .= '\'description\' => \''.Cutil::addslashes($snip['description']).'\'';
558 }
559 $contentSrc .= ');'.chr(10);
560 }
561 }
562 $contentSrc .= '?>';
563
564 $APPLICATION->SaveFileContent($basePath."/.content.php", $contentSrc);
565 }
566 $res = array('result' => true);
567
569
570 return $res;
571 }
572
579 public static function Remove($params = array())
580 {
581 global $APPLICATION;
582 $res = false;
585 $basePath = self::GetBasePath($template);
586 $snippetPath = $basePath.($path == '' ? '' : '/'.$path);
587
589 if (!$io->ValidatePathString('/'.$path) ||
592 {
593 return false;
594 }
595
596 //Delete snippet file
597 if($io->FileExists($snippetPath))
598 {
599 $res = $io->Delete($snippetPath);
600 }
601
602 $SNIPPETS = array();
603 if ($io->FileExists($basePath."/.content.php"))
604 @include($basePath."/.content.php");
605
606 $contentSrc = '<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>'.chr(10);
607 $contentSrc .= '<?'.chr(10).'$SNIPPETS = Array();'.chr(10);
608 foreach ($SNIPPETS as $k => $snip)
609 {
610 if($io->FileExists(CFileMan::SecurePathVar($basePath.'/'.$k)))
611 {
612 $contentSrc .= '$SNIPPETS[\''.CUtil::addslashes($k).'\'] = Array(';
613
614 if (isset($snip['title']) && $snip['title'] !== '')
615 {
616 $contentSrc .= '\'title\' => \''.Cutil::addslashes($snip['title']).'\'';
617 if (isset($snip['description']) && $snip['description'] !== '')
618 $contentSrc .= ', ';
619 }
620 if (isset($snip['description']) && $snip['description'] !== '')
621 {
622 $contentSrc .= '\'description\' => \''.Cutil::addslashes($snip['description']).'\'';
623 }
624 $contentSrc .= ');'.chr(10);
625 }
626 }
627 $contentSrc .= '?>';
628 $APPLICATION->SaveFileContent($basePath."/.content.php", $contentSrc);
629
631
632 return $res;
633 }
634
635 public static function CreateCategory($params = array())
636 {
637 $res = false;
638 if (is_array($params) && isset($params['name']))
639 {
641 $template = (isset($params['template']) && $params['template'] !== '') ? CFileMan::SecurePathVar($params['template']) : '.default';
642 $basePath = self::GetBasePath($template);
643 $templatePath = mb_substr($basePath, 0, -9);
644
646 if($io->DirectoryExists($templatePath))
647 {
648 if(!$io->DirectoryExists($basePath))
649 {
650 $io->CreateDirectory($basePath);
651 }
652
653 $parentPath = (isset($params['parent']) && $params['parent'] !== '') ? '/'.CFileMan::SecurePathVar($params['parent']) : '';
654 $categoryPath = $basePath.$parentPath.'/'.$name;
655 if (!$io->DirectoryExists($categoryPath))
656 {
657 $res = $io->CreateDirectory($categoryPath);
658 }
659 }
661 }
662 return $res;
663 }
664
665 public static function RenameCategory($params)
666 {
667 global $APPLICATION;
668 $res = false;
669 if (is_array($params) && isset($params['path'], $params['new_name']))
670 {
672 $template = (isset($params['template']) && $params['template'] !== '') ? CFileMan::SecurePathVar($params['template']) : '.default';
673 $basePath = self::GetBasePath($template);
674 $categoryPath = $basePath.'/'.$path;
675
677 $newCategoryPath = $io->ExtractPathFromPath($categoryPath).'/'.$params['new_name'];
678 if($io->DirectoryExists($categoryPath) && !$io->DirectoryExists($newCategoryPath))
679 {
680 $res = $io->Rename($categoryPath, $newCategoryPath);
681 }
682
684 if($io->FileExists($basePath."/.content.php"))
685 {
686 $contentSrc = $APPLICATION->GetFileContent($basePath."/.content.php");
687 $newPath = ltrim($io->ExtractPathFromPath($path).'/'.$params['new_name'], '/');
688 $processedNewPath = CUtil::addslashes($newPath);
689 $contentSrc = preg_replace("/\\\$SNIPPETS\\['".$path."\\//", '$SNIPPETS[\''.$processedNewPath.'/', $contentSrc);
690 $APPLICATION->SaveFileContent($basePath."/.content.php", $contentSrc);
691 }
692
694 }
695 return $res;
696 }
697
698 public static function RemoveCategory($params)
699 {
700 $res = false;
701 if (is_array($params) && isset($params['path']))
702 {
704 $template = (isset($params['template']) && $params['template'] !== '') ? CFileMan::SecurePathVar($params['template']) : '.default';
705 $basePath = self::GetBasePath($template);
706 $categoryPath = $basePath.'/'.$path;
707
709 if($io->DirectoryExists($categoryPath))
710 {
711 $res = $io->Delete($categoryPath);
712 }
713
715 }
716 return $res;
717 }
718
719 private static function GetBasePath($template)
720 {
722 if($io->DirectoryExists($_SERVER["DOCUMENT_ROOT"]."/local/templates/".$template."/snippets"))
723 {
724 $basePath = $_SERVER["DOCUMENT_ROOT"]."/local/templates/".$template."/snippets";
725 }
726 else
727 {
728 $basePath = $_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$template."/snippets";
729 }
730
731 return $basePath;
732 }
733}
$path
Определения access_edit.php:21
$basePath
Определения include.php:41
global $APPLICATION
Определения include.php:80
static GetInstance()
Определения virtual_io.php:60
static SecurePathVar($str)
Определения fileman.php:2111
Определения snippets.php:4
static Remove($params=array())
Определения snippets.php:579
static UpdateContentInfo(&$ar, &$arKeys, $template)
Определения snippets.php:141
static ReadDir(&$arSNIPPETS, &$arKeys, $path, $template, $level=0, $parent="")
Определения snippets.php:59
static Edit($Params)
Определения snippets.php:183
static GetDefaultFileName($path)
Определения snippets.php:422
static RemoveCategory($params)
Определения snippets.php:698
static WriteHtaccess($path)
Определения snippets.php:163
static RenameCategory($params)
Определения snippets.php:665
static HandleForTemplate($template, &$arSNIPPETS, &$arTemplateKeys)
Определения snippets.php:50
static CheckFile($params)
Определения snippets.php:341
static LoadList($Params)
Определения snippets.php:5
static ClearCache()
Определения snippets.php:170
static CreateCategory($params=array())
Определения snippets.php:635
static GetCode($path)
Определения snippets.php:177
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$template
Определения file_edit.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения .description.php:24
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
$io
Определения csv_new_run.php:98
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
IsFileUnsafe($name)
Определения tools.php:3016
HasScriptExtension($check_name)
Определения tools.php:2956
$name
Определения menu_edit.php:35
return false
Определения prolog_main_admin.php:185
<? endif;?> window document title
Определения prolog_main_admin.php:76
$ar
Определения options.php:199
if(empty($signedUserToken)) $key
Определения quickway.php:257
die
Определения quickway.php:367
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$title
Определения pdf.php:123
$location
Определения options.php:2729
$k
Определения template_pdf.php:567
path
Определения template_copy.php:201
$GLOBALS['_____370096793']
Определения update_client.php:1
$n
Определения update_log.php:107
$site
Определения yandex_run.php:614