CKEditor:将值传回 link-plugin

CKEditor: pass value back to link-plugin

To insert a link to specific files I want to add a button to the link-Dialog, which opens my own php-filebrowser.

In this filebrowser I can browse specific directories to finally select a pdf-file.

By clicking on a file I want to pass the url of this file to the link-dialogs url-field. And that is the point where I do not get ahead.

The url I alert when clicking the file is the one I need. All I need is the javascript to pass it to the opener's url-field. I have tried several proposed solutions I found in this forum but nothing helped.

In my filebrowser I have a list of files. Each file has a link like this one:

<a href="javascript:passvalue('*my_file_with_path*');">*filename*</a>

This is the javascript part I tried in my filebrowser:

<script>
     function passvalue(url) {
       alert (url);
       opener.SetValue(url, 'url');
       window.close();
     }
</script>

The script alerts the correct value. But the next line doesn't pass the value back.

Instead of "opener.SetValue(url, 'url');" I also tried window.opener.CKEDITOR.tools.callFunction(ckeditorfuncnum, url);
with the ckeditorfuncnum passed to the script and
opener.SetUrl(url);

更新: it seems as if the second try ('window.opener.CKEditor...') would be the right one. Since no value is displayed in my input field, I tried to return an error message... The error message is being displayed in the window with the CKEditor-Fields.

对于可能 运行 遇到同样问题的每个人,这里是解决方案:

function passvalue(url) {
    var dialog = window.opener.CKEDITOR.dialog.getCurrent();
    dialog.setValueOf('info', 'url', url);
    dialog.setValueOf('info', 'protocol', 'http://');
    window.close();
  }