- Patch #518750 by Damien Tournoud: rethink system settings form.

merge-requests/26/head
Dries Buytaert 2009-07-16 10:44:21 +00:00
parent 436fc4f879
commit 44740785fe
6 changed files with 30 additions and 70 deletions

View File

@ -293,8 +293,7 @@ function color_scheme_form_submit($form, &$form_state) {
}
// Don't render the default colorscheme, use the standard theme instead.
if (implode(',', color_get_palette($theme, TRUE)) == implode(',', $palette)
|| $form_state['values']['op'] == t('Reset to defaults')) {
if (implode(',', color_get_palette($theme, TRUE)) == implode(',', $palette)) {
variable_del('color_' . $theme . '_palette');
variable_del('color_' . $theme . '_stylesheets');
variable_del('color_' . $theme . '_logo');

View File

@ -229,13 +229,6 @@ function node_type_form(&$form_state, $type = NULL) {
);
}
}
else {
$form['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset to defaults'),
'#weight' => 50,
);
}
return $form;
}
@ -310,10 +303,7 @@ function node_type_form_submit($form, &$form_state) {
$type->modified = TRUE;
$type->locked = $form_state['values']['locked'];
if ($op == t('Reset to defaults')) {
node_type_reset($type);
}
elseif ($op == t('Delete content type')) {
if ($op == t('Delete content type')) {
$form_state['redirect'] = 'admin/build/node-type/' . str_replace('_', '-', $type->old_type) . '/delete';
return;
}
@ -337,10 +327,6 @@ function node_type_form_submit($form, &$form_state) {
$variable_new = $key . '_' . $type->type;
$variable_old = $key . '_' . $type->old_type;
if ($op == t('Reset to defaults')) {
variable_del($variable_old);
}
else {
if (is_array($value)) {
$value = array_keys(array_filter($value));
}
@ -350,16 +336,10 @@ function node_type_form_submit($form, &$form_state) {
variable_del($variable_old);
}
}
}
node_types_rebuild();
$t_args = array('%name' => $type->name);
if ($op == t('Reset to defaults')) {
drupal_set_message(t('The content type %name has been reset to its default values.', $t_args));
return;
}
if ($status == SAVED_UPDATED) {
drupal_set_message(t('The content type %name has been updated.', $t_args));
}

View File

@ -227,10 +227,6 @@ function system_themes_form() {
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$form['buttons']['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset to defaults'),
);
return $form;
}
@ -513,16 +509,10 @@ function system_theme_settings_submit($form, &$form_state) {
$values = $form_state['values'];
$key = $values['var'];
if ($values['op'] == t('Reset to defaults')) {
variable_del($key);
drupal_set_message(t('The configuration options have been reset to their default values.'));
}
else {
// Exclude unnecessary elements before saving.
unset($values['var'], $values['submit'], $values['reset'], $values['form_id'], $values['op'], $values['form_build_id'], $values['form_token']);
variable_set($key, $values);
drupal_set_message(t('The configuration options have been saved.'));
}
cache_clear_all();
}

View File

@ -2033,7 +2033,6 @@ function _system_settings_form_automatic_defaults($form) {
*/
function system_settings_form($form, $automatic_defaults = TRUE) {
$form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
$form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
if ($automatic_defaults) {
$form = _system_settings_form_automatic_defaults($form);
@ -2060,22 +2059,13 @@ function system_settings_form_submit($form, &$form_state) {
unset($form_state['values']['submit'], $form_state['values']['reset'], $form_state['values']['form_id'], $form_state['values']['op'], $form_state['values']['form_token'], $form_state['values']['form_build_id']);
foreach ($form_state['values'] as $key => $value) {
if ($op == t('Reset to defaults')) {
variable_del($key);
}
else {
if (is_array($value) && isset($form_state['values']['array_filter'])) {
$value = array_keys(array_filter($value));
}
variable_set($key, $value);
}
}
if ($op == t('Reset to defaults')) {
drupal_set_message(t('The configuration options have been reset to their default values.'));
}
else {
drupal_set_message(t('The configuration options have been saved.'));
}
cache_clear_all();
drupal_theme_rebuild();

View File

@ -539,7 +539,7 @@ class AccessDeniedTestCase extends DrupalWebTestCase {
// Log back in and remove the custom 403 page.
$this->drupalLogin($this->admin_user);
$this->drupalPost('admin/settings/site-information', array(), t('Reset to defaults'));
$this->drupalPost('admin/settings/site-information', array('site_403' => ''), t('Save configuration'));
// Logout and check that the user login block is shown on default 403 pages.
$this->drupalLogout();
@ -600,7 +600,7 @@ class PageNotFoundTestCase extends DrupalWebTestCase {
// Log back in and remove the custom 404 page.
$this->drupalLogin($this->admin_user);
$this->drupalPost('admin/settings/site-information', array(), t('Reset to defaults'));
$this->drupalPost('admin/settings/site-information', array('site_404' => ''), t('Save configuration'));
// Logout and check that the user login block is not shown on default 404 pages.
$this->drupalLogout();
@ -961,7 +961,12 @@ class SystemThemeFunctionalTest extends DrupalWebTestCase {
$this->assertRaw('themes/stark', t('Site default theme used on the add content page.'));
// Reset to the default theme settings.
$this->drupalPost('admin/build/themes', array(), t('Reset to defaults'));
$edit = array(
'theme_default' => 'garland',
'admin_theme' => '0',
'node_admin_theme' => FALSE,
);
$this->drupalPost('admin/build/themes', $edit, t('Save configuration'));
$this->drupalGet('admin');
$this->assertRaw('themes/garland', t('Site default theme used on administration page.'));

View File

@ -91,10 +91,6 @@ function update_settings_validate($form, &$form_state) {
function update_settings_submit($form, $form_state) {
$op = $form_state['values']['op'];
if ($op == t('Reset to defaults')) {
unset($form_state['notify_emails']);
}
else {
if (empty($form_state['notify_emails'])) {
variable_del('update_notify_emails');
}
@ -103,6 +99,6 @@ function update_settings_submit($form, $form_state) {
}
unset($form_state['notify_emails']);
unset($form_state['values']['update_notify_emails']);
}
system_settings_form_submit($form, $form_state);
}