1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
file_dialog.php
См. документацию.
1<?php
2
4
5// ***** CAdminFileDialog *****
8{
9 public static function ShowScript($arConfig)
10 {
11 global $USER, $APPLICATION;
12 $bCloudsBrowse = is_object($USER) && $USER->CanDoOperation("clouds_browse") && $arConfig["operation"] === "O";
13
14 CUtil::InitJSCore(array('ajax', 'window'));
15
17 $rootPath = "";
18 $resultDest = "";
19
20 if(CModule::IncludeModule("fileman"))
21 {
22 $arConfig['path'] = ($arConfig['arPath']['PATH'] ?? '');
23 $arConfig['site'] = ($arConfig['arPath']['SITE'] ?? '');
24 $arConfig['lang'] = ($arConfig['lang'] ?? LANGUAGE_ID);
25 $arConfig['zIndex'] = $arConfig['zIndex'] ?? 2500;
26 $arConfig['saveConfig'] = $arConfig['saveConfig'] ?? true;
27
28 $path = $io->CombinePath("/", $arConfig['path']);
30 $rootPath = CSite::GetSiteDocRoot($arConfig['site']);
31
32 while (!$io->DirectoryExists($rootPath.$path))
33 {
34 $rpos = mb_strrpos($path, '/');
35 if ($rpos === false || $rpos < 1)
36 {
37 $path = '/';
38 break;
39 }
40 $path = rtrim(mb_substr($path, 0, $rpos), "/\\");
41 }
42 if (!$path || $path == '')
43 $path = '/';
44 $arConfig['path'] = $path;
45
46 $functionError = "";
47 if (!isset($arConfig['event']))
48 {
49 $functionError .= GetMessage("BX_FD_NO_EVENT").". ";
50 }
51 else
52 {
53 $arConfig['event'] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['event']);
54 if ($arConfig['event'] == '')
55 $functionError .= GetMessage("BX_FD_NO_EVENT").". ";
56 }
57
58 if (!isset($arConfig['arResultDest']) || !is_array($arConfig['arResultDest']))
59 {
60 $functionError .= GetMessage("BX_FD_NO_RETURN_PRM").". ";
61 }
62 else
63 {
64 if (isset($arConfig['arResultDest']["FUNCTION_NAME"]) && $arConfig['arResultDest']["FUNCTION_NAME"] <> '')
65 {
66 $arConfig['arResultDest']["FUNCTION_NAME"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["FUNCTION_NAME"]);
67 if ($arConfig['arResultDest']["FUNCTION_NAME"] == '')
68 $functionError .= GetMessage("BX_FD_NO_RETURN_FNC").". ";
69 else
70 $resultDest = "FUNCTION";
71 }
72 elseif (isset($arConfig['arResultDest']["FORM_NAME"]) && $arConfig['arResultDest']["FORM_NAME"] <> ''
73 && isset($arConfig['arResultDest']["FORM_ELEMENT_NAME"]) && $arConfig['arResultDest']["FORM_ELEMENT_NAME"] <> '')
74 {
75 $arConfig['arResultDest']["FORM_NAME"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["FORM_NAME"]);
76 $arConfig['arResultDest']["FORM_ELEMENT_NAME"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["FORM_ELEMENT_NAME"]);
77 if ($arConfig['arResultDest']["FORM_NAME"] == '' || $arConfig['arResultDest']["FORM_ELEMENT_NAME"] == '')
78 $functionError .= GetMessage("BX_FD_NO_RETURN_FRM").". ";
79 else
80 $resultDest = "FORM";
81 }
82 elseif (isset($arConfig['arResultDest']["ELEMENT_ID"]) && $arConfig['arResultDest']["ELEMENT_ID"] <> '')
83 {
84 $arConfig['arResultDest']["ELEMENT_ID"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["ELEMENT_ID"]);
85 if ($arConfig['arResultDest']["ELEMENT_ID"] == '')
86 $functionError .= GetMessage("BX_FD_NO_RETURN_ID").". ";
87 else
88 $resultDest = "ID";
89 }
90 else
91 {
92 $functionError .= GetMessage("BX_FD_BAD_RETURN").". ";
93 }
94 }
95 }
96 else
97 {
98 $functionError = GetMessage("BX_FD_NO_FILEMAN");
99 }
100
101 if ($functionError == '')
102 {
103 ?>
104 <script>
105 var mess_SESS_EXPIRED = '<?=GetMessageJS('BX_FD_ERROR').': '.GetMessageJS('BX_FD_SESS_EXPIRED')?>';
106 var mess_ACCESS_DENIED = '<?=GetMessageJS('BX_FD_ERROR').': '.GetMessageJS('BX_FD_NO_PERMS')?>';
107 window.<?= CUtil::JSEscape($arConfig['event'])?> = function(bLoadJS, Params)
108 {
109 if (!Params)
110 Params = {};
111
112 <?if(!$USER->CanDoOperation('fileman_view_file_structure')):?>
113 <?echo '
114 alert(mess_ACCESS_DENIED);
115 return;
116 '?>
117 <?else:?>
118 var UserConfig;
119 <?
120 $fd_config = stripslashes(CUserOptions::GetOption("fileman", "file_dialog_config", "N"));
121 if ($fd_config == "N" || $arConfig['saveConfig'] === false)
122 {
123 ?>
124 UserConfig =
125 {
126 site : '<?= CUtil::JSEscape($arConfig['site'])?>',
127 path : '<?= CUtil::JSEscape($arConfig['path'])?>',
128 view : "list",
129 sort : "type",
130 sort_order : "asc"
131 };
132 <?
133 }
134 else
135 {
136 $res = explode(";", $fd_config);
137 if ($res[0])
138 $arConfig['site'] = $res[0];
139 if ($res[1])
140 $arConfig['path'] = rtrim($res[1], " /\\");
141
142 $rootPath = CSite::GetSiteDocRoot($arConfig['site']);
143
144 if (!$io->DirectoryExists($rootPath.$arConfig['path']))
145 $arConfig['path'] = '/';
146 ?>
147 UserConfig =
148 {
149 site : '<?= CUtil::JSEscape($arConfig['site'])?>',
150 path : '<?= CUtil::JSEscape($arConfig['path'])?>',
151 view : '<?= CUtil::JSEscape($res[2])?>',
152 sort : '<?= CUtil::JSEscape($res[3])?>',
153 sort_order : '<?= CUtil::JSEscape($res[4])?>'
154 };
155 <?
156 }
157 ?>
158 if (!window.BXFileDialog)
159 {
160 if (bLoadJS !== false)
161 BX.loadScript('<?=CUtil::GetAdditionalFileURL("/bitrix/js/main/file_dialog.js")?>');
162 return setTimeout(function(){window['<?= CUtil::JSEscape($arConfig['event'])?>'](false, Params)}, 50);
163 }
164
165 var oConfig =
166 {
167 submitFuncName : '<?= CUtil::JSEscape($arConfig['event'])?>Result',
168 select : '<?= CUtil::JSEscape($arConfig['select'])?>',
169 operation: '<?= CUtil::JSEscape($arConfig['operation'])?>',
170 showUploadTab : <?= $arConfig['showUploadTab'] ? 'true' : 'false';?>,
171 showAddToMenuTab : <?= (isset($arConfig['showAddToMenuTab']) && $arConfig['showAddToMenuTab'] ? 'true' : 'false');?>,
172 site : '<?= CUtil::JSEscape($arConfig['site'] ?? '')?>',
173 path : '<?= CUtil::JSEscape($arConfig['path'] ?? '')?>',
174 lang : '<?= CUtil::JSEscape($arConfig['lang'] ?? '')?>',
175 fileFilter : '<?= CUtil::JSEscape($arConfig['fileFilter'] ?? '')?>',
176 allowAllFiles : <?= (!isset($arConfig['allowAllFiles']) || $arConfig['allowAllFiles'] !== false ? 'true' : 'false')?>,
177 saveConfig : <?= (!isset($arConfig['saveConfig']) || $arConfig['saveConfig'] !== false ? 'true' : 'false');?>,
178 sessid: "<?=bitrix_sessid()?>",
179 checkChildren: true,
180 genThumb: <?= COption::GetOptionString("fileman", "file_dialog_gen_thumb", "Y") == 'Y' ? 'true' : 'false';?>,
181 zIndex: <?= CUtil::JSEscape($arConfig['zIndex'] ?? 0)?>
182 };
183
184 if(window.oBXFileDialog && window.oBXFileDialog.UserConfig)
185 {
186 UserConfig = oBXFileDialog.UserConfig;
187 oConfig.path = UserConfig.path;
188 oConfig.site = UserConfig.site;
189 }
190
191 if (Params.path)
192 oConfig.path = Params.path;
193 if (Params.site)
194 oConfig.site = Params.site;
195
196 oBXFileDialog = new BXFileDialog();
197 oBXFileDialog.Open(oConfig, UserConfig);
198 <?endif;?>
199 };
200 window.<?= CUtil::JSEscape($arConfig['event'])?>Result = function(filename, path, site, title, menu)
201 {
202<?
203$arBuckets = array();
204if($bCloudsBrowse && CModule::IncludeModule('clouds'))
205{
206 foreach(CCloudStorageBucket::GetAllBuckets() as $arBucket)
207 {
208 if($arBucket["ACTIVE"] == "Y")
209 {
210 $obBucket = new CCloudStorageBucket($arBucket["ID"]);
211 if($obBucket->Init())
212 $arBuckets[$arBucket["BUCKET"]] = rtrim($obBucket->GetFileSRC("/"), "/");
213 }
214 }
215}
216?>
217 path = jsUtils.trim(path);
218 path = path.replace(/\\/ig,"/");
219 path = path.replace(/\/\//ig,"/");
220 if (path.substr(path.length-1) == "/")
221 path = path.substr(0, path.length-1);
222 var full = (path + '/' + filename).replace(/\/\//ig, '/');
223 if (path == '')
224 path = '/';
225
226 var arBuckets = <?echo Json::encode($arBuckets)?>;
227 if(arBuckets[site])
228 {
229 full = arBuckets[site] + filename;
230 path = arBuckets[site] + path;
231 }
232
233 if ('<?= CUtil::JSEscape($arConfig['select'])?>' == 'D')
234 name = full;
235
236 <?if ($resultDest == "FUNCTION"): ?>
237 <?= CUtil::JSEscape($arConfig['arResultDest']["FUNCTION_NAME"])."(filename, path, site, title || '', menu || '');"?>
238 <?elseif($resultDest == "FORM"): ?>
239 document.<?= CUtil::JSEscape($arConfig['arResultDest']["FORM_NAME"])?>.<?= CUtil::JSEscape($arConfig['arResultDest']["FORM_ELEMENT_NAME"])?>.value = full;
240 BX.fireEvent(document.<?= CUtil::JSEscape($arConfig['arResultDest']["FORM_NAME"])?>.<?= CUtil::JSEscape($arConfig['arResultDest']["FORM_ELEMENT_NAME"])?>, 'change');
241 <?elseif($resultDest == "ID"): ?>
242 BX('<?= CUtil::JSEscape($arConfig['arResultDest']["ELEMENT_ID"])?>').value = full;
243 BX.fireEvent(BX('<?= CUtil::JSEscape($arConfig['arResultDest']["ELEMENT_ID"])?>'), 'change');
244 <?endif;?>
245 };
247 </script>
248 <?
249 }
250 else
251 {
252 echo "<font color=\"#FF0000\">".htmlspecialcharsbx($functionError)."</font>";
253 }
254 }
255
256 public static function AttachJSScripts()
257 {
258 if(!defined("BX_B_FILE_DIALOG_SCRIPT_LOADED"))
259 {
260 define("BX_B_FILE_DIALOG_SCRIPT_LOADED", true);
261?>
262if (window.jsUtils)
263{
264 jsUtils.addEvent(window, 'load', function(){jsUtils.loadJSFile('<?=CUtil::GetAdditionalFileURL("/bitrix/js/main/file_dialog.js")?>');}, false);
265}
266<?
267 }
268 }
269
270 public static function Start($Params)
271 {
272 global $USER;
273 $bCloudsBrowse = is_object($USER) && $USER->CanDoOperation('clouds_browse') && $Params["operation"] === "O";
274
275 $arSites = Array();
276 $dbSitesList = CSite::GetList();
277 $arSitesPP = Array();
278 while($arSite = $dbSitesList->GetNext())
279 {
280 $arSites[$arSite["ID"]] = $arSite["NAME"] ? $arSite["NAME"] : $arSite["ID"];
281 $arSitesPP[] = array(
282 "ID" => $arSite["ID"],
283 "TEXT" => '['.$arSite["ID"].'] '.$arSite["NAME"],
284 "ONCLICK" => "oBXDialogControls.SiteSelectorOnChange('".$arSite["ID"]."')",
285 "ICON" => ($arSite["ID"] == $Params['site']) ? 'checked' : ''
286 );
287 }
288
289 if($bCloudsBrowse && CModule::IncludeModule('clouds'))
290 {
291 foreach(CCloudStorageBucket::GetAllBuckets() as $arBucket)
292 {
293 if($arBucket["ACTIVE"] == "Y")
294 {
295 $id = $arBucket["BUCKET"];
296 $arSites[$id] = $arBucket["BUCKET"];
297 $arSitesPP[] = array(
298 "ID" => $id,
299 "TEXT" => $arBucket["BUCKET"],
300 "ONCLICK" => "oBXDialogControls.SiteSelectorOnChange('".$id."')",
301 "ICON" => ($id == $Params['site']) ? 'checked' : ''
302 );
303 }
304 }
305 }
306
307 $Params['arSites'] = $arSites;
308 $Params['arSitesPP'] = $arSitesPP;
309 $Params['site'] = ($Params['site'] && isset($arSites[$Params['site']])) ? $Params['site'] : key($arSites); // Secure site var
310
311 if (!in_array(mb_strtolower($Params['lang']), array('en', 'ru'))) // Secure lang var
312 {
313 $res = CLanguage::GetByID($Params['lang']);
314 if($lang = $res->Fetch())
315 $Params['lang'] = $lang['ID'];
316 else
317 $Params['lang'] = 'en';
318 }
319
320 if ($Params['bAddToMenu'])
321 {
322 $armt = self::GetMenuTypes($Params['site'], $Params['path']);
323 $Params['arMenuTypes'] = $armt[0];
324 $Params['arMenuTypesScript'] = $armt[1];
325 $Params['menuItems'] = $armt[2];
326 }
327
328 self::BuildDialog($Params);
329 self::ShowJS($Params);
330 }
331
332 public static function LoadItems($Params)
333 {
334 global $APPLICATION;
335
336 echo '<script>';
337 if ($Params['bAddToMenu'])
338 self::GetMenuTypes($Params['site'], $Params['path'], true);
339
340 if ($Params['loadRecursively'])
342 'path' => $Params['path'],
343 'site' => $Params['site'],
344 'bCheckEmpty' => true,
345 'getFiles' => $Params['getFiles'],
346 'loadRoot' => $Params['loadRoot'],
347 'bThrowException' => true,
348 'operation' => $Params['operation'],
349 ));
350 else
352 'path' => $Params['path'],
353 'site' => $Params['site'],
354 'bCheckEmpty' => true,
355 'getFiles' => $Params['getFiles'],
356 'operation' => $Params['operation'],
357 ));
358
359 if ($e = $APPLICATION->GetException())
360 echo 'window.action_warning = "'.addslashes($e->GetString()).'";';
361 else
362 echo 'window.load_items_correct = true;';
363
364 echo '</script>';
365 }
366
367 public static function BuildDialog($Params)
368 {
369 $arSites = $Params['arSites'];
370 if (count($arSites) > 1) // Site selector
371 {
372 $u = new CAdminPopup("fd_site_list", "fd_site_list", $Params['arSitesPP'], array('zIndex' => 3520, 'dxShadow' => 0));
373 $u->Show();
374 }
375 ?>
376<form id="file_dialog" name="file_dialog" onsubmit="return false;">
377<table class="bx-file-dialog">
378<tr>
379 <td class= "bxfd-cntrl-cell">
380 <div id="__bx_fd_top_controls_container">
381 <table class="bx-fd-top-contr-tbl">
382 <tr>
383 <?if (count($arSites) > 1):?>
384 <td style="width:22px!important; padding: 0 4px 0 5px !important;">
385 <div id="__bx_site_selector" bxvalue="<?=htmlspecialcharsbx($Params['site'])?>" onclick="oBXDialogControls.SiteSelectorOnClick(this);" class="site_selector_div"><span><?=htmlspecialcharsbx($Params['site'])?></span><span class="fd_iconkit site_selector_div_arrow">&nbsp;&nbsp;</span></div>
386 </td>
387 <?endif;?>
388 <td style="padding: 0 2px 0 2px !important;">
389 <input class="fd_input" type="text" id="__bx_dir_path_bar">
390 </td>
391 <td nowrap style="width:170px !important; padding: 0 2px 0 2px !important;">
392 <img src="/bitrix/images/1.gif" class="fd_iconkit go_button" id="__bx_dir_path_go" title="<?=GetMessage("FD_GO_TO")?>"/>
393 <img src="/bitrix/images/1.gif" __bx_disable="Y" class="fd_iconkit path_back_dis" title="<?=GetMessage("FD_GO_BACK")?>" id="__bx_dir_path_back"/>
394 <img src="/bitrix/images/1.gif" __bx_disable="Y" class="fd_iconkit path_forward_dis" title="<?=GetMessage("FD_GO_FORWARD")?>" id="__bx_dir_path_forward"/>
395 <img src="/bitrix/images/1.gif" class="fd_iconkit dir_path_up" title="<?=GetMessage("FD_GO_UP")?>" id="__bx_dir_path_up" />
396 <img src="/bitrix/images/1.gif" class="fd_iconkit dir_path_root" title="<?=GetMessage("FD_GO_TO_ROOT")?>" id="__bx_dir_path_root" />
397 <img src="/bitrix/images/1.gif" class="fd_iconkit new_dir" title="<?=GetMessage("FD_NEW_FOLDER")?>" id="__bx_new_dir" />
398 <img src="/bitrix/images/1.gif" class="fd_iconkit refresh" title="<?=GetMessage("FD_REFRESH")?>" onclick="oBXDialogControls.RefreshOnclick();"/>
399 <?
400 $arViews = Array(
401 Array("ID" => 'list', "TEXT" => GetMessage("FD_VIEW_LIST"), "ONCLICK" => "oBXDialogControls.ViewSelector.OnChange('list')"),
402 Array("ID" => 'detail', "TEXT" => GetMessage("FD_VIEW_DETAIL"), "ONCLICK" => "oBXDialogControls.ViewSelector.OnChange('detail')"),
403 Array("ID" => 'preview', "TEXT" => GetMessage("FD_VIEW_PREVIEW"), "ONCLICK" => "oBXDialogControls.ViewSelector.OnChange('preview')")
404 );
405 $u = new CAdminPopup("fd_view_list", "fd_view_list", $arViews, array('zIndex' => 2500, 'dxShadow' => 0));
406 $u->Show();
407 ?>
408 <img onclick="oBXDialogControls.ViewSelector.OnClick();" src="/bitrix/images/1.gif" id="__bx_view_selector" class="fd_iconkit view_selector" title="<?=GetMessage("FD_SELECT_VIEW")?>"/>
409 </td>
410 <td nowrap style="width:180px !important; padding: 0 6px 0 3px !important; text-align:right !important;" align="right">
411 <?=GetMessage("FD_SORT_BY")?>:
412 <select class="fd_select" id="__bx_sort_selector" title="<?=GetMessage("FD_SORT_BY")?>" style="font-size:11px !important;">
413 <option value="name"><?=GetMessage("FD_SORT_BY_NAME")?></option>
414 <option value="type"><?=GetMessage("FD_SORT_BY_TYPE")?></option>
415 <option value="size"><?=GetMessage("FD_SORT_BY_SIZE")?></option>
416 <option value="date"><?=GetMessage("FD_SORT_BY_DATE")?></option>
417 </select>
418 </td>
419 <td style="width:20px !important; padding: 0 6px 0 3px !important;">
420 <img src="/bitrix/images/1.gif" class="fd_iconkit sort_up" title="<?=GetMessage("FD_CHANGE_SORT_ORDER")?>" __bx_value="asc" id="__bx_sort_order" />
421 </td>
422 </tr>
423 </table>
424 </div>
425 </td>
426</tr>
427<tr>
428 <td style="vertical-align:top !important; height:398px !important;">
429 <div id="__bx_fd_tree_and_window" style="display:block">
430 <table style="width:743px !important; height:250px !important;">
431 <tr>
432 <td class="bxfd-tree-cont">
433 <div id="__bx_treeContainer" class="fd_window bxfd-tree-cont-div"></div>
434 </td>
435 <td class="bxfd-window-cont">
436 <div class="fd_window" ><div id="__bx_windowContainer" class="bxfd-win-cont"></div></div>
437 </td>
438 </tr>
439 </table>
440 </div>
441 <div id="__bx_fd_preview_and_panel" style="display:block;">
442 <table style="width:100% !important;height:132px !important; padding:0 !important;" border="0">
443 <tr>
444 <td style="width:25% !important; height: 100% !important;">
445 <div style="margin: 3px 8px 3px 5px;border:1px solid #C6C6C6"><div style="height:127px;">
446 <div id="bxfd_previewContainer"></div>
447 <div id="bxfd_addInfoContainer"></div>
448 </div></div>
449 </td>
450 <td style="width:70% !important; vertical-align:top !important;">
451 <div class="bxfd-save-cont">
452 <table>
453 <tr>
454 <td class="bxfd-sc-cell" colspan="2">
455 <input type="text" style="width:98% !important;margin-bottom:5px !important;" id="__bx_file_path_bar">
456 <select style="width:98% !important; display:none; margin-bottom:5px !important;" id="__bx_file_filter"></select>
457 <div id="__bx_page_title_cont" style="display:none;">
458 <?=GetMessage('FD_PAGE_TITLE')?>:<br/>
459 <input type="text" style="width:98% !important;" id="__bx_page_title1">
460 </div>
461 </td>
462 </tr>
463 <tr>
464 <td class="bxfd-sc-cell2">
465 <table id="add2menu_cont" style="display:none"><tr>
466 <td><input type="checkbox" id="__bx_fd_add_to_menu"></td>
467 <td><label for="__bx_fd_add_to_menu"><?=GetMessage("FD_ADD_PAGE_2_MENU")?></label></td>
468 </tr></table>
469 </td>
470 <td class="bxfd-sc-cell3">
471 <input style="width:100px !important;" type="button" id="__bx_fd_submit_but" value="">
472 <input style="width:100px !important;" type="button" onclick="oBXFileDialog.Close()" value="<?=GetMessage("FD_BUT_CANCEL");?>">
473 </td>
474 </tr>
475 </table>
476 </div>
477 </td>
478 </tr>
479 </table>
480 </div>
481 <div id="__bx_fd_load" style="display:none;">
482 <div id="bxfd_upload_container"><iframe id="bxfd_iframe_upload" src="javascript:''" frameborder="0"></iframe></div>
483 </div>
484 <div id="__bx_fd_container_add2menu" class="bxfd-add-2-menu-tab"><? if ($Params['bAddToMenu']) :?><table class="bx-fd-add-2-menu-tbl">
485 <tr>
486 <td style="height:30px">
487 <table class="fd_tab_title">
488 <tr>
489 <td class="icon"><img class="bxfd-add-to-menu-icon" src="/bitrix/images/1.gif" width="32" height="32"/></td>
490 <td class="title"><?=GetMessage("FD_ADD_PAGE_2_MENU_TITLE")?></td>
491 </tr>
492 <tr>
493 <td colspan="2" class="delimiter"></td>
494 </tr>
495 </table>
496 </td>
497 </tr>
498 <tr>
499 <td style="height:310px !important; vertical-align:top !important;">
500 <table id="add2menuTable" class="bxfd-add-2-menu-tbl">
501 <tr>
502 <td style="width:200px !important; text-align:right !important;"><?=GetMessage("FD_FILE_NAME")?></td>
503 <td style="width:250px !important;" id="__bx_fd_file_name"></td>
504 </tr>
505 <tr>
506 <td align="right"><?=GetMessage("FD_PAGE_TITLE")?>:</td>
507 <td><input type="text" id="__bx_page_title2" value=""></td>
508 </tr>
509 <tr>
510 <td align="right"><?=GetMessage("FD_MENU_TYPE")?></td>
511 <td>
512 <select id="__bx_fd_menutype" name="menutype">
513 <?for($i = 0, $n = count($Params['arMenuTypes']); $i < $n; $i++): ?>
514 <option value="<?=htmlspecialcharsbx($Params['arMenuTypes'][$i]['key'])?>"><?=htmlspecialcharsbx($Params['arMenuTypes'][$i]['title'])?></option>
515 <? endfor;?>
516 </select>
517 </td>
518 </tr>
519 <tr id="e0">
520 <td style="vertical-align:top !important; text-align:right !important;"><?=GetMessage("FD_MENU_POINT")?></td>
521 <td>
522 <input type="radio" name="itemtype" id="__bx_fd_itemtype_n" value="n" checked> <label for="__bx_fd_itemtype_n"><?=GetMessage("FD_ADD_NEW")?></label><br>
523 <input type="radio" name="itemtype" id="__bx_fd_itemtype_e" value="e"> <label for="__bx_fd_itemtype_e"><?=GetMessage("FD_ATTACH_2_EXISTENT")?></label>
524 </td>
525 </tr>
526 <tr id="__bx_fd_e1">
527 <td align="right"><?=GetMessage("FD_NEW_ITEM_NAME")?></td>
528 <td><input type="text" name="newp" id="__bx_fd_newp" value=""></td>
529 </tr>
530 <tr id="__bx_fd_e2">
531 <td align="right"><?=GetMessage("FD_ATTACH_BEFORE")?></td>
532 <td>
533 <select name="newppos" id="__bx_fd_newppos">
534 <?for($i = 0, $n = count($Params['menuItems']); $i < $n; $i++):?>
535 <option value="<?= $i + 1 ?>"><?=htmlspecialcharsbx($Params['menuItems'][$i])?></option>
536 <?endfor;?>
537 <option value="0" selected="selected"><?=GetMessage("FD_LAST_POINT")?></option>
538 </select>
539 </td>
540 </tr>
541 <tr id="__bx_fd_e3" style="display:none;">
542 <td align="right"><?=GetMessage("FD_ATTACH_2_ITEM")?></td>
543 <td>
544 <select name="menuitem" id="__bx_fd_menuitem">
545 <?for($i = 0; $i < $n; $i++):?>
546 <option value="<?= $i + 1 ?>"><?=htmlspecialcharsbx($Params['menuItems'][$i])?></option>
547 <?endfor;?>
548 </select>
549 </td>
550 </tr>
551
552 <tr>
553 <td>
554 </td>
555 <td>
556 </td>
557 </tr>
558 </table>
559 </td>
560 </tr>
561 <tr>
562 <td class="bx-fd-buttons-cont">
563 <input type="button" id="__bx_fd_submit_but2" value="">
564 <input type="button" onclick="oBXFileDialog.Close()" value="<?=GetMessage("FD_BUT_CANCEL");?>">
565 </td>
566 </tr>
567 </table><?endif;?></div>
568 </td>
569</tr>
570<tr>
571 <td id="__bx_tab_cont" style="background-color: #D7D7D7;"></td>
572</tr>
573</table>
574</form>
575<div id="__bx_get_real_size_cont"></div>
576 <?
577 }
578
579 public static function ShowJS($Params)
580 {
581 global $APPLICATION;
582 $fd_engine_js_src = '/bitrix/js/main/file_dialog_engine.js';
583 $fd_css_src = '/bitrix/themes/.default/file_dialog.css';
584 $arSites = $Params['arSites'];
585 ?>
586<script>
587BXSite = "<?= CUtil::JSEscape($Params['site'])?>";
588BXLang = "<?= CUtil::JSEscape($Params['lang'])?>";
589if (!window.arFDDirs || !window.arFDFiles || !window.arFDPermission)
590{
591 arFDDirs = {};
592 arFDFiles = {};
593 arFDPermission = {};
594}
595if (!window.arFDMenuTypes)
596 arFDMenuTypes = {};
597<?
598 if (!empty($Params['arMenuTypesScript']))
599 echo $Params['arMenuTypesScript'];
600
602 'path' => $Params['path'],
603 'site' => $Params['site'],
604 'bCheckEmpty' => true,
605 'getFiles' => $Params['getFiles'],
606 'loadRoot' => true,
607 'bFindCorrectPath' => true,
608 'bThrowException' => false,
609 'operation' => $Params['operation'],
610 ));
611
612 if ($e = $APPLICATION->GetException())
613 echo 'alert("'.CUtil::JSEscape($e->GetString()).'");';
614?>
615
616// Sites array
617var arSites = [];
618<?foreach ($arSites as $key => $val):?>
619arSites['<?= CUtil::JSEscape($key)?>'] = '<?= CUtil::JSEscape($val)?>';
620<?endforeach;?>
621
623function OnLoad()
624{
625 if (!window.BXWaitWindow || !window.BXDialogTree || !window.BXDialogWindow)
626 {
627 setTimeout(function(){OnLoad();}, 20);
628 return;
629 }
630
631 window.oWaitWindow = new BXWaitWindow();
632 window.oBXDialogTree = new BXDialogTree();
633 if(oBXFileDialog.oConfig.operation == 'S' && oBXFileDialog.oConfig.showAddToMenuTab)
634 window.oBXMenuHandling = new BXMenuHandling();
635 window.oBXDialogControls = new BXDialogControls();
636 window.oBXDialogWindow = new BXDialogWindow();
637 window.oBXDialogTabs = new BXDialogTabs();
638 window.oBXFDContextMenu = false;
639
640 if (oBXFileDialog.oConfig.operation == 'O' && oBXFileDialog.oConfig.showUploadTab)
641 {
642 oBXDialogTabs.AddTab('tab1', '<?= GetMessageJS("FD_OPEN_TAB_TITLE")?>', _Show_tab_OPEN, true);
643 oBXDialogTabs.AddTab('tab2', '<?= GetMessageJS("FD_LOAD_TAB_TITLE")?>',_Show_tab_LOAD, false);
644 }
645 else if(oBXFileDialog.oConfig.operation == 'S' && oBXFileDialog.oConfig.showAddToMenuTab)
646 {
647 oBXDialogTabs.AddTab('tab1', '<?= GetMessageJS("FD_SAVE_TAB_TITLE")?>', _Show_tab_SAVE, true);
648 oBXDialogTabs.AddTab('tab2', '<?= GetMessageJS("FD_MENU_TAB_TITLE")?>', _Show_tab_MENU, false);
649 BX('add2menu_cont').style.display = 'block';
650 }
651 oBXDialogTabs.DisplayTabs();
652
653 oBXDialogTree.Append();
654 oBXFileDialog.SubmitFileDialog = SubmitFileDialog;
655
656 BX.onCustomEvent(window, 'onFileDialogLoaded');
657}
658
659// Append CSS
660if (!window.fd_styles_link || !window.fd_styles_link.parentNode)
661 window.fd_styles_link = jsUtils.loadCSSFile("<?=$fd_css_src.'?v='.@filemtime($_SERVER['DOCUMENT_ROOT'].$fd_css_src)?>");
662
663// Append file with File Dialog engine
664if (window.BXDialogTree)
665 OnLoad();
666else
667 BX.loadScript("<?=$fd_engine_js_src.'?v='.@filemtime($_SERVER['DOCUMENT_ROOT'].$fd_engine_js_src)?>", OnLoad);
668
669</script>
670<?
671 }
672
673 public static function AppendLangMess()
674 {
675 //* * * * * * * * * * * * * * * * * * * * * * * * *
676 // FD_MESS - Array of messages for JS files
677 //* * * * * * * * * * * * * * * * * * * * * * * * *
678 ?>
679var FD_MESS =
680{
681 FD_SAVE_TAB_TITLE : '<?=GetMessageJS('FD_SAVE_TAB_TITLE')?>',
682 FD_OPEN_DIR : '<?=GetMessageJS('FD_OPEN_DIR')?>',
683 FD_OPEN_TAB_TITLE : '<?=GetMessageJS('FD_OPEN_TAB_TITLE')?>',
684 FD_CLOSE : '<?=GetMessageJS('FD_CLOSE')?>',
685 FD_SORT_SIZE : '<?=GetMessageJS('FD_SORT_SIZE')?>',
686 FD_SORT_DATE : '<?=GetMessageJS('FD_SORT_DATE')?>',
687 FD_SORT_NAME : '<?=GetMessageJS('FD_SORT_NAME')?>',
688 FD_SORT_TYPE : '<?=GetMessageJS('FD_SORT_TYPE')?>',
689 FD_BUT_OPEN : '<?=GetMessageJS('FD_BUT_OPEN')?>',
690 FD_BUT_SAVE : '<?=GetMessageJS('FD_BUT_SAVE')?>',
691 FD_ALL_FILES : '<?=GetMessageJS('FD_ALL_FILES')?>',
692 FD_ALL_IMAGES : '<?=GetMessageJS('FD_ALL_IMAGES')?>',
693 FD_BYTE : '<?=GetMessageJS('FD_BYTE')?>',
694 FD_EMPTY_FILENAME : '<?=GetMessageJS('FD_EMPTY_FILENAME')?>',
695 FD_INPUT_NEW_PUNKT_NAME : '<?=GetMessageJS('FD_INPUT_NEW_PUNKT_NAME')?>',
696 FD_LAST_POINT : '<?=GetMessageJS('FD_LAST_POINT')?>',
697 FD_NEWFOLDER_EXISTS : '<?=GetMessageJS('FD_NEWFOLDER_EXISTS')?>',
698 FD_NEWFILE_EXISTS : '<?=GetMessageJS('FD_NEWFILE_EXISTS')?>',
699 FD_RENAME : '<?=GetMessageJS('FD_RENAME')?>',
700 FD_DELETE : '<?=GetMessageJS('FD_DELETE')?>',
701 FD_RENAME_TITLE : '<?=GetMessageJS('FD_RENAME_TITLE')?>',
702 FD_DELETE_TITLE : '<?=GetMessageJS('FD_DELETE_TITLE')?>',
703 FD_CONFIRM_DEL_DIR : '<?=GetMessageJS('FD_CONFIRM_DEL_DIR')?>',
704 FD_CONFIRM_DEL_FILE : '<?=GetMessageJS('FD_CONFIRM_DEL_FILE')?>',
705 FD_EMPTY_NAME : '<?=GetMessageJS('FD_EMPTY_NAME')?>',
706 FD_INCORRECT_NAME : '<?=GetMessageJS('FD_INCORRECT_NAME')?>',
707 FD_LOADIND : '<?=GetMessageJS('FD_LOADING')?>...',
708 FD_EMPTY_NAME : '<?=GetMessageJS('FD_EMPTY_NAME')?>',
709 FD_INCORRECT_EXT : '<?=GetMessageJS('FD_INCORRECT_EXT')?>',
710 FD_LOAD_EXIST_CONFIRM : '<?=GetMessageJS('FD_LOAD_EXIST_CONFIRM')?>',
711 FD_SESS_EXPIRED : '<?=GetMessageJS('BX_FD_ERROR').': '.GetMessageJS('BX_FD_SESS_EXPIRED')?>',
712 FD_ERROR : '<?=GetMessageJS('BX_FD_ERROR')?>',
713 FD_FILE : '<?=GetMessageJS('FD_FILE')?>',
714 FD_FOLDER : '<?=GetMessageJS('FD_FOLDER')?>',
715 FD_IMAGE : '<?=GetMessageJS('FD_IMAGE')?>'
716};
717<?
718 }
719
720 public static function GetMenuTypes($site, $path, $bEchoResult = false)
721 {
722 global $USER, $APPLICATION;
723
724 if(!CModule::IncludeModule("fileman"))
725 {
726 $APPLICATION->ThrowException(GetMessage("BX_FD_NO_FILEMAN"));
727 return false;
728 }
729
730 $path = Rel2Abs("/", $APPLICATION->UnJSEscape($path));
731 $path = rtrim($path, "/")."/";
732
734 $arAllItems = Array();
735 $arMenuTypes = Array();
736 $strSelected = "";
737 $DOC_ROOT = CSite::GetSiteDocRoot($site);
738
739 foreach($armt as $key => $title)
740 {
741 $menuname = $path.".".$key.".menu.php";
742 if(!$USER->CanDoFileOperation('fm_view_file', Array($site, $menuname)))
743 continue;
744
745 $arItems = Array();
746
748 $aMenuLinksTmp = $res["aMenuLinks"];
749
750 for($j = 0, $n = count($aMenuLinksTmp); $j < $n; $j++)
751 {
753 $arItems[] = htmlspecialcharsbx($aMenuLinksItem[0]);
754 }
755 $arAllItems[$key] = $arItems;
756 if($strSelected == "")
757 $strSelected = $key;
758 $arMenuTypes[] = array('key' => $key, 'title' => $title." [".$key."]");
759 }
760
761 $arTypes = array_keys($arAllItems);
762 $strTypes="";
763 $strItems="";
764 for($i = 0; $i < count($arTypes); $i++)
765 {
766 if($i>0)
767 {
768 $strTypes .= ",";
769 $strItems .= ",";
770 }
771 $strTypes.="'".CUtil::JSEscape($arTypes[$i])."'";
772 $arItems = $arAllItems[$arTypes[$i]];
773 $strItems .= "[";
774 for($j = 0; $j < count($arItems); $j++)
775 {
776 if($j>0)$strItems .= ",";
777 $strItems.="'".CUtil::JSEscape($arItems[$j])."'";
778 }
779 $strItems .= "]";
780 }
781
782 $scriptRes = "\n".'arFDMenuTypes["'.CUtil::JSEscape($path).'"] = {types: ['.$strTypes.'], items: ['.$strItems.']};'."\n";
783
784 if ($bEchoResult)
785 {
786 echo $scriptRes;
787 return null;
788 }
789 return array($arMenuTypes, $scriptRes, $arAllItems[$strSelected]);
790 }
791
792 public static function GetItems($Params)
793 {
794 global $APPLICATION, $USER;
795 static $checkChildren, $genTmb;
796
797 if (!isset($checkChildren, $genTmb))
798 {
799 $checkChildren = COption::GetOptionString("fileman", "file_dialog_check_children", "Y") == 'Y';
800 $genTmb = COption::GetOptionString("fileman", "file_dialog_gen_thumb", "Y") == 'Y';
801 }
802
803 if(mb_strlen($Params["site"]) > 2)
804 {
805 if (!$USER->CanDoOperation('clouds_browse'))
806 {
807 $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_ACCESS_DENIED'), 'access_denied');
808 return;
809 }
810
811 if($Params['operation'] !== 'O')
812 {
813 $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT').' [clouds 04]', 'path_corrupt');
814 return;
815 }
816
817 if(!CModule::IncludeModule('clouds'))
818 {
819 $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT').' [clouds 01]', 'path_corrupt');
820 return;
821 }
822
823 $obBucket = null;
824 foreach(CCloudStorageBucket::GetAllBuckets() as $arBucket)
825 {
826 if($arBucket["ACTIVE"] == "Y" && $arBucket["BUCKET"] === $Params["site"])
827 $obBucket = new CCloudStorageBucket($arBucket["ID"]);
828 }
829
830 if(!$obBucket)
831 {
832 $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT').' [clouds 02]', 'path_corrupt');
833 return;
834 }
835
836 if(!$obBucket->Init())
837 {
838 $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT').' [clouds 03]', 'path_corrupt');
839 return;
840 }
841
842 $path = preg_replace("#[\\\\\\/]+#", "/", "/".$APPLICATION->UnJSEscape($Params['path']));
843 $path_js = $path == "" ? "/" : addslashes(htmlspecialcharsex($path));
844 $path_js = str_replace("//", "/", $path_js);
845
846 $arFiles = $obBucket->ListFiles($path);
847 if(!is_array($arFiles))
848 {
849 $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT').' [clouds 05]', 'path_corrupt');
850 return;
851 }
852?>
853arFDDirs['<?=$path_js?>'] = [];
854arFDFiles['<?=$path_js?>'] = [];
855<?
856 foreach ($arFiles["dir"] as $ind => $dir)
857 {
858?>
859arFDDirs['<?=$path_js?>'][<?=$ind?>] =
860{
861 name : '<?=CUtil::JSEscape($dir)?>',
862 path : '<?=CUtil::JSEscape(preg_replace("#[\\\\\\/]+#", "/", $path."/".$dir));?>',
863 empty: false,
864 permission : {del : false, ren : false},
865 date : '',
866 timestamp : '',
867 size : 0
868};
869<?
870 }
871
872
873 if ($Params['getFiles'])
874 {
875 foreach ($arFiles['file'] as $ind => $file)
876 {
877?>
878arFDFiles['<?=$path_js?>'][<?=$ind?>] =
879{
880 name : '<?=CUtil::JSEscape($file)?>',
881 path : '<?=CUtil::JSEscape($obBucket->GetFileSRC($path."/".$file))?>',
882 permission : {del : false, ren : false},
883 date : '',
884 timestamp : '',
885 size : '<?=$arFiles["file_size"][$ind];?>'
886};
887<?
888 }
889 }
890
891 ?>
892arFDPermission['<?=$path_js?>'] = {
893 new_folder : false,
894 upload : false
895};
896<?
897
898 return;
899 }
900
902
903 $site = $Params['site'];
904 $path = $io->CombinePath("/", $APPLICATION->UnJSEscape($Params['path']));
905 $path_js = $path == "" ? "/" : addslashes(htmlspecialcharsex($path));
906 $path_js = str_replace("//", "/", $path_js);
907 $bCheckEmpty = $Params['bCheckEmpty'];
908
909 $rootPath = CSite::GetSiteDocRoot($site);
910 if (!$io->FileExists($rootPath.$path) && !$io->DirectoryExists($rootPath.$path) && $Params['bThrowException'] === true)
911 {
912 $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT'), 'path_corrupt');
913 return;
914 }
915 elseif (!$USER->CanDoFileOperation('fm_view_listing', array($site, $path)))
916 {
917 $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_ACCESS_DENIED'), 'access_denied');
918 return;
919 }
920
921 $arDirs = array(); $arFiles = array();
922 GetDirList(array($site, $path), $arDirs, $arFiles, array(), array("name_nat" => "asc"), "DF", false, true);
923?>
924arFDDirs['<?=$path_js?>'] = [];
925arFDFiles['<?=$path_js?>'] = [];
926<?
927 $ind = -1;
928 foreach ($arDirs as $Dir)
929 {
930 $name = addslashes(htmlspecialcharsex($Dir["NAME"]));
931 $path_i = addslashes(htmlspecialcharsex($path))."/".$name;
932 $path_i = str_replace("//", "/", $path_i);
933 $arPath_i = Array($site, $path_i);
934
935 if (!$USER->CanDoFileOperation('fm_view_listing', $arPath_i))
936 continue;
937 $ind++;
938
939 $empty = true;
940 if ($bCheckEmpty) // Find subfolders inside
941 {
942 $dirTmp = $io->GetDirectory($rootPath.$path.'/'.$name);
943 $arDirTmpChildren = $dirTmp->GetChildren();
944 foreach ($arDirTmpChildren as $child)
945 {
946 if(!$child->IsDirectory())
947 continue;
948 $empty = false;
949 break;
950 }
951 }
952 $perm_del = $USER->CanDoFileOperation('fm_delete_folder', $arPath_i) ? 'true' : 'false';
953 $perm_ren = $USER->CanDoFileOperation('fm_rename_folder', $arPath_i) ? 'true' : 'false';
954
955?>
956arFDDirs['<?=$path_js?>'][<?=$ind?>] =
957{
958 name : '<?=CUtil::JSEscape($name)?>',
959 path : '<?=CUtil::JSEscape($path_i)?>',
960 empty: <?= $empty ? 'true' : 'false';?>,
961 permission : {del : <?=$perm_del?>, ren : <?=$perm_ren?>},
962 date : '<?=$Dir["DATE"];?>',
963 timestamp : '<?=$Dir["TIMESTAMP"];?>',
964 size : 0
965};
966<?
967 }
968
969 if ($Params['getFiles'])
970 {
971 $ind = -1;
972 foreach ($arFiles as $File)
973 {
974 $name = addslashes(htmlspecialcharsex($File["NAME"]));
975 $path_i = addslashes(htmlspecialcharsex($File["ABS_PATH"]));
976 $path_i = str_replace("//", "/", $path_i);
977 $arPath_i = Array($site, $path_i);
978
979 if (!$USER->CanDoFileOperation('fm_view_file', $arPath_i))
980 continue;
981 $ind++;
982
983 $perm_del = $USER->CanDoFileOperation('fm_delete_file', $arPath_i) ? 'true' : 'false';
984 $perm_ren = $USER->CanDoFileOperation('fm_rename_file', $arPath_i) ? 'true' : 'false';
985
986 $imageAddProps = '';
987 if ($genTmb)
988 {
989 $ext = mb_strtolower(GetFileExtension($name));
990 if (in_array($ext, array('gif','jpg','jpeg','png','jpe','bmp'))) // It is image
991 {
992 $upload_dir = COption::GetOptionString("main", "upload_dir", "upload");
993 $tmbPath = "/".$upload_dir."/tmp/fd_tmb".$path_i;
994 $destinationFile = $rootPath.$tmbPath;
995 if (!file_exists($destinationFile))
996 {
997 $sourceFile = $File['PATH'];
998 if (CFile::ResizeImageFile($sourceFile, $destinationFile, array('width' => 140, 'height' => 110)))
999 $imageAddProps = ",\n".'tmb_src : \''.CUtil::JSEscape($tmbPath).'\'';
1000 }
1001 else
1002 $imageAddProps = ",\n".'tmb_src : \''.CUtil::JSEscape($tmbPath).'\'';
1003 }
1004 }
1005?>
1006arFDFiles['<?=$path_js?>'][<?=$ind?>] =
1007{
1008 name : '<?=CUtil::JSEscape($name)?>',
1009 path : '<?=CUtil::JSEscape($path_i)?>',
1010 permission : {del : <?=$perm_del?>, ren : <?=$perm_ren?>},
1011 date : '<?=$File["DATE"];?>',
1012 timestamp : '<?=$File["TIMESTAMP"];?>',
1013 size : '<?=$File["SIZE"];?>'<?=$imageAddProps?>
1014};
1015<?
1016 }
1017 }
1018
1020 ?>
1021arFDPermission['<?=$path_js?>'] = {
1022 new_folder : <?= ($USER->CanDoFileOperation('fm_create_new_folder',$arPath) ? 'true' : 'false');?>,
1023 upload : <?= ($USER->CanDoFileOperation('fm_upload_file',$arPath) ? 'true' : 'false');?>
1024};
1025<?
1026 }
1027
1028 public static function GetItemsRecursively($Params)
1029 {
1030 global $APPLICATION;
1031
1033
1034 $path = $io->CombinePath("/", $APPLICATION->UnJSEscape($Params['path']));
1035 $rootPath = CSite::GetSiteDocRoot($Params['site']);
1036
1037 if (!$io->FileExists($rootPath.$path) && !$io->DirectoryExists($rootPath.$path))
1038 {
1039 if ($Params['bThrowException'] === true)
1040 {
1041 $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR').': '.GetMessage('BX_FD_PATH_CORRUPT'), 'path_corrupt');
1042 return;
1043 }
1044 $path = '/';
1045 }
1046
1047 $arPath = explode('/', $path);
1048
1049 if ($Params['loadRoot'] !== false)
1050 {
1051 $Params['path'] = '/';
1052 self::GetItems($Params);
1053 }
1054
1055 $curPath = '';
1056 for ($i = 0, $l = count($arPath); $i < $l; $i++)
1057 {
1058 $catalog = trim($arPath[$i], "/\\");
1059
1060 if ($catalog != "")
1061 {
1062 $curPath .= '/'.$catalog;
1063 $Params['path'] = $curPath;
1064 self::GetItems($Params);
1065 }
1066 }
1067 }
1068
1069 public static function MakeNewDir($Params)
1070 {
1071 global $USER, $APPLICATION;
1072
1074 $path = $io->CombinePath("/", $APPLICATION->UnJSEscape($Params['path']));
1075 $site = $Params['site'];
1076
1077 if(CModule::IncludeModule("fileman"))
1078 {
1079 $arPath = Array($site, $path);
1080 $DOC_ROOT = CSite::GetSiteDocRoot($site);
1081 $abs_path = $DOC_ROOT.$path;
1082 $dirname = str_replace("/", "_", $APPLICATION->UnJSEscape($Params['name']));
1083 $strWarning = '';
1084
1085 //Check access to folder
1086 if (!$USER->CanDoFileOperation('fm_create_new_folder', $arPath))
1087 {
1088 $strWarning = GetMessage("ACCESS_DENIED");
1089 }
1090 elseif(!$io->DirectoryExists($abs_path))
1091 {
1092 $strWarning = GetMessage("FD_FOLDER_NOT_FOUND", array('#PATH#' => addslashes(htmlspecialcharsbx($path))));
1093 }
1094 else
1095 {
1096 if ($dirname <> '' && ($mess = self::CheckFileName($dirname)) !== true)
1097 {
1098 $strWarning = $mess;
1099 }
1100 elseif($dirname == '')
1101 {
1102 $strWarning = GetMessage("FD_NEWFOLDER_ENTER_NAME");
1103 }
1104 else
1105 {
1106 $pathto = Rel2Abs($path, $dirname);
1107 if($io->DirectoryExists($DOC_ROOT.$pathto))
1108 $strWarning = GetMessage("FD_NEWFOLDER_EXISTS");
1109 else
1110 $strWarning = CFileMan::CreateDir(Array($site, $pathto));
1111 }
1112 }
1113 }
1114 else
1115 {
1116 $strWarning = GetMessage("BX_FD_NO_FILEMAN");
1117 }
1118
1120
1121 if ($strWarning == '')
1122 self::LoadItems(array('path' => $path, 'site' => $site, 'bAddToMenu' => $Params['bAddToMenu'], 'loadRecursively' => false, 'getFiles' => $Params['getFiles']));
1123 }
1124
1125 public static function Remove($Params)
1126 {
1127 global $USER, $APPLICATION;
1128
1129 $path = $site = '';
1130
1131 if(CModule::IncludeModule("fileman"))
1132 {
1134 $path = Rel2Abs("/", $APPLICATION->UnJSEscape($Params['path']));
1136 $site = $Params['site'];
1137
1138 $arPath = Array($site, $path);
1139 $DOC_ROOT = CSite::GetSiteDocRoot($site);
1140 $abs_path = $DOC_ROOT.$path;
1141 $strWarning = '';
1142
1143 $type = false;
1144 if ($io->DirectoryExists($abs_path))
1145 $type = 'folder';
1146 if ($io->FileExists($abs_path))
1147 $type = 'file';
1148
1149 //Check access to folder or file
1150 if (!$type) // Not found
1151 $strWarning = GetMessage("FD_ELEMENT_NOT_FOUND", array('#PATH#' => addslashes(htmlspecialcharsbx($path))));
1152 elseif (!$USER->CanDoFileOperation('fm_delete_'.$type, $arPath)) // Access denied
1153 $strWarning = GetMessage("ACCESS_DENIED");
1154 else // Ok, delete it!
1156 }
1157 else
1158 {
1159 $strWarning = GetMessage("BX_FD_NO_FILEMAN");
1160 }
1161
1163
1164 if ($strWarning == '')
1165 {
1166 // get parent dir path and load content
1167 $parPath = mb_substr($path, 0, mb_strrpos($path, '/'));
1168 self::LoadItems(array('path' => $parPath, 'site' => $site, 'bAddToMenu' => $Params['bAddToMenu'], 'loadRecursively' => false, 'getFiles' => $Params['getFiles']));
1169 }
1170 }
1171
1172 public static function Rename($Params)
1173 {
1174 global $USER, $APPLICATION;
1175
1176 $path = $site = '';
1177
1178 if(CModule::IncludeModule("fileman"))
1179 {
1181 $path = Rel2Abs("/", $APPLICATION->UnJSEscape($Params['path']));
1183 $site = $Params['site'];
1184
1185 $name = str_replace("/", "_", $APPLICATION->UnJSEscape($Params['name']));
1186 $oldName = str_replace("/", "_", $APPLICATION->UnJSEscape($Params['old_name']));
1187
1188 $DOC_ROOT = CSite::GetSiteDocRoot($site);
1189
1190 $oldPath = Rel2Abs($path, $oldName);
1191 $newPath = Rel2Abs($path, $name);
1192 $oldAbsPath = $DOC_ROOT.$oldPath;
1193 $newAbsPath = $DOC_ROOT.$newPath;
1194 $arPath1 = Array($site, $oldPath);
1195 $arPath2 = Array($site, $newPath);
1196 $strWarning = '';
1197
1198 $type = false;
1199 if ($io->DirectoryExists($oldAbsPath))
1200 $type = 'folder';
1201 if ($io->FileExists($oldAbsPath))
1202 $type = 'file';
1203
1204 if (
1205 $type == 'file' &&
1206 !$USER->CanDoOperation('edit_php') &&
1207 (
1208 str_starts_with($oldName, ".")
1209 ||
1210 str_starts_with($name, ".")
1211 ||
1212 (
1213 HasScriptExtension($oldName) &&
1215 )
1216 ||
1217 (
1219 !HasScriptExtension($oldName)
1220 )
1221 )
1222 )
1223 {
1224 $strWarning = GetMessage("ACCESS_DENIED");
1225 }
1226 elseif (!$type)
1227 $strWarning = GetMessage("FD_ELEMENT_NOT_FOUND", array('#PATH#' => addslashes(htmlspecialcharsbx($path))));
1228 elseif (!$USER->CanDoFileOperation('fm_rename_'.$type,$arPath1) || !$USER->CanDoFileOperation('fm_rename_'.$type,$arPath2))
1229 $strWarning = GetMessage("ACCESS_DENIED");
1230 else
1231 {
1232 if ($name <> '' && ($mess = self::CheckFileName($name)) !== true)
1233 $strWarning = $mess;
1234 else if($name == '')
1235 $strWarning = GetMessage("FD_ELEMENT_ENTER_NAME");
1236 else
1237 {
1238 if($io->FileExists($DOC_ROOT.$newPath) || $io->DirectoryExists($DOC_ROOT.$newPath))
1239 $strWarning = GetMessage("FD_ELEMENT_EXISTS");
1240 elseif(!$io->Rename($oldAbsPath, $newAbsPath))
1241 $strWarning = GetMessage("FD_RENAME_ERROR");
1242 }
1243 }
1244 }
1245 else
1246 {
1247 $strWarning = GetMessage("BX_FD_NO_FILEMAN");
1248 }
1249
1251
1252 if ($strWarning == '')
1253 self::LoadItems(array('path' => $path, 'site' => $site, 'bAddToMenu' => $Params['bAddToMenu'], 'loadRecursively' => false, 'getFiles' => $Params['getFiles']));
1254 }
1255
1256 public static function CheckFileName($str)
1257 {
1259 if (!$io->ValidateFilenameString($str))
1260 return GetMessage("FD_INCORRECT_NAME");
1261 return true;
1262 }
1263
1264 public static function EchoActionStatus($strWarning = '')
1265 {
1266?>
1267 <script>
1268 <? if ($strWarning == ''): ?>
1269 window.action_status = true;
1270 <?else: ?>
1271 window.action_warning = '<?= CUtil::JSEscape($strWarning)?>';
1272 window.action_status = false;
1273 <?endif;?>
1274 </script>
1275<?
1276 }
1277
1278 public static function SetUserConfig($Params)
1279 {
1280 global $APPLICATION;
1281 $Params['path'] = $APPLICATION->UnJSEscape($Params['path']);
1282 $Params['site'] = $APPLICATION->UnJSEscape($Params['site']);
1283 $Params['view'] = in_array($Params['view'], array('detail', 'preview')) ? $Params['view'] : 'list';
1284 $Params['sort'] = in_array($Params['sort'], array('size', 'type', 'date')) ? $Params['sort'] : 'name';
1285 $Params['sort_order'] = ($Params['sort_order'] == 'asc') ? 'asc' : 'des';
1286
1287 CUserOptions::SetOption("fileman", "file_dialog_config", addslashes($Params['site'].';'.$Params['path'].';'.$Params['view'].';'.$Params['sort'].';'.$Params['sort_order']));
1288 }
1289
1290 public static function PreviewFlash($Params)
1291 {
1292 if(CModule::IncludeModule("fileman"))
1293 {
1294 global $APPLICATION, $USER;
1295
1296 $path = $Params['path'];
1298 $path = Rel2Abs("/", $path);
1299 $arPath = Array($Params['site'], $path);
1300
1301 if(!$USER->CanDoFileOperation('fm_view_file', $arPath))
1302 $path = '';
1303
1304 if ($path == "")
1305 return;
1306
1307 $APPLICATION->RestartBuffer();
1308?>
1309<HTML>
1310<HEAD></HEAD>
1311<BODY id="__flash" style="margin:0; border-width: 0;">
1312<embed id="__flash_preview" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="__flash_preview" quality="high" width="<?=$Params['width']?>" height="<?=$Params['height']?>" src="<?=htmlspecialcharsex($path)?>"></embed>
1313</BODY>
1314</HTML>
1315<?
1316 die();
1317 }
1318 }
1319
1320 public static function ShowUploadForm($Params)
1321 {
1322 $lang = htmlspecialcharsex($Params['lang']);
1323 $site = htmlspecialcharsex($Params['site']);
1324 $res = $Params['file'] ? self::UploadFile($Params) : '';
1325 ?>
1326<HTML>
1327<HEAD><?=$res?></HEAD>
1328<BODY style="margin:0 !important; background-color:#F4F4F4; font-family:Verdana,serif;">
1329<form name="frmLoad" action="file_dialog.php?action=uploader&lang=<?=$lang?>&site=<?=$site?>&<?=bitrix_sessid_get()?>" onsubmit="return parent.oBXDialogControls.Uploader.OnSubmit();" method="post" enctype="multipart/form-data">
1330 <input id="__bx_fd_server_site" type="hidden" name="cur_site" value="<?=$site?>" />
1331 <table style="width: 540px; height: 123px; font-size:70%">
1332 <tr height="0%">
1333 <td style="width:40%;" align="left">
1334 <?=GetMessage('FD_LOAD_FILE')?>:
1335 </td>
1336 <td style="width:60%; padding-top: 0;" valign="top" align="left">
1337 <input id="__bx_fd_load_file" size="45" type="file" name="load_file">
1338 </td>
1339 </tr>
1340 <tr height="0%">
1341 <td style="width:40%;" align="left">
1342 <?=GetMessage("FD_FILE_NAME_ON_SERVER");?>
1343 </td>
1344 <td style="width:60%;" align="left">
1345 <input id="__bx_fd_server_file_name" style="width:100%;" type="text">
1346 </td>
1347 </tr>
1348 <tr height="100%">
1349 <td style="width:100%;" valign="top" align="left" colspan="2">
1350 <table style="font-size:100%"><tr>
1351 <td><input id="_bx_fd_upload_and_open" value="Y" type="checkbox" name="upload_and_open" checked="checked"></td>
1352 <td><label for="_bx_fd_upload_and_open"> <?=GetMessage("FD_UPLOAD_AND_OPEN");?></label></td>
1353 </tr></table>
1354 </td>
1355 </tr>
1356 <tr height="0%">
1357 <td style="width:100%; padding:0 8px 5px 0" valign="bottom" align="right" colSpan="2">
1358 <input type="submit" value="<?=GetMessage("FD_BUT_LOAD");?>">
1359 <input style="width:100px;" type="button" onclick="parent.oBXFileDialog.Close()" value="<?=GetMessage("FD_BUT_CANCEL");?>">
1360 </td>
1361 </tr>
1362 </table>
1363 <input type="hidden" name="MAX_FILE_SIZE" value="1000000000">
1364 <input type="hidden" name="lang" value="<?=$lang?>">
1365 <input type="hidden" name="site" value="<?=$site?>">
1366 <input id="__bx_fd_rewrite" type="hidden" name="rewrite" value="N">
1367 <input id="__bx_fd_upload_path" type="hidden" name="path" value="">
1368 <input id="__bx_fd_upload_fname" type="hidden" name="filename" value="">
1369</form>
1370</BODY>
1371</HTML>
1372<?
1373 }
1374
1375 public static function UploadFile($Params)
1376 {
1377 $buffer = 'parent.oWaitWindow.Hide();';
1378 $F = $Params['file'];
1379
1381
1382 if (isset($F["tmp_name"]) && $F["tmp_name"] <> '' && $F["name"] <> '' || is_uploaded_file($F["tmp_name"]))
1383 {
1384 global $APPLICATION, $USER;
1385 $strWarning = '';
1386 $filename = $Params['filename'];
1387 $path = $Params['path'];
1388 $site = $Params['site'];
1389 $upload_and_open = $Params['upload_and_open'];
1390 $rootPath = CSite::GetSiteDocRoot($site);
1391
1392 if($filename == '')
1393 $filename = $F["name"];
1394
1395 $pathto = Rel2Abs($path, $filename);
1396
1397 if ($filename <> '' && ($mess = self::CheckFileName($filename)) !== true)
1398 $strWarning = $mess;
1399
1400 if($strWarning == '')
1401 {
1402 $fn = $io->ExtractNameFromPath($pathto);
1403 if($USER->CanDoFileOperation('fm_upload_file', array($site, $pathto)) &&
1404 ($USER->IsAdmin() || (!HasScriptExtension($fn) && !str_starts_with($fn, ".") && $io->ValidateFilenameString($fn)))
1405 )
1406 {
1407 if(!$io->FileExists($rootPath.$pathto) || $_REQUEST["rewrite"] == "Y")
1408 {
1409 //************************** Quota **************************//
1410 $bQuota = true;
1411 $quota = null;
1412 if(COption::GetOptionInt("main", "disk_space") > 0)
1413 {
1414 $bQuota = false;
1415 $quota = new CDiskQuota();
1416 if ($quota->checkDiskQuota(array("FILE_SIZE"=>filesize($F["tmp_name"]))))
1417 $bQuota = true;
1418 }
1419 //************************** Quota **************************//
1420 if ($bQuota)
1421 {
1422 $io->Copy($F["tmp_name"], $rootPath.$pathto);
1423 $flTmp = $io->GetFile($rootPath.$pathto);
1424 $flTmp->MarkWritable();
1425
1426 if(COption::GetOptionInt("main", "disk_space") > 0)
1427 CDiskQuota::updateDiskQuota("file", $flTmp->GetFileSize(), "copy");
1428
1429 $buffer = 'setTimeout(function(){parent.oBXDialogControls.Uploader.OnAfterUpload("'.$filename.'", '.($upload_and_open == "Y" ? 'true' : 'false').');}, 50);';
1430 }
1431 else
1432 {
1433 $strWarning = $quota->LAST_ERROR;
1434 }
1435 }
1436 else
1437 {
1438 $strWarning = GetMessage("FD_LOAD_EXIST_ALERT");
1439 }
1440 }
1441 else
1442 {
1443 $strWarning = GetMessage("FD_LOAD_DENY_ALERT");
1444 }
1445 }
1446 }
1447 else
1448 {
1449 $strWarning = GetMessage("FD_LOAD_ERROR_ALERT");
1450 }
1451
1452 if ($strWarning <> '')
1453 $buffer = 'alert("'.addslashes(htmlspecialcharsex($strWarning)).'");';
1454
1455 return '<script>'.$buffer.'</script>';
1456 }
1457
1458}
$path
Определения access_edit.php:21
return select
Определения access_edit.php:440
<?=$taskID?> selected
Определения access_edit.php:348
$type
Определения options.php:106
$arSites
Определения options.php:15
$arTypes
Определения options.php:23
global $APPLICATION
Определения include.php:80
if($canUseYandexMarket) $strWarning
Определения options.php:74
Определения json.php:9
Определения file_dialog.php:8
static ShowJS($Params)
Определения file_dialog.php:579
static EchoActionStatus($strWarning='')
Определения file_dialog.php:1264
static PreviewFlash($Params)
Определения file_dialog.php:1290
static AppendLangMess()
Определения file_dialog.php:673
static MakeNewDir($Params)
Определения file_dialog.php:1069
static AttachJSScripts()
Определения file_dialog.php:256
static Remove($Params)
Определения file_dialog.php:1125
static UploadFile($Params)
Определения file_dialog.php:1375
static BuildDialog($Params)
Определения file_dialog.php:367
static GetItemsRecursively($Params)
Определения file_dialog.php:1028
static GetItems($Params)
Определения file_dialog.php:792
static Start($Params)
Определения file_dialog.php:270
static Rename($Params)
Определения file_dialog.php:1172
static CheckFileName($str)
Определения file_dialog.php:1256
static SetUserConfig($Params)
Определения file_dialog.php:1278
static ShowScript($arConfig)
Определения file_dialog.php:9
static ShowUploadForm($Params)
Определения file_dialog.php:1320
static LoadItems($Params)
Определения file_dialog.php:332
static GetMenuTypes($site, $path, $bEchoResult=false)
Определения file_dialog.php:720
Определения admin_lib.php:1349
static GetByID($ID)
Определения language.php:99
static GetInstance()
Определения virtual_io.php:60
static GetAllBuckets()
Определения storage_bucket.php:654
Определения quota.php:6
static CreateDir($path)
Определения fileman.php:348
static SecurePathVar($str)
Определения fileman.php:2111
static DeleteEx($path)
Определения fileman.php:475
static GetMenuArray($abs_path)
Определения fileman.php:321
$str
Определения commerceml2.php:63
$abs_path
Определения component_props2.php:76
if(!defined("ADMIN_AJAX_MODE") &&(($_REQUEST["mode"] ?? '') !='excel')) $buffer
Определения epilog_admin_after.php:40
& nbsp
Определения epilog_main_admin.php:38
$filename
Определения file_edit.php:47
$DOC_ROOT
Определения file_edit.php:66
$arPath
Определения file_edit.php:72
hidden PROPERTY[<?=$propertyIndex?>][CODE]<?=htmlspecialcharsEx( $propertyCode)?> height
Определения file_new.php:759
bx popup label bx width30 PAGE_NEW_MENU_NAME text width
Определения file_new.php:677
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$armt
Определения options.php:675
$res
Определения filter_act.php:7
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$catalog
Определения iblock_catalog_edit.php:135
global $USER
Определения csv_new_run.php:40
$io
Определения csv_new_run.php:98
endif
Определения csv_new_setup.php:990
GetDirList($path, &$arDirs, &$arFiles, $arFilter=array(), $sort=array(), $type="DF", $bLogical=false, $task_mode=false)
Определения admin_tools.php:214
if(!defined('SITE_ID')) $lang
Определения include.php:91
$l
Определения options.php:783
GetFileExtension($path)
Определения tools.php:2972
HasScriptExtension($check_name)
Определения tools.php:2956
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
Rel2Abs($curdir, $relpath)
Определения tools.php:3297
GetMessage($name, $aReplace=null)
Определения tools.php:3397
for($i=1, $n=count($aMenuLinksTmp); $i<=$n; $i++) $aMenuLinksItem
Определения menu_edit.php:290
$aMenuLinksTmp
Определения menu_edit.php:261
$name
Определения menu_edit.php:35
$arFiles
Определения options.php:60
global_menu_<?echo $menu["menu_id"]?> adm main menu item icon adm main menu item text text adm main menu hover adm submenu menucontainer menu_id menu_id items_id items_id desktop menu_id block none adm global submenu<?=($subMenuDisplay=="block" ? " adm-global-submenu-active" :"")?> global_submenu_<?echo $menu["menu_id"]?> text MAIN_PR_ADMIN_FAV items adm submenu items wrap adm submenu items stretch wrap BX adminMenu itemsStretchScroll()"> <table class if (!empty( $menu["items"])) elseif ( $menu[ 'menu_id']=='desktop') if ( $menu[ 'menu_id']=='desktop') endforeach
Определения prolog_main_admin.php:255
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
$dir
Определения quickway.php:303
if(empty($signedUserToken)) $key
Определения quickway.php:257
die
Определения quickway.php:367
lang
Определения options.php:182
$i
Определения factura.php:643
font style
Определения invoice.php:442
font size
Определения invoice.php:442
</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
endfor
Определения template.php:569
text align
Определения template.php:556
$title
Определения pdf.php:123
$val
Определения options.php:1793
path
Определения template_copy.php:201
$arDirs
Определения translate_tools.php:10
$n
Определения update_log.php:107
$site
Определения yandex_run.php:614