diff --git a/core/includes/theme.inc b/core/includes/theme.inc index d128167..2fe05d5 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -348,14 +348,12 @@ function theme_get_setting($setting_name, $theme = NULL) { } // Generate the path to the logo image. - if ($cache[$theme]->get('features.logo')) { - $logo_path = $cache[$theme]->get('logo.path'); - if ($cache[$theme]->get('logo.use_default')) { - $cache[$theme]->set('logo.url', file_create_url($theme_object->getPath() . '/logo.svg')); - } - elseif ($logo_path) { - $cache[$theme]->set('logo.url', file_create_url($logo_path)); - } + $logo_path = $cache[$theme]->get('logo.path'); + if ($cache[$theme]->get('logo.use_default')) { + $cache[$theme]->set('logo.url', file_create_url($theme_object->getPath() . '/logo.svg')); + } + elseif ($logo_path) { + $cache[$theme]->set('logo.url', file_create_url($logo_path)); } // Generate the path to the favicon. @@ -1374,8 +1372,8 @@ function template_preprocess_page(&$variables) { $variables['front_page'] = \Drupal::url(''); $variables['language'] = $language_interface; $variables['logo'] = theme_get_setting('logo.url'); - $variables['site_name'] = (theme_get_setting('features.name') ? SafeMarkup::checkPlain($site_config->get('name')) : ''); - $variables['site_slogan'] = (theme_get_setting('features.slogan') ? Xss::filterAdmin($site_config->get('slogan')) : ''); + $variables['site_name'] = $site_config->get('name'); + $variables['site_slogan'] = $site_config->get('slogan'); // An exception might be thrown. try { diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index 6684c72..c2570c2 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -29,10 +29,7 @@ class ThemeHandler implements ThemeHandlerInterface { * @var array */ protected $defaultFeatures = array( - 'logo', 'favicon', - 'name', - 'slogan', 'node_user_picture', 'comment_user_picture', 'comment_user_verification', diff --git a/core/modules/color/color.module b/core/modules/color/color.module index 65c60d7..1484db7 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -9,6 +9,7 @@ use Drupal\Component\Utility\Bytes; use Drupal\Component\Utility\Environment; use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\Block\BlockPluginInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; @@ -120,6 +121,27 @@ function color_preprocess_page(&$variables) { } /** + * Implements hook_block_view_BASE_BLOCK_ID_alter(). + */ +function color_block_view_system_branding_block_alter(array &$build, BlockPluginInterface $block) { + $build['#pre_render'][] = 'color_block_view_pre_render'; +} + +/** + * #pre_render callback: Sets color preset logo. + */ +function color_block_view_pre_render(array $build) { + $theme_key = \Drupal::theme()->getActiveTheme()->getName(); + + // Override logo. + $logo = \Drupal::config('color.theme.' . $theme_key)->get('logo'); + if ($logo && $build['content']['site_logo'] && preg_match('!' . $theme_key . '/logo.svg$!', $build['content']['site_logo']['#uri'])) { + $build['content']['site_logo']['#uri'] = file_create_url($logo); + } + return $build; +} + +/** * Retrieves the Color module information for a particular theme. */ function color_get_info($theme) { diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index 807307c..e04bada 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -28,7 +28,7 @@ class ConfigTranslationUiTest extends WebTestBase { * * @var array */ - public static $modules = array('node', 'contact', 'contact_test', 'config_translation', 'config_translation_test', 'views', 'views_ui', 'contextual', 'filter', 'filter_test'); + public static $modules = ['node', 'contact', 'contact_test', 'config_translation', 'config_translation_test', 'views', 'views_ui', 'contextual', 'filter', 'filter_test', 'block']; /** * Languages to enable. @@ -157,6 +157,9 @@ public function testSiteInformationTranslationUi() { $this->assertFieldByName('translation[config_names][system.site][name]', $fr_site_name); $this->assertFieldByName('translation[config_names][system.site][slogan]', $fr_site_slogan); + // Place branding block with site name and slogan into header region. + $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']); + // Check French translation of site name and slogan are in place. $this->drupalGet('fr'); $this->assertRaw($fr_site_name); diff --git a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php index f46c0e0..8369416 100644 --- a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php @@ -393,6 +393,9 @@ function testUrlLanguageFallback() { // it is set by JavaScript. $this->drupalLogout(); + // Place a site branding block in the header region. + $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']); + // Access the front page without specifying any valid URL language prefix // and having as browser language preference a non-default language. $http_header = array("Accept-Language: $langcode_browser_fallback;q=1"); @@ -406,7 +409,7 @@ function testUrlLanguageFallback() { $this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->getName(), 'The browser language is the URL active language'); // Check that URLs are rewritten using the given browser language. - $fields = $this->xpath('//strong[@class="site-name"]/a[@rel="home" and @href=:url]', $args); + $fields = $this->xpath('//div[@class="site-name"]/a[@rel="home" and @href=:url]', $args); $this->assertTrue($fields[0] == 'Drupal', 'URLs are rewritten using the browser language.'); } diff --git a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php index c6af0ac..c4ed86a 100644 --- a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php +++ b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php @@ -86,6 +86,7 @@ function testPageCacheTags() { 'rendered', 'block_view', 'config:block_list', + 'config:block.block.bartik_branding', 'config:block.block.bartik_breadcrumbs', 'config:block.block.bartik_content', 'config:block.block.bartik_tools', @@ -117,6 +118,7 @@ function testPageCacheTags() { 'rendered', 'block_view', 'config:block_list', + 'config:block.block.bartik_branding', 'config:block.block.bartik_breadcrumbs', 'config:block.block.bartik_content', 'config:block.block.bartik_tools', diff --git a/core/modules/system/config/install/system.theme.global.yml b/core/modules/system/config/install/system.theme.global.yml index 5ee6cc7..b8da423 100644 --- a/core/modules/system/config/install/system.theme.global.yml +++ b/core/modules/system/config/install/system.theme.global.yml @@ -7,10 +7,7 @@ features: comment_user_picture: true comment_user_verification: true favicon: true - logo: true - name: true node_user_picture: true - slogan: true logo: path: '' url: '' diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php index fd8b777..978ca80 100644 --- a/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -141,9 +141,6 @@ public function buildForm(array $form, FormStateInterface $form_state, $theme = // Toggle settings $toggles = array( - 'logo' => t('Logo'), - 'name' => t('Site name'), - 'slogan' => t('Site slogan'), 'node_user_picture' => t('User pictures in posts'), 'comment_user_picture' => t('User pictures in comments'), 'comment_user_verification' => t('User verification status in comments'), diff --git a/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php b/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php index c5ebaa5..4e5060a 100644 --- a/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemBrandingBlock.php @@ -159,10 +159,9 @@ public function build() { $build = array(); $site_config = $this->configFactory->get('system.site'); - $logo = theme_get_setting('logo'); $build['site_logo'] = array( '#theme' => 'image', - '#uri' => $logo['url'], + '#uri' => theme_get_setting('logo.url'), '#alt' => $this->t('Home'), '#access' => $this->configuration['use_site_logo'], ); diff --git a/core/modules/system/src/Tests/System/PageTitleTest.php b/core/modules/system/src/Tests/System/PageTitleTest.php index 1fef0a4..1b07ab6 100644 --- a/core/modules/system/src/Tests/System/PageTitleTest.php +++ b/core/modules/system/src/Tests/System/PageTitleTest.php @@ -23,7 +23,7 @@ class PageTitleTest extends WebTestBase { * * @var array */ - public static $modules = array('node', 'test_page_test', 'form_test'); + public static $modules = ['node', 'test_page_test', 'form_test', 'block']; protected $contentUser; protected $savedTitle; @@ -70,13 +70,6 @@ function testTitleXSS() { $slogan = ''; $slogan_filtered = Xss::filterAdmin($slogan); - // Activate needed appearance settings. - $edit = array( - 'toggle_name' => TRUE, - 'toggle_slogan' => TRUE, - ); - $this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration')); - // Set title and slogan. $edit = array( 'site_name' => $title, @@ -84,6 +77,9 @@ function testTitleXSS() { ); $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); + // Place branding block with site name and slogan into header region. + $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']); + // Load frontpage. $this->drupalGet(''); diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php index d5bb6f6..66d6830 100644 --- a/core/modules/system/src/Tests/System/ThemeTest.php +++ b/core/modules/system/src/Tests/System/ThemeTest.php @@ -122,9 +122,11 @@ function testThemeSettings() { $this->assertEqual((string) $elements[1], $explicit_file); $this->assertEqual((string) $elements[2], $local_file); - // Verify the actual 'src' attribute of the logo being output. + // Verify the actual 'src' attribute of the logo being output in a site + // branding block. + $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']); $this->drupalGet(''); - $elements = $this->xpath('//header/a[@rel=:rel]/img', array( + $elements = $this->xpath('//header//a[@rel=:rel]/img', array( ':rel' => 'home', ) ); @@ -174,8 +176,9 @@ function testThemeSettings() { $fields = $this->xpath($this->constructFieldXpath('name', 'logo_path')); $uploaded_filename = 'public://' . $fields[0]['value']; + $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']); $this->drupalGet(''); - $elements = $this->xpath('//header/a[@rel=:rel]/img', array( + $elements = $this->xpath('//header//a[@rel=:rel]/img', array( ':rel' => 'home', ) ); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index a52f701..0e3897a 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1024,10 +1024,7 @@ function system_rebuild_module_data() { */ function _system_default_theme_features() { return array( - 'logo', 'favicon', - 'name', - 'slogan', 'node_user_picture', 'comment_user_picture', 'comment_user_verification', diff --git a/core/modules/system/templates/block--system-branding-block.html.twig b/core/modules/system/templates/block--system-branding-block.html.twig index 4c64251..6920a65 100644 --- a/core/modules/system/templates/block--system-branding-block.html.twig +++ b/core/modules/system/templates/block--system-branding-block.html.twig @@ -17,13 +17,13 @@ #} {% block content %} {% if site_logo %} - + {{ 'Home'|t }} {% endif %} {% if site_name %}
- {{ site_name }} + {{ site_name }}
{% endif %} {% if site_slogan %} diff --git a/core/modules/system/templates/page.html.twig b/core/modules/system/templates/page.html.twig index eb5c7bf..83455f5 100644 --- a/core/modules/system/templates/page.html.twig +++ b/core/modules/system/templates/page.html.twig @@ -63,32 +63,6 @@
- {% if logo %} - - {{ 'Home'|t }} - - {% endif %} - - {% if site_name or site_slogan %} -
- - {# Use h1 when the content title is empty #} - {% if title %} - - {{ site_name }} - - {% else %} -

- {{ site_name }} -

- {% endif %} - - {% if site_slogan %} -
{{ site_slogan }}
- {% endif %} -
{# ./name-and-slogan #} - {% endif %} - {{ page.header }}
diff --git a/core/profiles/minimal/config/install/block.block.stark_branding.yml b/core/profiles/minimal/config/install/block.block.stark_branding.yml new file mode 100644 index 0000000..acf108f --- /dev/null +++ b/core/profiles/minimal/config/install/block.block.stark_branding.yml @@ -0,0 +1,18 @@ +id: stark_branding +theme: stark +weight: 0 +status: true +langcode: en +region: header +plugin: system_branding_block +settings: + id: system_branding_block + label: 'Site Branding' + provider: system + label_display: '0' +dependencies: + module: + - system + theme: + - stark +visibility: { } diff --git a/core/profiles/standard/config/install/block.block.bartik_branding.yml b/core/profiles/standard/config/install/block.block.bartik_branding.yml new file mode 100644 index 0000000..3bed730 --- /dev/null +++ b/core/profiles/standard/config/install/block.block.bartik_branding.yml @@ -0,0 +1,18 @@ +id: bartik_branding +theme: bartik +weight: 0 +status: true +langcode: en +region: header +plugin: system_branding_block +settings: + id: system_branding_block + label: 'Site Branding' + provider: system + label_display: '0' +dependencies: + module: + - system + theme: + - bartik +visibility: { } diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme index 1f69448..54484c1 100644 --- a/core/themes/bartik/bartik.theme +++ b/core/themes/bartik/bartik.theme @@ -41,9 +41,6 @@ function bartik_preprocess_html(&$variables) { * Implements hook_preprocess_HOOK() for page templates. */ function bartik_preprocess_page(&$variables) { - // Set the options that apply to both page and maintenance page. - _bartik_process_page($variables); - // Since the title and the shortcut link are both block level elements, // positioning them next to each other is much simpler with a wrapper div. if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) { @@ -76,9 +73,6 @@ function bartik_preprocess_maintenance_page(&$variables) { // Bartik has custom styling for the maintenance page. $variables['#attached']['library'][] = 'bartik/maintenance_page'; - - // Set the options that apply to both page and maintenance page. - _bartik_process_page($variables); } /** @@ -108,23 +102,3 @@ function bartik_preprocess_block(&$variables) { function bartik_preprocess_menu(&$variables) { $variables['attributes']['class'][] = 'clearfix'; } - -/** - * Helper function for handling the site name and slogan. - */ -function _bartik_process_page(&$variables) { - $site_config = \Drupal::config('system.site'); - // Always print the site name and slogan, but if they are toggled off, we'll - // just hide them visually. - $variables['hide_site_name'] = theme_get_setting('features.name') ? FALSE : TRUE; - $variables['hide_site_slogan'] = theme_get_setting('features.slogan') ? FALSE : TRUE; - if ($variables['hide_site_name']) { - // If toggle_name is FALSE, the site_name will be empty, so we rebuild it. - $variables['site_name'] = SafeMarkup::checkPlain($site_config->get('name')); - } - if ($variables['hide_site_slogan']) { - // If toggle_site_slogan is FALSE, the site_slogan will be empty, so we - // rebuild it. - $variables['site_slogan'] = Xss::filterAdmin($site_config->get('slogan')); - } -} diff --git a/core/themes/bartik/css/colors.css b/core/themes/bartik/css/colors.css index d56f24b..9946d5d 100644 --- a/core/themes/bartik/css/colors.css +++ b/core/themes/bartik/css/colors.css @@ -46,9 +46,9 @@ a:active, .region-header, .region-header a, .region-header li a.is-active, -#name-and-slogan, +.site-branding-text, .site-branding-block, -#name-and-slogan a, +.site-branding-text a, .site-branding-block a, .region-secondary-menu .menu-item a { color: #fffeff; diff --git a/core/themes/bartik/css/components/header.css b/core/themes/bartik/css/components/header.css index 84ab4e5..036b1b0 100644 --- a/core/themes/bartik/css/components/header.css +++ b/core/themes/bartik/css/components/header.css @@ -6,7 +6,6 @@ position: relative; } .region-header { - float: right; /* LTR */ margin: .5em 5px .75em; } [dir="rtl"] .region-header { @@ -22,83 +21,67 @@ margin: 1em 5px 1.5em; } } -#logo, .site-logo { float: left; /* LTR */ padding: 4px 4px 4px 9px; /* LTR */ } -[dir="rtl"] #logo, [dir="rtl"] .site-logo { padding: 4px 9px 4px 4px; } @media all and (min-width: 461px) and (max-width: 900px) { - #logo, .site-logo { padding: 5px 0 0 5px; /* LTR */ } - [dir="rtl"] #logo, [dir="rtl"] .site-logo { padding: 5px 5px 0 0; } } @media all and (min-width: 901px) { - #logo, .site-logo { padding: 9px 4px 4px 9px; /* LTR */ } - [dir="rtl"] #logo, [dir="rtl"] .site-logo { padding: 9px 9px 4px 4px; } } -#name-and-slogan, .site-branding-text { float: left; /* LTR */ margin: 0; padding: 5px 10px 8px; } -[dir="rtl"] #name-and-slogan, [dir="rtl"] .site-branding-text { margin: 0 15px 30px 0; } @media all and (min-width: 461px) and (max-width: 900px) { - #name-and-slogan, .site-branding-text { padding: 10px 10px 8px; } } @media all and (min-width: 901px) { - #name-and-slogan, .site-branding-text { padding: 26px 0 0; margin: 0 0 30px 15px; /* LTR */ } - [dir="rtl"] #name-and-slogan, [dir="rtl"] .site-branding-text { margin: 0 15px 30px 0; } } -#site-name, .site-name { font-size: 1.6em; color: #686868; line-height: 1; } @media all and (min-width: 901px) { - #site-name, .site-name { font-size: 1.821em; } } -h1#site-name, h1.site-name { margin: 0; } -#site-name a, .site-name a { font-weight: normal; } -#site-slogan, .site-slogan { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 0.929em; @@ -146,8 +129,8 @@ h1.site-name { margin-right: 0; } .region-header .form-text:hover, -.region-header .form-text:active, -.region-header .form-text:focus { +.region-header .form-text:focus, +.region-header .form-text:active { background: #fff; background: rgba(255, 255, 255, 0.8); } @@ -170,15 +153,15 @@ h1.site-name { padding: 3px 7px; } .region-header .block-menu li a:hover, -.region-header .block-menu li a:active, -.region-header .block-menu li a:focus { +.region-header .block-menu li a:focus, +.region-header .block-menu li a:active { text-decoration: none; background: rgba(255, 255, 255, 0.15); } .region-header .block-menu li:last-child a { border-bottom: 0; } -/* User Login block in the header region */ +/* User Login block in the header region. */ .region-header #block-user-login { width: auto; } @@ -236,14 +219,14 @@ h1.site-name { background: #fff; background: rgba(255, 255, 255, 0.9); } -/* Search block in region header. */ +/* Search block in header region. */ .region-header #block-search-form { width: 208px; } .region-header #block-search-form .form-text { width: 154px; } -/* Language switcher block in region header. */ +/* Language switcher block in header region. */ .region-header .block-locale ul li { display: inline; padding: 0 0.5em; @@ -252,9 +235,7 @@ h1.site-name { border-bottom: none; } -[dir="rtl"] #logo, [dir="rtl"] .site-logo, -[dir="rtl"] #name-and-slogan, [dir="rtl"] .site-branding-text, [dir="rtl"] .region-header .block, [dir="rtl"] .region-header #block-user-login .form-item, diff --git a/core/themes/bartik/css/maintenance-page.css b/core/themes/bartik/css/maintenance-page.css index 9a08d04..ffe0a61 100644 --- a/core/themes/bartik/css/maintenance-page.css +++ b/core/themes/bartik/css/maintenance-page.css @@ -35,19 +35,19 @@ body.maintenance-page { background-color: #fff; background-image: none; } -.maintenance-page #name-and-slogan { +.maintenance-page .site-branding-text { margin-bottom: 50px; margin-left: 0; /* LTR */ padding-top: 20px; font-size: 90%; } -[dir="rtl"] .maintenance-page #name-and-slogan { +[dir="rtl"] .maintenance-page .site-branding-text { margin-right: 0; } -.maintenance-page #name-and-slogan, -.maintenance-page #name-and-slogan a, -.maintenance-page #name-and-slogan a:hover, -.maintenance-page #name-and-slogan a:focus { +.maintenance-page .site-branding-text, +.maintenance-page .site-branding-text a, +.maintenance-page .site-branding-text a:hover, +.maintenance-page .site-branding-text a:focus { color: #777; } .maintenance-page h1#page-title { diff --git a/core/themes/bartik/templates/block--system-branding-block.html.twig b/core/themes/bartik/templates/block--system-branding-block.html.twig index 4a4b733..44ff621 100644 --- a/core/themes/bartik/templates/block--system-branding-block.html.twig +++ b/core/themes/bartik/templates/block--system-branding-block.html.twig @@ -13,9 +13,10 @@ * - site_slogan: Slogan for site as defined in Site information settings. */ #} +{% set attributes = attributes.addClass('branding') %} {% block content %} {% if site_logo %} - {% endif %} @@ -23,7 +24,7 @@
{% if site_name %} - {{ site_name }} + {{ site_name }} {% endif %} {% if site_slogan %} diff --git a/core/themes/bartik/templates/page.html.twig b/core/themes/bartik/templates/page.html.twig index 60b2885..0e20f3f 100644 --- a/core/themes/bartik/templates/page.html.twig +++ b/core/themes/bartik/templates/page.html.twig @@ -25,13 +25,7 @@ * name has been disabled in the theme settings. * - site_slogan: The slogan of the site. This is empty when displaying the site * slogan has been disabled in theme settings. - * - hide_site_name: A flag indicating if the site name has been toggled off on - * the theme settings page. If hidden, the "visually-hidden" class is added - * to make the site name visually hidden, but still accessible. - * - hide_site_slogan: A flag indicating if the site slogan has been toggled off - * on the theme settings page. If hidden, the "visually-hidden" class is - * added to make the site slogan visually hidden, but still accessible. - * + * Page content (in order of occurrence in the default page.html.twig): * - title_prefix: Additional output populated by modules, intended to be * displayed in front of the main title tag that appears in the template. @@ -77,34 +71,6 @@