Index: www/sites/all/modules/contrib/better_formats/better_formats.module
===================================================================
--- www/sites/all/modules/contrib/better_formats/better_formats.module	(revision 54859)
+++ www/sites/all/modules/contrib/better_formats/better_formats.module	(revision 54963)
@@ -86,6 +86,23 @@
 }
 
 /**
+ * Implementation of hook_features_api().
+ *
+ * Allow exporting of Better formats profiles by the Features module
+ */
+function better_formats_features_api() {
+  return array(
+    'better_formats' => array(
+      'name' => t('Better formats'),
+      'file' => drupal_get_path('module', 'better_formats') .'/better_formats.features.inc',
+      'default_hook' => 'better_formats_default',
+      'default_file' => FEATURES_DEFAULTS_INCLUDED,
+      'features_source' => TRUE,
+    ),
+  );
+}
+
+/**
  * Implementation of hook_form_alter().
  */
 function better_formats_form_alter(&$form, $form_state, $form_id) {
Index: www/sites/all/modules/contrib/better_formats/better_formats.features.inc
===================================================================
--- www/sites/all/modules/contrib/better_formats/better_formats.features.inc	(revision 0)
+++ www/sites/all/modules/contrib/better_formats/better_formats.features.inc	(revision 54963)
@@ -0,0 +1,128 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Contains hooks for features api.
+ */
+
+require_once('better_formats_defaults.admin.inc');
+
+/**
+ * Implementation of hook_features_export_options().
+ *
+ */
+function better_formats_features_export_options() {
+  $options = array();
+  
+  // Get the node type names
+  $type_names = node_get_types('names');
+  
+  // Get format data
+  $sql = 'SELECT DISTINCT type FROM {better_formats_defaults}
+          ORDER BY type_weight';
+  $result = db_query($sql);
+  
+  while ($better_type = db_result($result)) {
+    
+    // Get node name for node type specific defaults (e.g., node/page)
+    $type = explode('/', $better_type);
+    if (count($type) > 1) {
+      $type_name = $type_names[$type[1]] . ' ';
+    } else {
+      $type_name = '';
+    }
+    
+    switch ($type[0]) {
+      case 'node':
+        $option = t('Node Defaults');
+        break;
+      case 'comment':
+        $option = t('Comment Defaults');
+        break;
+      case 'block':
+        $option = t('Block Defaults');
+        break;
+      default:
+        $option = $better_type;
+    }
+    
+    $options[$better_type] = $type_name . $option;
+    
+  }
+  
+  return $options;
+  
+}
+
+/**
+ * Implementation of hook_features_export()
+ */
+function better_formats_features_export($data, &$export, $module_name = '') {
+  $pipe = array();
+
+  // Get format data
+  $sql = 'SELECT bf.*, role.name
+          FROM {better_formats_defaults} AS bf
+          INNER JOIN {role} AS role ON bf.rid = role.rid';
+  $result = db_query($sql);
+  
+  while ($role = db_fetch_object($result)) {
+    if (in_array($role->type, (array) $export['features']['better_formats'])) {
+      continue;
+    }
+    
+    if (in_array($role->type, $data)) {
+      $export['features']['better_formats'][$role->type] = $role->type;
+    }
+  }
+  
+  $export['dependencies'][] = 'better_formats';
+  return $pipe;
+}
+
+/**
+ * Implementation of hook_features_export_render().
+ */
+function better_formats_features_export_render($module, $data, $export = NULL) {
+  
+  module_load_include('inc', 'features', 'features.export');
+  $code = array();
+  $code[] = '  $defaults = array();';
+  $code[] = '';
+
+  foreach ($data as $name) {
+    $result = db_query("SELECT * FROM {better_formats_defaults} WHERE type = '%s'", $name);
+    while ($row = db_fetch_array($result)) {
+      $code[] = "  \$defaults['{$name}/{$row['rid']}'] = " . features_var_export($row, '  ') . ';';
+    }
+    $code[] = '';
+  }
+  $code[] = '  return $defaults;';
+  $code = implode("\n", $code);
+  
+  return array('better_formats_default' => $code);
+  
+}
+
+/**
+ * Implementation of hook_features_export_revert().
+ */
+function better_formats_features_revert($module) {
+  better_formats_features_rebuild($module);
+}
+
+/**
+ * Implementation of hook_features_export_rebuild().
+ */
+function better_formats_features_rebuild($module) {
+  $defaults = module_invoke($module, 'better_formats_default');
+  if (!empty($defaults)) {
+    foreach ($defaults as $default) {
+      db_query("UPDATE {better_formats_defaults} SET rid = %d, type = '%s', format = %d, type_weight = %d, weight = %d WHERE rid = %d AND type = '%s'", $default['rid'], $default['type'], $default['format'], $default['type_weight'], $default['weight'], $default['rid'], $default['type']);
+      if (!db_affected_rows()) {
+        db_query("INSERT INTO {better_formats_defaults} (rid, type, format, type_weight, weight) VALUES (%d, '%s', %d, %d, %d)", $default['rid'], $default['type'], $default['format'], $default['type_weight'], $default['weight']);
+      }
+    }
+  }
+}
