addBehavior('adminCurrentThemeDetails', ['themeEditorBehaviors', 'theme_editor_details']); $core->addBehavior('adminBeforeUserOptionsUpdate', ['themeEditorBehaviors', 'adminBeforeUserUpdate']); $core->addBehavior('adminPreferencesForm', ['themeEditorBehaviors', 'adminPreferencesForm']); class themeEditorBehaviors { public static function theme_editor_details($core, $id) { if ($id != 'default' && $core->auth->isSuperAdmin()) { return '
' . __('Edit theme files') . '
'; } } public static function adminBeforeUserUpdate($cur, $userID) { global $core; // Get and store user's prefs for plugin options $core->auth->user_prefs->addWorkspace('interface'); try { $core->auth->user_prefs->interface->put('colorsyntax', !empty($_POST['colorsyntax']), 'boolean'); $core->auth->user_prefs->interface->put('colorsyntax_theme', (!empty($_POST['colorsyntax_theme']) ? $_POST['colorsyntax_theme'] : '')); } catch (Exception $e) { $core->error->add($e->getMessage()); } } public static function adminPreferencesForm($core) { // Add fieldset for plugin options $core->auth->user_prefs->addWorkspace('interface'); $themes_list = dcPage::getCodeMirrorThemes(); $themes_combo = [__('Default') => '']; foreach ($themes_list as $theme) { $themes_combo[$theme] = $theme; } echo '' . __('Syntax highlighting in theme editor') . '
'; if (count($themes_combo) > 1) { echo '' . form::combo('colorsyntax_theme', $themes_combo, [ 'default' => $core->auth->user_prefs->interface->colorsyntax_theme, 'extra_html' => 'onchange="selectTheme()"']) . '
'; } else { echo form::hidden('colorsyntax_theme', ''); } echo '