diff --git a/template.php b/template.php index fc4191360611b57885e21a09bbb90f70a7e47b3a..0389d75876393e8d922a861ac671e74a09d8ebbb 100644 --- a/template.php +++ b/template.php @@ -324,7 +324,8 @@ function zen_preprocess_page(&$vars, $hook) { } // Add conditional stylesheets. elseif (!module_exists('conditional_styles')) { - $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], ''); + $language = $GLOBALS['language']->direction == LANGUAGE_RTL ? '_rtl' : ''; + $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'] . $language, ''); $vars['styles'] .= $vars['conditional_styles']; } @@ -410,7 +411,8 @@ function zen_preprocess_maintenance_page(&$vars, $hook) { } // Add conditional stylesheets. elseif (!module_exists('conditional_styles')) { - $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], ''); + $language = $GLOBALS['language']->direction == LANGUAGE_RTL ? '_rtl' : ''; + $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'] . $language, ''); $vars['styles'] .= $vars['conditional_styles']; } } diff --git a/zen-internals/template.conditional-styles.inc b/zen-internals/template.conditional-styles.inc index eb23dbcde3b37987bf1aaebdde2b3f8be9e21894..fc4d04e4c4d50727a0b6bd02da879a49a83ddaea 100644 --- a/zen-internals/template.conditional-styles.inc +++ b/zen-internals/template.conditional-styles.inc @@ -38,12 +38,7 @@ function conditional_styles_paths_to_basetheme($theme) { * When the theme registry is rebuilt, we also build the conditional stylesheets. */ function _conditional_styles_theme($existing, $type, $theme, $path) { - // @TODO: For PHP 4 compatibility we use foreach (array_keys($array) AS $key). - // When PHP 5 becomes required (Drupal 7.x), use the following faster - // implementation: foreach ($array AS $key => &$value) {} - // Process the conditional stylesheets for every active theme. - global $language; $themes = list_themes(); foreach (array_keys($themes) AS $theme) { // We only need to process active themes. @@ -67,29 +62,30 @@ function _conditional_styles_theme($existing, $type, $theme, $path) { } } // Render the stylesheets to link elements. - $conditional_styles = ''; + $conditional_styles = $conditional_styles_rtl = ''; if (!empty($stylesheets)) { $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1); $base_path = base_path(); foreach ($stylesheets AS $condition => $css) { // Each condition requires its own set of links. - $output = ''; + $output = $output_rtl = ''; foreach ($css AS $media => $files) { foreach ($files AS $file => $path) { // Don't allow non-existent stylesheets to clutter the logs with 404. if (file_exists("./$path/$file")) { - $output .= "\n"; - if ($language->direction == LANGUAGE_RTL){ - $file_rtl = str_replace('.css', '-rtl.css', $file); - if (file_exists("./$path/$file_rtl")) { - $output .= "\n"; - } + $link = "\n"; + $output .= $link; + $output_rtl .= $link; + $file_rtl = str_replace('.css', '-rtl.css', $file); + if (file_exists("./$path/$file_rtl")) { + $output_rtl .= "\n"; } } } } if ($output) { $conditional_styles .= "\n"; + $conditional_styles_rtl .= "\n"; } } } @@ -97,13 +93,16 @@ function _conditional_styles_theme($existing, $type, $theme, $path) { if ($conditional_styles) { if (db_is_active()) { variable_set('conditional_styles_' . $theme, $conditional_styles); + variable_set('conditional_styles_' . $theme . '_rtl', $conditional_styles_rtl); } else { $GLOBALS['conf']['conditional_styles_' . $theme] = $conditional_styles; + $GLOBALS['conf']['conditional_styles_' . $theme . '_rtl'] = $conditional_styles_rtl; } } elseif (db_is_active()) { variable_del('conditional_styles_' . $theme); + variable_del('conditional_styles_' . $theme . '_rtl'); } } }