From 15fb95a9311b73255f96ac6a1e9fb1fee7bcc418 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Thu, 9 Sep 2010 19:48:48 +0000 Subject: [PATCH] Moved dependency of $wgUseDataURLs out of CSSMin and into ResourceLoaderModule. --- includes/CSSMin.php | 9 ++++----- includes/ResourceLoaderModule.php | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/CSSMin.php b/includes/CSSMin.php index 765aed5403..40f893d27a 100644 --- a/includes/CSSMin.php +++ b/includes/CSSMin.php @@ -24,7 +24,7 @@ * @author Trevor Parscal */ class CSSMin { - + /* Constants */ /** @@ -69,8 +69,7 @@ class CSSMin { * @param $path string File path where the source was read from * @return string Remapped CSS data */ - public static function remap( $source, $path ) { - global $wgUseDataURLs; + public static function remap( $source, $path, $embed = true ) { $pattern = '/((?\s*\/\*\s*\@embed\s*\*\/)(?[^\;\}]*))?url\([\'"]?(?[^\?\)\:]*)\??[^\)]*[\'"]?\)(?[^;]*)[\;]?/'; $offset = 0; @@ -81,14 +80,14 @@ class CSSMin { $rule = $match['rule'][0]; $extra = $match['extra'][0]; $file = "{$path}/{$match['file'][0]}"; - + // Only proceed if we can access the file if ( file_exists( $file ) ) { // Add version parameter as a time-stamp in ISO 8601 format, using Z for the timezone, meaning GMT $url = "{$file}?" . gmdate( 'Y-m-d\TH:i:s\Z', round( filemtime( $file ), -2 ) ); // Detect when URLs were preceeded with embed tags, and also verify file size is below the limit - if ( $wgUseDataURLs && $match['embed'][1] > 0 && filesize( $file ) < self::EMBED_SIZE_LIMIT ) { + if ( $embed && $match['embed'][1] > 0 && filesize( $file ) < self::EMBED_SIZE_LIMIT ) { // If we ever get to PHP 5.3, we should use the Fileinfo extension instead of mime_content_type $type = mime_content_type( $file ); // Strip off any trailing = symbols (makes browsers freak out) diff --git a/includes/ResourceLoaderModule.php b/includes/ResourceLoaderModule.php index b824ec35d6..4c84ff1b26 100644 --- a/includes/ResourceLoaderModule.php +++ b/includes/ResourceLoaderModule.php @@ -613,7 +613,8 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @return string Remapped CSS */ protected static function remapStyle( $file ) { - return CSSMin::remap( file_get_contents( self::remapFilename( $file ) ), dirname( $file ) ); + global $wgUseDataURLs; + return CSSMin::remap( file_get_contents( self::remapFilename( $file ) ), dirname( $file ), $wgUseDataURLs ); } } -- 2.20.1