Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.6 diff -u -F^f -r1.6 install.php --- install.php 8 Aug 2006 21:18:02 -0000 1.6 +++ install.php 12 Aug 2006 21:53:25 -0000 @@ -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. */ Index: update.php =================================================================== RCS file: /cvs/drupal/drupal/update.php,v retrieving revision 1.196 diff -u -F^f -r1.196 update.php --- update.php 31 Jul 2006 19:24:16 -0000 1.196 +++ update.php 12 Aug 2006 21:53:25 -0000 @@ -320,6 +320,15 @@ function update_selection_page() { $output = '

The version of Drupal you are updating from has been automatically detected. You can select a different version, but you should not need to.

'; $output .= '

Click Update to start the update process.

'; + drupal_set_title('Drupal database update'); + // Prevent browser from using cached drupal.js or update.js + drupal_add_js('misc/update.js', TRUE); + $output .= drupal_get_form('update_script_selection_form'); + + return $output; +} + +function update_script_selection_form() { $form = array(); $form['start'] = array( '#tree' => TRUE, @@ -356,13 +365,7 @@ function update_selection_page() { '#type' => 'submit', '#value' => 'Update', ); - - drupal_set_title('Drupal database update'); - // Prevent browser from using cached drupal.js or update.js - drupal_add_js('misc/update.js', TRUE); - $output .= drupal_get_form('update_script_selection_form', $form); - - return $output; + return $form; } function update_update_page() { Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.133 diff -u -F^f -r1.133 form.inc --- includes/form.inc 10 Aug 2006 15:42:32 -0000 1.133 +++ includes/form.inc 12 Aug 2006 21:53:25 -0000 @@ -15,47 +15,102 @@ */ /** + * Retrieves a form from a handler function, then passes it on for + * processing and rendering. + * + * @param $form_handler + * The unique string identifying the desired form. This is passed on + * to drupal_retrieve_form(). + * @param ... + * Any additional arguments needed by the form handler. + */ +function drupal_get_form($form_handler) { + $args = func_get_args(); + $form = call_user_func_array('drupal_retrieve_form', $args); + return drupal_process_form($form_handler, $form); +} + +/** + * Retrieves the structured array that defines a given form. + * + * @param $form_handler + * The unique string identifying the desired form. If $form_handler + * exists as a function, it is called to build the form. Otherwise, + * hook_forms() is called to build a system-wide array of forms, + * and $form_handler is used as a key to locate the appropriate + * builder-function in that array. + * @param ... + * Any additional arguments needed by the form handler. + */ +function drupal_retrieve_form($form_handler) { + static $forms; + + $args = func_get_args(); + $form_handler = array_shift($args); + if (!function_exists($form_handler)) { + if (!isset($forms)) { + $forms = module_invoke_all('forms'); + } + $form_definition = $forms[$form_handler]; + if (isset($form_definition['callback arguments'])) { + $args = array_merge($form_definition['callback arguments'], $args); + } + if (isset($form_definition['callback'])) { + $callback = $form_definition['callback']; + } + } + return call_user_func_array(isset($callback) ? $callback : $form_handler, $args); +} + +/** * 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(). * - * @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) + * @param $form_handler + * 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) { - global $form_values, $form_submitted, $user, $form_button_counter; +function drupal_process_form($form_handler, $form) { + global $form_values, $form_post_key, $form_submitted, $user, $form_button_counter; static $saved_globals = array(); + if (empty($form_post_key)) { + $form_post_key = '_POST'; + } + + $form_id = isset($form['#form_id']) ? $form['#form_id'] : $form_handler; + if (isset($form['#function_prefix'])) { + $function_prefix = $form['#function_prefix']; + } // Save globals in case of indirect recursive call - array_push($saved_globals, array($form_values, $form_submitted, $form_button_counter)); + array_push($saved_globals, array($form_post_key, $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); + $form = drupal_build_form($form_id, $form, $function_prefix); - if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $callback))) { - drupal_validate_form($form_id, $form, $callback); + if (($form_post_key != '_POST') || (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $function_prefix)))) { + 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); - drupal_redirect_form($form, $redirect); + if ((($form_post_key != '_POST') || $form_submitted || (!$form_button_counter[0] && $form_button_counter[1])) && !form_get_errors()) { + $redirect = drupal_submit_form($form_id, $form); + if ($form_post_key == '_POST') { + drupal_redirect_form($form, $redirect); + } } } - $output = drupal_render_form($form_id, $form, $callback); - list($form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals); + if ($form_post_key == '_POST') { + $output = drupal_render_form($form_id, $form, $function_prefix); + } + list($form_post_key, $form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals); return $output; } @@ -69,11 +124,11 @@ 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. + * @param $function_prefix + * An optional function prefix that will be used in place of $form_id. * */ -function drupal_build_form($form_id, &$form, $callback = NULL) { +function drupal_build_form($form_id, &$form, $function_prefix = NULL) { $form['#type'] = 'form'; if (isset($form['#token'])) { // If the page cache is on and an anonymous user issues a GET request, @@ -105,8 +160,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($function_prefix .'_validate')) { + $form['#validate'] = array($function_prefix .'_validate' => array()); } } @@ -116,8 +171,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($function_prefix .'_submit')) { + $form['#submit'] = array($function_prefix .'_submit' => array()); } } @@ -141,11 +196,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(); @@ -175,14 +228,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 +260,21 @@ 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. + * @param $function_prefix + * An optional function prefix 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, $function_prefix = NULL) { // Don't override #theme if someone already set it. 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($function_prefix)) { + $form['#theme'] = $function_prefix; } } @@ -389,7 +440,7 @@ function form_error(&$element, $message * An associative array containing the structure of the form. */ function form_builder($form_id, $form) { - global $form_values, $form_submitted, $form_button_counter; + global $form_values, $form_post_key, $form_submitted, $form_button_counter; // Initialize as unprocessed. $form['#processed'] = FALSE; @@ -408,8 +459,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_post_key != '_POST') || (isset($_POST['edit']) && ($_POST['edit']['form_id'] == $form_id))); + $edit = $posted ? $GLOBALS[$form_post_key]['edit'] : array(); foreach ($form['#parents'] as $parent) { $edit = isset($edit[$parent]) ? $edit[$parent] : NULL; } @@ -762,6 +813,7 @@ function expand_password_confirm($elemen * Validate password_confirm element. */ function password_confirm_validate($form) { + global $form_post_key; $pass1 = trim($form['pass1']['#value']); if (!empty($pass1)) { $pass2 = trim($form['pass2']['#value']); @@ -769,7 +821,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($GLOBALS[$form_post_key]['edit'])) { form_error($form, t('Password field is required.')); } Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.132 diff -u -F^f -r1.132 menu.inc --- includes/menu.inc 31 Jul 2006 11:25:52 -0000 1.132 +++ includes/menu.inc 12 Aug 2006 21:53:25 -0000 @@ -415,7 +415,12 @@ 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; } /** Index: modules/aggregator/aggregator.module =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v retrieving revision 1.295 diff -u -F^f -r1.295 aggregator.module --- modules/aggregator/aggregator.module 10 Aug 2006 15:42:32 -0000 1.295 +++ modules/aggregator/aggregator.module 12 Aug 2006 21:53:25 -0000 @@ -166,9 +166,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'), @@ -179,7 +179,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'), @@ -223,7 +223,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); } /** @@ -332,7 +332,7 @@ function aggregator_block($op, $delta = $form['cid'] = array('#type' => 'hidden', '#value' => $edit['cid']); } - return drupal_get_form('aggregator_form_category', $form); + return $form; } /** @@ -463,7 +463,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; } /** @@ -1045,28 +1045,15 @@ 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; 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)) { @@ -1085,11 +1072,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)) { @@ -1098,9 +1082,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 = 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) { Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.213 diff -u -F^f -r1.213 block.module --- modules/block/block.module 10 Aug 2006 15:42:32 -0000 1.213 +++ modules/block/block.module 12 Aug 2006 21:53:25 -0000 @@ -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) { @@ -240,7 +240,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; } /** @@ -463,7 +463,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) { @@ -488,23 +488,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.')); @@ -562,6 +552,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; } Index: modules/blogapi/blogapi.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blogapi/blogapi.module,v retrieving revision 1.91 diff -u -F^f -r1.91 blogapi.module --- modules/blogapi/blogapi.module 7 Aug 2006 21:00:26 -0000 1.91 +++ modules/blogapi/blogapi.module 12 Aug 2006 21:53:25 -0000 @@ -564,7 +564,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) { Index: modules/book/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.module,v retrieving revision 1.381 diff -u -F^f -r1.381 book.module --- modules/book/book.module 10 Aug 2006 15:42:32 -0000 1.381 +++ modules/book/book.module 12 Aug 2006 21:53:26 -0000 @@ -320,7 +320,7 @@ function book_outline($nid) { } drupal_set_title(check_plain($node->title)); - return drupal_get_form('book_outline', $form); + return $form; } /** @@ -887,7 +887,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(); @@ -915,19 +915,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['#form_id'] = 'book_admin_edit'; + return $form; } function book_admin_edit_submit($form_id, $form_values) { Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.474 diff -u -F^f -r1.474 comment.module --- modules/comment/comment.module 10 Aug 2006 15:42:32 -0000 1.474 +++ modules/comment/comment.module 12 Aug 2006 21:53:26 -0000 @@ -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); } /** @@ -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,7 +916,7 @@ 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); } } @@ -1014,7 +1014,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 +1043,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; } /** @@ -1274,7 +1274,7 @@ function comment_validate($edit) { ** This is rendered by theme_comment_form. */ -function comment_form($edit, $title = NULL) { +function _comment_form($edit, $title = NULL) { global $user; $op = isset($_POST['op']) ? $_POST['op'] : ''; @@ -1421,8 +1421,12 @@ function comment_form($edit, $title = NU // Graft in extra form additions $form = array_merge($form, comment_invoke_comment($form, 'form')); + $form['#form_id'] = 'comment_form'; + return $form; +} - return theme('box', $title, drupal_get_form('comment_form', $form)); +function comment_form($edit, $title = NULL) { + return theme('box', $title, drupal_get_form('_comment_form', $edit, $title)); } function comment_form_add_preview($form, $edit) { @@ -1575,7 +1579,7 @@ function comment_controls($mode = COMMEN '#weight' => 20, ); - return drupal_get_form('comment_controls', $form); + return $form; } function theme_comment_controls($form) { Index: modules/contact/contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v retrieving revision 1.59 diff -u -F^f -r1.59 contact.module --- modules/contact/contact.module 10 Aug 2006 15:36:55 -0000 1.59 +++ modules/contact/contact.module 12 Aug 2006 21:53:26 -0000 @@ -100,7 +100,6 @@ 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', @@ -199,7 +198,7 @@ function contact_admin_edit($cid = NULL) '#value' => t('Submit'), ); - return drupal_get_form('contact_admin_edit', $form); + return $form; } /** @@ -297,14 +296,7 @@ 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); } /** @@ -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 me 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_form'); } return $output; @@ -358,6 +324,37 @@ function contact_mail_user() { } } +function contact_mail_user_form() { + 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 me a copy.'), + ); + $form['submit'] = array('#type' => 'submit', + '#value' => t('Send e-mail'), + ); + $form['#form_id'] = 'contact_mail_user'; + return $form; +} + /** * Process the personal contact page form submission. */ @@ -416,77 +413,79 @@ function contact_mail_page() { $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_form'); + } - $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_form() { + 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 me 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 me 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.')); + } + $form['#form_id'] = 'contact_mail_page'; + return $form; } /** Index: modules/drupal/drupal.module =================================================================== RCS file: /cvs/drupal/drupal/modules/drupal/drupal.module,v retrieving revision 1.125 diff -u -F^f -r1.125 drupal.module --- modules/drupal/drupal.module 7 Aug 2006 15:04:14 -0000 1.125 +++ modules/drupal/drupal.module 12 Aug 2006 21:53:26 -0000 @@ -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); } /** Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.133 diff -u -F^f -r1.133 filter.module --- modules/filter/filter.module 10 Aug 2006 15:42:32 -0000 1.133 +++ modules/filter/filter.module 12 Aug 2006 21:53:26 -0000 @@ -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) { @@ -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; } /** Index: modules/forum/forum.module =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v retrieving revision 1.346 diff -u -F^f -r1.346 forum.module --- modules/forum/forum.module 10 Aug 2006 15:42:32 -0000 1.346 +++ modules/forum/forum.module 12 Aug 2006 21:53:26 -0000 @@ -201,8 +201,9 @@ function forum_admin_settings() { '#options' => $forder, '#description' => t('The default display order for topics.'), ); + $form['#form_id'] = 'forum_admin_configure'; - return system_settings_form('forum_admin_configure', $form); + return system_settings_form($form); } /** @@ -476,8 +477,9 @@ function forum_form_container($edit = ar $form['delete'] = array('#type' => 'submit', '#value' => t('Delete')); $form['tid'] = array('#type' => 'value', '#value' => $edit['tid']); } + $form['#function_prefix'] = 'forum_form'; - return drupal_get_form('forum_form_container', $form, 'forum_form'); + return $form; } /** @@ -517,8 +519,9 @@ function forum_form_forum($edit = array( $form['delete'] = array('#type' => 'submit', '#value' => t('Delete')); $form['tid'] = array('#type' => 'hidden', '#value' => $edit['tid']); } + $form['#function_prefix'] = 'forum_form'; - return drupal_get_form('forum_form_forum', $form, 'forum_form'); + return $form; } /** Index: modules/menu/menu.module =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v retrieving revision 1.78 diff -u -F^f -r1.78 menu.module --- modules/menu/menu.module 7 Aug 2006 15:04:15 -0000 1.78 +++ modules/menu/menu.module 12 Aug 2006 21:53:26 -0000 @@ -303,7 +303,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); } /** @@ -331,9 +331,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['#function_prefix'] = 'menu_edit_item_form'; + + return $form; } /** @@ -411,7 +412,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; } /** Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.669 diff -u -F^f -r1.669 node.module --- modules/node/node.module 10 Aug 2006 15:42:33 -0000 1.669 +++ modules/node/node.module 12 Aug 2006 21:53:26 -0000 @@ -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); } /** @@ -1288,13 +1288,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 .= '
'; @@ -1305,7 +1305,7 @@ function theme_node_filter_form(&$form) /** * Theme node administraton filter selector. */ -function theme_node_filters(&$form) { +function theme_node_filters($form) { $output .= '