How to create event capture after renaming or after deleting for CKFinder?

I need to edit the contents and inform the user about various things if the file is deleted or renamed to CKFinder. I thought I could create a JavaScript solution and then offload the logic into the backend using simple AJAX with something like this:

CKFinder.on('successfulFileRename', function(event, oldpath, newpath) {
    // Contact backend, see where file was used, inform user etc etc
});

But, alas, I could not find any system of events. How to implement this function for CKFinder? I need the File / Folder events - Rename / Delete / Move. This should not be an interface, but I would prefer it for simplicity. My backend is ASP.net MVC3.

(Alternatives to CKF are welcome as comments, but they need the same functionality as it.)

+4
source share
1 answer

Looking through the documentation , I also could not find any event, for example, extension points.

However, looking at some source, I found sendCommandPostmetho d in CKFinder.dataTypes.Connector, which starts every time something needs to be sent to the server. So, at every important event, such as File / Folder - Rename / Delete / Move.

This way you can easily create your own plugin in which you can access the CKFinderAPI instance , and from there you can override sendCommandPostand add custom logic

CKFinder.addPlugin( 'myplugin', function( api ) {
    var orginalsendCommandPost = api.connector.sendCommandPost;
    api.connector.sendCommandPost = function() {

      // call the original function
      var result = orginalsendCommandPost.apply(this, arguments);

      // commandname as string: 'CreateFolder', 'MoveFiles', 'RenameFile', etc
      console.log(arguments[0]); 
      // arguments as object
      console.log(JSON.stringify(arguments[1]));

      return result;
    }
} );

And register the plugin:

config.extraPlugins = "myplugin";
var ckfinder = new CKFinder( config );
+3
source

All Articles