Commit 557351e2 authored by catch's avatar catch

Issue #1798872 by vijaycs85, leschekfm, pcambra, andreiashu: Convert admin_theme() to CMI.

parent 42490d9c
......@@ -312,7 +312,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
);
$theme_default = variable_get('theme_default', 'stark');
$admin_theme = variable_get('admin_theme');
$admin_theme = config('system.site')->get('admin_theme');
foreach (list_themes() as $key => $theme) {
// Only display enabled themes
if ($theme->status) {
......
......@@ -40,7 +40,7 @@ function testNewDefaultThemeBlocks() {
// Ensure no other theme's blocks are in the block table yet.
$themes = array();
$themes['default'] = variable_get('theme_default', 'stark');
if ($admin_theme = variable_get('admin_theme')) {
if ($admin_theme = config('system.site')->get('admin_theme')) {
$themes['admin'] = $admin_theme;
}
$count = db_query_range('SELECT 1 FROM {block} WHERE theme NOT IN (:themes)', 0, 1, array(':themes' => $themes))->fetchField();
......
......@@ -129,7 +129,7 @@ function testRecentNodeBlock() {
$custom_block['types[article]'] = TRUE;
$custom_block['body[value]'] = $this->randomName(32);
$custom_block['regions[' . variable_get('theme_default', 'stark') . ']'] = 'content';
if ($admin_theme = variable_get('admin_theme')) {
if ($admin_theme = config('system.site')->get('admin_theme')) {
$custom_block['regions[' . $admin_theme . ']'] = 'content';
}
$this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
......
......@@ -64,7 +64,7 @@ function testShortcutLinkAdd() {
*/
function testShortcutQuickLink() {
theme_enable(array('seven'));
variable_set('admin_theme', 'seven');
config('system.site')->set('admin_theme', 'seven')->save();
variable_set('node_admin_theme', TRUE);
$this->drupalGet($this->set->links[0]['link_path']);
$this->assertRaw(t('Remove from %title shortcuts', array('%title' => $this->set->title)), '"Add to shortcuts" link properly switched to "Remove from shortcuts".');
......
admin_theme: '0'
name: Drupal
mail: ''
slogan: ''
......
......@@ -37,7 +37,7 @@ function testBatchProgressPageTheme() {
// 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');
config('system.site')->set('admin_theme', 'seven')->save();
// Log in as an administrator who can see the administrative theme.
$admin_user = $this->drupalCreateUser(array('view the administration theme'));
$this->drupalLogin($admin_user);
......
......@@ -38,7 +38,7 @@ function setUp() {
// and administrative theme that they expect.
theme_enable(array('bartik'));
variable_set('theme_default', 'bartik');
variable_set('admin_theme', 'seven');
config('system.site')->set('admin_theme', 'seven')->save();
theme_disable(array('stark'));
// Enable navigation menu block.
......
......@@ -120,7 +120,7 @@ function system_themes_page() {
$theme_default = variable_get('theme_default', 'stark');
$theme_groups = array();
$admin_theme = variable_get('admin_theme', 0);
$admin_theme = config('system.site')->get('admin_theme');
foreach ($themes as &$theme) {
if (!empty($theme->info['hidden'])) {
......@@ -257,7 +257,7 @@ function system_themes_admin_form($form, &$form_state, $theme_options) {
'#options' => array(0 => t('Default theme')) + $theme_options,
'#title' => t('Administration theme'),
'#description' => t('Choose "Default theme" to always use the same theme as the rest of the site.'),
'#default_value' => variable_get('admin_theme', 0),
'#default_value' => config('system.site')->get('admin_theme'),
);
$form['admin_theme']['actions'] = array('#type' => 'actions');
$form['admin_theme']['actions']['submit'] = array(
......@@ -272,7 +272,7 @@ function system_themes_admin_form($form, &$form_state, $theme_options) {
*/
function system_themes_admin_form_submit($form, &$form_state) {
drupal_set_message(t('The configuration options have been saved.'));
variable_set('admin_theme', $form_state['values']['admin_theme']);
config('system.site')->set('admin_theme', $form_state['values']['admin_theme'])->save();
}
/**
......@@ -309,7 +309,7 @@ function system_theme_disable() {
// Check if the specified theme is one recognized by the system.
if (!empty($themes[$theme])) {
// Do not disable the default or admin theme.
if ($theme == variable_get('theme_default', 'stark') || $theme == variable_get('admin_theme', 0)) {
if ($theme == variable_get('theme_default', 'stark') || $theme == config('system.site')->get('admin_theme')) {
drupal_set_message(t('%theme is the default theme and cannot be disabled.', array('%theme' => $themes[$theme]->info['name'])), 'error');
}
else {
......@@ -353,7 +353,7 @@ function system_theme_default() {
// The status message depends on whether an admin theme is currently in use:
// a value of 0 means the admin theme is set to be the default theme.
$admin_theme = variable_get('admin_theme', 0);
$admin_theme = config('system.site')->get('admin_theme');
if ($admin_theme != 0 && $admin_theme != $theme) {
drupal_set_message(t('Please note that the administration theme 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' => $themes[$admin_theme]->info['name'],
......
......@@ -2319,6 +2319,17 @@ function system_update_8040() {
));
}
/**
* Converts admin_theme variable to config.
*
* @ingroup config_upgrade
*/
function system_update_8041() {
update_variables_to_config('system.site', array(
'admin_theme' => 'admin_theme'
));
}
/**
* @} End of "defgroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
......
......@@ -214,7 +214,7 @@ function system_permission() {
),
'view the administration theme' => array(
'title' => t('View the administration theme'),
'description' => variable_get('admin_theme') ? '' : t('This is only used when the site is configured to use a separate administration theme on the <a href="@appearance-url">Appearance</a> page.', array('@appearance-url' => url('admin/appearance'))),
'description' => config('system.site')->get('admin_theme') ?: t('This is only used when the site is configured to use a separate administration theme on the <a href="@appearance-url">Appearance</a> page.', array('@appearance-url' => url('admin/appearance'))),
),
'access site reports' => array(
'title' => t('View site reports'),
......@@ -2394,7 +2394,7 @@ function system_custom_theme() {
$request = drupal_container()->get('request');
$path = $request->attributes->get('system_path');
if (user_access('view the administration theme') && path_is_admin($path)) {
return variable_get('admin_theme');
return config('system.site')->get('admin_theme');
}
}
}
......
......@@ -462,7 +462,7 @@ function menu_test_theme_page_callback($inherited = FALSE) {
function menu_test_theme_callback($argument) {
// Test using the variable administrative theme.
if ($argument == 'use-admin-theme') {
return variable_get('admin_theme');
return config('system.site')->get('admin_theme');
}
// Test using a theme that exists, but may or may not be enabled.
elseif ($argument == 'use-stark-theme') {
......
......@@ -27,7 +27,7 @@ function setUp() {
// the duration of these tests.
variable_set('theme_default', 'bartik');
theme_enable(array('seven'));
variable_set('admin_theme', 'seven');
config('system.site')->set('admin_theme', 'seven')->save();
// Create and log in as a user who has permission to add and edit taxonomy
// terms and view the administrative theme.
......
......@@ -437,6 +437,6 @@ function standard_install() {
// Enable the admin theme.
theme_enable(array('seven'));
variable_set('admin_theme', 'seven');
config('system.site')->set('admin_theme', 'seven')->save();
variable_set('node_admin_theme', '1');
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment