30 $basePath =
'/bitrix/js/fileman/light_editor/';
32 $this->Id = preg_replace(
"/[^a-zA-Z0-9_:\.]/is",
"", $this->Id);
34 $this->cssPath =
$basePath.
"light_editor.css";
37 $this->arJSPath =
array(
44 $this->bBBCode = (
$arParams[
'BBCode'] ??
null) ===
true;
45 $this->bRecreate = (
$arParams[
'bRecreate'] ??
null) ===
true;
49 foreach(
GetModuleEvents(
"fileman",
"OnBeforeLightEditorScriptsGet",
true) as $arEvent)
55 if (is_array(
$tmp[
'JS']))
60 $this->arJSPath[] =
$tmp[
'JS'][
$i];
65 foreach($this->arJSPath as
$path)
71 $langPath =
$_SERVER[
'DOCUMENT_ROOT'].
'/bitrix/modules/fileman/lang/'.LANGUAGE_ID.
'/classes/general/light_editor_js.php';
72 if(!file_exists($langPath))
73 $langPath =
$_SERVER[
'DOCUMENT_ROOT'].
'/bitrix/modules/fileman/lang/en/classes/general/light_editor_js.php';
75 $this->messOld =
array();
77 if (!empty($this->mess))
79 $this->messOld =
array(
'Image' => $this->mess[
'Image'],
'Video' => $this->mess[
'Video'],
'ImageSizing' => $this->mess[
'ImageSizing']);
81 $jsMsg =
"<script bxrunfirst>LHE_MESS = window.LHE_MESS = ".CUtil::PhpToJSObject($this->messOld).
"; (window.BX||top.BX).message(".CUtil::PhpToJSObject($this->mess,
false).
");</script>";
86 $this->bAutorized = is_object(
$USER) &&
$USER->IsAuthorized();
87 $this->bUseFileDialogs =
$arParams[
'bUseFileDialogs'] !==
false && $this->bAutorized;
88 $this->bUseMedialib = (
$arParams[
'bUseMedialib'] ??
null) !==
false && COption::GetOptionString(
'fileman',
"use_medialib",
"Y") ==
"Y" && CMedialib::CanDoOperation(
'medialib_view_collection', 0);
90 $this->bResizable = (
$arParams[
'bResizable'] ??
null) ===
true;
91 $this->bManualResize = $this->bResizable && (
$arParams[
'bManualResize'] ??
null) !==
false;
92 $this->bAutoResize = (
$arParams[
'bAutoResize'] ??
null) !==
false;
93 $this->bInitByJS = (
$arParams[
'bInitByJS'] ??
null) ===
true;
94 $this->bSaveOnBlur = (
$arParams[
'bSaveOnBlur'] ??
null) !==
false;
95 $this->content = (
$arParams[
'content'] ??
null);
97 $this->inputName = isset(
$arParams[
'inputName']) ?
$arParams[
'inputName'] :
'lha_content';
99 $this->inputId = isset(
$arParams[
'inputId']) ?
$arParams[
'inputId'] :
'lha_content_id';
103 'WMode' =>
'transparent',
104 'windowless' =>
true,
105 'bufferLength' => 20,
106 'skin' =>
'/bitrix/components/bitrix/player/mediaplayer/skins/bitrix.swf',
111 $arParams[
'arFonts'] =
array(
'Arial',
'Verdana',
'Times New Roman',
'Courier',
'Tahoma',
'Georgia',
'Optima',
'Impact',
'Geneva',
'Helvetica');
114 $arParams[
'arFontSizes'] =
array(
'1' =>
'xx-small',
'2' =>
'x-small',
'3' =>
'small',
'4' =>
'medium',
'5' =>
'large',
'6' =>
'x-large',
'7' =>
'xx-large');
118 $this->jsObjName = (isset(
$arParams[
'jsObjName']) &&
$arParams[
'jsObjName'] <>
'') ?
$arParams[
'jsObjName'] :
'LightHTMLEditor'.$this->Id;
119 $this->jsObjName = preg_replace(
"/[^a-zA-Z0-9_:\.]/is",
"", $this->jsObjName);
121 if ($this->bResizable)
124 $userOpt = CUserOptions::GetOption(
126 'LHESize_'.$this->Id,
129 $arParams[
'height'] = intval($userOpt[
'height']) > 0 ? $userOpt[
'height'] :
$arParams[
'height'];
132 $this->JSConfig =
array(
134 'content' => $this->content,
135 'bBBCode' => $this->bBBCode,
136 'bUseFileDialogs' => $this->bUseFileDialogs,
137 'bUseMedialib' => $this->bUseMedialib,
138 'arSmiles' => (
$arParams[
'arSmiles'] ??
null),
139 'arFonts' => (
$arParams[
'arFonts'] ??
null),
140 'arFontSizes' => (
$arParams[
'arFontSizes'] ??
null),
141 'inputName' => $this->inputName,
142 'inputId' => $this->inputId,
143 'videoSettings' => $this->videoSettings,
144 'bSaveOnBlur' => $this->bSaveOnBlur,
145 'bResizable' => $this->bResizable,
146 'autoResizeSaveSize' => (
$arParams[
'autoResizeSaveSize'] ??
null) !==
false,
147 'bManualResize' => $this->bManualResize,
148 'bAutoResize' => $this->bAutoResize,
149 'bReplaceTabToNbsp' =>
true,
150 'bSetDefaultCodeView' => isset(
$arParams[
'bSetDefaultCodeView']) &&
$arParams[
'bSetDefaultCodeView'],
151 'bBBParseImageSize' => isset(
$arParams[
'bBBParseImageSize']) &&
$arParams[
'bBBParseImageSize'],
152 'smileCountInToolbar' => intval((
$arParams[
'smileCountInToolbar'] ??
null)),
153 'bQuoteFromSelection' => isset(
$arParams[
'bQuoteFromSelection']) &&
$arParams[
'bQuoteFromSelection'],
154 'bConvertContentFromBBCodes' => isset(
$arParams[
'bConvertContentFromBBCodes']) &&
$arParams[
'bConvertContentFromBBCodes'],
155 'oneGif' =>
'/bitrix/images/1.gif',
156 'imagePath' =>
'/bitrix/images/fileman/light_htmledit/'
161 $this->JSConfig[
'bSetDefaultCodeView'] =
true;
164 $this->JSConfig[
'width'] =
$arParams[
'width'];
166 $this->JSConfig[
'height'] =
$arParams[
'height'];
168 $this->JSConfig[
'toolbarConfig'] =
$arParams[
'toolbarConfig'];
170 $this->JSConfig[
'documentCSS'] =
$arParams[
'documentCSS'];
172 $this->JSConfig[
'fontFamily'] =
$arParams[
'fontFamily'];
174 $this->JSConfig[
'fontSize'] =
$arParams[
'fontSize'];
176 $this->JSConfig[
'lineHeight'] =
$arParams[
'lineHeight'];
178 $this->JSConfig[
'bHandleOnPaste'] =
$arParams[
'bHandleOnPaste'];
179 if (isset(
$arParams[
'autoResizeOffset']))
180 $this->JSConfig[
'autoResizeOffset'] =
$arParams[
'autoResizeOffset'];
181 if (isset(
$arParams[
'autoResizeMaxHeight']))
182 $this->JSConfig[
'autoResizeMaxHeight'] =
$arParams[
'autoResizeMaxHeight'];
183 if (isset(
$arParams[
'controlButtonsHeight']))
184 $this->JSConfig[
'controlButtonsHeight'] =
$arParams[
'controlButtonsHeight'];
188 $this->JSConfig[
'bParceBBImageSize'] =
true;
191 if (isset(
$arParams[
'ctrlEnterHandler']))
192 $this->JSConfig[
'ctrlEnterHandler'] =
$arParams[
'ctrlEnterHandler'];
216 $width = isset($this->JSConfig[
'width']) && intval($this->JSConfig[
'width']) > 0 ? $this->JSConfig[
'width'] :
"100%";
217 $height = isset($this->JSConfig[
'height']) && intval($this->JSConfig[
'height']) > 0 ? $this->JSConfig[
'height'] :
"100%";
219 $widthUnit = mb_strpos(
$width,
"%") ===
false ?
"px" :
"%";
220 $heightUnit = mb_strpos($height,
"%") ===
false ?
"px" :
"%";
222 $height = intval($height);
224 $editorCellHeight = ($heightUnit ==
"px" && $height > 50 ?
"height:".($height - 27 - ($this->bResizable ? 3 : 0)).
"px" :
"");
227<div
class=
"bxlhe-frame" id=
"bxlhe_frame_<?=$this->Id?>" style=
"width:<?=$width.$widthUnit?>; height:<?=$height.$heightUnit?>;"><table
class=
"bxlhe-frame-table" cellspacing=
"0" style=
"height:<?=$height.$heightUnit?>; width: 100%;">
228 <tr
class=
"bxlhe-editor-toolbar-row"><td
class=
"bxlhe-editor-buttons" style=
"height:27px;"><div
class=
"lhe-stat-toolbar-cont lhe-stat-toolbar-cont-preload"></div></td></tr>
229 <tr><td
class=
"bxlhe-editor-cell" style=
"<?=$editorCellHeight?>"></td></tr>
230 <?
if ($this->bResizable):?>
231 <tr><td
class=
"lhe-resize-row" style=
"height: 3px;"><img
id=
"bxlhe_resize_<?=$this->Id?>" src=
"/bitrix/images/1.gif"/></td></tr>
240 foreach(
GetModuleEvents(
"fileman",
"OnIncludeLightEditorScript",
true) as $arEvent)
242 $scripts = trim(ob_get_contents());
245 $scripts = str_replace(
"<script>",
"", $scripts);
246 $scripts = str_replace(
"</script>",
"", $scripts);
249 foreach ($this->arJSPath as
$path)
251 if ($loadScript !=
"")
255 $loadScript .=
"\"".$this->GetActualPath(
$path).
"\"";
259 function LoadLHE_<?=$this->Id?>()
261 function _lheScriptloaded()
263 if (!window.JCLightHTMLEditor)
264 return setTimeout(_lheScriptloaded, 10);
266 <?
if (!empty($scripts)):?>
269 catch(e){alert(
'Errors in customization scripts! ' + e);}
273 <?= ($this->bRecreate ?
'true' :
'false')?> ||
274 JCLightHTMLEditor.items[
'<?= $this->Id?>'] == undefined ||
275 !document.body.contains(JCLightHTMLEditor.items[
'<?= $this->Id?>'].pFrame)
278 top.<?=$this->jsObjName?> = window.<?=$this->jsObjName?> =
new window.JCLightHTMLEditor(<?=CUtil::PhpToJSObject($this->JSConfig)?>);
279 BX.onCustomEvent(window,
'LHE_ConstructorInited', [window.<?=$this->jsObjName?>]);
283 if (!window.JCLightHTMLEditor)
285 BX.loadCSS(
"<?=$this->GetActualPath($this->cssPath)?>");
286 <?
if (!empty($this->mess)):?>
287 LHE_MESS = window.LHE_MESS =
"<?=CUtil::PhpToJSObject($this->messOld)?>"; (window.BX||
top.BX).message(<?=CUtil::PhpToJSObject($this->mess,
false)?>);
289 BX.loadScript([<?=$loadScript?>], _lheScriptloaded);
297 <?
if(!$this->bInitByJS):?>
298 BX.ready(
function(){LoadLHE_<?=$this->Id?>();});