summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-05-27 17:57:48 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-05-27 17:57:48 +0000
commit860947d3c87e8ebd53031ac8077d1dce24716e32 (patch)
treea333fef28fb5ad71b93a6b933a384f6439ba99d2 /includes
parent7f83d274b5eead1c1dc0a92036afccc11cdbd5d8 (diff)
downloadbrdo-860947d3c87e8ebd53031ac8077d1dce24716e32.tar.gz
brdo-860947d3c87e8ebd53031ac8077d1dce24716e32.tar.bz2
#145737 by yhager, documentation cleaned up by myself: add support for RTL CSS overrides and default RTL CSS override files for modules
Note: properties, which are different in the RTL display are marked with /* LTR */ in default CSS files now, so maintainers remember that changing them should also have an effect on RTL CSS files. This should open the way for better RTL (right-to-left written) language (such as Arabic and Hebrew) support.
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc19
1 files changed, 18 insertions, 1 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 513b6fc9f..e5bdf49a2 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1450,6 +1450,14 @@ function drupal_add_link($attributes) {
* @param $path
* (optional) The path to the CSS file relative to the base_path(), e.g.,
* /modules/devel/devel.css.
+ *
+ * If the direction of the current language is right-to-left (Hebrew,
+ * Arabic, etc.), the function will also look for an RTL CSS file and append
+ * it to the list. The name of this file should have an '-rtl.css' suffix.
+ * For example a CSS file called 'name.css' will have a 'name-rtl.css'
+ * file added to the list, if exists in the same directory. This CSS file
+ * should contain overrides for properties which should be reversed or
+ * otherwise different in a right-to-left display.
* @param $type
* (optional) The type of stylesheet that is being added. Types are: module
* or theme.
@@ -1483,6 +1491,7 @@ function drupal_add_link($attributes) {
*/
function drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preprocess = TRUE) {
static $css = array();
+ global $language;
// Create an array of CSS files for each media type first, since each type needs to be served
// to the browser differently.
@@ -1492,8 +1501,16 @@ function drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preproc
$css[$media] = array('module' => array(), 'theme' => array());
}
$css[$media][$type][$path] = $preprocess;
- }
+ // If the current language is RTL, add the CSS file with RTL overrides.
+ if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
+ $rtl_path = str_replace('.css', '-rtl.css', $path);
+ if (file_exists($rtl_path)) {
+ $css[$media][$type][$rtl_path] = $preprocess;
+ }
+ }
+ }
+
return $css;
}