Published in: Diff
=== modified file 'includes/form.inc' --- includes/form.inc +++ includes/form.inc @@ -12,7 +12,67 @@ * 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 + * + * If you want to programatically submit a form, you need to + * retrieve the form, load name/value pairs into $form['#post'] and then + * call drupal_process_form(). Example: + * + * // register a new user. + * $form = drupal_retrieve_form('user_register'); + * $form['#post']['edit']['name'] = 'robo-user'; + * $form['#post']['mail'] = 'robouser@example.com'; + * $output = drupal_process_form('user_register', $form); + * + */ + +/** + * Retrieves a form from a handler function, then passes it on for + * processing and rendering. + * + * @param $form_id + * The unique string identifying the form. + * @param ... + * Any additional arguments needed by the form handler. + * @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 $form_id + * 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_id 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_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']; + } + } + return call_user_func_array(isset($callback) ? $callback : $form_id, $args); +} /** * Processes a form array and produces the HTML output of a form. @@ -21,19 +81,26 @@ * 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) + * 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(); + if (!isset($form['#post'])) { + $form['#post'] = $_POST; + $form['#programmed'] = FALSE; + } + else { + $form['#programmed'] = TRUE; + } + + if (isset($form['#base'])) { + $base = $form['#base']; + } + // Save globals in case of indirect recursive call array_push($saved_globals, array($form_values, $form_submitted, $form_button_counter)); @@ -41,20 +108,24 @@ function drupal_get_form($form_id, &$for $form_submitted = FALSE; $form_button_counter = array(0, 0); - $form = drupal_build_form($form_id, $form, $callback); + $form = drupal_build_form($form_id, $form, $base); - if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $callback))) { - drupal_validate_form($form_id, $form, $callback); + if (($form['#programmed']) || (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $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); - drupal_redirect_form($form, $redirect); + if ((($form['#programmed']) || $form_submitted || (!$form_button_counter[0] && $form_button_counter[1])) && !form_get_errors()) { + $redirect = drupal_submit_form($form_id, $form); + if (!$form['#programmed']) { + drupal_redirect_form($form, $redirect); + } } } - $output = drupal_render_form($form_id, $form, $callback); + if (!$form['#programmed']) { + $output = drupal_render_form($form_id, $form, $base); + } list($form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals); return $output; } @@ -69,11 +140,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 $base + * 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, $base = NULL) { $form['#type'] = 'form'; if (isset($form['#token'])) { // If the page cache is on and an anonymous user issues a GET request, @@ -105,8 +176,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 +187,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()); } } @@ -141,11 +212,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 +244,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 +276,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 $base + * 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, $base = 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($base)) { + $form['#theme'] = $base; } } @@ -408,8 +475,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 +557,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 +838,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/menu.inc' --- includes/menu.inc +++ includes/menu.inc @@ -415,7 +415,15 @@ 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); + + // A menu callback that returns an array always consists of a form definition. Then we push $return to + // drupal_process_form(). Modules may submit forms programmatically using an analogous "push". + 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,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 = '<div id="aggregator">'; - +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)) { @@ -1089,11 +1076,8 @@ function _aggregator_page_list($sql, $op ); } } - $output .= '</div>'; $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 +1086,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 = '<div id="aggregator">'; + $output .= $header; + foreach ($form['items'] as $item) { + $output .= $item['#value']; + } + $output .= '</div>'; + $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 @@ -324,7 +324,7 @@ function book_outline($nid) { } drupal_set_title(check_plain($node->title)); - return drupal_get_form('book_outline', $form); + return $form; } /** @@ -891,7 +891,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(); @@ -919,19 +919,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 '<p>'. t('There are no orphan pages.') .'</p>'; + $form['error'] = array('#value' => '<p>'. t('There are no orphan pages.') .'</p>'); } + $form['#function_prefix'] = '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(
