summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt2
-rw-r--r--includes/form.inc192
-rw-r--r--includes/install.inc2
-rw-r--r--includes/locale.inc89
-rw-r--r--install.php84
-rw-r--r--modules/aggregator/aggregator.module75
-rw-r--r--modules/block/block.module35
-rw-r--r--modules/blogapi/blogapi.module5
-rw-r--r--modules/book/book.module18
-rw-r--r--modules/comment/comment.module60
-rw-r--r--modules/contact/contact.module216
-rw-r--r--modules/drupal/drupal.module10
-rw-r--r--modules/filter/filter.module44
-rw-r--r--modules/forum/forum.module27
-rw-r--r--modules/locale/locale.module11
-rw-r--r--modules/menu/menu.module42
-rw-r--r--modules/node/content_types.inc2
-rw-r--r--modules/node/node.module92
-rw-r--r--modules/path/path.module13
-rw-r--r--modules/poll/poll.module28
-rw-r--r--modules/profile/profile.module16
-rw-r--r--modules/search/search.module32
-rw-r--r--modules/statistics/statistics.module5
-rw-r--r--modules/system/system.module119
-rw-r--r--modules/taxonomy/taxonomy.module18
-rw-r--r--modules/throttle/throttle.module5
-rw-r--r--modules/upload/upload.module5
-rw-r--r--modules/user/user.module180
-rw-r--r--modules/watchdog/watchdog.module17
-rw-r--r--themes/engines/phptemplate/phptemplate.engine2
-rw-r--r--update.php17
31 files changed, 844 insertions, 619 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index a55d3f9b4..0d411f2c4 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -44,6 +44,8 @@ Drupal x.x.x, xxxx-xx-xx (development version)
- removed the archive module.
- upgrade system:
* created space for update branches.
+- forms API:
+ * made it possible to programmatically submit forms.
- split up and removed drupal.css.
- added nested lists generation.
diff --git a/includes/form.inc b/includes/form.inc
index 291933d1f..c99f423c0 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -4,59 +4,138 @@
/**
* @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 builder function, passes it on for
+ * processing, and renders the form or redirects to its destination
+ * as appropriate.
+ *
+ * @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. Examples
+ * may be found in 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);
+
+ $redirect = drupal_process_form($form_id, $form);
+
+ if (isset($redirect)) {
+ drupal_redirect_form($form, $redirect);
+ }
+ return drupal_render_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.
*
* @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.
- *
+ * @return
+ * The path to redirect the user to upon completion.
*/
-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);
- 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);
}
}
- $output = drupal_render_form($form_id, $form, $callback);
+ // We've finished calling functions that alter the global values, so we can
+ // restore the ones that were there before this function was called.
list($form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals);
- return $output;
+ return $redirect;
}
/**
@@ -69,12 +148,25 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
* 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 +197,8 @@ function drupal_build_form($form_id, &$form, $callback = NULL) {
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 +208,8 @@ function drupal_build_form($form_id, &$form, $callback = NULL) {
// $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 +219,6 @@ function drupal_build_form($form_id, &$form, $callback = NULL) {
}
$form = form_builder($form_id, $form);
-
- return $form;
}
@@ -141,11 +231,9 @@ function drupal_build_form($form_id, &$form, $callback = NULL) {
* 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 +241,7 @@ function drupal_validate_form($form_id, $form, $callback = NULL) {
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 +263,12 @@ function drupal_validate_form($form_id, $form, $callback = NULL) {
* 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 +295,23 @@ function drupal_submit_form($form_id, $form, $callback = NULL) {
* 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 +496,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 +578,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 +859,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.'));
}
diff --git a/includes/install.inc b/includes/install.inc
index 1de8261ee..50281c86c 100644
--- a/includes/install.inc
+++ b/includes/install.inc
@@ -558,7 +558,7 @@ function st($string, $args = array()) {
/**
* Helper function: apply the appropriate transformation to st() and t() placeholders.
- */
+ */
function _st(&$value, $key) {
switch ($key[0]) {
// Escaped only
diff --git a/includes/locale.inc b/includes/locale.inc
index 0f6e3ee1d..5c63c5443 100644
--- a/includes/locale.inc
+++ b/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_submit($form_id, $form_values) {
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($form_id, $form_values) {
/**
* 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($form_id, $form_values) {
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($translation) {
* Build object out of search criteria specified in request variables
*/
function _locale_string_seek_query() {
- static $query = NULL;
+ static $query;
- if (is_null($query)) {
+ if (!isset($query)) {
$fields = array('string', 'language', 'searchin');
$query = new StdClass;
if (is_array($_REQUEST['edit'])) {
diff --git a/install.php b/install.php
index f2a2ea77a..7c88eab34 100644
--- a/install.php
+++ b/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,11 +124,11 @@ 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('@drupal' => drupal_install_profile_name(), '%file' => $settings_file)), 'error');
drupal_set_title('Drupal database setup');
@@ -140,8 +140,17 @@ function install_change_settings() {
if ($db_url == 'mysql://username:password@localhost/databasename') {
$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(
@@ -170,7 +179,7 @@ function install_change_settings() {
}
else {
if (count($db_types) == 1) {
- $db_types = array_values($db_types);
+ $db_types = array_values($db_types);
$form['basic_options']['db_type'] = array(
'#type' => 'hidden',
'#value' => $db_types[0],
@@ -250,26 +259,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
@@ -313,7 +317,7 @@ function _install_settings_validate($db_prefix, $db_type, $db_user, $db_pass, $d
/**
* 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
@@ -349,42 +353,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.
*/
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 893745abf..095d24ace 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -54,12 +54,14 @@ function aggregator_menu($may_cache) {
'access' => $edit);
$items[] = array('path' => 'admin/content/aggregator/add/feed',
'title' => t('add feed'),
- 'callback' => 'aggregator_form_feed',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('aggregator_form_feed'),
'access' => $edit,
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/content/aggregator/add/category',
'title' => t('add category'),
- 'callback' => 'aggregator_form_category',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('aggregator_form_category'),
'access' => $edit,
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/content/aggregator/remove',
@@ -78,7 +80,8 @@ function aggregator_menu($may_cache) {
'weight' => -10);
$items[] = array('path' => 'admin/content/aggregator/settings',
'title' => t('settings'),
- 'callback' => 'aggregator_admin_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('aggregator_admin_settings'),
'type' => MENU_LOCAL_TASK,
'weight' => 10,
'access' => $edit);
@@ -170,25 +173,25 @@ 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'),
- 'callback' => 'aggregator_form_feed',
- 'callback arguments' => array($feed),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('aggregator_form_feed', $feed),
'access' => $edit,
'type' => MENU_CALLBACK);
}
}
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'),
- 'callback' => 'aggregator_form_category',
- 'callback arguments' => array($category),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('aggregator_form_category', $category),
'access' => $edit,
'type' => MENU_CALLBACK);
}
@@ -227,7 +230,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 +339,7 @@ function aggregator_block($op, $delta = 0, $edit = array()) {
$form['cid'] = array('#type' => 'hidden', '#value' => $edit['cid']);
}
- return drupal_get_form('aggregator_form_category', $form);
+ return $form;
}
/**
@@ -467,7 +470,7 @@ function aggregator_form_feed($edit = array()) {
$form['fid'] = array('#type' => 'hidden', '#value' => $edit['fid']);
}
- return drupal_get_form('aggregator_form_feed', $form);
+ return $form;
}
/**
@@ -1049,28 +1052,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 = '<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;
+ $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 +1080,8 @@ function _aggregator_page_list($sql, $op, $header = '') {
);
}
}
- $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 +1090,30 @@ function _aggregator_page_list($sql, $op, $header = '') {
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 = '<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) {
diff --git a/modules/block/block.module b/modules/block/block.module
index 3f7eab4d5..c8b9b599d 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -71,20 +71,24 @@ function block_menu($may_cache) {
'title' => t('blocks'),
'access' => user_access('administer blocks'),
'description' => t('Configure what block content appears in your site\'s sidebars and other regions.'),
- 'callback' => 'block_admin_display');
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('block_admin_display'));
$items[] = array('path' => 'admin/build/block/list', 'title' => t('list'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'admin/build/block/configure', 'title' => t('configure block'),
'access' => user_access('administer blocks'),
- 'callback' => 'block_admin_configure',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('block_admin_configure'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/build/block/delete', 'title' => t('delete block'),
'access' => user_access('administer blocks'),
- 'callback' => 'block_box_delete',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('block_box_delete'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/build/block/add', 'title' => t('add block'),
'access' => user_access('administer blocks'),
- 'callback' => 'block_box_add',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('block_box_form'),
'type' => MENU_LOCAL_TASK);
foreach (list_themes() as $key => $theme) {
if ($theme->status) {
@@ -245,7 +249,7 @@ function block_admin_display($theme = NULL) {
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Save blocks'));
- return drupal_get_form('block_admin_display', $form);
+ return $form;
}
/**
@@ -468,7 +472,7 @@ function block_admin_configure($module = NULL, $delta = 0) {
'#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 +497,13 @@ function block_admin_configure_submit($form_id, $form_values) {
}
}
-/**
- * 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 +520,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' => $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' => $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' => $form_values['info'])));
cache_clear_all();
@@ -567,6 +561,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;
}
diff --git a/modules/blogapi/blogapi.module b/modules/blogapi/blogapi.module
index 878afd9f8..8d6fb52bc 100644
--- a/modules/blogapi/blogapi.module
+++ b/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) {
@@ -580,7 +580,8 @@ function blogapi_menu($may_cache) {
'path' => 'admin/settings/blogapi',
'title' => t('blog APIs'),
'description' => t('Configure which content types and engines external blog clients can use.'),
- 'callback' => 'blogapi_admin_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('blogapi_admin_settings'),
'access' => user_access('administer site configuration'),
'type' => MENU_NORMAL_ITEM
);
diff --git a/modules/book/book.module b/modules/book/book.module
index 20d1e88ff..cd402393d 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -102,7 +102,8 @@ function book_menu($may_cache) {
$items[] = array(
'path' => 'admin/content/book/orphan',
'title' => t('orphan pages'),
- 'callback' => 'book_admin_orphan',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('book_admin_orphan'),
'type' => MENU_LOCAL_TASK,
'weight' => 8);
$items[] = array(
@@ -131,8 +132,8 @@ function book_menu($may_cache) {
$items[] = array(
'path' => 'node/'. arg(1) .'/outline',
'title' => t('outline'),
- 'callback' => 'book_outline',
- 'callback arguments' => array(arg(1)),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('book_outline', arg(1)),
'access' => user_access('outline posts in books'),
'type' => MENU_LOCAL_TASK,
'weight' => 2);
@@ -322,7 +323,7 @@ function book_outline($nid) {
}
drupal_set_title(check_plain($node->title));
- return drupal_get_form('book_outline', $form);
+ return $form;
}
/**
@@ -889,7 +890,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 +918,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['#base'] = 'book_admin_edit';
+ return $form;
}
function book_admin_edit_submit($form_id, $form_values) {
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index cc88de53b..3547d2d61 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -104,7 +104,8 @@ function comment_menu($may_cache) {
'path' => 'admin/content/comment',
'title' => t('comments'),
'description' => t('List and edit site comments and the comment moderation queue.'),
- 'callback' => 'comment_admin_overview',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('comment_admin_overview'),
'access' => $access
);
@@ -116,14 +117,16 @@ function comment_menu($may_cache) {
$items[] = array('path' => 'admin/content/comment/list/new', 'title' => t('published comments'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'admin/content/comment/list/approval', 'title' => t('approval queue'),
- 'callback' => 'comment_admin_overview', 'access' => $access,
- 'callback arguments' => array('approval'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('comment_admin_overview', 'approval'),
+ 'access' => $access,
'type' => MENU_LOCAL_TASK);
$items[] = array(
'path' => 'admin/content/comment/settings',
'title' => t('settings'),
- 'callback' => 'comment_admin_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('comment_admin_settings'),
'access' => $access,
'weight' => 10,
'type' => MENU_LOCAL_TASK);
@@ -133,7 +136,8 @@ function comment_menu($may_cache) {
$access = user_access('post comments');
$items[] = array('path' => 'comment/edit', 'title' => t('edit comment'),
- 'callback' => 'comment_edit', 'access' => $access, 'type' => MENU_CALLBACK);
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('comment_edit'), 'access' => $access, 'type' => MENU_CALLBACK);
}
else {
if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
@@ -466,7 +470,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 +500,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 +521,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 +557,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 +895,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 +920,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 +960,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' => $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 +969,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' => $comment->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 +1022,7 @@ function comment_admin_overview($type = 'new') {
'#prefix' => '<div class="container-inline">', '#suffix' => '</div>'
);
$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 +1051,7 @@ function comment_admin_overview($type = 'new') {
}
$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 +1144,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 +1429,11 @@ function comment_form($edit, $title = NULL) {
// 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 +1586,7 @@ function comment_controls($mode = COMMENT_MODE_THREADED_EXPANDED, $order = COMME
'#weight' => 20,
);
- return drupal_get_form('comment_controls', $form);
+ return $form;
}
function theme_comment_controls($form) {
@@ -1855,3 +1866,4 @@ function int2vancode($i = 0) {
function vancode2int($c = '00') {
return base_convert(substr($c, 1), 36, 10);
}
+
diff --git a/modules/contact/contact.module b/modules/contact/contact.module
index 5f7e88289..61d0aa743 100644
--- a/modules/contact/contact.module
+++ b/modules/contact/contact.module
@@ -64,33 +64,37 @@ function contact_menu($may_cache) {
);
$items[] = array('path' => 'admin/build/contact/add',
'title' => t('add category'),
- 'callback' => 'contact_admin_edit',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('contact_admin_edit'),
'access' => user_access('administer site configuration'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
$items[] = array('path' => 'admin/build/contact/edit',
'title' => t('edit contact category'),
- 'callback' => 'contact_admin_edit',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('contact_admin_edit'),
'access' => user_access('administer site configuration'),
'type' => MENU_CALLBACK,
);
$items[] = array('path' => 'admin/build/contact/delete',
'title' => t('delete contact'),
- 'callback' => 'contact_admin_delete',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('contact_admin_delete'),
'access' => user_access('administer site configuration'),
'type' => MENU_CALLBACK,
);
$items[] = array('path' => 'admin/build/contact/settings',
'title' => t('settings'),
- 'callback' => 'contact_admin_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('contact_admin_settings'),
'access' => user_access('administer site configuration'),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
$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 +104,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 +202,7 @@ function contact_admin_edit($cid = NULL) {
'#value' => t('Submit'),
);
- return drupal_get_form('contact_admin_edit', $form);
+ return $form;
}
/**
@@ -260,7 +263,7 @@ function contact_admin_delete($cid = NULL) {
'#value' => $info->category,
);
- return confirm_form('contact_admin_delete', $form, t('Are you sure you want to delete %category?', array('%category' => $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' => $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 +300,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 +318,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 .' &lt;'. $user->mail .'&gt;',
- );
- $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 +328,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 .' &lt;'. $user->mail .'&gt;',
+ );
+ $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 +409,85 @@ function contact_mail_user_submit($form_id, $edit) {
/**
* 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;
+}
+
+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' => $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),
- );
+ 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 +552,4 @@ function contact_mail_page_submit($form_id, $edit) {
// Jump to home page rather than back to contact page to avoid contradictory messages if flood control has been activated.
return('');
}
+
diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module
index 1e7d7fc5f..69c4ed569 100644
--- a/modules/drupal/drupal.module
+++ b/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_authentication_settings() {
'#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);
}
/**
@@ -350,12 +350,14 @@ function drupal_menu($may_cache) {
$items[] = array('path' => 'admin/settings/sites-registry',
'title' => t('sites registry'),
'description' => t('Register with another Drupal site (drupal.org by default) for statistics sharing, or set up your server to be a central server for registrations.'),
- 'callback' => 'drupal_sites_registry_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('drupal_sites_registry_settings'),
'access' => user_access('administer site configuration'));
$items[] = array('path' => 'admin/settings/distributed-authentication',
'title' => t('distributed authentication'),
'description' => t('Allow your site to accept logins from other Drupal sites such as drupal.org.'),
- 'callback' => 'drupal_distributed_authentication_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('drupal_distributed_authentication_settings'),
'access' => user_access('administer site configuration'));;
if (variable_get('drupal_authentication_service', 0)) {
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index d1fd22456..cc4b81a49 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -66,7 +66,8 @@ function filter_menu($may_cache) {
$items[] = array('path' => 'admin/settings/filters',
'title' => t('input formats'),
'description' => t('Configure how content input by users is filtering, including allowed HTML tags, PHP code tags. Also allows enabling of module-provided filters.'),
- 'callback' => 'filter_admin_overview',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('filter_admin_overview'),
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'admin/settings/filters/list',
@@ -77,14 +78,16 @@ function filter_menu($may_cache) {
);
$items[] = array('path' => 'admin/settings/filters/add',
'title' => t('add input format'),
- 'callback' => 'filter_admin_format_form',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('filter_admin_format_form'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'admin/settings/filters/delete',
'title' => t('delete input format'),
- 'callback' => 'filter_admin_delete',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('filter_admin_delete'),
'type' => MENU_CALLBACK,
'access' => user_access('administer filters'),
);
@@ -102,30 +105,31 @@ function filter_menu($may_cache) {
if (isset($formats[arg(3)])) {
$items[] = array('path' => 'admin/settings/filters/'. arg(3),
'title' => t("!format input format", array('!format' => $formats[arg(3)]->name)),
- 'callback' => 'filter_admin_format_form',
- 'callback arguments' => array('format' => $formats[arg(3)]),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('filter_admin_format_form', $formats[arg(3)]),
'type' => MENU_CALLBACK,
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'admin/settings/filters/'. arg(3) .'/list',
'title' => t('view'),
- 'callback' => 'filter_admin_format_form',
- 'callback arguments' => array('format' => $formats[arg(3)]),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('filter_admin_format_form', $formats[arg(3)]),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'admin/settings/filters/'. arg(3) .'/configure',
'title' => t('configure'),
- 'callback' => 'filter_admin_configure',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('filter_admin_configure'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'access' => user_access('administer filters'),
);
$items[] = array('path' => 'admin/settings/filters/'. arg(3) .'/order',
'title' => t('rearrange'),
- 'callback' => 'filter_admin_order',
- 'callback arguments' => array('format' => $formats[arg(3)]),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('filter_admin_order', 'format' => $formats[arg(3)]),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
'access' => user_access('administer filters'),
@@ -316,7 +320,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 +363,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' => $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' => $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 +444,6 @@ function filter_admin_format_form($format = NULL) {
'#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 +456,11 @@ function filter_admin_format_form($format = NULL) {
}
$group = t('<p>These are the guidelines that users will see for posting in this input format. They are automatically generated from the filter settings.</p>');
$group .= $tiplist;
- $output = '<h2>'. t('Formatting guidelines') .'</h2>'. $group;
+ $form['tips'] = array('#value' => '<h2>'. t('Formatting guidelines') .'</h2>'. $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 +551,7 @@ function filter_admin_order($format = NULL) {
$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 +602,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;
}
/**
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index ced6cffb3..9909bfdf7 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -64,17 +64,20 @@ function forum_menu($may_cache) {
'weight' => -10);
$items[] = array('path' => 'admin/content/forum/add/container',
'title' => t('add container'),
- 'callback' => 'forum_form_container',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('forum_form_container'),
'access' => user_access('administer forums'),
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/content/forum/add/forum',
'title' => t('add forum'),
- 'callback' => 'forum_form_forum',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('forum_form_forum'),
'access' => user_access('administer forums'),
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/content/forum/settings',
'title' => t('settings'),
- 'callback' => 'forum_admin_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('forum_admin_settings'),
'weight' => 5,
'access' => user_access('administer forums'),
'type' => MENU_LOCAL_TASK);
@@ -183,7 +186,6 @@ function forum_taxonomy($op, $type, $term = NULL) {
}
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 +208,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 +446,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 +482,9 @@ function forum_form_container($edit = array()) {
$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 +495,7 @@ function forum_form_container($edit = array()) {
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 +524,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 +564,13 @@ function forum_form_submit($form_id, $form_values) {
*
* @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' => $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' => $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'));
}
/**
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 767586429..555e4cafc 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -106,7 +106,8 @@ function locale_menu($may_cache) {
// Language related callbacks
$items[] = array('path' => 'admin/settings/locale/language/delete',
'title' => t('confirm'),
- 'callback' => 'locale_admin_manage_delete_form',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('locale_admin_manage_delete_form'),
'access' => $access,
'type' => MENU_CALLBACK);
}
@@ -314,7 +315,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 +339,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' => 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' => 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 +378,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 +401,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;
}
diff --git a/modules/menu/menu.module b/modules/menu/menu.module
index 8e6d42414..cac6dd2ee 100644
--- a/modules/menu/menu.module
+++ b/modules/menu/menu.module
@@ -61,14 +61,14 @@ function menu_menu($may_cache) {
$items[] = array('path' => 'admin/build/menu/item/add',
'title' => t('add menu item'),
- 'callback' => 'menu_edit_item_form',
- 'callback arguments' => array('add'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('menu_edit_item_form', 'add'),
'access' => user_access('administer menu'),
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/build/menu/item/edit',
'title' => t('edit menu item'),
- 'callback' => 'menu_edit_item_form',
- 'callback arguments' => array('edit'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('menu_edit_item_form', 'edit'),
'access' => user_access('administer menu'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/build/menu/item/reset',
@@ -83,31 +83,34 @@ function menu_menu($may_cache) {
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/build/menu/item/delete',
'title' => t('delete menu item'),
- 'callback' => 'menu_item_delete_form',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('menu_item_delete_form'),
'access' => user_access('administer menu'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/build/menu/menu/add',
'title' => t('add menu'),
- 'callback' => 'menu_edit_menu_form',
- 'callback arguments' => array('add'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('menu_edit_menu_form', 'add'),
'access' => user_access('administer menu'),
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/build/menu/menu/edit',
'title' => t('edit menu'),
- 'callback' => 'menu_edit_menu_form',
- 'callback arguments' => array('edit'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('menu_edit_menu_form', 'edit'),
'access' => user_access('administer menu'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/build/menu/menu/delete',
'title' => t('delete menu'),
- 'callback' => 'menu_item_delete_form',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('menu_item_delete_form'),
'access' => user_access('administer menu'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/build/menu/settings',
'title' => t('settings'),
- 'callback' => 'menu_configure',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('menu_configure'),
'type' => MENU_LOCAL_TASK,
'weight' => 5,
);
@@ -308,7 +311,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 +339,10 @@ function menu_edit_menu_form($type, $mid = 0) {
$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 +420,7 @@ function menu_edit_item_form($type, $mid = 0) {
$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 +451,13 @@ function menu_item_delete_form($mid) {
$message = t('Are you sure you want to delete the custom menu item %item?', array('%item' => $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 +479,7 @@ function menu_confirm_delete_form_submit($form_id, $form_values) {
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' => $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' => $title)), 'admin/build/menu', t('Any customizations will be lost. This action cannot be undone.'), t('Reset'));
}
else {
drupal_not_found();
@@ -485,7 +489,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.'));
diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc
index 95fc1f47c..0e6d05bc9 100644
--- a/modules/node/content_types.inc
+++ b/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;
}
/**
diff --git a/modules/node/node.module b/modules/node/node.module
index 907b9946c..919854f64 100644
--- a/modules/node/node.module
+++ b/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')
);
@@ -1023,7 +1023,8 @@ function node_menu($may_cache) {
'path' => 'admin/content/node-settings',
'title' => t('post settings'),
'description' => t('Control posting behavior, such as teaser length, requiring previews before posting, and the number of posts on the front page.'),
- 'callback' => 'node_configure',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('node_configure'),
'access' => user_access('administer nodes')
);
@@ -1043,7 +1044,8 @@ function node_menu($may_cache) {
$items[] = array(
'path' => 'admin/content/types/add',
'title' => t('add content type'),
- 'callback' => 'node_type_form',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('node_type_form'),
'type' => MENU_LOCAL_TASK,
);
@@ -1090,13 +1092,14 @@ function node_menu($may_cache) {
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10);
$items[] = array('path' => 'node/'. arg(1) .'/edit', 'title' => t('edit'),
- 'callback' => 'node_page_edit',
- 'callback arguments' => array($node),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('node_page_edit', $node),
'access' => node_access('update', $node),
'weight' => 1,
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'node/'. arg(1) .'/delete', 'title' => t('delete'),
- 'callback' => 'node_delete_confirm',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('node_delete_confirm'),
'access' => node_access('delete', $node),
'weight' => 1,
'type' => MENU_CALLBACK);
@@ -1125,15 +1128,15 @@ function node_menu($may_cache) {
$items[] = array(
'path' => 'admin/content/types/'. $type_url_str,
'title' => t($type->name),
- 'callback' => 'node_type_form',
- 'callback arguments' => array($type),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('node_type_form', $type),
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'admin/content/types/'. $type_url_str .'/delete',
'title' => t('delete'),
- 'callback' => 'node_type_delete',
- 'callback arguments' => array($type),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('node_type_delete', $type),
'type' => MENU_CALLBACK,
);
}
@@ -1143,7 +1146,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 +1315,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 .= '<div id="node-admin-filter">';
$output .= drupal_render($form['filters']);
$output .= '</div>';
@@ -1329,7 +1332,7 @@ function theme_node_filter_form(&$form) {
/**
* Theme node administraton filter selector.
*/
-function theme_node_filters(&$form) {
+function theme_node_filters($form) {
$output .= '<ul>';
if (sizeof($form['current'])) {
foreach (element_children($form['current']) as $key) {
@@ -1420,14 +1423,20 @@ function node_admin_nodes_validate($form_id, $edit) {
/**
* Menu callback: content administration.
*/
-function node_admin_nodes() {
- global $form_values;
- $output = node_filter_form();
+function node_admin_content() {
+ $output = drupal_get_form('node_filter_form');
if ($_POST['edit']['operation'] == 'delete' && $_POST['edit']['nodes']) {
return node_multiple_delete_confirm();
}
+ // Call the form first, to allow for the form_values array to be populated.
+ $output .= drupal_get_form('node_admin_nodes');
+
+ return $output;
+}
+function node_admin_nodes() {
+ global $form_values;
$filter = node_build_filter_query();
$result = pager_query('SELECT n.*, u.name, u.uid FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] .' ORDER BY n.changed DESC', 50, 0, NULL, $filter['args']);
@@ -1455,11 +1464,7 @@ function node_admin_nodes() {
}
$form['nodes'] = array('#type' => 'checkboxes', '#options' => $nodes);
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
-
- // Call the form first, to allow for the form_values array to be populated.
- $output .= drupal_get_form('node_admin_nodes', $form);
-
- return $output;
+ return $form;
}
/**
@@ -1508,7 +1513,7 @@ function node_multiple_delete_confirm() {
}
$form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
- return confirm_form('node_multiple_delete_confirm', $form,
+ return confirm_form($form,
t('Are you sure you want to delete these items?'),
'admin/content/node', t('This action cannot be undone.'),
t('Delete all'), t('Cancel'));
@@ -1644,8 +1649,7 @@ function node_revision_list($node) {
}
function node_admin_search() {
- $output = search_form(url('admin/content/search'), $_POST['edit']['keys'], 'node') . search_data($_POST['edit']['keys'], 'node');
- return $output;
+ return drupal_get_form('search_form', url('admin/content/search'), $_POST['edit']['keys'], 'node') . search_data($_POST['edit']['keys'], 'node');
}
/**
@@ -1851,18 +1855,10 @@ function node_object_prepare(&$node) {
}
/**
- * Generate the node editing form.
+ * Generate the node editing form array
*/
function node_form($node) {
$node = (object)$node;
- $form = node_form_array($node);
- return drupal_get_form($node->type .'_node_form', $form, 'node_form');
-}
-
-/**
- * Generate the node editing form array.
- */
-function node_form_array($node) {
node_object_prepare($node);
// Set the id of the top-level form tag
@@ -1930,9 +1926,8 @@ function node_form_array($node) {
if ($node->nid && node_access('delete', $node)) {
$form['delete'] = array('#type' => 'button', '#value' => t('Delete'), '#weight' => 50);
}
-
$form['#after_build'] = array('node_form_add_preview');
-
+ $form['#base'] = 'node_form';
return $form;
}
@@ -2007,7 +2002,7 @@ function node_add($type = NULL) {
// Initialize settings:
$node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type);
- $output = node_form($node);
+ $output = drupal_get_form($type .'_node_form', $node);
drupal_set_title(t('Submit @name', array('%name' => $types[$type]->name)));
}
else {
@@ -2155,7 +2150,7 @@ function node_delete_confirm() {
if (node_access('delete', $node)) {
$form['nid'] = array('#type' => 'value', '#value' => $node->nid);
- $output = confirm_form('node_delete_confirm', $form,
+ $output = confirm_form($form,
t('Are you sure you want to delete %title?', array('%title' => $node->title)),
$_GET['destination'] ? $_GET['destination'] : 'node/'. $node->nid, t('This action cannot be undone.'),
t('Delete'), t('Cancel') );
@@ -2317,7 +2312,7 @@ function node_page_edit($node) {
}
drupal_set_title(check_plain($node->title));
- return node_form($node);
+ return drupal_get_form($node->type . '_node_form', $node);
}
/**
@@ -2791,7 +2786,7 @@ function node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE)
}
}
-function node_access_rebuild_page() {
+function node_access_rebuild() {
$form['markup'] = array(
'#prefix' => '<p>',
'#value' => t('Rebuilding the node_access table is necessary immediately after uninstalling a module that utilizes the node_access system. Each node will have its access control recalculated. This may take a while if your site has many nodes.'),
@@ -2801,18 +2796,18 @@ function node_access_rebuild_page() {
'#type' => 'submit',
'#value' => t('Rebuild node access'),
);
- return drupal_get_form('node_access_rebuild', $form);
+ return $form;
}
/**
* rebuild the node access database
*/
function node_access_rebuild_submit() {
- node_access_rebuild();
+ _node_access_rebuild();
drupal_set_message(t('The node access table has been rebuilt.'));
}
-function node_access_rebuild() {
+function _node_access_rebuild() {
db_query("DELETE FROM {node_access}");
// only recalculate if site is using a node_access module
if (count(module_implements('node_grants'))) {
@@ -2891,3 +2886,12 @@ function node_content_form($node) {
* @} End of "defgroup node_content".
*/
+/**
+ * Implementation of hook_forms(). All node forms share the same form handler
+ */
+function node_forms() {
+ foreach (array_keys(node_get_types()) as $type) {
+ $forms[$type .'_node_form']['callback'] = 'node_form';
+ }
+ return $forms;
+}
diff --git a/modules/path/path.module b/modules/path/path.module
index 54f6ee771..5809c981d 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -55,17 +55,20 @@ function path_menu($may_cache) {
'callback' => 'path_admin',
'access' => user_access('administer url aliases'));
$items[] = array('path' => 'admin/build/path/edit', 'title' => t('edit alias'),
- 'callback' => 'path_admin_edit',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('path_admin_edit'),
'access' => user_access('administer url aliases'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/build/path/delete', 'title' => t('delete alias'),
- 'callback' => 'path_admin_delete_confirm',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('path_admin_delete_confirm'),
'access' => user_access('administer url aliases'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/build/path/list', 'title' => t('list'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'admin/build/path/add', 'title' => t('add alias'),
- 'callback' => 'path_admin_edit',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('path_admin_edit'),
'access' => user_access('administer url aliases'),
'type' => MENU_LOCAL_TASK);
}
@@ -103,7 +106,7 @@ function path_admin_delete_confirm($pid) {
$path = path_load($pid);
if (user_access('administer url aliases')) {
$form['pid'] = array('#type' => 'value', '#value' => $pid);
- $output = confirm_form('path_admin_delete_confirm', $form,
+ $output = confirm_form($form,
t('Are you sure you want to delete path alias %title?', array('%title' => $path['dst'])),
$_GET['destination'] ? $_GET['destination'] : 'admin/build/path', t('This action cannot be undone.'),
t('Delete'), t('Cancel') );
@@ -193,7 +196,7 @@ function path_form($edit = '') {
$form['submit'] = array('#type' => 'submit', '#value' => t('Create new alias'));
}
- return drupal_get_form('path_form', $form);
+ return $form;
}
/**
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 3162bbe33..02a72b8cb 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -131,6 +131,9 @@ function poll_form(&$node) {
$form['choice']['choices'] = array('#type' => 'hidden', '#default_value' => max(2, count($node->choice) ? count($node->choice) : 5));
$form['choice']['morechoices'] = array('#type' => 'checkbox', '#title' => t('Need more choices'), '#default_value' => 0, '#description' => t("If the amount of boxes above isn't enough, check this box and click the Preview button below to add some more."), '#weight' => 1);
+ // when building the whole form, #post is overwritten unconditionally,
+ // so no problems from setting by hand here for the local build
+ $form['choice']['#post'] = $_POST;
$form['choice'] = form_builder('poll_node_form', $form['choice']);
if ($form['choice']['morechoices']['#value']) {
$form['choice']['morechoices']['#value'] = 0;
@@ -321,11 +324,7 @@ function poll_teaser($node) {
/**
* Generates the voting form for a poll.
*/
-function poll_view_voting(&$node, $teaser, $page, $block) {
- if ($_POST['op'] == t('Vote')) {
- poll_vote($node);
- }
-
+function poll_view_voting($node, $page) {
if ($node->choice) {
$list = array();
foreach ($node->choice as $i => $choice) {
@@ -336,7 +335,7 @@ function poll_view_voting(&$node, $teaser, $page, $block) {
$form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
$form['vote'] = array('#type' => 'submit', '#value' => t('Vote'));
$form['#action'] = url('node/'. $node->nid);
- return drupal_get_form('poll_view_voting', $form);
+ return $form;
}
/**
@@ -391,10 +390,7 @@ function theme_poll_results($title, $results, $votes, $links, $block, $nid, $vot
$output .= $results;
$output .= '<div class="total">'. t('Total votes: %votes', array('%votes' => $votes)) .'</div>';
if (isset($vote) && $vote > -1 && user_access('cancel own vote')) {
- $form['#action'] = url("poll/cancel/$nid");
- $form['choice'] = array('#type' => 'hidden', '#value' => $vote);
- $form['submit'] = array('#type' => 'submit', '#value' => t('Cancel your vote'));
- $output .= drupal_get_form('poll_cancel_form', $form);
+ $output .= drupal_get_form('poll_cancel_form', $nid, $vote);
}
$output .= '</div>';
}
@@ -402,6 +398,13 @@ function theme_poll_results($title, $results, $votes, $links, $block, $nid, $vot
return $output;
}
+function poll_cancel_form($nid, $vote) {
+ $form['#action'] = url("poll/cancel/$nid");
+ $form['choice'] = array('#type' => 'hidden', '#value' => $vote);
+ $form['submit'] = array('#type' => 'submit', '#value' => t('Cancel your vote'));
+ return $form;
+}
+
function theme_poll_bar($title, $percentage, $votes, $block) {
if ($block) {
$output = '<div class="text">'. $title .'</div>';
@@ -563,8 +566,11 @@ function poll_view($node, $teaser = FALSE, $page = FALSE, $block = FALSE) {
}
if ($node->allowvotes && ($block || arg(2) != 'results')) {
+ if ($_POST['op'] == t('Vote')) {
+ poll_vote($node);
+ }
$node->content['body'] = array(
- '#value' => poll_view_voting($node, $teaser, $page, $block),
+ '#value' => drupal_get_form('poll_view_voting', $node, $page),
);
}
else {
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index 4ec71d4f1..bc40edb6d 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -65,7 +65,8 @@ function profile_menu($may_cache) {
'callback' => 'profile_admin_overview');
$items[] = array('path' => 'admin/user/profile/add',
'title' => t('add field'),
- 'callback' => 'profile_field_form',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('profile_field_form'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/user/profile/autocomplete',
'title' => t('profile category autocomplete'),
@@ -74,11 +75,13 @@ function profile_menu($may_cache) {
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/user/profile/edit',
'title' => t('edit field'),
- 'callback' => 'profile_field_form',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('profile_field_form'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/user/profile/delete',
'title' => t('delete field'),
- 'callback' => 'profile_field_delete',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('profile_field_delete'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'profile/autocomplete', 'title' => t('profile autocomplete'),
'callback' => 'profile_autocomplete',
@@ -296,7 +299,7 @@ Unless you know what you are doing, it is highly recommended that you prefix the
$form['submit'] = array('#type' => 'submit',
'#value' => t('Save field'),
);
- return drupal_get_form('profile_field_form', $form);
+ return $form;
}
/**
@@ -367,7 +370,10 @@ function profile_field_delete($fid) {
$form['fid'] = array('#type' => 'value', '#value' => $fid);
$form['title'] = array('#type' => 'value', '#value' => $field->title);
- return confirm_form('profile_field_delete', $form, t('Are you sure you want to delete the field %field?', array('%field' => $field->title)), 'admin/user/profile', t('This action cannot be undone. If users have entered values into this field in their profile, these entries will also be deleted. If you want to keep the user-entered data, instead of deleting the field you may wish to <a href="@edit-field">edit this field</a> and change it to a hidden profile field so that it may only be accessed by administrators.', array('@edit-field' => url('admin/user/profile/edit/' . $fid))), t('Delete'), t('Cancel'));
+ return confirm_form($form,
+ t('Are you sure you want to delete the field %field?', array('%field' => $field->title)), 'admin/user/profile',
+ t('This action cannot be undone. If users have entered values into this field in their profile, these entries will also be deleted. If you want to keep the user-entered data, instead of deleting the field you may wish to <a href="@edit-field">edit this field</a> and change it to a hidden profile field so that it may only be accessed by administrators.', array('@edit-field' => url('admin/user/profile/edit/' . $fid))),
+ t('Delete'), t('Cancel'));
}
/**
diff --git a/modules/search/search.module b/modules/search/search.module
index d9e17acce..8a4573b77 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -138,7 +138,7 @@ function search_block($op = 'list', $delta = 0) {
return $blocks;
}
else if ($op == 'view' && user_access('search content')) {
- $block['content'] = search_box('search_block_form');
+ $block['content'] = drupal_get_form('search_block_form');
$block['subject'] = t('Search');
return $block;
}
@@ -153,18 +153,21 @@ function search_menu($may_cache) {
if ($may_cache) {
$items[] = array('path' => 'search',
'title' => t('search settings'),
- 'callback' => 'search_view',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('search_view'),
'access' => user_access('search content'),
'type' => MENU_SUGGESTED_ITEM);
$items[] = array('path' => 'admin/settings/search',
'title' => t('search'),
'description' => t('Configure relevance settings for search and other indexing options'),
- 'callback' => 'search_admin_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('search_admin_settings'),
'access' => user_access('administer search'),
'type' => MENU_NORMAL_ITEM);
$items[] = array('path' => 'admin/settings/search/wipe',
'title' => t('clear index'),
- 'callback' => 'search_wipe_confirm',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('search_wipe_confirm'),
'access' => user_access('administer search'),
'type' => MENU_CALLBACK);
}
@@ -241,14 +244,14 @@ function search_admin_settings() {
// Per module settings
$form = array_merge($form, module_invoke_all('search', 'admin'));
- return system_settings_form('search_admin_settings', $form);
+ return system_settings_form($form);
}
/**
* Menu callback: confirm wiping of the index.
*/
function search_wipe_confirm() {
- return confirm_form('search_wipe_confirm', array(), t('Are you sure you want to re-index the site?'),
+ return confirm_form(array(), t('Are you sure you want to re-index the site?'),
'admin/settings/search', t(' The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed. This action cannot be undone.'), t('Re-index site'), t('Cancel'));
}
@@ -931,13 +934,13 @@ function search_view() {
}
// Construct the search form.
- $output = search_form(NULL, $keys, $type);
+ $output = drupal_get_form('search_form', NULL, $keys, $type);
$output .= $results;
return $output;
}
- return search_form(NULL, $keys, $type);
+ return drupal_get_form('search_form', NULL, $keys, $type);
}
/**
@@ -1010,7 +1013,7 @@ function search_form($action = '', $keys = '', $type = NULL, $prompt = NULL) {
$form['basic']['inline']['processed_keys'] = array('#type' => 'value', '#value' => array());
$form['basic']['inline']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
- return drupal_get_form('search_form', $form);
+ return $form;
}
/**
@@ -1040,7 +1043,7 @@ function search_form_submit($form_id, $form_values) {
/**
* Output a search form for the search block and the theme's search box.
*/
-function search_box($form_id = 'search_theme_form') {
+function search_box() {
// Use search_keys instead of keys to avoid ID conflicts with the search block.
$form[$form_id .'_keys'] = array(
'#type' => 'textfield',
@@ -1052,8 +1055,9 @@ function search_box($form_id = 'search_theme_form') {
// Always go to the search page since the search form is not guaranteed to be
// on every page.
$form['#action'] = url('search/node');
+ $form['#base'] = 'search_box_form';
- return drupal_get_form($form_id, $form, 'search_box_form');
+ return $form;
}
/**
@@ -1277,3 +1281,9 @@ function theme_search_page($results, $type) {
return $output;
}
+
+function search_forms() {
+ $forms['search_theme_form']['callback'] = 'search_box';
+ $forms['search_block_form']['callback'] = 'search_box';
+ return $forms;
+}
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index bed1cdbbf..1d468c413 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -152,7 +152,8 @@ function statistics_menu($may_cache) {
'path' => 'admin/logs/settings',
'title' => t('access log settings'),
'description' => t('Control details about what and how your site logs.'),
- 'callback' => 'statistics_access_logging_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('statistics_access_logging_settings'),
'access' => user_access('administer site configuration'),
'type' => MENU_NORMAL_ITEM
);
@@ -400,7 +401,7 @@ function statistics_access_logging_settings() {
'#options' => $options,
'#description' => t('Increment a counter each time content is viewed.'));
- return system_settings_form('statistics_access_logging_settings', $form);
+ return system_settings_form($form);
}
/**
diff --git a/modules/system/system.module b/modules/system/system.module
index 4f4e1033e..4b302109b 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -133,7 +133,8 @@ function system_menu($may_cache) {
'title' => t('administration theme'),
'description' => t('Settings for how your administrative pages should look.'),
'position' => 'left',
- 'callback' => 'system_admin_theme_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_admin_theme_settings'),
'block callback' => 'system_admin_theme_settings',
'access' => $access);
@@ -142,33 +143,40 @@ function system_menu($may_cache) {
'path' => 'admin/build/themes',
'title' => t('themes'),
'description' => t('Change which theme your site uses or allows users to set.'),
- 'callback' => 'system_themes', 'access' => $access);
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_themes'),
+ 'access' => $access);
$items[] = array(
'path' => 'admin/build/themes/select',
'title' => t('list'),
'description' => t('Select the default theme.'),
- 'callback' => 'system_themes',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_themes'),
'access' => $access,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -1);
$items[] = array('path' => 'admin/build/themes/settings',
'title' => t('configure'),
- 'callback' => 'system_theme_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_theme_settings'),
'access' => $access,
'type' => MENU_LOCAL_TASK);
// Theme configuration subtabs
$items[] = array('path' => 'admin/build/themes/settings/global', 'title' => t('global settings'),
- 'callback' => 'system_theme_settings', 'access' => $access,
- 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1);
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_theme_settings'),
+ 'access' => $access,
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -1);
foreach (list_themes() as $theme) {
if ($theme->status) {
$items[] = array('path' => 'admin/build/themes/settings/'. $theme->name, 'title' => $theme->name,
- 'callback' => 'system_theme_settings', 'callback arguments' => array($theme->name), 'access' => $access,
- 'type' => MENU_LOCAL_TASK);
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('system_theme_settings', $theme->name),
+ 'access' => $access, 'type' => MENU_LOCAL_TASK);
}
}
@@ -177,7 +185,8 @@ function system_menu($may_cache) {
'title' => t('modules'),
'description' => t('Enable or disable add-on modules for your site.'),
'weight' => -10,
- 'callback' => 'system_modules',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_modules'),
'access' => $access);
// Settings:
@@ -185,47 +194,56 @@ function system_menu($may_cache) {
'path' => 'admin/settings/site-information',
'title' => t('site information'),
'description' => t('Change basic site information, such as the site name, slogan, e-mail address, mission, front page and more.'),
- 'callback' => 'system_site_information_settings');
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_site_information_settings'));
$items[] = array(
'path' => 'admin/settings/error-reporting',
'title' => t('error reporting'),
'description' => t('Control how Drupal deals with errors including 403/404 erros as well as PHP error reporting.'),
- 'callback' => 'system_error_reporting_settings');
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_error_reporting_settings'));
$items[] = array(
'path' => 'admin/settings/page-caching',
'title' => t('page caching'),
'description' => t('Enable or disable page caching for anonymous users.'),
- 'callback' => 'system_page_caching_settings');
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_page_caching_settings'));
$items[] = array(
'path' => 'admin/settings/file-system',
'title' => t('file system'),
'description' => t('Tell Drupal where to store uploaded files and how they are accessed.'),
- 'callback' => 'system_file_system_settings');
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_file_system_settings'));
$items[] = array(
'path' => 'admin/settings/image-toolkit',
'title' => t('image toolkit'),
'description' => t('Choose which image toolkit to use if you have installed optional toolkits.'),
- 'callback' => 'system_image_toolkit_settings');
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_image_toolkit_settings'));
$items[] = array(
'path' => 'admin/content/rss-feed',
'title' => t('RSS feeds'),
'description' => t('Configure the number of items per feed and whether feeds should be titles/teasers/full-text.'),
- 'callback' => 'system_rss_feeds_settings');
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_rss_feeds_settings'));
$items[] = array(
'path' => 'admin/settings/date-time',
'title' => t('date and time'),
'description' => t('Settings for how Drupal displays date and time, as well as the system\'s default timezone.'),
- 'callback' => 'system_date_time_settings');
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_date_time_settings'));
$items[] = array(
'path' => 'admin/settings/site-status',
'title' => t('site status'),
'description' => t('Take the site off-line for maintenance or bring it back online.'),
- 'callback' => 'system_site_status_settings');
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_site_status_settings'));
$items[] = array(
'path' => 'admin/settings/unicode',
'title' => t('unicode'),
'description' => t('Unicode string handling settings.'),
- 'callback' => 'system_unicode_settings');
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_unicode_settings'));
$items[] = array(
'path' => 'admin/settings/cron-status',
'title' => t('cron status'),
@@ -235,7 +253,8 @@ function system_menu($may_cache) {
'path' => 'admin/settings/clean-urls',
'title' => t('clean URLs'),
'description' => t('Enable or disable clean URLs for your site.'),
- 'callback' => 'system_clean_url_settings');
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('system_clean_url_settings'));
}
else {
/**
@@ -366,8 +385,7 @@ function system_admin_theme_settings() {
// from being used. Also we want ours first.
$form['#submit']['system_admin_theme_submit'] = array();
$form['#submit']['system_settings_form_submit'] = array();
-
- return system_settings_form('system_admin_theme_form', $form);
+ return system_settings_form($form);
}
@@ -504,7 +522,7 @@ function system_site_information_settings() {
'#description' => t('The home page displays content from this relative URL. If you are not using clean URLs, specify the part after "?q=". If unsure, specify "node".')
);
- return system_settings_form('system_site_information_settings', $form);
+ return system_settings_form($form);
}
function system_clean_url_settings() {
@@ -528,7 +546,7 @@ function system_clean_url_settings() {
}
}
- return system_settings_form('system_clean_url_settings', $form);
+ return system_settings_form($form);
}
function system_error_reporting_settings() {
@@ -563,7 +581,7 @@ function system_error_reporting_settings() {
'#description' => t('The time log entries should be kept. Older entries will be automatically discarded. Requires crontab.')
);
- return system_settings_form('system_error_reporting_settings', $form);
+ return system_settings_form($form);
}
function system_page_caching_settings() {
@@ -586,7 +604,7 @@ function system_page_caching_settings() {
'#description' => t('Enabling the cache will offer a sufficient performance boost for most low-traffic and medium-traffic sites. On high-traffic sites it can become necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will go by before the cache is emptied and recreated. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.')
);
- return system_settings_form('system_page_caching_settings', $form);
+ return system_settings_form($form);
}
function system_file_system_settings() {
@@ -617,7 +635,7 @@ function system_file_system_settings() {
'#description' => t('If you want any sort of access control on the downloading of files, this needs to be set to <em>private</em>. You can change this at any time, however all download URLs will change and there may be unexpected problems so it is not recommended.')
);
- return system_settings_form('system_file_system_settings', $form);
+ return system_settings_form($form);
}
function system_image_toolkit_settings() {
@@ -630,10 +648,11 @@ function system_image_toolkit_settings() {
'#options' => $toolkits_available
);
- return system_settings_form('system_image_toolkit_settings', $form);
+ return system_settings_form($form);
}
else {
- return '<p>'. t("No image toolkits found. Drupal will use PHP's built-in GD library for image handling.") .'</p>';
+ $form['error'] = array('#value' => '<p>'. t("No image toolkits found. Drupal will use PHP's built-in GD library for image handling.") .'</p>');
+ return $form;
}
}
@@ -654,7 +673,7 @@ function system_rss_feeds_settings() {
'#description' => t('Global setting for the length of XML feed items that are output by default.')
);
- return system_settings_form('system_rss_feeds_settings', $form);
+ return system_settings_form($form);
}
function system_date_time_settings() {
@@ -732,7 +751,7 @@ function system_date_time_settings() {
'#description' => t('The first day of the week for calendar views.')
);
- return system_settings_form('system_date_time_settings', $form);
+ return system_settings_form($form);
}
function system_site_status_settings() {
@@ -752,11 +771,12 @@ function system_site_status_settings() {
'#description' => t('Message to show visitors when the site is in off-line mode.')
);
- return system_settings_form('system_site_status_settings', $form);
+ return system_settings_form($form);
}
function system_unicode_settings() {
- return system_settings_form('system_unicode_settings', unicode_settings());
+ $form = unicode_settings();
+ return system_settings_form($form);
}
function system_cron_status($cron = '') {
@@ -1029,16 +1049,18 @@ function system_initialize_theme_blocks($theme) {
}
}
-// Add the submit / reset buttons and run drupal_get_form()
-function system_settings_form($form_id, $form) {
+/**
+ * Add default buttons to a form and set its prefix
+ */
+function system_settings_form($form) {
$form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
$form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
if (!empty($_POST) && form_get_errors()) {
drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
}
-
- return drupal_get_form($form_id, $form, 'system_settings_form');
+ $form['#base'] = 'system_settings_form';
+ return $form;
}
function system_theme_settings_submit($form_id, $values) {
@@ -1122,7 +1144,7 @@ function system_themes() {
$form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
$form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
- return drupal_get_form('system_themes', $form);
+ return $form;
}
function theme_system_themes($form) {
@@ -1221,7 +1243,7 @@ function system_modules() {
$form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
- return drupal_get_form('system_modules', $form);
+ return $form;
}
function theme_system_modules($form) {
@@ -1491,22 +1513,20 @@ function system_theme_settings($key = '') {
}
$form['#attributes'] = array('enctype' => 'multipart/form-data');
- return system_settings_form('system_theme_settings', $form);
-
+ return system_settings_form($form);
}
/**
* Output a confirmation form
*
- * This function outputs a complete form for confirming an action. A link is
+ * This function returns a complete form for confirming an action. A link is
* offered to go back to the item that is being changed in case the user changes
* his/her mind.
*
- * You should use $GLOBALS['values']['edit'][$name] (where $name is usually 'confirm') to
- * check if the confirmation was successful.
+ * You can check for the existence of $_POST['edit'][$name] (where $name
+ * is usually 'confirm') to check if the confirmation was successful or
+ * use the regular submit model.
*
- * @param $form_id
- * The unique form identifier. Used by the form API to construct the theme.
* @param $form
* Additional elements to inject into the form, for example hidden elements.
* @param $question
@@ -1524,11 +1544,9 @@ function system_theme_settings($key = '') {
* @param $name
* The internal name used to refer to the confirmation item.
* @return
- * A themed HTML string representing the form.
+ * The form.
*/
-
-function confirm_form($form_id, $form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
-
+function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
$description = ($description) ? $description : t('This action cannot be undone.');
drupal_set_title($question);
$form['#attributes'] = array('class' => 'confirmation');
@@ -1538,7 +1556,8 @@ function confirm_form($form_id, $form, $question, $path, $description = NULL, $y
$form['actions'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $yes ? $yes : t('Confirm'));
$form['actions']['cancel'] = array('#value' => l($no ? $no : t('Cancel'), $path));
- return drupal_get_form($form_id, $form, 'confirm_form');
+ $form['#base'] = 'confirm_form';
+ return $form;
}
/**
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 6d2f05822..814a1a11b 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -260,7 +260,7 @@ function taxonomy_form_vocabulary($edit = array()) {
$form['vid'] = array('#type' => 'value', '#value' => $edit['vid']);
$form['module'] = array('#type' => 'value', '#value' => $edit['module']);
}
- return drupal_get_form('taxonomy_form_vocabulary', $form);
+ return $form;
}
/**
@@ -327,13 +327,13 @@ function taxonomy_del_vocabulary($vid) {
return SAVED_DELETED;
}
-function _taxonomy_confirm_del_vocabulary($vid) {
+function taxonomy_vocabulary_confirm_delete($vid) {
$vocabulary = taxonomy_get_vocabulary($vid);
$form['type'] = array('#type' => 'value', '#value' => 'vocabulary');
$form['vid'] = array('#type' => 'value', '#value' => $vid);
$form['name'] = array('#type' => 'value', '#value' => $vocabulary->name);
- return confirm_form('taxonomy_vocabulary_confirm_delete', $form,
+ return confirm_form($form,
t('Are you sure you want to delete the vocabulary %title?',
array('%title' => $vocabulary->name)),
'admin/content/taxonomy', t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'),
@@ -401,7 +401,7 @@ function taxonomy_form_term($edit = array()) {
$form['destination'] = array('#type' => 'hidden', '#value' => $_GET['q']);
}
- return drupal_get_form('taxonomy_form_term', $form);
+ return $form;
}
/**
@@ -513,13 +513,13 @@ function taxonomy_del_term($tid) {
return SAVED_DELETED;
}
-function _taxonomy_confirm_del_term($tid) {
+function taxonomy_term_confirm_delete($tid) {
$term = taxonomy_get_term($tid);
$form['type'] = array('#type' => 'value', '#value' => 'term');
$form['name'] = array('#type' => 'value', '#value' => $term->name);
$form['tid'] = array('#type' => 'value', '#value' => $tid);
- return confirm_form('taxonomy_term_confirm_delete', $form,
+ return confirm_form($form,
t('Are you sure you want to delete the term %title?',
array('%title' => $term->name)),
'admin/content/taxonomy',
@@ -1285,12 +1285,12 @@ function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
*/
function taxonomy_admin_vocabulary_edit($vid = NULL) {
if ($_POST['op'] == t('Delete') || $_POST['edit']['confirm']) {
- return _taxonomy_confirm_del_vocabulary($vid);
+ return taxonomy_vocabulary_confirm_delete($vid);
}
elseif ($vid) {
$vocabulary = (array)taxonomy_get_vocabulary($vid);
}
- return taxonomy_form_vocabulary($vocabulary);
+ return drupal_get_form('taxonomy_form_vocabulary', $vocabulary);
}
/**
@@ -1298,7 +1298,7 @@ function taxonomy_admin_vocabulary_edit($vid = NULL) {
*/
function taxonomy_admin_term_edit($tid = NULL) {
if ($_POST['op'] == t('Delete') || $_POST['edit']['confirm']) {
- return _taxonomy_confirm_del_term($tid);
+ return taxonomy_term_confirm_delete($tid);
}
elseif ($tid) {
$term = (array)taxonomy_get_term($tid);
diff --git a/modules/throttle/throttle.module b/modules/throttle/throttle.module
index 641ee0490..4707aa580 100644
--- a/modules/throttle/throttle.module
+++ b/modules/throttle/throttle.module
@@ -14,7 +14,8 @@ function throttle_menu($may_cache) {
'path' => 'admin/settings/throttle',
'description' => t('Control how your site cuts out content during heavy load.'),
'title' => t('throttle'),
- 'callback' => 'throttle_admin_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('throttle_admin_settings'),
'access' => user_access('administer site configuration'),
'type' => MENU_NORMAL_ITEM
);
@@ -168,5 +169,5 @@ function throttle_admin_settings() {
'#description' => t('The auto-throttle probability limiter is an efficiency mechanism to statistically reduce the overhead of the auto-throttle. The limiter is expressed as a percentage of page views, so for example if set to the default of 10% we only perform the extra database queries to update the throttle status 1 out of every 10 page views. The busier your site, the lower you should set the limiter value.')
);
- return system_settings_form('throttle_admin_settings', $form);
+ return system_settings_form($form);
}
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index bf1a130eb..38f1398da 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -81,7 +81,8 @@ function upload_menu($may_cache) {
$items[] = array('path' => 'admin/settings/uploads',
'title' => t('file uploads'),
'description' => t('Control how files may be attached to content.'),
- 'callback' => 'upload_admin_settings',
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('upload_admin_settings'),
'access' => user_access('administer site configuration'),
'type' => MENU_NORMAL_ITEM);
}
@@ -252,7 +253,7 @@ function upload_admin_settings() {
);
}
- return system_settings_form('upload_admin_settings', $form);
+ return system_settings_form($form);
}
function upload_download() {
diff --git a/modules/user/user.module b/modules/user/user.module
index 9f4ef44c3..5f74ca43c 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -469,6 +469,35 @@ function user_user($type, &$edit, &$user, $category = NULL) {
}
}
+function user_login_block() {
+ $form = array(
+ '#action' => url($_GET['q'], drupal_get_destination()),
+ '#id' => 'user-login-form',
+ '#base' => 'user_login',
+ );
+ $form['name'] = array('#type' => 'textfield',
+ '#title' => t('Username'),
+ '#maxlength' => 60,
+ '#size' => 15,
+ '#required' => TRUE,
+ );
+ $form['pass'] = array('#type' => 'password',
+ '#title' => t('Password'),
+ '#size' => 15,
+ '#required' => TRUE,
+ );
+ $form['submit'] = array('#type' => 'submit',
+ '#value' => t('Log in'),
+ );
+ $items = array();
+ if (variable_get('user_register', 1)) {
+ $items[] = l(t('Create new account'), 'user/register', array('title' => t('Create a new user account.')));
+ }
+ $items[] = l(t('Request new password'), 'user/password', array('title' => t('Request new password via e-mail.')));
+ $form['links'] = array('#value' => theme('item_list', $items));
+ return $form;
+}
+
/**
* Implementation of hook_block().
*/
@@ -501,31 +530,9 @@ function user_block($op = 'list', $delta = 0, $edit = array()) {
case 0:
// For usability's sake, avoid showing two login forms on one page.
if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) {
- $form['#action'] = url($_GET['q'], drupal_get_destination());
- $form['#id'] = 'user-login-form';
- $form['name'] = array('#type' => 'textfield',
- '#title' => t('Username'),
- '#maxlength' => 60,
- '#size' => 15,
- '#required' => TRUE,
- );
- $form['pass'] = array('#type' => 'password',
- '#title' => t('Password'),
- '#size' => 15,
- '#required' => TRUE,
- );
- $form['submit'] = array('#type' => 'submit',
- '#value' => t('Log in'),
- );
-
- if (variable_get('user_register', 1)) {
- $items[] = l(t('Create new account'), 'user/register', array('title' => t('Create a new user account.')));
- }
- $items[] = l(t('Request new password'), 'user/password', array('title' => t('Request new password via e-mail.')));
- $form['links'] = array('#value' => theme('item_list', $items));
$block['subject'] = t('User login');
- $block['content'] = drupal_get_form('user_login_block', $form, 'user_login');
+ $block['content'] = drupal_get_form('user_login_block');
}
return $block;
@@ -670,20 +677,20 @@ function user_menu($may_cache) {
if ($may_cache) {
$items[] = array('path' => 'user', 'title' => t('user account'),
- 'callback' => 'user_login', 'access' => TRUE, 'type' => MENU_CALLBACK);
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('user_login'), 'access' => TRUE, 'type' => MENU_CALLBACK);
$items[] = array('path' => 'user/autocomplete', 'title' => t('user autocomplete'),
'callback' => 'user_autocomplete', 'access' => $view_access, 'type' => MENU_CALLBACK);
// Registration and login pages.
$items[] = array('path' => 'user/login', 'title' => t('log in'),
- 'callback' => 'user_login', 'type' => MENU_DEFAULT_LOCAL_TASK);
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('user_login'), 'type' => MENU_DEFAULT_LOCAL_TASK);
$items[] = array('path' => 'user/register', 'title' => t('create new account'),
- 'callback' => 'user_register', 'access' => $user->uid == 0 && variable_get('user_register', 1), 'type' => MENU_LOCAL_TASK);
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('user_register'), 'access' => $user->uid == 0 && variable_get('user_register', 1), 'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'user/password', 'title' => t('request new password'),
- 'callback' => 'user_pass', 'access' => $user->uid == 0, 'type' => MENU_LOCAL_TASK);
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('user_pass'), 'access' => $user->uid == 0, 'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'user/reset', 'title' => t('reset password'),
- 'callback' => 'user_pass_reset', 'access' => TRUE, 'type' => MENU_CALLBACK);
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('user_pass_reset'), 'access' => TRUE, 'type' => MENU_CALLBACK);
$items[] = array('path' => 'user/help', 'title' => t('help'),
'callback' => 'user_help_page', 'type' => MENU_CALLBACK);
@@ -705,18 +712,18 @@ function user_menu($may_cache) {
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/user/settings', 'title' => t('user settings'),
'description' => t('Configure default behavior of users, including registration requirements, e-mails, and user pictures.'),
- 'callback' => 'user_admin_settings');
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_settings'));
// Admin access pages
$items[] = array('path' => 'admin/user/access', 'title' => t('access control'),
'description' => t('Determine access to features by selecting permissions for roles.'),
- 'callback' => 'user_admin_perm', 'access' => $access_access);
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_perm'), 'access' => $access_access);
$items[] = array('path' => 'admin/user/roles', 'title' => t('roles'),
'description' => t('List, edit, or add user roles.'),
- 'callback' => 'user_admin_role', 'access' => $access_access,
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_role'), 'access' => $access_access,
'type' => MENU_NORMAL_ITEM);
$items[] = array('path' => 'admin/user/roles/edit', 'title' => t('edit role'),
- 'callback' => 'user_admin_role', 'access' => $access_access,
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_role'), 'access' => $access_access,
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/user/rules', 'title' => t('access rules'),
'description' => t('List and create rules to disallow usernames, e-mail addresses, and IP addresses.'),
@@ -733,8 +740,8 @@ function user_menu($may_cache) {
'callback' => 'user_admin_access_edit', 'access' => $access_access,
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/user/rules/delete', 'title' => t('delete rule'),
- 'callback' => 'user_admin_access_delete', 'access' => $access_access,
- 'type' => MENU_CALLBACK);
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_access_delete_confirm'),
+ 'access' => $access_access, 'type' => MENU_CALLBACK);
if (module_exist('search')) {
$items[] = array('path' => 'admin/user/search', 'title' => t('search users'),
@@ -777,8 +784,8 @@ function user_menu($may_cache) {
'access' => $view_access, 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
$items[] = array('path' => 'user/'. arg(1) .'/edit', 'title' => t('edit'),
- 'callback' => 'user_edit', 'access' => $admin_access || $user->uid == arg(1),
- 'type' => MENU_LOCAL_TASK);
+ 'callback' => 'drupal_get_form', 'callback arguments' => array('user_edit'),
+ 'access' => $admin_access || $user->uid == arg(1), 'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'user/'. arg(1) .'/delete', 'title' => t('delete'),
'callback' => 'user_edit', 'access' => $admin_access,
'type' => MENU_CALLBACK);
@@ -880,7 +887,7 @@ function user_login($msg = '') {
'#attributes' => array('tabindex' => '2'),
);
$form['submit'] = array('#type' => 'submit', '#value' => t('Log in'), '#weight' => 2, '#attributes' => array('tabindex' => '3'));
- return drupal_get_form('user_login', $form);
+ return $form;
}
function user_login_validate($form_id, $form_values) {
@@ -1012,7 +1019,7 @@ function user_pass() {
'#value' => t('E-mail new password'),
'#weight' => 2,
);
- return drupal_get_form('user_pass', $form);
+ return $form;
}
function user_pass_validate() {
@@ -1102,7 +1109,7 @@ function user_pass_reset($uid, $timestamp, $hashed_pass, $action = NULL) {
$form['help'] = array('#value' => t('<p>This login can be used only once.</p>'));
$form['submit'] = array('#type' => 'submit', '#value' => t('Log in'));
$form['#action'] = url("user/reset/$uid/$timestamp/$hashed_pass/login");
- return drupal_get_form('user_pass_reset', $form);
+ return $form;
}
}
else {
@@ -1178,7 +1185,7 @@ function user_register() {
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Create new account'), '#weight' => 30);
- return drupal_get_form('user_register', $form);
+ return $form;
}
function user_register_validate($form_id, $form_values) {
@@ -1187,7 +1194,6 @@ function user_register_validate($form_id, $form_values) {
function user_register_submit($form_id, $form_values) {
global $base_url;
-
$admin = user_access('administer users');
$mail = $form_values['mail'];
@@ -1386,7 +1392,7 @@ function user_edit($category = 'account') {
drupal_goto('admin/user/user');
}
else {
- return confirm_form('user_confirm_delete', array(), t('Are you sure you want to delete the account %name?', array('%name' => $account->name)), 'user/'. $account->uid, t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.'), t('Delete'), t('Cancel'));
+ return drupal_get_form('user_confirm_delete', $name, $uid);
}
}
else if ($_POST['op'] == t('Delete')) {
@@ -1408,7 +1414,15 @@ function user_edit($category = 'account') {
$form['#attributes']['enctype'] = 'multipart/form-data';
drupal_set_title($account->name);
- return drupal_get_form('user_edit', $form);
+ return $form;
+}
+
+function user_confirm_delete($name, $uid) {
+ return confirm_form(array(),
+ t('Are you sure you want to delete the account %name?', array('%name' => $name)),
+ 'user/'. $uid,
+ t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.'),
+ t('Delete'), t('Cancel'));
}
/**
@@ -1515,31 +1529,40 @@ function _user_mail_text($messageid, $variables = array()) {
}
}
-/**
- * Menu callback: check an access rule
- */
-function user_admin_access_check() {
+function user_admin_check_user() {
$form['user'] = array('#type' => 'fieldset', '#title' => t('Username'));
$form['user']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter a username to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64);
$form['user']['type'] = array('#type' => 'hidden', '#value' => 'user');
$form['user']['submit'] = array('#type' => 'submit', '#value' => t('Check username'));
- $output .= drupal_get_form('check_user', $form, 'user_admin_access_check');
- unset($form); // prevent endless loop?
+ $form['#base'] = 'user_admin_access_check';
+ return $form;
+}
+function user_admin_check_mail() {
$form['mail'] = array('#type' => 'fieldset', '#title' => t('E-mail'));
$form['mail']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter an e-mail address to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64);
$form['mail']['type'] = array('#type' => 'hidden', '#value' => 'mail');
$form['mail']['submit'] = array('#type' => 'submit', '#value' => t('Check e-mail'));
- $output .= drupal_get_form('check_mail', $form, 'user_admin_access_check');
- unset($form); // prevent endless loop?
+ $form['#base'] = 'user_admin_access_check';
+ return $form;
+}
+function user_admin_check_host() {
$form['host'] = array('#type' => 'fieldset', '#title' => t('Hostname'));
$form['host']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter a hostname or IP address to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64);
$form['host']['type'] = array('#type' => 'hidden', '#value' => 'host');
$form['host']['submit'] = array('#type' => 'submit', '#value' => t('Check hostname'));
- $output .= drupal_get_form('check_host', $form, 'user_admin_access_check');
- unset($form); // prevent endless loop?
+ $form['#base'] = 'user_admin_access_check';
+ return $form;
+}
+/**
+ * Menu callback: check an access rule
+ */
+function user_admin_access_check() {
+ $output = drupal_get_form('user_admin_check_user');
+ $output .= drupal_get_form('user_admin_check_mail');
+ $output .= drupal_get_form('user_admin_check_host');
return $output;
}
@@ -1599,23 +1622,19 @@ function user_admin_access_add($mask = NULL, $type = NULL) {
$edit['mask'] = $mask;
$edit['type'] = $type;
}
-
- $form = _user_admin_access_form($edit);
- $form['submit'] = array('#type' => 'submit', '#value' => t('Add rule'));
-
- return drupal_get_form('access_rule', $form);
+ return drupal_get_form('user_admin_access_add_form', $edit, t('Add rule'));
}
/**
* Menu callback: delete an access rule
*/
-function user_admin_access_delete($aid = 0) {
+function user_admin_access_delete_confirm($aid = 0) {
$access_types = array('user' => t('username'), 'mail' => t('e-mail'));
$edit = db_fetch_object(db_query('SELECT aid, type, status, mask FROM {access} WHERE aid = %d', $aid));
$form = array();
$form['aid'] = array('#type' => 'hidden', '#value' => $aid);
- $output = confirm_form('user_admin_access_delete_confirm', $form,
+ $output = confirm_form($form,
t('Are you sure you want to delete the @type rule for %rule?', array('@type' => $access_types[$edit->type], '%rule' => $edit->mask)),
'admin/user/rules',
t('This action cannot be undone.'),
@@ -1647,13 +1666,10 @@ function user_admin_access_edit($aid = 0) {
else {
$edit = db_fetch_array(db_query('SELECT aid, type, status, mask FROM {access} WHERE aid = %d', $aid));
}
- $form = _user_admin_access_form($edit);
- $form['submit'] = array('#type' => 'submit', '#value' => t('Save rule'));
-
- return drupal_get_form('access_rule', $form);
+ return drupal_get_form('user_admin_access_edit_form', $edit, t('Save rule'));
}
-function _user_admin_access_form($edit) {
+function user_admin_access_form($edit, $submit) {
$form['status'] = array(
'#type' => 'radios',
'#title' => t('Access type'),
@@ -1676,6 +1692,8 @@ function _user_admin_access_form($edit) {
'#description' => '%: '. t('Matches any number of characters, even zero characters') .'.<br />_: '. t('Matches exactly one character.'),
'#required' => TRUE,
);
+ $form['submit'] = array('#type' => 'submit', '#value' => $submit);
+
return $form;
}
@@ -1787,7 +1805,7 @@ function user_admin_perm($str_rids = NULL) {
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Save permissions'));
- return drupal_get_form('user_admin_perm', $form);
+ return $form;
}
function theme_user_admin_perm($form) {
@@ -1891,11 +1909,12 @@ function user_admin_role() {
$form['name'] = array('#type' => 'textfield', '#title' => t('Role name'), '#default_value' => $role->name, '#size' => 30, '#maxlength' => 64, '#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'));
$form['submit'] = array('#type' => 'submit', '#value' => t('Save role'));
$form['delete'] = array('#type' => 'submit', '#value' => t('Delete role'));
- return drupal_get_form('user_admin_role', $form);
+
+ return $form;
}
$form['name'] = array('#type' => 'textfield', '#size' => 32, '#maxlength' => 64);
$form['submit'] = array('#type' => 'submit', '#value' => t('Add role'));
- return drupal_get_form('user_admin_new_role', $form);
+ return $form;
}
function theme_user_admin_new_role($form) {
@@ -1982,10 +2001,7 @@ function user_admin_account() {
);
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
- // Call the form first, to allow for the form_values array to be populated.
- $output .= drupal_get_form('user_admin_account', $form);
-
- return $output;
+ return $form;
}
/**
@@ -2162,7 +2178,7 @@ function user_multiple_delete_confirm() {
}
$form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
- return confirm_form('user_multiple_delete_confirm', $form,
+ return confirm_form($form,
t('Are you sure you want to delete these users?'),
'admin/user/user', t('This action cannot be undone.'),
t('Delete all'), t('Cancel'));
@@ -2210,7 +2226,7 @@ function user_admin_settings() {
$form['pictures']['user_picture_file_size'] = array('#type' => 'textfield', '#title' => t('Picture maximum file size'), '#default_value' => variable_get('user_picture_file_size', '30'), '#size' => 15, '#maxlength' => 10, '#description' => t('Maximum file size for pictures, in kB.'));
$form['pictures']['user_picture_guidelines'] = array('#type' => 'textarea', '#title' => t('Picture guidelines'), '#default_value' => variable_get('user_picture_guidelines', ''), '#description' => t('This text is displayed at the picture upload form in addition to the default guidelines. It\'s useful for helping or instructing your users.'));
- return system_settings_form('user_admin_settings', $form);
+ return system_settings_form($form);
}
function user_admin($callback_arg = '') {
@@ -2220,14 +2236,14 @@ function user_admin($callback_arg = '') {
switch ($op) {
case 'search':
case t('Search'):
- $output = search_form(url('admin/user/search'), $_POST['edit']['keys'], 'user') . search_data($_POST['edit']['keys'], 'user');
+ $output = drupal_get_form('search_form', url('admin/user/search'), $_POST['edit']['keys'], 'user') . search_data($_POST['edit']['keys'], 'user');
break;
case t('Create new account'):
case 'create':
- $output = user_register();
+ $output = drupal_get_form('user_register');
break;
default:
- $output = user_admin_account();
+ $output = drupal_get_form('user_admin_account');
}
return $output;
}
@@ -2462,7 +2478,7 @@ function user_filter_form() {
);
}
- return drupal_get_form('user_filter_form', $form);
+ return $form;
}
/**
@@ -2537,3 +2553,11 @@ function user_filter_form_submit($form_id, $form_values) {
return 'admin/user/user';
}
+
+function user_forms() {
+ $forms['user_admin_access_add_form']['callback'] = 'user_admin_access_form';+
+ $forms['user_admin_access_edit_form']['callback'] = 'user_admin_access_form';
+ $forms['user_admin_new_role']['callback'] = 'user_admin_role';
+ return $forms;
+}
+
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index ec33bb9d9..f93a2cd2a 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/watchdog.module
@@ -83,10 +83,7 @@ function watchdog_user($op, &$edit, &$user) {
}
}
-/**
- * Menu callback; displays a listing of log messages.
- */
-function watchdog_overview() {
+function watchdog_form_overview() {
$icons = array(WATCHDOG_NOTICE => '',
WATCHDOG_WARNING => theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')),
WATCHDOG_ERROR => theme('image', 'misc/watchdog-error.png', t('error'), t('error')));
@@ -107,10 +104,16 @@ function watchdog_overview() {
'#options' => $names,
'#default_value' => $_SESSION['watchdog_overview_filter']
);
- $form['#action'] = url('admin/logs');
-
$form['submit'] = array('#type' => 'submit', '#value' =>t('Filter'));
- $output = drupal_get_form('watchdog_form_overview', $form);
+ $form['#redirect'] = FALSE;
+
+ return $form;
+}
+/**
+ * Menu callback; displays a listing of log messages.
+ */
+function watchdog_overview() {
+ $output = drupal_get_form('watchdog_form_overview');
$header = array(
' ',
diff --git a/themes/engines/phptemplate/phptemplate.engine b/themes/engines/phptemplate/phptemplate.engine
index 5b39ab229..6b503a782 100644
--- a/themes/engines/phptemplate/phptemplate.engine
+++ b/themes/engines/phptemplate/phptemplate.engine
@@ -206,7 +206,7 @@ function phptemplate_page($content) {
'messages' => theme('status_messages'),
'mission' => isset($mission) ? $mission : '',
'primary_links' => menu_primary_links(),
- 'search_box' => (theme_get_setting('toggle_search') ? search_box() : ''),
+ 'search_box' => (theme_get_setting('toggle_search') ? drupal_get_form('search_theme_form') : ''),
'secondary_links' => menu_secondary_links(),
'sidebar_left' => $sidebar_left,
'sidebar_right' => $sidebar_right,
diff --git a/update.php b/update.php
index 039e882ac..5e4454fee 100644
--- a/update.php
+++ b/update.php
@@ -320,6 +320,15 @@ function update_selection_page() {
$output = '<p>The version of Drupal you are updating from has been automatically detected. You can select a different version, but you should not need to.</p>';
$output .= '<p>Click Update to start the update process.</p>';
+ 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,
@@ -363,13 +372,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() {