Index: wysiwyg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.module,v
retrieving revision 1.17.2.2
diff -u -p -r1.17.2.2 wysiwyg.module
--- wysiwyg.module	20 Jan 2009 21:27:04 -0000	1.17.2.2
+++ wysiwyg.module	24 Jan 2009 19:54:00 -0000
@@ -470,7 +470,7 @@ function wysiwyg_user($type, &$edit, &$u
 function wysiwyg_user_get_status($profile) {
   global $user;
 
-  if ($profile->settings['user_choose'] && isset($user->wysiwyg_status)) {
+  if (!empty($profile->settings['user_choose']) && isset($user->wysiwyg_status)) {
     $status = $user->wysiwyg_status;
   }
   else {
Index: editors/fckeditor.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/fckeditor.inc,v
retrieving revision 1.6.2.1
diff -u -p -r1.6.2.1 fckeditor.inc
--- editors/fckeditor.inc	21 Jan 2009 15:49:42 -0000	1.6.2.1
+++ editors/fckeditor.inc	24 Jan 2009 23:03:59 -0000
@@ -1,25 +1,24 @@
 <?php
 // $Id: fckeditor.inc,v 1.6.2.1 2009/01/21 15:49:42 sun Exp $
 
+/**
+ * @file
+ * Editor integration functions for FCKeditor.
+ */
+
 
 /**
  * Plugin implementation of hook_editor().
- *
- * - Function signature and returned editor name nust match include filename.
- * - Returns an array of supported editor versions along with support files.
- *
- * @todo wysiwyg_<editor>_alter() to add/inject optional libraries like gzip.
  */
 function wysiwyg_fckeditor_editor() {
   $editor = array();
   $editor['fckeditor'] = array(
-    // Required properties
     'title' => 'FCKeditor',
     'vendor url' => 'http://www.fckeditor.net',
     'download url' => 'http://www.fckeditor.net/download',
     'library path' => wysiwyg_get_path('fckeditor'),
-    'libraries' => array( // We cannot assume that all editors need just one js library.
-      '' => array( // Key may be used in wysiwyg_fckeditor_settings() for exec mode.
+    'libraries' => array(
+      '' => array(
         'title' => 'Default',
         'files' => array('fckeditor.js'),
       ),
@@ -28,19 +27,11 @@ function wysiwyg_fckeditor_editor() {
     'themes callback' => 'wysiwyg_fckeditor_themes',
     'settings callback' => 'wysiwyg_fckeditor_settings',
     'plugin callback' => 'wysiwyg_fckeditor_plugins',
-    'plugin settings callback' => 'wysiwyg_fckeditor_plugin_settings',
-    'versions' => array( // Each version can override global editor properties.
+    'versions' => array(
       2.6 => array(
-        // 'include files' => array('fckeditor-2.inc'),
         'js files' => array('fckeditor-2.6.js'),
       ),
     ),
-    // Optional properties
-    // 'editor path' => wysiwyg_get_path('fckeditor'),
-    // 'js path' => wysiwyg_get_path('js'),
-    // 'css path' => wysiwyg_get_path('css'),
-    // @todo Not yet implemented.
-    // 'css files' => array('fckeditor.css'),
   );
   return $editor;
 }
@@ -57,12 +48,15 @@ function wysiwyg_fckeditor_editor() {
 function wysiwyg_fckeditor_version($editor) {
   $library = $editor['library path'] .'/fckeditor.js';
   $library = fopen($library, 'r');
-  while ($line = fgets($library, 60)) {
+  $max_lines = 100;
+  while ($max_lines && $line = fgets($library, 60)) {
     if (preg_match('@^FCKeditor.prototype.Version\s*= \'([\d\.]+)@', $line, $version)) {
       fclose($library);
       return $version[1];
     }
+    $max_lines--;
   }
+  fclose($library);
 }
 
 /**
@@ -80,9 +74,10 @@ function wysiwyg_fckeditor_version($edit
  *   Drupal.settings.wysiwyg.configs.{editor}
  */
 function wysiwyg_fckeditor_settings($editor, $config, $theme) {
-  $init = array(
-    'EditorPath' => base_path() . $editor['editor path'] .'/',
-    'SkinPath' => base_path() . $editor['editor path'] .'/editor/skins/default/',
+  $settings = array(
+    'EditorPath' => base_path() . $editor['library path'] .'/',
+    'CustomConfigurationsPath' => wysiwyg_get_path('editors/js/fckeditor.config.js', TRUE),
+    'SkinPath' => base_path() . $editor['library path'] .'/editor/skins/default/',
     'Width' => '100%',
     'Height' => 420,
     'DefaultLanguage' => 'en',
@@ -98,28 +93,55 @@ function wysiwyg_fckeditor_settings($edi
     'FlashUpload' => FALSE,
   );
   if (isset($config['block_formats'])) {
-    $init['FontFormats'] = strtr($config['block_formats'], array(',' => ';'));
+    $settings['FontFormats'] = strtr($config['block_formats'], array(',' => ';'));
   }
   if (isset($config['apply_source_formatting'])) {
-    $init['FormatSource'] = $config['apply_source_formatting'];
+    $settings['FormatSource'] = $config['apply_source_formatting'];
   }
   if (isset($config['preformatted'])) {
-    $init['FormatOutput'] = $config['preformatted'];
+    $settings['FormatOutput'] = $config['preformatted'];
   }
 
   if (isset($config['css_setting'])) {
     if ($config['css_setting'] == 'theme') {
       $css = path_to_theme() .'/style.css';
       if (file_exists($css)) {
-        $init['EditorAreaCSS'] = base_path() . $css;
+        $settings['EditorAreaCSS'] = base_path() . $css;
       }
     }
     else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
-      $init['EditorAreaCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
+      $settings['EditorAreaCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
     }
   }
 
-  return $init;
+  $plugins = wysiwyg_get_plugins($editor['name']);
+  if (!empty($config['buttons'])) {
+    // Use our custom toolbar set (for FCKinstance).
+    $settings['ToolbarSet'] = 'Wysiwyg';
+    // Populate our custom toolbar set for fckeditor.config.js.
+    $settings['buttons'] = array();
+    foreach ($config['buttons'] as $plugin => $buttons) {
+      foreach ($buttons as $button => $enabled) {
+        // Iterate separately over buttons and extensions properties.
+        foreach (array('buttons', 'extensions') as $type) {
+          // Skip unavailable plugins.
+          if (!isset($plugins[$plugin][$type][$button])) {
+            continue;
+          }
+          // Add buttons.
+          if ($type == 'buttons') {
+            $settings['buttons'][] = $button;
+          }
+        }
+      }
+    }
+    // For now, all buttons are placed into one row.
+    if (!empty($settings['buttons'])) {
+      $settings['buttons'] = array($settings['buttons']);
+    }
+  }
+
+  return $settings;
 }
 
 /**
@@ -139,21 +161,44 @@ function wysiwyg_fckeditor_themes($edito
 }
 
 /**
- * Build a JS settings array of external plugins that need to be loaded separately.
- *
- * TinyMCE requires that external plugins (i.e. not residing in the editor's
- * directory) are loaded (once) after the editor has been initialized.
- */
-function wysiwyg_fckeditor_plugin_settings($editor, $profile, $info) {
-  $plugins = array();
-  return $plugins;
-}
-
-/**
  * Return internal plugins for FCKeditor; semi-implementation of hook_wysiwyg_plugin().
  */
 function wysiwyg_fckeditor_plugins($editor) {
   return array(
+    'default' => array(
+      'buttons' => array(
+        'Bold' => t('Bold'), 'Italic' => t('Italic'), 'Underline' => t('Underline'),
+        'StrikeThrough' => t('Strike-through'),
+        'JustifyLeft' => t('Align left'), 'JustifyCenter' => t('Align center'), 'JustifyRight' => t('Align right'), 'JustifyFull' => t('Justify'),
+        'UnorderedList' => t('Bullet list'), 'OrderedList' => t('Numbered list'),
+        'Outdent' => t('Outdent'), 'Indent' => t('Indent'),
+        'Undo' => t('Undo'), 'Redo' => t('Redo'),
+        'Link' => t('Link'), 'Unlink' => t('Unlink'), 'Anchor' => t('Anchor'),
+        'Image' => t('Image'),
+        'TextColor' => t('Forecolor'), 'BGColor' => t('Backcolor'),
+        'Superscript' => t('Superscript'), 'Subscript' => t('Subscript'),
+        'Blockquote' => t('Blockquote'), 'Source' => t('Source code'),
+        'Rule' => t('Horizontal rule'),
+        'Cut' => t('Cut'), 'Copy' => t('Copy'), 'Paste' => t('Paste'),
+        'PasteText' => t('Paste Text'), 'PasteWord' => t('Paste from Word'),
+        'ShowBlocks' => t('Visual aid'),
+        'RemoveFormat' => t('Remove format'),
+        'SpecialChar' => t('Character map'),
+        'About' => t('About'),
+
+        'FontFormat' => t('HTML block format'), 'FontName' => t('Font'), 'FontSize' => t('Font size'), 'Style' => t('Font style'),
+        'Table' => t('Table'),
+        'Find' => t('Search'), 'Replace' => t('Replace'), 'SelectAll' => t('Select all'),
+        'CreateDiv' => t('CreateDiv'),
+        'Flash' => t('Flash'), 'Smiley' => t('Smiley'),
+        'FitWindow' => t('FitWindow'),
+        'SpellCheck' => t('SpellCheck'),
+        // Useless in Drupal.
+        // 'DocProps' => t('DocProps'), 'Save' => t('Save'), 'NewPage' => t('NewPage'), 'Preview' => t('Preview'), 'Templates' => t('Templates'),
+        // 'Form' => t('Form'), 'Checkbox' => t('Checkbox'), 'Radio' => t('Radio'), 'TextField' => t('TextField'), 'Textarea' => t('Textarea'), 'Select' => t('Select'), 'Button' => t('Button'), 'ImageButton' => t('ImageButton'), 'HiddenField' => t('HiddenField'),
+      ),
+      'internal' => TRUE,
+    ),
   );
 }
 
Index: editors/js/fckeditor-2.6.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/fckeditor-2.6.js,v
retrieving revision 1.8.2.1
diff -u -p -r1.8.2.1 fckeditor-2.6.js
--- editors/js/fckeditor-2.6.js	21 Jan 2009 15:49:42 -0000	1.8.2.1
+++ editors/js/fckeditor-2.6.js	24 Jan 2009 23:10:49 -0000
@@ -2,13 +2,18 @@
 
 /**
  * Attach this editor to a target element.
- *
- * See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook.
  */
 Drupal.wysiwyg.editor.attach.fckeditor = function(context, params, settings) {
   var FCKinstance = new FCKeditor(params.field, settings['Width'], settings['Height']);
-  // Configure editor settings for this input format.
+  // Apply editor instance settings.
   FCKinstance.BasePath = settings.EditorPath;
+  // Apply 'Wysiwyg' toolbar, if defined.
+  if (settings.buttons) {
+    FCKinstance.ToolbarSet = settings.ToolbarSet;
+  }
+
+  // Apply input format configuration.
+  FCKinstance.Config.format = params.format;
   for (var setting in settings) {
     FCKinstance.Config[setting] = settings[setting];
   }
@@ -18,8 +23,6 @@ Drupal.wysiwyg.editor.attach.fckeditor =
 
 /**
  * Detach a single or all editors.
- *
- * See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook.
  */
 Drupal.wysiwyg.editor.detach.fckeditor = function(context, params) {
   if (typeof params != 'undefined' && typeof FCKeditorAPI != 'undefined') {
@@ -31,9 +34,13 @@ Drupal.wysiwyg.editor.detach.fckeditor =
       delete FCKeditorAPI.__Instances[params.field];
     }
   }
-//  else {
-//    tinyMCE.triggerSave();
-//    tinyMCE.remove();
-//  }
+  else {
+    for (instance in FCKeditorAPI.__Instances) {
+      $('#' + instance).val(editor.GetXHTML()).show();
+      $('#' + instance + '___Config').remove();
+      $('#' + instance + '___Frame').remove();
+      delete FCKeditorAPI.__Instances[instance];
+    }
+  }
 };
 
Index: editors/js/fckeditor.config.js
===================================================================
RCS file: editors/js/fckeditor.config.js
diff -N editors/js/fckeditor.config.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ editors/js/fckeditor.config.js	24 Jan 2009 23:08:21 -0000
@@ -0,0 +1,10 @@
+// $Id$
+
+/**
+ * Apply custom Wysiwyg API toolbar for input format.
+ *
+ * For whatever reason, our custom 'format' property is not available in
+ * FCKConfig.format, but in FCKConfig.PageConfig.format instead.
+ */
+FCKConfig.ToolbarSets['Wysiwyg'] = window.parent.Drupal.settings.wysiwyg.configs.fckeditor[FCKConfig.PageConfig.format].buttons;
+
