Combine editor preferences and backend preferences
Add backend timezone setting used for converting display dates
This commit is contained in:
parent
7cb9087ffb
commit
6c081d9265
|
|
@ -38,6 +38,18 @@ return [
|
|||
|
||||
'edgeUpdates' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Back-end timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This acts as the default setting for a back-end user's timezone. This can
|
||||
| be changed by the user at any time using the backend preferences.
|
||||
|
|
||||
*/
|
||||
|
||||
'backendTimezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Back-end Skin
|
||||
|
|
|
|||
|
|
@ -206,26 +206,16 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
'context' => 'mysettings',
|
||||
'keywords' => 'backend::lang.myaccount.menu_keywords'
|
||||
],
|
||||
'backend_preferences' => [
|
||||
'preferences' => [
|
||||
'label' => 'backend::lang.backend_preferences.menu_label',
|
||||
'description' => 'backend::lang.backend_preferences.menu_description',
|
||||
'category' => SettingsManager::CATEGORY_MYSETTINGS,
|
||||
'icon' => 'icon-laptop',
|
||||
'class' => 'Backend\Models\BackendPreferences',
|
||||
'url' => Backend::URL('backend/preferences'),
|
||||
'permissions' => ['backend.manage_preferences'],
|
||||
'order' => 510,
|
||||
'context' => 'mysettings'
|
||||
],
|
||||
'editor' => [
|
||||
'label' => 'backend::lang.editor.menu_label',
|
||||
'description' => 'backend::lang.editor.menu_description',
|
||||
'category' => SettingsManager::CATEGORY_MYSETTINGS,
|
||||
'icon' => 'icon-code',
|
||||
'url' => Backend::URL('backend/editorpreferences'),
|
||||
'permissions' => ['backend.manage_editor'],
|
||||
'order' => 520,
|
||||
'context' => 'mysettings'
|
||||
],
|
||||
'access_logs' => [
|
||||
'label' => 'backend::lang.access_log.menu_label',
|
||||
'description' => 'backend::lang.access_log.menu_description',
|
||||
|
|
|
|||
|
|
@ -1,67 +0,0 @@
|
|||
$(document).ready(function(){
|
||||
|
||||
var editorEl = $('#editorpreferencesCodeeditor'),
|
||||
editor = editorEl.codeEditor('getEditorObject'),
|
||||
session = editor.getSession(),
|
||||
renderer = editor.renderer
|
||||
|
||||
editorEl.height($('#editorSettingsForm').height() - 23)
|
||||
|
||||
$('#Form-field-EditorPreferences-theme').on('change', function(){
|
||||
editorEl.codeEditor('setTheme', $(this).val())
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-font_size').on('change', function(){
|
||||
editor.setFontSize(parseInt($(this).val()))
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-word_wrap').on('change', function(){
|
||||
editorEl.codeEditor('setWordWrap', $(this).val())
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-code_folding').on('change', function(){
|
||||
session.setFoldStyle($(this).val())
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-tab_size').on('change', function(){
|
||||
session.setTabSize($(this).val())
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-show_invisibles').on('change', function(){
|
||||
editor.setShowInvisibles($(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-enable_basic_autocompletion').on('change', function(){
|
||||
editor.setOption('enableBasicAutocompletion', $(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-enable_snippets').on('change', function(){
|
||||
editor.setOption('enableSnippets', $(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-enable_live_autocompletion').on('change', function(){
|
||||
editor.setOption('enableLiveAutocompletion', $(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-display_indent_guides').on('change', function(){
|
||||
editor.setDisplayIndentGuides($(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-show_print_margin').on('change', function(){
|
||||
editor.setShowPrintMargin($(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-highlight_active_line').on('change', function(){
|
||||
editor.setHighlightActiveLine($(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-use_hard_tabs').on('change', function(){
|
||||
session.setUseSoftTabs(!$(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-EditorPreferences-show_gutter').on('change', function(){
|
||||
renderer.setShowGutter($(this).is(':checked'))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
$(document).ready(function(){
|
||||
|
||||
var editorEl = $('#editorpreferencesCodeeditor'),
|
||||
editor = editorEl.codeEditor('getEditorObject'),
|
||||
session = editor.getSession(),
|
||||
renderer = editor.renderer
|
||||
|
||||
editorEl.height($('#editorSettingsForm').height() - 23)
|
||||
|
||||
$('#Form-field-Preferences-editor_theme').on('change', function(){
|
||||
editorEl.codeEditor('setTheme', $(this).val())
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_font_size').on('change', function(){
|
||||
editor.setFontSize(parseInt($(this).val()))
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_word_wrap').on('change', function(){
|
||||
editorEl.codeEditor('setWordWrap', $(this).val())
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_code_folding').on('change', function(){
|
||||
session.setFoldStyle($(this).val())
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_tab_size').on('change', function(){
|
||||
session.setTabSize($(this).val())
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_show_invisibles').on('change', function(){
|
||||
editor.setShowInvisibles($(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_enable_basic_autocompletion').on('change', function(){
|
||||
editor.setOption('enableBasicAutocompletion', $(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_enable_snippets').on('change', function(){
|
||||
editor.setOption('enableSnippets', $(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_enable_live_autocompletion').on('change', function(){
|
||||
editor.setOption('enableLiveAutocompletion', $(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_display_indent_guides').on('change', function(){
|
||||
editor.setDisplayIndentGuides($(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_show_print_margin').on('change', function(){
|
||||
editor.setShowPrintMargin($(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_highlight_active_line').on('change', function(){
|
||||
editor.setHighlightActiveLine($(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_use_hard_tabs').on('change', function(){
|
||||
session.setUseSoftTabs(!$(this).is(':checked'))
|
||||
})
|
||||
|
||||
$('#Form-field-Preferences-editor_show_gutter').on('change', function(){
|
||||
renderer.setShowGutter($(this).is(':checked'))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ use Response;
|
|||
use Exception;
|
||||
use BackendAuth;
|
||||
use Backend\Models\UserPreferences;
|
||||
use Backend\Models\BackendPreferences;
|
||||
use Backend\Models\Preferences as BackendPreferences;
|
||||
use Cms\Widgets\MediaManager;
|
||||
use System\Classes\ErrorHandler;
|
||||
use October\Rain\Exception\AjaxException;
|
||||
|
|
@ -218,13 +218,8 @@ class Controller extends Extendable
|
|||
/*
|
||||
* Set the admin preference locale
|
||||
*/
|
||||
if (Session::has('locale')) {
|
||||
App::setLocale(Session::get('locale'));
|
||||
}
|
||||
elseif ($this->user && ($locale = BackendPreferences::get('locale'))) {
|
||||
Session::put('locale', $locale);
|
||||
App::setLocale($locale);
|
||||
}
|
||||
BackendPreferences::setAppLocale();
|
||||
BackendPreferences::setAppFallbackLocale();
|
||||
|
||||
/*
|
||||
* Execute AJAX event
|
||||
|
|
|
|||
|
|
@ -1,74 +0,0 @@
|
|||
<?php namespace Backend\Controllers;
|
||||
|
||||
use BackendMenu;
|
||||
use Backend\Classes\Controller;
|
||||
use System\Classes\SettingsManager;
|
||||
use Backend\Models\EditorPreferences as EditorPreferencesModel;
|
||||
|
||||
/**
|
||||
* Editor Settings controller
|
||||
*
|
||||
* @package october\backend
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*
|
||||
*/
|
||||
class EditorPreferences extends Controller
|
||||
{
|
||||
public $implement = [
|
||||
'Backend.Behaviors.FormController',
|
||||
];
|
||||
|
||||
public $formConfig = 'config_form.yaml';
|
||||
|
||||
public $requiredPermissions = ['backend.manage_editor'];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->addCss('/modules/backend/formwidgets/codeeditor/assets/css/codeeditor.css', 'core');
|
||||
$this->addJs('/modules/backend/formwidgets/codeeditor/assets/js/build-min.js', 'core');
|
||||
$this->addJs('/modules/backend/assets/js/editorpreferences/editorpreferences.js', 'core');
|
||||
|
||||
BackendMenu::setContext('October.System', 'system', 'mysettings');
|
||||
SettingsManager::setContext('October.Backend', 'editor');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// Load the editor system settings
|
||||
$editorSettings = EditorPreferencesModel::instance();
|
||||
|
||||
$this->vars['fontSize'] = $editorSettings->font_size;
|
||||
$this->vars['wordWrap'] = $editorSettings->word_wrap;
|
||||
$this->vars['codeFolding'] = $editorSettings->code_folding;
|
||||
$this->vars['tabSize'] = $editorSettings->tab_size;
|
||||
$this->vars['theme'] = $editorSettings->theme;
|
||||
$this->vars['showInvisibles'] = $editorSettings->show_invisibles;
|
||||
$this->vars['highlightActiveLine'] = $this->highlight_active_line;
|
||||
$this->vars['useSoftTabs'] = !$editorSettings->use_hard_tabs;
|
||||
$this->vars['showGutter'] = true;
|
||||
$this->vars['language'] = 'css';
|
||||
$this->vars['margin'] = 0;
|
||||
$this->vars['enableBasicAutocompletion'] = $editorSettings->enable_basic_autocompletion;
|
||||
$this->vars['enableLiveAutocompletion'] = $editorSettings->enable_live_autocompletion;
|
||||
$this->vars['enableSnippets'] = $editorSettings->enable_snippets;
|
||||
$this->vars['displayIndentGuides'] = $editorSettings->display_indent_guides;
|
||||
$this->vars['showPrintMargin'] = $editorSettings->show_print_margin;
|
||||
$this->asExtension('FormController')->update();
|
||||
$this->pageTitle = 'backend::lang.editor.menu_label';
|
||||
}
|
||||
|
||||
public function index_onSave()
|
||||
{
|
||||
return $this->asExtension('FormController')->update_onSave();
|
||||
}
|
||||
|
||||
public function formFindModelObject()
|
||||
{
|
||||
return EditorPreferencesModel::instance();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
<?php namespace Backend\Controllers;
|
||||
|
||||
use Backend;
|
||||
use BackendMenu;
|
||||
use Backend\Classes\Controller;
|
||||
use System\Classes\SettingsManager;
|
||||
use Backend\Models\Preferences as PreferencesModel;
|
||||
|
||||
/**
|
||||
* Editor Settings controller
|
||||
*
|
||||
* @package october\backend
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*
|
||||
*/
|
||||
class Preferences extends Controller
|
||||
{
|
||||
public $implement = [
|
||||
'Backend.Behaviors.FormController',
|
||||
];
|
||||
|
||||
public $formConfig = 'config_form.yaml';
|
||||
|
||||
public $requiredPermissions = ['backend.manage_preferences'];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->addCss('/modules/backend/formwidgets/codeeditor/assets/css/codeeditor.css', 'core');
|
||||
$this->addJs('/modules/backend/formwidgets/codeeditor/assets/js/build-min.js', 'core');
|
||||
$this->addJs('/modules/backend/assets/js/preferences/preferences.js', 'core');
|
||||
|
||||
BackendMenu::setContext('October.System', 'system', 'mysettings');
|
||||
SettingsManager::setContext('October.Backend', 'preferences');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->pageTitle = 'backend::lang.backend_preferences.menu_label';
|
||||
$this->asExtension('FormController')->update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the code editor tab if there is no permission.
|
||||
*/
|
||||
public function formExtendFields($form)
|
||||
{
|
||||
if (!$this->user->hasAccess('backend.manage_editor')) {
|
||||
$form->removeTab('backend::lang.backend_preferences.code_editor');
|
||||
}
|
||||
}
|
||||
|
||||
public function index_onSave()
|
||||
{
|
||||
return $this->asExtension('FormController')->update_onSave();
|
||||
}
|
||||
|
||||
public function index_onResetDefault()
|
||||
{
|
||||
$model = $this->formFindModelObject();
|
||||
$model->resetDefault();
|
||||
|
||||
return Backend::redirect('backend/preferences');
|
||||
}
|
||||
|
||||
public function formFindModelObject()
|
||||
{
|
||||
return PreferencesModel::instance();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# ===================================
|
||||
# Form Behavior Config
|
||||
# ===================================
|
||||
|
||||
form: ~/modules/backend/models/editorpreferences/fields.yaml
|
||||
modelClass: Backend\Models\EditorPreferences
|
||||
defaultRedirect: system/mailtemplates
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
<?php if (!$this->fatalError): ?>
|
||||
|
||||
<?= Form::open(['class'=>'layout']) ?>
|
||||
|
||||
<div class="layout-row">
|
||||
<div class="row">
|
||||
<div class="col-md-5" id="editorSettingsForm">
|
||||
<div class="form-preview">
|
||||
<?= $this->formRender() ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
|
||||
<div
|
||||
id="editorpreferencesCodeeditor"
|
||||
class="field-codeeditor size-large layout-relative"
|
||||
data-control="codeeditor"
|
||||
data-font-size="<?= $fontSize ?>"
|
||||
data-word-wrap="<?= $wordWrap ?>"
|
||||
data-code-folding="<?= $codeFolding ?>"
|
||||
data-tab-size="<?= $tabSize ?>"
|
||||
data-theme="<?= $theme ?>"
|
||||
data-show-invisibles="<?= $showInvisibles ?>"
|
||||
data-enable-basic-autocompletion="<?= $enableBasicAutocompletion ?>"
|
||||
data-enable-live-autocompletion="<?= $enableLiveAutocompletion ?>"
|
||||
data-enable-snippets="<?= $enableSnippets ?>"
|
||||
data-display-indent-guides="<?= $displayIndentGuides ?>"
|
||||
data-show-print-margin="<?= $showPrintMargin ?>"
|
||||
data-highlight-active-line="<?= $highlightActiveLine ?>"
|
||||
data-use-soft-tabs="<?= $useSoftTabs ?>"
|
||||
data-show-gutter="<?= $showGutter ? 'true' : 'false' ?>"
|
||||
data-language="<?= $language ?>"
|
||||
data-margin="<?= $margin ?>"
|
||||
data-vendor-path="<?= URL::to('/modules/backend/formwidgets/codeeditor/assets/vendor/ace') ?>/">
|
||||
<textarea name="editorpreferences_codeeditor"><?= e($this->makePartial('example_code')) ?></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-buttons">
|
||||
<div class="loading-indicator-container">
|
||||
<button
|
||||
type="submit"
|
||||
data-request="onSave"
|
||||
data-request-data="redirect:0"
|
||||
data-hotkey="ctrl+s, cmd+s"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-primary">
|
||||
<?= e(trans('backend::lang.form.save')) ?>
|
||||
</button>
|
||||
|
||||
<span class="btn-text">
|
||||
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('system/settings') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<?= Form::close() ?>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
|
||||
<p><a href="<?= Backend::url('system/settings') ?>" class="btn btn-default"><?= e(trans('system::lang.settings.return')) ?></a></p>
|
||||
<?php endif ?>
|
||||
|
|
@ -11,12 +11,3 @@ body {
|
|||
p {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
optgroup {
|
||||
font-style: normal;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
option {
|
||||
color: #000;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<div
|
||||
id="editorpreferencesCodeeditor"
|
||||
class="field-codeeditor size-large layout-relative"
|
||||
data-control="codeeditor"
|
||||
data-font-size="<?= $model->editor_font_size ?>"
|
||||
data-word-wrap="<?= $model->editor_word_wrap ?>"
|
||||
data-code-folding="<?= $model->editor_code_folding ?>"
|
||||
data-tab-size="<?= $model->editor_tab_size ?>"
|
||||
data-theme="<?= $model->editor_theme ?>"
|
||||
data-show-invisibles="<?= $model->editor_show_invisibles ?>"
|
||||
data-highlight-active-line="<?= $model->editor_highlight_active_line ?>"
|
||||
data-use-soft-tabs="<?= !$model->editor_use_hard_tabs ?>"
|
||||
data-enable-basic-autocompletion="<?= $model->editor_enable_basic_autocompletion ?>"
|
||||
data-enable-live-autocompletion="<?= $model->editor_enable_live_autocompletion ?>"
|
||||
data-enable-snippets="<?= $model->editor_enable_snippets ?>"
|
||||
data-display-indent-guides="<?= $model->editor_display_indent_guides ?>"
|
||||
data-show-print-margin="<?= $model->editor_show_print_margin ?>"
|
||||
data-show-gutter="<?= $model->editor_show_gutter ? 'true' : 'false' ?>"
|
||||
data-language="css"
|
||||
data-margin="0"
|
||||
data-vendor-path="<?= URL::to('/modules/backend/formwidgets/codeeditor/assets/vendor/ace') ?>/">
|
||||
<textarea name="editorpreferences_codeeditor"><?= e($this->makePartial('example_code')) ?></textarea>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# ===================================
|
||||
# Form Behavior Config
|
||||
# ===================================
|
||||
|
||||
form: ~/modules/backend/models/preferences/fields.yaml
|
||||
modelClass: Backend\Models\Preferences
|
||||
defaultRedirect: system/settings
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php if (!$this->fatalError): ?>
|
||||
|
||||
<?= Form::open(['class'=>'layout']) ?>
|
||||
|
||||
<div class="layout-row">
|
||||
<?= $this->formRender() ?>
|
||||
</div>
|
||||
|
||||
<div class="form-buttons">
|
||||
<div class="loading-indicator-container">
|
||||
<button
|
||||
type="submit"
|
||||
data-request="onSave"
|
||||
data-request-data="redirect:0"
|
||||
data-hotkey="ctrl+s, cmd+s"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-primary">
|
||||
<?= e(trans('backend::lang.form.save')) ?>
|
||||
</button>
|
||||
|
||||
<span class="btn-text">
|
||||
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('system/settings') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
|
||||
</span>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-danger pull-right"
|
||||
data-request="onResetDefault"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.resetting')) ?>"
|
||||
data-request-confirm="<?= e(trans('backend::lang.form.action_confirm')) ?>">
|
||||
<?= e(trans('backend::lang.form.reset_default')) ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?= Form::close() ?>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
|
||||
<p><a href="<?= Backend::url('system/settings') ?>" class="btn btn-default"><?= e(trans('system::lang.settings.return')) ?></a></p>
|
||||
<?php endif ?>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Backend\FormWidgets;
|
||||
|
||||
use Backend\Models\EditorPreferences;
|
||||
use Backend\Models\Preferences as BackendPreferences;
|
||||
use Backend\Classes\FormWidgetBase;
|
||||
|
||||
/**
|
||||
|
|
@ -74,29 +74,29 @@ class CodeEditor extends FormWidgetBase
|
|||
|
||||
/**
|
||||
* @var boolean If true, the editor activate Basic Autocompletion if press Ctrl+Space
|
||||
*/
|
||||
public $enableBasicAutocompletion = true;
|
||||
|
||||
*/
|
||||
public $enableBasicAutocompletion = true;
|
||||
|
||||
/**
|
||||
* @var boolean If true, the editor activate use Snippets
|
||||
*/
|
||||
public $enableSnippets = true;
|
||||
|
||||
*/
|
||||
public $enableSnippets = true;
|
||||
|
||||
/**
|
||||
* @var boolean If true, the editor activate Live Autocompletion mode
|
||||
*/
|
||||
public $enableLiveAutocompletion = true;
|
||||
|
||||
*/
|
||||
public $enableLiveAutocompletion = true;
|
||||
|
||||
/**
|
||||
* @var boolean If true, the editor show Indent Guides
|
||||
*/
|
||||
public $displayIndentGuides = true;
|
||||
|
||||
*/
|
||||
public $displayIndentGuides = true;
|
||||
|
||||
/**
|
||||
* @var boolean If true, the editor show Print Margin
|
||||
*/
|
||||
public $showPrintMargin = false;
|
||||
|
||||
*/
|
||||
public $showPrintMargin = false;
|
||||
|
||||
//
|
||||
// Object properties
|
||||
//
|
||||
|
|
@ -125,11 +125,11 @@ class CodeEditor extends FormWidgetBase
|
|||
'margin',
|
||||
'theme',
|
||||
'readOnly',
|
||||
'enableBasicAutocompletion',
|
||||
'enableSnippets',
|
||||
'enableLiveAutocompletion',
|
||||
'displayIndentGuides',
|
||||
'showPrintMargin'
|
||||
'enableBasicAutocompletion',
|
||||
'enableSnippets',
|
||||
'enableLiveAutocompletion',
|
||||
'displayIndentGuides',
|
||||
'showPrintMargin'
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ class CodeEditor extends FormWidgetBase
|
|||
$this->vars['name'] = $this->formField->getName();
|
||||
$this->vars['readOnly'] = $this->readOnly;
|
||||
$this->vars['enableBasicAutocompletion'] = $this->enableBasicAutocompletion;
|
||||
$this->vars['enableSnippets'] = $this->enableSnippets;
|
||||
$this->vars['enableSnippets'] = $this->enableSnippets;
|
||||
$this->vars['enableLiveAutocompletion'] = $this->enableLiveAutocompletion;
|
||||
$this->vars['displayIndentGuides'] = $this->displayIndentGuides;
|
||||
$this->vars['showPrintMargin'] = $this->showPrintMargin;
|
||||
|
|
@ -189,23 +189,23 @@ class CodeEditor extends FormWidgetBase
|
|||
protected function applyEditorPreferences()
|
||||
{
|
||||
// Load the editor system settings
|
||||
$editorSettings = EditorPreferences::instance();
|
||||
$preferences = BackendPreferences::instance();
|
||||
|
||||
$this->fontSize = $editorSettings->font_size;
|
||||
$this->wordWrap = $editorSettings->word_wrap;
|
||||
$this->codeFolding = $editorSettings->code_folding;
|
||||
$this->autoClosing = $editorSettings->auto_closing;
|
||||
$this->tabSize = $editorSettings->tab_size;
|
||||
$this->theme = $editorSettings->theme;
|
||||
$this->showInvisibles = $editorSettings->show_invisibles;
|
||||
$this->highlightActiveLine = $editorSettings->highlight_active_line;
|
||||
$this->useSoftTabs = !$editorSettings->use_hard_tabs;
|
||||
$this->showGutter = $editorSettings->show_gutter;
|
||||
$this->enableBasicAutocompletion = $editorSettings->enable_basic_autocompletion;
|
||||
$this->enableSnippets = $editorSettings->enable_snippets;
|
||||
$this->enableLiveAutocompletion = $editorSettings->enable_live_autocompletion;
|
||||
$this->displayIndentGuides = $editorSettings->display_indent_guides;
|
||||
$this->showPrintMargin = $editorSettings->show_print_margin;
|
||||
$this->fontSize = $preferences->editor_font_size;
|
||||
$this->wordWrap = $preferences->editor_word_wrap;
|
||||
$this->codeFolding = $preferences->editor_code_folding;
|
||||
$this->autoClosing = $preferences->editor_auto_closing;
|
||||
$this->tabSize = $preferences->editor_tab_size;
|
||||
$this->theme = $preferences->editor_theme;
|
||||
$this->showInvisibles = $preferences->editor_show_invisibles;
|
||||
$this->highlightActiveLine = $preferences->editor_highlight_active_line;
|
||||
$this->useSoftTabs = !$preferences->editor_use_hard_tabs;
|
||||
$this->showGutter = $preferences->editor_show_gutter;
|
||||
$this->enableBasicAutocompletion = $preferences->editor_enable_basic_autocompletion;
|
||||
$this->enableSnippets = $preferences->editor_enable_snippets;
|
||||
$this->enableLiveAutocompletion = $preferences->editor_enable_live_autocompletion;
|
||||
$this->displayIndentGuides = $preferences->editor_display_indent_guides;
|
||||
$this->showPrintMargin = $preferences->editor_show_print_margin;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,11 +281,11 @@ return [
|
|||
'auto_closing' => 'Auto close tags and special characters',
|
||||
'show_invisibles' => 'Show invisible characters',
|
||||
'show_gutter' => 'Show gutter',
|
||||
'enable_basic_autocompletion'=> 'Enable Basic Autocompletion(Ctrl+Space)',
|
||||
'enable_snippets'=> 'Enable use of Snippets',
|
||||
'enable_live_autocompletion'=> 'Enable Live Autocompletion',
|
||||
'display_indent_guides'=> 'Show Display Indent Guides',
|
||||
'show_print_margin'=> 'Show Print Margin',
|
||||
'enable_basic_autocompletion'=> 'Enable Basic Autocompletion (Ctrl+Space)',
|
||||
'enable_snippets'=> 'Enable use of Snippets',
|
||||
'enable_live_autocompletion'=> 'Enable Live Autocompletion',
|
||||
'display_indent_guides'=> 'Show Display Indent Guides',
|
||||
'show_print_margin'=> 'Show Print Margin',
|
||||
'theme' => 'Color scheme'
|
||||
],
|
||||
'tooltips' => [
|
||||
|
|
@ -311,17 +311,24 @@ return [
|
|||
'app_tagline' => 'App Tagline',
|
||||
'app_tagline_description' => 'This name is shown on the sign in screen for the back-end.',
|
||||
'colors' => 'Colors',
|
||||
'appearance' => 'Appearance',
|
||||
'primary_color' => 'Primary color',
|
||||
'secondary_color' => 'Secondary color',
|
||||
'accent_color' => 'Accent color',
|
||||
'styles' => 'Styles',
|
||||
'custom_stylesheet' => 'Custom stylesheet'
|
||||
'custom_stylesheet' => 'Custom stylesheet',
|
||||
'navigation' => 'Navigation',
|
||||
'menu_mode' => 'Menu style',
|
||||
'menu_mode_inline' => 'Inline',
|
||||
'menu_mode_tile' => 'Tiles',
|
||||
'menu_mode_collapsed' => 'Collapsed',
|
||||
],
|
||||
'backend_preferences' => [
|
||||
'menu_label' => 'Back-end preferences',
|
||||
'menu_description' => 'Manage your account preferences such as desired language.',
|
||||
'locale' => 'Language',
|
||||
'region' => 'Region',
|
||||
'code_editor' => 'Code editor',
|
||||
'timezone' => 'Timezone',
|
||||
'locale' => 'Locale',
|
||||
'locale_comment' => 'Select your desired locale for language use.'
|
||||
],
|
||||
'access_log' => [
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
<?php namespace Backend\Models;
|
||||
|
||||
use Lang;
|
||||
use Model;
|
||||
use Config;
|
||||
use Session;
|
||||
use DirectoryIterator;
|
||||
|
||||
/**
|
||||
* Backend preferences for the backend user
|
||||
*
|
||||
* @package october\backend
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class BackendPreferences extends Model
|
||||
{
|
||||
public $implement = ['Backend.Behaviors.UserPreferencesModel'];
|
||||
public $settingsCode = 'backend::backend.preferences';
|
||||
public $settingsFields = 'fields.yaml';
|
||||
|
||||
public function initSettingsData()
|
||||
{
|
||||
$this->locale = Config::get('app.locale', 'en');
|
||||
}
|
||||
|
||||
public static function applyConfigValues()
|
||||
{
|
||||
$settings = self::instance();
|
||||
Config::set('app.locale', $settings->locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns available options for the "locale" attribute.
|
||||
* @return array
|
||||
*/
|
||||
public function getLocaleOptions()
|
||||
{
|
||||
$locales = Config::get('app.localeOptions', [
|
||||
'cs' => [Lang::get('system::lang.locale.cs'), 'flag-cz'],
|
||||
'en' => [Lang::get('system::lang.locale.en'), 'flag-gb'],
|
||||
'de' => [Lang::get('system::lang.locale.de'), 'flag-de'],
|
||||
'es' => [Lang::get('system::lang.locale.es'), 'flag-es'],
|
||||
'es-ar' => [Lang::get('system::lang.locale.es-ar'), 'flag-ar'],
|
||||
'fa' => [Lang::get('system::lang.locale.fa'), 'flag-ir'],
|
||||
'fr' => [Lang::get('system::lang.locale.fr'), 'flag-fr'],
|
||||
'hu' => [Lang::get('system::lang.locale.hu'), 'flag-hu'],
|
||||
'id' => [Lang::get('system::lang.locale.id'), 'flag-id'],
|
||||
'it' => [Lang::get('system::lang.locale.it'), 'flag-it'],
|
||||
'ja' => [Lang::get('system::lang.locale.ja'), 'flag-jp'],
|
||||
'lv' => [Lang::get('system::lang.locale.lv'), 'flag-lv'],
|
||||
'nl' => [Lang::get('system::lang.locale.nl'), 'flag-nl'],
|
||||
'pt-br' => [Lang::get('system::lang.locale.pt-br'), 'flag-br'],
|
||||
'ro' => [Lang::get('system::lang.locale.ro'), 'flag-ro'],
|
||||
'ru' => [Lang::get('system::lang.locale.ru'), 'flag-ru'],
|
||||
'sv' => [Lang::get('system::lang.locale.sv'), 'flag-se'],
|
||||
'tr' => [Lang::get('system::lang.locale.tr'), 'flag-tr'],
|
||||
'pl' => [Lang::get('system::lang.locale.pl'), 'flag-pl'],
|
||||
'sk' => [Lang::get('system::lang.locale.sk'), 'flag-sk'],
|
||||
'zh-cn' => [Lang::get('system::lang.locale.zh-cn'), 'flag-cn'],
|
||||
'zh-tw' => [Lang::get('system::lang.locale.zh-tw'), 'flag-tw'],
|
||||
'nb-no' => [Lang::get('system::lang.locale.nb-no'), 'flag-no'],
|
||||
'el' => [Lang::get('system::lang.locale.el'), 'flag-gr'],
|
||||
]);
|
||||
|
||||
// Sort locales alphabetically
|
||||
asort($locales);
|
||||
|
||||
return $locales;
|
||||
}
|
||||
|
||||
public function afterSave()
|
||||
{
|
||||
Session::put('locale', $this->locale);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
<?php namespace Backend\Models;
|
||||
|
||||
use App;
|
||||
use Model;
|
||||
use DirectoryIterator;
|
||||
|
||||
/**
|
||||
* Code editor preferences for the backend user\
|
||||
*
|
||||
* @package october\backend
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class EditorPreferences extends Model
|
||||
{
|
||||
public $implement = ['Backend.Behaviors.UserPreferencesModel'];
|
||||
public $settingsCode = 'backend::editor.preferences';
|
||||
public $settingsFields = 'fields.yaml';
|
||||
|
||||
const DEFAULT_THEME = 'twilight';
|
||||
|
||||
public function initSettingsData()
|
||||
{
|
||||
$config = App::make('config');
|
||||
$this->font_size = $config->get('editor.font_size', 12);
|
||||
$this->word_wrap = $config->get('editor.word_wrap', 'fluid');
|
||||
$this->code_folding = $config->get('editor.code_folding', 'manual');
|
||||
$this->tab_size = $config->get('editor.tab_size', 4);
|
||||
$this->theme = $config->get('editor.theme', static::DEFAULT_THEME);
|
||||
$this->show_invisibles = $config->get('editor.show_invisibles', true);
|
||||
$this->highlight_active_line = $config->get('editor.highlight_active_line', true);
|
||||
$this->use_hard_tabs = $config->get('editor.use_hard_tabs', false);
|
||||
$this->show_gutter = $config->get('editor.show_gutter', true);
|
||||
$this->auto_closing = $config->get('editor.auto_closing', true);
|
||||
$this->enable_basic_autocompletion = $config->get('editor.enable_basic_autocompletion', true);
|
||||
$this->enable_snippets = $config->get('editor.enable_snippets', true);
|
||||
$this->enable_live_autocompletion = $config->get('editor.enable_live_autocompletion', true);
|
||||
$this->display_indent_guides = $config->get('editor.display_indent_guides', true);
|
||||
$this->show_print_margin = $config->get('editor.show_print_margin', true);
|
||||
}
|
||||
|
||||
public static function applyConfigValues()
|
||||
{
|
||||
$config = App::make('config');
|
||||
$settings = self::instance();
|
||||
$config->set('editor.font_size', $settings->font_size);
|
||||
$config->set('editor.word_wrap', $settings->word_wrap);
|
||||
$config->set('editor.code_folding', $settings->code_folding);
|
||||
$config->set('editor.tab_size', $settings->tab_size);
|
||||
$config->set('editor.theme', $settings->theme);
|
||||
$config->set('editor.show_invisibles', $settings->show_invisibles);
|
||||
$config->set('editor.highlight_active_line', $settings->highlight_active_line);
|
||||
$config->set('editor.use_hard_tabs', $settings->use_hard_tabs);
|
||||
$config->set('editor.show_gutter', $settings->show_gutter);
|
||||
$config->set('editor.auto_closing', $settings->auto_closing);
|
||||
$config->set('editor.enable_basic_autocompletion', $settings->enable_basic_autocompletion);
|
||||
$config->set('editor.editor.enable_snippets', $settings->enable_snippets);
|
||||
$config->set('editor.enable_live_autocompletion', $settings->enable_live_autocompletion);
|
||||
$config->set('editor.display_indent_guides', $settings->display_indent_guides);
|
||||
$config->set('editor.show_print_margin', $settings->show_print_margin);
|
||||
}
|
||||
|
||||
public function getThemeOptions()
|
||||
{
|
||||
$themeDir = new DirectoryIterator("modules/backend/formwidgets/codeeditor/assets/vendor/ace/");
|
||||
$themes = [];
|
||||
|
||||
// Iterate through the themes
|
||||
foreach ($themeDir as $node) {
|
||||
|
||||
// If this file is a theme (starting by "theme-")
|
||||
if (!$node->isDir() && substr($node->getFileName(), 0, 6) == 'theme-') {
|
||||
// Remove the theme- prefix and the .js suffix, create an user friendly and capitalized name
|
||||
$themeId = substr($node->getFileName(), 6, -3);
|
||||
$themeName = ucwords(str_replace("_", " ", $themeId));
|
||||
|
||||
// Add the values to the themes array
|
||||
if ($themeId != static::DEFAULT_THEME) {
|
||||
$themes[$themeId] = $themeName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Sort the theme alphabetically, and push the default theme
|
||||
asort($themes);
|
||||
return [static::DEFAULT_THEME => ucwords(static::DEFAULT_THEME)] + $themes;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,220 @@
|
|||
<?php namespace Backend\Models;
|
||||
|
||||
use App;
|
||||
use Lang;
|
||||
use Model;
|
||||
use Config;
|
||||
use Session;
|
||||
use BackendAuth;
|
||||
use DirectoryIterator;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Backend preferences for the backend user
|
||||
*
|
||||
* @package october\backend
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class Preferences extends Model
|
||||
{
|
||||
use \October\Rain\Database\Traits\Validation;
|
||||
|
||||
public $implement = ['Backend.Behaviors.UserPreferencesModel'];
|
||||
public $settingsCode = 'backend::backend.preferences';
|
||||
public $settingsFields = 'fields.yaml';
|
||||
|
||||
const DEFAULT_THEME = 'twilight';
|
||||
|
||||
/**
|
||||
* Validation rules
|
||||
*/
|
||||
public $rules = [];
|
||||
|
||||
public function initSettingsData()
|
||||
{
|
||||
$this->locale = Config::get('app.locale', 'en');
|
||||
$this->fallback_locale = $this->getFallbackLocale($this->locale);
|
||||
$this->timezone = Config::get('cms.backendTimezone', 'UTC');
|
||||
|
||||
$config = App::make('config');
|
||||
$this->editor_font_size = $config->get('editor.font_size', 12);
|
||||
$this->editor_word_wrap = $config->get('editor.word_wrap', 'fluid');
|
||||
$this->editor_code_folding = $config->get('editor.code_folding', 'manual');
|
||||
$this->editor_tab_size = $config->get('editor.tab_size', 4);
|
||||
$this->editor_theme = $config->get('editor.theme', static::DEFAULT_THEME);
|
||||
$this->editor_show_invisibles = $config->get('editor.show_invisibles', true);
|
||||
$this->editor_highlight_active_line = $config->get('editor.highlight_active_line', true);
|
||||
$this->editor_use_hard_tabs = $config->get('editor.use_hard_tabs', false);
|
||||
$this->editor_show_gutter = $config->get('editor.show_gutter', true);
|
||||
$this->editor_auto_closing = $config->get('editor.auto_closing', true);
|
||||
$this->editor_enable_basic_autocompletion = $config->get('editor.enable_basic_autocompletion', true);
|
||||
$this->editor_enable_live_autocompletion = $config->get('editor.enable_live_autocompletion', true);
|
||||
$this->editor_enable_snippets = $config->get('editor.enable_snippets', true);
|
||||
$this->editor_display_indent_guides = $config->get('editor.display_indent_guides', true);
|
||||
$this->editor_show_print_margin = $config->get('editor.show_print_margin', true);
|
||||
}
|
||||
|
||||
public static function setAppLocale()
|
||||
{
|
||||
if (Session::has('locale')) {
|
||||
App::setLocale(Session::get('locale'));
|
||||
}
|
||||
elseif (
|
||||
($user = BackendAuth::getUser()) &&
|
||||
($locale = static::get('locale'))
|
||||
) {
|
||||
Session::put('locale', $locale);
|
||||
App::setLocale($locale);
|
||||
}
|
||||
}
|
||||
|
||||
public static function setAppFallbackLocale()
|
||||
{
|
||||
if (Session::has('fallback_locale')) {
|
||||
Lang::setFallback(Session::get('fallback_locale'));
|
||||
}
|
||||
elseif (
|
||||
($user = BackendAuth::getUser()) &&
|
||||
($locale = static::get('fallback_locale'))
|
||||
) {
|
||||
Session::put('fallback_locale', $locale);
|
||||
Lang::setFallback($locale);
|
||||
}
|
||||
}
|
||||
|
||||
public function beforeValidate()
|
||||
{
|
||||
$this->fallback_locale = $this->getFallbackLocale($this->locale);
|
||||
}
|
||||
|
||||
public function afterSave()
|
||||
{
|
||||
Session::put('locale', $this->locale);
|
||||
Session::put('fallback_locale', $this->fallback_locale);
|
||||
}
|
||||
|
||||
public function resetDefault()
|
||||
{
|
||||
parent::resetDefault();
|
||||
Session::forget('locale');
|
||||
Session::forget('fallback_locale');
|
||||
}
|
||||
|
||||
public static function applyConfigValues()
|
||||
{
|
||||
$settings = self::instance();
|
||||
Config::set('app.locale', $settings->locale);
|
||||
Config::set('app.fallback_locale', $this->getFallbackLocale($settings->locale));
|
||||
}
|
||||
|
||||
protected function getFallbackLocale($locale)
|
||||
{
|
||||
if ($position = strpos($locale, '-')) {
|
||||
return substr($locale, 0, $position);
|
||||
}
|
||||
|
||||
return Config::get('app.fallback_locale');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns available options for the "locale" attribute.
|
||||
* @return array
|
||||
*/
|
||||
public function getLocaleOptions()
|
||||
{
|
||||
$locales = Config::get('app.localeOptions', [
|
||||
'cs' => [Lang::get('system::lang.locale.cs'), 'flag-cz'],
|
||||
'en' => [Lang::get('system::lang.locale.en'), 'flag-gb'],
|
||||
'en-au' => [Lang::get('system::lang.locale.en-au'), 'flag-au'],
|
||||
'de' => [Lang::get('system::lang.locale.de'), 'flag-de'],
|
||||
'es' => [Lang::get('system::lang.locale.es'), 'flag-es'],
|
||||
'es-ar' => [Lang::get('system::lang.locale.es-ar'), 'flag-ar'],
|
||||
'fa' => [Lang::get('system::lang.locale.fa'), 'flag-ir'],
|
||||
'fr' => [Lang::get('system::lang.locale.fr'), 'flag-fr'],
|
||||
'fr-ca' => [Lang::get('system::lang.locale.fr-ca'), 'flag-fr'],
|
||||
'hu' => [Lang::get('system::lang.locale.hu'), 'flag-hu'],
|
||||
'id' => [Lang::get('system::lang.locale.id'), 'flag-id'],
|
||||
'it' => [Lang::get('system::lang.locale.it'), 'flag-it'],
|
||||
'ja' => [Lang::get('system::lang.locale.ja'), 'flag-jp'],
|
||||
'lv' => [Lang::get('system::lang.locale.lv'), 'flag-lv'],
|
||||
'nl' => [Lang::get('system::lang.locale.nl'), 'flag-nl'],
|
||||
'pt-br' => [Lang::get('system::lang.locale.pt-br'), 'flag-br'],
|
||||
'ro' => [Lang::get('system::lang.locale.ro'), 'flag-ro'],
|
||||
'ru' => [Lang::get('system::lang.locale.ru'), 'flag-ru'],
|
||||
'sv' => [Lang::get('system::lang.locale.sv'), 'flag-se'],
|
||||
'tr' => [Lang::get('system::lang.locale.tr'), 'flag-tr'],
|
||||
'pl' => [Lang::get('system::lang.locale.pl'), 'flag-pl'],
|
||||
'sk' => [Lang::get('system::lang.locale.sk'), 'flag-sk'],
|
||||
'zh-cn' => [Lang::get('system::lang.locale.zh-cn'), 'flag-cn'],
|
||||
'zh-tw' => [Lang::get('system::lang.locale.zh-tw'), 'flag-tw'],
|
||||
'nb-no' => [Lang::get('system::lang.locale.nb-no'), 'flag-no'],
|
||||
'el' => [Lang::get('system::lang.locale.el'), 'flag-gr'],
|
||||
]);
|
||||
|
||||
// Sort locales alphabetically
|
||||
asort($locales);
|
||||
|
||||
return $locales;
|
||||
}
|
||||
|
||||
public function getTimezoneOptions()
|
||||
{
|
||||
$timezoneIdentifiers = DateTimeZone::listIdentifiers();
|
||||
$utcTime = new DateTime('now', new DateTimeZone('UTC'));
|
||||
|
||||
$tempTimezones = [];
|
||||
foreach ($timezoneIdentifiers as $timezoneIdentifier) {
|
||||
$currentTimezone = new DateTimeZone($timezoneIdentifier);
|
||||
|
||||
$tempTimezones[] = [
|
||||
'offset' => (int) $currentTimezone->getOffset($utcTime),
|
||||
'identifier' => $timezoneIdentifier
|
||||
];
|
||||
}
|
||||
|
||||
// Sort the array by offset, identifier ascending
|
||||
usort($tempTimezones, function($a, $b) {
|
||||
return $a['offset'] === $b['offset']
|
||||
? strcmp($a['identifier'], $b['identifier'])
|
||||
: $a['offset'] - $b['offset'];
|
||||
});
|
||||
|
||||
$timezoneList = [];
|
||||
foreach ($tempTimezones as $tz) {
|
||||
$sign = $tz['offset'] > 0 ? '+' : '-';
|
||||
$offset = gmdate('H:i', abs($tz['offset']));
|
||||
$timezoneList[$tz['identifier']] = '(UTC ' . $sign . $offset . ') ' . $tz['identifier'];
|
||||
}
|
||||
|
||||
return $timezoneList;
|
||||
}
|
||||
|
||||
public function getEditorThemeOptions()
|
||||
{
|
||||
$themeDir = new DirectoryIterator("modules/backend/formwidgets/codeeditor/assets/vendor/ace/");
|
||||
$themes = [];
|
||||
|
||||
// Iterate through the themes
|
||||
foreach ($themeDir as $node) {
|
||||
|
||||
// If this file is a theme (starting by "theme-")
|
||||
if (!$node->isDir() && substr($node->getFileName(), 0, 6) == 'theme-') {
|
||||
// Remove the theme- prefix and the .js suffix, create an user friendly and capitalized name
|
||||
$themeId = substr($node->getFileName(), 6, -3);
|
||||
$themeName = ucwords(str_replace("_", " ", $themeId));
|
||||
|
||||
// Add the values to the themes array
|
||||
if ($themeId != static::DEFAULT_THEME) {
|
||||
$themes[$themeId] = $themeName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Sort the theme alphabetically, and push the default theme
|
||||
asort($themes);
|
||||
return [static::DEFAULT_THEME => ucwords(static::DEFAULT_THEME)] + $themes;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
# ===================================
|
||||
# Field Definitions
|
||||
# ===================================
|
||||
|
||||
fields:
|
||||
locale:
|
||||
label: backend::lang.backend_preferences.locale
|
||||
comment: backend::lang.backend_preferences.locale_comment
|
||||
type: dropdown
|
||||
span: left
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
# ===================================
|
||||
# Field Definitions
|
||||
# ===================================
|
||||
|
||||
fields:
|
||||
|
||||
font_size:
|
||||
label: backend::lang.editor.font_size
|
||||
span: auto
|
||||
type: dropdown
|
||||
options:
|
||||
11: 11px
|
||||
12: 12px
|
||||
13: 13px
|
||||
14: 14px
|
||||
15: 15px
|
||||
16: 16px
|
||||
|
||||
word_wrap:
|
||||
label: backend::lang.editor.word_wrap
|
||||
type: dropdown
|
||||
span: auto
|
||||
options:
|
||||
off: Off
|
||||
40: 40 Characters
|
||||
80: 80 Characters
|
||||
fluid: Fluid
|
||||
|
||||
code_folding:
|
||||
label: backend::lang.editor.code_folding
|
||||
type: dropdown
|
||||
span: auto
|
||||
options:
|
||||
manual: Off
|
||||
markbegin: Mark begin
|
||||
markbeginend: Mark begin and end
|
||||
|
||||
tab_size:
|
||||
label: backend::lang.editor.tab_size
|
||||
span: auto
|
||||
type: dropdown
|
||||
options:
|
||||
2: 2
|
||||
3: 3
|
||||
4: 4
|
||||
5: 5
|
||||
6: 6
|
||||
7: 7
|
||||
8: 8
|
||||
|
||||
theme:
|
||||
label: backend::lang.editor.theme
|
||||
type: dropdown
|
||||
|
||||
auto_closing:
|
||||
label: backend::lang.editor.auto_closing
|
||||
type: checkbox
|
||||
|
||||
show_invisibles:
|
||||
label: backend::lang.editor.show_invisibles
|
||||
type: checkbox
|
||||
|
||||
highlight_active_line:
|
||||
label: backend::lang.editor.highlight_active_line
|
||||
type: checkbox
|
||||
|
||||
use_hard_tabs:
|
||||
label: backend::lang.editor.use_hard_tabs
|
||||
type: checkbox
|
||||
|
||||
show_gutter:
|
||||
label: backend::lang.editor.show_gutter
|
||||
type: checkbox
|
||||
|
||||
enable_basic_autocompletion:
|
||||
label: backend::lang.editor.enable_basic_autocompletion
|
||||
type: checkbox
|
||||
|
||||
enable_snippets:
|
||||
label: backend::lang.editor.enable_snippets
|
||||
type: checkbox
|
||||
|
||||
enable_live_autocompletion:
|
||||
label: backend::lang.editor.enable_live_autocompletion
|
||||
type: checkbox
|
||||
|
||||
display_indent_guides:
|
||||
label: backend::lang.editor.display_indent_guides
|
||||
type: checkbox
|
||||
|
||||
show_print_margin:
|
||||
label: backend::lang.editor.show_print_margin
|
||||
type: checkbox
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
# ===================================
|
||||
# Field Definitions
|
||||
# ===================================
|
||||
#
|
||||
tabs:
|
||||
fields:
|
||||
|
||||
locale:
|
||||
tab: backend::lang.backend_preferences.region
|
||||
label: backend::lang.backend_preferences.locale
|
||||
comment: backend::lang.backend_preferences.locale_comment
|
||||
type: dropdown
|
||||
span: left
|
||||
|
||||
timezone:
|
||||
tab: backend::lang.backend_preferences.region
|
||||
label: backend::lang.backend_preferences.timezone
|
||||
comment: Adjust displayed dates to this timezone.
|
||||
type: dropdown
|
||||
span: left
|
||||
|
||||
editor_preview:
|
||||
type: partial
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
path: field_editor_preview
|
||||
|
||||
editor_font_size:
|
||||
label: backend::lang.editor.font_size
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
span: auto
|
||||
type: dropdown
|
||||
options:
|
||||
11: 11px
|
||||
12: 12px
|
||||
13: 13px
|
||||
14: 14px
|
||||
15: 15px
|
||||
16: 16px
|
||||
|
||||
editor_word_wrap:
|
||||
label: backend::lang.editor.word_wrap
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: dropdown
|
||||
span: auto
|
||||
options:
|
||||
off: Off
|
||||
40: 40 Characters
|
||||
80: 80 Characters
|
||||
fluid: Fluid
|
||||
|
||||
editor_code_folding:
|
||||
label: backend::lang.editor.code_folding
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: dropdown
|
||||
span: auto
|
||||
options:
|
||||
manual: Off
|
||||
markbegin: Mark begin
|
||||
markbeginend: Mark begin and end
|
||||
|
||||
editor_tab_size:
|
||||
label: backend::lang.editor.tab_size
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
span: auto
|
||||
type: dropdown
|
||||
options:
|
||||
2: 2
|
||||
3: 3
|
||||
4: 4
|
||||
5: 5
|
||||
6: 6
|
||||
7: 7
|
||||
8: 8
|
||||
|
||||
editor_theme:
|
||||
label: backend::lang.editor.theme
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: dropdown
|
||||
|
||||
editor_auto_closing:
|
||||
label: backend::lang.editor.auto_closing
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: checkbox
|
||||
span: auto
|
||||
|
||||
editor_show_invisibles:
|
||||
label: backend::lang.editor.show_invisibles
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: checkbox
|
||||
span: auto
|
||||
|
||||
editor_highlight_active_line:
|
||||
label: backend::lang.editor.highlight_active_line
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: checkbox
|
||||
span: auto
|
||||
|
||||
editor_use_hard_tabs:
|
||||
label: backend::lang.editor.use_hard_tabs
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: checkbox
|
||||
span: auto
|
||||
|
||||
editor_show_gutter:
|
||||
label: backend::lang.editor.show_gutter
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: checkbox
|
||||
span: auto
|
||||
|
||||
editor_enable_basic_autocompletion:
|
||||
label: backend::lang.editor.enable_basic_autocompletion
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: checkbox
|
||||
span: auto
|
||||
|
||||
editor_enable_snippets:
|
||||
label: backend::lang.editor.enable_snippets
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: checkbox
|
||||
span: auto
|
||||
|
||||
editor_enable_live_autocompletion:
|
||||
label: backend::lang.editor.enable_live_autocompletion
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: checkbox
|
||||
span: auto
|
||||
|
||||
editor_display_indent_guides:
|
||||
label: backend::lang.editor.display_indent_guides
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: checkbox
|
||||
span: auto
|
||||
|
||||
editor_show_print_margin:
|
||||
label: backend::lang.editor.show_print_margin
|
||||
tab: backend::lang.backend_preferences.code_editor
|
||||
type: checkbox
|
||||
span: auto
|
||||
Loading…
Reference in New Issue