# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /var/www/drupal/html/sites/all/modules/contrib/better_formats # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: better_formats.features.inc --- better_formats.features.inc Locally New +++ better_formats.features.inc Locally New @@ -0,0 +1,117 @@ +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) { + // @todo - without this there is an undefined function features_var_export(). + module_load_include('inc', 'features', 'features.export'); + $code = array(); + $code[] = ' $defaults = array();'; + $code[] = ''; + + $result = db_query("SELECT * FROM {better_formats_defaults}"); + while ($row = db_fetch_array($result)) { + $code[] = ' $defaults[] = '. 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']); + } + } + } +} Index: better_formats.module --- better_formats.module Base (BASE) +++ better_formats.module Locally Modified (Based On LOCAL) @@ -132,6 +132,22 @@ } /** + * 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'), + 'default_hook' => 'better_formats_default', + 'features_source' => TRUE, + 'file' => drupal_get_path('module', 'better_formats') .'/better_formats.features.inc', + ), + ); +} + +/** * FAPI form to add to the content type edit form. * * @see better_formats_node_type_form_validate()