summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-01-18 09:36:35 (GMT)
committerAlex Pott2015-01-18 09:36:35 (GMT)
commitf8aa6c2e8a391d15867ca7ad96545054d4332958 (patch)
treed52fb167f8a4d8e5ad5872ec52873e9d5a6ed097
parentefbeab2ca2f018b165306fe4861a7fbf9aa61d93 (diff)
Issue #2404929 by dileepmaurya, segi, Kristen Pol, prajaankit: Path class on <body> may be language specific, results in CSS bugs
-rw-r--r--core/includes/theme.inc13
-rw-r--r--core/modules/language/src/Tests/LanguageSwitchingTest.php28
2 files changed, 37 insertions, 4 deletions
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 27573e7..5f58419 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1343,8 +1343,15 @@ function template_preprocess_html(&$variables) {
// Add a variable for the root path. This can be used to create a class and
// theme the page depending on the current path (e.g. node, admin, user) as
// well as more specific data like path-frontpage.
- $path = \Drupal::request()->getPathInfo();
- $variables['root_path'] = explode('/', $path)[1];
+ $is_front_page = \Drupal::service('path.matcher')->isFrontPage();
+
+ if ($is_front_page) {
+ $variables['root_path'] = TRUE;
+ }
+ else {
+ $system_path = \Drupal::request()->attributes->get('_system_path');
+ $variables['root_path'] = explode('/', $system_path)[0];
+ }
$site_config = \Drupal::config('system.site');
// Construct page title.
@@ -1356,7 +1363,7 @@ function template_preprocess_html(&$variables) {
}
// @todo Remove once views is not bypassing the view subscriber anymore.
// @see http://drupal.org/node/2068471
- elseif (drupal_is_front_page()) {
+ elseif ($is_front_page) {
$head_title = array(
'title' => t('Home'),
'name' => String::checkPlain($site_config->get('name')),
diff --git a/core/modules/language/src/Tests/LanguageSwitchingTest.php b/core/modules/language/src/Tests/LanguageSwitchingTest.php
index a39da66..d0e2a0d 100644
--- a/core/modules/language/src/Tests/LanguageSwitchingTest.php
+++ b/core/modules/language/src/Tests/LanguageSwitchingTest.php
@@ -163,7 +163,6 @@ class LanguageSwitchingTest extends WebTestBase {
/**
* Test languge switcher links for domain based negotiation
*/
-
function testLanguageBlockWithDomain() {
// Add the Italian language.
ConfigurableLanguage::createFromLangcode('it')->save();
@@ -242,6 +241,33 @@ class LanguageSwitchingTest extends WebTestBase {
}
/**
+ * Check the path-admin class, as same as on default language.
+ */
+ function testLanguageBodyClass() {
+ $searched_class = 'path-admin';
+
+ // Add language.
+ $edit = array(
+ 'predefined_langcode' => 'fr',
+ );
+ $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
+
+ // Enable URL language detection and selection.
+ $edit = array('language_interface[enabled][language-url]' => '1');
+ $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
+
+ // Go to admin/config, check the class on default language.
+ $this->drupalGet('admin/config');
+ $class = $this->xpath('//body[contains(@class, :class)]', array(':class' => $searched_class));
+ $this->assertTrue(isset($class[0]), t('The path-admin class appears on default language.'));
+
+ // Go to admin/config, check the class on french language.
+ $this->drupalGet('fr/admin/config');
+ $class = $this->xpath('//body[contains(@class, :class)]', array(':class' => $searched_class));
+ $this->assertTrue(isset($class[0]), t('The path-admin class same as on default language.'));
+ }
+
+ /**
* For authenticated users, the "active" class is set by JavaScript.
*
* @see testLanguageLinkActiveClass()