- Модуль: fileman
- Путь к файлу: ~/bitrix/modules/fileman/classes/general/code_editor.php
- Класс: CCodeEditor
- Вызов: CCodeEditor::Show
static function Show($params)
{
global $APPLICATION, $USER;
CUtil::InitJSCore(array('window', 'ajax'));
$APPLICATION->AddHeadScript('/bitrix/js/fileman/code_editor/code-editor.js');
$APPLICATION->SetAdditionalCSS('/bitrix/js/fileman/code_editor/code-editor.css');
$id = (isset($params['id']) && $params['id'] <> '') ? $params['id'] : 'bxce-'.mb_substr(uniqid(mt_rand(), true), 0, 4);
$theme = isset($params['defaultTheme']) ? $params['defaultTheme'] : 'light';
$highlight = isset($params['defaultHighlight']) ? $params['defaultHighlight'] : true;
$saveSettings = ($params['saveSettings'] ?? null) !== false && $USER && $USER->IsAuthorized();
if ($saveSettings)
{
$Settings = CUserOptions::GetOption("fileman", "code_editor");
$theme = ($Settings['theme'] ?? null) == 'dark' ? 'dark' : 'light';
$highlight = !isset($Settings['highlight']) || $Settings['highlight'];
}
if (!in_array($theme, array('dark', 'light')))
$theme = 'dark';
$highlight = $highlight === false ? false : true;
$JSConfig = array(
'id' => $id,
'textareaId' => $params['textareaId'],
'theme' => $theme,
'highlightMode' => $highlight,
'saveSettings' => $saveSettings
);
if (isset($params['width']) && intval($params['width']) > 0)
$JSConfig['width'] = $params['width'];
if (isset($params['height']) && intval($params['height']) > 0)
$JSConfig['height'] = $params['height'];
if (isset($params['forceSyntax']) && in_array($params['forceSyntax'], array('php', 'js', 'sql', 'css')))
$JSConfig['forceSyntax'] = $params['forceSyntax'];
else
$JSConfig['forceSyntax'] = false;
?>
return $id;
}