2014-06-11 18:48:16 +10:00
|
|
|
<?php namespace Backend\Controllers;
|
|
|
|
|
2014-06-11 22:18:46 +10:00
|
|
|
use Lang;
|
2014-06-11 18:48:16 +10:00
|
|
|
use BackendMenu;
|
|
|
|
use Backend\Classes\Controller;
|
2014-07-24 15:19:00 +11:00
|
|
|
use System\Classes\SettingsManager;
|
2014-07-01 17:17:53 +10:00
|
|
|
use Backend\Models\EditorPreferences as EditorPreferencesModel;
|
2014-06-11 18:48:16 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Editor Settings controller
|
|
|
|
*
|
|
|
|
* @package october\backend
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
*
|
|
|
|
*/
|
2014-07-01 17:17:53 +10:00
|
|
|
class EditorPreferences extends Controller
|
2014-06-11 18:48:16 +10:00
|
|
|
{
|
|
|
|
|
|
|
|
public $implement = [
|
|
|
|
'Backend.Behaviors.FormController',
|
|
|
|
];
|
|
|
|
|
|
|
|
public $formConfig = 'config_form.yaml';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
2014-06-11 21:19:26 +10:00
|
|
|
$this->addCss('/modules/backend/formwidgets/codeeditor/assets/css/codeeditor.css', 'core');
|
|
|
|
$this->addJs('/modules/backend/formwidgets/codeeditor/assets/vendor/ace/ace.js', 'core');
|
|
|
|
$this->addJs('/modules/backend/formwidgets/codeeditor/assets/js/codeeditor.js', 'core');
|
2014-07-01 17:17:53 +10:00
|
|
|
$this->addJs('/modules/backend/assets/js/editorpreferences/editorpreferences.js', 'core');
|
2014-06-11 21:19:26 +10:00
|
|
|
|
2014-07-01 17:17:53 +10:00
|
|
|
BackendMenu::setContext('October.System', 'system', 'mysettings');
|
2014-07-24 15:19:00 +11:00
|
|
|
SettingsManager::setContext('October.Backend', 'editor');
|
2014-06-11 18:48:16 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
2014-06-11 21:19:26 +10:00
|
|
|
// Load the editor system settings
|
2014-07-01 17:17:53 +10:00
|
|
|
$editorSettings = EditorPreferencesModel::instance();
|
2014-06-11 21:19:26 +10:00
|
|
|
|
|
|
|
$this->vars['fontSize'] = $editorSettings->font_size;
|
2014-06-12 18:29:12 +10:00
|
|
|
$this->vars['wordWrap'] = $editorSettings->word_wrap;
|
|
|
|
$this->vars['codeFolding'] = $editorSettings->code_folding;
|
2014-06-11 21:19:26 +10:00
|
|
|
$this->vars['tabSize'] = $editorSettings->tab_size;
|
2014-06-12 18:29:12 +10:00
|
|
|
$this->vars['theme'] = $editorSettings->theme;
|
|
|
|
$this->vars['showInvisibles'] = $editorSettings->show_invisibles;
|
|
|
|
$this->vars['highlightActiveLine'] = $this->highlight_active_line;
|
2014-06-11 21:19:26 +10:00
|
|
|
$this->vars['useSoftTabs'] = !$editorSettings->use_hard_tabs;
|
2014-06-12 18:29:12 +10:00
|
|
|
$this->vars['showGutter'] = true;
|
|
|
|
$this->vars['language'] = 'css';
|
2014-06-11 21:19:26 +10:00
|
|
|
$this->vars['margin'] = 0;
|
|
|
|
|
2014-08-23 09:41:48 +10:00
|
|
|
$this->asExtension('FormController')->update();
|
2014-06-11 22:18:46 +10:00
|
|
|
$this->pageTitle = Lang::get('backend::lang.editor.menu_label');
|
2014-06-11 18:48:16 +10:00
|
|
|
}
|
|
|
|
|
2014-06-12 18:29:12 +10:00
|
|
|
public function index_onSave()
|
|
|
|
{
|
2014-08-23 09:41:48 +10:00
|
|
|
return $this->asExtension('FormController')->update_onSave();
|
2014-06-12 18:29:12 +10:00
|
|
|
}
|
|
|
|
|
2014-06-11 18:48:16 +10:00
|
|
|
public function formFindModelObject()
|
|
|
|
{
|
2014-07-01 17:17:53 +10:00
|
|
|
return EditorPreferencesModel::instance();
|
2014-06-11 18:48:16 +10:00
|
|
|
}
|
|
|
|
}
|