CCrmInstantEditorHelper::RenderHtmlEditor

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmInstantEditorHelper
  4. RenderHtmlEditor
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_component_helper.php
  • Класс: \CCrmInstantEditorHelper
  • Вызов: CCrmInstantEditorHelper::RenderHtmlEditor
static function RenderHtmlEditor(&$arParams)
{
	if(!is_array($arParams))
	{
		return;
	}

	$fieldID = isset($arParams['FIELD_ID']) ? $arParams['FIELD_ID'] : '';
	$value = isset($arParams['VALUE']) ? $arParams['VALUE'] : '';

	$editorID = isset($arParams['EDITOR_ID']) ? $arParams['EDITOR_ID'] : '';
	if($editorID ==='')
	{
		$editorID = uniqid('LHE_');
	}

	$editorJsName = isset($arParams['EDITOR_JS_NAME']) ? $arParams['EDITOR_JS_NAME'] : '';
	if($editorJsName ==='')
	{
		$editorJsName = $editorID;
	}

	$toolbarConfig = isset($arParams['TOOLBAR_CONFIG']) ? $arParams['TOOLBAR_CONFIG'] : null;
	if(!is_array($toolbarConfig))
	{
		$toolbarConfig = array(
			'Bold', 'Italic', 'Underline', 'Strike',
			'BackColor', 'ForeColor',
			'CreateLink', 'DeleteLink',
			'InsertOrderedList', 'InsertUnorderedList', 'Outdent', 'Indent'
		);
	}

	if(!self::$IS_FILEMAN_INCLUDED)
	{
		CModule::IncludeModule('fileman');
		self::$IS_FILEMAN_INCLUDED = true;
	}

	ob_start();
	$editor = new CLightHTMLEditor;
	$editor->Show(
		array(
			'id' => $editorID,
			'height' => '150',
			'bUseFileDialogs' => false,
			'bFloatingToolbar' => false,
			'bArisingToolbar' => false,
			'bResizable' => false,
			'jsObjName' => $editorJsName,
			'bInitByJS' => false, // TODO: Lazy initialization
			'bSaveOnBlur' => true,
			'toolbarConfig' => $toolbarConfig
		)
	);
	$lheHtml = ob_get_contents();
	ob_end_clean();

	$wrapperID = isset($arParams['WRAPPER_ID']) ? $arParams['WRAPPER_ID'] : '';
	if($wrapperID ==='')
	{
		$wrapperID = $editorID.'_WRAPPER';
	}

	echo str_replace(
		array(
			'#TEXT#',
			'#VALUE#',
			'#NAME#',
			'#SETTINGS#',
			'#WRAPPER_ID#',
			'#HTML#'
		),
		array(
			$value,
			htmlspecialcharsbx($value),
			$fieldID,
			htmlspecialcharsbx('{ "id":"'.CUtil::JSEscape($editorID).'", "wrapperId":"'.CUtil::JSEscape($wrapperID).'", "jsName":"'.CUtil::JSEscape($editorJsName).'" }'),
			$wrapperID,
			$lheHtml
		),
		self::$TEMPLATES['LHE']
	);
}

Добавить комментарий