ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Assetic\Util\CssUtils Class Reference

CSS Utils. More...

+ Inheritance diagram for Assetic\Util\CssUtils:
+ Collaboration diagram for Assetic\Util\CssUtils:

Static Public Member Functions

static filterReferences ($content, $callback)
 Filters all references – url() and "@import" – through a callable. More...
 
static filterUrls ($content, $callback)
 Filters all CSS url()'s through a callable. More...
 
static filterImports ($content, $callback, $includeUrl=true)
 Filters all CSS imports through a callable. More...
 
static filterIEFilters ($content, $callback)
 Filters all IE filters (AlphaImageLoader filter) through a callable. More...
 
static filterCommentless ($content, $callback)
 Filters each non-comment part through a callable. More...
 
static extractImports ($content)
 Extracts all references from the supplied CSS content. More...
 

Data Fields

const REGEX_URLS = '/url\((["\']?)(?P<url>.*?)(\\1)\)/'
 
const REGEX_IMPORTS = '/@import (?:url\()?(\'|"|)(?P<url>[^\'"\)\n\r]*)\1\)?;?/'
 
const REGEX_IMPORTS_NO_URLS = '/@import (?!url\()(\'|"|)(?P<url>[^\'"\)\n\r]*)\1;?/'
 
const REGEX_IE_FILTERS = '/src=(["\']?)(?P<url>.*?)\\1/'
 
const REGEX_COMMENTS = '/(\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)/'
 

Private Member Functions

 __construct ()
 

Detailed Description

CSS Utils.

Author
Kris Wallsmith kris..nosp@m.wall.nosp@m.smith.nosp@m.@gma.nosp@m.il.co.nosp@m.m

Definition at line 19 of file CssUtils.php.

Constructor & Destructor Documentation

◆ __construct()

Assetic\Util\CssUtils::__construct ( )
finalprivate

Definition at line 135 of file CssUtils.php.

136  {
137  }

Member Function Documentation

◆ extractImports()

static Assetic\Util\CssUtils::extractImports (   $content)
static

Extracts all references from the supplied CSS content.

Parameters
string$contentThe CSS content
Returns
array An array of unique URLs

Definition at line 125 of file CssUtils.php.

References array.

Referenced by Assetic\Filter\Sass\BaseSassFilter\addLoadPath(), Assetic\Filter\ScssphpFilter\getChildren(), Assetic\Filter\LessphpFilter\getChildren(), and Assetic\Filter\LessFilter\getChildren().

126  {
127  $imports = array();
128  static::filterImports($content, function ($matches) use (&$imports) {
129  $imports[] = $matches['url'];
130  });
131 
132  return array_unique($imports);
133  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ filterCommentless()

static Assetic\Util\CssUtils::filterCommentless (   $content,
  $callback 
)
static

Filters each non-comment part through a callable.

Parameters
string$contentThe CSS
callable$callbackA PHP callable
Returns
string The filtered CSS

Definition at line 104 of file CssUtils.php.

References $result.

105  {
106  $result = '';
107  foreach (preg_split(static::REGEX_COMMENTS, $content, -1, PREG_SPLIT_DELIM_CAPTURE) as $part) {
108  if (!preg_match(static::REGEX_COMMENTS, $part, $match) || $part != $match[0]) {
109  $part = call_user_func($callback, $part);
110  }
111 
112  $result .= $part;
113  }
114 
115  return $result;
116  }
$result

◆ filterIEFilters()

static Assetic\Util\CssUtils::filterIEFilters (   $content,
  $callback 
)
static

Filters all IE filters (AlphaImageLoader filter) through a callable.

Parameters
string$contentThe CSS
callable$callbackA PHP callable
Returns
string The filtered CSS

Definition at line 87 of file CssUtils.php.

Referenced by Assetic\Filter\BaseCssFilter\filterIEFilters().

88  {
89  $pattern = static::REGEX_IE_FILTERS;
90 
91  return static::filterCommentless($content, function ($part) use (& $callback, $pattern) {
92  return preg_replace_callback($pattern, $callback, $part);
93  });
94  }
+ Here is the caller graph for this function:

◆ filterImports()

static Assetic\Util\CssUtils::filterImports (   $content,
  $callback,
  $includeUrl = true 
)
static

Filters all CSS imports through a callable.

Parameters
string$contentThe CSS
callable$callbackA PHP callable
Boolean$includeUrlWhether to include url() in the pattern
Returns
string The filtered CSS

Definition at line 70 of file CssUtils.php.

Referenced by Assetic\Filter\BaseCssFilter\filterImports().

71  {
72  $pattern = $includeUrl ? static::REGEX_IMPORTS : static::REGEX_IMPORTS_NO_URLS;
73 
74  return static::filterCommentless($content, function ($part) use (& $callback, $pattern) {
75  return preg_replace_callback($pattern, $callback, $part);
76  });
77  }
+ Here is the caller graph for this function:

◆ filterReferences()

static Assetic\Util\CssUtils::filterReferences (   $content,
  $callback 
)
static

Filters all references – url() and "@import" – through a callable.

Parameters
string$contentThe CSS
callable$callbackA PHP callable
Returns
string The filtered CSS

Definition at line 35 of file CssUtils.php.

Referenced by Assetic\Filter\BaseCssFilter\filterReferences().

36  {
37  $content = static::filterUrls($content, $callback);
38  $content = static::filterImports($content, $callback, false);
39  $content = static::filterIEFilters($content, $callback);
40 
41  return $content;
42  }
+ Here is the caller graph for this function:

◆ filterUrls()

static Assetic\Util\CssUtils::filterUrls (   $content,
  $callback 
)
static

Filters all CSS url()'s through a callable.

Parameters
string$contentThe CSS
callable$callbackA PHP callable
Returns
string The filtered CSS

Definition at line 52 of file CssUtils.php.

Referenced by Assetic\Filter\BaseCssFilter\filterUrls().

53  {
54  $pattern = static::REGEX_URLS;
55 
56  return static::filterCommentless($content, function ($part) use (& $callback, $pattern) {
57  return preg_replace_callback($pattern, $callback, $part);
58  });
59  }
+ Here is the caller graph for this function:

Field Documentation

◆ REGEX_COMMENTS

const Assetic\Util\CssUtils::REGEX_COMMENTS = '/(\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)/'

Definition at line 25 of file CssUtils.php.

◆ REGEX_IE_FILTERS

const Assetic\Util\CssUtils::REGEX_IE_FILTERS = '/src=(["\']?)(?P<url>.*?)\\1/'

Definition at line 24 of file CssUtils.php.

◆ REGEX_IMPORTS

const Assetic\Util\CssUtils::REGEX_IMPORTS = '/@import (?:url\()?(\'|"|)(?P<url>[^\'"\)\n\r]*)\1\)?;?/'

Definition at line 22 of file CssUtils.php.

◆ REGEX_IMPORTS_NO_URLS

const Assetic\Util\CssUtils::REGEX_IMPORTS_NO_URLS = '/@import (?!url\()(\'|"|)(?P<url>[^\'"\)\n\r]*)\1;?/'

Definition at line 23 of file CssUtils.php.

◆ REGEX_URLS

const Assetic\Util\CssUtils::REGEX_URLS = '/url\((["\']?)(?P<url>.*?)(\\1)\)/'

Definition at line 21 of file CssUtils.php.


The documentation for this class was generated from the following file: