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.

126 {
127 $imports = array();
128 static::filterImports($content, function ($matches) use (&$imports) {
129 $imports[] = $matches['url'];
130 });
131
132 return array_unique($imports);
133 }

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

+ 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.

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
echo;exit;}function LogoutNotification($SessionID) { global $ilDB; $q="SELECT session_id, data FROM usr_session WHERE expires > (\w+)\|/" PREG_SPLIT_NO_EMPTY PREG_SPLIT_DELIM_CAPTURE

References $result, and PREG_SPLIT_DELIM_CAPTURE.

◆ 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.

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 }

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

+ 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.

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 }

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

+ 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.

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 }

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

+ 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.

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 }

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

+ 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: