summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnAlbin2011-04-05 11:50:45 (GMT)
committer JohnAlbin2011-04-05 11:50:45 (GMT)
commit49b6843da3af4b7bd09b50650e02f49bfd1795be (patch)
tree8c4fed24b7e30d2466825ce873b9fd7701a816e2
parentc33d648eb0d59c77547fe816fa0baea7f8de1d58 (diff)
by JohnAlbin: Update template.conditional-styles.inc to use latest code from Conditional Styles 6.x-1.2.
-rw-r--r--template.php6
-rw-r--r--zen-internals/template.conditional-styles.inc25
2 files changed, 16 insertions, 15 deletions
diff --git a/template.php b/template.php
index fc41913..0389d75 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 eb23dbc..fc4d04e 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 .= "<link type=\"text/css\" rel=\"stylesheet\" media=\"$media\" href=\"$base_path$path/$file$query_string\" />\n";
- if ($language->direction == LANGUAGE_RTL){
- $file_rtl = str_replace('.css', '-rtl.css', $file);
- if (file_exists("./$path/$file_rtl")) {
- $output .= "<link type=\"text/css\" rel=\"stylesheet\" media=\"$media\" href=\"$base_path$path/$file_rtl$query_string\" />\n";
- }
+ $link = "<link type=\"text/css\" rel=\"stylesheet\" media=\"$media\" href=\"$base_path$path/$file$query_string\" />\n";
+ $output .= $link;
+ $output_rtl .= $link;
+ $file_rtl = str_replace('.css', '-rtl.css', $file);
+ if (file_exists("./$path/$file_rtl")) {
+ $output_rtl .= "<link type=\"text/css\" rel=\"stylesheet\" media=\"$media\" href=\"$base_path$path/$file_rtl$query_string\" />\n";
}
}
}
}
if ($output) {
$conditional_styles .= "<!--[$condition]>\n$output<![endif]-->\n";
+ $conditional_styles_rtl .= "<!--[$condition]>\n$output_rtl<![endif]-->\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');
}
}
}