diff --git a/weight.features.inc b/weight.features.inc new file mode 100644 index 0000000000000000000000000000000000000000..d5961780670319005193d0d7e146cdc7761a4a76 --- /dev/null +++ b/weight.features.inc @@ -0,0 +1,61 @@ + $code); +} + +/** + * Implements hook_features_revert(). + */ +function weight_features_revert($module) { + weight_features_rebuild($module); +} + +/** + * Implements hook_features_rebuild(). + */ +function weight_features_rebuild($module) { + if ($settings = features_get_default('weight', $module)) { + weight_settings_save($settings); + } +} diff --git a/weight.install b/weight.install index c9d0f248b1cd111e0369b3d1f057ea243ec466f7..d02891ffe9a45f4d06965884e1d602e4fc639d45 100644 --- a/weight.install +++ b/weight.install @@ -6,19 +6,6 @@ function weight_schema() { $schema['weight_settings'] = array( 'description' => 'Table for storing Weight configuration', - 'export' => array( - 'key' => 'type', - 'key name' => 'Type', - 'primary key' => 'type', - 'identifier' => 'settings', - 'export type string' => 'export_type', - 'api' => array( - 'owner' => 'weight', - 'api' => 'weight', - 'minimum_version' => 1, - 'current_version' => 1, - ), - ), 'fields' => array( 'id' => array( 'description' => 'The primary identifier for a content type configuration', diff --git a/weight.module b/weight.module index 2e4d5f9215dcf102279825d27592ad8c304165ba..076d7ab1fd075748168e09ee2a3ba825bd43513e 100644 --- a/weight.module +++ b/weight.module @@ -374,6 +374,20 @@ function weight_menu_link_update($link) { _weight_set_weight_from_menu_link($link); } +/** + * Implements hook_features_api(). + */ +function weight_features_api() { + return array( + 'weight' => array( + 'name' => 'Weight', + 'file' => drupal_get_path('module', 'weight') . '/weight.features.inc', + 'default_hook' => 'weight_features_default_settings', + 'feature_source' => TRUE, + ), + ); +} + /** * Implements hook_views_api(). */ @@ -438,6 +452,25 @@ function weight_apachesolr_query_prepare($query) { )); } +/** + * Saves Weight settings for a node type. + */ +function weight_settings_save($settings) { + foreach ($settings as $type => $setting) { + db_merge('weight_settings') + ->key(array('type' => $type)) + ->fields(array( + 'type' => $type, + 'weight_enabled' => $setting['enabled'], + 'weight_range' => $setting['range'], + 'menu_weight' => $setting['menu_weight'], + 'weight_default' => $setting['default'], + 'sync_translations' => $setting['sync_translations'], + )) + ->execute(); + } +} + /** * Set the weight of a node. */