Index: fusion_core/template.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/themes/fusion/fusion_core/template.php,v
retrieving revision 1.1.2.9
diff -u -F '^f' -r1.1.2.9 template.php
--- fusion_core/template.php	4 Jul 2010 22:34:29 -0000	1.1.2.9
+++ fusion_core/template.php	12 Nov 2010 12:29:12 -0000
@@ -104,20 +104,44 @@ function fusion_core_preprocess_page(&$v
   // Add grid, color, ie6, ie7, ie8 & local stylesheets, including inherited & rtl versions
   $grid_style = '/css/' . theme_get_setting('theme_grid');
   $themes = fusion_core_theme_paths($theme_key);
-  $vars['setting_styles'] = $vars['ie6_styles'] = $vars['ie7_styles'] = $vars['ie8_styles'] = $vars['local_styles'] = '';
+  $style_categories = array(
+    // category => file basename
+    'setting'   => $grid_style,
+    'ie6'       => 'css/ie6-fixes',
+    'ie7'       => 'css/ie7-fixes',
+    'ie8'       => 'css/ie8-fixes',
+    'local'     => 'css/local',
+  );
+  $link_prefix = '<link type="text/css" rel="stylesheet" media="all" href="';
+  $link_suffix = '" />' . "\n";
+  // Initialize.
+  $css_files = array();
+  foreach (array_keys($style_categories) as $category) {
+    $vars[$category . '_styles'] = '';
+  }
+  // Find all CSS files that should be added.
   foreach ($themes as $name => $path) {
-    $link = '<link type="text/css" rel="stylesheet" media="all" href="' . base_path() . $path;
-    $vars['setting_styles'] .= (file_exists($path . $grid_style . '.css')) ? $link . $grid_style . '.css" />' . "\n" : '';
-    $vars['ie6_styles'] .= (file_exists($path . '/css/ie6-fixes.css')) ? $link . '/css/ie6-fixes.css" />' . "\n" : '';
-    $vars['ie7_styles'] .= (file_exists($path . '/css/ie7-fixes.css')) ? $link . '/css/ie7-fixes.css" />' . "\n" : '';
-    $vars['ie8_styles'] .= (file_exists($path . '/css/ie8-fixes.css')) ? $link . '/css/ie8-fixes.css" />' . "\n" : '';
-    $vars['local_styles'] .= (file_exists($path . '/css/local.css')) ? $link . '/css/local.css" />' . "\n" : '';
-    if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
-      $vars['setting_styles'] .= (file_exists($path . $grid_style . '-rtl.css')) ? $link . $grid_style . '-rtl.css" />' . "\n" : '';
-      $vars['ie6_styles'] .= (file_exists($path . '/css/ie6-fixes-rtl.css')) ? $link . '/css/ie6-fixes-rtl.css" />' . "\n" : '';
-      $vars['ie7_styles'] .= (file_exists($path . '/css/ie7-fixes-rtl.css')) ? $link . '/css/ie7-fixes-rtl.css" />' . "\n" : '';
-      $vars['ie8_styles'] .= (file_exists($path . '/css/ie8-fixes-rtl.css')) ? $link . '/css/ie8-fixes-rtl.css" />' . "\n" : '';
-      $vars['local_styles'] .= (file_exists($path . '/css/local-rtl.css')) ? $link . '/css/local-rtl.css" />' . "\n" : '';
+    foreach ($style_categories as $category => $file_basename) {
+      // Check if a CSS file for this style category exists.
+      if (file_exists($path . $file_basename . '.css')) {
+        $css_files[$category] = $path . $file_basename . '.css';
+      }
+      // Check if a CSS file for this style category, but in RTL, exists.
+      if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL && file_exists($path . $file_basename . '-rtl.css')) {
+        $css_files[$category] = $path . $file_basename . '-rtl.css';
+      }
+    }
+  }
+  // Add all found CSS files to their corresponding style categories.
+  foreach ($css_files as $category => $css_file) {
+    // Use the file_create_url() function to create file URLs when it's
+    // available, to add automatic support for CDN integration.
+    // This is also the way it will work in Drupal 7.
+    if (module_exists('cdn')) {
+      $vars[$category . '_styles'] .= $link_prefix . file_create_url($css_file) . $link_suffix;
+    }
+    else {
+      $vars[$category . '_styles'] .= $link_prefix . base_path() . $css_file . $link_suffix;
     }
   }
 
@@ -133,7 +157,15 @@ function fusion_core_preprocess_page(&$v
         $imports = array();
         foreach ($types as $files) {
           foreach ($files as $file => $preprocess) {
-            $imports[] = '@import "'. base_path() . $file .'";';
+            // Use the file_create_url() function to create file URLs when it's
+            // available, to add automatic support for CDN integration.
+            // This is also the way it will work in Drupal 7.
+            if (module_exists('cdn')) {
+              $imports[] = '@import "'. file_create_url($file) .'";';
+            }
+            else {
+              $imports[] = '@import "'. base_path() . $file .'";';
+            }
             if (count($imports) == 30) {
               $styles .= $prefix . implode("\n", $imports) . $suffix;
               $imports = array();
