function _cdn_build_css_cache in CDN 6.2
Same name and namespace in other branches
- 7.2 cdn.basic.css.inc \_cdn_build_css_cache()
1 call to _cdn_build_css_cache()
- _cdn_css_aggregate in ./cdn.basic.css.inc
- Mostly based on drupal_get_css().
File
- ./cdn.basic.css.inc, line 95
- Overrides of Drupal's CSS aggregation system. Ensures that files referenced
by CSS files are also served from the CDN, according to the CDN module's
CSS aggregation rules.
Code
function _cdn_build_css_cache($types, $filename) {
$data = '';
$csspath = file_create_path('css');
file_check_directory($csspath, FILE_CREATE_DIRECTORY);
if (!file_exists($csspath . '/' . $filename)) {
foreach ($types as $type) {
foreach ($type as $file => $cache) {
if ($cache) {
$contents = drupal_load_stylesheet($file, TRUE);
$base = dirname($file) . '/';
_cdn_build_css_path(NULL, $base);
$data .= preg_replace_callback('/url\\([\'"]?(?![a-z]+:|\\/+)([^\'")]+)[\'"]?\\)/i', '_cdn_build_css_path', $contents);
}
}
}
$regexp = '/@import[^;]+;/i';
preg_match_all($regexp, $data, $matches);
$data = preg_replace($regexp, '', $data);
$data = implode('', $matches[0]) . $data;
file_save_data($data, $csspath . '/' . $filename, FILE_EXISTS_REPLACE);
}
return $csspath . '/' . $filename;
}