Common subdirectories: wysiwyg/editors and wysiwyg_features/editors
Common subdirectories: wysiwyg/plugins and wysiwyg_features/plugins
Common subdirectories: wysiwyg/translations and wysiwyg_features/translations
diff -upN wysiwyg/wysiwyg.admin.inc wysiwyg_features/wysiwyg.admin.inc
--- wysiwyg/wysiwyg.admin.inc	2009-06-08 17:18:11.000000000 -0700
+++ wysiwyg_features/wysiwyg.admin.inc	2010-01-05 12:23:31.000000000 -0800
@@ -413,6 +413,8 @@ function wysiwyg_profile_overview() {
 
   $formats = filter_formats();
   $profiles = wysiwyg_profile_load_all();
+
+
   $form['formats']['#tree'] = TRUE;
   foreach ($formats as $id => $format) {
     $form['formats'][$id]['name'] = array(
@@ -429,6 +431,9 @@ function wysiwyg_profile_overview() {
       $form['formats'][$id]['edit'] = array(
         '#value' => l(t('Edit'), "admin/settings/wysiwyg/profile/$id/edit"),
       );
+      $form['formats'][$id]['export'] = array(
+        '#value' => l(t('Export'), "admin/settings/wysiwyg/profile/$id/export"),
+      );
       $form['formats'][$id]['remove'] = array(
         '#value' => l(t('Remove'), "admin/settings/wysiwyg/profile/$id/delete"),
       );
@@ -455,6 +460,7 @@ function theme_wysiwyg_profile_overview(
       drupal_render($format['name']),
       drupal_render($format['editor']),
       isset($format['edit']) ? drupal_render($format['edit']) : '',
+      isset($format['export']) ? drupal_render($format['export']) : '',
       isset($format['remove']) ? drupal_render($format['remove']) : '',
     );
   }
@@ -509,3 +515,76 @@ function wysiwyg_profile_delete($format)
   db_query("DELETE FROM {wysiwyg} WHERE format = %d", $format);
 }
 
+/**
+* Import a format setting.
+*/
+function wysiwyg_import_format(&$form_state) {
+
+  $form['wysiwyg'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Paste wysiwyg settings code here:'),
+    '#required' => TRUE,
+  );
+
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Import'),
+    '#submit' => array('wysiwyg_import_submit'),
+    '#validate' => array('wysiwyg_import_validate'),
+  );
+
+  return $form;
+}
+
+/**
+ * Validate that the pasted in code works.
+ */
+function wysiwyg_import_validate( ) {
+  $wysiwyg = '';
+// Put any necessary includes here
+  ob_start();
+  eval($form_state['values']['wysiwyg']);
+  ob_end_clean();
+
+  if (!is_object($wysiwyg)) {
+    return form_error($form['wysiwyg'], t('Unable to interpret view code.'));
+  }
+  if (empty($wysiwyg->api_version) || $wysiwyg->api_version < 2) {
+    form_error($form['wysiwyg'], t('That wysiwyg format setting is not compatible with this version of the wysiwyg module.'));
+  }
+
+  // Refuse any settings that already exist for that format type
+  $settings_count = db_result(db_query("SELECT count(*) FROM {wysiwyg} WHERE format = %d", $wysiwyg->format));
+  if( $settings_count >= 1 ) {
+    form_error( $form['wysiwyg'], t('Wysiwyg settings already exist for that input format type. Please delete the existing settings and attempt the import again if you wish to replace the existing settings.'));
+  }  
+
+}
+
+/**
+ * Submit handler for wysiwyg settings import
+ */
+function wysiwyg_import_submit($form, &$form_state) {
+  // Check to see if the setting exits (should have been caught by validation hook above); if so give an error; 
+  // else write the format settings to the database and then redirect the user to the edit page
+  $wysiwyg = '';
+  eval($form_state['values']['wysiwyg']);
+
+  $settings_count = db_result(db_query("SELECT count(*) FROM {wysiwyg} WHERE format = %d", $wysiwyg->format));
+  if( $settings_count >= 1 ) {
+    drupal_set_message( t("Settings for that format input type already existed; your import was not used and nothing was done.  Please delete the existing wysiwyg format settings for that input type and import again."), "error");
+    return;
+  }
+
+  // Write the settings to the database
+  $dwr_ret = drupal_write_record( "wysiwyg", $wysiwyg );
+ 
+  if ( $dwr_ret == FALSE ) { 
+    drupal_set_message( t("An error occurred when writing the settings to the database.") , "error");
+    return ;
+  }
+
+  $form_state['redirect'] = 'admin/settings/wysiwyg/profile/'. $wysiwyg->format .'/edit';
+
+}
+
diff -upN wysiwyg/wysiwyg.features.inc wysiwyg_features/wysiwyg.features.inc
--- wysiwyg/wysiwyg.features.inc	1969-12-31 16:00:00.000000000 -0800
+++ wysiwyg_features/wysiwyg.features.inc	2009-12-16 09:01:40.000000000 -0800
@@ -0,0 +1,2 @@
+<?php
+
diff -upN wysiwyg/wysiwyg.install wysiwyg_features/wysiwyg.install
--- wysiwyg/wysiwyg.install	2009-06-08 14:57:10.000000000 -0700
+++ wysiwyg_features/wysiwyg.install	2009-12-13 01:48:21.000000000 -0800
@@ -8,6 +8,17 @@ function wysiwyg_schema() {
   $schema = array();
   $schema['wysiwyg'] = array(
     'description' => t('Stores Wysiwyg profiles.'),
+    'export' =>  array(
+      'key' => 'format',
+      'identifier' => 'wysiwyg',
+      'default hook' => 'default_wysiwyg_format',  // Function hook name.
+      'api' => array(
+        'owner' => 'wysiwyg',
+        'api' => 'default_wysiwyg_format',  // Base name for api include files.
+        'minimum_version' => 2,
+        'current_version' => 2,
+      ),
+    ),
     'fields' => array(
       'format' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
       'editor' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
diff -upN wysiwyg/wysiwyg.module wysiwyg_features/wysiwyg.module
--- wysiwyg/wysiwyg.module	2009-06-08 17:18:11.000000000 -0700
+++ wysiwyg_features/wysiwyg.module	2010-01-05 12:27:18.000000000 -0800
@@ -50,6 +50,21 @@ function wysiwyg_menu() {
     'type' => MENU_CALLBACK,
     'file' => 'wysiwyg.dialog.inc',
   );
+  $items['admin/settings/wysiwyg/profile/%/export'] = array(
+    'title' => 'Export',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('wysiwyg_export_format', 4),
+    'access arguments' => array('administer filters'),
+    'type' => MENU_CALLBACK,
+  ); 
+  $items['admin/settings/wysiwyg/import'] = array(
+    'title' => 'Import',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('wysiwyg_import_format', 3),
+    'access arguments' => array('administer filters'),
+    'file' => 'wysiwyg.admin.inc',
+    'type' => MENU_LOCAL_TASK,
+  ); 
   return $items;
 }
 
@@ -572,6 +587,17 @@ function wysiwyg_profile_load($format) {
       $profile->settings = unserialize($profile->settings);
       $profiles[$profile->format] = $profile;
     }
+
+    // For features integration: call each module's hook_wysiwyg_defaults if they have it,
+    // and if the settings for that format type don't already exist from being read from 
+    // the database above, put them in the array.
+    $default_profiles = module_invoke_all('default_wysiwyg_format');
+    foreach( $default_profiles as $def_prof ) {
+      if (!isset($profiles) || !array_key_exists( $def_prof->format, $profiles )) {
+        $def_prof->settings = unserialize($def_prof->settings);
+	$profiles[$def_prof->format] = $def_prof;
+      }
+    }
   }
 
   return (isset($profiles[$format]) ? $profiles[$format] : FALSE);
@@ -590,6 +616,17 @@ function wysiwyg_profile_load_all() {
       $profile->settings = unserialize($profile->settings);
       $profiles[$profile->format] = $profile;
     }
+
+    // For features integration: call each module's hook_wysiwyg_defaults if they have it,
+    // and if the settings for that format type don't already exist from being read from 
+    // the database above, put them in the array.
+    $default_profiles = module_invoke_all('default_wysiwyg_format');
+    foreach( $default_profiles as $def_prof ) {
+      if (!array_key_exists( $def_prof->format, $profiles )) {
+        $def_prof->settings = unserialize($def_prof->settings);
+	$profiles[$def_prof->format] = $def_prof;
+      }
+    }
   }
 
   return $profiles;
@@ -949,6 +986,61 @@ function _wysiwyg_process_include($modul
 }
 
 /**
+* Export a format setting and display it in a form.
+*/
+function wysiwyg_export_format(&$form_state, $format) {
+  $obj = wysiwyg_format_load($format);
+
+  drupal_set_title(check_plain($obj->format));
+  $code = wysiwyg_format_export($obj);
+  $lines = substr_count($code, "\n");
+
+ 
+  $form['export'] = array(
+    '#title' => t('Export data'),
+    '#type' => 'textarea',
+    '#value' => $code,
+    '#rows' => $lines,
+    '#description' => t('Copy the export text and paste it into another wysiwyg format using the import function.'),
+  );
+  return $form;
+}
+
+/**
+* Load a single format setting.
+*/
+function wysiwyg_format_load($format) {
+  ctools_include('export');
+  $result = ctools_export_load_object('wysiwyg', 'names', array($format));
+  if (isset($result[$format])) {
+    return $result[$format];
+  }
+}
+
+/**
+* Export wysiwyg settings.
+*/
+function wysiwyg_format_export($obj, $indent = '') {
+  ctools_include('export');
+  $output = ctools_export_object('wysiwyg', $obj, $indent);
+  return $output;
+}
+
+/**
+ * Features hook
+ */
+function wysiwyg_features_api() {
+  return array( 
+    'wysiwyg' => array( 
+      'default_hook' => 'default_wysiwyg_format',
+      'default_file' => FEATURES_DEFAULTS_INCLUDED,
+      'features_source' => TRUE,
+      'file' => drupal_get_path('module', 'wysiwyg') .'/wysiwyg.features.inc',
+    ), 
+  );
+}
+
+/**
  * @} End of "defgroup wysiwyg_api".
  */
 
