Dominus77 / yii2-advanced-start

Yii2 Start Project Advanced Template
https://dominus77.github.io/yii2-advanced-start/
MIT License
23 stars 12 forks source link

Can not insert/edit image while using yii2-tinymce-widget with ElFinder file manager #12

Closed polinwei closed 7 years ago

polinwei commented 7 years ago

While I edit content in tinymce , when I want to insert/edit image , I got 404

Dominus77 commented 7 years ago

Why did you get 404?

Dominus77 commented 7 years ago

What extensions do you use? How do you insert an image? Check the path settings.

polinwei commented 7 years ago

I use dominus77/yii2-tinymce-widget & mihaildev/yii2-elfinder extension.

run command as below

php composer.phar require dominus77/yii2-tinymce-widget "*"
php composer.phar require --prefer-dist mihaildev/yii2-elfinder "*"

yii2-elfinder

Dominus77 commented 7 years ago

The question is not in this thread. And here yii2-advanced-start?)

polinwei commented 7 years ago

Yes

Dominus77 commented 7 years ago

Elfinder is not configured correctly

Dominus77 commented 7 years ago

Show the TinyMCE connection code in View Show the code from the module's init section Show the rules from the Bootstrap.php file of the module

polinwei commented 7 years ago

I follow your recommend. It is workable in yii2-advanced

common\config\main


    'controllerMap' => [
        'elfinder' => [
            'class' => 'mihaildev\elfinder\Controller',
            'access' => ['@'], //Global file manager access @ - for authorized , ? - for guests , to open to all ['@', '?']
            'disabledCommands' => ['netmount'], //disabling unnecessary commands https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#commands
            'roots' => [
                [
                    'baseUrl'=> (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]",
                    'basePath'=>'@frontend/web',
                    'path' => 'files/global',
                    'name' => 'Global'
                ],
                [
                    'class' => 'mihaildev\elfinder\volume\UserPath',
                    'path'  => 'files/user_{id}',
                    'name'  => 'My Documents'
                ],
                [
                    'path' => 'files/some',
                    'name' => ['category' => 'my','message' => 'app'] //перевод Yii::t($category, $message)
                ],
                [
                    'path'   => 'files/some',
                    'name'   => ['category' => 'my','message' => 'app'], // Yii::t($category, $message)
                                'access' => ['read' => '*', 'write' => 'UserFilesAccess'] // * - for all, otherwise the access check in this example can be seen by all users with rights only UserFilesAccess
                ]
            ],
            'watermark' => [
                'source'         => __DIR__.'/logo.png', // Path to Water mark image
                'marginRight'    => 5,          // Margin right pixel
                'marginBottom'   => 5,          // Margin bottom pixel
                'quality'        => 95,         // JPEG image save quality
                'transparency'   => 70,         // Water mark image transparency ( other than PNG )
                'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
                'targetMinPixel' => 200         // Target image minimum pixel size
            ]
        ]
    ],
polinwei commented 7 years ago

Bootstrap.php

namespace modules\blog;

use yii\base\BootstrapInterface;

class Bootstrap implements BootstrapInterface
{
    /**
     * @inheritdoc
     */
    public function bootstrap($app)
    {
        // i18n
        $app->i18n->translations['modules/blog/*'] = [
            'class' => 'yii\i18n\PhpMessageSource',
            'basePath' => '@modules/blog/messages',
            'fileMap' => [
                'modules/blog/module' => 'module.php',                
            ],
        ];

        // Rules
        $app->getUrlManager()->addRules(
            [
                // blog backend
                'blog/post' => 'blog/post/index',
                // CRUD
                'blog/post/<_a:[\w\-]+>' => 'blog/post/<_a>',
                'blog/comment' => 'blog/comment/index',
                'blog/comment/<_a:[\w\-]+>' => 'blog/comment/<_a>',

            ]
        );
    }
}
Dominus77 commented 7 years ago

Try adding a rule to common\config\main

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'normalizer' => [
                'class' => 'yii\web\UrlNormalizer',
                'action' => \yii\web\UrlNormalizer::ACTION_REDIRECT_PERMANENT,
            ],
            'enableStrictParsing' => true,
            'rules' => [
                // Rule Elfinder
                'elfinder' => 'elfinder',
                'elfinder/<_a:[\w\-]+>' => 'elfinder/<_a>',
            ],
        ],

Upd

polinwei commented 7 years ago

Now It can open, but got

Invalid backend response.
Error occurred on the server side.
HTTP error 500

yii2-elfinder2

Dominus77 commented 7 years ago

Connect Elfinder to the module

Dominus77 commented 7 years ago

Now I will plug and skim the example

Dominus77 commented 7 years ago

Try it with my module https://github.com/Dominus77/fm

polinwei commented 7 years ago

How to integrate with dominus77/yii2-tinymce-widget?

Dominus77 commented 7 years ago

Similarly, as indicated in README.md by dominus77/yii2-tinymce-widget

//...
'fileManager' => [
        'class' => \dominus77\tinymce\components\MihaildevElFinder::className(),
        'controller' => Url::to('/fm/elfinder'), // << Link to module fm
        'title' => 'File Manager',
        //'width' => 900,
        //'height' => 600,
        'resizable' => 'yes',
    ],
polinwei commented 7 years ago

It is workable . WOW !! Cool

polinwei commented 7 years ago

Does Dominus77/fm which can plugin yii2-advanced-start ?

polinwei commented 7 years ago

So !! Now I can remove the mihaildev/yii2-elfinder extension ?

Dominus77 commented 7 years ago

no

Dominus77 commented 7 years ago

The module works with this extension, it's just one of the ways to integrate

polinwei commented 7 years ago

Thanks.!!