diff --git a/inc/lib.improve.action.phpcsfixer.js b/inc/lib.improve.action.phpcsfixer.js new file mode 100644 index 0000000..0ac9f92 --- /dev/null +++ b/inc/lib.improve.action.phpcsfixer.js @@ -0,0 +1,7 @@ +/*global CodeMirror, dotclear */ +'use strict'; + +window.CodeMirror.defineMode('dotclear', function (config) { + config.readOnly = true; + return CodeMirror.getMode(config, 'php'); +}); \ No newline at end of file diff --git a/inc/lib.improve.action.phpcsfixer.php b/inc/lib.improve.action.phpcsfixer.php index cebe244..b19c935 100644 --- a/inc/lib.improve.action.phpcsfixer.php +++ b/inc/lib.improve.action.phpcsfixer.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 '
' . '' . __('If this module does not work you can try to put here directory to php executable (without executable file name).') . - ' C:\path_to\php
'; + ' C:\path_to\php' . + + '' . + '' . form::textarea('file_content', 120, 60, [ + 'default' => html::escapeHTML($content), + 'class' => 'maximal', + 'extra_html' => 'readonly="true"' + ]) . '
' . + ( + !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 diff --git a/inc/libs/dc.phpcsfixer.rules.php b/inc/libs/dc.phpcsfixer.rules.php index 4fe98fd..059b618 100644 --- a/inc/libs/dc.phpcsfixer.rules.php +++ b/inc/libs/dc.phpcsfixer.rules.php @@ -3,6 +3,7 @@ $finder = PhpCsFixer\Finder::create() ->exclude('node_modules') ->exclude('vendor') + ->exclude('libs') ->in(__DIR__); $config = new PhpCsFixer\Config();