diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 84e2ec7..6017bee 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -48,25 +48,15 @@ const MARK_UPDATED = 2; */ function drupal_theme_access($theme) { if (is_object($theme)) { - return _drupal_theme_access($theme); + return !empty($theme->status); } else { $themes = list_themes(); - return isset($themes[$theme]) && _drupal_theme_access($themes[$theme]); + return !empty($themes[$theme]->status); } } /** - * Helper function for determining access to a theme. - * - * @see drupal_theme_access() - */ -function _drupal_theme_access($theme) { - $admin_theme = variable_get('admin_theme'); - return !empty($theme->status) || ($admin_theme && $theme->name == $admin_theme); -} - -/** * Initialize the theme system by loading the theme. */ function drupal_theme_initialize() { diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 455f98f..25f722d 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -177,7 +177,7 @@ function block_menu() { } /** - * Access callback: Only admin or enabled themes can be accessed. + * Access callback: Only enabled themes can be accessed. * * Path: * - admin/structure/block/list/% (for each theme) diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php index 0397802..7336543 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php @@ -10,13 +10,13 @@ namespace Drupal\block\Tests; use Drupal\simpletest\WebTestBase; /** - * Test the block system with admin themes. + * Tests the block system with admin themes. */ class BlockAdminThemeTest extends WebTestBase { public static function getInfo() { return array( - 'name' => 'Admin theme block admin accessibility', - 'description' => "Check whether the block administer page for a disabled theme accessible if and only if it's the admin theme.", + 'name' => 'Administration theme', + 'description' => 'Tests the block system with admin themes.', 'group' => 'Block', ); } @@ -35,12 +35,13 @@ class BlockAdminThemeTest extends WebTestBase { // Ensure that access to block admin page is denied when theme is disabled. $this->drupalGet('admin/structure/block/list/bartik'); - $this->assertResponse(403, t('The block admin page for a disabled theme can not be accessed')); + $this->assertResponse(403); // Enable admin theme and confirm that tab is accessible. + theme_enable(array('bartik')); $edit['admin_theme'] = 'bartik'; $this->drupalPost('admin/appearance', $edit, t('Save configuration')); $this->drupalGet('admin/structure/block/list/bartik'); - $this->assertResponse(200, t('The block admin page for the admin theme can be accessed')); + $this->assertResponse(200); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Batch/PageTest.php b/core/modules/system/lib/Drupal/system/Tests/Batch/PageTest.php index bef4812..85e9a5e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Batch/PageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Batch/PageTest.php @@ -32,6 +32,7 @@ class PageTest extends WebTestBase { // Make sure that the page which starts the batch (an administrative page) // is using a different theme than would normally be used by the batch API. variable_set('theme_default', 'bartik'); + theme_enable(array('seven')); variable_set('admin_theme', 'seven'); // Log in as an administrator who can see the administrative theme. $admin_user = $this->drupalCreateUser(array('view the administration theme')); diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php index 11db04e..82fd4a0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php @@ -85,6 +85,7 @@ class RouterTest extends WebTestBase { * Test the theme callback when it is set to use an administrative theme. */ function testThemeCallbackAdministrative() { + theme_enable(array('seven')); $this->drupalGet('menu-test/theme-callback/use-admin-theme'); $this->assertText('Custom theme: seven. Actual theme: seven.', t('The administrative theme can be correctly set in a theme callback.')); $this->assertRaw('seven/style.css', t("The administrative theme's CSS appears on the page.")); @@ -94,6 +95,7 @@ class RouterTest extends WebTestBase { * Test that the theme callback is properly inherited. */ function testThemeCallbackInheritance() { + theme_enable(array('seven')); $this->drupalGet('menu-test/theme-callback/use-admin-theme/inheritance'); $this->assertText('Custom theme: seven. Actual theme: seven. Theme callback inheritance is being tested.', t('Theme callback inheritance correctly uses the administrative theme.')); $this->assertRaw('seven/style.css', t("The administrative theme's CSS appears on the page.")); @@ -124,6 +126,7 @@ class RouterTest extends WebTestBase { */ function testThemeCallbackMaintenanceMode() { config('system.maintenance')->set('enabled', 1)->save(); + theme_enable(array('seven')); // For a regular user, the fact that the site is in maintenance mode means // we expect the theme callback system to be bypassed entirely. @@ -215,7 +218,7 @@ class RouterTest extends WebTestBase { // Trigger hook_custom_theme() to dynamically request the Stark theme for // the requested page. variable_set('menu_test_hook_custom_theme_name', 'stark'); - theme_enable(array('stark')); + theme_enable(array('stark', 'seven')); // Visit a page that does not implement a theme callback. The above request // should be honored. @@ -231,7 +234,7 @@ class RouterTest extends WebTestBase { // Trigger hook_custom_theme() to dynamically request the Stark theme for // the requested page. variable_set('menu_test_hook_custom_theme_name', 'stark'); - theme_enable(array('stark')); + theme_enable(array('stark', 'seven')); // The menu "theme callback" should take precedence over a value set in // hook_custom_theme(). diff --git a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php index 30d8422..793fc97 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php @@ -164,8 +164,8 @@ class ThemeTest extends WebTestBase { * Test the administration theme functionality. */ function testAdministrationTheme() { - theme_enable(array('stark')); - variable_set('theme_default', 'stark'); + theme_enable(array('seven')); + // Enable an administration theme and show it on the node admin pages. $edit = array( 'admin_theme' => 'seven', diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 2947245..6dfcff7 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -119,12 +119,12 @@ function system_themes_page() { $theme_default = variable_get('theme_default', 'stark'); $theme_groups = array(); + $admin_theme = variable_get('admin_theme', 0); foreach ($themes as &$theme) { if (!empty($theme->info['hidden'])) { continue; } - $admin_theme_options[$theme->name] = $theme->info['name']; $theme->is_default = ($theme->name == $theme_default); // Identify theme screenshot. @@ -171,12 +171,14 @@ function system_themes_page() { } if (!empty($theme->status)) { if (!$theme->is_default) { - $theme->operations[] = array( - 'title' => t('Disable'), - 'href' => 'admin/appearance/disable', - 'query' => $query, - 'attributes' => array('title' => t('Disable !theme theme', array('!theme' => $theme->info['name']))), - ); + if ($theme->name != $admin_theme) { + $theme->operations[] = array( + 'title' => t('Disable'), + 'href' => 'admin/appearance/disable', + 'query' => $query, + 'attributes' => array('title' => t('Disable !theme theme', array('!theme' => $theme->info['name']))), + ); + } $theme->operations[] = array( 'title' => t('Set default'), 'href' => 'admin/appearance/default', @@ -184,6 +186,7 @@ function system_themes_page() { 'attributes' => array('title' => t('Set !theme as default theme', array('!theme' => $theme->info['name']))), ); } + $admin_theme_options[$theme->name] = $theme->info['name']; } else { $theme->operations[] = array( @@ -208,6 +211,10 @@ function system_themes_page() { $theme->classes[] = 'theme-default'; $theme->notes[] = t('default theme'); } + if ($theme->name == $admin_theme || ($theme->is_default && $admin_theme == '0')) { + $theme->classes[] = 'theme-admin'; + $theme->notes[] = t('admin theme'); + } // Sort enabled and disabled themes into their own groups. $theme_groups[$theme->status ? 'enabled' : 'disabled'][] = $theme; @@ -296,7 +303,7 @@ function system_theme_disable() { // Check if the specified theme is one recognized by the system. if (!empty($themes[$theme])) { - if ($theme == variable_get('theme_default', 'stark')) { + if ($theme == variable_get('theme_default', 'stark') || $theme == variable_get('admin_theme', 0)) { // Don't disable the default theme. drupal_set_message(t('%theme is the default theme and cannot be disabled.', array('%theme' => $themes[$theme]->info['name'])), 'error'); } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 4c34dd2..33bbbb1 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1879,7 +1879,7 @@ function blocked_ip_load($iid) { } /** - * Menu item access callback - only admin or enabled themes can be accessed. + * Menu item access callback - only enabled themes can be accessed. */ function _system_themes_access($theme) { return user_access('administer themes') && drupal_theme_access($theme); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/ThemeTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/ThemeTest.php index baa5c61..b226970 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/ThemeTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/ThemeTest.php @@ -26,6 +26,7 @@ class ThemeTest extends TaxonomyTestBase { // Make sure we are using distinct default and administrative themes for // the duration of these tests. variable_set('theme_default', 'bartik'); + theme_enable(array('seven')); variable_set('admin_theme', 'seven'); // Create and log in as a user who has permission to add and edit taxonomy