MediaWiki
1.30.0
|
Transforms CSS data. More...
Static Public Member Functions | |
static | buildUrlValue ( $url) |
Build a CSS 'url()' value for the given URL, quoting parentheses (and other funny characters) and escaping quotes as necessary. More... | |
static | encodeImageAsDataURI ( $file, $type=null, $ie8Compat=true) |
Encode an image file as a data URI. More... | |
static | encodeStringAsDataURI ( $contents, $type, $ie8Compat=true) |
Encode file contents as a data URI with chosen MIME type. More... | |
static | getLocalFileReferences ( $source, $path) |
Get a list of local files referenced in a stylesheet (includes non-existent files). More... | |
static | getMimeType ( $file) |
static | minify ( $css) |
Removes whitespace from CSS data. More... | |
static | remap ( $source, $local, $remote, $embedData=true) |
Remaps CSS URL paths and automatically embeds data URIs for CSS rules or url() values preceded by an / * @embed * / comment. More... | |
static | remapOne ( $file, $query, $local, $remote, $embed) |
Remap or embed a CSS URL path. More... | |
static | serializeStringValue ( $value) |
Serialize a string (escape and quote) for use as a CSS string value. More... | |
Public Attributes | |
const | COMMENT_REGEX = '\/\*.*?\*\/' |
const | DATA_URI_SIZE_LIMIT = 32768 |
Internet Explorer data URI length limit. More... | |
const | EMBED_REGEX = '\/\*\s*\@embed\s*\*\/' |
Static Protected Member Functions | |
static | isLocalUrl ( $maybeUrl) |
Is this CSS rule referencing a local URL? More... | |
static | isRemoteUrl ( $maybeUrl) |
Is this CSS rule referencing a remote URL? More... | |
Static Protected Attributes | |
static array | $mimeTypes |
List of common image files extensions and MIME-types. More... | |
Static Private Member Functions | |
static | getUrlRegex () |
static | processUrlMatch (array &$match, $flags=0) |
Transforms CSS data.
This class provides minification, URL remapping, URL extracting, and data-URL embedding.
Definition at line 30 of file CSSMin.php.
|
static |
Build a CSS 'url()' value for the given URL, quoting parentheses (and other funny characters) and escaping quotes as necessary.
See http://www.w3.org/TR/css-syntax-3/#consume-a-url-token
string | $url | URL to process |
"url($url)"
, quoted/escaped if necessary Definition at line 211 of file CSSMin.php.
Referenced by ResourceLoaderImageModule\getCssDeclarations(), Vector\ResourceLoaderLessModule\getLessVars(), ResourceLoaderSkinModule\getStyles(), CssContentHandler\makeRedirectContent(), and remap().
|
static |
Encode an image file as a data URI.
If the image file has a suitable MIME type and size, encode it as a data URI, base64-encoded for binary files or just percent-encoded otherwise. Return false if the image type is unfamiliar or file exceeds the size limit.
string | $file | Image file to encode. |
string | null | $type | File's MIME type or null. If null, CSSMin will try to autodetect the type. |
bool | $ie8Compat | By default, a data URI will only be produced if it can be made short enough to fit in Internet Explorer 8 (and earlier) URI length limit (32,768 bytes). Pass false to remove this limitation. |
Definition at line 111 of file CSSMin.php.
References $type, encodeStringAsDataURI(), and getMimeType().
Referenced by Vector\ResourceLoaderLessModule\getLessVars(), and remapOne().
|
static |
Encode file contents as a data URI with chosen MIME type.
The URI will be base64-encoded for binary files or just percent-encoded otherwise.
string | $contents | File contents to encode. |
string | $type | File's MIME type. |
bool | $ie8Compat | See encodeImageAsDataURI(). |
Definition at line 139 of file CSSMin.php.
References $type.
Referenced by encodeImageAsDataURI(), and ResourceLoaderImage\getDataUri().
|
static |
Get a list of local files referenced in a stylesheet (includes non-existent files).
string | $source | CSS stylesheet source to process |
string | $path | File path where the source was read from |
Definition at line 69 of file CSSMin.php.
References $matches, $path, $source, as, and processUrlMatch().
Referenced by ResourceLoaderFileModule\readStyleFile(), and ResourcesTest\testCommentedLocalFileReferences().
|
static |
string | $file |
Definition at line 192 of file CSSMin.php.
References $ext.
Referenced by encodeImageAsDataURI(), and remap().
|
staticprivate |
Definition at line 398 of file CSSMin.php.
Referenced by remap().
|
staticprotected |
Is this CSS rule referencing a local URL?
string | $maybeUrl |
Definition at line 388 of file CSSMin.php.
|
staticprotected |
Is this CSS rule referencing a remote URL?
string | $maybeUrl |
Definition at line 375 of file CSSMin.php.
|
static |
Removes whitespace from CSS data.
string | $css | CSS data to minify |
Definition at line 530 of file CSSMin.php.
References $css.
Referenced by BenchmarkCSSMin\execute(), MinifyScript\minify(), and ResourcesTest\testStyleMedia().
|
staticprivate |
Definition at line 432 of file CSSMin.php.
References $flags.
Referenced by getLocalFileReferences(), and remap().
|
static |
Remaps CSS URL paths and automatically embeds data URIs for CSS rules or url() values preceded by an / * @embed * / comment.
string | $source | CSS data to remap |
string | $local | File path where the source was read from |
string | $remote | URL path to the file |
bool | $embedData | If false, never do any data URI embedding, even if / * @embed * / is found. |
Definition at line 233 of file CSSMin.php.
References $mimeTypes, $source, buildUrlValue(), captcha-old\count, EMBED_REGEX, getMimeType(), getUrlRegex(), processUrlMatch(), remapOne(), true, and use.
Referenced by BenchmarkCSSMin\execute(), and ResourceLoaderFileModule\readStyleFile().
|
static |
Remap or embed a CSS URL path.
string | $file | URL to remap/embed |
string | $query | |
string | $local | File path where the source was read from |
string | $remote | URL path to the file |
bool | $embed | Whether to do any data URI embedding |
Definition at line 471 of file CSSMin.php.
References $query, encodeImageAsDataURI(), PROTO_RELATIVE, OutputPage\transformFilePath(), wfExpandUrl(), and wfRemoveDotSegments().
Referenced by remap().
|
static |
Serialize a string (escape and quote) for use as a CSS string value.
http://www.w3.org/TR/2013/WD-cssom-20131205/#serialize-a-string
string | $value |
Exception |
Definition at line 177 of file CSSMin.php.
References $value.
Referenced by ResourceLoaderEditToolbarModule\getLessVars().
|
staticprotected |
List of common image files extensions and MIME-types.
Definition at line 48 of file CSSMin.php.
Referenced by remap().
const CSSMin::COMMENT_REGEX = '\/\*.*?\*\/' |
Definition at line 43 of file CSSMin.php.
const CSSMin::DATA_URI_SIZE_LIMIT = 32768 |
Internet Explorer data URI length limit.
Definition at line 40 of file CSSMin.php.
const CSSMin::EMBED_REGEX = '\/\*\s*\@embed\s*\*\/' |
Definition at line 42 of file CSSMin.php.
Referenced by remap().