- Patch #542828 by sun, Pasqualle, marcingy, Gábor Hojtsy: do not special case disabled admin theme.
parent
2aa02a0b30
commit
ed9f736bc0
core
includes
modules
block
lib/Drupal/block/Tests
system
lib/Drupal/system/Tests
taxonomy/lib/Drupal/taxonomy/Tests
|
@ -48,24 +48,14 @@ 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.
|
||||
*/
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -10,7 +10,7 @@ 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 {
|
||||
|
||||
|
@ -23,8 +23,8 @@ 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',
|
||||
);
|
||||
}
|
||||
|
@ -39,12 +39,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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,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'));
|
||||
|
|
|
@ -93,6 +93,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."));
|
||||
|
@ -102,6 +103,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."));
|
||||
|
@ -132,6 +134,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.
|
||||
|
@ -223,7 +226,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.
|
||||
|
@ -239,7 +242,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().
|
||||
|
|
|
@ -172,8 +172,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',
|
||||
|
|
|
@ -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.
|
||||
|
@ -175,12 +175,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',
|
||||
|
@ -188,6 +190,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(
|
||||
|
@ -212,6 +215,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;
|
||||
|
@ -300,8 +307,8 @@ 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')) {
|
||||
// Don't disable the default theme.
|
||||
// Do not disable the default or admin theme.
|
||||
if ($theme == variable_get('theme_default', 'stark') || $theme == variable_get('admin_theme', 0)) {
|
||||
drupal_set_message(t('%theme is the default theme and cannot be disabled.', array('%theme' => $themes[$theme]->info['name'])), 'error');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1881,7 +1881,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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue