diff -u b/core/modules/aggregator/aggregator.admin.inc b/core/modules/aggregator/aggregator.admin.inc --- b/core/modules/aggregator/aggregator.admin.inc +++ b/core/modules/aggregator/aggregator.admin.inc @@ -429,6 +429,8 @@ * @ingroup forms */ function aggregator_admin_form($form, &$form_state) { + $form['#config'] = config('aggregator.settings'); + // Global aggregator settings. $form['aggregator_allowed_html_tags'] = array( '#type' => 'textfield', @@ -522,7 +524,6 @@ // Implementing modules will expect an array at $form['modules']. $form['modules'] = array(); - $form['#config'] = config('aggregator.settings'); return system_config_form($form, $form_state); } diff -u b/core/modules/aggregator/aggregator.processor.inc b/core/modules/aggregator/aggregator.processor.inc --- b/core/modules/aggregator/aggregator.processor.inc +++ b/core/modules/aggregator/aggregator.processor.inc @@ -70,8 +70,7 @@ * separate from aggregator API functionality. */ function aggregator_form_aggregator_admin_form_alter(&$form, $form_state) { - $config = config('aggregator.settings'); - $aggregator_processors = $config->get('processors'); + $aggregator_processors = $form['#config']->get('processors'); if (in_array('aggregator', $aggregator_processors)) { $info = module_invoke('aggregator', 'aggregator_process', 'info'); $items = drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items'); reverted: --- b/core/modules/book/book.module +++ a/core/modules/book/book.module @@ -342,15 +342,22 @@ '#type' => 'radios', '#title' => t('Book navigation block display'), '#options' => $options, + '#default_value' => config('book.settings')->get('block.navigation.mode'), - '#load' => 'config', - '#config' => config('book.settings'), - '#config_key' => 'block.navigation.mode', '#description' => t("If Show block on all pages is selected, the block will contain the automatically generated menus for all of the site's books. If Show block only on book pages is selected, the block will contain only the one menu corresponding to the current page's book. In this case, if the current page is not in a book, no block will be displayed. The Page specific visibility settings or other visibility settings can be used in addition to selectively display this block."), + ); + - ); return $form; } /** + * Implements hook_block_save(). + */ +function book_block_save($delta = '', $edit = array()) { + $block = array(); + config('book.settings')->set('block.navigation.mode', $edit['book_block_mode'])->save(); +} + +/** * Returns HTML for a link to a book title when used as a block title. * * @param $variables diff -u b/core/modules/contact/contact.module b/core/modules/contact/contact.module --- b/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -257,17 +257,5 @@ '#load' => 'config', + '#config' => config('contact.settings'), '#config_key' => 'user_default_enabled', ); - // Add submit handler to save contact configuration. - $form['#submit'][] = 'contact_form_user_admin_settings_submit'; -} - -/** - * Form submission handler for user_admin_settings(). - * - * @see contact_form_user_admin_settings_alter() - */ -function contact_form_user_admin_settings_submit($form, &$form_state) { - config('contact.settings') - ->set('user_default_enabled', $form_state['values']['contact_default_status']) - ->save(); } diff -u b/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module --- b/core/modules/dblog/dblog.module +++ b/core/modules/dblog/dblog.module @@ -170,21 +170,11 @@ '#type' => 'select', '#title' => t('Database log messages to keep'), '#load' => 'config', + '#config' => config('dblog.settings'), '#config_key' => 'row_limit', '#options' => array(0 => t('All')) + drupal_map_assoc(array(100, 1000, 10000, 100000, 1000000)), '#description' => t('The maximum number of messages to keep in the database log. Requires a cron maintenance task.', array('@cron' => url('admin/reports/status'))) ); - - $form['#submit'][] = 'dblog_logging_settings_submit'; -} - -/** - * Form submission handler for system_logging_settings(). - * - * @see dblog_form_system_logging_settings_alter() - */ -function dblog_logging_settings_submit($form, &$form_state) { - config('dblog.settings')->set('row_limit', $form_state['values']['dblog_row_limit'])->save(); } /** diff -u b/core/modules/forum/forum.admin.inc b/core/modules/forum/forum.admin.inc --- b/core/modules/forum/forum.admin.inc +++ b/core/modules/forum/forum.admin.inc @@ -237,7 +237,7 @@ * @ingroup forms */ function forum_admin_settings($form, &$form_state) { - $config = config('forum.settings'); + $form['#config'] = config('forum.settings'); $number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500)); $form['forum_hot_topic'] = array('#type' => 'select', '#title' => t('Hot topic threshold'), @@ -265,18 +265,6 @@ return system_config_form($form, $form_state); } - -/** - * Form submission handler for forum_admin_settings(). - */ -function forum_admin_settings_submit($form, &$form_state) { - config('forum.settings') - ->set('topics.hot_threshold', $form_state['values']['forum_hot_topic']) - ->set('topics.page_limit', $form_state['values']['forum_per_page']) - ->set('topics.order', $form_state['values']['forum_order']) - ->save(); -} - /** * Form constructor for the forum overview form. * reverted: --- b/core/modules/forum/forum.module +++ a/core/modules/forum/forum.module @@ -663,8 +663,7 @@ $form['block_num_' . $delta] = array( '#type' => 'select', '#title' => t('Number of topics'), + '#default_value' => config('forum.settings')->get('block.num_' . $delta), - '#load' => 'config', - '#config_key' => 'block.num_' . $delta, '#options' => drupal_map_assoc(range(2, 20)), ); return $form; diff -u b/core/modules/menu/menu.admin.inc b/core/modules/menu/menu.admin.inc --- b/core/modules/menu/menu.admin.inc +++ b/core/modules/menu/menu.admin.inc @@ -690,19 +690,20 @@ * @see menu_configure_submit() */ function menu_configure($form, &$form_state) { - $config = config('menu.settings'); + $form['#config'] = config('menu.settings'); $form['intro'] = array( '#type' => 'item', '#markup' => t('The menu module allows on-the-fly creation of menu links in the content authoring forms. To configure these settings for a particular content type, visit the Content types page, click the edit link for the content type, and go to the Menu settings section.', array('@content-types' => url('admin/structure/types'))), ); $menu_options = menu_get_menus(); + $main = $form['#config']->get('main_links'); - $main = $config->get('main_links'); $form['menu_main_links_source'] = array( '#type' => 'select', '#title' => t('Source for the Main links'), - '#default_value' => $main, + '#load' => 'config', + '#config_key' => 'main_links', '#empty_option' => t('No Main links'), '#options' => $menu_options, '#tree' => FALSE, @@ -725,10 +725,0 @@ - -/** - * Form submission handler for menu_configure(). - */ -function menu_configure_submit($form, &$form_state) { - config('menu.settings') - ->set('main_links', $form_state['values']['menu_main_links_source']) - ->set('secondary_links', $form_state['values']['menu_secondary_links_source']) - ->save(); -} reverted: --- b/core/modules/search/search.admin.inc +++ a/core/modules/search/search.admin.inc @@ -75,8 +75,7 @@ $form['indexing_throttle']['cron_limit'] = array( '#type' => 'select', '#title' => t('Number of items to index per cron run'), + '#default_value' => $config->get('index.cron_limit'), - '#load' => 'config', - '#config_key' => 'index.cron_limit', '#options' => $items, '#description' => t('The maximum number of items indexed in each pass of a cron maintenance task. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status'))) ); @@ -91,8 +90,7 @@ $form['indexing_settings']['minimum_word_size'] = array( '#type' => 'number', '#title' => t('Minimum word length to index'), + '#default_value' => $config->get('index.minimum_word_size'), - '#load' => 'config', - '#config_key' => 'index.minimum_word_size', '#min' => 1, '#max' => 1000, '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).') @@ -100,8 +98,7 @@ $form['indexing_settings']['overlap_cjk'] = array( '#type' => 'checkbox', '#title' => t('Simple CJK handling'), + '#default_value' => $config->get('index.overlap_cjk'), - '#load' => 'config', - '#config_key' => 'index.overlap_cjk', '#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.') ); @@ -114,16 +111,14 @@ '#type' => 'checkboxes', '#title' => t('Active modules'), '#title_display' => 'invisible', + '#default_value' => $config->get('active_modules'), - '#load' => 'config', - '#config_key' => 'active_modules', '#options' => $module_options, '#description' => t('Choose which search modules are active from the available modules.') ); $form['active']['default_module'] = array( '#title' => t('Default search module'), '#type' => 'radios', + '#default_value' => $config->get('default_module'), - '#load' => 'config', - '#config_key' => 'default_module', '#options' => $module_options, '#description' => t('Choose which search module is the default.') ); diff -u b/core/modules/statistics/statistics.admin.inc b/core/modules/statistics/statistics.admin.inc --- b/core/modules/statistics/statistics.admin.inc +++ b/core/modules/statistics/statistics.admin.inc @@ -285,7 +285,7 @@ * @see statistics_settings_form_submit(). */ function statistics_settings_form($form, &$form_state) { - $config = config('statistics.settings'); + $form['#config'] = config('statistics.settings'); // Access log settings. $form['access'] = array( '#type' => 'fieldset', @@ -325,11 +324,0 @@ - -/** - * Form submission handler for statistics_settings_form(). - */ -function statistics_settings_form_submit($form, &$form_state) { - config('statistics.settings') - ->set('access_log.enabled', $form_state['values']['statistics_enable_access_log']) - ->set('access_log.max_lifetime', $form_state['values']['statistics_flush_accesslog_timer']) - ->set('count_content_views', $form_state['values']['statistics_count_content_views']) - ->save(); -} reverted: --- b/core/modules/statistics/statistics.module +++ a/core/modules/statistics/statistics.module @@ -325,33 +325,9 @@ $config = config('statistics.settings'); // Popular content block settings $numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40)); + $form['statistics_block_popular_top_day_limit'] = array('#type' => 'select', '#title' => t("Number of day's top views to display"), '#default_value' => $config->get('block.popular.top_day_limit'), '#options' => $numbers, '#description' => t('How many content items to display in "day" list.')); + $form['statistics_block_popular_top_all_limit'] = array('#type' => 'select', '#title' => t('Number of all time views to display'), '#default_value' => $config->get('block.popular.top_all_limit'), '#options' => $numbers, '#description' => t('How many content items to display in "all time" list.')); + $form['statistics_block_popular_top_recent_limit'] = array('#type' => 'select', '#title' => t('Number of most recent views to display'), '#default_value' => $config->get('block.popular.top_recent_limit'), '#options' => $numbers, '#description' => t('How many content items to display in "recently viewed" list.')); - $form['statistics_block_popular_top_day_limit'] = array( - '#type' => 'select', - '#title' => t("Number of day's top views to display"), - '#load' => 'config', - '#config' => $config, - '#config_key' => 'block.popular.top_day_limit', - '#options' => $numbers, - '#description' => t('How many content items to display in "day" list.'), - ); - $form['statistics_block_popular_top_all_limit'] = array( - '#type' => 'select', - '#title' => t('Number of all time views to display'), - '#load' => 'config', - '#config' => $config, - '#config_key' => 'block.popular.top_all_limit', - '#options' => $numbers, - '#description' => t('How many content items to display in "all time" list.'), - ); - $form['statistics_block_popular_top_recent_limit'] = array( - '#type' => 'select', - '#title' => t('Number of most recent views to display'), - '#load' => 'config', - '#config' => $config, - '#config_key' => 'block.popular.top_recent_limit', - '#options' => $numbers, - '#description' => t('How many content items to display in "recently viewed" list.'), - ); return $form; } diff -u b/core/modules/syslog/syslog.module b/core/modules/syslog/syslog.module --- b/core/modules/syslog/syslog.module +++ b/core/modules/syslog/syslog.module @@ -51,6 +51,7 @@ '#type' => 'textfield', '#title' => t('Syslog identity'), '#load' => 'config', + '#config' => $config, '#config_key' => 'identity', '#description' => t('A string that will be prepended to every message logged to Syslog. If you have multiple sites logging to the same Syslog log file, a unique identity per site makes it easy to tell the log entries apart.') . $help, ); @@ -59,6 +60,7 @@ '#type' => 'select', '#title' => t('Syslog facility'), '#load' => 'config', + '#config' => $config, '#config_key' => 'facility', '#options' => syslog_facility_list(), '#description' => t('Depending on the system configuration, Syslog and other logging tools use this code to identify or filter messages from within the entire system log.') . $help, @@ -68,27 +70,13 @@ '#type' => 'textarea', '#title' => t('Syslog format'), '#load' => 'config', + '#config' => $config, '#config_key' => 'format', '#description' => t('Specify the format of the syslog entry. Available variables are:
!base_url
Base URL of the site.
!timestamp
Unix timestamp of the log entry.
!type
The category to which this message belongs.
!ip
IP address of the user triggering the message.
!request_uri
The requested URI.
!referer
HTTP Referer if available.
!uid
User ID.
!link
A link to associate with the message.
!message
The message to store in the log.
'), ); - - $form['#submit'][] = 'syslog_logging_settings_submit'; } /** - * Form submission handler for system_logging_settings(). - * - * @see syslog_form_system_logging_settings_alter() - */ -function syslog_logging_settings_submit($form, &$form_state) { - config('syslog.settings') - ->set('identity', $form_state['values']['syslog_identity']) - ->set('facility', $form_state['values']['syslog_facility']) - ->set('format', $form_state['values']['syslog_format']) - ->save(); -} - - /** * Lists all possible syslog facilities for UNIX/Linux. * * @return array diff -u b/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc --- b/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1591,6 +1591,8 @@ * @ingroup forms */ function system_cron_settings($form, &$form_state) { + $form['#config'] = config('system.cron'); + $form['description'] = array( '#markup' => '

' . t('Cron takes care of running periodic tasks like checking for updates and indexing content for search.') . '

', ); @@ -1615,7 +1617,6 @@ '#config_key' => 'threshold.autorun', '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'), ); - $form['#config'] = config('system.cron'); return system_config_form($form, $form_state); } @@ -1644,6 +1645,8 @@ * @see system_logging_settings_submit() */ function system_logging_settings($form, &$form_state) { + $form['#config'] = config('system.logging'); + $form['error_level'] = array( '#type' => 'radios', '#title' => t('Error messages to display'), @@ -1657,7 +1660,6 @@ ), '#description' => t('It is recommended that sites running on production environments do not display any errors.'), ); - $form['#config'] = config('system.logging'); return system_config_form($form, $form_state); } @@ -1870,12 +1872,12 @@ * @ingroup forms */ function system_rss_feeds_settings($form, &$form_state) { - $rss_config = config('system.rss'); + $form['#config'] = config('system.rss'); + $form['feed_description'] = array( '#type' => 'textarea', '#title' => t('Feed description'), '#load' => 'config', - '#config' => $rss_config, '#config_key' => 'channel.description', '#description' => t('Description of your site, included in each feed.') ); @@ -1883,7 +1885,6 @@ '#type' => 'select', '#title' => t('Number of items in each feed'), '#load' => 'config', - '#config' => $rss_config, '#config_key' => 'items.limit', '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), '#description' => t('Default number of items to include in each feed.') @@ -1892,7 +1893,6 @@ '#type' => 'select', '#title' => t('Feed content'), '#load' => 'config', - '#config' => $rss_config, '#config_key' => 'items.view_mode', '#options' => array( 'title' => t('Titles only'), @@ -1906,19 +1906,6 @@ } /** - * Form builder submit handler; Handle submission for RSS feeds settings. - * - * @ingroup forms - */ -function system_rss_feeds_settings_submit($form, &$form_state) { - config('system.rss') - ->set('channel.description', $form_state['values']['feed_description']) - ->set('items.limit', $form_state['values']['feed_default_items']) - ->set('items.view_mode', $form_state['values']['feed_item_length']) - ->save(); -} - -/** * Form builder; Configure the site regional settings. * * @ingroup forms @@ -2217,7 +2204,7 @@ * @see system_site_maintenance_mode_submit() */ function system_site_maintenance_mode($form, &$form_state) { - $config = config('system.maintenance'); + $form['#config'] = config('system.maintenance'); $form['maintenance_mode'] = array( '#type' => 'checkbox', '#title' => t('Put site into maintenance mode'), @@ -2236,18 +2223,6 @@ } /** - * Form submission handler for system_site_maintenance_mode(). - * - * @ingroup forms - */ -function system_site_maintenance_mode_submit($form, &$form_state) { - config('system.maintenance') - ->set('enabled', $form_state['values']['maintenance_mode']) - ->set('message', $form_state['values']['maintenance_mode_message']) - ->save(); -} - -/** * Menu callback: displays the site status report. Can also be used as a pure check. * * @param $check diff -u b/core/modules/system/system.module b/core/modules/system/system.module --- b/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -3191,13 +3191,6 @@ if (!isset($form['#theme'])) { $form['#theme'] = 'system_settings_form'; } - $config = isset($form['#config']) ? $form['#config'] : NULL; - $form_state['callbacks']['load']['config'] = function ($element) use ($config) { - if (isset($element['#config'])) { - $config = $element['#config']; - } - return $config->get($element['#config_key']); - }; return $form; } @@ -3242,6 +3235,14 @@ * http://drupal.org/node/1324618. */ function system_config_form($form, &$form_state) { + $config = isset($form['#config']) ? $form['#config'] : NULL; + $form_state['callbacks']['load']['config'] = function ($element) use ($config) { + if (isset($element['#config'])) { + $config = $element['#config']; + } + return $config->get($element['#config_key']); + }; + $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = array( '#type' => 'submit', diff -u b/core/modules/update/update.settings.inc b/core/modules/update/update.settings.inc --- b/core/modules/update/update.settings.inc +++ b/core/modules/update/update.settings.inc @@ -33,12 +33,11 @@ '#config_key' => 'check.disabled_extensions', ); - $notification_emails = $config->get('notification.emails'); $form['update_notify_emails'] = array( '#type' => 'textarea', '#title' => t('E-mail addresses to notify when updates are available'), '#rows' => 4, - '#default_value' => implode("\n", $notification_emails), + '#default_value' => implode("\n", $form['#config']->get('notification.emails')), '#description' => t('Whenever your site checks for available updates and finds new releases, it can notify a list of users via e-mail. Put each address on a separate line. If blank, no e-mails will be sent.'), ); @@ -113,2 +112,6 @@ } + + $config + ->set('notification.emails', $form_state['notify_emails']) + ->save(); }