Commit f8899fb6 authored by catch's avatar catch
Browse files

Issue #1829224 by alexpott, pfrenssen, vijaycs85, lirantal: Convert the...

Issue #1829224 by alexpott, pfrenssen, vijaycs85, lirantal: Convert the 'theme_default()' variable to CMI.
parent 17e71a44
......@@ -411,7 +411,7 @@ function ajax_base_page_theme() {
// to see the default theme, token validation isn't required for that, and
// bypassing it allows most use-cases to work even when accessed from the
// page cache.
if ($theme === variable_get('theme_default', 'stark') || drupal_valid_token($token, $theme)) {
if ($theme === config('system.theme')->get('default') || drupal_valid_token($token, $theme)) {
return $theme;
}
}
......
......@@ -90,7 +90,7 @@ function drupal_theme_initialize() {
// Only select the user selected theme if it is available in the
// list of themes that can be accessed.
$theme = !empty($user->theme) && drupal_theme_access($user->theme) ? $user->theme : variable_get('theme_default', 'stark');
$theme = !empty($user->theme) && drupal_theme_access($user->theme) ? $user->theme : config('system.theme')->get('default');
// Allow modules to override the theme. Validation has already been performed
// inside menu_get_custom_theme(), so we do not need to check it again here.
......@@ -1530,7 +1530,7 @@ function theme_enable($theme_list) {
*/
function theme_disable($theme_list) {
// Don't disable the default theme.
if ($pos = array_search(variable_get('theme_default', 'stark'), $theme_list) !== FALSE) {
if ($pos = array_search(config('system.theme')->get('default'), $theme_list) !== FALSE) {
unset($theme_list[$pos]);
if (empty($theme_list)) {
return;
......
......@@ -50,7 +50,7 @@ function _drupal_maintenance_theme() {
// Stark otherwise. Since there is no low-level access to configuration
// currently, we only consult settings.php and fall back to Bartik
// otherwise, as it looks generic enough and way more user-friendly.
$custom_theme = variable_get('maintenance_theme', variable_get('theme_default', 'bartik'));
$custom_theme = variable_get('maintenance_theme', config('system.theme')->get('default')) ?: 'bartik';
}
// Ensure that system.module is loaded.
......
......@@ -70,7 +70,7 @@ function block_admin_edit(Block $entity) {
$theme = $themes[$theme_key];
// Use meaningful titles for the main site and administrative themes.
$theme_title = $theme->info['name'];
if ($theme_key == variable_get('theme_default', 'stark')) {
if ($theme_key == config('system.theme')->get('default')) {
$theme_title = t('!theme (default theme)', array('!theme' => $theme_title));
}
elseif ($admin_theme && $theme_key == $admin_theme) {
......
......@@ -59,7 +59,7 @@ function block_help($path, $arg) {
$output .= '<dd>' . t('Blocks can be configured to be visible only on certain pages, only to users of certain roles, or only on pages displaying certain <a href="@content-type">content types</a>. Some dynamic blocks, such as those generated by modules, will be displayed only on certain pages.', array('@content-type' => url('admin/structure/types'), '@user' => url('user'))) . '</dd>';
if (module_exists('custom_block')) {
$output .= '<dt>' . t('Creating custom blocks') . '</dt>';
$output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can <a href="@block-add">add custom blocks</a>, which are then listed on the <a href="@blocks">Blocks administration page</a>. Once created, custom blocks behave just like default and module-generated blocks.', array('@blocks' => url('admin/structure/block'), '@block-add' => url('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add/custom_blocks'))) . '</dd>';
$output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can <a href="@block-add">add custom blocks</a>, which are then listed on the <a href="@blocks">Blocks administration page</a>. Once created, custom blocks behave just like default and module-generated blocks.', array('@blocks' => url('admin/structure/block'), '@block-add' => url('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add/custom_blocks'))) . '</dd>';
}
$output .= '</dl>';
return $output;
......@@ -69,7 +69,7 @@ function block_help($path, $arg) {
list(, $demo_theme) = explode(':', $arg[4]);
}
else {
$demo_theme = variable_get('theme_default', 'stark');
$demo_theme = config('system.theme')->get('default');
}
$themes = list_themes();
$output = '<p>' . t('This page provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page. Click the <em>configure</em> link next to each block to configure its specific title and visibility settings.') . '</p>';
......@@ -112,7 +112,7 @@ function block_permission() {
* @todo Clarify the documentation for the per-plugin block admin links.
*/
function block_menu() {
$default_theme = variable_get('theme_default', 'stark');
$default_theme = config('system.theme')->get('default');
$items['admin/structure/block'] = array(
'title' => 'Blocks',
'description' => 'Configure what block content appears in your site\'s sidebars and other regions.',
......@@ -267,7 +267,7 @@ function block_page_build(&$page) {
$page['page_top']['backlink'] = array(
'#type' => 'link',
'#title' => t('Exit block region demonstration'),
'#href' => 'admin/structure/block' . (variable_get('theme_default', 'stark') == $theme ? '' : '/list/' . $theme),
'#href' => 'admin/structure/block' . (config('system.theme')->get('default') == $theme ? '' : '/list/' . $theme),
// Add the "overlay-restore" class to indicate this link should restore
// the context in which the region demonstration page was opened.
'#options' => array('attributes' => array('class' => array('block-demo-backlink', 'overlay-restore'))),
......@@ -363,7 +363,7 @@ function _block_get_renderable_region($list = array()) {
* Blocks currently exported by modules.
*/
function _block_rehash($theme = NULL) {
$theme = $theme ? $theme : variable_get('theme_default', 'stark');
$theme = $theme ? $theme : config('system.theme')->get('default');
$regions = system_region_list($theme);
$blocks = entity_load_multiple_by_properties('block', array('theme' => $theme));
foreach ($blocks as $block_id => $block) {
......@@ -412,7 +412,7 @@ function block_theme_initialize($theme) {
// Initialize theme's blocks if none already registered.
$has_blocks = entity_load_multiple_by_properties('block', array('theme' => $theme));
if (!$has_blocks) {
$default_theme = variable_get('theme_default', 'stark');
$default_theme = config('system.theme')->get('default');
// Apply only to new theme's visible regions.
$regions = system_region_list($theme, REGIONS_VISIBLE);
$default_theme_blocks = entity_load_multiple_by_properties('block', array('theme' => $default_theme));
......
......@@ -182,7 +182,7 @@ public function save(array $form, array &$form_state) {
$form_state['redirect'] = 'admin/structure/block/add/custom_block:' . $block->uuid->value . '/' . $theme;
}
else {
$form_state['redirect'] = 'admin/structure/block/add/custom_block:' . $block->uuid->value . '/' . variable_get('theme_default', 'stark');
$form_state['redirect'] = 'admin/structure/block/add/custom_block:' . $block->uuid->value . '/' . config('system.theme')->get('default');
}
}
else {
......
......@@ -61,7 +61,9 @@ public function testBlockNotInHiddenRegion() {
// Enable "block_test_theme" and set it as the default theme.
$theme = 'block_test_theme';
theme_enable(array($theme));
variable_set('theme_default', $theme);
config('system.theme')
->set('default', $theme)
->save();
menu_router_rebuild();
// Ensure that "block_test_theme" is set as the default theme.
......
......@@ -54,7 +54,7 @@ function setUp() {
*/
public function testLanguageBlockVisibility() {
// Check if the visibility setting is available.
$default_theme = variable_get('theme_default', 'stark');
$default_theme = config('system.theme')->get('default');
$this->drupalGet('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme);
$this->assertField('visibility[language][langcodes][en]', 'Language visibility field is visible.');
......
......@@ -40,7 +40,7 @@ function testBlockThemeHookSuggestions() {
$block = entity_create('block', array(
'plugin' => 'system_menu_block:menu-admin',
'region' => 'footer',
'id' => variable_get('theme_default', 'stark') . '.machinename',
'id' => config('system.theme')->get('default') . '.machinename',
));
$variables = array();
......
......@@ -65,7 +65,7 @@ function setUp() {
* Test creating custom block, moving it to a specific region and then deleting it.
*/
public function testCustomBlock() {
$default_theme = variable_get('theme_default', 'stark');
$default_theme = config('system.theme')->get('default');
// Clear the block cache to load the Custom Block module's block definitions.
$this->container->get('plugin.manager.block')->clearCachedDefinitions();
......@@ -150,7 +150,7 @@ public function testCustomBlock() {
* Test creating custom block using Full HTML.
*/
public function testCustomBlockFormat() {
$default_theme = variable_get('theme_default', 'stark');
$default_theme = config('system.theme')->get('default');
// Add a new custom block by filling out the input form on block/add/basic.
$info = strtolower($this->randomName(8));
......@@ -200,7 +200,7 @@ function testBlockVisibility() {
// Create a random title for the block.
$title = $this->randomName(8);
// Enable a standard block.
$default_theme = variable_get('theme_default', 'stark');
$default_theme = config('system.theme')->get('default');
$edit = array(
'machine_name' => strtolower($this->randomName(8)),
'region' => 'sidebar_first',
......@@ -240,7 +240,7 @@ function testBlockVisibilityListedEmpty() {
// Create a random title for the block.
$title = $this->randomName(8);
// Enable a standard block.
$default_theme = variable_get('theme_default', 'stark');
$default_theme = config('system.theme')->get('default');
$edit = array(
'machine_name' => strtolower($this->randomName(8)),
'region' => 'sidebar_first',
......@@ -273,7 +273,7 @@ function testBlock() {
$block['id'] = 'system_powered_by_block';
$block['label'] = $this->randomName(8);
$block['machine_name'] = strtolower($this->randomName(8));
$block['theme'] = variable_get('theme_default', 'stark');
$block['theme'] = config('system.theme')->get('default');
$block['region'] = 'header';
// Set block title to confirm that interface works and override any custom titles.
......@@ -320,7 +320,7 @@ function testBlock() {
*/
function moveBlockToRegion(array $block, $region) {
// Set the created block to a specific region.
$block += array('theme' => variable_get('theme_default', 'stark'));
$block += array('theme' => config('system.theme')->get('default'));
$edit = array();
$edit['blocks[' . $block['theme'] . '.' . $block['machine_name'] . '][region]'] = $region;
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
......@@ -354,7 +354,7 @@ function testBlockRehash() {
$block = array();
$block['id'] = 'test_cache';
$block['machine_name'] = strtolower($this->randomName(8));
$block['theme'] = variable_get('theme_default', 'stark');
$block['theme'] = config('system.theme')->get('default');
$block['region'] = 'header';
$block = $this->drupalPlaceBlock('test_cache', array('region' => 'header'));
......@@ -413,7 +413,7 @@ function testBlockModuleDisable() {
}
// Ensure that the disabled module's block plugin is no longer available.
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add');
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add');
$this->assertNoText(t('Test block caching'));
// Confirm that the block is no longer displayed on the front page.
......
......@@ -47,7 +47,7 @@ function testXSSInTitle() {
$this->assertNoRaw('<script>alert("XSS label");</script>', 'The block title was properly sanitized when rendered.');
$this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'access administration pages')));
$default_theme = variable_get('theme_default', 'stark');
$default_theme = config('system.theme')->get('default');
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . $default_theme . '/add');
$this->assertNoRaw("<script>alert('XSS subject');</script>", 'The block title was properly sanitized in Block Plugin UI Admin page.');
}
......
......@@ -33,7 +33,7 @@ public static function getInfo() {
* Check the enabled Bartik blocks are correctly copied over.
*/
function testNewDefaultThemeBlocks() {
$default_theme = variable_get('theme_default', 'stark');
$default_theme = config('system.theme')->get('default');
// Add several block instances.
$this->adminUser = $this->drupalCreateUser(array('administer blocks'));
......@@ -51,7 +51,9 @@ function testNewDefaultThemeBlocks() {
$new_theme = 'bartik';
$this->assertFalse($new_theme == $default_theme, 'The new theme is different from the previous default theme.');
theme_enable(array($new_theme));
variable_set('theme_default', $new_theme);
config('system.theme')
->set('default', $new_theme)
->save();
// Ensure that the new theme has all the blocks as the previous default.
// @todo Replace the string manipulation below once the configuration
......
......@@ -142,7 +142,7 @@ protected function testDeleteBlockDisplay() {
*/
public function testViewsBlockForm() {
$this->drupalLogin($this->drupalCreateUser(array('administer blocks')));
$default_theme = variable_get('theme_default', 'stark');
$default_theme = config('system.theme')->get('default');
$this->drupalGet('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme);
$elements = $this->xpath('//input[@name="label"]');
$this->assertTrue(empty($elements), 'The label field is not found for Views blocks.');
......
......@@ -97,7 +97,7 @@ function ckeditor_theme() {
function _ckeditor_theme_css($theme = NULL) {
$css = array();
if (!isset($theme)) {
$theme = variable_get('theme_default');
$theme = config('system.theme')->get('default');
}
if ($theme_path = drupal_get_path('theme', $theme)) {
$info = system_get_info('theme', $theme);
......
......@@ -76,7 +76,9 @@ function testColor() {
* Tests the Color module functionality using the given theme.
*/
function _testColor($theme, $test_values) {
variable_set('theme_default', $theme);
config('system.theme')
->set('default', $theme)
->save();
$settings_path = 'admin/appearance/settings/' . $theme;
$this->drupalLogin($this->big_user);
......@@ -122,7 +124,9 @@ function _testColor($theme, $test_values) {
* Tests whether the provided color is valid.
*/
function testValidColor() {
variable_set('theme_default', 'bartik');
config('system.theme')
->set('default', 'bartik')
->save();
$settings_path = 'admin/appearance/settings/bartik';
$this->drupalLogin($this->big_user);
......
......@@ -35,7 +35,9 @@ public static function getInfo() {
function testCommentLinks() {
// Bartik theme alters comment links, so use a different theme.
theme_enable(array('stark'));
variable_set('theme_default', 'stark');
config('system.theme')
->set('default', 'stark')
->save();
// Remove additional user permissions from $this->web_user added by setUp(),
// since this test is limited to anonymous and authenticated roles only.
......
......@@ -157,7 +157,7 @@ function addCustomMenu() {
// Enable the custom menu block.
$menu_name = 'menu-' . $menu_name; // Drupal prepends the name with 'menu-'.
// Confirm that the custom menu block is available.
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . variable_get('theme_default', 'stark') . '/add');
$this->drupalGet('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add');
$this->assertText($label);
// Enable the block.
......
......@@ -61,16 +61,16 @@ function php_permission() {
* @see php_filter_info()
*/
function php_eval($code) {
global $theme_path, $theme_info, $conf;
global $theme_path, $theme_info;
// Store current theme path.
$old_theme_path = $theme_path;
// Restore theme_path to the theme, as long as php_eval() executes,
// so code evaluated will not see the caller module as the current theme.
// If theme info is not initialized get the path from theme_default.
// If theme info is not initialized get the path from default theme.
if (!isset($theme_info)) {
$theme_path = drupal_get_path('theme', $conf['theme_default']);
$theme_path = drupal_get_path('theme', config('system.theme')->get('default'));
}
else {
$theme_path = dirname($theme_info->filename);
......
......@@ -136,7 +136,9 @@ function testShortcutLinkDelete() {
*/
function testNoShortcutLink() {
// Change to a theme that displays shortcuts.
variable_set('theme_default', 'seven');
config('system.theme')
->set('default', 'seven')
->save();
$this->drupalGet('page-that-does-not-exist');
$this->assertNoRaw('add-shortcut', 'Add to shortcuts link was not shown on a page not found.');
......
......@@ -119,6 +119,8 @@ protected function setUp() {
$modules = array_reverse($modules);
$modules = call_user_func_array('array_merge_recursive', $modules);
$this->enableModules($modules, FALSE);
// In order to use theme functions default theme config needs to exist.
config('system.theme')->set('default', 'stark');
}
protected function tearDown() {
......
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