Index: modules/webfm_popup/webfm_popup.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webfm/modules/webfm_popup/webfm_popup.info,v
retrieving revision 1.1
diff -u -p -r1.1 webfm_popup.info
--- modules/webfm_popup/webfm_popup.info	8 Feb 2009 06:27:11 -0000	1.1
+++ modules/webfm_popup/webfm_popup.info	17 Sep 2009 18:09:51 -0000
@@ -1,6 +1,7 @@
 ; $Id: webfm_popup.info,v 1.1 2009/02/08 06:27:11 robmilne Exp $
 name = WebFM Popup
-description = Places the WebFM browser into a popup window for Rich Text Editors
+description = Places the WebFM browser into a popup window for Rich Text Editors with the  wysiwyg-package
 package = WebFM
 core = 6.x
-dependencies[] = webfm
\ No newline at end of file
+dependencies[] = webfm
+dependencies[] = wysiwyg
\ No newline at end of file
Index: modules/webfm_popup/webfm_popup.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webfm/modules/webfm_popup/webfm_popup.js,v
retrieving revision 1.1
diff -u -p -r1.1 webfm_popup.js
--- modules/webfm_popup/webfm_popup.js	8 Feb 2009 06:27:11 -0000	1.1
+++ modules/webfm_popup/webfm_popup.js	17 Sep 2009 18:09:52 -0000
@@ -1,29 +1,61 @@
 // $Id: webfm_popup.js,v 1.1 2009/02/08 06:27:11 robmilne Exp $
 
+/**
+ * Wysiwyg API integration helper function.
+ */
+function webfm_popup_tinymce(field_name, url, type, win) {
+  // TinyMCE.
+  if (win !== 'undefined') {
+    win.open(Drupal.settings.webfm_popup.url + encodeURIComponent(field_name), '', 'width=760,height=560,resizable=1');
+  }
+}
+
+
+/**
+  * WebFM Popup handler functions
+  */
 function webfm_popup() {}
 
-if (Drupal.jsEnabled) {
+if (Drupal.jsEnabled && get_url_param('q') == 'webfm_popup') {
   $(window).load(webfm_popupGetMenusAjax);
 }
 
 // Add the send to rich text editor link to the right click menu of files.
 function webfm_popupGetMenusAjax() {
   Webfm.menuHT.put('file', new Webfm.menuElement("Send to rich text editor", webfm_popup.sendtocaller, ""));
-}
+};
 
-// Send the selected file to the rich text editor.
-webfm_popup.sendtocaller = function(obj) {
+//Redirect to the correct editor function
+webfm_popup.sendtocaller = function(fileobj) {
+	if(get_url_param('caller') == 'ckeditor') webfm_popup.sendtockeditor(fileobj);
+	if(get_url_param('caller') == 'tinymce') webfm_popup.sendtotinymce(fileobj);
+};
+
+/**
+ * Send data to ckeditor
+ */
+webfm_popup.sendtockeditor = function(fileobj) {
+	var fid = $('#'+fileobj.row_id).find('td').eq(1).find('a').attr('title');
+	window.opener.CKEDITOR.tools.callFunction(get_url_param('CKEditorFuncNum'), Drupal.settings.basePath + 'webfm_send/' + fid);
+	window.opener.focus();
+	window.close();
+};
+
+/**
+ * Send data to tinymce
+ */
+webfm_popup.sendtotinymce = function(fileobj) {
   // the window this popup was called from
   var doc = $(window.opener.document);
 
   // put the file url in the input with the id specified in the url
-  var fpath = obj.filepath;
-  var url_id = '#'+get_url_param('url');
+  var fpath = fileobj.filepath;
+  var url_id = '#'+get_url_param('webfm_popup_target_field_name');
   doc.find(url_id).val(Drupal.settings.basePath + Drupal.settings.webfm_popup.fileDirectory + fpath);
   doc.find(url_id).change();
 
   // put the webfm file-id in the input with the id specified in the url
-  var fid = $('#'+obj.row_id).find('td').eq(1).find('a').attr('title');
+  var fid = $('#'+fileobj.row_id).find('td').eq(1).find('a').attr('title');
 //  console.log(fid);
   var webfm_id = '#'+get_url_param('webfmid');
   doc.find(webfm_id).val(Drupal.settings.basePath + 'webfm_send/' + fid);
@@ -33,6 +65,7 @@ webfm_popup.sendtocaller = function(obj)
   window.close();
 }
 
+
 // read GET parameter from the url
 // for example on the url http://example.com/page.php?some=value&more=evenmore&get_it=yes
 // calling get_url_param('get_it') would return 'yes'
Index: modules/webfm_popup/webfm_popup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webfm/modules/webfm_popup/webfm_popup.module,v
retrieving revision 1.5
diff -u -p -r1.5 webfm_popup.module
--- modules/webfm_popup/webfm_popup.module	5 Aug 2009 03:33:21 -0000	1.5
+++ modules/webfm_popup/webfm_popup.module	17 Sep 2009 18:09:52 -0000
@@ -11,10 +11,19 @@
  */
 function webfm_popup_help($path, $arg) {
   if ($path == 'admin/help#webfm_popup') {
-    $txt = "This module creates a popup for the webfm module. <br />
+    $txt = t("This module creates a popup for the webfm module. <br />
+	<h3>Usage with the WYSIWYG_modul</h3>
+    <ol>
+      <li>Go to !wysiwyg</li>
+	  <li>Choose which input format you which to edit, e.g. <em>Filtered HTML</em></li>
+	  <li>In the section <em>Buttons and Plugins</em>. Select to use <em>webfm_popup</em></li>
+	  <li>You must also select a least one of image or flash</li>
+	  <li>Once you save and go back to create content you will be able to <em>Browse server</em> through the editor.</li>
+	  <li>Right click the file that you would like to insert and select <em>Send to rich text editor</em></li>
+	  </ol>
     <h3>FCKEditor Usage</h3>
     <ol>
-      <li>Go to admin/settings/fckeditor</li>
+      <li>Go to !fckeditor</li>
       <li>Edit the profile you would like to use it.</li>
       <li>Under Advanced options Enter the code below into the Custom javascript
       configuration box.
@@ -34,8 +43,8 @@ function webfm_popup_help($path, $arg) {
       </p>
       </li>
       <li>Click Save Configuration</li>
-    </ol>";
-    return '<p>'. t($txt) .'</p>';
+    </ol>",array('!fckeditor' => l('admin/settings/fckeditor','admin/settings/fckeditor'), '!wysiwyg' => l('admin/settings/wysiwyg','admin/settings/wysiwyg'));
+    return '<p>'. $txt .'</p>';
   }
 }
 
@@ -58,31 +67,44 @@ function webfm_popup_webfm_extend_js(){
 * Implementation of hook_wysiwyg_plugin().
 */
 function webfm_popup_wysiwyg_plugin($editor) {
-  static $integrated;
+  static $integrated = array();
+  
+    if (empty($integrated)) {
+		$modulepath = drupal_get_path('module', 'webfm_popup');
+		drupal_add_js($modulepath.'/webfm_popup.js');
+  }
+  
   switch ($editor) {
-    case 'tinymce':
-      if (!isset($integrated)) {
-        $integrated = TRUE;
-        $settings = array(
-          'webfm_popup' => array(
-            'url' => url('webfm'),
-            'appname' => t('editor'),
-            'wysiwyg_module' => true,
+	case 'ckeditor':
+		$integrated[$editor] = TRUE;
+      return array(
+        'webfm_popup' => array(
+          'extensions' => array('webfm_popup' => t('webfm_popup')),
+          'url' => 'http://drupal.org/project/webfm',
+          'options' => array(
+		  
+            'filebrowserBrowseUrl' => url('webfm', array('query' => array('q' => 'webfm_popup','caller'=>$editor)))),
           ),
+          'load' => FALSE,
+      );
+	break;
+	case 'tinymce':
+      if (!isset($integrated[$editor])) {
+        $integrated[$editor] = TRUE;
+        $settings = array(
+          'webfm_popup' => array('url' => url('webfm',array('query' => array('q' => 'webfm_popup','caller'=>$editor,'webfm_popup_target_field_name' => '')))),
         );
         drupal_add_js($settings, 'setting');
-        drupal_add_js(drupal_get_path('module', 'webfm_popup') .'/webfm_popup.js');
       }
       return array(
         'webfm_popup' => array(
           'extensions' => array('webfm_popup' => t('webfm_popup')),
           'url' => 'http://drupal.org/project/webfm',
           'options' => array(
-            'file_browser_callback' => 'webfmImageBrowser',
+            'file_browser_callback' => 'webfm_popup_tinymce',
             'inline_styles' => TRUE,
           ),
           'load' => FALSE,
         ),
       );
-  }
 }
