Moved dependency of $wgUseDataURLs out of CSSMin and into ResourceLoaderModule.
This commit is contained in:
parent
db2fd9007f
commit
15fb95a931
2 changed files with 6 additions and 6 deletions
|
|
@ -24,7 +24,7 @@
|
||||||
* @author Trevor Parscal
|
* @author Trevor Parscal
|
||||||
*/
|
*/
|
||||||
class CSSMin {
|
class CSSMin {
|
||||||
|
|
||||||
/* Constants */
|
/* Constants */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -69,8 +69,7 @@ class CSSMin {
|
||||||
* @param $path string File path where the source was read from
|
* @param $path string File path where the source was read from
|
||||||
* @return string Remapped CSS data
|
* @return string Remapped CSS data
|
||||||
*/
|
*/
|
||||||
public static function remap( $source, $path ) {
|
public static function remap( $source, $path, $embed = true ) {
|
||||||
global $wgUseDataURLs;
|
|
||||||
|
|
||||||
$pattern = '/((?<embed>\s*\/\*\s*\@embed\s*\*\/)(?<rule>[^\;\}]*))?url\([\'"]?(?<file>[^\?\)\:]*)\??[^\)]*[\'"]?\)(?<extra>[^;]*)[\;]?/';
|
$pattern = '/((?<embed>\s*\/\*\s*\@embed\s*\*\/)(?<rule>[^\;\}]*))?url\([\'"]?(?<file>[^\?\)\:]*)\??[^\)]*[\'"]?\)(?<extra>[^;]*)[\;]?/';
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
|
|
@ -81,14 +80,14 @@ class CSSMin {
|
||||||
$rule = $match['rule'][0];
|
$rule = $match['rule'][0];
|
||||||
$extra = $match['extra'][0];
|
$extra = $match['extra'][0];
|
||||||
$file = "{$path}/{$match['file'][0]}";
|
$file = "{$path}/{$match['file'][0]}";
|
||||||
|
|
||||||
// Only proceed if we can access the file
|
// Only proceed if we can access the file
|
||||||
if ( file_exists( $file ) ) {
|
if ( file_exists( $file ) ) {
|
||||||
// Add version parameter as a time-stamp in ISO 8601 format, using Z for the timezone, meaning GMT
|
// 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 ) );
|
$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
|
// 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
|
// If we ever get to PHP 5.3, we should use the Fileinfo extension instead of mime_content_type
|
||||||
$type = mime_content_type( $file );
|
$type = mime_content_type( $file );
|
||||||
// Strip off any trailing = symbols (makes browsers freak out)
|
// Strip off any trailing = symbols (makes browsers freak out)
|
||||||
|
|
|
||||||
|
|
@ -613,7 +613,8 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
|
||||||
* @return string Remapped CSS
|
* @return string Remapped CSS
|
||||||
*/
|
*/
|
||||||
protected static function remapStyle( $file ) {
|
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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue