Created
March 24, 2010 01:35
-
-
Save SupermanScott/341891 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/html/sites/all/modules/contrib/ctools/includes/ajax.inc b/html/sites/all/modules/contrib/ctools/includes/ajax.inc | |
index f2a38f1..c891d69 100644 | |
--- a/html/sites/all/modules/contrib/ctools/includes/ajax.inc | |
+++ b/html/sites/all/modules/contrib/ctools/includes/ajax.inc | |
@@ -451,6 +451,11 @@ function ctools_ajax_render($commands = array()) { | |
// them the first command. | |
global $conf; | |
$query_string = '?'. variable_get('css_js_query_string', '0'); | |
+ $preprocessed = ''; | |
+ $preprocess_js = (variable_get('preprocess_js', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update')); | |
+ $directory = file_directory_path(); | |
+ $is_writable = is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC); | |
+ $preprocess_files = array(); | |
$scripts = drupal_add_js(NULL, NULL); | |
foreach ($scripts as $type => $data) { | |
@@ -466,15 +471,28 @@ function ctools_ajax_render($commands = array()) { | |
// Additionally, go through any remaining scripts if JS preprocessing is on and output the non-cached ones. | |
foreach ($data as $path => $info) { | |
$cdn = $info['cdn'] ? $conf['cdn_static2'] : ''; | |
- | |
- $js_files[] = $cdn . base_path() . $path . ($info['cache'] ? $query_string : '?' . time()); | |
+ if (!$info['preprocess'] || !$is_writable || !$preprocess_js) { | |
+ $js_files[] = $cdn . base_path() . $path . ($info['cache'] ? $query_string : '?' . time()); | |
+ } | |
+ else { | |
+ $preprocess_files[$path] = $info; | |
+ } | |
} | |
} | |
} | |
+ // Add in the aggregated JS file. | |
+ if ($is_writable && $preprocess_js && count($preprocess_files)) { | |
+ $filename = 'js_'. md5(serialize($files) . $query_string) .'.js'; | |
+ $preprocess_file = drupal_build_js_cache($files, $filename); | |
+ $js_files[] = $conf['cdn_static2'] . base_path() . $preprocess_file; | |
+ } | |
+ | |
$css = drupal_add_css(); | |
+ $preprocess_css = (variable_get('preprocess_css', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update')); | |
+ | |
foreach ($css as $media => $types) { | |
// If CSS preprocessing is off, we still need to output the styles. | |
// Additionally, go through any remaining styles if CSS preprocessing is on and output the non-cached ones. | |
@@ -496,13 +514,25 @@ function ctools_ajax_render($commands = array()) { | |
} | |
// Only include the stylesheet if it exists. | |
if (file_exists($file)) { | |
- $css_files[] = array( | |
- 'file' => $conf['cdn_static2'] . base_path() . $file . $query_string, | |
- 'media' => $media, | |
- ); | |
+ if (!$preprocess || !($is_writable && $preprocess_css)) { | |
+ $css_files[] = array( | |
+ 'file' => $conf['cdn_static2'] . base_path() . $file . $query_string, | |
+ 'media' => $media, | |
+ ); | |
+ } | |
} | |
} | |
} | |
+ if ($is_writable && $preprocess_css) { | |
+ // Prefix filename to prevent blocking by firewalls which reject files | |
+ // starting with "ad*". | |
+ $filename = 'css_'. md5(serialize($types) . $query_string) .'.css'; | |
+ $preprocess_file = drupal_build_css_cache($types, $filename); | |
+ $css_files[] = array( | |
+ 'file' => $conf['cdn_static2'] . base_path() . $preprocess_file, | |
+ 'media' => $media, | |
+ ); | |
+ } | |
} | |
if (!empty($settings)) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment