=== modified file 'includes/form.inc' --- includes/form.inc +++ includes/form.inc @@ -4,59 +4,140 @@ /** * @defgroup form Form generation * @{ - * Functions to enable output of HTML forms and form elements. + * Functions to enable the processing and display of HTML forms. * - * Drupal uses these functions to achieve consistency in its form presentation, - * while at the same time simplifying code and reducing the amount of HTML that - * must be explicitly generated by modules. See the reference at + * Drupal uses these functions to achieve consistency in its form processing and, + * presentation., while simplifying code and reducing the amount of HTML that + * must be explicitly generated by modules. + * + * The drupal_get_form() function handles retrieving, processing, and + * displaying a rendered HTML form for modules automatically. For example: + * + * // display the user registration form + * $output = drupal_get_form('user_register'); + * + * Forms can also be built and submitted programmatically without any user input + * by populating $form['#post']['edit'] with values to be submitted. For example: + * + * // register a new user + * $form = drupal_retrieve_form('user_register'); + * $form['#post']['edit']['name'] = 'robo-user'; + * $form['#post']['edit']['mail'] = 'robouser@example.com'; + * $form['#post']['edit']['pass'] = 'password'; + * drupal_process_form('user_register', $form); + * + * Calling form_get_errors() will list any validation errors that prevented the + * form from being submitted. + * + * For information on the format of the structured arrays used to define forms, + * and more detailed explanations of the Form API workflow, see the reference at * http://api.drupal.org/api/HEAD/file/developer/topics/forms_api_reference.html * and the quickstart guide at * http://api.drupal.org/api/HEAD/file/developer/topics/forms_api.html */ /** - * Processes a form array and produces the HTML output of a form. - * If there is input in the $_POST['edit'] variable, this function - * will attempt to validate it, using drupal_validate_form(), - * and then submit the form using drupal_submit_form(). + * Retrieves a form from a handler function, then passes it on for + * processing and rendering. * * @param $form_id - * A unique string identifying the form. Allows each form to be - * themed. Pass NULL to suppress the form_id parameter (produces - * a shorter URL with method=get) + * The unique string identifying the desired form. If a function + * with that name exists, it is called to build the form array. + * Modules that need to generate the same form (or very similar forms) + * using different $form_ids can implement hook_forms(), which maps + * different $form_id values to the proper form building function. Example uses + * may be found at node_forms(), search_forms(), and user_forms(). + * @param ... + * Any additional arguments needed by the form building function. + * @return + * The rendered form. + */ +function drupal_get_form($form_id) { + $args = func_get_args(); + $form = call_user_func_array('drupal_retrieve_form', $args); + return drupal_process_form($form_id, $form); +} + +/** + * Retrieves the structured array that defines a given form. + * + * @param $form_id + * The unique string identifying the desired form. If a function + * with that name exists, it is called to build the form array. + * Modules that need to generate the same form (or very similar forms) + * using different $form_ids can implement hook_forms(), which maps + * different $form_id values to the proper form building function. + * @param ... + * Any additional arguments needed by the form building function. + */ +function drupal_retrieve_form($form_id) { + static $forms; + + $args = func_get_args(); + array_shift($args); + if (!function_exists($form_id)) { + if (!isset($forms)) { + $forms = module_invoke_all('forms'); + } + $form_definition = $forms[$form_id]; + if (isset($form_definition['callback arguments'])) { + $args = array_merge($form_definition['callback arguments'], $args); + } + if (isset($form_definition['callback'])) { + $callback = $form_definition['callback']; + } + } + // $callback comes from a hook_forms() implementation + return call_user_func_array(isset($callback) ? $callback : $form_id, $args); +} + +/** + * This function is the heart of form API. The form gets built, validated and in + * appropriate cases, submitted or rendered. + * + * @param $form_id + * The unique string identifying the current form. * @param $form * An associative array containing the structure of the form. - * @param $callback - * An optional callback that will be used in addition to the form_id. - * */ -function drupal_get_form($form_id, &$form, $callback = NULL) { +function drupal_process_form($form_id, &$form) { global $form_values, $form_submitted, $user, $form_button_counter; static $saved_globals = array(); - - // Save globals in case of indirect recursive call + // In some scenerios, this function can be called recursively. Pushing any pre-existing + // $form_values and form submission data lets us start fresh without clobbering work done + // in earlier recursive calls. array_push($saved_globals, array($form_values, $form_submitted, $form_button_counter)); $form_values = array(); $form_submitted = FALSE; $form_button_counter = array(0, 0); - $form = drupal_build_form($form_id, $form, $callback); - - if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $callback))) { - drupal_validate_form($form_id, $form, $callback); + drupal_prepare_form($form_id, $form); + if (($form['#programmed']) || (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $form['#base'])))) { + drupal_validate_form($form_id, $form); // IE does not send a button value when there is only one submit button (and no non-submit buttons) // and you submit by pressing enter. // In that case we accept a submission without button values. - if (($form_submitted || (!$form_button_counter[0] && $form_button_counter[1])) && !form_get_errors()) { - $redirect = drupal_submit_form($form_id, $form, $callback); + if ((($form['#programmed']) || $form_submitted || (!$form_button_counter[0] && $form_button_counter[1])) && !form_get_errors()) { + $redirect = drupal_submit_form($form_id, $form); + } + } + + // If the form is being directly submitted via PHP code rather than + // via a web browser, don't bother doing redirection or rendering it + // to HTML. + if (!$form['#programmed']) { + if (isset($redirect)) { drupal_redirect_form($form, $redirect); } + $return = drupal_render_form($form_id, $form); + } + else { + $return = $redirect; } - $output = drupal_render_form($form_id, $form, $callback); list($form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals); - return $output; + return $return; } /** @@ -69,12 +150,25 @@ function drupal_get_form($form_id, &$for * theming, and hook_form_alter functions. * @param $form * An associative array containing the structure of the form. - * @param $callback - * An optional callback that will be used in addition to the form_id. - * */ -function drupal_build_form($form_id, &$form, $callback = NULL) { +function drupal_prepare_form($form_id, &$form) { $form['#type'] = 'form'; + + if (!isset($form['#post'])) { + $form['#post'] = $_POST; + $form['#programmed'] = FALSE; + } + else { + $form['#programmed'] = TRUE; + } + + // If $base is set, it is used in place of $form_id when constructing validation, + // submission, and theming functions. Useful for mapping many similar or duplicate + // forms with different $form_ids to the same processing functions. + if (isset($form['#base'])) { + $base = $form['#base']; + } + if (isset($form['#token'])) { // If the page cache is on and an anonymous user issues a GET request, // unset the token because the token in the cached page would not match, @@ -105,8 +199,8 @@ function drupal_build_form($form_id, &$f if (function_exists($form_id .'_validate')) { $form['#validate'] = array($form_id .'_validate' => array()); } - elseif (function_exists($callback .'_validate')) { - $form['#validate'] = array($callback .'_validate' => array()); + elseif (function_exists($base .'_validate')) { + $form['#validate'] = array($base .'_validate' => array()); } } @@ -116,8 +210,8 @@ function drupal_build_form($form_id, &$f // $form_values because it will change later $form['#submit'] = array($form_id .'_submit' => array()); } - elseif (function_exists($callback .'_submit')) { - $form['#submit'] = array($callback .'_submit' => array()); + elseif (function_exists($base .'_submit')) { + $form['#submit'] = array($base .'_submit' => array()); } } @@ -127,8 +221,6 @@ function drupal_build_form($form_id, &$f } $form = form_builder($form_id, $form); - - return $form; } @@ -141,11 +233,9 @@ function drupal_build_form($form_id, &$f * theming, and hook_form_alter functions. * @param $form * An associative array containing the structure of the form. - * @param $callback - * An optional callback that will be used in addition to the form_id. * */ -function drupal_validate_form($form_id, $form, $callback = NULL) { +function drupal_validate_form($form_id, $form) { global $form_values; static $validated_forms = array(); @@ -153,7 +243,7 @@ function drupal_validate_form($form_id, return; } - // If the session token was set by drupal_build_form(), ensure that it + // If the session token was set by drupal_prepare_form(), ensure that it // matches the current user's session if (isset($form['#token'])) { if ($form_values['form_token'] != md5(session_id() . $form['#token'] . variable_get('drupal_private_key', ''))) { @@ -175,14 +265,12 @@ function drupal_validate_form($form_id, * theming, and hook_form_alter functions. * @param $form * An associative array containing the structure of the form. - * @param $callback - * An optional callback that will be used in addition to the form_id. * @return * A string containing the path of the page to display when processing * is complete. * */ -function drupal_submit_form($form_id, $form, $callback = NULL) { +function drupal_submit_form($form_id, $form) { global $form_values; $default_args = array($form_id, &$form_values); @@ -209,21 +297,23 @@ function drupal_submit_form($form_id, $f * theming, and hook_form_alter functions. * @param $form * An associative array containing the structure of the form. - * @param $callback - * An optional callback that will be used in addition to the form_id. * @return * A string containing the path of the page to display when processing * is complete. * */ -function drupal_render_form($form_id, &$form, $callback = NULL) { +function drupal_render_form($form_id, &$form) { // Don't override #theme if someone already set it. + if (isset($form['#base'])) { + $base = $form['#base']; + } + if (!isset($form['#theme'])) { if (theme_get_function($form_id)) { $form['#theme'] = $form_id; } - elseif (theme_get_function($callback)) { - $form['#theme'] = $callback; + elseif (theme_get_function($base)) { + $form['#theme'] = $base; } } @@ -408,8 +498,8 @@ function form_builder($form_id, $form) { $form['#id'] = 'edit-' . implode('-', $form['#parents']); } - $posted = (isset($_POST['edit']) && ($_POST['edit']['form_id'] == $form_id)); - $edit = $posted ? $_POST['edit'] : array(); + $posted = (($form['#programmed']) || (isset($_POST['edit']) && ($_POST['edit']['form_id'] == $form_id))); + $edit = $posted ? $form['#post']['edit'] : array(); foreach ($form['#parents'] as $parent) { $edit = isset($edit[$parent]) ? $edit[$parent] : NULL; } @@ -490,6 +580,8 @@ function form_builder($form_id, $form) { // Recurse through all child elements. $count = 0; foreach (element_children($form) as $key) { + $form[$key]['#post'] = $form['#post']; + $form[$key]['#programmed'] = $form['#programmed']; // don't squash an existing tree value if (!isset($form[$key]['#tree'])) { $form[$key]['#tree'] = $form['#tree']; @@ -769,7 +861,7 @@ function password_confirm_validate($form form_error($form, t('The specified passwords do not match.')); } } - elseif ($form['#required'] && !empty($_POST['edit'])) { + elseif ($form['#required'] && !empty($form['#post']['edit'])) { form_error($form, t('Password field is required.')); } === modified file 'includes/locale.inc' --- includes/locale.inc +++ includes/locale.inc @@ -75,8 +75,9 @@ function _locale_admin_manage_screen() { '#default_value' => $isdefault, ); $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); + $form['#base'] = 'locale_admin_manage_screen'; - return drupal_get_form('_locale_admin_manage_screen', $form, 'locale_admin_manage_screen'); + return $form; } /** @@ -123,12 +124,8 @@ function _locale_admin_manage_screen_sub return 'admin/settings/locale/language/overview'; } -/** - * User interface for the language addition screen. - */ -function _locale_admin_manage_add_screen() { +function locale_add_language_form() { $isocodes = _locale_prepare_iso_list(); - $form = array(); $form['language list'] = array('#type' => 'fieldset', '#title' => t('Language list'), @@ -141,9 +138,10 @@ function _locale_admin_manage_add_screen '#description' => t('Select your language here, or add it below, if you are unable to find it.'), ); $form['language list']['submit'] = array('#type' => 'submit', '#value' => t('Add language')); + return $form; +} - $output = drupal_get_form('locale_add_language_form', $form); - +function locale_custom_language_form() { $form = array(); $form['custom language'] = array('#type' => 'fieldset', '#title' => t('Custom language'), @@ -163,10 +161,17 @@ function _locale_admin_manage_add_screen '#description' => t('Name of the language. Will be available for translation in all languages.'), ); $form['custom language']['submit'] = array('#type' => 'submit', '#value' => t('Add custom language')); - // Use the validation and submit functions of the add language form. - $output .= drupal_get_form('locale_custom_language_form', $form, 'locale_add_language_form'); + $form['#base'] = 'locale_add_language_form'; + return $form; +} +/** + * User interface for the language addition screen. + */ +function _locale_admin_manage_add_screen() { + $output = drupal_get_form('locale_add_language_form'); + $output .= drupal_get_form('locale_custom_language_form'); return $output; } @@ -205,7 +210,7 @@ function locale_add_language_form_submit /** * User interface for the translation import screen. */ -function _locale_admin_import_screen() { +function _locale_admin_import() { $languages = locale_supported_languages(FALSE, TRUE); $languages = array_map('t', $languages['name']); unset($languages['en']); @@ -242,7 +247,7 @@ function _locale_admin_import_screen() { $form['import']['submit'] = array('#type' => 'submit', '#value' => t('Import')); $form['#attributes']['enctype'] = 'multipart/form-data'; - return drupal_get_form('_locale_admin_import', $form); + return $form; } /** @@ -267,6 +272,32 @@ function _locale_admin_import_submit($fo return 'admin/settings/locale'; } +function _locale_export_po_form() { + $form['export'] = array('#type' => 'fieldset', + '#title' => t('Export translation'), + '#collapsible' => TRUE, + ); + $form['export']['langcode'] = array('#type' => 'select', + '#title' => t('Language name'), + '#options' => $languages, + '#description' => t('Select the language you would like to export in gettext Portable Object (.po) format.'), + ); + $form['export']['submit'] = array('#type' => 'submit', '#value' => t('Export')); + return $form; +} + +function _locale_export_pot_form() { + // Complete template export of the strings + $form['export'] = array('#type' => 'fieldset', + '#title' => t('Export template'), + '#collapsible' => TRUE, + '#description' => t('Generate a gettext Portable Object Template (.pot) file with all the interface strings from the Drupal locale database.'), + ); + $form['export']['submit'] = array('#type' => 'submit', '#value' => t('Export')); + $form['#base'] = '_locale_export_po_form'; + return $form; +} + /** * User interface for the translation export screen */ @@ -275,31 +306,13 @@ function _locale_admin_export_screen() { $languages = array_map('t', $languages['name']); unset($languages['en']); + $output = ''; // Offer language specific export if any language is set up if (count($languages)) { - $form = array(); - $form['export'] = array('#type' => 'fieldset', - '#title' => t('Export translation'), - '#collapsible' => TRUE, - ); - $form['export']['langcode'] = array('#type' => 'select', - '#title' => t('Language name'), - '#options' => $languages, - '#description' => t('Select the language you would like to export in gettext Portable Object (.po) format.'), - ); - $form['export']['submit'] = array('#type' => 'submit', '#value' => t('Export')); - $output = drupal_get_form('_locale_export_po', $form); + $output = drupal_get_form('_locale_export_po_form'); } - // Complete template export of the strings - $form = array(); - $form['export'] = array('#type' => 'fieldset', - '#title' => t('Export template'), - '#collapsible' => TRUE, - '#description' => t('Generate a gettext Portable Object Template (.pot) file with all the interface strings from the Drupal locale database.'), - ); - $form['export']['submit'] = array('#type' => 'submit', '#value' => t('Export')); - $output .= drupal_get_form('_locale_export_pot', $form, '_locale_export_po'); + $output .= drupal_get_form('_locale_export_pot_form'); return $output; } @@ -307,7 +320,7 @@ function _locale_admin_export_screen() { /** * Process a locale export form submissions. */ -function _locale_export_po_submit($form_id, $form_values) { +function _locale_export_po_form_submit($form_id, $form_values) { _locale_export_po($form_values['langcode']); } @@ -346,7 +359,7 @@ function _locale_string_seek_form() { $form['search']['submit'] = array('#type' => 'submit', '#value' => t('Search')); $form['#redirect'] = FALSE; - return drupal_get_form('_locale_string_seek', $form); + return $form; } /** @@ -398,7 +411,7 @@ function _locale_string_edit($lid) { $form['lid'] = array('#type' => 'value', '#value' => $lid); $form['submit'] = array('#type' => 'submit', '#value' => t('Save translations')); - return drupal_get_form('_locale_string_edit', $form); + return $form; } /** @@ -1235,9 +1248,9 @@ function _locale_string_language_list($t * Build object out of search criteria specified in request variables */ function _locale_string_seek_query() { - static $query = NULL; - - if (is_null($query)) { + static $query; + + if (!isset($query)) { $fields = array('string', 'language', 'searchin'); $query = new StdClass; if (is_array($_REQUEST['edit'])) { === modified file 'includes/menu.inc' --- includes/menu.inc +++ includes/menu.inc @@ -382,6 +382,12 @@ function menu_set_location($location) { * here may, as a side effect, change the active menu item so that later * menu functions (that display the menus and breadcrumbs, for example) * act as if the user were in a different location on the site. + * + * If the handler returns raw text, it is assumed to be rendered HTML. + * If it returns an array, it is assumed to be a stuctured form + * definition array (e.g., a settings page or a content editing page) and + * drupal_process_form() is called to obtain the fully rendered HTML + * for the form. */ function menu_execute_active_handler() { if (_menu_site_is_offline()) { @@ -415,7 +421,13 @@ function menu_execute_active_handler() { $arguments = array_merge($arguments, explode('/', $arg)); } - return call_user_func_array($menu['callbacks'][$path]['callback'], $arguments); + $callback = $menu['callbacks'][$path]['callback']; + $return = call_user_func_array($callback, $arguments); + + if (is_array($return)) { + return drupal_process_form($callback, $return); + } + return $return; } /** === modified file 'install.php' --- install.php +++ install.php @@ -101,7 +101,7 @@ function install_verify_settings() { $db_path = ltrim(urldecode($url['path']), '/'); $settings_file = './'. conf_path() .'/settings.php'; - _install_settings_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_path, $settings_file); + _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_path, $settings_file); if (!form_get_errors()) { return TRUE; } @@ -124,13 +124,12 @@ function install_change_settings() { // We always need this because we want to run form_get_errors. include_once './includes/form.inc'; + drupal_maintenance_theme(); // The existing database settings are not working, so we need write access // to settings.php to change them. if (!drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_WRITABLE)) { - drupal_maintenance_theme(); drupal_set_message(st('The Drupal installer requires write permissions to %file during the installation process.', array('%file' => $settings_file)), 'error'); - drupal_set_title('Drupal database setup'); print theme('install_page', ''); exit; @@ -141,8 +140,18 @@ function install_change_settings() { $db_user = $db_pass = $db_path = ''; } + $output = drupal_get_form('install_settings_form', $profile, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host); + drupal_set_title('Database configuration'); + print theme('install_page', $output); + exit; +} + +/** + * Form API array definition for install_settings. + */ +function install_settings_form($profile, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host) { $db_types = drupal_detect_database_types(); if (count($db_types) == 0) { $form['no_db_types'] = array( @@ -251,26 +260,21 @@ function install_change_settings() { $form['_db_url'] = array('#type' => 'value'); $form['#action'] = "install.php?profile=$profile"; $form['#redirect'] = NULL; - drupal_maintenance_theme(); } - $output = drupal_get_form('install_settings', $form); - drupal_set_title('Database configuration'); - print theme('install_page', $output); - exit; + return $form; } - /** * Form API validate for install_settings form. */ -function install_settings_validate($form_id, $form_values, $form) { +function install_settings_form_validate($form_id, $form_values, $form) { global $db_url; - _install_settings_validate($form_values['db_prefix'], $form_values['db_type'], $form_values['db_user'], $form_values['db_pass'], $form_values['db_host'], $form_values['db_path'], $form_values['settings_file'], $form); + _install_settings_form_validate($form_values['db_prefix'], $form_values['db_type'], $form_values['db_user'], $form_values['db_pass'], $form_values['db_host'], $form_values['db_path'], $form_values['settings_file'], $form); } /** * Helper function for install_settings_validate. */ -function _install_settings_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_path, $settings_file, $form = NULL) { +function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_path, $settings_file, $form = NULL) { global $db_url; // Check for default username/password @@ -314,7 +318,7 @@ function _install_settings_validate($db_ /** * Form API submit for install_settings form. */ -function install_settings_submit($form_id, $form_values) { +function install_settings_form_submit($form_id, $form_values) { global $profile; // Update global settings array and save @@ -350,42 +354,46 @@ function install_select_profile() { return $profile->name; } elseif (sizeof($profiles) > 1) { - drupal_maintenance_theme(); - $form = ''; foreach ($profiles as $profile) { - include_once($profile->filename); if ($_POST['edit']['profile'] == $profile->name) { return $profile->name; } - // Load profile details. - $function = $profile->name .'_profile_details'; - if (function_exists($function)) { - $details = $function(); - } - - // If set, used defined name. Otherwise use file name. - $name = isset($details['name']) ? $details['name'] : $profile->name; - - $form['profile'][$name] = array( - '#type' => 'radio', - '#value' => 'default', - '#return_value' => $profile->name, - '#title' => $name, - '#description' => isset($details['description']) ? $details['description'] : '', - '#parents' => array('profile'), - ); } - $form['submit'] = array( - '#type' => 'submit', - '#value' => 'Save configuration', - ); + + drupal_maintenance_theme(); drupal_set_title('Select an installation profile'); - print theme('install_page', drupal_get_form('install_select_profile', $form)); + print theme('install_page', drupal_get_form('install_select_profile_form', $profiles)); exit; } } +function install_select_profile_form($profiles) { + foreach ($profiles as $profile) { + include_once($profile->filename); + // Load profile details. + $function = $profile->name .'_profile_details'; + if (function_exists($function)) { + $details = $function(); + } + // If set, used defined name. Otherwise use file name. + $name = isset($details['name']) ? $details['name'] : $profile->name; + $form['profile'][$name] = array( + '#type' => 'radio', + '#value' => 'default', + '#return_value' => $profile->name, + '#title' => $name, + '#description' => isset($details['description']) ? $details['description'] : '', + '#parents' => array('profile'), + ); + } + $form['submit'] = array( + '#type' => 'submit', + '#value' => 'Save configuration', + ); + return $form; +} + /** * Show an error page when there are no profiles available. */ === modified file 'modules/aggregator/aggregator.module' --- modules/aggregator/aggregator.module +++ modules/aggregator/aggregator.module @@ -170,9 +170,9 @@ function aggregator_menu($may_cache) { } } } - else if (arg(1) == 'aggregator' && is_numeric(arg(4))) { - if (arg(3) == 'feed') { - $feed = aggregator_get_feed(arg(4)); + else if (arg(2) == 'aggregator' && is_numeric(arg(5))) { + if (arg(4) == 'feed') { + $feed = aggregator_get_feed(arg(5)); if ($feed) { $items[] = array('path' => 'admin/content/aggregator/edit/feed/'. $feed['fid'], 'title' => t('edit feed'), @@ -183,7 +183,7 @@ function aggregator_menu($may_cache) { } } else { - $category = aggregator_get_category(arg(4)); + $category = aggregator_get_category(arg(5)); if ($category) { $items[] = array('path' => 'admin/content/aggregator/edit/category/'. $category['cid'], 'title' => t('edit category'), @@ -227,7 +227,7 @@ function aggregator_admin_settings() { '#description' => t('The type of category selection widget which is shown on categorization pages. Checkboxes are easier to use; a multiple selector is good for working with large numbers of categories.') ); - return system_settings_form('aggregator_admin_settings', $form); + return system_settings_form($form); } /** @@ -336,7 +336,7 @@ function aggregator_block($op, $delta = $form['cid'] = array('#type' => 'hidden', '#value' => $edit['cid']); } - return drupal_get_form('aggregator_form_category', $form); + return $form; } /** @@ -467,7 +467,7 @@ function aggregator_form_feed($edit = ar $form['fid'] = array('#type' => 'hidden', '#value' => $edit['fid']); } - return drupal_get_form('aggregator_form_feed', $form); + return $form; } /** @@ -1049,28 +1049,16 @@ function aggregator_page_category() { return _aggregator_page_list('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = '. $category->cid .' ORDER BY timestamp DESC, iid DESC', arg(3)); } -/** - * Prints an aggregator page listing a number of feed items. Various - * menu callbacks use this function to print their feeds. - */ -function _aggregator_page_list($sql, $op, $header = '') { - $categorize = (user_access('administer news feeds') && ($op == 'categorize')); - - $output = '
'; - +function aggregator_page_list($sql, $header, $categorize) { $form['header'] = array('#value' => $header); - $output .= $form['header']['#value']; - $result = pager_query($sql, 20); $categories = array(); $done = FALSE; + $form['items'] = array(); while ($item = db_fetch_object($result)) { $form['items'][$item->iid] = array('#value' => theme('aggregator_page_item', $item)); - $output .= $form['items'][$item->iid]['#value']; $form['categories'][$item->iid] = array(); - if ($categorize) { - $categories_result = db_query('SELECT c.cid, c.title, ci.iid FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid AND ci.iid = %d', $item->iid); $selected = array(); while ($category = db_fetch_object($categories_result)) { @@ -1089,11 +1077,8 @@ function _aggregator_page_list($sql, $op ); } } - $output .= '
'; $form['submit'] = array('#type' => 'submit', '#value' => t('Save categories')); $form['pager'] = array('#value' => theme('pager', NULL, 20, 0)); - $output .= $form['pager']['#value']; - // arg(1) is undefined if we are at the top aggregator URL // is there a better way to do this? if (!arg(1)) { @@ -1102,9 +1087,30 @@ function _aggregator_page_list($sql, $op elseif (arg(1) == 'categories' && arg(2) && !arg(3)) { $form['feed_icon'] = array('#value' => theme('feed_icon', url('aggregator/rss/' . arg(2)))); } - $output .= $form['feed_icon']['#value']; + return $form; +} - return ($categorize) ? drupal_get_form('aggregator_page_list', $form) : $output; +/** + * Prints an aggregator page listing a number of feed items. Various + * menu callbacks use this function to print their feeds. + */ +function _aggregator_page_list($sql, $op, $header = '') { + $categorize = (user_access('administer news feeds') && ($op == 'categorize')); + $form = drupal_retrieve_form('aggregator_page_list', $sql, $header, $categorize); + if ($categorize) { + return $form; + } + else { + $output = '
'; + $output .= $header; + foreach ($form['items'] as $item) { + $output .= $item['#value']; + } + $output .= '
'; + $output .= $form['pager']['#value']; + $output .= $form['feed_icon']['#value']; + return $output; + } } function theme_aggregator_page_list($form) { === modified file 'modules/block/block.module' --- modules/block/block.module +++ modules/block/block.module @@ -84,7 +84,7 @@ function block_menu($may_cache) { 'type' => MENU_CALLBACK); $items[] = array('path' => 'admin/build/block/add', 'title' => t('add block'), 'access' => user_access('administer blocks'), - 'callback' => 'block_box_add', + 'callback' => 'block_box_form', 'type' => MENU_LOCAL_TASK); foreach (list_themes() as $key => $theme) { if ($theme->status) { @@ -245,7 +245,7 @@ function block_admin_display($theme = NU } $form['submit'] = array('#type' => 'submit', '#value' => t('Save blocks')); - return drupal_get_form('block_admin_display', $form); + return $form; } /** @@ -468,7 +468,7 @@ function block_admin_configure($module = '#value' => t('Save block'), ); - return drupal_get_form('block_admin_configure', $form); + return $form; } function block_admin_configure_validate($form_id, $form_values) { @@ -493,23 +493,13 @@ function block_admin_configure_submit($f } } -/** - * Menu callback; displays the block creation form. - */ -function block_box_add() { - $form = block_box_form(); - $form['submit'] = array('#type' => 'submit', '#value' => t('Save block')); - - return drupal_get_form('block_box_add', $form); -} - -function block_box_add_validate($form_id, $form_values) { +function block_box_form_validate($form_id, $form_values) { if (empty($form_values['info']) || db_num_rows(db_query("SELECT info FROM {boxes} WHERE info = '%s'", $form_values['info']))) { form_set_error('info', t('Please ensure that each block description is unique.')); } } -function block_box_add_submit($form_id, $form_values) { +function block_box_form_submit($form_id, $form_values) { if (!form_get_errors()) { if (block_box_save($form_values)) { drupal_set_message(t('The block has been created.')); @@ -526,13 +516,13 @@ function block_box_delete($bid = 0) { $form['info'] = array('#type' => 'hidden', '#value' => $box['info'] ? $box['info'] : $box['title']); $form['bid'] = array('#type' => 'hidden', '#value' => $bid); - return confirm_form('block_box_delete_confirm', $form, t('Are you sure you want to delete the block %name?', array('%name' => theme('placeholder', $box['info']))), 'admin/build/block', '', t('Delete'), t('Cancel')); + return confirm_form($form, t('Are you sure you want to delete the block %name?', array('%name' => theme('placeholder', $box['info']))), 'admin/build/block', '', t('Delete'), t('Cancel')); } /** * Deletion of custom blocks. */ -function block_box_delete_confirm_submit($form_id, $form_values) { +function block_box_delete_submit($form_id, $form_values) { db_query('DELETE FROM {boxes} WHERE bid = %d', $form_values['bid']); drupal_set_message(t('The block %name has been removed.', array('%name' => theme('placeholder', $form_values['info'])))); cache_clear_all(); @@ -567,6 +557,7 @@ function block_box_form($edit = array()) '#weight' => -17, ); $form['body_filter']['format'] = filter_form($edit['format'], -16); + $form['submit'] = array('#type' => 'submit', '#value' => t('Save block')); return $form; } === modified file 'modules/blogapi/blogapi.module' --- modules/blogapi/blogapi.module +++ modules/blogapi/blogapi.module @@ -556,7 +556,7 @@ function blogapi_admin_settings() { '#description' => t('Select the content types for which you wish to enable posting via blogapi. Each type will appear as a different "blog" in the client application (if supported).') ); - return system_settings_form('blogapi_admin_settings', $form); + return system_settings_form($form); } function blogapi_menu($may_cache) { === modified file 'modules/book/book.module' --- modules/book/book.module +++ modules/book/book.module @@ -322,7 +322,7 @@ function book_outline($nid) { } drupal_set_title(check_plain($node->title)); - return drupal_get_form('book_outline', $form); + return $form; } /** @@ -889,7 +889,7 @@ function book_admin_edit($nid) { '#value' => t('Save book pages'), ); - return drupal_get_form('book_admin_edit', $form); + return $form; } else { drupal_not_found(); @@ -917,19 +917,18 @@ function book_admin_orphan() { } if (count($orphans)) { - $form = array(); - $form['table'] = _book_admin_table($orphans); $form['save'] = array( '#type' => 'submit', '#value' => t('Save book pages'), ); - return drupal_get_form('book_admin_edit', $form); } else { - return '

'. t('There are no orphan pages.') .'

'; + $form['error'] = array('#value' => '

'. t('There are no orphan pages.') .'

'); } + $form['#base'] = 'book_admin_edit'; + return $form; } function book_admin_edit_submit($form_id, $form_values) { === modified file 'modules/comment/comment.module' --- modules/comment/comment.module +++ modules/comment/comment.module @@ -466,7 +466,7 @@ function comment_admin_settings() { '#options' => array(t('Display on separate page'), t('Display below post or comments')), ); - return system_settings_form('comment_admin_settings', $form); + return system_settings_form($form); } /** @@ -496,7 +496,7 @@ function comment_edit($cid) { $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; if (comment_access('edit', $comment)) { - return comment_form((array)$comment); + return comment_form_box((array)$comment); } else { drupal_access_denied(); @@ -517,7 +517,7 @@ function comment_reply($nid, $pid = NULL if ($op == t('Preview comment')) { if (user_access('post comments')) { - $output .= comment_form(array('pid' => $pid, 'nid' => $nid), NULL); + $output .= comment_form_box(array('pid' => $pid, 'nid' => $nid), NULL); } else { drupal_set_message(t('You are not authorized to post comments.'), 'error'); @@ -553,7 +553,7 @@ function comment_reply($nid, $pid = NULL drupal_goto("node/$nid"); } else if (user_access('post comments')) { - $output .= comment_form(array('pid' => $pid, 'nid' => $nid), t('Reply')); + $output .= comment_form_box(array('pid' => $pid, 'nid' => $nid), t('Reply')); } else { drupal_set_message(t('You are not authorized to post comments.'), 'error'); @@ -891,7 +891,7 @@ function comment_render($node, $cid = 0) // Start a form, for use with comment control. $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args); if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) { - $output .= comment_controls($mode, $order, $comments_per_page); + $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page); } while ($comment = db_fetch_object($result)) { @@ -916,13 +916,13 @@ function comment_render($node, $cid = 0) $output .= theme('pager', NULL, $comments_per_page, 0); if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) { - $output .= comment_controls($mode, $order, $comments_per_page); + $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page); } } // If enabled, show new comment form. if (user_access('post comments') && node_comment_mode($nid) == COMMENT_NODE_READ_WRITE && (variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW)) { - $output .= comment_form(array('nid' => $nid), t('Post new comment')); + $output .= comment_form_box(array('nid' => $nid), t('Post new comment')); } $output = theme('comment_wrapper', $output); @@ -956,13 +956,7 @@ function comment_delete($cid) { drupal_goto("node/$comment->nid"); } else if (is_object($comment) && is_numeric($comment->cid)) { - $output = confirm_form('comment_confirm_delete', - array(), - t('Are you sure you want to delete the comment %title?', array('%title' => theme('placeholder', $comment->subject))), - 'node/'. $comment->nid, - t('Any replies to this comment will be lost. This action cannot be undone.'), - t('Delete'), - t('Cancel')); + $output = drupal_get_form('comment_confirm_delete', $subject, $nid); } else { drupal_set_message(t('The comment no longer exists.')); @@ -971,6 +965,16 @@ function comment_delete($cid) { return $output; } +function comment_confirm_delete($subject, $nid) { + return confirm_form( + array(), + t('Are you sure you want to delete the comment %title?', array('%title' => theme('placeholder', $subject))), + 'node/'. $nid, + t('Any replies to this comment will be lost. This action cannot be undone.'), + t('Delete'), + t('Cancel')); +} + /** * Comment operations. We offer different update operations depending on * which comment administration page we're on. @@ -1014,7 +1018,7 @@ function comment_admin_overview($type = '#prefix' => '
', '#suffix' => '
' ); $options = array(); - foreach (comment_operations(arg(3) == 'approval' ? 'publish' : 'unpublish') as $key => $value) { + foreach (comment_operations(arg(4) == 'approval' ? 'publish' : 'unpublish') as $key => $value) { $options[$key] = $value[0]; } $form['options']['operation'] = array('#type' => 'select', '#options' => $options, '#default_value' => 'publish'); @@ -1043,7 +1047,7 @@ function comment_admin_overview($type = } $form['comments'] = array('#type' => 'checkboxes', '#options' => $comments); $form['pager'] = array('#value' => theme('pager', NULL, 50, 0)); - return drupal_get_form('comment_admin_overview', $form); + return $form; } /** @@ -1136,7 +1140,7 @@ function comment_multiple_delete_confirm drupal_goto('admin/content/comment'); } else { - return confirm_form('comment_multiple_delete_confirm', $form, + return confirm_form($form, t('Are you sure you want to delete these comments and all their children?'), 'admin/content/comment', t('This action cannot be undone.'), t('Delete comments'), t('Cancel')); @@ -1421,8 +1425,11 @@ function comment_form($edit, $title = NU // Graft in extra form additions $form = array_merge($form, comment_invoke_comment($form, 'form')); + return $form; +} - return theme('box', $title, drupal_get_form('comment_form', $form)); +function comment_form_box($edit, $title = NULL) { + return theme('box', $title, drupal_get_form('comment_form', $edit, $title)); } function comment_form_add_preview($form, $edit) { @@ -1575,7 +1582,7 @@ function comment_controls($mode = COMMEN '#weight' => 20, ); - return drupal_get_form('comment_controls', $form); + return $form; } function theme_comment_controls($form) { @@ -1855,3 +1862,4 @@ function int2vancode($i = 0) { function vancode2int($c = '00') { return base_convert(substr($c, 1), 36, 10); } + === modified file 'modules/contact/contact.module' --- modules/contact/contact.module +++ modules/contact/contact.module @@ -90,7 +90,7 @@ function contact_menu($may_cache) { ); $items[] = array('path' => 'contact', 'title' => t('contact'), - 'callback' => 'contact_mail_page', + 'callback' => 'contact_site_page', 'access' => user_access('access site-wide contact form'), 'type' => MENU_SUGGESTED_ITEM, ); @@ -100,10 +100,9 @@ function contact_menu($may_cache) { global $user; $account = user_load(array('uid' => arg(1))); if (($user->uid != $account->uid && $account->contact) || user_access('administer users')) { - global $user; $items[] = array('path' => 'user/'. arg(1) .'/contact', 'title' => t('contact'), - 'callback' => 'contact_mail_user', + 'callback' => 'contact_user_page', 'type' => MENU_LOCAL_TASK, 'access' => ($user->uid && user_access('access personal contact forms')), 'weight' => 2, @@ -199,7 +198,7 @@ function contact_admin_edit($cid = NULL) '#value' => t('Submit'), ); - return drupal_get_form('contact_admin_edit', $form); + return $form; } /** @@ -260,7 +259,7 @@ function contact_admin_delete($cid = NUL '#value' => $info->category, ); - return confirm_form('contact_admin_delete', $form, t('Are you sure you want to delete %category?', array('%category' => theme('placeholder', $info->category))), 'admin/build/contact', t('This action cannot be undone.'), t('Delete'), t('Cancel')); + return confirm_form($form, t('Are you sure you want to delete %category?', array('%category' => theme('placeholder', $info->category))), 'admin/build/contact', t('This action cannot be undone.'), t('Delete'), t('Cancel')); } else { drupal_set_message(t('Category not found.'), 'error'); @@ -297,20 +296,13 @@ function contact_admin_settings() { '#default_value' => variable_get('contact_default_status', 1), '#description' => t('Default status of the personal contact form for new users.'), ); - $form['submit'] = array('#type' => 'submit', - '#value' => t('Save configuration'), - ); - $form['reset'] = array('#type' => 'submit', - '#value' => t('Reset to defaults'), - ); - - return drupal_get_form('contact_admin_settings', $form, 'system_settings_form'); + return system_settings_form($form); } /** * Personal contact page. */ -function contact_mail_user() { +function contact_user_page() { global $user; if ($account = user_load(array('uid' => arg(1)))) { @@ -322,33 +314,7 @@ function contact_mail_user() { } else { drupal_set_title($account->name); - - $form['#token'] = $user->name . $user->mail; - $form['from'] = array('#type' => 'item', - '#title' => t('From'), - '#value' => $user->name .' <'. $user->mail .'>', - ); - $form['to'] = array('#type' => 'item', - '#title' => t('To'), - '#value' => $account->name, - ); - $form['subject'] = array('#type' => 'textfield', - '#title' => t('Subject'), - '#maxlength' => 50, - '#required' => TRUE, - ); - $form['message'] = array('#type' => 'textarea', - '#title' => t('Message'), - '#rows' => 15, - '#required' => TRUE, - ); - $form['copy'] = array('#type' => 'checkbox', - '#title' => t('Send yourself a copy.'), - ); - $form['submit'] = array('#type' => 'submit', - '#value' => t('Send e-mail'), - ); - $output = drupal_get_form('contact_mail_user', $form); + $output = drupal_get_form('contact_mail_user'); } return $output; @@ -358,6 +324,36 @@ function contact_mail_user() { } } +function contact_mail_user() { + global $user; + $form['#token'] = $user->name . $user->mail; + $form['from'] = array('#type' => 'item', + '#title' => t('From'), + '#value' => $user->name .' <'. $user->mail .'>', + ); + $form['to'] = array('#type' => 'item', + '#title' => t('To'), + '#value' => $account->name, + ); + $form['subject'] = array('#type' => 'textfield', + '#title' => t('Subject'), + '#maxlength' => 50, + '#required' => TRUE, + ); + $form['message'] = array('#type' => 'textarea', + '#title' => t('Message'), + '#rows' => 15, + '#required' => TRUE, + ); + $form['copy'] = array('#type' => 'checkbox', + '#title' => t('Send yourself a copy.'), + ); + $form['submit'] = array('#type' => 'submit', + '#value' => t('Send e-mail'), + ); + return $form; +} + /** * Process the personal contact page form submission. */ @@ -409,84 +405,85 @@ function contact_mail_user_submit($form_ /** * Site-wide contact page */ -function contact_mail_page() { +function contact_site_page() { global $user; if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) { $output = t("You cannot send more than %number messages per hour. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3))); } else { - if ($user->uid) { - $edit['name'] = $user->name; - $edit['mail'] = $user->mail; - } + $output = drupal_get_form('contact_mail_page'); + } - $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category'); - while ($category = db_fetch_object($result)) { - $categories[$category->cid] = $category->category; - if ($category->selected) { - $default_category = $category->cid; - } - } + return $output; +} - if (count($categories) > 0) { - $form['#token'] = $user->name . $user->mail; - $form['contact_information'] = array('#value' => filter_xss_admin(variable_get('contact_form_information', t('You can leave us a message using the contact form below.')))); - $form['name'] = array('#type' => 'textfield', - '#title' => t('Your name'), - '#maxlength' => 255, - '#default_value' => $edit['name'], - '#required' => TRUE, - ); - $form['mail'] = array('#type' => 'textfield', - '#title' => t('Your e-mail address'), - '#maxlength' => 255, - '#default_value' => $edit['mail'], - '#required' => TRUE, - ); - $form['subject'] = array('#type' => 'textfield', - '#title' => t('Subject'), - '#maxlength' => 255, - '#required' => TRUE, - ); - if (count($categories) > 1) { - // If there is more than one category available and no default category has been selected, - // prepend a default placeholder value. - if (!isset($default_category)) { - $categories = array(t('--')) + $categories; - } - $form['cid'] = array('#type' => 'select', - '#title' => t('Category'), - '#default_value' => $default_category, - '#options' => $categories, - '#required' => TRUE, - ); - } - else { - // If there is only one category, store its cid. - $category_keys = array_keys($categories); - $form['cid'] = array('#type' => 'value', - '#value' => array_shift($category_keys), - ); +function contact_mail_page() { + global $user; + + $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category'); + while ($category = db_fetch_object($result)) { + $categories[$category->cid] = $category->category; + if ($category->selected) { + $default_category = $category->cid; + } + } + + if (count($categories) > 0) { + $form['#token'] = $user->name . $user->mail; + $form['contact_information'] = array('#value' => filter_xss_admin(variable_get('contact_form_information', t('You can leave us a message using the contact form below.')))); + $form['name'] = array('#type' => 'textfield', + '#title' => t('Your name'), + '#maxlength' => 255, + '#default_value' => $user->uid ? $user->name : '', + '#required' => TRUE, + ); + $form['mail'] = array('#type' => 'textfield', + '#title' => t('Your e-mail address'), + '#maxlength' => 255, + '#default_value' => $user->uid ? $user->mail : '', + '#required' => TRUE, + ); + $form['subject'] = array('#type' => 'textfield', + '#title' => t('Subject'), + '#maxlength' => 255, + '#required' => TRUE, + ); + if (count($categories) > 1) { + // If there is more than one category available and no default category has been selected, + // prepend a default placeholder value. + if (!isset($default_category)) { + $categories = array(t('--')) + $categories; } - $form['message'] = array('#type' => 'textarea', - '#title' => t('Message'), + $form['cid'] = array('#type' => 'select', + '#title' => t('Category'), + '#default_value' => $default_category, + '#options' => $categories, '#required' => TRUE, ); - $form['copy'] = array('#type' => 'checkbox', - '#title' => t('Send yourself a copy.'), - ); - $form['submit'] = array('#type' => 'submit', - '#value' => t('Send e-mail'), - ); - $output = drupal_get_form('contact_mail_page', $form); } else { - $output = t('The contact form has not been configured.'); + // If there is only one category, store its cid. + $category_keys = array_keys($categories); + $form['cid'] = array('#type' => 'value', + '#value' => array_shift($category_keys), + ); } + $form['message'] = array('#type' => 'textarea', + '#title' => t('Message'), + '#required' => TRUE, + ); + $form['copy'] = array('#type' => 'checkbox', + '#title' => t('Send yourself a copy.'), + ); + $form['submit'] = array('#type' => 'submit', + '#value' => t('Send e-mail'), + ); } - - return $output; + else { + $form['#error'] = array('#value' => t('The contact form has not been configured.')); + } + return $form; } /** @@ -551,3 +548,4 @@ function contact_mail_page_submit($form_ // Jump to home page rather than back to contact page to avoid contradictory messages if flood control has been activated. return(''); } + === modified file 'modules/drupal/drupal.module' --- modules/drupal/drupal.module +++ modules/drupal/drupal.module @@ -111,7 +111,7 @@ function drupal_sites_registry_settings( '#description' => t('If enabled, your Drupal site will allow other sites to register with your site and send information to this site. This functionality can be used to maintain a list of related sites.') ); - return system_settings_form('drupal_sites_registry_settings', $form); + return system_settings_form($form); } function drupal_distributed_authentication_settings() { @@ -141,7 +141,7 @@ function drupal_distributed_authenticati '#description' => t('Only accept remote logins from the above specified default authentication server and not from any other server. Useful when an external system is the solitary authority on user accounts for this site. A common usage is to enable this setting and also enable an authentication module which talks to your company\'s directory server.') ); - return system_settings_form('drupal_distributed_authentication_settings', $form); + return system_settings_form($form); } /** === modified file 'modules/filter/filter.module' --- modules/filter/filter.module +++ modules/filter/filter.module @@ -316,7 +316,7 @@ function filter_admin_overview() { } $form['default'] = array('#type' => 'radios', '#options' => $options, '#default_value' => variable_get('filter_default_format', 1)); $form['submit'] = array('#type' => 'submit', '#value' => t('Set default format')); - return drupal_get_form('filter_admin_overview', $form); + return $form; } function filter_admin_overview_submit($form_id, $form_values) { @@ -359,7 +359,7 @@ function filter_admin_delete() { $form['format'] = array('#type' => 'hidden', '#value' => $format->format); $form['name'] = array('#type' => 'hidden', '#value' => $format->name); - return confirm_form('filter_admin_delete', $form, t('Are you sure you want to delete the input format %format?', array('%format' => theme('placeholder', $format->name))), 'admin/settings/filters', t('If you have any content left in this input format, it will be switched to the default input format. This action cannot be undone.'), t('Delete'), t('Cancel')); + return confirm_form($form, t('Are you sure you want to delete the input format %format?', array('%format' => theme('placeholder', $format->name))), 'admin/settings/filters', t('If you have any content left in this input format, it will be switched to the default input format. This action cannot be undone.'), t('Delete'), t('Cancel')); } else { drupal_set_message(t('The default format cannot be deleted.')); @@ -440,8 +440,6 @@ function filter_admin_format_form($forma '#description' => module_invoke($filter->module, 'filter', 'description', $filter->delta), ); } - $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); - if (isset($format)) { $form['format'] = array('#type' => 'hidden', '#value' => $format->format); @@ -454,11 +452,11 @@ function filter_admin_format_form($forma } $group = t('

These are the guidelines that users will see for posting in this input format. They are automatically generated from the filter settings.

'); $group .= $tiplist; - $output = '

'. t('Formatting guidelines') .'

'. $group; + $form['tips'] = array('#value' => '

'. t('Formatting guidelines') .'

'. $group); } - $output = drupal_get_form('filter_admin_format_form', $form) . $output; + $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); - return $output; + return $form; } /** @@ -549,7 +547,7 @@ function filter_admin_order($format = NU $form['format'] = array('#type' => 'hidden', '#value' => $format->format); $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); - return drupal_get_form('filter_admin_order', $form); + return $form; } /** @@ -600,13 +598,13 @@ function filter_admin_configure() { } if (!empty($form)) { - $output = system_settings_form('filter_admin_configure', $form); + $form = system_settings_form($form); } else { - $output = t('No settings are available.'); + $form['error'] = array('#value' => t('No settings are available.')); } - return $output; + return $form; } /** === modified file 'modules/forum/forum.module' --- modules/forum/forum.module +++ modules/forum/forum.module @@ -183,7 +183,6 @@ function forum_taxonomy($op, $type, $ter } function forum_admin_settings() { - $form = array(); $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', @@ -206,8 +205,7 @@ function forum_admin_settings() { '#options' => $forder, '#description' => t('The default display order for topics.'), ); - - return system_settings_form('forum_admin_configure', $form); + return system_settings_form($form); } /** @@ -445,7 +443,7 @@ function forum_delete(&$node) { function forum_form_container($edit = array()) { // Handle a delete operation. if ($_POST['op'] == t('Delete') || $_POST['edit']['confirm']) { - return _forum_confirm_delete($edit['tid']); + return forum_confirm_delete($edit['tid']); } $form['name'] = array( @@ -481,8 +479,9 @@ function forum_form_container($edit = ar $form['delete'] = array('#type' => 'submit', '#value' => t('Delete')); $form['tid'] = array('#type' => 'value', '#value' => $edit['tid']); } + $form['#base'] = 'forum_form'; - return drupal_get_form('forum_form_container', $form, 'forum_form'); + return $form; } /** @@ -493,7 +492,7 @@ function forum_form_container($edit = ar function forum_form_forum($edit = array()) { // Handle a delete operation. if ($_POST['op'] == t('Delete') || $_POST['edit']['confirm']) { - return _forum_confirm_delete($edit['tid']); + return forum_confirm_delete($edit['tid']); } $form['name'] = array('#type' => 'textfield', @@ -522,8 +521,9 @@ function forum_form_forum($edit = array( $form['delete'] = array('#type' => 'submit', '#value' => t('Delete')); $form['tid'] = array('#type' => 'hidden', '#value' => $edit['tid']); } + $form['#base'] = 'forum_form'; - return drupal_get_form('forum_form_forum', $form, 'forum_form'); + return $form; } /** @@ -561,13 +561,13 @@ function forum_form_submit($form_id, $fo * * @param $tid ID of the term to be deleted */ -function _forum_confirm_delete($tid) { +function forum_confirm_delete($tid) { $term = taxonomy_get_term($tid); $form['tid'] = array('#type' => 'value', '#value' => $tid); $form['name'] = array('#type' => 'value', '#value' => $term->name); - return confirm_form('forum_confirm_delete', $form, t('Are you sure you want to delete the forum %name?', array('%name' => theme('placeholder', $term->name))), 'admin/content/forums', t('Deleting a forum or container will delete all sub-forums and associated posts as well. This action cannot be undone.'), t('Delete'), t('Cancel')); + return confirm_form($form, t('Are you sure you want to delete the forum %name?', array('%name' => theme('placeholder', $term->name))), 'admin/content/forums', t('Deleting a forum or container will delete all sub-forums and associated posts as well. This action cannot be undone.'), t('Delete'), t('Cancel')); } /** === modified file 'modules/locale/locale.module' --- modules/locale/locale.module +++ modules/locale/locale.module @@ -314,7 +314,7 @@ function locale_get_plural($count) { */ function locale_admin_manage() { include_once './includes/locale.inc'; - return _locale_admin_manage_screen(); + return drupal_get_form('_locale_admin_manage_screen'); } /** @@ -338,7 +338,7 @@ function locale_admin_manage_delete_form } else { $form['langcode'] = array('#type' => 'value', '#value' => $langcode); - return confirm_form('locale_admin_manage_delete_form', $form, t('Are you sure you want to delete the language %name?', array('%name' => theme('placeholder', t($languages['name'][$langcode])))), 'admin/settings/locale/language/overview', t('Deleting a language will remove all data associated with it. This action cannot be undone.'), t('Delete'), t('Cancel')); + return confirm_form($form, t('Are you sure you want to delete the language %name?', array('%name' => theme('placeholder', t($languages['name'][$langcode])))), 'admin/settings/locale/language/overview', t('Deleting a language will remove all data associated with it. This action cannot be undone.'), t('Delete'), t('Cancel')); } } @@ -377,7 +377,7 @@ function locale_admin_manage_add() { */ function locale_admin_import() { include_once './includes/locale.inc'; - return _locale_admin_import_screen(); + return drupal_get_form('_locale_admin_import'); } // --------------------------------------------------------------------------------- @@ -400,7 +400,7 @@ function locale_admin_export() { function locale_string_search() { include_once './includes/locale.inc'; $output = _locale_string_seek(); - $output .= _locale_string_seek_form(); + $output .= drupal_get_form('_locale_string_seek_form'); return $output; } === modified file 'modules/menu/menu.module' --- modules/menu/menu.module +++ modules/menu/menu.module @@ -308,7 +308,7 @@ function menu_configure() { '#description' => t('Choose the menu to be made available in the content authoring form. Only this menu item and its children will be shown.'), ); - return system_settings_form('menu_configure', $form); + return system_settings_form($form); } /** @@ -336,9 +336,10 @@ function menu_edit_menu_form($type, $mid $form['weight'] = array('#type' => 'value', '#value' => $item['weight']); $form['type'] = array('#type' => 'value', '#value' => $item['type']); $form['submit'] = array('#type' => 'submit', '#value' => t('Submit')); - // Reuse the submit function of menu_edit_item_form. - return drupal_get_form('menu_edit_menu_form', $form, 'menu_edit_item_form'); + $form['#base'] = 'menu_edit_item_form'; + + return $form; } /** @@ -416,7 +417,7 @@ function menu_edit_item_form($type, $mid $form['mid'] = array('#type' => 'value', '#value' => $item['mid']); $form['submit'] = array('#type' => 'submit', '#value' => t('Submit')); - return drupal_get_form('menu_edit_item_form', $form); + return $form; } /** @@ -447,13 +448,13 @@ function menu_item_delete_form($mid) { $message = t('Are you sure you want to delete the custom menu item %item?', array('%item' => theme('placeholder', $menu->title))); } - return confirm_form('menu_confirm_delete_form', $form, $message, 'admin/build/menu', t('This action cannot be undone.'), t('Delete')); + return confirm_form($form, $message, 'admin/build/menu', t('This action cannot be undone.'), t('Delete')); } /** * Process menu delete form submissions. */ -function menu_confirm_delete_form_submit($form_id, $form_values) { +function menu_item_delete_form_submit($form_id, $form_values) { menu_delete_item($form_values['mid']); $t_args = array('%title' => theme('placeholder', $form_values['title'])); @@ -475,7 +476,7 @@ function menu_confirm_delete_form_submit function menu_reset_item($mid) { if (isset($mid) && $title = db_result(db_query('SELECT title FROM {menu} WHERE mid = %d', $mid))) { $form['mid'] = array('#type' => 'value', '#value' => $mid); - return confirm_form('menu_reset_item_form', $form, t('Are you sure you want to reset the item %item to its default values?', array('%item' => theme('placeholder', $title))), 'admin/build/menu', t('Any customizations will be lost. This action cannot be undone.'), t('Reset')); + return confirm_form($form, t('Are you sure you want to reset the item %item to its default values?', array('%item' => theme('placeholder', $title))), 'admin/build/menu', t('Any customizations will be lost. This action cannot be undone.'), t('Reset')); } else { drupal_not_found(); @@ -485,7 +486,7 @@ function menu_reset_item($mid) { /** * Process menu reset item form submissions. */ -function menu_reset_item_form_submit($form_id, $form_values) { +function menu_reset_item_submit($form_id, $form_values) { menu_delete_item($form_values['mid']); drupal_set_message(t('The menu item was reset to its default settings.')); === modified file 'modules/node/content_types.inc' --- modules/node/content_types.inc +++ modules/node/content_types.inc @@ -207,7 +207,7 @@ function node_type_form($type = NULL) { ); } - return drupal_get_form('node_type_form', $form); + return $form; } /** === modified file 'modules/node/node.module' --- modules/node/node.module +++ modules/node/node.module @@ -948,7 +948,7 @@ function node_configure() { '#options' => array(t('Optional'), t('Required')), '#description' => t('Must users preview posts before submitting?') ); - return system_settings_form('node_configure', $form); + return system_settings_form($form); } /** @@ -1004,7 +1004,7 @@ function node_menu($may_cache) { 'path' => 'admin/content/node', 'title' => t('posts'), 'description' => t('View, edit, and delete your site\'s content.'), - 'callback' => 'node_admin_nodes', + 'callback' => 'node_admin_content', 'access' => user_access('administer nodes') ); @@ -1143,7 +1143,7 @@ function node_menu($may_cache) { // There is no need to rebuild node_access if there is only 1 record in the table (the default configuration). if (db_result(db_query('SELECT COUNT(*) FROM {node_access}')) > 1) { $items[] = array('path' => 'admin/settings/node-access', 'title' => t('node access'), - 'callback' => 'node_access_rebuild_page', + 'callback' => 'node_access_rebuild', 'access' => user_access('administer nodes')); } } @@ -1312,13 +1312,13 @@ function node_filter_form() { $form['filters']['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset')); } - return drupal_get_form('node_filter_form', $form); + return $form; } /** * Theme node administration filter form. */ -function theme_node_filter_form(&$form) { +function theme_node_filter_form($form) { $output .= '
'; $output .= drupal_render($form['filters']); $output .= '
'; @@ -1329,7 +1329,7 @@ function theme_node_filter_form(&$form) /** * Theme node administraton filter selector. */ -function theme_node_filters(&$form) { +function theme_node_filters($form) { $output .= '