=== modified file 'includes/form.inc' --- includes/form.inc +++ includes/form.inc @@ -58,10 +58,18 @@ function element_children($element) { * An optional callback that will be used in addition to the form_id. * */ -function drupal_get_form($form_id, &$form, $callback = NULL) { +function drupal_get_form($form_definition_id, $arguments = array(), $form_id = NULL) { global $form_values, $form_submitted, $user, $form_button_counter; static $saved_globals = array(); + $forms = module_invoke_all('forms'); + $form_definition = $forms[$form_definition_id]; + $form = call_user_func_array($form_definition['callback'], $arguments); + $callback = isset($form_definition['form_callback']) ? $form_definition['form_callback'] : ''; + if (!isset($form_id)) { + $form_id = $form_definition_id; + } + // Save globals in case of indirect recursive call array_push($saved_globals, array($form_values, $form_submitted, $form_button_counter)); === modified file 'modules/system/system.module' --- modules/system/system.module +++ modules/system/system.module @@ -140,42 +140,56 @@ function system_menu($may_cache) { 'path' => 'admin/build/themes', 'title' => t('themes'), 'description' => t('Change which theme your site uses or allows users to set.'), - 'callback' => 'system_themes', 'access' => $access); + 'callback' => 'drupal_get_form', + 'callback arguments' => array('system_themes'), + 'access' => $access); $items[] = array( 'path' => 'admin/build/themes/select', 'title' => t('list'), 'description' => t('Select the default theme.'), - 'callback' => 'system_themes', + 'callback' => 'drupal_get_form', + 'callback arguments' => array('system_themes'), 'access' => $access, 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1); $items[] = array('path' => 'admin/build/themes/settings', 'title' => t('configure'), - 'callback' => 'system_theme_settings', + 'callback' => 'drupal_get_form', + 'callback arguments' => array('system_theme_settings'), 'access' => $access, 'type' => MENU_LOCAL_TASK); // Theme configuration subtabs - $items[] = array('path' => 'admin/build/themes/settings/global', 'title' => t('global settings'), - 'callback' => 'system_theme_settings', 'access' => $access, + $items[] = array( + 'path' => 'admin/build/themes/settings/global', + 'title' => t('global settings'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('system_theme_settings'), + 'access' => $access, 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1); foreach (list_themes() as $theme) { if ($theme->status) { - $items[] = array('path' => 'admin/build/themes/settings/'. $theme->name, 'title' => $theme->name, - 'callback' => 'system_theme_settings', 'callback arguments' => array($theme->name), 'access' => $access, + $items[] = array( + 'path' => 'admin/build/themes/settings/'. $theme->name, + 'title' => $theme->name, + 'callback' => 'drupal_get_form', + 'callback arguments' => array('system_theme_settings', array($theme->name)), + 'access' => $access, 'type' => MENU_LOCAL_TASK); } } // Modules: - $items[] = array('path' => 'admin/settings/modules', + $items[] = array( + 'path' => 'admin/settings/modules', 'title' => t('modules'), 'description' => t('Enable or disable add-on modules for your site.'), 'weight' => -10, - 'callback' => 'system_modules', + 'callback' => 'drupal_get_form', + 'callback arguments' => array('system_modules'), 'access' => $access); // Settings: @@ -359,7 +373,7 @@ function system_admin_theme_settings() { $form['#submit']['system_admin_theme_submit'] = array(); $form['#submit']['system_settings_form_submit'] = array(); - return system_settings_form('system_admin_theme_form', $form); + return drupal_get_form('system_settings_form', array($form), 'system_admin_theme_form'); } @@ -496,7 +510,7 @@ function system_site_information_setting '#description' => t('The home page displays content from this relative URL. If you are not using clean URLs, specify the part after "?q=". If unsure, specify "node".') ); - return system_settings_form('system_site_information_settings', $form); + return drupal_get_form('system_settings_form', array($form), 'system_site_information_settings'); } function system_clean_url_settings() { @@ -520,7 +534,7 @@ function system_clean_url_settings() { } } - return system_settings_form('system_clean_url_settings', $form); + return drupal_get_form('system_settings_form', array($form), 'system_clean_url_settings'); } function system_error_reporting_settings() { @@ -555,7 +569,7 @@ function system_error_reporting_settings '#description' => t('The time log entries should be kept. Older entries will be automatically discarded. Requires crontab.') ); - return system_settings_form('system_error_reporting_settings', $form); + return drupal_get_form('system_settings_form', array($form), 'system_error_reporting_settings'); } function system_page_caching_settings() { @@ -578,7 +592,7 @@ function system_page_caching_settings() '#description' => t('Enabling the cache will offer a sufficient performance boost for most low-traffic and medium-traffic sites. On high-traffic sites it can become necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will go by before the cache is emptied and recreated. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.') ); - return system_settings_form('system_page_caching_settings', $form); + return drupal_get_form('system_settings_form', array($form), 'system_page_caching_settings'); } function system_file_system_settings() { @@ -609,7 +623,7 @@ function system_file_system_settings() { '#description' => t('If you want any sort of access control on the downloading of files, this needs to be set to private. You can change this at any time, however all download URLs will change and there may be unexpected problems so it is not recommended.') ); - return system_settings_form('system_file_system_settings', $form); + return drupal_get_form('system_settings_form', array($form), 'system_file_system_settings'); } function system_image_toolkit_settings() { @@ -622,7 +636,7 @@ function system_image_toolkit_settings() '#options' => $toolkits_available ); - return system_settings_form('system_image_toolkit_settings', $form); + return drupal_get_form('system_settings_form', array($form), 'system_image_toolkit_settings'); } else { return '

'. t("No image toolkits found. Drupal will use PHP's built-in GD library for image handling.") .'

'; @@ -646,7 +660,7 @@ function system_rss_feeds_settings() { '#description' => t('Global setting for the length of XML feed items that are output by default.') ); - return system_settings_form('system_rss_feeds_settings', $form); + return drupal_get_form('system_settings_form', array($form), 'system_rss_feeds_settings'); } function system_date_time_settings() { @@ -724,7 +738,7 @@ function system_date_time_settings() { '#description' => t('The first day of the week for calendar views.') ); - return system_settings_form('system_date_time_settings', $form); + return drupal_get_form('system_settings_form', array($form), 'system_date_time_settings'); } function system_site_status_settings() { @@ -744,11 +758,11 @@ function system_site_status_settings() { '#description' => t('Message to show visitors when the site is in off-line mode.') ); - return system_settings_form('system_site_status_settings', $form); + return drupal_get_form('system_settings_form', array($form), 'system_site_status_settings'); } function system_unicode_settings() { - return system_settings_form('system_unicode_settings', unicode_settings()); + return drupal_get_form('system_settings_form', array($form), 'system_unicode_settings'); } function system_cron_status() { @@ -1006,7 +1020,7 @@ function system_initialize_theme_blocks( } // Add the submit / reset buttons and run drupal_get_form() -function system_settings_form($form_id, $form) { +function system_settings_form($form) { $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') ); $form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') ); @@ -1014,7 +1028,7 @@ function system_settings_form($form_id, drupal_set_message(t('The settings have not been saved because of the errors.'), 'error'); } - return drupal_get_form($form_id, $form, 'system_settings_form'); + return $form; } function system_theme_settings_submit($form_id, $values) { @@ -1098,7 +1112,7 @@ function system_themes() { $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') ); $form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') ); - return drupal_get_form('system_themes', $form); + return $form; } function theme_system_themes($form) { @@ -1197,7 +1211,7 @@ function system_modules() { $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); - return drupal_get_form('system_modules', $form); + return $form; } function theme_system_modules($form) { @@ -1467,8 +1481,7 @@ function system_theme_settings($key = '' } $form['#attributes'] = array('enctype' => 'multipart/form-data'); - return system_settings_form('system_theme_settings', $form); - + return drupal_get_form('system_settings_form', array($form), 'system_theme_settings'); } /** @@ -1514,7 +1527,7 @@ function confirm_form($form_id, $form, $ $form['actions'] = array('#prefix' => '
', '#suffix' => '
'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $yes ? $yes : t('Confirm')); $form['actions']['cancel'] = array('#value' => l($no ? $no : t('Cancel'), $path)); - return drupal_get_form($form_id, $form, 'confirm_form'); + return $form; } /** @@ -1627,3 +1640,24 @@ function theme_admin_block_content($cont } return $output; } + + +function system_forms() { + $form = array( + 'system_settings_form' => array( + 'form_callback' => 'system_settings_form', + 'callback' => 'system_settings_form', + ), + 'system_themes' => array( + 'callback' => 'system_themes', + ), + 'system_modules' => array( + 'callback' => 'system_modules', + ), + 'system_theme_settings' => array( + 'form_callback' => 'confirm_form', + 'callback' => 'system_theme_settings', + ), + ); + return $form; +}