show phpcsfixer config in modules conf page (using themes user pref synthax highlight)
This commit is contained in:
parent
997096b9bc
commit
a2c3f05c36
3 changed files with 37 additions and 1 deletions
7
inc/lib.improve.action.phpcsfixer.js
Normal file
7
inc/lib.improve.action.phpcsfixer.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
/*global CodeMirror, dotclear */
|
||||
'use strict';
|
||||
|
||||
window.CodeMirror.defineMode('dotclear', function (config) {
|
||||
config.readOnly = true;
|
||||
return CodeMirror.getMode(config, 'php');
|
||||
});
|
|
@ -21,6 +21,8 @@ class ImproveActionPhpcsfixer extends ImproveAction
|
|||
32 => 'Configuration error of a Fixer.',
|
||||
64 => 'Exception raised within the application'
|
||||
];
|
||||
protected static $user_ui_colorsyntax = false;
|
||||
protected static $user_ui_colorsyntax_theme = 'default';
|
||||
|
||||
protected function init(): bool
|
||||
{
|
||||
|
@ -33,6 +35,10 @@ class ImproveActionPhpcsfixer extends ImproveAction
|
|||
'types' => ['plugin', 'theme']
|
||||
]);
|
||||
|
||||
$this->core->auth->user_prefs->addWorkspace('interface');
|
||||
self::$user_ui_colorsyntax = $this->core->auth->user_prefs->interface->colorsyntax;
|
||||
self::$user_ui_colorsyntax_theme = $this->core->auth->user_prefs->interface->colorsyntax_theme;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -41,6 +47,15 @@ class ImproveActionPhpcsfixer extends ImproveAction
|
|||
return true;
|
||||
}
|
||||
|
||||
public function header(): ?string
|
||||
{
|
||||
if (self::$user_ui_colorsyntax) {
|
||||
return dcPage::jsLoadCodeMirror(self::$user_ui_colorsyntax_theme);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function configure($url): ?string
|
||||
{
|
||||
if (!empty($_POST['save'])) {
|
||||
|
@ -49,6 +64,7 @@ class ImproveActionPhpcsfixer extends ImproveAction
|
|||
]);
|
||||
$this->redirect($url);
|
||||
}
|
||||
$content = file_get_contents(dirname(__FILE__) . '/libs/dc.phpcsfixer.rules.php');
|
||||
|
||||
return
|
||||
'<p><label class="classic" for="phpexe_path">' .
|
||||
|
@ -57,7 +73,19 @@ class ImproveActionPhpcsfixer extends ImproveAction
|
|||
'</p>' .
|
||||
'<p class="form-note">' .
|
||||
__('If this module does not work you can try to put here directory to php executable (without executable file name).') .
|
||||
' C:\path_to\php</p>';
|
||||
' C:\path_to\php</p>' .
|
||||
|
||||
'<p><label for="file_content">' . __('PHP CS Fixer configuration file:') . '</strong></label></p>' .
|
||||
'<p>' . form::textarea('file_content', 120, 60, [
|
||||
'default' => html::escapeHTML($content),
|
||||
'class' => 'maximal',
|
||||
'extra_html' => 'readonly="true"'
|
||||
]) . '</p>' .
|
||||
(
|
||||
!self::$user_ui_colorsyntax ? '' :
|
||||
dcPage::jsLoad(dcPage::getPF('improve/inc/lib.improve.action.phpcsfixer.js')) .
|
||||
dcPage::jsRunCodeMirror('editor', 'file_content', 'dotclear', self::$user_ui_colorsyntax_theme)
|
||||
);
|
||||
}
|
||||
|
||||
public function closeModule(): ?bool
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
$finder = PhpCsFixer\Finder::create()
|
||||
->exclude('node_modules')
|
||||
->exclude('vendor')
|
||||
->exclude('libs')
|
||||
->in(__DIR__);
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
|
|
Loading…
Reference in a new issue