base_theme)) { $theme_paths[$theme] = conditional_styles_paths_to_basetheme($themes[$theme]->base_theme); } $theme_paths[$theme][$theme] = dirname($themes[$theme]->filename); } return $theme_paths[$theme]; } /** * When the theme registry is rebuilt, we also build the conditional stylesheets. */ function _conditional_styles_theme($existing, $type, $theme, $path) { // Process the conditional stylesheets for every active theme. $themes = list_themes(); foreach (array_keys($themes) AS $theme) { // We only need to process active themes. if ($themes[$theme]->status || $GLOBALS['theme'] == $theme) { $paths = conditional_styles_paths_to_basetheme($theme); // Grab all the conditional stylesheets. $stylesheets = array(); // Start with the base theme and travel up the chain to the active theme. foreach ($paths AS $theme_name => $path) { // Look at the conditional-stylesheets defined in the theme's .info file. if (!empty($themes[$theme_name]->info['conditional-stylesheets'])) { foreach ($themes[$theme_name]->info['conditional-stylesheets'] AS $condition => $css) { // Allow the theme to override its base themes' styles. foreach ($css AS $media => $files) { foreach ($files AS $file) { $stylesheets[$condition][$media][$file] = $path; } } } } } // Render the stylesheets to link elements. $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_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")) { $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"; } } } // Save the stylesheets for later retrieval. 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'); } } } // Return nothing. return array(); }