Commit 615bbeaa authored by Dries's avatar Dries

- Patch #1405604 by aspilicious: Fixed RTL stylesheets don't get triggered...

- Patch #1405604 by aspilicious: Fixed RTL stylesheets don't get triggered when locale isn't enabled.
parent 1b6ba524
...@@ -198,3 +198,30 @@ function language_delete($langcode) { ...@@ -198,3 +198,30 @@ function language_delete($langcode) {
} }
return FALSE; return FALSE;
} }
/**
* Implements hook_css_alter().
*
* This function checks all CSS files currently added via drupal_add_css() and
* and checks to see if a related right to left CSS file should be included.
*/
function language_css_alter(&$css) {
global $language;
// If the current language is RTL, add the CSS file with the RTL overrides.
if ($language->direction == LANGUAGE_RTL) {
foreach ($css as $data => $item) {
// Only provide RTL overrides for files.
if ($item['type'] == 'file') {
$rtl_path = str_replace('.css', '-rtl.css', $item['data']);
if (file_exists($rtl_path) && !isset($css[$rtl_path])) {
// Replicate the same item, but with the RTL path and a little larger
// weight so that it appears directly after the original CSS file.
$item['data'] = $rtl_path;
$item['weight'] += 0.01;
$css[$rtl_path] = $item;
}
}
}
}
}
...@@ -902,33 +902,6 @@ function locale_js_alter(&$javascript) { ...@@ -902,33 +902,6 @@ function locale_js_alter(&$javascript) {
} }
} }
/**
* Implements hook_css_alter().
*
* This function checks all CSS files currently added via drupal_add_css() and
* and checks to see if a related right to left CSS file should be included.
*/
function locale_css_alter(&$css) {
global $language;
// If the current language is RTL, add the CSS file with the RTL overrides.
if ($language->direction == LANGUAGE_RTL) {
foreach ($css as $data => $item) {
// Only provide RTL overrides for files.
if ($item['type'] == 'file') {
$rtl_path = str_replace('.css', '-rtl.css', $item['data']);
if (file_exists($rtl_path) && !isset($css[$rtl_path])) {
// Replicate the same item, but with the RTL path and a little larger
// weight so that it appears directly after the original CSS file.
$item['data'] = $rtl_path;
$item['weight'] += 0.01;
$css[$rtl_path] = $item;
}
}
}
}
}
/** /**
* Implement hook_library_info_alter(). * Implement hook_library_info_alter().
* *
......
...@@ -591,7 +591,7 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase { ...@@ -591,7 +591,7 @@ class CommonCascadingStylesheetsTestCase extends DrupalWebTestCase {
} }
function setUp() { function setUp() {
parent::setUp('php', 'locale', 'common_test'); parent::setUp('php', 'language', 'common_test');
// Reset drupal_add_css() before each test. // Reset drupal_add_css() before each test.
drupal_static_reset('drupal_add_css'); drupal_static_reset('drupal_add_css');
} }
......
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