winter/modules/backend/controllers/EditorPreferences.php

71 lines
2.2 KiB
PHP
Raw Normal View History

<?php namespace Backend\Controllers;
2014-06-11 22:18:46 +10:00
use Lang;
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';
/**
* Constructor.
*/
public function __construct()
{
parent::__construct();
$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');
$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;
2014-06-12 18:29:12 +10:00
$this->vars['wordWrap'] = $editorSettings->word_wrap;
$this->vars['codeFolding'] = $editorSettings->code_folding;
$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;
$this->vars['useSoftTabs'] = !$editorSettings->use_hard_tabs;
2014-06-12 18:29:12 +10:00
$this->vars['showGutter'] = true;
$this->vars['language'] = 'css';
$this->vars['margin'] = 0;
$this->asExtension('FormController')->update();
2014-06-11 22:18:46 +10:00
$this->pageTitle = Lang::get('backend::lang.editor.menu_label');
}
2014-06-12 18:29:12 +10:00
public function index_onSave()
{
return $this->asExtension('FormController')->update_onSave();
2014-06-12 18:29:12 +10:00
}
public function formFindModelObject()
{
return EditorPreferencesModel::instance();
}
}