diff --git a/backend/bootstrap/SetUp.php b/backend/bootstrap/SetUp.php index 872eb09..52a5c5a 100644 --- a/backend/bootstrap/SetUp.php +++ b/backend/bootstrap/SetUp.php @@ -3,8 +3,9 @@ namespace backend\bootstrap; use core\entities\Settings; -use mihaildev\ckeditor\CKEditor; -use mihaildev\elfinder\ElFinder; + +use zertex\elfinder\ElFinder; +use zertex\ckeditor\CKEditor; use yii\base\BootstrapInterface; use yii\helpers\ArrayHelper; @@ -13,8 +14,32 @@ class SetUp implements BootstrapInterface public function bootstrap($app) { $container = \Yii::$container; + + // init presets + $presetsPath = \Yii::getAlias('@core/components/ckeditor/presets'); + // basic + $app->params['ckeditor']['basic']['toolbar'] = require $presetsPath . '/basic/toolbar.php'; + $app->params['ckeditor']['basic']['plugins'] = require $presetsPath . '/basic/plugins.php'; + // editor + $app->params['ckeditor']['editor']['toolbar'] = require $presetsPath . '/editor/toolbar.php'; + $app->params['ckeditor']['editor']['plugins'] = require $presetsPath . '/editor/plugins.php'; + // debeloper + $app->params['ckeditor']['developer']['toolbar'] = require $presetsPath . '/developer/toolbar.php'; + $app->params['ckeditor']['developer']['plugins'] = require $presetsPath . '/developer/plugins.php'; + + // set preset example + /*$form->field($model, 'content')->widget(CKEditor::class, [ + 'editorOptions' => \zertex\elfinder\ElFinder::ckeditorOptions('elfinder',[ + 'toolbar' => Yii::$app->params['ckeditor']['editor']['toolbar'], + 'extraPlugins' => Yii::$app->params['ckeditor']['editor']['plugins'], + ]) + ])*/ + $container->set(CKEditor::class, [ - 'editorOptions' => ElFinder::ckeditorOptions('elfinder', []), + 'editorOptions' => ElFinder::ckeditorOptions('elfinder', [ + 'toolbar' => $app->params['ckeditor']['editor']['toolbar'], + 'extraPlugins' => $app->params['ckeditor']['editor']['plugins'], + ]), ]); // load settings diff --git a/backend/config/main.php b/backend/config/main.php index 4e78edd..8706b53 100644 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -20,8 +20,12 @@ return [ 'common\bootstrap\SetUp', 'backend\bootstrap\SetUp', ], - 'modules' => [], - 'controllerMap' => [ + 'modules' => [ + 'elfinder' => [ + 'class' => 'core\components\elfinder\ElFinderModule', + ], + ], + /*'controllerMap' => [ 'elfinder' => [ 'class' => 'mihaildev\elfinder\Controller', 'access' => ['@'], @@ -41,6 +45,27 @@ return [ ], ], ], + ],*/ + 'controllerMap' => [ + 'elfinder' => [ + 'class' => 'zertex\elfinder\Controller', + 'access' => ['@'], + 'plugin' => [ + [ + 'class'=>'\zertex\elfinder\plugin\Sluggable', + 'lowercase' => true, + 'replacement' => '-' + ] + ], + 'roots' => [ + [ + 'baseUrl'=>'@static', + 'basePath'=>'@staticRoot', + 'path' => 'files', + 'name' => 'Global' + ], + ], + ], ], 'components' => [ 'request' => [ diff --git a/common/modules/blog/views/manage/category/_form.php b/common/modules/blog/views/manage/category/_form.php index d444072..e7ebd26 100644 --- a/common/modules/blog/views/manage/category/_form.php +++ b/common/modules/blog/views/manage/category/_form.php @@ -1,6 +1,6 @@ field($model, 'parentId')->dropDownList($model->parentsList()) ?> field($model, 'title')->textInput(['maxlength' => true]) ?> field($model, 'slug')->textInput(['maxlength' => true]) ?> - field($model, 'content')->widget(CKEditor::class) ?> - + field($model, 'content')->widget(CKEditor::class) ?> diff --git a/composer.json b/composer.json index ae2dfd7..bd4a8e8 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ }, "minimum-stability": "stable", "require": { - "php": ">=5.4.0", + "php": ">=7.1.0", "yiisoft/yii2": "~2.0.6", "yiisoft/yii2-bootstrap": "~2.0.0", "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0", @@ -39,7 +39,9 @@ "zertex/yii2-avatar-generator": "*", "paulzi/yii2-sortable": "^1.0", "paulzi/yii2-adjacency-list" : "^2.1", - "yiisoft/yii2-jui": "^2.0" + "yiisoft/yii2-jui": "^2.0", + "zertex/yii2-elfinder": "^1.2", + "zertex/yii2-ckeditor": "^1.0" }, "require-dev": { "yiisoft/yii2-debug": "~2.0.0", @@ -55,6 +57,14 @@ { "type": "composer", "url": "https://asset-packagist.org" + }, + { + "type": "vcs", + "url": "https://github.com/zertex/yii2-ckeditor.git" + }, + { + "type": "vcs", + "url": "https://github.com/zertex/yii2-elfinder.git" } ] } diff --git a/core/components/ckeditor/presets/basic/plugins.php b/core/components/ckeditor/presets/basic/plugins.php new file mode 100644 index 0000000..9383dce --- /dev/null +++ b/core/components/ckeditor/presets/basic/plugins.php @@ -0,0 +1,54 @@ + 'basicstyles', 'items' => [ 'Bold', 'Italic', 'Underline', 'Strike', '-', 'TextColor', 'BGColor' ] ], + ]; \ No newline at end of file diff --git a/core/components/ckeditor/presets/developer/plugins.php b/core/components/ckeditor/presets/developer/plugins.php new file mode 100644 index 0000000..d407b4b --- /dev/null +++ b/core/components/ckeditor/presets/developer/plugins.php @@ -0,0 +1,54 @@ + 'document', 'items' => [ 'Source', '-', 'searchCode', 'autoFormat', 'CommentSelectedRange', 'UncommentSelectedRange', 'AutoComplete', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates' ] ], + [ 'name' => 'clipboard', 'items' => [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] ], + [ 'name' => 'editing', 'items' => [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] ], + [ 'name' => 'forms', 'items' => [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] ], + '/', + [ 'name' => 'basicstyles', 'items' => [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'CopyFormatting', 'RemoveFormat' ] ], + [ 'name' => 'paragraph', 'items' => [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language' ] ], + [ 'name' => 'links', 'items' => [ 'Link', 'Unlink', 'Anchor' ] ], + [ 'name' => 'insert', 'items' => [ 'CodeSnippet', 'Image', 'VideoDetector', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe', 'Footnotes', 'Spoiler' ] ], + '/', + [ 'name' => 'styles', 'items' => [ 'Styles', 'Format', 'Font', 'FontSize' ] ], + [ 'name' => 'colors', 'items' => [ 'TextColor', 'BGColor' ] ], + [ 'name' => 'tools', 'items' => [ 'Maximize', 'ShowBlocks' ] ], + [ 'name' => 'about', 'items' => [ 'About' ] ] + ]; \ No newline at end of file diff --git a/core/components/ckeditor/presets/editor/plugins.php b/core/components/ckeditor/presets/editor/plugins.php new file mode 100644 index 0000000..d281c2a --- /dev/null +++ b/core/components/ckeditor/presets/editor/plugins.php @@ -0,0 +1,54 @@ + 'document', 'items' => [ 'Source', '-', 'searchCode', 'autoFormat', 'CommentSelectedRange', 'UncommentSelectedRange', 'AutoComplete', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates' ] ], + [ 'name' => 'clipboard', 'items' => [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] ], + [ 'name' => 'editing', 'items' => [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] ], + [ 'name' => 'forms', 'items' => [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] ], + '/', + [ 'name' => 'basicstyles', 'items' => [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'CopyFormatting', 'RemoveFormat' ] ], + [ 'name' => 'paragraph', 'items' => [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language' ] ], + [ 'name' => 'links', 'items' => [ 'Link', 'Unlink', 'Anchor' ] ], + [ 'name' => 'insert', 'items' => [ 'CodeSnippet', 'Image', 'VideoDetector', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe', 'Footnotes', 'Spoiler' ] ], + '/', + [ 'name' => 'styles', 'items' => [ 'Styles', 'Format', 'Font', 'FontSize' ] ], + [ 'name' => 'colors', 'items' => [ 'TextColor', 'BGColor' ] ], + [ 'name' => 'tools', 'items' => [ 'Maximize', 'ShowBlocks' ] ], + [ 'name' => 'about', 'items' => [ 'About' ] ] + ]; \ No newline at end of file diff --git a/static/files/bd942d71aa78e54a473ea0ddc2a0d7f6.jpg b/static/files/bd942d71aa78e54a473ea0ddc2a0d7f6.jpg index fce9c8c..6132bd5 100644 Binary files a/static/files/bd942d71aa78e54a473ea0ddc2a0d7f6.jpg and b/static/files/bd942d71aa78e54a473ea0ddc2a0d7f6.jpg differ