? includes/database/install.inc
? sites/all/modules/cvs
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.321
diff -u -p -r1.321 block.module
--- modules/block/block.module	3 Feb 2009 12:30:14 -0000	1.321
+++ modules/block/block.module	11 Feb 2009 02:07:27 -0000
@@ -176,7 +176,7 @@ function block_menu() {
  * Menu item access callback - only admin or enabled themes can be accessed.
  */
 function _block_themes_access($theme) {
-  return user_access('administer blocks') && ($theme->status || $theme->name == variable_get('admin_theme', '0'));
+  return user_access('administer blocks') && ($theme->status || $theme->name == variable_get('admin_theme', 0));
 }
 
 /**
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.124
diff -u -p -r1.124 system.admin.inc
--- modules/system/system.admin.inc	3 Feb 2009 18:55:31 -0000	1.124
+++ modules/system/system.admin.inc	11 Feb 2009 02:07:33 -0000
@@ -133,51 +133,15 @@ function system_settings_overview() {
 }
 
 /**
- * Form builder; This function allows selection of the theme to show in administration sections.
- *
- * @ingroup forms
- * @see system_settings_form()
- */
-function system_admin_theme_settings() {
-  $themes = system_theme_data();
-
-  uasort($themes, 'system_sort_modules_by_info_name');
-
-  $options[0] = '<' . t('System default') . '>';
-  foreach ($themes as $theme) {
-    $options[$theme->name] = $theme->info['name'];
-  }
-
-  $form['admin_theme'] = array(
-    '#type' => 'select',
-    '#options' => $options,
-    '#title' => t('Administration theme'),
-    '#description' => t('Choose which theme the administration pages should display in. If you choose "System default" the administration pages will use the same theme as the rest of the site.'),
-    '#default_value' => '0',
-  );
-
-  $form['node_admin_theme'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Use administration theme for content editing'),
-    '#description' => t('Use the administration theme when editing existing posts or creating new ones.'),
-    '#default_value' => '0',
-  );
-
-  $form['#submit'][] = 'system_admin_theme_submit';
-  return system_settings_form($form, TRUE);
-}
-
-/**
  * Menu callback; displays a listing of all themes.
  *
  * @ingroup forms
  * @see system_themes_form_submit()
  */
 function system_themes_form() {
-
   drupal_clear_css_cache();
-  $themes = system_theme_data();
 
+  $themes = system_theme_data();
   uasort($themes, 'system_sort_modules_by_info_name');
 
   $status = array();
@@ -201,9 +165,9 @@ function system_themes_form() {
       '#type' => 'value',
       '#value' => $theme->info,
     );
-    $options[$theme->name] = '';
+    $options[$theme->name] = $theme->info['name'];
 
-    if (!empty($theme->status) || $theme->name == variable_get('admin_theme', '0')) {
+    if (!empty($theme->status) || $theme->name == variable_get('admin_theme', 0)) {
       $form[$theme->name]['operations'] = array('#markup' => l(t('configure'), 'admin/build/themes/settings/' . $theme->name) );
     }
     else {
@@ -226,16 +190,38 @@ function system_themes_form() {
 
   $form['status'] = array(
     '#type' => 'checkboxes',
-    '#options' => $options,
+    '#options' => array_fill_keys(array_keys($options), ''),
     '#default_value' => $status,
     '#incompatible_themes_core' => drupal_map_assoc($incompatible_core),
     '#incompatible_themes_php' => $incompatible_php,
   );
   $form['theme_default'] = array(
     '#type' => 'radios',
-    '#options' => $options,
+    '#options' => array_fill_keys(array_keys($options), ''),
     '#default_value' => variable_get('theme_default', 'garland'),
   );
+
+  // Administration theme settings.
+  $form['admin_theme'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Administration theme'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  $form['admin_theme']['admin_theme'] = array(
+    '#type' => 'select',
+    '#options' => array(0 => t('Default theme')) + $options,
+    '#title' => t('Administration theme'),
+    '#description' => t('Choose which theme the administration pages should display in. If you choose "Default theme" the administration pages will use the same theme as the rest of the site.'),
+    '#default_value' => variable_get('admin_theme', 0),
+  );
+  $form['admin_theme']['node_admin_theme'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use administration theme for content editing'),
+    '#description' => t('Use the administration theme when editing existing posts or creating new ones.'),
+    '#default_value' => variable_get('node_admin_theme', '0'),
+  );
+
   $form['buttons']['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save configuration'),
@@ -244,6 +230,7 @@ function system_themes_form() {
     '#type' => 'submit',
     '#value' => t('Reset to defaults'),
   );
+
   return $form;
 }
 
@@ -272,18 +259,31 @@ function system_themes_form_submit($form
         }
       }
     }
-    if (($admin_theme = variable_get('admin_theme', '0')) != '0' && $admin_theme != $form_state['values']['theme_default']) {
+    if ($form_state['values']['admin_theme'] && $form_state['values']['admin_theme'] != $form_state['values']['theme_default']) {
       drupal_set_message(t('Please note that the <a href="!admin_theme_page">administration theme</a> is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', array(
         '!admin_theme_page' => url('admin/settings/admin'),
-        '%admin_theme' => $admin_theme,
+        '%admin_theme' => $form_state['values']['admin_theme'],
         '%selected_theme' => $form_state['values']['theme_default'],
       )));
     }
+    if ($form_state['values']['admin_theme'] && $form_state['values']['admin_theme'] != variable_get('admin_theme', 0)) {
+      // If we're changing themes, make sure the theme has its blocks initialized.
+      $result = db_result(db_query("SELECT COUNT(*) FROM {block} WHERE theme = '%s'", $form_state['values']['admin_theme']));
+      if (!$result) {
+        system_initialize_theme_blocks($form_state['values']['admin_theme']);
+      }
+    }
+
+    // Save the variables.
     variable_set('theme_default', $form_state['values']['theme_default']);
+    variable_set('admin_theme', $form_state['values']['admin_theme']);
+    variable_set('node_admin_theme', $form_state['values']['node_admin_theme']);
   }
   else {
     // Revert to defaults: only Garland is enabled.
     variable_del('theme_default');
+    variable_del('admin_theme');
+    variable_del('node_admin_theme');
     db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' AND name = 'garland'");
     $new_theme_list = array('garland');
   }
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.666
diff -u -p -r1.666 system.module
--- modules/system/system.module	3 Feb 2009 18:55:31 -0000	1.666
+++ modules/system/system.module	11 Feb 2009 02:07:38 -0000
@@ -504,26 +504,17 @@ function system_menu() {
     'page callback' => 'system_admin_menu_block_page',
     'access arguments' => array('access administration pages'),
   );
-  $items['admin/settings/admin'] = array(
-    'title' => 'Administration theme',
-    'description' => 'Settings for how your administrative pages should look.',
-    'position' => 'left',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('system_admin_theme_settings'),
-    'access arguments' => array('administer site configuration'),
-    'block callback' => 'system_admin_theme_settings',
-  );
   // Themes:
   $items['admin/build/themes'] = array(
     'title' => 'Themes',
     'description' => 'Change which theme your site uses or allows users to set.',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('system_themes_form', NULL),
+    'page arguments' => array('system_themes_form'),
     'access arguments' => array('administer site configuration'),
   );
   $items['admin/build/themes/select'] = array(
     'title' => 'List',
-    'description' => 'Select the default theme.',
+    'description' => 'Select the default theme for your site.',
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -1,
   );
@@ -782,7 +773,7 @@ function blocked_ip_load($iid) {
  * Menu item access callback - only admin or enabled themes can be accessed.
  */
 function _system_themes_access($theme) {
-  return user_access('administer site configuration') && ($theme->status || $theme->name == variable_get('admin_theme', '0'));
+  return user_access('administer site configuration') && ($theme->status || $theme->name == variable_get('admin_theme', 0));
 }
 
 /**
@@ -792,7 +783,7 @@ function system_init() {
   // Use the administrative theme if the user is looking at a page in the admin/* path.
   if (arg(0) == 'admin' || (variable_get('node_admin_theme', '0') && arg(0) == 'node' && (arg(1) == 'add' || arg(2) == 'edit'))) {
     global $custom_theme;
-    $custom_theme = variable_get('admin_theme', '0');
+    $custom_theme = variable_get('admin_theme', 0);
     drupal_add_css(drupal_get_path('module', 'system') . '/admin.css');
   }
 
@@ -982,19 +973,6 @@ function system_admin_menu_block($item) 
 }
 
 /**
- * Process admin theme form submissions.
- */
-function system_admin_theme_submit($form, &$form_state) {
-  // If we're changing themes, make sure the theme has its blocks initialized.
-  if ($form_state['values']['admin_theme'] && $form_state['values']['admin_theme'] != variable_get('admin_theme', '0')) {
-    $result = db_result(db_query("SELECT COUNT(*) FROM {block} WHERE theme = '%s'", $form_state['values']['admin_theme']));
-    if (!$result) {
-      system_initialize_theme_blocks($form_state['values']['admin_theme']);
-    }
-  }
-}
-
-/**
  * Returns a fieldset containing the theme select form.
  *
  * @param $description
Index: modules/system/system.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.test,v
retrieving revision 1.38
diff -u -p -r1.38 system.test
--- modules/system/system.test	25 Jan 2009 12:19:32 -0000	1.38
+++ modules/system/system.test	11 Feb 2009 02:07:39 -0000
@@ -828,3 +828,65 @@ class SystemSettingsForm extends DrupalW
     $this->assertTrue($no_automatic['has_children']['system_settings_form_test_5']['#default_value']);
   }
 }
+
+/**
+ * Tests for the theme interface functionality.
+ */
+class SystemThemeFunctionalTest extends DrupalWebTestCase {
+  function getInfo() {
+    return array(
+      'name' => t('Theme interface functionality'),
+      'description' => t('test'),
+      'group' => t('System'),
+    );
+  }
+
+  function setUp() {
+    parent::setUp();
+
+    $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'bypass node access'));
+    $this->drupalLogin($this->admin_user);
+    $this->node = $this->drupalCreateNode();
+  }
+
+  /**
+   * Test the administration theme functionality.
+   */
+  function testAdministrationTheme() {
+    // Enable an administration theme and show it on the node admin pages.
+    $edit = array(
+      'theme_default' => 'minnelli',
+      'admin_theme' => 'stark',
+      'node_admin_theme' => TRUE,
+    );
+    $this->drupalPost('admin/build/themes', $edit, t('Save configuration'));
+    $this->assertRaw('/themes/stark/', t('Administration theme used on an administration page.'));
+
+    $this->drupalGet('node/add');
+    $this->assertRaw('/themes/stark/', t('Administration theme used on the add content page.'));
+
+    $this->drupalGet('node/' . $this->node->nid);
+    $this->assertRaw('/themes/garland/minnelli/', t('Site default theme used on front page.'));
+
+    $this->drupalGet('node/' . $this->node->nid . '/edit');
+    $this->assertRaw('/themes/stark/', t('Administration theme used on the edit content page.'));
+
+    // Set the administration theme to the site's default theme.
+    $edit = array(
+      'admin_theme' => 0,
+    );
+    $this->drupalPost('admin/build/themes', $edit, t('Save configuration'));
+    $this->assertRaw('/themes/garland/minnelli/', t('Site default theme used on an administration page.'));
+
+    // Reset to the default theme settings (use default theme and do not show
+    // admin theme on node admin pages).
+    $this->drupalPost('admin/build/themes', array(), t('Reset to defaults'));
+    $this->assertRaw('/themes/garland/', t('Site default theme used on administration page.'));
+
+    $this->drupalGet('node/add');
+    $this->assertRaw('/themes/garland/', t('Site default theme used on the add content page.'));
+
+    $this->drupalGet('node/' . $this->node->nid . '/edit');
+    $this->assertRaw('/themes/garland/', t('Site default theme used on the edit content page.'));
+  }
+}
