Index: wysiwyg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.module,v
retrieving revision 1.29
diff -u -p -r1.29 wysiwyg.module
--- wysiwyg.module	18 May 2009 01:08:13 -0000	1.29
+++ wysiwyg.module	7 Jun 2009 20:42:05 -0000
@@ -351,72 +351,82 @@ function wysiwyg_add_editor_settings($pr
  *   and simplify this entire function.
  */
 function wysiwyg_add_plugin_settings($profile) {
-  static $plugins_native = array();
-  static $plugins_drupal = array();
+  static $plugins = array();
+  static $processed_plugins = array();
   static $processed_formats = array();
 
   // Each input format must only processed once.
+  // @todo ...as long as we do not have multiple profiles per format.
   if (isset($processed_formats[$profile->format])) {
     return;
   }
+  $processed_formats[$profile->format] = TRUE;
 
   $editor = wysiwyg_get_editor($profile->editor);
-  // Assume that this editor does not support neither native external plugins
-  // nor Drupal plugins if it does not provide a callback.
-  if (!(isset($editor['plugin settings callback']) && function_exists($editor['plugin settings callback']))) {
-    return;
+
+  // Collect native plugins for this editor provided via hook_wysiwyg_plugin()
+  // and Drupal plugins provided via hook_wysiwyg_include_directory().
+  if (!array_key_exists($editor['name'], $plugins)) {
+    $plugins[$editor['name']] = wysiwyg_get_plugins($editor['name']);
   }
 
-  // Collect native external plugins for this editor provided via
-  // hook_wysiwyg_plugin().
-  if (!array_key_exists($editor['name'], $plugins_native)) {
-    $plugins_native[$editor['name']] = module_invoke_all('wysiwyg_plugin', $editor['name'], $editor['installed version']);
-  }
-  // Only keep native external plugins that are enabled in this profile.
-  $profile_plugins_native = array();
-  foreach ($plugins_native[$editor['name']] as $plugin => $meta) {
-    if (isset($profile->settings['buttons'][$plugin])) {
-      $profile_plugins_native[$plugin] = $plugins_native[$editor['name']][$plugin];
-    }
-  }
-  // Invoke the editor's plugin settings callback, so it can populate the
-  // settings for native external plugins with custom, required values.
-  $settings_native = $editor['plugin settings callback']($editor, $profile, $profile_plugins_native);
-
-  drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('native' => $settings_native)))), 'setting');
-
-  // If this editor does not define a proxy plugin and a proxy plugin settings
-  // callback, it does not support Drupal plugins.
-  if (!(isset($editor['proxy plugin']) && isset($editor['proxy plugin settings callback']) && function_exists($editor['proxy plugin settings callback']))) {
+  // Nothing to do, if there are no plugins.
+  if (empty($plugins[$editor['name']])) {
     return;
   }
 
-  // Collect, load, and add proxy plugins provided by Drupal modules.
-  $proxy = key($editor['proxy plugin']);
-  $proxy_plugins = array();
-  foreach (wysiwyg_get_all_plugins() as $plugin_name => $meta) {
-    if (isset($profile->settings['buttons'][$proxy][$plugin_name])) {
-      if (!isset($plugins_drupal[$plugin_name])) {
-        $proxy_plugins[$plugin_name] = $plugins_drupal[$plugin_name] = $meta;
-        // Load the Drupal plugin's JavaScript.
-        drupal_add_js($meta['js path'] .'/'. $meta['js file']);
-        // Add plugin specific settings.
-        if (isset($meta['settings'])) {
-          drupal_add_js(array('wysiwyg' => array('plugins' => array('drupal' => array($plugin_name => $meta['settings'])))), 'setting');
-        }
+  // Determine name of proxy plugin for Drupal plugins.
+  $proxy = (isset($editor['proxy plugin']) ? key($editor['proxy plugin']) : '');
+
+  // Process native editor plugins.
+  if (isset($editor['plugin settings callback'])) {
+    // @todo Require PHP 5.1 in 3.x and use array_intersect_key().
+    $profile_plugins_native = array();
+    foreach ($plugins[$editor['name']] as $plugin => $meta) {
+      // Skip Drupal plugins (handled below).
+      if ($plugin === $proxy) {
+        continue;
       }
-      else {
-        $proxy_plugins[$plugin_name] = $plugins_drupal[$plugin_name];
+      // Only keep native plugins that are enabled in this profile.
+      if (isset($profile->settings['buttons'][$plugin])) {
+        $profile_plugins_native[$plugin] = $meta;
       }
     }
+    // Invoke the editor's plugin settings callback, so it can populate the
+    // settings for native external plugins with required values.
+    $settings_native = call_user_func($editor['plugin settings callback'], $editor, $profile, $profile_plugins_native);
+  
+    drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('native' => $settings_native)))), 'setting');
+  }
+
+  // Process Drupal plugins.
+  if ($proxy && isset($editor['proxy plugin settings callback'])) {
+    $profile_plugins_drupal = array();
+    foreach (wysiwyg_get_all_plugins() as $plugin => $meta) {
+      if (isset($profile->settings['buttons'][$proxy][$plugin])) {
+        // JavaScript and plugin-specific settings for Drupal plugins must be
+        // loaded and processed only once. Plugin information is cached
+        // statically to pass it to the editor's proxy plugin settings callback.
+        if (!isset($processed_plugins[$proxy][$plugin])) {
+          $profile_plugins_drupal[$plugin] = $processed_plugins[$proxy][$plugin] = $meta;
+          // Load the Drupal plugin's JavaScript.
+          drupal_add_js($meta['js path'] .'/'. $meta['js file']);
+          // Add plugin-specific settings.
+          if (isset($meta['settings'])) {
+            drupal_add_js(array('wysiwyg' => array('plugins' => array('drupal' => array($plugin => $meta['settings'])))), 'setting');
+          }
+        }
+        else {
+          $profile_plugins_drupal[$plugin] = $processed_plugins[$proxy][$plugin];
+        }
+      }
+    }
+    // Invoke the editor's proxy plugin settings callback, so it can populate
+    // the settings for Drupal plugins with custom, required values.
+    $settings_drupal = call_user_func($editor['proxy plugin settings callback'], $editor, $profile, $profile_plugins_drupal);
+  
+    drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('drupal' => $settings_drupal)))), 'setting');
   }
-  // Invoke the editor's proxy plugin settings callback, so it can populate
-  // the settings for Drupal plugins with custom, required values.
-  $settings_drupal = $editor['proxy plugin settings callback']($editor, $profile, $proxy_plugins);
-
-  drupal_add_js(array('wysiwyg' => array('plugins' => array('format' . $profile->format => array('drupal' => $settings_drupal)))), 'setting');
-
-  $processed_formats[$profile->format] = TRUE;
 }
 
 /**
Index: editors/fckeditor.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/fckeditor.inc,v
retrieving revision 1.15
diff -u -p -r1.15 fckeditor.inc
--- editors/fckeditor.inc	4 Jun 2009 00:53:10 -0000	1.15
+++ editors/fckeditor.inc	7 Jun 2009 22:01:06 -0000
@@ -172,12 +172,22 @@ function wysiwyg_fckeditor_themes($edito
 
 /**
  * Build a JS settings array of native external plugins that need to be loaded separately.
- *
- * @todo Required for FCKeditor?  If not, wysiwyg_add_plugin_settings() needs
- *   an overhaul.
  */
 function wysiwyg_fckeditor_plugin_settings($editor, $profile, $plugins) {
   $settings = array();
+  foreach ($plugins as $name => $plugin) {
+    // Register all plugins that need to be loaded.
+    if (!empty($plugin['load'])) {
+      $settings[$name] = array();
+      // Add path for native external plugins; internal ones do not need a path.
+      if (empty($plugin['internal']) && isset($plugin['path'])) {
+        $settings[$name]['path'] = base_path() . $plugin['path'];
+      }
+      if (!empty($plugin['languages'])) {
+        $settings[$name]['languages'] = $plugin['languages'];
+      }
+    }
+  }
   return $settings;
 }
 
@@ -203,7 +213,7 @@ function wysiwyg_fckeditor_proxy_plugin_
  * Return internal plugins for FCKeditor; semi-implementation of hook_wysiwyg_plugin().
  */
 function wysiwyg_fckeditor_plugins($editor) {
-  return array(
+  $plugins = array(
     'default' => array(
       'buttons' => array(
         'Bold' => t('Bold'), 'Italic' => t('Italic'), 'Underline' => t('Underline'),
@@ -235,6 +245,50 @@ function wysiwyg_fckeditor_plugins($edit
       ),
       'internal' => TRUE,
     ),
+    'autogrow' => array(
+      'path' => $editor['library path'] . '/editor/plugins',
+      'extensions' => array(
+        'autogrow' => t('Autogrow'),
+      ),
+      'options' => array(
+        'AutoGrowMax' => 800,
+      ),
+      'internal' => TRUE,
+      'load' => TRUE,
+    ),
+    'bbcode' => array(
+      'path' => $editor['library path'] . '/editor/plugins',
+      'extensions' => array(
+        'bbcode' => t('BBCode'),
+      ),
+      'internal' => TRUE,
+      'load' => TRUE,
+    ),
+    'dragresizetable' => array(
+      'path' => $editor['library path'] . '/editor/plugins',
+      'extensions' => array(
+        'dragresizetable' => t('Table drag/resize'),
+      ),
+      'internal' => TRUE,
+      'load' => TRUE,
+    ),
+    'tablecommands' => array(
+      'path' => $editor['library path'] . '/editor/plugins',
+      'buttons' => array(
+        'TableCellProp' => t('Table: Cell properties'),
+        'TableInsertRowAfter' => t('Table: Insert row after'),
+        'TableInsertColumnAfter' => t('Table: Insert column after'),
+        'TableInsertCellAfter' => t('Table: Insert cell after'),
+        'TableDeleteRows' => t('Table: Delete rows'),
+        'TableDeleteColumns' => t('Table: Delete columns'),
+        'TableDeleteCells' => t('Table: Delete cells'),
+        'TableMergeCells' => t('Table: Merge cells'),
+        'TableHorizontalSplitCell' => t('Table: Horizontal split cell'),
+      ),
+      'internal' => TRUE,
+      'load' => TRUE,
+    ),
   );
+  return $plugins;
 }
 
Index: editors/js/fckeditor.config.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/fckeditor.config.js,v
retrieving revision 1.4
diff -u -p -r1.4 fckeditor.config.js
--- editors/js/fckeditor.config.js	26 Mar 2009 22:31:42 -0000	1.4
+++ editors/js/fckeditor.config.js	7 Jun 2009 21:19:58 -0000
@@ -11,6 +11,7 @@ Drupal = window.parent.Drupal;
  */
 var wysiwygFormat = FCKConfig.PageConfig.wysiwygFormat;
 var wysiwygSettings = Drupal.settings.wysiwyg.configs.fckeditor[wysiwygFormat];
+var pluginSettings = Drupal.settings.wysiwyg.plugins[wysiwygFormat];
 
 /**
  * Apply format-specific settings.
@@ -31,6 +32,19 @@ for (var setting in wysiwygSettings) {
 Drupal.wysiwyg.editor.instance.fckeditor.init(window);
 
 /**
+ * Register native plugins for this input format.
+ *
+ * Parameters to Plugins.Add are:
+ * - Plugin name.
+ * - Languages the plugin is available in.
+ * - Location of the plugin folder; <plugin_name>/fckplugin.js is appended.
+ */
+for (var plugin in pluginSettings['native']) {
+  // Languages and path may be undefined for internal plugins.
+  FCKConfig.Plugins.Add(plugin, pluginSettings['native'][plugin].languages, pluginSettings['native'][plugin].path);
+}
+
+/**
  * Register Drupal plugins for this input format.
  *
  * Parameters to addPlugin() are:
@@ -39,7 +53,7 @@ Drupal.wysiwyg.editor.instance.fckeditor
  * - General plugin settings.
  * - A reference to this window so the plugin setup can access FCKConfig.
  */
-for (var plugin in Drupal.settings.wysiwyg.plugins[wysiwygFormat].drupal) {
-  Drupal.wysiwyg.editor.instance.fckeditor.addPlugin(plugin, Drupal.settings.wysiwyg.plugins[wysiwygFormat].drupal[plugin], Drupal.settings.wysiwyg.plugins.drupal[plugin], window);
+for (var plugin in pluginSettings.drupal) {
+  Drupal.wysiwyg.editor.instance.fckeditor.addPlugin(plugin, pluginSettings.drupal[plugin], Drupal.settings.wysiwyg.plugins.drupal[plugin], window);
 }
 
