summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Stein2011-01-19 15:05:50 (GMT)
committerJoel Stein2011-01-19 15:05:50 (GMT)
commit24d56be0d4fa94a0e8917044ab673565b5f3cb02 (patch)
treee1a7718585c2e8a9ce73901c2e31d0e992d18536
parentd70385e6dd7362a74c4695f243f377bb99b1c81c (diff)
Resolved imports and paths when saving non-optimized files.6.x-1.3
-rwxr-xr-xskin.module13
1 files changed, 12 insertions, 1 deletions
diff --git a/skin.module b/skin.module
index a1d1bc9..aaaf829 100755
--- a/skin.module
+++ b/skin.module
@@ -83,7 +83,18 @@ function _skin_replace_callback($matches) {
$skin_path = file_create_path('skin') . (!$optimized ? '/'. dirname($filepath_minus_query) : '');
if (file_check_directory($skin_path, FILE_CREATE_DIRECTORY) or mkdir($skin_path, 0755, TRUE)) {
$filename = $skin_path .'/'. $info['filename'] .'.'. $info['extension'];
- $contents = file_get_contents($filepath_minus_query);
+ // Optimized files have already resolved imports and prefixed paths.
+ if ($optimized) {
+ $contents = file_get_contents($filepath_minus_query);
+ }
+ // Unoptimized files need to resolve imports and prefix paths.
+ // See drupal_build_css_cache().
+ else {
+ $contents = drupal_load_stylesheet($filepath_minus_query);
+ $base = base_path() . dirname($filepath_minus_query) .'/';
+ _drupal_build_css_path(NULL, $base);
+ $contents = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', '_drupal_build_css_path', $contents);
+ }
if (!file_save_data($contents, $filename, FILE_EXISTS_REPLACE)) {
unset($filename);
}