1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
html_editor.php
См. документацию.
1<?
6
7use Bitrix\AI;
11
12IncludeModuleLangFile(__FILE__);
14{
15 private const TASKS_CATEGORY = 'tasks';
16
17 private static
18 $thirdLevelId,
19 $arComponents;
20
21 private
22 $content,
23 $id,
24 $name,
25 $jsConfig = [],
26 $cssIframePath,
27 $bAutorized,
28 $bAllowPhp,
29 $display,
30 $inputName,
31 $inputId;
32
33 const CACHE_TIME = 31536000; // 365 days
34
35 private function Init($arParams)
36 {
37 global $USER;
38 ?>
39 <script>
40 (function(window) {
41 if (!window.BXHtmlEditor)
42 {
43 var BXHtmlEditor = {
44 editors: {},
45 configs: {},
46 dialogs: {},
47 Controls: {},
48 SaveConfig: function(config)
49 {
50 BX.ready(function()
51 {
52 if (config && config.id)
53 {
54 BXHtmlEditor.configs[config.id] = config;
55 }
56 }
57 );
58 },
59 Show: function(config, id)
60 {
61 BX.ready(function()
62 {
63 if ((!config || typeof config != 'object') && id && BXHtmlEditor.configs[id])
64 {
65 config = BXHtmlEditor.configs[id];
66 }
67
68 if (config && typeof config == 'object')
69 {
70 if (!BXHtmlEditor.editors[config.id] || !BXHtmlEditor.editors[config.id].Check())
71 {
72 BXHtmlEditor.editors[config.id] = new window.BXEditor(config);
73 }
74 else
75 {
76 BXHtmlEditor.editors[config.id].CheckAndReInit();
77 }
78 }
79 }
80 );
81 },
82 Hide: function(id)
83 {
84 if (BXHtmlEditor.editors[id])
85 {
86 BXHtmlEditor.editors[config.id].Hide();
87 }
88 },
89 Get: function(id)
90 {
91 return BXHtmlEditor.editors[id] || false;
92 },
93 OnBeforeUnload: function()
94 {
95 for (var id in BXHtmlEditor.editors)
96 {
97 if (BXHtmlEditor.editors.hasOwnProperty(id) &&
98 BXHtmlEditor.editors[id].config.askBeforeUnloadPage === true &&
99 BXHtmlEditor.editors[id].IsShown() &&
100 BXHtmlEditor.editors[id].IsContentChanged() &&
101 !BXHtmlEditor.editors[id].IsSubmited() &&
102 BXHtmlEditor.editors[id].beforeUnloadHandlerAllowed !== false)
103 {
104 if(typeof(BX.desktopUtils) != 'undefined' && typeof(BX.desktopUtils.isChangedLocationToBx) == 'function' && BX.desktopUtils.isChangedLocationToBx())
105 {
106 return;
107 }
108 return BXHtmlEditor.editors[id].config.beforeUnloadMessage || BX.message('BXEdExitConfirm');
109 }
110 }
111 },
112
113 ReplaceNewLines : function(content)
114 {
115 content = content.replace(/<[^<>]*br>\n/ig, '#BX_BR#');
116 var contentTmp;
117 while (true)
118 {
119 contentTmp = content.replace(/([\s|\S]+)\n([\s|\S]+)/gi, function (s, s1, s2)
120 {
121 if (s1.match(/>\s*$/) || s2.match(/^\s*</))
122 return s;
123 return s1 + '#BX_BR#' + s2;
124 }
125 );
126 if (contentTmp == content)
127 {
128 break;
129 }
130 else
131 {
132 content = contentTmp;
133 }
134 }
135
136 content = content.replace(/#BX_BR#/ig, "<br>\n");
137
138 return content;
139 },
140
141 ReplaceNewLinesBack: function(content)
142 {
143 content = content.replace(/<[^<>]*br>\n/ig, '#BX_BR#');
144 var contentTmp;
145 while (true)
146 {
147 contentTmp = content.replace(/([\s|\S]+)#BX_BR#([\s|\S]+)/gi, function (s, s1, s2)
148 {
149 if (s1.match(/>\s*$/) || s2.match(/^\s*</))
150 return s;
151 return s1 + '\n' + s2;
152 }
153 );
154 if (contentTmp == content)
155 {
156 break;
157 }
158 else
159 {
160 content = contentTmp;
161 }
162 }
163
164 content = content.replace(/#BX_BR#/ig, "<br>\n");
165
166 return content;
167 }
168 };
169
170 window.BXHtmlEditor = BXHtmlEditor;
171 window.onbeforeunload = BXHtmlEditor.OnBeforeUnload;
172 }
173
174 BX.onCustomEvent(window, "OnBXHtmlEditorInit");
175 top.BXHtmlEditorAjaxResponse = {};
176 })(window);
177 </script><?
178
179 $basePath = '/bitrix/js/fileman/html_editor/';
180 $this->id = (isset($arParams['id']) && $arParams['id'] <> '') ? $arParams['id'] : 'bxeditor'.mb_substr(uniqid(mt_rand(), true), 0, 4);
181 $this->id = preg_replace("/[^a-zA-Z0-9_:\.]/is", "", $this->id);
182 if (isset($arParams['name']))
183 {
184 $this->name = preg_replace("/[^a-zA-Z0-9_:\.]/is", "", $arParams['name']);
185 }
186 else
187 {
188 $this->name = $this->id;
189 }
190
191 $this->cssIframePath = $this->GetActualPath($basePath.'iframe-style.css');
192
193 CJSCore::RegisterExt('html_editor', array(
194 'js' => array(
195 $basePath.'range.js',
196 $basePath.'html-actions.js',
197 $basePath.'html-views.js',
198 $basePath.'html-parser.js',
199 $basePath.'html-base-controls.js',
200 $basePath.'html-controls.js',
201 $basePath.'html-components.js',
202 $basePath.'html-snippets.js',
203 $basePath.'html-editor.js',
204 '/bitrix/js/main/dd.js'
205 ),
206 'css' => $basePath.'html-editor.css',
207 'rel' => array('ui.design-tokens', 'date', 'timer')
208 ));
209 CUtil::InitJSCore(array('html_editor'));
210
212
213 foreach(GetModuleEvents("fileman", "OnBeforeHTMLEditorScriptRuns", true) as $arEvent)
214 ExecuteModuleEventEx($arEvent);
215
216 $this->bAutorized = is_object($USER) && $USER->IsAuthorized();
217 if (isset($arParams['allowPhp']) && !isset($arParams['bAllowPhp']))
218 {
219 $arParams['bAllowPhp'] = $arParams['allowPhp'];
220 }
221
222 $this->bAllowPhp = $arParams['bAllowPhp'] !== false;
223
224 $arParams['limitPhpAccess'] = $arParams['limitPhpAccess'] === true;
225 $this->display = !isset($arParams['display']) || $arParams['display'];
226
227 $arParams["bodyClass"] = COption::GetOptionString("fileman", "editor_body_class", "");
228 $arParams["bodyId"] = COption::GetOptionString("fileman", "editor_body_id", "");
229
230 $this->content = ($arParams['content'] ?? '');
231 $this->content = preg_replace("/\r\n/is", "\n", $this->content);
232
233 $this->inputName = isset($arParams['inputName']) ? $arParams['inputName'] : $this->name;
234 $this->inputId = isset($arParams['inputId']) ? $arParams['inputId'] : 'html_editor_content_id';
235
236 $arParams["bbCode"] = (isset($arParams["bbCode"]) && $arParams["bbCode"]) || (isset($arParams["BBCode"]) && $arParams["BBCode"]);
237
238 // Site id
239 if (!isset($arParams['siteId']))
240 {
241 $siteId = CSite::GetDefSite();
242 }
243 else
244 {
245 $siteId = $arParams['siteId'];
246 $res = CSite::GetByID($siteId);
247 if (!$res->Fetch())
248 {
249 $siteId = CSite::GetDefSite();
250 }
251 }
252
253 if (!isset($siteId) && defined('SITE_ID'))
254 {
256 $res = CSite::GetByID($siteId);
257 if (!$res->Fetch())
258 {
259 $siteId = CSite::GetDefSite();
260 }
261 }
262
263 $templateId = null;
264 if (isset($arParams['templateId']))
265 {
266 $templateId = $arParams['templateId'];
267 }
268 elseif (defined('SITE_TEMPLATE_ID'))
269 {
270 $templateId = SITE_TEMPLATE_ID;
271 }
272
273 if (!isset($templateId) && isset($_GET['siteTemplateId']))
274 {
275 $templateId = $_GET['siteTemplateId'];
276 }
277
278 if ($arParams["bbCode"])
279 {
280 $arTemplates = array();
281 $arSnippets = array();
282 $templateParams = array();
283 }
284 else
285 {
286 if (isset($arParams['arTemplates']))
287 {
288 $arTemplates = $arParams['arTemplates'];
289 }
290 else
291 {
292 $arTemplates = self::GetSiteTemplates();
293 }
294
295 if (!isset($templateId) && isset($siteId))
296 {
297 $dbSiteRes = CSite::GetTemplateList($siteId);
298 $first = false;
299 while($arSiteRes = $dbSiteRes->Fetch())
300 {
301 if (!$first)
302 {
303 $first = $arSiteRes['TEMPLATE'];
304 }
305 if ($arSiteRes['CONDITION'] == "")
306 {
307 $templateId = $arSiteRes['TEMPLATE'];
308 break;
309 }
310 }
311
312 if (!isset($templateId))
313 {
314 $templateId = $first ? $first : '';
315 }
316 }
317
318 $arSnippets = array($templateId => self::GetSnippets($templateId));
320 }
321
322 $userSettings = array(
323 'view' => isset($arParams["view"]) ? $arParams["view"] : 'wysiwyg',
324 'split_vertical' => 0,
325 'split_ratio' => 1,
326 'taskbar_shown' => 0,
327 'taskbar_width' => 250,
328 'specialchars' => false,
329 'clean_empty_spans' => 'Y',
330 'paste_clear_colors' => 'Y',
331 'paste_clear_borders' => 'Y',
332 'paste_clear_decor' => 'Y',
333 'paste_clear_table_dimen' => 'Y',
334 'show_snippets' => 'Y',
335 'link_dialog_type' => 'internal'
336 );
337
338 $settingsKey = self::GetSettingKey($arParams);
339 $curSettings = CUserOptions::GetOption("html_editor", $settingsKey, false, $USER->GetId());
340 if (is_array($curSettings))
341 {
342 foreach ($userSettings as $k => $val)
343 {
344 if (isset($curSettings[$k]))
345 {
346 $userSettings[$k] = $curSettings[$k];
347 }
348 }
349 }
350
351 if(!isset($arParams["uploadImagesFromClipboard"]) && $arParams["bbCode"])
352 {
353 $arParams["uploadImagesFromClipboard"] = false;
354 }
355
356 if(!isset($arParams["usePspell"]))
357 {
358 $arParams["usePspell"] = COption::GetOptionString("fileman", "use_pspell", "N");
359 }
360
361 if(!isset($arParams["useCustomSpell"]))
362 {
363 $arParams["useCustomSpell"] = COption::GetOptionString("fileman", "use_custom_spell", "Y");
364 }
365
366 $arParams["showComponents"] = isset($arParams["showComponents"]) ? $arParams["showComponents"] : true;
367 $arParams["showSnippets"] = isset($arParams["showSnippets"]) ? $arParams["showSnippets"] : true;
368 $arParams["showSnippets"] = $arParams["showSnippets"] && $userSettings['show_snippets'] != 'N';
369
370 $arParams["showTaskbars"] = $arParams["showTaskbars"] ?? null;
371 if(!isset($arParams["initConponentParams"]))
372 $arParams["initConponentParams"] = $arParams["showTaskbars"] !== false && $arParams["showComponents"] && ($arParams['limitPhpAccess'] || $arParams['bAllowPhp']);
373 if (empty($arParams["actionUrl"]))
374 {
375 $arParams["actionUrl"] = $arParams["bbCode"] ? '/bitrix/tools/html_editor_action.php' : '/bitrix/admin/fileman_html_editor_action.php';
376 }
377
378 $arParams["lazyLoad"] = isset($arParams["lazyLoad"]) ? $arParams["lazyLoad"] : false;
379
380 $arParams['copilotParams'] ??= [];
381 if ($this->GetAiCategory($this->id, $this->name) !== null)
382 {
383 $arParams['copilotParams']['category'] ??= $this->GetAiCategory($this->id, $this->name);
384 $arParams['copilotParams']['contextId'] ??= 'bxhtmled_copilot';
385 $arParams['copilotParams']['moduleId'] ??= 'main';
386 }
387
388 if (!empty($arParams['copilotParams']['category']))
389 {
390 $arParams['copilotParams']['invitationLineMode'] ??= 'lastLine';
391 }
392
393 $arParams['isCopilotEnabled'] ??= null;
394 $isCopilotEnabled = ($arParams['isCopilotEnabled'] !== false)
395 && !empty($arParams['copilotParams']['category'])
396 && ($arParams['isCopilotTextEnabledBySettings'] ?? true)
397 && $this->isCopilotEnabled()
398 && !$this->bAllowPhp
399 ;
400
401 if ($isCopilotEnabled)
402 {
403 \Bitrix\Main\UI\Extension::load(['ai.copilot']);
404 }
405
406 $this->jsConfig = [
407 'id' => $this->id,
408 'isCopilotEnabled' => $isCopilotEnabled,
409 'isCopilotImageEnabledBySettings' => $arParams['isCopilotImageEnabledBySettings'] ?? true,
410 'isCopilotTextEnabledBySettings' => $arParams['isCopilotTextEnabledBySettings'] ?? true,
411 'copilotParams' => $arParams["copilotParams"],
412 'isMentionUnavailable' => $arParams['isMentionUnavailable'] ?? false,
413 'inputName' => $this->inputName,
414 'content' => $this->content,
415 'width' => $arParams['width'],
416 'height' => $arParams['height'],
417 'allowPhp' => $this->bAllowPhp,
418 'limitPhpAccess' => $arParams['limitPhpAccess'],
419 'templates' => $arTemplates,
420 'templateId' => $templateId,
421 'templateParams' => $templateParams,
422 'componentFilter' => $arParams['componentFilter'] ?? null,
423 'snippets' => $arSnippets,
424 'placeholder' => isset($arParams['placeholder']) ? $arParams['placeholder'] : 'Text here...',
425 'actionUrl' => $arParams["actionUrl"],
426 'cssIframePath' => $this->cssIframePath,
427 'bodyClass' => $arParams["bodyClass"],
428 'fontSize' => isset($arParams['fontSize']) && is_string($arParams['fontSize']) ? $arParams['fontSize'] : '14px',
429 'bodyId' => $arParams["bodyId"],
430 'designTokens' => \Bitrix\Main\UI\Extension::getHtml('ui.design-tokens'),
431 'spellcheck_path' => $basePath.'html-spell.js?v='.filemtime($_SERVER['DOCUMENT_ROOT'].$basePath.'html-spell.js'),
432 'usePspell' => $arParams["usePspell"],
433 'useCustomSpell' => $arParams["useCustomSpell"],
434 'bbCode' => $arParams["bbCode"],
435 'askBeforeUnloadPage' => ($arParams["askBeforeUnloadPage"] ?? null) !== false,
436 'settingsKey' => $settingsKey,
437 'showComponents' => $arParams["showComponents"],
438 'showSnippets' => $arParams["showSnippets"],
439 // user settings
440 'view' => $userSettings['view'],
441 'splitVertical' => $userSettings['split_vertical'] ? true : false,
442 'splitRatio' => $userSettings['split_ratio'],
443 'taskbarShown' => $userSettings['taskbar_shown'] ? true : false,
444 'taskbarWidth' => $userSettings['taskbar_width'],
445 'lastSpecialchars' => $userSettings['specialchars'] ? explode('|', $userSettings['specialchars']) : false,
446 'cleanEmptySpans' => $userSettings['clean_empty_spans'] != 'N',
447 'pasteSetColors' => $userSettings['paste_clear_colors'] != 'N',
448 'pasteSetBorders' => $userSettings['paste_clear_borders'] != 'N',
449 'pasteSetDecor' => $userSettings['paste_clear_decor'] != 'N',
450 'pasteClearTableDimen' => $userSettings['paste_clear_table_dimen'] != 'N',
451 'linkDialogType' => $userSettings['link_dialog_type'],
452 'lazyLoad' => $arParams["lazyLoad"],
453 'siteId' => $siteId
454 ];
455
456 if (($this->bAllowPhp || $arParams['limitPhpAccess']) && $arParams["showTaskbars"] !== false)
457 {
458 $this->jsConfig['components'] = self::GetComponents($templateId, false, $arParams['componentFilter'] ?? null);
459 }
460
461 if (isset($arParams["initAutosave"]))
462 {
463 $this->jsConfig["initAutosave"] = $arParams["initAutosave"];
464 }
465
466 if (isset($arParams["uploadImagesFromClipboard"]))
467 {
468 $this->jsConfig["uploadImagesFromClipboard"] = $arParams["uploadImagesFromClipboard"];
469 }
470
471 if (isset($arParams["useFileDialogs"]))
472 {
473 $this->jsConfig["useFileDialogs"] = $arParams["useFileDialogs"];
474 }
475 elseif (\Bitrix\Main\ModuleManager::isModuleInstalled('bitrix24'))
476 {
477 $this->jsConfig["useFileDialogs"] = false;
478 }
479
480 if (isset($arParams["showTaskbars"]))
481 {
482 $this->jsConfig["showTaskbars"] = $arParams["showTaskbars"];
483 }
484
485 if (isset($arParams["showNodeNavi"]))
486 {
487 $this->jsConfig["showNodeNavi"] = $arParams["showNodeNavi"];
488 }
489
490 if (isset($arParams["controlsMap"]))
491 {
492 $this->jsConfig["controlsMap"] = $arParams["controlsMap"];
493 }
494
495 if (isset($arParams["arSmiles"]))
496 {
497 $this->jsConfig["smiles"] = $arParams["arSmiles"];
498 }
499
500 if (isset($arParams["arSmilesSet"]))
501 {
502 $this->jsConfig["smileSets"] = $arParams["arSmilesSet"];
503 }
504
505 if (isset($arParams["iframeCss"]))
506 {
507 $this->jsConfig["iframeCss"] = $arParams["iframeCss"];
508 }
509
510 if (isset($arParams["beforeUnloadMessage"]))
511 {
512 $this->jsConfig["beforeUnloadMessage"] = $arParams["beforeUnloadMessage"];
513 }
514
515 if (isset($arParams["setFocusAfterShow"]))
516 {
517 $this->jsConfig["setFocusAfterShow"] = $arParams["setFocusAfterShow"];
518 }
519
520 if (isset($arParams["relPath"]))
521 {
522 $this->jsConfig["relPath"] = $arParams["relPath"];
523 }
524
525 // autoresize
526 if (isset($arParams["autoResize"]))
527 {
528 $this->jsConfig["autoResize"] = $arParams["autoResize"];
529 if (isset($arParams['autoResizeOffset']))
530 {
531 $this->jsConfig['autoResizeOffset'] = $arParams['autoResizeOffset'];
532 }
533 if (isset($arParams['autoResizeMaxHeight']))
534 {
535 $this->jsConfig['autoResizeMaxHeight'] = $arParams['autoResizeMaxHeight'];
536 }
537 if (isset($arParams['autoResizeSaveSize']))
538 {
539 $this->jsConfig['autoResizeSaveSize'] = $arParams['autoResizeSaveSize'] !== false;
540 }
541 }
542
543 if (isset($arParams["minBodyWidth"]))
544 {
545 $this->jsConfig["minBodyWidth"] = $arParams["minBodyWidth"];
546 }
547 if (isset($arParams["minBodyHeight"]))
548 {
549 $this->jsConfig["minBodyHeight"] = $arParams["minBodyHeight"];
550 }
551 if (isset($arParams["normalBodyWidth"]))
552 {
553 $this->jsConfig["normalBodyWidth"] = $arParams["normalBodyWidth"];
554 }
555
556 if (isset($arParams['autoLink']))
557 {
558 $this->jsConfig['autoLink'] = $arParams['autoLink'];
559 }
560
561 return $arParams;
562 }
563
564 public function isCopilotEnabled(): bool
565 {
566 if (!Loader::includeModule('ai'))
567 {
568 return false;
569 }
570
571 $engine = AI\Engine::getByCategory(AI\Engine::CATEGORIES['text'], AI\Context::getFake());
572
573 return !is_null($engine);
574 }
575
576 function GetAiCategory(string $id, string $name): ?string
577 {
578 $isTasks = str_contains($id, 'tasks');
579
580 if ($isTasks)
581 {
582 return self::TASKS_CATEGORY;
583 }
584
585 return null;
586 }
587
589 {
590 return $path.'?'.@filemtime($_SERVER['DOCUMENT_ROOT'].$path);
591 }
592
593 function Show($arParams)
594 {
595 CJSCore::Init(array('window', 'ajax', 'fx'));
596
597 $this->InitLangMess();
598 $arParams = $this->Init($arParams);
599
600 if (($arParams["uploadImagesFromClipboard"] ?? null) !== false)
601 CJSCore::Init(array("uploader"));
602
603 $event = new Event(
604 'fileman',
605 'HtmlEditor:onBeforeBuild',
606 [$this]
607 );
608
609 EventManager::getInstance()->send($event);
610
611 // Display all DOM elements, dialogs
612 $this->BuildSceleton($this->display);
613 $this->Run($this->display);
614
615 if ($arParams["initConponentParams"])
616 {
618 'requestUrl' => '/bitrix/admin/fileman_component_params.php'
619 ));
620 }
621 }
622
623 function BuildSceleton($display = true)
624 {
625 $width = isset($this->jsConfig['width']) && intval($this->jsConfig['width']) > 0 ? $this->jsConfig['width'] : "100%";
626 $height = isset($this->jsConfig['height']) && intval($this->jsConfig['height']) > 0 ? $this->jsConfig['height'] : "100%";
627
628 $widthUnit = mb_strpos($width, "%") === false ? "px" : "%";
629 $heightUnit = mb_strpos($height, "%") === false ? "px" : "%";
630 $width = intval($width);
631 $height = intval($height);
632
633 ?>
634 <div class="bx-html-editor" id="bx-html-editor-<?=$this->id?>" style="width:<?= $width.$widthUnit?>; height:<?= $height.$heightUnit?>; <?= $display ? '' : 'display: none;'?>">
635 <div class="bxhtmled-toolbar-cnt" id="bx-html-editor-tlbr-cnt-<?=$this->id?>">
636 <div class="bxhtmled-toolbar" id="bx-html-editor-tlbr-<?=$this->id?>"></div>
637 </div>
638 <div class="bxhtmled-search-cnt" id="bx-html-editor-search-cnt-<?=$this->id?>" style="display: none;"></div>
639 <div class="bxhtmled-area-cnt" id="bx-html-editor-area-cnt-<?=$this->id?>">
640 <div class="bxhtmled-iframe-cnt" id="bx-html-editor-iframe-cnt-<?=$this->id?>"></div>
641 <div class="bxhtmled-textarea-cnt" id="bx-html-editor-ta-cnt-<?=$this->id?>"></div>
642 <div class="bxhtmled-resizer-overlay" id="bx-html-editor-res-over-<?=$this->id?>"></div>
643 <div id="bx-html-editor-split-resizer-<?=$this->id?>"></div>
644 </div>
645 <div class="bxhtmled-nav-cnt" id="bx-html-editor-nav-cnt-<?=$this->id?>" style="display: none;"></div>
646 <div class="bxhtmled-taskbar-cnt bxhtmled-taskbar-hidden" id="bx-html-editor-tskbr-cnt-<?=$this->id?>">
647 <div class="bxhtmled-taskbar-top-cnt" id="bx-html-editor-tskbr-top-<?=$this->id?>"></div>
648 <div class="bxhtmled-taskbar-resizer" id="bx-html-editor-tskbr-res-<?=$this->id?>">
649 <div class="bxhtmled-right-side-split-border">
650 <div data-bx-tsk-split-but="Y" class="bxhtmled-right-side-split-btn"></div>
651 </div>
652 </div>
653 <div class="bxhtmled-taskbar-search-nothing" id="bxhed-tskbr-search-nothing-<?=$this->id?>"><?= GetMessage('HTMLED_SEARCH_NOTHING')?></div>
654 <div class="bxhtmled-taskbar-search-cont" id="bxhed-tskbr-search-cnt-<?=$this->id?>" data-bx-type="taskbar_search">
655 <div class="bxhtmled-search-alignment" id="bxhed-tskbr-search-ali-<?=$this->id?>">
656 <input type="text" class="bxhtmled-search-inp" id="bxhed-tskbr-search-inp-<?=$this->id?>" placeholder="<?= GetMessage('HTMLED_SEARCH_PLACEHOLDER')?>"/>
657 </div>
658 <div class="bxhtmled-search-cancel" data-bx-type="taskbar_search_cancel" title="<?= GetMessage('HTMLED_SEARCH_CANCEL')?>"></div>
659 </div>
660 </div>
661 <div id="bx-html-editor-file-dialogs-<?=$this->id?>" style="display: none;"></div>
662 </div>
663 <?
664 }
665
666 function Run($display = true)
667 {
668 $content = $this->jsConfig['content'];
669 $templates = $this->jsConfig['templates'];
670 $templateParams = $this->jsConfig['templateParams'];
671 $snippets = $this->jsConfig['snippets'];
672 $components = $this->jsConfig['components'] ?? null;
673
674 unset($this->jsConfig['content'], $this->jsConfig['templates'], $this->jsConfig['templateParams'], $this->jsConfig['snippets'], $this->jsConfig['components']);
675 ?>
676
677 <script>
678 var config = <?= $this->SafeJsonEncode($this->jsConfig)?>;
679 config.content = '<?= CUtil::JSEscape($content)?>';
680 config.templates = <?= $this->SafeJsonEncode($templates)?>;
681 config.templateParams = <?= $this->SafeJsonEncode($templateParams)?>;
682 config.snippets = <?= $this->SafeJsonEncode($snippets)?>;
683 config.components = <?= $this->SafeJsonEncode($components)?>;
684 <?if($display):?>
685 window.BXHtmlEditor.Show(config);
686 <?else:?>
687 window.BXHtmlEditor.SaveConfig(config);
688 <?endif;?>
689 </script><?
690 }
691
693 {
694 try
695 {
696 $json = \Bitrix\Main\Web\Json::encode($data, JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_PARTIAL_OUTPUT_ON_ERROR);
697 }
698 catch (Exception $e)
699 {
700 $json = '{}';
701 }
702 return $json;
703 }
704
705 function InitLangMess()
706 {
707 $mess_lang = \Bitrix\Main\Localization\Loc::loadLanguageFile($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/fileman/classes/general/html_editor_js.php');
708 ?><script>BX.message(<?=CUtil::PhpToJSObject($mess_lang, false);?>);</script><?
709 }
710
711 public function getConfig(): array
712 {
713 return $this->jsConfig;
714 }
715
716 public function setOption(string $option, $value): void
717 {
718 $this->jsConfig[$option] = $value;
719 }
720
721 public static function GetSnippets($templateId, $bClearCache = false)
722 {
723 return array(
724 'items' => CSnippets::LoadList(
725 array(
726 'template' => $templateId,
727 'bClearCache' => $bClearCache,
728 'returnArray' => true
729 )
730 ),
731 'groups' => CSnippets::GetGroupList(
732 array(
733 'template' => $templateId,
734 'bClearCache' => $bClearCache
735 )
736 ),
737 'rootDefaultFilename' => CSnippets::GetDefaultFileName($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$templateId."/snippets")
738 );
739 }
740
741 public static function GetComponents($Params, $bClearCache = false, $arFilter = array())
742 {
743 global $CACHE_MANAGER;
744
745 $allowed = trim(COption::GetOptionString('fileman', "~allowed_components", ''));
746 $mask = $allowed === ''? 0 : mb_substr(md5($allowed), 0, 10);
747
748 $lang = isset($Params['lang']) ? $Params['lang'] : LANGUAGE_ID;
749 $component_type = '';
750 if(isset($arFilter['TYPE']))
751 $component_type = '_'.$arFilter['TYPE'];
752
753 $cache_name = 'component_tree_array_'.$lang.'_'.$mask.$component_type;
754 $table_id = "fileman_component_tree";
755
756 if ($bClearCache)
757 {
758 $CACHE_MANAGER->CleanDir($table_id);
759 }
760
761 if($CACHE_MANAGER->Read(self::CACHE_TIME, $cache_name, $table_id))
762 {
763 self::$arComponents = $CACHE_MANAGER->Get($cache_name);
764 }
765
766 if (empty(self::$arComponents))
767 {
768 // Name filter exists
769 if ($allowed !== '')
770 {
771 $arAC = explode("\n", $allowed);
772 $arAC = array_unique($arAC);
773 $arAllowed = Array();
774 foreach ($arAC as $f)
775 {
776 $f = preg_replace("/\s/is", "", $f);
777 $f = preg_replace("/\./is", "\\.", $f);
778 $f = preg_replace("/\*/is", ".*", $f);
779 $arAllowed[] = '/^'.$f.'$/';
780 }
781 $namespace = 'bitrix';
782 }
783 else
784 {
785 $arAllowed = false;
786 $namespace = false;
787 }
788
789 $arTree = CComponentUtil::GetComponentsTree($namespace, $arAllowed, $arFilter);
790 self::$arComponents = array(
791 'items' => array(),
792 'groups' => array()
793 );
794 self::$thirdLevelId = 0;
795
796 if (isset($arTree['#']))
797 {
798 self::_HandleComponentElement($arTree['#'], '');
799 }
800
801 $CACHE_MANAGER->Set($cache_name, self::$arComponents);
802 }
803
804 return self::$arComponents;
805 }
806
807 public static function _HandleComponentElement($arEls, $path)
808 {
809 foreach ($arEls as $elName => $arEl)
810 {
811 $arEl['*'] = $arEl['*'] ?? null;
812 if (mb_strpos($path, ",") !== false)
813 {
814 if (isset($arEl['*']))
815 {
816 $thirdLevelName = '__bx_thirdLevel_'.self::$thirdLevelId;
817 self::$thirdLevelId++;
818 foreach ($arEl['*'] as $name => $comp)
819 {
820 self::$arComponents['items'][] = array(
821 "path" => $path,
822 "name" => $name,
823 "type" => $comp['TYPE'],
824 "title" => $comp['TITLE'],
825 "complex" => $comp['COMPLEX'],
826 "params" => array("DESCRIPTION" => $comp['DESCRIPTION']),
827 "thirdlevel" => $thirdLevelName
828 );
829 }
830 }
831 continue;
832 }
833
834 $realPath = (($path == '') ? $elName : $path.','.$elName);
835 // Group
836 self::$arComponents['groups'][] = array(
837 "path" => $path,
838 "name" => $elName,
839 "title" => (isset($arEl['@']['NAME']) && $arEl['@']['NAME'] !== '') ? $arEl['@']['NAME'] : $elName
840 );
841
842 if (isset($arEl['#']))
843 {
844 self::_HandleComponentElement($arEl['#'], $realPath);
845 }
846
847 if (is_array($arEl['*']) && !empty($arEl['*']))
848 {
849 foreach ($arEl['*'] as $name => $comp)
850 {
851 self::$arComponents['items'][] = array(
852 "path" => $realPath,
853 "name" => $name,
854 "type" => $comp['TYPE'],
855 "title" => $comp['TITLE'],
856 "complex" => $comp['COMPLEX'],
857 "params" => array("DESCRIPTION" => $comp['DESCRIPTION']),
858 "thirdlevel" => false
859 );
860 }
861 }
862 }
863 }
864
865 public static function GetSiteTemplates()
866 {
867 $arTemplates = Array(Array('value' => '.default', 'name' => GetMessage("FILEMAN_DEFTEMPL")));
869 while($ar = $db_site_templates->Fetch())
870 {
871 $arTemplates[] = Array('value'=>$ar['ID'], 'name'=> $ar['NAME']);
872 }
873
874 return $arTemplates;
875 }
876
877 public static function RequestAction($action = '')
878 {
879 global $USER;
880 $result = array();
881
882 switch($action)
883 {
884 case "load_site_template":
885 if (!$USER->CanDoOperation('fileman_view_file_structure'))
886 break;
887 $siteTemplate = $_REQUEST['site_template'];
888 $siteId = isset($_REQUEST['site_id']) ? $_REQUEST['site_id'] : SITE_ID;
890 break;
891 case "load_components_list":
892 if (!$USER->CanDoOperation('fileman_view_file_structure'))
893 break;
894 $siteTemplate = $_REQUEST['site_template'];
895 $componentFilter = isset($_REQUEST['componentFilter']) ? $_REQUEST['componentFilter'] : false;
896 $result = self::GetComponents($siteTemplate, true, $componentFilter);
897 break;
898 case "video_oembed":
899 $result = self::GetVideoOembed($_REQUEST['video_source']);
900 break;
901 // Snippets actions
902 case "load_snippets_list":
903 if (!$USER->CanDoOperation('fileman_view_file_structure'))
904 break;
905 $template = $_REQUEST['site_template'];
906 $result = array(
907 'result' => true,
908 'snippets' => array($template => self::GetSnippets($template, $_REQUEST['clear_cache'] == 'Y'))
909 );
910 break;
911 case "edit_snippet":
912 if (!$USER->CanDoOperation('fileman_view_file_structure'))
913 break;
914 $template = $_REQUEST['site_template'];
915
916 // Update
917 if ($_REQUEST['current_path'])
918 {
920 'template' => $template,
921 'path' => $_REQUEST['path'],
922 'code' => $_REQUEST['code'],
923 'title' => $_REQUEST['name'],
924 'current_path' => $_REQUEST['current_path'],
925 'description' => $_REQUEST['description']
926 ));
927 }
928 // Add new
929 else
930 {
932 'template' => $template,
933 'path' => $_REQUEST['path'],
934 'code' => $_REQUEST['code'],
935 'title' => $_REQUEST['name'],
936 'description' => $_REQUEST['description']
937 ));
938 }
939
940 if ($result && $result['result'])
941 {
942 $result['snippets'] = array($template => self::GetSnippets($template));
943 }
944
945 break;
946 case "remove_snippet":
947 if (!$USER->CanDoOperation('fileman_view_file_structure'))
948 break;
949 $template = $_REQUEST['site_template'];
950
952 'template' => $template,
953 'path' => $_REQUEST['path']
954 ));
955
956 if ($res)
957 {
958 $result = array(
959 'result' => true,
960 'snippets' => array($template => self::GetSnippets($template))
961 );
962 }
963 else
964 {
965 $result = array('result' => false);
966 }
967
968 break;
969 case "snippet_add_category":
970 if (!$USER->CanDoOperation('fileman_view_file_structure'))
971 break;
972 $template = $_REQUEST['site_template'];
974 'template' => $template,
975 'name' => $_REQUEST['category_name'],
976 'parent' => $_REQUEST['category_parent']
977 ));
978
979 if ($res)
980 {
981 $result = array(
982 'result' => true,
983 'snippets' => array($template => self::GetSnippets($template))
984 );
985 }
986 else
987 {
988 $result = array('result' => false);
989 }
990 break;
991 case "snippet_remove_category":
992 if (!$USER->CanDoOperation('fileman_view_file_structure'))
993 break;
994 $template = $_REQUEST['site_template'];
996 'template' => $template,
997 'path' => $_REQUEST['category_path']
998 ));
999
1000 if ($res)
1001 {
1002 $result = array(
1003 'result' => true,
1004 'snippets' => array($template => self::GetSnippets($template))
1005 );
1006 }
1007 else
1008 {
1009 $result = array('result' => false);
1010 }
1011 break;
1012 case "snippet_rename_category":
1013 if (!$USER->CanDoOperation('fileman_view_file_structure'))
1014 break;
1015 $template = $_REQUEST['site_template'];
1017 'template' => $template,
1018 'path' => $_REQUEST['category_path'],
1019 'new_name' => $_REQUEST['category_new_name']
1020 ));
1021
1022 if ($res)
1023 {
1024 $result = array(
1025 'result' => true,
1026 'snippets' => array($template => self::GetSnippets($template))
1027 );
1028 }
1029 else
1030 {
1031 $result = array('result' => false);
1032 }
1033 break;
1034 // END *** Snippets actions
1035
1036 // spellcheck
1037 case "spellcheck_words":
1038 case "spellcheck_add_word":
1039 $spellChecker = new CSpellchecker(array(
1040 "lang" => $_REQUEST['lang'],
1041 "skip_length" => 2,
1042 "use_pspell" => $_REQUEST['use_pspell'] !== "N",
1043 "use_custom_spell" => $_REQUEST['use_custom_spell'] !== "N",
1044 "mode" => PSPELL_FAST
1045 ));
1046
1047 if ($action == "spellcheck_words")
1048 {
1049 $words = (isset($_REQUEST['words']) && is_array($_REQUEST['words'])) ? $_REQUEST['words'] : array();
1050 $result = array(
1051 'words' => $spellChecker->checkWords($words)
1052 );
1053 }
1054 else // Add word
1055 {
1056 $word = CFileMan::SecurePathVar($_REQUEST['word']);
1057 $spellChecker->addWord($word);
1058 }
1059 break;
1060 // END *** spellcheck
1061 case "load_file_dialogs":
1062 $editorId = $_REQUEST['editor_id'];
1063 $editorId = preg_replace("/[^a-zA-Z0-9_-]/is", "_", $editorId);
1064
1066 (
1067 "event" => "BxOpenFileBrowserWindFile".$editorId,
1068 "arResultDest" => Array("FUNCTION_NAME" => "OnFileDialogSelect".$editorId),
1069 "arPath" => Array("SITE" => SITE_ID),
1070 "select" => 'F',
1071 "operation" => 'O',
1072 "showUploadTab" => true,
1073 "showAddToMenuTab" => false,
1074 "fileFilter" => 'image',
1075 "allowAllFiles" => true,
1076 "saveConfig" => true
1077 )
1078 );
1079 CMedialib::ShowBrowseButton(
1080 array(
1081 'value' => '...',
1082 'event' => "BxOpenFileBrowserWindFile".$editorId,
1083 'button_id' => "bx-open-file-link-medialib-but-".$editorId,
1084 'id' => "bx_open_file_link_medialib_button_".$editorId,
1085 'MedialibConfig' => array(
1086 "event" => "BxOpenFileBrowserFileMl".$editorId,
1087 "arResultDest" => Array("FUNCTION_NAME" => "OnFileDialogSelect".$editorId)
1088 ),
1089 'useMLDefault' => false
1090 )
1091 );
1092
1093 CMedialib::ShowBrowseButton(
1094 array(
1095 'value' => '...',
1096 'event' => "BxOpenFileBrowserWindFile".$editorId,
1097 'button_id' => "bx-open-file-medialib-but-".$editorId,
1098 'id' => "bx_open_file_medialib_button_".$editorId,
1099 'MedialibConfig' => array(
1100 "event" => "BxOpenFileBrowserImgFileMl".$editorId,
1101 "arResultDest" => Array("FUNCTION_NAME" => "OnFileDialogImgSelect".$editorId),
1102 "types" => array('image')
1103 )
1104 )
1105 );
1106
1107
1108 $result = array('result' => true);
1109 break;
1110
1111 case "uploadfile":
1112 $uploader = new \CFileUploader(
1113 array("events" => array(
1114 "onFileIsUploaded" => function ($hash, &$file, &$package, &$upload, &$error)
1115 {
1116 $error = \CFile::CheckFile($file["files"]["default"], 0, "image/", \CFile::GetImageExtensions());
1118 $fileName = $file["name"];
1119
1120 if(empty($error) && $io->ValidateFilenameString($fileName) && $io->ValidatePathString(self::GetUploadPath().$fileName))
1121 {
1122 if (COption::GetOptionString('fileman', "use_medialib", "Y") != "N" &&
1123 CMedialib::CanDoOperation('medialib_view_collection', 0, false, true))
1124 {
1125 $image = CMedialib::AutosaveImage($file["files"]["default"]);
1126 if ($image && $image['PATH'])
1127 {
1128 $file["uploadedPath"] = $image['PATH'];
1129 return true;
1130 }
1131 else
1132 {
1133 return false;
1134 }
1135 }
1136 else
1137 {
1138 $newPath = self::GetUploadPath().$fileName;
1139 if($io->FileExists($_SERVER["DOCUMENT_ROOT"].$newPath))
1140 {
1143 $iter = 1;
1144 while(true && $iter < 1000)
1145 {
1146 $newPath = self::GetUploadPath().$name.'('.$iter.').'.$ext;
1147 if(!$io->FileExists($_SERVER["DOCUMENT_ROOT"].$newPath))
1148 {
1149 break;
1150 }
1151 $iter++;
1152 }
1153 }
1154 CopyDirFiles($file["files"]["default"]["tmp_name"], $_SERVER["DOCUMENT_ROOT"].$newPath);
1155 $file["uploadedPath"] = $newPath;
1156 return true;
1157 }
1158 }
1159 }
1160 )),
1161 "get"
1162 );
1163 $uploader->checkPost();
1164 $result = array('result' => true);
1165 break;
1166 }
1167
1168 self::ShowResponse(intval($_REQUEST['reqId']), $result);
1169 }
1170
1171 public static function ShowResponse($reqId = false, $Res = false)
1172 {
1173 if ($Res !== false)
1174 {
1175 if ($reqId === false)
1176 {
1177 $reqId = intval($_REQUEST['reqId']);
1178 }
1179
1180 if ($reqId)
1181 {
1182 ?>
1183 <script>top.BXHtmlEditorAjaxResponse['<?= $reqId?>'] = <?= \Bitrix\Main\Web\Json::encode($Res)?>;</script>
1184 <?
1185 }
1186 }
1187 }
1188
1189 public static function GetComponentParams($name, $siteTemplate = '', $template = '', $curValues = array(), $loadHelp = true)
1190 {
1191 $template = (!$template || $template == '.default') ? '' : CUtil::JSEscape($template);
1192 $arTemplates = CComponentUtil::GetTemplatesList($name, $siteTemplate);
1193
1194 $result = array(
1195 'groups' => array(),
1196 'templates' => array(),
1197 'props' => array(),
1198 'template_props' => array()
1199 );
1200
1201 $arProps = CComponentUtil::GetComponentProps($name, $curValues);
1202
1203 if (is_array($arTemplates))
1204 {
1205 foreach ($arTemplates as $k => $arTemplate)
1206 {
1207 $result['templates'][] = array(
1208 'name' => $arTemplate['NAME'],
1209 'template' => $arTemplate['TEMPLATE'],
1210 'title' => $arTemplate['TITLE'],
1211 'description' => $arTemplate['DESCRIPTION'],
1212 );
1213
1214 $tName = (!$arTemplate['NAME'] || $arTemplate['NAME'] == '.default') ? '' : $arTemplate['NAME'];
1215 if ($tName == $template)
1216 {
1217 $arTemplateProps = CComponentUtil::GetTemplateProps($name, $arTemplate['NAME'], $siteTemplate, $curValues);
1218
1219 if (is_array($arTemplateProps))
1220 {
1221 foreach ($arTemplateProps as $k => $arTemplateProp)
1222 {
1223 $result['templ_props'][] = self::_HandleComponentParam($k, $arTemplateProp, $arProps['GROUPS']);
1224 }
1225 }
1226 }
1227 }
1228 }
1229
1230 //if ($loadHelp && is_array($arProps['PARAMETERS']))
1231 // fetchPropsHelp($name);
1232
1233 if (is_array($arProps['GROUPS']))
1234 {
1235 foreach ($arProps['GROUPS'] as $k => $arGroup)
1236 {
1237 $result['templ_props'][] = array(
1238 'name' => $k,
1239 'title' => $arGroup['NAME']
1240 );
1241 }
1242 }
1243
1244 if (is_array($arProps['PARAMETERS']))
1245 {
1246 foreach ($arProps['PARAMETERS'] as $k => $arParam)
1247 {
1248 $result['properties'][] = self::_HandleComponentParam($k, $arParam, $arProps['GROUPS']);
1249 }
1250 }
1251
1252 return $result;
1253 }
1254
1255 private static function _HandleComponentParam($name = '', $arParam = array(), $arGroup = array())
1256 {
1257 $name = preg_replace("/[^a-zA-Z0-9_-]/is", "_", $name);
1258
1259 $result = array(
1260 'name' => $name,
1261 'parent' => (isset($arParam['PARENT']) && isset($arGroup[$arParam['PARENT']])) ? $arParam['PARENT'] : false
1262 );
1263
1264 if (!empty($arParam))
1265 {
1266 foreach ($arParam as $k => $prop)
1267 {
1268 if ($k == 'TYPE' && $prop == 'FILE')
1269 {
1270 $GLOBALS['arFD'][] = Array(
1271 'NAME' => CUtil::JSEscape($name),
1272 'TARGET' => isset($arParam['FD_TARGET']) ? $arParam['FD_TARGET'] : 'F',
1273 'EXT' => isset($arParam['FD_EXT']) ? $arParam['FD_EXT'] : '',
1274 'UPLOAD' => isset($arParam['FD_UPLOAD']) && $arParam['FD_UPLOAD'] && $arParam['FD_TARGET'] == 'F',
1275 'USE_ML' => isset($arParam['FD_USE_MEDIALIB']) && $arParam['FD_USE_MEDIALIB'],
1276 'ONLY_ML' => isset($arParam['FD_USE_ONLY_MEDIALIB']) && $arParam['FD_USE_ONLY_MEDIALIB'],
1277 'ML_TYPES' => isset($arParam['FD_MEDIALIB_TYPES']) ? $arParam['FD_MEDIALIB_TYPES'] : false
1278 );
1279 }
1280 elseif (in_array($k, Array('FD_TARGET', 'FD_EXT','FD_UPLOAD', 'FD_MEDIALIB_TYPES', 'FD_USE_ONLY_MEDIALIB')))
1281 {
1282 continue;
1283 }
1284
1285 $result[$k] = $prop;
1286 }
1287 }
1288
1289 return $result;
1290 }
1291
1293 {
1294 $params = CFileman::GetAllTemplateParams($templateId, $siteId);
1295
1296 $params["STYLES"] = preg_replace("/(url\‍(\"?)images\//is", "\\1".$params['SITE_TEMPLATE_PATH'].'/images/', $params["STYLES"]);
1297
1298 $params['EDITOR_STYLES'] = $params['EDITOR_STYLES'] ?? null;
1299 if (is_array($params['EDITOR_STYLES']))
1300 {
1301 for ($i = 0, $l = count($params['EDITOR_STYLES']); $i < $l; $i++)
1302 {
1303 $params['EDITOR_STYLES'][$i] = $params['EDITOR_STYLES'][$i].'?'.@filemtime($_SERVER['DOCUMENT_ROOT'].$params['EDITOR_STYLES'][$i]);
1304 }
1305 }
1306
1307 return $params;
1308 }
1309
1310 public static function GetVideoOembed($url = '')
1311 {
1312 $output = array('result' => false, 'error' => "");
1313 if(empty($url))
1314 {
1315 return $output;
1316 }
1317
1319 if($metaData && isset($metaData['EMBED']))
1320 {
1321 $output['result'] = true;
1322 $output['data'] = array(
1323 'html' => $metaData['EMBED'],
1324 'title' => $metaData['TITLE'],
1325 'provider' => $metaData['EXTRA']['PROVIDER_NAME'] ?? null,
1326 'width' => intval($metaData['EXTRA']['VIDEO_WIDTH'] ?? null),
1327 'height' => intval($metaData['EXTRA']['VIDEO_HEIGHT'] ?? null),
1328 );
1329 }
1330 else
1331 {
1332 if($metaData &&
1333 isset($metaData['EXTRA']['VIDEO']) &&
1334 !empty($metaData['EXTRA']['VIDEO']) &&
1335 $metaData['EXTRA']['VIDEO_TYPE'] != 'application/x-shockwave-flash'
1336 )
1337 {
1338 $output = self::getRemoteVideoUrlInfo($metaData['EXTRA']['VIDEO']);
1339 if($output['result'] == true)
1340 {
1341 unset($output['data']['local']);
1342 $output['data']['remote'] = true;
1343 $output['data']['title'] = $metaData['TITLE'];
1344 if(isset($metaData['EXTRA']['VIDEO_WIDTH']))
1345 {
1346 $output['data']['width'] = $metaData['EXTRA']['VIDEO_WIDTH'];
1347 }
1348 if(isset($metaData['EXTRA']['VIDEO_HEIGHT']))
1349 {
1350 $output['data']['height'] = $metaData['EXTRA']['VIDEO_HEIGHT'];
1351 }
1352 if(isset($metaData['EXTRA']['VIDEO_TYPE']))
1353 {
1354 $output['data']['mimeType'] = $metaData['EXTRA']['VIDEO_TYPE'];
1355 }
1356 return $output;
1357 }
1358 }
1360 $path = $url;
1361 $serverPath = self::GetServerPath();
1362
1363 if (mb_strpos($path, $serverPath) !== false)
1364 {
1365 $path = str_replace($serverPath, '', $path);
1366 }
1367
1368 if ($io->FileExists($io->RelativeToAbsolutePath($path)))
1369 {
1370 $output['data'] = array(
1371 'local' => true,
1372 'path' => $path
1373 );
1374 $output['result'] = true;
1375 }
1376 else
1377 {
1379 }
1380 }
1381 return $output;
1382 }
1383
1384 protected static function getRemoteVideoUrlInfo($path)
1385 {
1386 $output = array('result' => false, 'error' => "");
1387 $http = new \Bitrix\Main\Web\HttpClient();
1388 //prevents proxy to LAN
1389 $http->setPrivateIp(false);
1390 $http->setTimeout(5);
1391 $http->setStreamTimeout(5);
1392 $resp1 = $http->head($path);
1393 if ($resp1 !== false)
1394 {
1395 if($resp1 == '403 Forbidden' || $http->getStatus() == '403')
1396 {
1397 $output['error'] .= '[FVID403] '.GetMessage('HTMLED_VIDEO_FORBIDDEN').";\n";
1398 }
1399 elseif($resp1 == 'Not Found' || $http->getStatus() == '404' || $http->getContentType() == 'text/html')
1400 {
1401 $output['error'] .= '[FVID404] '.GetMessage('HTMLED_VIDEO_NOT_FOUND').";\n";
1402 }
1403 else
1404 {
1405 $output['result'] = true;
1406 $output['data'] = array(
1407 'local' => true,
1408 'path' => $path,
1409 );
1410 }
1411 }
1412 else
1413 {
1414 $error = $http->getError();
1415 foreach($error as $errorCode => $errorMessage)
1416 {
1417 $output['error'] .= '['.$errorCode.'] '.$errorMessage.";\n";
1418 }
1419 }
1420
1421 return $output;
1422 }
1423
1424 public static function GetServerPath()
1425 {
1426 if (defined("SITE_SERVER_NAME") && SITE_SERVER_NAME <> '')
1427 $server_name = SITE_SERVER_NAME;
1428 $server_name = $server_name ?? null;
1429 if (!$server_name)
1430 $server_name = COption::GetOptionString("main", "server_name", "");
1431 if (!$server_name)
1432 $server_name = $_SERVER['HTTP_HOST'];
1433 $server_name = rtrim($server_name, '/');
1434 if (!preg_match('/^[a-z0-9\.\-]+$/i', $server_name)) // cyrillic domain hack
1435 {
1436 $converter = new CBXPunycode('UTF-8');
1437 $host = $converter->Encode($server_name);
1438 $server_name = $host;
1439 }
1440
1441 $serverPath = (CMain::IsHTTPS() ? "https://" : "http://").$server_name;
1442
1443 return $serverPath;
1444 }
1445
1446 private static function GetSettingKey($params = array())
1447 {
1448 $settingsKey = "user_settings_".$params["bbCode"];
1449
1450 if (isset($params["view"]))
1451 $settingsKey .= '_'.$params["view"];
1452
1453 if (isset($params["controlsMap"]) && is_array($params["controlsMap"]))
1454 {
1455 foreach($params["controlsMap"] as $control)
1456 {
1457 if (isset($control['id']))
1458 {
1459 $controlId = strtolower($control['id']);
1460 if ($controlId == 'bbcode' || $controlId == 'changeview')
1461 {
1462 $settingsKey .= '_'.$control['id'];
1463 }
1464 }
1465 }
1466 }
1467 return $settingsKey;
1468 }
1469
1470 public static function GetUploadPath()
1471 {
1472 return '/upload/images/';
1473 }
1474}
1475?>
if(isset( $_REQUEST["mode"]) &&$_REQUEST["mode"]=="ajax") if(isset($_REQUEST["mode"]) && $_REQUEST["mode"]=="save_lru" &&check_bitrix_sessid()) $first
Определения access_dialog.php:54
$arParams
Определения access_dialog.php:21
$path
Определения access_edit.php:21
$hash
Определения ajax_redirector.php:8
$basePath
Определения include.php:41
Определения event.php:5
Определения loader.php:13
static loadLanguageFile($file, $language=null, $normalize=true)
Определения loc.php:225
static load($extNames)
Определения extension.php:16
static getHtml($extName)
Определения extension.php:262
static fetchVideoMetaData($url)
Определения urlpreview.php:1040
static encode($data, $options=null)
Определения json.php:22
static ShowScript($arConfig)
Определения file_dialog.php:9
Определения punycode.php:4
static GetInstance()
Определения virtual_io.php:60
static Init($config=array())
Определения component_params_manager.php:13
static GetTemplateProps($componentName, $templateName, $siteTemplate="", $arCurrentValues=array())
Определения component_util.php:963
static GetTemplatesList($componentName, $currentTemplate=false)
Определения component_util.php:1024
static GetComponentsTree($filterNamespace=false, $arNameFilter=false, $arFilter=false)
Определения component_util.php:355
static GetComponentProps($componentName, $arCurrentValues=array(), $templateProperties=array())
Определения component_util.php:461
static SecurePathVar($str)
Определения fileman.php:2111
Определения html_editor.php:14
static GetUploadPath()
Определения html_editor.php:1470
static GetSiteTemplates()
Определения html_editor.php:865
BuildSceleton($display=true)
Определения html_editor.php:623
static ShowResponse($reqId=false, $Res=false)
Определения html_editor.php:1171
const CACHE_TIME
Определения html_editor.php:33
getConfig()
Определения html_editor.php:711
SafeJsonEncode($data=array())
Определения html_editor.php:692
static RequestAction($action='')
Определения html_editor.php:877
InitLangMess()
Определения html_editor.php:705
Run($display=true)
Определения html_editor.php:666
isCopilotEnabled()
Определения html_editor.php:564
static GetServerPath()
Определения html_editor.php:1424
GetAiCategory(string $id, string $name)
Определения html_editor.php:576
Show($arParams)
Определения html_editor.php:593
static getRemoteVideoUrlInfo($path)
Определения html_editor.php:1384
static GetSnippets($templateId, $bClearCache=false)
Определения html_editor.php:721
static GetComponents($Params, $bClearCache=false, $arFilter=array())
Определения html_editor.php:741
static GetSiteTemplateParams($templateId, $siteId)
Определения html_editor.php:1292
static GetComponentParams($name, $siteTemplate='', $template='', $curValues=array(), $loadHelp=true)
Определения html_editor.php:1189
static _HandleComponentElement($arEls, $path)
Определения html_editor.php:807
GetActualPath($path)
Определения html_editor.php:588
static GetVideoOembed($url='')
Определения html_editor.php:1310
setOption(string $option, $value)
Определения html_editor.php:716
static Init($arExt=array(), $bReturn=false)
Определения jscore.php:66
static RegisterExt($name, $arPaths)
Определения jscore.php:28
static GetList($arOrder=array(), $arFilter=array(), $arSelect=false)
Определения site_template.php:13
static Remove($params=array())
Определения snippets.php:579
static GetGroupList($Params)
Определения snippets.php:355
static Add($params=array())
Определения snippets.php:464
static GetDefaultFileName($path)
Определения snippets.php:422
static Update($params=array())
Определения snippets.php:476
static RemoveCategory($params)
Определения snippets.php:698
static RenameCategory($params)
Определения snippets.php:665
static LoadList($Params)
Определения snippets.php:5
static CreateCategory($params=array())
Определения snippets.php:635
Определения spellchecker.php:5
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$content
Определения commerceml.php:144
$templateId
Определения component_props2.php:51
$arTemplate
Определения component_props.php:26
$f
Определения component_props.php:52
$data['IS_AVAILABLE']
Определения .description.php:13
$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
bx_acc_lim_group_list limitGroupList[] multiple<?=$group[ 'ID']?> ID selected margin top
Определения file_new.php:657
$res
Определения filter_act.php:7
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$result
Определения get_property_values.php:14
$host
Определения .description.php:9
$control
Определения iblock_catalog_edit.php:61
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
Get()
Определения idea_idea_comment.php:22
$jsConfig
Определения include.php:14
$output
Определения options.php:436
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $USER
Определения csv_new_run.php:40
$io
Определения csv_new_run.php:98
endif
Определения csv_new_setup.php:990
$inputName
Определения options.php:197
if(!defined('SITE_ID')) $lang
Определения include.php:91
$l
Определения options.php:783
$siteId
Определения ajax.php:8
GetFileExtension($path)
Определения tools.php:2972
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
CopyDirFiles($path_from, $path_to, $ReWrite=true, $Recursive=false, $bDeleteAfterCopy=false, $strExclude="")
Определения tools.php:2732
GetMessage($name, $aReplace=null)
Определения tools.php:3397
GetFileNameWithoutExtension($path)
Определения tools.php:2986
$name
Определения menu_edit.php:35
$event
Определения prolog_after.php:141
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
$ar
Определения options.php:199
$fileName
Определения quickway.php:305
$i
Определения factura.php:643
font style
Определения 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
$width
Определения html.php:68
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$option
Определения options.php:1711
$val
Определения options.php:1793
$engine
Определения options.php:121
const SITE_ID
Определения sonet_set_content_view.php:12
$error
Определения subscription_card_product.php:20
$k
Определения template_pdf.php:567
$db_site_templates
Определения template_copy.php:237
$action
Определения file_dialog.php:21
$GLOBALS['_____370096793']
Определения update_client.php:1
$arFilter
Определения user_search.php:106
$url
Определения iframe.php:7
adm detail iblock types adm detail iblock list tr_SITE_ID display
Определения yandex_setup.php:388