ezze / ezze-elfinder

YII framework's extension used to integrate ElFinder file manager.
11 stars 5 forks source link

Keep getting {"error":["errUnknownCmd"]} #2

Closed yfktn closed 11 years ago

yfktn commented 11 years ago

Hi, I've following your direction in YII wiki, but sadly, for me it doesn't worked and just keep returned {"error":["errUnknownCmd"]}. I've searching all over the Internet and forum to find out the cause of this error, but I cannot fix it.

I'll show You how my code is, according what I've read based on wiki ...

// this is my Connector named EzZelConnectorController
class EzZelConnectorController extends Controller {
    public function filters()
    {
        return array(
            'accessControl', // perform access control for CRUD operations
        );
    }
    public function accessRules()
    {
        return array(
            array('allow', // allow admin user to perform 'admin' and 'delete' actions
                'actions'=>array('fileUploader'),
                'expression'=> "Yii::app()->user->isAdmin === true",
            ),
            array('deny',  // deny all users
                'users'=>array('*'),
            ),
        );
    }

    public function actions() {
        return array(
            'fileUploader' => 'ext.ezzeelfinder.ElFinderConnectorAction',
        );
    }
}

And then this is my view that put in protected/views/ezZelConnector/fileUploader.php

echo '<div id="file-uploader"></div>';

$filesPath = Yii::getPathOfAlias('webroot') . "/uploads/";
$filesUrl = Yii::app()->baseUrl . "/uploads/";

$this->widget("ext.ezzeelfinder.ElFinderWidget", array(
    'selector' => "div#file-uploader",
    'clientOptions' => array(
//        'lang' => "ru",
        'resizable' => false,
        'wysiwyg' => "ckeditor"
    ),
    'connectorRoute' => "ezZelConnector/fileUploader",
    'connectorOptions' => array(
        'roots' => array(
            array(
                'driver'  => "LocalFileSystem",
                'path' => $filesPath,
                'URL' => $filesUrl,
                'tmbPath' => $filesPath . DIRECTORY_SEPARATOR . ".thumbs",
                'mimeDetect' => "internal",
                'accessControl' => "access"
            )
        )
    )
));

After that, when I call it from my Browser through http://my.localhost.local/ezZelConnector/fileUploader it just keep returned the error message above.

Did I miss something about how to installed your extension? Any help would be appreciated.

Regards,

Yan

yfktn commented 11 years ago

Oh my God, I forgot to add proper action. It only needs to add

    public function actionFileUploader() {
        $this->render('fileUploader');
    }

and change the connector name to fileUploaderConnector.

Your extensions worked, it's my fault! I'm really sorry ...

ezze commented 11 years ago

No problem! ;)

alexbs commented 11 years ago

Sorry, please help, i have tried your code, but get the error 'Unable to connect to backend.' (the filemanager is displayed on screen but there is an error window over him)

"and change the connector name to fileUploaderConnector."

  • where is that name that i should change?

when typing an address: http://site.com/ezZelConnector/fileUploaderConnector/ In my FireBug i can see the red line: http://site.com/ezZelConnector/fileUploaderConnector/elfinder_connector_options/YToxOntzOjU6InJvb3RzIjthOjE6e2k6MDthOjY6e3M6NjoiZHJpdmVyIjtzOjE1OiJMb2NhbEZpbGVTeXN0ZW0iO3M6NDoicGF0aCI7czoyNToiWDovaG9tZS9sYW1wYS5ydS91cGxvYWRzLyI7czozOiJVUkwiO3M6OToiL3VwbG9hZHMvIjtzOjc6InRtYlBhdGgiO3M6MzM6Ilg6L2hvbWUvbGFtcGEucnUvdXBsb2Fkcy9cLnRodW1icyI7czoxMDoibWltZURldGVjdCI7czo4OiJpbnRlcm5hbCI7czoxMzoiYWNjZXNzQ29udHJvbCI7czo2OiJhY2Nlc3MiO319fQ%3D%3D/?cmd=open&target=&init=1&tree=1&_=1350801461313

mine code:

controllers/EzZelConnectorController.php

<?php

// this is my Connector named EzZelConnectorController
class EzZelConnectorController extends Controller {
    public $layout='/layouts/clear';

    public function filters()
    {
        return array(
            'accessControl', // perform access control for CRUD operations
        );
    }
    public function accessRules()
    {
        return array(
            array('allow', // allow admin user to perform 'admin' and 'delete' actions
                'actions'=>array('fileUploaderConnector','fileUploader',),
                //'expression'=> "Yii::app()->user->isAdmin === true",
                //'expression'=> "1 === 1",
                'users'=>array('*'),
            ),
            //array('deny',  // deny all users
            //  'users'=>array('*'),
            //),
        );
    }

    public function actions() {
        return array(
            'fileUploaderConnector' => 'ext.ezzeelfinder.ElFinderConnectorAction',
        );
    }

    public function actionfileUploaderConnector() {
        $this->render('fileUploader');
    }

}

views/ezZelConnector/fileUploader.php

<?php
echo '<div id="file-uploader"></div>';

$filesPath = Yii::getPathOfAlias('webroot') . "/uploads/";
$filesUrl = Yii::app()->baseUrl . "/uploads/";

$this->widget("ext.ezzeelfinder.ElFinderWidget", array(
    'selector' => "div#file-uploader",
    'clientOptions' => array(
        'lang' => "ru",
        'resizable' => false,
        'wysiwyg' => "NOckeditor"
    ),
    'connectorRoute' => "ezZelConnector/fileUploaderConnector",
    'connectorOptions' => array(
        'roots' => array(
            array(
                'driver'  => "LocalFileSystem",
                'path' => $filesPath,
                'URL' => $filesUrl,
                'tmbPath' => $filesPath . DIRECTORY_SEPARATOR . ".thumbs",
                'mimeDetect' => "internal",
                'accessControl' => "access"
            )
        )
    )
));

And the extension is in folder extensions/ezzeelfinder

have spent more 8 hours but still can't resolve problem (

ezze commented 11 years ago

Dear alexbs!

I hope I can help to solve your problem. I've copied and pasted your code to my project and seems to me I know what's the issue.

As you can see, the extension requires two actions to be used: the first one that you've defined as your controller's method (it renders fileUploader view), the second one that is already defined in extension as ElFinderConnectorAction and you refer to it in actions method.

The problem is that you have a route collision for both your actions. Action public function actionFileUploaderConnector() corresponds to ezZelConnector/fileUploaderConnector route, and ext.ezzeelfinder.ElFinderConnectorAction corresponds to the same root due to you specified its action as fileUploaderConnector (array key in actions method). As the result one action overrides another, and when ElFinder interface is loaded it sends a request to connector action and can't get back a valid JSON response due to it requests the same page that renders ElFinder's interface but not the connector script.

The solution is to rename your action function that renders fileUploader view. For example, instead of

public function actionfileUploaderConnector() {
    $this->render('fileUploader');
}

you can type

public function actionFileUploader() {
    $this->render('fileUploader');
}

and then access your ElFinder by this URL: http://site.com/ezZelConnector/fileUploader.

Please also make sure that directory pointed by $filesPath in view fileUploader exists. In example above it is uploads directory in site's root directory.

alexbs commented 11 years ago

Thanks a lot for help! I have done as you proposed, but when i go for http://site.com/ezZelConnector/fileUploader - i received a message like 'Can't connect to the server..' (

I think that it would be very useful for me and many other Yii users if you put working sample files to the archive with original extension folder..

Please... if it is not a good idea in your opinion - please send me this files..

Thanks for your big work on this extension!!

alexbs commented 11 years ago

Please... Can anybody post a full code of your working extension? It wont work! (

ezze commented 11 years ago

Hey, here you can download demo files I've prepared specially for you: http://ezze.org/yii/ezzeelfinderdemo.zip

You have to extract the archive to the root directory of your site. After extracting the files also make sure that upload directory has 777 permissions. You can specify another directory in ezze/elfinder view.

To access a page with ElFinder specify a route ezze/elfinder as r parameter of URL.

Please note that these code snippets have been written and tested with Yii's demo web application (EzzeController extends Controller from components directory).

alexbs commented 11 years ago

Thank's a lot! Now it's working good. Not ready to say what was wrong in my code, there is no time right now to find out. I hope that that upload which you have made will be usefull for other