summaryrefslogtreecommitdiff
path: root/modules/locale
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-07-30 19:57:10 +0000
committerDries Buytaert <dries@buytaert.net>2009-07-30 19:57:10 +0000
commit1a5c71e2dab7a4ea03fce8edd850022abd641d20 (patch)
tree769112ea6b3cdae62668354a115be6317a6fb420 /modules/locale
parenteb34d29999f0f0c4f36201cb01be9f936f9a1fc1 (diff)
downloadbrdo-1a5c71e2dab7a4ea03fce8edd850022abd641d20.tar.gz
brdo-1a5c71e2dab7a4ea03fce8edd850022abd641d20.tar.bz2
- Patch #92877 by mfer, Rob Loach, Damien Tournoud, et al: add numeric weight to drupal_add_css.
Diffstat (limited to 'modules/locale')
-rw-r--r--modules/locale/locale.module27
1 files changed, 27 insertions, 0 deletions
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 0ece6958b..3e6c987fb 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -583,6 +583,33 @@ function locale_js_alter(&$javascript) {
}
}
+/*
+ * Implement 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;
+ }
+ }
+ }
+ }
+}
+
// ---------------------------------------------------------------------------------
// Language switcher block