views:

208

answers:

1

I use InnovaStudio WYSIWYG Editor, and I am trying to replace InnovaStudio's Asset Manager with CKFinder. There's a line in the editor configuration for what URL to use for the asset manager. I have pointed it at CKFinder. The part I can't get to work is getting the field to populate with the double-clicked file's path from CKFinder.

It appears to use the 'func' parameter to specify the callback function. The URL I'm calling is: /common/ckfinder/ckfinder.html?action=js&func=setAssetValue

The InnovaStudio WYSIWYG Editor provides the setAssetValue(v) callback function for setting the field value. The v parameter should hold the URL.

CKFinder pops up as expected when it's invoked, but neither double-clicking the thumbnails nor using the "select" option in the context menu works. The normal/expected behavior is that CKFinder closes and the target field is populated with the URL for the selected asset.


Additional Info: The InnovaStudio WYSIWYG Editor has a "popup" for adding an image or flash file to the content. This pop-up is in an iframe. When it calls CKFinder (or it's own asset manager), that is also in an iframe. It appears that CKFinder is looking in the scope of the main window rather than the image/flash iframe that actually contains the field that needs to be populated.

A: 

(Sort of) Solution

I discovered, by digging through the DOM with Firebug, that InnovaStudio creates an ISWindow object where it places references to the windows that it spawns. I modified my callback function to loop over that object and call the setAssetValue() function for the appropriate iframe. This worked, but CKEditor still did not close itself. I assume that's because it didn't "know" how to close the iframe that it was inside. Is there a way to tell CKFinder how to close the window it's inside of? I can envision other cases where using an iframe would be useful.

I would prefer to have CKFinder to use the iframe display, but I finally got things working using the standard CKFinder popup.

Editor config line: oEdit1.cmdAssetManager = "parent.BrowseServerIS();";

Supporting functions:

// InnovaStudio WYSIWYG Editor version
function BrowseServerIS()
{
   // You can use the "CKFinder" class to render CKFinder in a page:
   var finder = new CKFinder();
   // The path for the installation of CKFinder (default = "/ckfinder/").
   finder.BasePath = '/common/ckfinder/';
   // Name of a function which is called when a file is selected in CKFinder.
   finder.SelectFunction = SetFileFieldIS;
   // Launch CKFinder
   finder.Popup();
}

// InnovaStudio WYSIWYG Editor version
function SetFileFieldIS(fileUrl, data)
{
   for (var i in ISWindow.objs) {
      if ((null != ISWindow.objs[i].rt.frm.contentWindow)
            && ('function' == typeof ISWindow.objs[i].rt.frm.contentWindow.setAssetValue)) {
         ISWindow.objs[i].rt.frm.contentWindow.setAssetValue(fileUrl);
      }
   }
}
Sonny