Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imce/README.txt,v
retrieving revision 1.11.2.5
diff -u -p -r1.11.2.5 README.txt
--- README.txt	5 Jul 2008 21:09:38 -0000	1.11.2.5
+++ README.txt	13 Feb 2009 02:15:14 -0000
@@ -57,9 +57,6 @@ And also if "safe mode restriction" is a
 - Disappearing images after node submission:
 Having nothing to do with IMCE, it appeared many times in issue queues. This is an input filtering issue that can be resolved by adding <img> tag into the default input format. Using Full HTML is another solution. See admin/settings/filters.
 
-- No browse button in IE/FF/at all:
-Probably talking about tinyMCE or FCKeditor. See INTEGRATION METHODS to learn to integrate it by yourself.
-
 - Upload does not work in Opera
 Jquery form plugin before version 2.09 has problems with Opera 9.2+. Replace Drupal's misc/jquery.form.js with http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js
 
@@ -67,19 +64,9 @@ Jquery form plugin before version 2.09 h
 
 Here are the applications whose users are lucky that they don't have to read the details of integration methods.
 
-BUEditor: Obviously, the author knows how to integrate IMCE to his application:). Users need nothing to do.
-
-FCKeditor: Another module from another blessed author, which makes IMCE integration as simple as a single click. Fckeditor profile->File browser settings->IMCE integration
-Note: One can also override the settings at advanced settings->custom javascript configuration.
-Here are the lines that force imce integration (don't force unless you need to):
-LinkBrowser= true;
-ImageBrowser= true;
-FlashBrowser= true;
-LinkBrowserURL= '/?q=imce&app=FCKEditor|url@txtUrl';
-ImageBrowserURL= '/?q=imce&app=FCKEditor|url@txtUrl|width@txtWidth|height@txtHeight';
-FlashBrowserURL= '/?q=imce&app=FCKEditor|url@txtUrl';
+Wysiwyg API: Just enable the plugin.  Currently supported: TinyMCE, FCKeditor.
 
-TinyMCE: See http://drupal.org/node/241753#comment-792305
+BUEditor: Obviously, the author knows how to integrate IMCE to his application:). Users need nothing to do.
 
 There may be other applications that integrated IMCE already. If your application is not one of them, please keep reading.
 
Index: imce.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imce/imce.module,v
retrieving revision 1.23.2.5
diff -u -p -r1.23.2.5 imce.module
--- imce.module	19 Jul 2008 13:21:02 -0000	1.23.2.5
+++ imce.module	13 Feb 2009 02:11:17 -0000
@@ -189,4 +189,62 @@ function imce_user_page_access($account,
  */
 function imce_reg_dir($dirname) {
   return $dirname == '.' || (is_string($dirname) && $dirname != '' && !preg_match('@(^\s)|(^/)|(^\./)|(\s$)|(/$)|(/\.$)|(\.\.)|(//)|(\\\\)|(/\./)@', $dirname));
-}
\ No newline at end of file
+}
+
+/**
+ * Implementation of hook_wysiwyg_plugin().
+ */
+function imce_wysiwyg_plugin($editor, $version) {
+  static $integrated = array();
+
+  if (!imce_access()) {
+    return;
+  }
+  // Load our invocation scripts.
+  if (empty($integrated)) {
+    $path = drupal_get_path('module', 'imce');
+    drupal_add_js($path . '/js/imce.js');
+    drupal_add_js($path . '/js/imce_set_app.js');
+  }
+
+  switch ($editor) {
+    case 'tinymce':
+      if (!isset($integrated[$editor])) {
+        $integrated[$editor] = TRUE;
+        $settings = array(
+          'imce' => array('url' => url('imce', array('query' => 'app=' . $editor . '|url@src'))),
+        );
+        drupal_add_js($settings, 'setting');
+      }
+      return array(
+        'imce' => array(
+          'extensions' => array('imce' => t('IMCE')),
+          'url' => 'http://drupal.org/project/imce',
+          'options' => array(
+            'file_browser_callback' => 'imceImageBrowser',
+            'inline_styles' => TRUE,
+          ),
+          'load' => FALSE,
+        ),
+      );
+
+    case 'fckeditor':
+      $integrated[$editor] = TRUE;
+      return array(
+        'imce' => array(
+          'extensions' => array('imce' => t('IMCE')),
+          'url' => 'http://drupal.org/project/imce',
+          'options' => array(
+            'LinkBrowser' => TRUE,
+            'LinkBrowserURL' => url('imce', array('query' => 'app=' . $editor . '|url@txtUrl')),
+            'ImageBrowser' => TRUE,
+            'ImageBrowserURL' => url('imce', array('query' => 'app=' . $editor . '|url@txtUrl|width@txtWidth|height@txtHeight')),
+            'FlashBrowser' => TRUE,
+            'FlashBrowserURL' => url('imce', array('query' => 'app=' . $editor . '|url@txtUrl')),
+          ),
+          'load' => FALSE,
+        ),
+      );
+  }
+}
+
Index: js/imce_set_app.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imce/js/imce_set_app.js,v
retrieving revision 1.3.2.5
diff -u -p -r1.3.2.5 imce_set_app.js
--- js/imce_set_app.js	3 Feb 2009 23:21:26 -0000	1.3.2.5
+++ js/imce_set_app.js	13 Feb 2009 02:10:58 -0000
@@ -48,3 +48,11 @@ var appFinish = function(file, win) {
   appWindow.focus();
   win.close();
 };
+
+/**
+ * Wysiwyg API integration helper function.
+ */
+function imceImageBrowser() {
+  win.open(Drupal.settings.imce.url, '', 'width=760,height=560,resizable=1');
+}
+
