CFileMan::AddHTMLEditorFrame: метод Битрикс
Постоянная ссылка: http://bxapi.ru/src/?id=172362
<?php
// CFileMan::AddHTMLEditorFrame()
// /bitrix/modules/fileman/fileman.php:1300
public static function AddHTMLEditorFrame(
$strTextFieldName,
$strTextValue,
$strTextTypeFieldName,
$strTextTypeValue,
$arSize = Array("height"=>350),
$CONVERT_FOR_WORKFLOW="N",
$WORKFLOW_DOCUMENT_ID=0,
$NEW_DOCUMENT_PATH="",
$textarea_field="",
$site = false,
$bWithoutPHP = true,
$arTaskbars = false,
$arAdditionalParams = Array()
)
{
// We have to avoid of showing HTML-editor with probably unsecure content when loosing the session [mantis:#0007986]
if ($_SERVER["REQUEST_METHOD"] == "POST" && !check_bitrix_sessid())
return;
global $htmled, $usehtmled;
$strTextFieldName = preg_replace("/[^a-zA-Z0-9_:\.]/is", "", $strTextFieldName);
if(is_array($arSize))
$iHeight = $arSize["height"];
else
$iHeight = $arSize;
$strTextValue = htmlspecialcharsback($strTextValue);
$dontShowTA = isset($arAdditionalParams['dontshowta']) ? $arAdditionalParams['dontshowta'] : false;
if ($arAdditionalParams['hideTypeSelector'])
{
$textType = $strTextTypeValue == 'html' ? 'editor' : 'text';
?><input type="hidden" name="<?= $strTextTypeFieldName?>" value="<?= $strTextTypeValue?>"/><?
}
else
{
$textType = CFileMan::ShowTypeSelector(array(
'name' => $strTextFieldName,
'key' => $arAdditionalParams['saveEditorKey'],
'strTextTypeFieldName' => $strTextTypeFieldName,
'strTextTypeValue' => $strTextTypeValue,
'bSave' => $arAdditionalParams['saveEditorState'] !== false
));
}
$curHTMLEd = $textType == 'editor';
setEditorEventHandlers($strTextFieldName);
?>
<textarea class="typearea" style="<? echo(($curHTMLEd || $dontShowTA) ? 'display:none;' : '');?>width:100%;height:<?=$iHeight?>px;" name="<?=$strTextFieldName?>" id="bxed_<?=$strTextFieldName?>" wrap="virtual" <?=$textarea_field?>><?= htmlspecialcharsbx($strTextValue)?></textarea>
<?
if ($bWithoutPHP)
$arTaskbars = Array("BXPropertiesTaskbar", "BXSnippetsTaskbar");
else if (!$arTaskbars)
$arTaskbars = Array("BXPropertiesTaskbar", "BXSnippetsTaskbar", "BXComponents2Taskbar");
$minHeight = $arAdditionalParams['minHeight'] ? intval($arAdditionalParams['minHeight']) : 450;
$arParams = Array(
"bUseOnlyDefinedStyles"=>COption::GetOptionString("fileman", "show_untitled_styles", "N")!="Y",
"bFromTextarea" => true,
"bDisplay" => $curHTMLEd,
"bWithoutPHP" => $bWithoutPHP,
"arTaskbars" => $arTaskbars,
"height" => max($iHeight, $minHeight)
);
if (isset($arAdditionalParams['use_editor_3']))
$arParams['use_editor_3'] = $arAdditionalParams['use_editor_3'];
$arParams['site'] = (strlen($site)<=0?LANG:$site);
if(isset($arSize["width"]))
$arParams["width"] = $arSize["width"];
if (isset($arAdditionalParams))
$arParams["arAdditionalParams"] = $arAdditionalParams;
if (isset($arAdditionalParams['limit_php_access']))
$arParams['limit_php_access'] = $arAdditionalParams['limit_php_access'];
if (isset($arAdditionalParams['toolbarConfig']))
$arParams['toolbarConfig'] = $arAdditionalParams['toolbarConfig'];
if (isset($arAdditionalParams['componentFilter']))
$arParams['componentFilter'] = $arAdditionalParams['componentFilter'];
$arParams['setFocusAfterShow'] = isset($arParams['setFocusAfterShow']) ? $arParams['setFocusAfterShow'] : false;
CFileman::ShowHTMLEditControl($strTextFieldName, $strTextValue, $arParams);
}