@@ -69,7 +69,7 @@ |
||
69 | 69 | |
70 | 70 | // For any reason if required IV size needs greater value. |
71 | 71 | if ($length > strlen($allowedIVString)) { |
72 | - $repeatedIVString = str_repeat($allowedIVString, ceil($length/strlen($allowedIVString))); |
|
72 | + $repeatedIVString = str_repeat($allowedIVString, ceil($length / strlen($allowedIVString))); |
|
73 | 73 | $allowedIVString .= $repeatedIVString; |
74 | 74 | } |
75 | 75 |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | protected $inputLength = 0; |
70 | 70 | protected $lookAhead = null; |
71 | 71 | protected $output = ''; |
72 | - protected $lastByteOut = ''; |
|
72 | + protected $lastByteOut = ''; |
|
73 | 73 | protected $keptComment = ''; |
74 | 74 | |
75 | 75 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | $mbIntEnc = null; |
110 | - if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) { |
|
110 | + if (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) { |
|
111 | 111 | $mbIntEnc = mb_internal_encoding(); |
112 | 112 | mb_internal_encoding('8bit'); |
113 | 113 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | && ($this->b === $this->lastByteOut)) { |
125 | 125 | // Don't delete this space. If we do, the addition/subtraction |
126 | 126 | // could be parsed as a post-increment |
127 | - } elseif (! $this->isAlphaNum($this->b)) { |
|
127 | + } elseif (!$this->isAlphaNum($this->b)) { |
|
128 | 128 | $command = self::ACTION_DELETE_A; |
129 | 129 | } |
130 | 130 | } elseif ($this->a === "\n") { |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | // otherwise mb_strpos will give WARNING |
136 | 136 | } elseif ($this->b === null |
137 | 137 | || (false === strpos('{[(+-!~', $this->b) |
138 | - && ! $this->isAlphaNum($this->b))) { |
|
138 | + && !$this->isAlphaNum($this->b))) { |
|
139 | 139 | $command = self::ACTION_DELETE_A; |
140 | 140 | } |
141 | - } elseif (! $this->isAlphaNum($this->a)) { |
|
141 | + } elseif (!$this->isAlphaNum($this->a)) { |
|
142 | 142 | if ($this->b === ' ' |
143 | 143 | || ($this->b === "\n" |
144 | 144 | && (false === strpos('}])+-\'', $this->a)))) { |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $this->a = $this->b; |
195 | 195 | if ($this->a === "'" || $this->a === '"') { // string literal |
196 | 196 | $str = $this->a; // in case needed for exception |
197 | - for(;;) { |
|
197 | + for (;;) { |
|
198 | 198 | $this->output .= $this->a; |
199 | 199 | $this->lastByteOut = $this->a; |
200 | 200 | |
@@ -224,11 +224,11 @@ discard block |
||
224 | 224 | if ($this->b === '/' && $this->isRegexpLiteral()) { |
225 | 225 | $this->output .= $this->a . $this->b; |
226 | 226 | $pattern = '/'; // keep entire pattern in case we need to report it in the exception |
227 | - for(;;) { |
|
227 | + for (;;) { |
|
228 | 228 | $this->a = $this->get(); |
229 | 229 | $pattern .= $this->a; |
230 | 230 | if ($this->a === '[') { |
231 | - for(;;) { |
|
231 | + for (;;) { |
|
232 | 232 | $this->output .= $this->a; |
233 | 233 | $this->a = $this->get(); |
234 | 234 | $pattern .= $this->a; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | if ($this->isEOF($this->a)) { |
244 | 244 | throw new JSMin_UnterminatedRegExpException( |
245 | 245 | "JSMin: Unterminated set in RegExp at byte " |
246 | - . $this->inputIndex .": {$pattern}"); |
|
246 | + . $this->inputIndex . ": {$pattern}"); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | { |
398 | 398 | $this->get(); |
399 | 399 | $comment = ''; |
400 | - for(;;) { |
|
400 | + for (;;) { |
|
401 | 401 | $get = $this->get(); |
402 | 402 | if ($get === '*') { |
403 | 403 | if ($this->peek() === '/') { // end of comment reached |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | * @version 3.0.1 |
46 | 46 | */ |
47 | 47 | abstract class aCssToken |
48 | - { |
|
49 | - /** |
|
50 | - * Returns the token as string. |
|
51 | - * |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - abstract public function __toString(); |
|
55 | - } |
|
48 | + { |
|
49 | + /** |
|
50 | + * Returns the token as string. |
|
51 | + * |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + abstract public function __toString(); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Abstract definition of a for a ruleset start token. |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * @version 3.0.1 |
66 | 66 | */ |
67 | 67 | abstract class aCssRulesetStartToken extends aCssToken |
68 | - { |
|
68 | + { |
|
69 | 69 | |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Abstract definition of a for ruleset end token. |
@@ -80,17 +80,17 @@ discard block |
||
80 | 80 | * @version 3.0.1 |
81 | 81 | */ |
82 | 82 | abstract class aCssRulesetEndToken extends aCssToken |
83 | - { |
|
84 | - /** |
|
85 | - * Implements {@link aCssToken::__toString()}. |
|
86 | - * |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function __toString() |
|
90 | - { |
|
91 | - return "}"; |
|
92 | - } |
|
93 | - } |
|
83 | + { |
|
84 | + /** |
|
85 | + * Implements {@link aCssToken::__toString()}. |
|
86 | + * |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function __toString() |
|
90 | + { |
|
91 | + return "}"; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Abstract definition of a parser plugin. |
@@ -106,59 +106,59 @@ discard block |
||
106 | 106 | * @version 3.0.1 |
107 | 107 | */ |
108 | 108 | abstract class aCssParserPlugin |
109 | - { |
|
110 | - /** |
|
111 | - * Plugin configuration. |
|
112 | - * |
|
113 | - * @var array |
|
114 | - */ |
|
115 | - protected $configuration = array(); |
|
116 | - /** |
|
117 | - * The CssParser of the plugin. |
|
118 | - * |
|
119 | - * @var CssParser |
|
120 | - */ |
|
121 | - protected $parser = null; |
|
122 | - /** |
|
123 | - * Plugin buffer. |
|
124 | - * |
|
125 | - * @var string |
|
126 | - */ |
|
127 | - protected $buffer = ""; |
|
128 | - /** |
|
129 | - * Constructor. |
|
130 | - * |
|
131 | - * @param CssParser $parser The CssParser object of this plugin. |
|
132 | - * @param array $configuration Plugin configuration [optional] |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - public function __construct(CssParser $parser, array $configuration = null) |
|
136 | - { |
|
137 | - $this->configuration = $configuration; |
|
138 | - $this->parser = $parser; |
|
139 | - } |
|
140 | - /** |
|
141 | - * Returns the array of chars triggering the parser plugin. |
|
142 | - * |
|
143 | - * @return array |
|
144 | - */ |
|
145 | - abstract public function getTriggerChars(); |
|
146 | - /** |
|
147 | - * Returns the array of states triggering the parser plugin or FALSE if every state will trigger the parser plugin. |
|
148 | - * |
|
149 | - * @return array |
|
150 | - */ |
|
151 | - abstract public function getTriggerStates(); |
|
152 | - /** |
|
153 | - * Parser routine of the plugin. |
|
154 | - * |
|
155 | - * @param integer $index Current index |
|
156 | - * @param string $char Current char |
|
157 | - * @param string $previousChar Previous char |
|
158 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
159 | - */ |
|
160 | - abstract public function parse($index, $char, $previousChar, $state); |
|
161 | - } |
|
109 | + { |
|
110 | + /** |
|
111 | + * Plugin configuration. |
|
112 | + * |
|
113 | + * @var array |
|
114 | + */ |
|
115 | + protected $configuration = array(); |
|
116 | + /** |
|
117 | + * The CssParser of the plugin. |
|
118 | + * |
|
119 | + * @var CssParser |
|
120 | + */ |
|
121 | + protected $parser = null; |
|
122 | + /** |
|
123 | + * Plugin buffer. |
|
124 | + * |
|
125 | + * @var string |
|
126 | + */ |
|
127 | + protected $buffer = ""; |
|
128 | + /** |
|
129 | + * Constructor. |
|
130 | + * |
|
131 | + * @param CssParser $parser The CssParser object of this plugin. |
|
132 | + * @param array $configuration Plugin configuration [optional] |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + public function __construct(CssParser $parser, array $configuration = null) |
|
136 | + { |
|
137 | + $this->configuration = $configuration; |
|
138 | + $this->parser = $parser; |
|
139 | + } |
|
140 | + /** |
|
141 | + * Returns the array of chars triggering the parser plugin. |
|
142 | + * |
|
143 | + * @return array |
|
144 | + */ |
|
145 | + abstract public function getTriggerChars(); |
|
146 | + /** |
|
147 | + * Returns the array of states triggering the parser plugin or FALSE if every state will trigger the parser plugin. |
|
148 | + * |
|
149 | + * @return array |
|
150 | + */ |
|
151 | + abstract public function getTriggerStates(); |
|
152 | + /** |
|
153 | + * Parser routine of the plugin. |
|
154 | + * |
|
155 | + * @param integer $index Current index |
|
156 | + * @param string $char Current char |
|
157 | + * @param string $previousChar Previous char |
|
158 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
159 | + */ |
|
160 | + abstract public function parse($index, $char, $previousChar, $state); |
|
161 | + } |
|
162 | 162 | |
163 | 163 | /** |
164 | 164 | * Abstract definition of a minifier plugin class. |
@@ -174,45 +174,45 @@ discard block |
||
174 | 174 | * @version 3.0.1 |
175 | 175 | */ |
176 | 176 | abstract class aCssMinifierPlugin |
177 | - { |
|
178 | - /** |
|
179 | - * Plugin configuration. |
|
180 | - * |
|
181 | - * @var array |
|
182 | - */ |
|
183 | - protected $configuration = array(); |
|
184 | - /** |
|
185 | - * The CssMinifier of the plugin. |
|
186 | - * |
|
187 | - * @var CssMinifier |
|
188 | - */ |
|
189 | - protected $minifier = null; |
|
190 | - /** |
|
191 | - * Constructor. |
|
192 | - * |
|
193 | - * @param CssMinifier $minifier The CssMinifier object of this plugin. |
|
194 | - * @param array $configuration Plugin configuration [optional] |
|
195 | - * @return void |
|
196 | - */ |
|
197 | - public function __construct(CssMinifier $minifier, array $configuration = array()) |
|
198 | - { |
|
199 | - $this->configuration = $configuration; |
|
200 | - $this->minifier = $minifier; |
|
201 | - } |
|
202 | - /** |
|
203 | - * Apply the plugin to the token. |
|
204 | - * |
|
205 | - * @param aCssToken $token Token to process |
|
206 | - * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
207 | - */ |
|
208 | - abstract public function apply(aCssToken &$token); |
|
209 | - /** |
|
210 | - * -- |
|
211 | - * |
|
212 | - * @return array |
|
213 | - */ |
|
214 | - abstract public function getTriggerTokens(); |
|
215 | - } |
|
177 | + { |
|
178 | + /** |
|
179 | + * Plugin configuration. |
|
180 | + * |
|
181 | + * @var array |
|
182 | + */ |
|
183 | + protected $configuration = array(); |
|
184 | + /** |
|
185 | + * The CssMinifier of the plugin. |
|
186 | + * |
|
187 | + * @var CssMinifier |
|
188 | + */ |
|
189 | + protected $minifier = null; |
|
190 | + /** |
|
191 | + * Constructor. |
|
192 | + * |
|
193 | + * @param CssMinifier $minifier The CssMinifier object of this plugin. |
|
194 | + * @param array $configuration Plugin configuration [optional] |
|
195 | + * @return void |
|
196 | + */ |
|
197 | + public function __construct(CssMinifier $minifier, array $configuration = array()) |
|
198 | + { |
|
199 | + $this->configuration = $configuration; |
|
200 | + $this->minifier = $minifier; |
|
201 | + } |
|
202 | + /** |
|
203 | + * Apply the plugin to the token. |
|
204 | + * |
|
205 | + * @param aCssToken $token Token to process |
|
206 | + * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
207 | + */ |
|
208 | + abstract public function apply(aCssToken &$token); |
|
209 | + /** |
|
210 | + * -- |
|
211 | + * |
|
212 | + * @return array |
|
213 | + */ |
|
214 | + abstract public function getTriggerTokens(); |
|
215 | + } |
|
216 | 216 | |
217 | 217 | /** |
218 | 218 | * Abstract definition of a minifier filter class. |
@@ -228,39 +228,39 @@ discard block |
||
228 | 228 | * @version 3.0.1 |
229 | 229 | */ |
230 | 230 | abstract class aCssMinifierFilter |
231 | - { |
|
232 | - /** |
|
233 | - * Filter configuration. |
|
234 | - * |
|
235 | - * @var array |
|
236 | - */ |
|
237 | - protected $configuration = array(); |
|
238 | - /** |
|
239 | - * The CssMinifier of the filter. |
|
240 | - * |
|
241 | - * @var CssMinifier |
|
242 | - */ |
|
243 | - protected $minifier = null; |
|
244 | - /** |
|
245 | - * Constructor. |
|
246 | - * |
|
247 | - * @param CssMinifier $minifier The CssMinifier object of this plugin. |
|
248 | - * @param array $configuration Filter configuration [optional] |
|
249 | - * @return void |
|
250 | - */ |
|
251 | - public function __construct(CssMinifier $minifier, array $configuration = array()) |
|
252 | - { |
|
253 | - $this->configuration = $configuration; |
|
254 | - $this->minifier = $minifier; |
|
255 | - } |
|
256 | - /** |
|
257 | - * Filter the tokens. |
|
258 | - * |
|
259 | - * @param array $tokens Array of objects of type aCssToken |
|
260 | - * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
261 | - */ |
|
262 | - abstract public function apply(array &$tokens); |
|
263 | - } |
|
231 | + { |
|
232 | + /** |
|
233 | + * Filter configuration. |
|
234 | + * |
|
235 | + * @var array |
|
236 | + */ |
|
237 | + protected $configuration = array(); |
|
238 | + /** |
|
239 | + * The CssMinifier of the filter. |
|
240 | + * |
|
241 | + * @var CssMinifier |
|
242 | + */ |
|
243 | + protected $minifier = null; |
|
244 | + /** |
|
245 | + * Constructor. |
|
246 | + * |
|
247 | + * @param CssMinifier $minifier The CssMinifier object of this plugin. |
|
248 | + * @param array $configuration Filter configuration [optional] |
|
249 | + * @return void |
|
250 | + */ |
|
251 | + public function __construct(CssMinifier $minifier, array $configuration = array()) |
|
252 | + { |
|
253 | + $this->configuration = $configuration; |
|
254 | + $this->minifier = $minifier; |
|
255 | + } |
|
256 | + /** |
|
257 | + * Filter the tokens. |
|
258 | + * |
|
259 | + * @param array $tokens Array of objects of type aCssToken |
|
260 | + * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
261 | + */ |
|
262 | + abstract public function apply(array &$tokens); |
|
263 | + } |
|
264 | 264 | |
265 | 265 | /** |
266 | 266 | * Abstract formatter definition. |
@@ -275,45 +275,45 @@ discard block |
||
275 | 275 | * @version 3.0.1 |
276 | 276 | */ |
277 | 277 | abstract class aCssFormatter |
278 | - { |
|
279 | - /** |
|
280 | - * Indent string. |
|
281 | - * |
|
282 | - * @var string |
|
283 | - */ |
|
284 | - protected $indent = " "; |
|
285 | - /** |
|
286 | - * Declaration padding. |
|
287 | - * |
|
288 | - * @var integer |
|
289 | - */ |
|
290 | - protected $padding = 0; |
|
291 | - /** |
|
292 | - * Tokens. |
|
293 | - * |
|
294 | - * @var array |
|
295 | - */ |
|
296 | - protected $tokens = array(); |
|
297 | - /** |
|
298 | - * Constructor. |
|
299 | - * |
|
300 | - * @param array $tokens Array of CssToken |
|
301 | - * @param string $indent Indent string [optional] |
|
302 | - * @param integer $padding Declaration value padding [optional] |
|
303 | - */ |
|
304 | - public function __construct(array $tokens, $indent = null, $padding = null) |
|
305 | - { |
|
306 | - $this->tokens = $tokens; |
|
307 | - $this->indent = !is_null($indent) ? $indent : $this->indent; |
|
308 | - $this->padding = !is_null($padding) ? $padding : $this->padding; |
|
309 | - } |
|
310 | - /** |
|
311 | - * Returns the array of aCssToken as formatted string. |
|
312 | - * |
|
313 | - * @return string |
|
314 | - */ |
|
315 | - abstract public function __toString(); |
|
316 | - } |
|
278 | + { |
|
279 | + /** |
|
280 | + * Indent string. |
|
281 | + * |
|
282 | + * @var string |
|
283 | + */ |
|
284 | + protected $indent = " "; |
|
285 | + /** |
|
286 | + * Declaration padding. |
|
287 | + * |
|
288 | + * @var integer |
|
289 | + */ |
|
290 | + protected $padding = 0; |
|
291 | + /** |
|
292 | + * Tokens. |
|
293 | + * |
|
294 | + * @var array |
|
295 | + */ |
|
296 | + protected $tokens = array(); |
|
297 | + /** |
|
298 | + * Constructor. |
|
299 | + * |
|
300 | + * @param array $tokens Array of CssToken |
|
301 | + * @param string $indent Indent string [optional] |
|
302 | + * @param integer $padding Declaration value padding [optional] |
|
303 | + */ |
|
304 | + public function __construct(array $tokens, $indent = null, $padding = null) |
|
305 | + { |
|
306 | + $this->tokens = $tokens; |
|
307 | + $this->indent = !is_null($indent) ? $indent : $this->indent; |
|
308 | + $this->padding = !is_null($padding) ? $padding : $this->padding; |
|
309 | + } |
|
310 | + /** |
|
311 | + * Returns the array of aCssToken as formatted string. |
|
312 | + * |
|
313 | + * @return string |
|
314 | + */ |
|
315 | + abstract public function __toString(); |
|
316 | + } |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Abstract definition of a ruleset declaration token. |
@@ -326,57 +326,57 @@ discard block |
||
326 | 326 | * @version 3.0.1 |
327 | 327 | */ |
328 | 328 | abstract class aCssDeclarationToken extends aCssToken |
329 | - { |
|
330 | - /** |
|
331 | - * Is the declaration flagged as important? |
|
332 | - * |
|
333 | - * @var boolean |
|
334 | - */ |
|
335 | - public $IsImportant = false; |
|
336 | - /** |
|
337 | - * Is the declaration flagged as last one of the ruleset? |
|
338 | - * |
|
339 | - * @var boolean |
|
340 | - */ |
|
341 | - public $IsLast = false; |
|
342 | - /** |
|
343 | - * Property name of the declaration. |
|
344 | - * |
|
345 | - * @var string |
|
346 | - */ |
|
347 | - public $Property = ""; |
|
348 | - /** |
|
349 | - * Value of the declaration. |
|
350 | - * |
|
351 | - * @var string |
|
352 | - */ |
|
353 | - public $Value = ""; |
|
354 | - /** |
|
355 | - * Set the properties of the @font-face declaration. |
|
356 | - * |
|
357 | - * @param string $property Property of the declaration |
|
358 | - * @param string $value Value of the declaration |
|
359 | - * @param boolean $isImportant Is the !important flag is set? |
|
360 | - * @param boolean $IsLast Is the declaration the last one of the block? |
|
361 | - * @return void |
|
362 | - */ |
|
363 | - public function __construct($property, $value, $isImportant = false, $isLast = false) |
|
364 | - { |
|
365 | - $this->Property = $property; |
|
366 | - $this->Value = $value; |
|
367 | - $this->IsImportant = $isImportant; |
|
368 | - $this->IsLast = $isLast; |
|
369 | - } |
|
370 | - /** |
|
371 | - * Implements {@link aCssToken::__toString()}. |
|
372 | - * |
|
373 | - * @return string |
|
374 | - */ |
|
375 | - public function __toString() |
|
376 | - { |
|
377 | - return $this->Property . ":" . $this->Value . ($this->IsImportant ? " !important" : "") . ($this->IsLast ? "" : ";"); |
|
378 | - } |
|
379 | - } |
|
329 | + { |
|
330 | + /** |
|
331 | + * Is the declaration flagged as important? |
|
332 | + * |
|
333 | + * @var boolean |
|
334 | + */ |
|
335 | + public $IsImportant = false; |
|
336 | + /** |
|
337 | + * Is the declaration flagged as last one of the ruleset? |
|
338 | + * |
|
339 | + * @var boolean |
|
340 | + */ |
|
341 | + public $IsLast = false; |
|
342 | + /** |
|
343 | + * Property name of the declaration. |
|
344 | + * |
|
345 | + * @var string |
|
346 | + */ |
|
347 | + public $Property = ""; |
|
348 | + /** |
|
349 | + * Value of the declaration. |
|
350 | + * |
|
351 | + * @var string |
|
352 | + */ |
|
353 | + public $Value = ""; |
|
354 | + /** |
|
355 | + * Set the properties of the @font-face declaration. |
|
356 | + * |
|
357 | + * @param string $property Property of the declaration |
|
358 | + * @param string $value Value of the declaration |
|
359 | + * @param boolean $isImportant Is the !important flag is set? |
|
360 | + * @param boolean $IsLast Is the declaration the last one of the block? |
|
361 | + * @return void |
|
362 | + */ |
|
363 | + public function __construct($property, $value, $isImportant = false, $isLast = false) |
|
364 | + { |
|
365 | + $this->Property = $property; |
|
366 | + $this->Value = $value; |
|
367 | + $this->IsImportant = $isImportant; |
|
368 | + $this->IsLast = $isLast; |
|
369 | + } |
|
370 | + /** |
|
371 | + * Implements {@link aCssToken::__toString()}. |
|
372 | + * |
|
373 | + * @return string |
|
374 | + */ |
|
375 | + public function __toString() |
|
376 | + { |
|
377 | + return $this->Property . ":" . $this->Value . ($this->IsImportant ? " !important" : "") . ($this->IsLast ? "" : ";"); |
|
378 | + } |
|
379 | + } |
|
380 | 380 | |
381 | 381 | /** |
382 | 382 | * Abstract definition of a for at-rule block start token. |
@@ -389,9 +389,9 @@ discard block |
||
389 | 389 | * @version 3.0.1 |
390 | 390 | */ |
391 | 391 | abstract class aCssAtBlockStartToken extends aCssToken |
392 | - { |
|
392 | + { |
|
393 | 393 | |
394 | - } |
|
394 | + } |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Abstract definition of a for at-rule block end token. |
@@ -404,17 +404,17 @@ discard block |
||
404 | 404 | * @version 3.0.1 |
405 | 405 | */ |
406 | 406 | abstract class aCssAtBlockEndToken extends aCssToken |
407 | - { |
|
408 | - /** |
|
409 | - * Implements {@link aCssToken::__toString()}. |
|
410 | - * |
|
411 | - * @return string |
|
412 | - */ |
|
413 | - public function __toString() |
|
414 | - { |
|
415 | - return "}"; |
|
416 | - } |
|
417 | - } |
|
407 | + { |
|
408 | + /** |
|
409 | + * Implements {@link aCssToken::__toString()}. |
|
410 | + * |
|
411 | + * @return string |
|
412 | + */ |
|
413 | + public function __toString() |
|
414 | + { |
|
415 | + return "}"; |
|
416 | + } |
|
417 | + } |
|
418 | 418 | |
419 | 419 | /** |
420 | 420 | * {@link aCssFromatter Formatter} returning the CSS source in {@link http://goo.gl/etzLs Whitesmiths indent style}. |
@@ -427,103 +427,103 @@ discard block |
||
427 | 427 | * @version 3.0.1 |
428 | 428 | */ |
429 | 429 | class CssWhitesmithsFormatter extends aCssFormatter |
430 | - { |
|
431 | - /** |
|
432 | - * Implements {@link aCssFormatter::__toString()}. |
|
433 | - * |
|
434 | - * @return string |
|
435 | - */ |
|
436 | - public function __toString() |
|
437 | - { |
|
438 | - $r = array(); |
|
439 | - $level = 0; |
|
440 | - for ($i = 0, $l = count($this->tokens); $i < $l; $i++) |
|
441 | - { |
|
442 | - $token = $this->tokens[$i]; |
|
443 | - $class = get_class($token); |
|
444 | - $indent = str_repeat($this->indent, $level); |
|
445 | - if ($class === "CssCommentToken") |
|
446 | - { |
|
447 | - $lines = array_map("trim", explode("\n", $token->Comment)); |
|
448 | - for ($ii = 0, $ll = count($lines); $ii < $ll; $ii++) |
|
449 | - { |
|
450 | - $r[] = $indent . (substr($lines[$ii], 0, 1) == "*" ? " " : "") . $lines[$ii]; |
|
451 | - } |
|
452 | - } |
|
453 | - elseif ($class === "CssAtCharsetToken") |
|
454 | - { |
|
455 | - $r[] = $indent . "@charset " . $token->Charset . ";"; |
|
456 | - } |
|
457 | - elseif ($class === "CssAtFontFaceStartToken") |
|
458 | - { |
|
459 | - $r[] = $indent . "@font-face"; |
|
460 | - $r[] = $this->indent . $indent . "{"; |
|
461 | - $level++; |
|
462 | - } |
|
463 | - elseif ($class === "CssAtImportToken") |
|
464 | - { |
|
465 | - $r[] = $indent . "@import " . $token->Import . " " . implode(", ", $token->MediaTypes) . ";"; |
|
466 | - } |
|
467 | - elseif ($class === "CssAtKeyframesStartToken") |
|
468 | - { |
|
469 | - $r[] = $indent . "@keyframes \"" . $token->Name . "\""; |
|
470 | - $r[] = $this->indent . $indent . "{"; |
|
471 | - $level++; |
|
472 | - } |
|
473 | - elseif ($class === "CssAtMediaStartToken") |
|
474 | - { |
|
475 | - $r[] = $indent . "@media " . implode(", ", $token->MediaTypes); |
|
476 | - $r[] = $this->indent . $indent . "{"; |
|
477 | - $level++; |
|
478 | - } |
|
479 | - elseif ($class === "CssAtPageStartToken") |
|
480 | - { |
|
481 | - $r[] = $indent . "@page"; |
|
482 | - $r[] = $this->indent . $indent . "{"; |
|
483 | - $level++; |
|
484 | - } |
|
485 | - elseif ($class === "CssAtVariablesStartToken") |
|
486 | - { |
|
487 | - $r[] = $indent . "@variables " . implode(", ", $token->MediaTypes); |
|
488 | - $r[] = $this->indent . $indent . "{"; |
|
489 | - $level++; |
|
490 | - } |
|
491 | - elseif ($class === "CssRulesetStartToken" || $class === "CssAtKeyframesRulesetStartToken") |
|
492 | - { |
|
493 | - $r[] = $indent . implode(", ", $token->Selectors); |
|
494 | - $r[] = $this->indent . $indent . "{"; |
|
495 | - $level++; |
|
496 | - } |
|
497 | - elseif ($class == "CssAtFontFaceDeclarationToken" |
|
498 | - || $class === "CssAtKeyframesRulesetDeclarationToken" |
|
499 | - || $class === "CssAtPageDeclarationToken" |
|
500 | - || $class == "CssAtVariablesDeclarationToken" |
|
501 | - || $class === "CssRulesetDeclarationToken" |
|
502 | - ) |
|
503 | - { |
|
504 | - $declaration = $indent . $token->Property . ": "; |
|
505 | - if ($this->padding) |
|
506 | - { |
|
507 | - $declaration = str_pad($declaration, $this->padding, " ", STR_PAD_RIGHT); |
|
508 | - } |
|
509 | - $r[] = $declaration . $token->Value . ($token->IsImportant ? " !important" : "") . ";"; |
|
510 | - } |
|
511 | - elseif ($class === "CssAtFontFaceEndToken" |
|
512 | - || $class === "CssAtMediaEndToken" |
|
513 | - || $class === "CssAtKeyframesEndToken" |
|
514 | - || $class === "CssAtKeyframesRulesetEndToken" |
|
515 | - || $class === "CssAtPageEndToken" |
|
516 | - || $class === "CssAtVariablesEndToken" |
|
517 | - || $class === "CssRulesetEndToken" |
|
518 | - ) |
|
519 | - { |
|
520 | - $r[] = $indent . "}"; |
|
521 | - $level--; |
|
522 | - } |
|
523 | - } |
|
524 | - return implode("\n", $r); |
|
525 | - } |
|
526 | - } |
|
430 | + { |
|
431 | + /** |
|
432 | + * Implements {@link aCssFormatter::__toString()}. |
|
433 | + * |
|
434 | + * @return string |
|
435 | + */ |
|
436 | + public function __toString() |
|
437 | + { |
|
438 | + $r = array(); |
|
439 | + $level = 0; |
|
440 | + for ($i = 0, $l = count($this->tokens); $i < $l; $i++) |
|
441 | + { |
|
442 | + $token = $this->tokens[$i]; |
|
443 | + $class = get_class($token); |
|
444 | + $indent = str_repeat($this->indent, $level); |
|
445 | + if ($class === "CssCommentToken") |
|
446 | + { |
|
447 | + $lines = array_map("trim", explode("\n", $token->Comment)); |
|
448 | + for ($ii = 0, $ll = count($lines); $ii < $ll; $ii++) |
|
449 | + { |
|
450 | + $r[] = $indent . (substr($lines[$ii], 0, 1) == "*" ? " " : "") . $lines[$ii]; |
|
451 | + } |
|
452 | + } |
|
453 | + elseif ($class === "CssAtCharsetToken") |
|
454 | + { |
|
455 | + $r[] = $indent . "@charset " . $token->Charset . ";"; |
|
456 | + } |
|
457 | + elseif ($class === "CssAtFontFaceStartToken") |
|
458 | + { |
|
459 | + $r[] = $indent . "@font-face"; |
|
460 | + $r[] = $this->indent . $indent . "{"; |
|
461 | + $level++; |
|
462 | + } |
|
463 | + elseif ($class === "CssAtImportToken") |
|
464 | + { |
|
465 | + $r[] = $indent . "@import " . $token->Import . " " . implode(", ", $token->MediaTypes) . ";"; |
|
466 | + } |
|
467 | + elseif ($class === "CssAtKeyframesStartToken") |
|
468 | + { |
|
469 | + $r[] = $indent . "@keyframes \"" . $token->Name . "\""; |
|
470 | + $r[] = $this->indent . $indent . "{"; |
|
471 | + $level++; |
|
472 | + } |
|
473 | + elseif ($class === "CssAtMediaStartToken") |
|
474 | + { |
|
475 | + $r[] = $indent . "@media " . implode(", ", $token->MediaTypes); |
|
476 | + $r[] = $this->indent . $indent . "{"; |
|
477 | + $level++; |
|
478 | + } |
|
479 | + elseif ($class === "CssAtPageStartToken") |
|
480 | + { |
|
481 | + $r[] = $indent . "@page"; |
|
482 | + $r[] = $this->indent . $indent . "{"; |
|
483 | + $level++; |
|
484 | + } |
|
485 | + elseif ($class === "CssAtVariablesStartToken") |
|
486 | + { |
|
487 | + $r[] = $indent . "@variables " . implode(", ", $token->MediaTypes); |
|
488 | + $r[] = $this->indent . $indent . "{"; |
|
489 | + $level++; |
|
490 | + } |
|
491 | + elseif ($class === "CssRulesetStartToken" || $class === "CssAtKeyframesRulesetStartToken") |
|
492 | + { |
|
493 | + $r[] = $indent . implode(", ", $token->Selectors); |
|
494 | + $r[] = $this->indent . $indent . "{"; |
|
495 | + $level++; |
|
496 | + } |
|
497 | + elseif ($class == "CssAtFontFaceDeclarationToken" |
|
498 | + || $class === "CssAtKeyframesRulesetDeclarationToken" |
|
499 | + || $class === "CssAtPageDeclarationToken" |
|
500 | + || $class == "CssAtVariablesDeclarationToken" |
|
501 | + || $class === "CssRulesetDeclarationToken" |
|
502 | + ) |
|
503 | + { |
|
504 | + $declaration = $indent . $token->Property . ": "; |
|
505 | + if ($this->padding) |
|
506 | + { |
|
507 | + $declaration = str_pad($declaration, $this->padding, " ", STR_PAD_RIGHT); |
|
508 | + } |
|
509 | + $r[] = $declaration . $token->Value . ($token->IsImportant ? " !important" : "") . ";"; |
|
510 | + } |
|
511 | + elseif ($class === "CssAtFontFaceEndToken" |
|
512 | + || $class === "CssAtMediaEndToken" |
|
513 | + || $class === "CssAtKeyframesEndToken" |
|
514 | + || $class === "CssAtKeyframesRulesetEndToken" |
|
515 | + || $class === "CssAtPageEndToken" |
|
516 | + || $class === "CssAtVariablesEndToken" |
|
517 | + || $class === "CssRulesetEndToken" |
|
518 | + ) |
|
519 | + { |
|
520 | + $r[] = $indent . "}"; |
|
521 | + $level--; |
|
522 | + } |
|
523 | + } |
|
524 | + return implode("\n", $r); |
|
525 | + } |
|
526 | + } |
|
527 | 527 | |
528 | 528 | /** |
529 | 529 | * This {@link aCssMinifierPlugin} will process var-statement and sets the declaration value to the variable value. |
@@ -553,88 +553,88 @@ discard block |
||
553 | 553 | * @version 3.0.1 |
554 | 554 | */ |
555 | 555 | class CssVariablesMinifierPlugin extends aCssMinifierPlugin |
556 | - { |
|
557 | - /** |
|
558 | - * Regular expression matching a value. |
|
559 | - * |
|
560 | - * @var string |
|
561 | - */ |
|
562 | - private $reMatch = "/var\((.+)\)/iSU"; |
|
563 | - /** |
|
564 | - * Parsed variables. |
|
565 | - * |
|
566 | - * @var array |
|
567 | - */ |
|
568 | - private $variables = null; |
|
569 | - /** |
|
570 | - * Returns the variables. |
|
571 | - * |
|
572 | - * @return array |
|
573 | - */ |
|
574 | - public function getVariables() |
|
575 | - { |
|
576 | - return $this->variables; |
|
577 | - } |
|
578 | - /** |
|
579 | - * Implements {@link aCssMinifierPlugin::minify()}. |
|
580 | - * |
|
581 | - * @param aCssToken $token Token to process |
|
582 | - * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
583 | - */ |
|
584 | - public function apply(aCssToken &$token) |
|
585 | - { |
|
586 | - if (stripos($token->Value, "var") !== false && preg_match_all($this->reMatch, $token->Value, $m)) |
|
587 | - { |
|
588 | - $mediaTypes = $token->MediaTypes; |
|
589 | - if (!in_array("all", $mediaTypes)) |
|
590 | - { |
|
591 | - $mediaTypes[] = "all"; |
|
592 | - } |
|
593 | - for ($i = 0, $l = count($m[0]); $i < $l; $i++) |
|
594 | - { |
|
595 | - $variable = trim($m[1][$i]); |
|
596 | - foreach ($mediaTypes as $mediaType) |
|
597 | - { |
|
598 | - if (isset($this->variables[$mediaType], $this->variables[$mediaType][$variable])) |
|
599 | - { |
|
600 | - // Variable value found => set the declaration value to the variable value and return |
|
601 | - $token->Value = str_replace($m[0][$i], $this->variables[$mediaType][$variable], $token->Value); |
|
602 | - continue 2; |
|
603 | - } |
|
604 | - } |
|
605 | - // If no value was found trigger an error and replace the token with a CssNullToken |
|
606 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": No value found for variable <code>" . $variable . "</code> in media types <code>" . implode(", ", $mediaTypes) . "</code>", (string) $token)); |
|
607 | - $token = new CssNullToken(); |
|
608 | - return true; |
|
609 | - } |
|
610 | - } |
|
611 | - return false; |
|
612 | - } |
|
613 | - /** |
|
614 | - * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
615 | - * |
|
616 | - * @return array |
|
617 | - */ |
|
618 | - public function getTriggerTokens() |
|
619 | - { |
|
620 | - return array |
|
621 | - ( |
|
622 | - "CssAtFontFaceDeclarationToken", |
|
623 | - "CssAtPageDeclarationToken", |
|
624 | - "CssRulesetDeclarationToken" |
|
625 | - ); |
|
626 | - } |
|
627 | - /** |
|
628 | - * Sets the variables. |
|
629 | - * |
|
630 | - * @param array $variables Variables to set |
|
631 | - * @return void |
|
632 | - */ |
|
633 | - public function setVariables(array $variables) |
|
634 | - { |
|
635 | - $this->variables = $variables; |
|
636 | - } |
|
637 | - } |
|
556 | + { |
|
557 | + /** |
|
558 | + * Regular expression matching a value. |
|
559 | + * |
|
560 | + * @var string |
|
561 | + */ |
|
562 | + private $reMatch = "/var\((.+)\)/iSU"; |
|
563 | + /** |
|
564 | + * Parsed variables. |
|
565 | + * |
|
566 | + * @var array |
|
567 | + */ |
|
568 | + private $variables = null; |
|
569 | + /** |
|
570 | + * Returns the variables. |
|
571 | + * |
|
572 | + * @return array |
|
573 | + */ |
|
574 | + public function getVariables() |
|
575 | + { |
|
576 | + return $this->variables; |
|
577 | + } |
|
578 | + /** |
|
579 | + * Implements {@link aCssMinifierPlugin::minify()}. |
|
580 | + * |
|
581 | + * @param aCssToken $token Token to process |
|
582 | + * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
583 | + */ |
|
584 | + public function apply(aCssToken &$token) |
|
585 | + { |
|
586 | + if (stripos($token->Value, "var") !== false && preg_match_all($this->reMatch, $token->Value, $m)) |
|
587 | + { |
|
588 | + $mediaTypes = $token->MediaTypes; |
|
589 | + if (!in_array("all", $mediaTypes)) |
|
590 | + { |
|
591 | + $mediaTypes[] = "all"; |
|
592 | + } |
|
593 | + for ($i = 0, $l = count($m[0]); $i < $l; $i++) |
|
594 | + { |
|
595 | + $variable = trim($m[1][$i]); |
|
596 | + foreach ($mediaTypes as $mediaType) |
|
597 | + { |
|
598 | + if (isset($this->variables[$mediaType], $this->variables[$mediaType][$variable])) |
|
599 | + { |
|
600 | + // Variable value found => set the declaration value to the variable value and return |
|
601 | + $token->Value = str_replace($m[0][$i], $this->variables[$mediaType][$variable], $token->Value); |
|
602 | + continue 2; |
|
603 | + } |
|
604 | + } |
|
605 | + // If no value was found trigger an error and replace the token with a CssNullToken |
|
606 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": No value found for variable <code>" . $variable . "</code> in media types <code>" . implode(", ", $mediaTypes) . "</code>", (string) $token)); |
|
607 | + $token = new CssNullToken(); |
|
608 | + return true; |
|
609 | + } |
|
610 | + } |
|
611 | + return false; |
|
612 | + } |
|
613 | + /** |
|
614 | + * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
615 | + * |
|
616 | + * @return array |
|
617 | + */ |
|
618 | + public function getTriggerTokens() |
|
619 | + { |
|
620 | + return array |
|
621 | + ( |
|
622 | + "CssAtFontFaceDeclarationToken", |
|
623 | + "CssAtPageDeclarationToken", |
|
624 | + "CssRulesetDeclarationToken" |
|
625 | + ); |
|
626 | + } |
|
627 | + /** |
|
628 | + * Sets the variables. |
|
629 | + * |
|
630 | + * @param array $variables Variables to set |
|
631 | + * @return void |
|
632 | + */ |
|
633 | + public function setVariables(array $variables) |
|
634 | + { |
|
635 | + $this->variables = $variables; |
|
636 | + } |
|
637 | + } |
|
638 | 638 | |
639 | 639 | /** |
640 | 640 | * This {@link aCssMinifierFilter minifier filter} will parse the variable declarations out of @variables at-rule |
@@ -649,86 +649,86 @@ discard block |
||
649 | 649 | * @version 3.0.1 |
650 | 650 | */ |
651 | 651 | class CssVariablesMinifierFilter extends aCssMinifierFilter |
652 | - { |
|
653 | - /** |
|
654 | - * Implements {@link aCssMinifierFilter::filter()}. |
|
655 | - * |
|
656 | - * @param array $tokens Array of objects of type aCssToken |
|
657 | - * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
658 | - */ |
|
659 | - public function apply(array &$tokens) |
|
660 | - { |
|
661 | - $variables = array(); |
|
662 | - $defaultMediaTypes = array("all"); |
|
663 | - $mediaTypes = array(); |
|
664 | - $remove = array(); |
|
665 | - for($i = 0, $l = count($tokens); $i < $l; $i++) |
|
666 | - { |
|
667 | - // @variables at-rule block found |
|
668 | - if (get_class($tokens[$i]) === "CssAtVariablesStartToken") |
|
669 | - { |
|
670 | - $remove[] = $i; |
|
671 | - $mediaTypes = (count($tokens[$i]->MediaTypes) == 0 ? $defaultMediaTypes : $tokens[$i]->MediaTypes); |
|
672 | - foreach ($mediaTypes as $mediaType) |
|
673 | - { |
|
674 | - if (!isset($variables[$mediaType])) |
|
675 | - { |
|
676 | - $variables[$mediaType] = array(); |
|
677 | - } |
|
678 | - } |
|
679 | - // Read the variable declaration tokens |
|
680 | - for($i = $i; $i < $l; $i++) |
|
681 | - { |
|
682 | - // Found a variable declaration => read the variable values |
|
683 | - if (get_class($tokens[$i]) === "CssAtVariablesDeclarationToken") |
|
684 | - { |
|
685 | - foreach ($mediaTypes as $mediaType) |
|
686 | - { |
|
687 | - $variables[$mediaType][$tokens[$i]->Property] = $tokens[$i]->Value; |
|
688 | - } |
|
689 | - $remove[] = $i; |
|
690 | - } |
|
691 | - // Found the variables end token => break; |
|
692 | - elseif (get_class($tokens[$i]) === "CssAtVariablesEndToken") |
|
693 | - { |
|
694 | - $remove[] = $i; |
|
695 | - break; |
|
696 | - } |
|
697 | - } |
|
698 | - } |
|
699 | - } |
|
700 | - // Variables in @variables at-rule blocks |
|
701 | - foreach($variables as $mediaType => $null) |
|
702 | - { |
|
703 | - foreach($variables[$mediaType] as $variable => $value) |
|
704 | - { |
|
705 | - // If a var() statement in a variable value found... |
|
706 | - if (stripos($value, "var") !== false && preg_match_all("/var\((.+)\)/iSU", $value, $m)) |
|
707 | - { |
|
708 | - // ... then replace the var() statement with the variable values. |
|
709 | - for ($i = 0, $l = count($m[0]); $i < $l; $i++) |
|
710 | - { |
|
711 | - $variables[$mediaType][$variable] = str_replace($m[0][$i], (isset($variables[$mediaType][$m[1][$i]]) ? $variables[$mediaType][$m[1][$i]] : ""), $variables[$mediaType][$variable]); |
|
712 | - } |
|
713 | - } |
|
714 | - } |
|
715 | - } |
|
716 | - // Remove the complete @variables at-rule block |
|
717 | - foreach ($remove as $i) |
|
718 | - { |
|
719 | - $tokens[$i] = null; |
|
720 | - } |
|
721 | - if (!($plugin = $this->minifier->getPlugin("CssVariablesMinifierPlugin"))) |
|
722 | - { |
|
723 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The plugin <code>CssVariablesMinifierPlugin</code> was not found but is required for <code>" . __CLASS__ . "</code>")); |
|
724 | - } |
|
725 | - else |
|
726 | - { |
|
727 | - $plugin->setVariables($variables); |
|
728 | - } |
|
729 | - return count($remove); |
|
730 | - } |
|
731 | - } |
|
652 | + { |
|
653 | + /** |
|
654 | + * Implements {@link aCssMinifierFilter::filter()}. |
|
655 | + * |
|
656 | + * @param array $tokens Array of objects of type aCssToken |
|
657 | + * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
658 | + */ |
|
659 | + public function apply(array &$tokens) |
|
660 | + { |
|
661 | + $variables = array(); |
|
662 | + $defaultMediaTypes = array("all"); |
|
663 | + $mediaTypes = array(); |
|
664 | + $remove = array(); |
|
665 | + for($i = 0, $l = count($tokens); $i < $l; $i++) |
|
666 | + { |
|
667 | + // @variables at-rule block found |
|
668 | + if (get_class($tokens[$i]) === "CssAtVariablesStartToken") |
|
669 | + { |
|
670 | + $remove[] = $i; |
|
671 | + $mediaTypes = (count($tokens[$i]->MediaTypes) == 0 ? $defaultMediaTypes : $tokens[$i]->MediaTypes); |
|
672 | + foreach ($mediaTypes as $mediaType) |
|
673 | + { |
|
674 | + if (!isset($variables[$mediaType])) |
|
675 | + { |
|
676 | + $variables[$mediaType] = array(); |
|
677 | + } |
|
678 | + } |
|
679 | + // Read the variable declaration tokens |
|
680 | + for($i = $i; $i < $l; $i++) |
|
681 | + { |
|
682 | + // Found a variable declaration => read the variable values |
|
683 | + if (get_class($tokens[$i]) === "CssAtVariablesDeclarationToken") |
|
684 | + { |
|
685 | + foreach ($mediaTypes as $mediaType) |
|
686 | + { |
|
687 | + $variables[$mediaType][$tokens[$i]->Property] = $tokens[$i]->Value; |
|
688 | + } |
|
689 | + $remove[] = $i; |
|
690 | + } |
|
691 | + // Found the variables end token => break; |
|
692 | + elseif (get_class($tokens[$i]) === "CssAtVariablesEndToken") |
|
693 | + { |
|
694 | + $remove[] = $i; |
|
695 | + break; |
|
696 | + } |
|
697 | + } |
|
698 | + } |
|
699 | + } |
|
700 | + // Variables in @variables at-rule blocks |
|
701 | + foreach($variables as $mediaType => $null) |
|
702 | + { |
|
703 | + foreach($variables[$mediaType] as $variable => $value) |
|
704 | + { |
|
705 | + // If a var() statement in a variable value found... |
|
706 | + if (stripos($value, "var") !== false && preg_match_all("/var\((.+)\)/iSU", $value, $m)) |
|
707 | + { |
|
708 | + // ... then replace the var() statement with the variable values. |
|
709 | + for ($i = 0, $l = count($m[0]); $i < $l; $i++) |
|
710 | + { |
|
711 | + $variables[$mediaType][$variable] = str_replace($m[0][$i], (isset($variables[$mediaType][$m[1][$i]]) ? $variables[$mediaType][$m[1][$i]] : ""), $variables[$mediaType][$variable]); |
|
712 | + } |
|
713 | + } |
|
714 | + } |
|
715 | + } |
|
716 | + // Remove the complete @variables at-rule block |
|
717 | + foreach ($remove as $i) |
|
718 | + { |
|
719 | + $tokens[$i] = null; |
|
720 | + } |
|
721 | + if (!($plugin = $this->minifier->getPlugin("CssVariablesMinifierPlugin"))) |
|
722 | + { |
|
723 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The plugin <code>CssVariablesMinifierPlugin</code> was not found but is required for <code>" . __CLASS__ . "</code>")); |
|
724 | + } |
|
725 | + else |
|
726 | + { |
|
727 | + $plugin->setVariables($variables); |
|
728 | + } |
|
729 | + return count($remove); |
|
730 | + } |
|
731 | + } |
|
732 | 732 | |
733 | 733 | /** |
734 | 734 | * {@link aCssParserPlugin Parser plugin} for preserve parsing url() values. |
@@ -743,68 +743,68 @@ discard block |
||
743 | 743 | * @version 3.0.1 |
744 | 744 | */ |
745 | 745 | class CssUrlParserPlugin extends aCssParserPlugin |
746 | - { |
|
747 | - /** |
|
748 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
749 | - * |
|
750 | - * @return array |
|
751 | - */ |
|
752 | - public function getTriggerChars() |
|
753 | - { |
|
754 | - return array("(", ")"); |
|
755 | - } |
|
756 | - /** |
|
757 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
758 | - * |
|
759 | - * @return array |
|
760 | - */ |
|
761 | - public function getTriggerStates() |
|
762 | - { |
|
763 | - return false; |
|
764 | - } |
|
765 | - /** |
|
766 | - * Implements {@link aCssParserPlugin::parse()}. |
|
767 | - * |
|
768 | - * @param integer $index Current index |
|
769 | - * @param string $char Current char |
|
770 | - * @param string $previousChar Previous char |
|
771 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
772 | - */ |
|
773 | - public function parse($index, $char, $previousChar, $state) |
|
774 | - { |
|
775 | - // Start of string |
|
776 | - if ($char === "(" && strtolower(substr($this->parser->getSource(), $index - 3, 4)) === "url(" && $state !== "T_URL") |
|
777 | - { |
|
778 | - $this->parser->pushState("T_URL"); |
|
779 | - $this->parser->setExclusive(__CLASS__); |
|
780 | - } |
|
781 | - // Escaped LF in url => remove escape backslash and LF |
|
782 | - elseif ($char === "\n" && $previousChar === "\\" && $state === "T_URL") |
|
783 | - { |
|
784 | - $this->parser->setBuffer(substr($this->parser->getBuffer(), 0, -2)); |
|
785 | - } |
|
786 | - // Parse error: Unescaped LF in string literal |
|
787 | - elseif ($char === "\n" && $previousChar !== "\\" && $state === "T_URL") |
|
788 | - { |
|
789 | - $line = $this->parser->getBuffer(); |
|
790 | - $this->parser->setBuffer(substr($this->parser->getBuffer(), 0, -1) . ")"); // Replace the LF with the url string delimiter |
|
791 | - $this->parser->popState(); |
|
792 | - $this->parser->unsetExclusive(); |
|
793 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated string literal", $line . "_")); |
|
794 | - } |
|
795 | - // End of string |
|
796 | - elseif ($char === ")" && $state === "T_URL") |
|
797 | - { |
|
798 | - $this->parser->popState(); |
|
799 | - $this->parser->unsetExclusive(); |
|
800 | - } |
|
801 | - else |
|
802 | - { |
|
803 | - return false; |
|
804 | - } |
|
805 | - return true; |
|
806 | - } |
|
807 | - } |
|
746 | + { |
|
747 | + /** |
|
748 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
749 | + * |
|
750 | + * @return array |
|
751 | + */ |
|
752 | + public function getTriggerChars() |
|
753 | + { |
|
754 | + return array("(", ")"); |
|
755 | + } |
|
756 | + /** |
|
757 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
758 | + * |
|
759 | + * @return array |
|
760 | + */ |
|
761 | + public function getTriggerStates() |
|
762 | + { |
|
763 | + return false; |
|
764 | + } |
|
765 | + /** |
|
766 | + * Implements {@link aCssParserPlugin::parse()}. |
|
767 | + * |
|
768 | + * @param integer $index Current index |
|
769 | + * @param string $char Current char |
|
770 | + * @param string $previousChar Previous char |
|
771 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
772 | + */ |
|
773 | + public function parse($index, $char, $previousChar, $state) |
|
774 | + { |
|
775 | + // Start of string |
|
776 | + if ($char === "(" && strtolower(substr($this->parser->getSource(), $index - 3, 4)) === "url(" && $state !== "T_URL") |
|
777 | + { |
|
778 | + $this->parser->pushState("T_URL"); |
|
779 | + $this->parser->setExclusive(__CLASS__); |
|
780 | + } |
|
781 | + // Escaped LF in url => remove escape backslash and LF |
|
782 | + elseif ($char === "\n" && $previousChar === "\\" && $state === "T_URL") |
|
783 | + { |
|
784 | + $this->parser->setBuffer(substr($this->parser->getBuffer(), 0, -2)); |
|
785 | + } |
|
786 | + // Parse error: Unescaped LF in string literal |
|
787 | + elseif ($char === "\n" && $previousChar !== "\\" && $state === "T_URL") |
|
788 | + { |
|
789 | + $line = $this->parser->getBuffer(); |
|
790 | + $this->parser->setBuffer(substr($this->parser->getBuffer(), 0, -1) . ")"); // Replace the LF with the url string delimiter |
|
791 | + $this->parser->popState(); |
|
792 | + $this->parser->unsetExclusive(); |
|
793 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated string literal", $line . "_")); |
|
794 | + } |
|
795 | + // End of string |
|
796 | + elseif ($char === ")" && $state === "T_URL") |
|
797 | + { |
|
798 | + $this->parser->popState(); |
|
799 | + $this->parser->unsetExclusive(); |
|
800 | + } |
|
801 | + else |
|
802 | + { |
|
803 | + return false; |
|
804 | + } |
|
805 | + return true; |
|
806 | + } |
|
807 | + } |
|
808 | 808 | |
809 | 809 | /** |
810 | 810 | * {@link aCssParserPlugin Parser plugin} for preserve parsing string values. |
@@ -819,93 +819,93 @@ discard block |
||
819 | 819 | * @version 3.0.1 |
820 | 820 | */ |
821 | 821 | class CssStringParserPlugin extends aCssParserPlugin |
822 | - { |
|
823 | - /** |
|
824 | - * Current string delimiter char. |
|
825 | - * |
|
826 | - * @var string |
|
827 | - */ |
|
828 | - private $delimiterChar = null; |
|
829 | - /** |
|
830 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
831 | - * |
|
832 | - * @return array |
|
833 | - */ |
|
834 | - public function getTriggerChars() |
|
835 | - { |
|
836 | - return array("\"", "'", "\n"); |
|
837 | - } |
|
838 | - /** |
|
839 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
840 | - * |
|
841 | - * @return array |
|
842 | - */ |
|
843 | - public function getTriggerStates() |
|
844 | - { |
|
845 | - return false; |
|
846 | - } |
|
847 | - /** |
|
848 | - * Implements {@link aCssParserPlugin::parse()}. |
|
849 | - * |
|
850 | - * @param integer $index Current index |
|
851 | - * @param string $char Current char |
|
852 | - * @param string $previousChar Previous char |
|
853 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
854 | - */ |
|
855 | - public function parse($index, $char, $previousChar, $state) |
|
856 | - { |
|
857 | - // Start of string |
|
858 | - if (($char === "\"" || $char === "'") && $state !== "T_STRING") |
|
859 | - { |
|
860 | - $this->delimiterChar = $char; |
|
861 | - $this->parser->pushState("T_STRING"); |
|
862 | - $this->parser->setExclusive(__CLASS__); |
|
863 | - } |
|
864 | - // Escaped LF in string => remove escape backslash and LF |
|
865 | - elseif ($char === "\n" && $previousChar === "\\" && $state === "T_STRING") |
|
866 | - { |
|
867 | - $this->parser->setBuffer(substr($this->parser->getBuffer(), 0, -2)); |
|
868 | - } |
|
869 | - // Parse error: Unescaped LF in string literal |
|
870 | - elseif ($char === "\n" && $previousChar !== "\\" && $state === "T_STRING") |
|
871 | - { |
|
872 | - $line = $this->parser->getBuffer(); |
|
873 | - $this->parser->popState(); |
|
874 | - $this->parser->unsetExclusive(); |
|
875 | - $this->parser->setBuffer(substr($this->parser->getBuffer(), 0, -1) . $this->delimiterChar); // Replace the LF with the current string char |
|
876 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated string literal", $line . "_")); |
|
877 | - $this->delimiterChar = null; |
|
878 | - } |
|
879 | - // End of string |
|
880 | - elseif ($char === $this->delimiterChar && $state === "T_STRING") |
|
881 | - { |
|
882 | - // If the Previous char is a escape char count the amount of the previous escape chars. If the amount of |
|
883 | - // escape chars is uneven do not end the string |
|
884 | - if ($previousChar == "\\") |
|
885 | - { |
|
886 | - $source = $this->parser->getSource(); |
|
887 | - $c = 1; |
|
888 | - $i = $index - 2; |
|
889 | - while (substr($source, $i, 1) === "\\") |
|
890 | - { |
|
891 | - $c++; $i--; |
|
892 | - } |
|
893 | - if ($c % 2) |
|
894 | - { |
|
895 | - return false; |
|
896 | - } |
|
897 | - } |
|
898 | - $this->parser->popState(); |
|
899 | - $this->parser->unsetExclusive(); |
|
900 | - $this->delimiterChar = null; |
|
901 | - } |
|
902 | - else |
|
903 | - { |
|
904 | - return false; |
|
905 | - } |
|
906 | - return true; |
|
907 | - } |
|
908 | - } |
|
822 | + { |
|
823 | + /** |
|
824 | + * Current string delimiter char. |
|
825 | + * |
|
826 | + * @var string |
|
827 | + */ |
|
828 | + private $delimiterChar = null; |
|
829 | + /** |
|
830 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
831 | + * |
|
832 | + * @return array |
|
833 | + */ |
|
834 | + public function getTriggerChars() |
|
835 | + { |
|
836 | + return array("\"", "'", "\n"); |
|
837 | + } |
|
838 | + /** |
|
839 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
840 | + * |
|
841 | + * @return array |
|
842 | + */ |
|
843 | + public function getTriggerStates() |
|
844 | + { |
|
845 | + return false; |
|
846 | + } |
|
847 | + /** |
|
848 | + * Implements {@link aCssParserPlugin::parse()}. |
|
849 | + * |
|
850 | + * @param integer $index Current index |
|
851 | + * @param string $char Current char |
|
852 | + * @param string $previousChar Previous char |
|
853 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
854 | + */ |
|
855 | + public function parse($index, $char, $previousChar, $state) |
|
856 | + { |
|
857 | + // Start of string |
|
858 | + if (($char === "\"" || $char === "'") && $state !== "T_STRING") |
|
859 | + { |
|
860 | + $this->delimiterChar = $char; |
|
861 | + $this->parser->pushState("T_STRING"); |
|
862 | + $this->parser->setExclusive(__CLASS__); |
|
863 | + } |
|
864 | + // Escaped LF in string => remove escape backslash and LF |
|
865 | + elseif ($char === "\n" && $previousChar === "\\" && $state === "T_STRING") |
|
866 | + { |
|
867 | + $this->parser->setBuffer(substr($this->parser->getBuffer(), 0, -2)); |
|
868 | + } |
|
869 | + // Parse error: Unescaped LF in string literal |
|
870 | + elseif ($char === "\n" && $previousChar !== "\\" && $state === "T_STRING") |
|
871 | + { |
|
872 | + $line = $this->parser->getBuffer(); |
|
873 | + $this->parser->popState(); |
|
874 | + $this->parser->unsetExclusive(); |
|
875 | + $this->parser->setBuffer(substr($this->parser->getBuffer(), 0, -1) . $this->delimiterChar); // Replace the LF with the current string char |
|
876 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated string literal", $line . "_")); |
|
877 | + $this->delimiterChar = null; |
|
878 | + } |
|
879 | + // End of string |
|
880 | + elseif ($char === $this->delimiterChar && $state === "T_STRING") |
|
881 | + { |
|
882 | + // If the Previous char is a escape char count the amount of the previous escape chars. If the amount of |
|
883 | + // escape chars is uneven do not end the string |
|
884 | + if ($previousChar == "\\") |
|
885 | + { |
|
886 | + $source = $this->parser->getSource(); |
|
887 | + $c = 1; |
|
888 | + $i = $index - 2; |
|
889 | + while (substr($source, $i, 1) === "\\") |
|
890 | + { |
|
891 | + $c++; $i--; |
|
892 | + } |
|
893 | + if ($c % 2) |
|
894 | + { |
|
895 | + return false; |
|
896 | + } |
|
897 | + } |
|
898 | + $this->parser->popState(); |
|
899 | + $this->parser->unsetExclusive(); |
|
900 | + $this->delimiterChar = null; |
|
901 | + } |
|
902 | + else |
|
903 | + { |
|
904 | + return false; |
|
905 | + } |
|
906 | + return true; |
|
907 | + } |
|
908 | + } |
|
909 | 909 | |
910 | 910 | /** |
911 | 911 | * This {@link aCssMinifierFilter minifier filter} sorts the ruleset declarations of a ruleset by name. |
@@ -918,84 +918,84 @@ discard block |
||
918 | 918 | * @version 3.0.1 |
919 | 919 | */ |
920 | 920 | class CssSortRulesetPropertiesMinifierFilter extends aCssMinifierFilter |
921 | - { |
|
922 | - /** |
|
923 | - * Implements {@link aCssMinifierFilter::filter()}. |
|
924 | - * |
|
925 | - * @param array $tokens Array of objects of type aCssToken |
|
926 | - * @return integer Count of added, changed or removed tokens; a return value larger than 0 will rebuild the array |
|
927 | - */ |
|
928 | - public function apply(array &$tokens) |
|
929 | - { |
|
930 | - $r = 0; |
|
931 | - for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
932 | - { |
|
933 | - // Only look for ruleset start rules |
|
934 | - if (get_class($tokens[$i]) !== "CssRulesetStartToken") { continue; } |
|
935 | - // Look for the corresponding ruleset end |
|
936 | - $endIndex = false; |
|
937 | - for ($ii = $i + 1; $ii < $l; $ii++) |
|
938 | - { |
|
939 | - if (get_class($tokens[$ii]) !== "CssRulesetEndToken") { continue; } |
|
940 | - $endIndex = $ii; |
|
941 | - break; |
|
942 | - } |
|
943 | - if (!$endIndex) { break; } |
|
944 | - $startIndex = $i; |
|
945 | - $i = $endIndex; |
|
946 | - // Skip if there's only one token in this ruleset |
|
947 | - if ($endIndex - $startIndex <= 2) { continue; } |
|
948 | - // Ensure that everything between the start and end is a declaration token, for safety |
|
949 | - for ($ii = $startIndex + 1; $ii < $endIndex; $ii++) |
|
950 | - { |
|
951 | - if (get_class($tokens[$ii]) !== "CssRulesetDeclarationToken") { continue(2); } |
|
952 | - } |
|
953 | - $declarations = array_slice($tokens, $startIndex + 1, $endIndex - $startIndex - 1); |
|
954 | - // Check whether a sort is required |
|
955 | - $sortRequired = $lastPropertyName = false; |
|
956 | - foreach ($declarations as $declaration) |
|
957 | - { |
|
958 | - if ($lastPropertyName) |
|
959 | - { |
|
960 | - if (strcmp($lastPropertyName, $declaration->Property) > 0) |
|
961 | - { |
|
962 | - $sortRequired = true; |
|
963 | - break; |
|
964 | - } |
|
965 | - } |
|
966 | - $lastPropertyName = $declaration->Property; |
|
967 | - } |
|
968 | - if (!$sortRequired) { continue; } |
|
969 | - // Arrange the declarations alphabetically by name |
|
970 | - usort($declarations, array(__CLASS__, "userDefinedSort1")); |
|
971 | - // Update "IsLast" property |
|
972 | - for ($ii = 0, $ll = count($declarations) - 1; $ii <= $ll; $ii++) |
|
973 | - { |
|
974 | - if ($ii == $ll) |
|
975 | - { |
|
976 | - $declarations[$ii]->IsLast = true; |
|
977 | - } |
|
978 | - else |
|
979 | - { |
|
980 | - $declarations[$ii]->IsLast = false; |
|
981 | - } |
|
982 | - } |
|
983 | - // Splice back into the array. |
|
984 | - array_splice($tokens, $startIndex + 1, $endIndex - $startIndex - 1, $declarations); |
|
985 | - $r += $endIndex - $startIndex - 1; |
|
986 | - } |
|
987 | - return $r; |
|
988 | - } |
|
989 | - /** |
|
990 | - * User defined sort function. |
|
991 | - * |
|
992 | - * @return integer |
|
993 | - */ |
|
994 | - public static function userDefinedSort1($a, $b) |
|
995 | - { |
|
996 | - return strcmp($a->Property, $b->Property); |
|
997 | - } |
|
998 | - } |
|
921 | + { |
|
922 | + /** |
|
923 | + * Implements {@link aCssMinifierFilter::filter()}. |
|
924 | + * |
|
925 | + * @param array $tokens Array of objects of type aCssToken |
|
926 | + * @return integer Count of added, changed or removed tokens; a return value larger than 0 will rebuild the array |
|
927 | + */ |
|
928 | + public function apply(array &$tokens) |
|
929 | + { |
|
930 | + $r = 0; |
|
931 | + for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
932 | + { |
|
933 | + // Only look for ruleset start rules |
|
934 | + if (get_class($tokens[$i]) !== "CssRulesetStartToken") { continue; } |
|
935 | + // Look for the corresponding ruleset end |
|
936 | + $endIndex = false; |
|
937 | + for ($ii = $i + 1; $ii < $l; $ii++) |
|
938 | + { |
|
939 | + if (get_class($tokens[$ii]) !== "CssRulesetEndToken") { continue; } |
|
940 | + $endIndex = $ii; |
|
941 | + break; |
|
942 | + } |
|
943 | + if (!$endIndex) { break; } |
|
944 | + $startIndex = $i; |
|
945 | + $i = $endIndex; |
|
946 | + // Skip if there's only one token in this ruleset |
|
947 | + if ($endIndex - $startIndex <= 2) { continue; } |
|
948 | + // Ensure that everything between the start and end is a declaration token, for safety |
|
949 | + for ($ii = $startIndex + 1; $ii < $endIndex; $ii++) |
|
950 | + { |
|
951 | + if (get_class($tokens[$ii]) !== "CssRulesetDeclarationToken") { continue(2); } |
|
952 | + } |
|
953 | + $declarations = array_slice($tokens, $startIndex + 1, $endIndex - $startIndex - 1); |
|
954 | + // Check whether a sort is required |
|
955 | + $sortRequired = $lastPropertyName = false; |
|
956 | + foreach ($declarations as $declaration) |
|
957 | + { |
|
958 | + if ($lastPropertyName) |
|
959 | + { |
|
960 | + if (strcmp($lastPropertyName, $declaration->Property) > 0) |
|
961 | + { |
|
962 | + $sortRequired = true; |
|
963 | + break; |
|
964 | + } |
|
965 | + } |
|
966 | + $lastPropertyName = $declaration->Property; |
|
967 | + } |
|
968 | + if (!$sortRequired) { continue; } |
|
969 | + // Arrange the declarations alphabetically by name |
|
970 | + usort($declarations, array(__CLASS__, "userDefinedSort1")); |
|
971 | + // Update "IsLast" property |
|
972 | + for ($ii = 0, $ll = count($declarations) - 1; $ii <= $ll; $ii++) |
|
973 | + { |
|
974 | + if ($ii == $ll) |
|
975 | + { |
|
976 | + $declarations[$ii]->IsLast = true; |
|
977 | + } |
|
978 | + else |
|
979 | + { |
|
980 | + $declarations[$ii]->IsLast = false; |
|
981 | + } |
|
982 | + } |
|
983 | + // Splice back into the array. |
|
984 | + array_splice($tokens, $startIndex + 1, $endIndex - $startIndex - 1, $declarations); |
|
985 | + $r += $endIndex - $startIndex - 1; |
|
986 | + } |
|
987 | + return $r; |
|
988 | + } |
|
989 | + /** |
|
990 | + * User defined sort function. |
|
991 | + * |
|
992 | + * @return integer |
|
993 | + */ |
|
994 | + public static function userDefinedSort1($a, $b) |
|
995 | + { |
|
996 | + return strcmp($a->Property, $b->Property); |
|
997 | + } |
|
998 | + } |
|
999 | 999 | |
1000 | 1000 | /** |
1001 | 1001 | * This {@link aCssToken CSS token} represents the start of a ruleset. |
@@ -1008,33 +1008,33 @@ discard block |
||
1008 | 1008 | * @version 3.0.1 |
1009 | 1009 | */ |
1010 | 1010 | class CssRulesetStartToken extends aCssRulesetStartToken |
1011 | - { |
|
1012 | - /** |
|
1013 | - * Array of selectors. |
|
1014 | - * |
|
1015 | - * @var array |
|
1016 | - */ |
|
1017 | - public $Selectors = array(); |
|
1018 | - /** |
|
1019 | - * Set the properties of a ruleset token. |
|
1020 | - * |
|
1021 | - * @param array $selectors Selectors of the ruleset |
|
1022 | - * @return void |
|
1023 | - */ |
|
1024 | - public function __construct(array $selectors = array()) |
|
1025 | - { |
|
1026 | - $this->Selectors = $selectors; |
|
1027 | - } |
|
1028 | - /** |
|
1029 | - * Implements {@link aCssToken::__toString()}. |
|
1030 | - * |
|
1031 | - * @return string |
|
1032 | - */ |
|
1033 | - public function __toString() |
|
1034 | - { |
|
1035 | - return implode(",", $this->Selectors) . "{"; |
|
1036 | - } |
|
1037 | - } |
|
1011 | + { |
|
1012 | + /** |
|
1013 | + * Array of selectors. |
|
1014 | + * |
|
1015 | + * @var array |
|
1016 | + */ |
|
1017 | + public $Selectors = array(); |
|
1018 | + /** |
|
1019 | + * Set the properties of a ruleset token. |
|
1020 | + * |
|
1021 | + * @param array $selectors Selectors of the ruleset |
|
1022 | + * @return void |
|
1023 | + */ |
|
1024 | + public function __construct(array $selectors = array()) |
|
1025 | + { |
|
1026 | + $this->Selectors = $selectors; |
|
1027 | + } |
|
1028 | + /** |
|
1029 | + * Implements {@link aCssToken::__toString()}. |
|
1030 | + * |
|
1031 | + * @return string |
|
1032 | + */ |
|
1033 | + public function __toString() |
|
1034 | + { |
|
1035 | + return implode(",", $this->Selectors) . "{"; |
|
1036 | + } |
|
1037 | + } |
|
1038 | 1038 | |
1039 | 1039 | /** |
1040 | 1040 | * {@link aCssParserPlugin Parser plugin} for parsing ruleset block with including declarations. |
@@ -1050,120 +1050,120 @@ discard block |
||
1050 | 1050 | * @version 3.0.1 |
1051 | 1051 | */ |
1052 | 1052 | class CssRulesetParserPlugin extends aCssParserPlugin |
1053 | - { |
|
1054 | - /** |
|
1055 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
1056 | - * |
|
1057 | - * @return array |
|
1058 | - */ |
|
1059 | - public function getTriggerChars() |
|
1060 | - { |
|
1061 | - return array(",", "{", "}", ":", ";"); |
|
1062 | - } |
|
1063 | - /** |
|
1064 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
1065 | - * |
|
1066 | - * @return array |
|
1067 | - */ |
|
1068 | - public function getTriggerStates() |
|
1069 | - { |
|
1070 | - return array("T_DOCUMENT", "T_AT_MEDIA", "T_RULESET::SELECTORS", "T_RULESET", "T_RULESET_DECLARATION"); |
|
1071 | - } |
|
1072 | - /** |
|
1073 | - * Selectors. |
|
1074 | - * |
|
1075 | - * @var array |
|
1076 | - */ |
|
1077 | - private $selectors = array(); |
|
1078 | - /** |
|
1079 | - * Implements {@link aCssParserPlugin::parse()}. |
|
1080 | - * |
|
1081 | - * @param integer $index Current index |
|
1082 | - * @param string $char Current char |
|
1083 | - * @param string $previousChar Previous char |
|
1084 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
1085 | - */ |
|
1086 | - public function parse($index, $char, $previousChar, $state) |
|
1087 | - { |
|
1088 | - // Start of Ruleset and selectors |
|
1089 | - if ($char === "," && ($state === "T_DOCUMENT" || $state === "T_AT_MEDIA" || $state === "T_RULESET::SELECTORS")) |
|
1090 | - { |
|
1091 | - if ($state !== "T_RULESET::SELECTORS") |
|
1092 | - { |
|
1093 | - $this->parser->pushState("T_RULESET::SELECTORS"); |
|
1094 | - } |
|
1095 | - $this->selectors[] = $this->parser->getAndClearBuffer(",{"); |
|
1096 | - } |
|
1097 | - // End of selectors and start of declarations |
|
1098 | - elseif ($char === "{" && ($state === "T_DOCUMENT" || $state === "T_AT_MEDIA" || $state === "T_RULESET::SELECTORS")) |
|
1099 | - { |
|
1100 | - if ($this->parser->getBuffer() !== "") |
|
1101 | - { |
|
1102 | - $this->selectors[] = $this->parser->getAndClearBuffer(",{"); |
|
1103 | - if ($state == "T_RULESET::SELECTORS") |
|
1104 | - { |
|
1105 | - $this->parser->popState(); |
|
1106 | - } |
|
1107 | - $this->parser->pushState("T_RULESET"); |
|
1108 | - $this->parser->appendToken(new CssRulesetStartToken($this->selectors)); |
|
1109 | - $this->selectors = array(); |
|
1110 | - } |
|
1111 | - } |
|
1112 | - // Start of declaration |
|
1113 | - elseif ($char === ":" && $state === "T_RULESET") |
|
1114 | - { |
|
1115 | - $this->parser->pushState("T_RULESET_DECLARATION"); |
|
1116 | - $this->buffer = $this->parser->getAndClearBuffer(":;", true); |
|
1117 | - } |
|
1118 | - // Unterminated ruleset declaration |
|
1119 | - elseif ($char === ":" && $state === "T_RULESET_DECLARATION") |
|
1120 | - { |
|
1121 | - // Ignore Internet Explorer filter declarations |
|
1122 | - if ($this->buffer === "filter") |
|
1123 | - { |
|
1124 | - return false; |
|
1125 | - } |
|
1126 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated declaration", $this->buffer . ":" . $this->parser->getBuffer() . "_")); |
|
1127 | - } |
|
1128 | - // End of declaration |
|
1129 | - elseif (($char === ";" || $char === "}") && $state === "T_RULESET_DECLARATION") |
|
1130 | - { |
|
1131 | - $value = $this->parser->getAndClearBuffer(";}"); |
|
1132 | - if (strtolower(substr($value, -10, 10)) === "!important") |
|
1133 | - { |
|
1134 | - $value = trim(substr($value, 0, -10)); |
|
1135 | - $isImportant = true; |
|
1136 | - } |
|
1137 | - else |
|
1138 | - { |
|
1139 | - $isImportant = false; |
|
1140 | - } |
|
1141 | - $this->parser->popState(); |
|
1142 | - $this->parser->appendToken(new CssRulesetDeclarationToken($this->buffer, $value, $this->parser->getMediaTypes(), $isImportant)); |
|
1143 | - // Declaration ends with a right curly brace; so we have to end the ruleset |
|
1144 | - if ($char === "}") |
|
1145 | - { |
|
1146 | - $this->parser->appendToken(new CssRulesetEndToken()); |
|
1147 | - $this->parser->popState(); |
|
1148 | - } |
|
1149 | - $this->buffer = ""; |
|
1150 | - } |
|
1151 | - // End of ruleset |
|
1152 | - elseif ($char === "}" && $state === "T_RULESET") |
|
1153 | - { |
|
1154 | - $this->parser->popState(); |
|
1155 | - $this->parser->clearBuffer(); |
|
1156 | - $this->parser->appendToken(new CssRulesetEndToken()); |
|
1157 | - $this->buffer = ""; |
|
1158 | - $this->selectors = array(); |
|
1159 | - } |
|
1160 | - else |
|
1161 | - { |
|
1162 | - return false; |
|
1163 | - } |
|
1164 | - return true; |
|
1165 | - } |
|
1166 | - } |
|
1053 | + { |
|
1054 | + /** |
|
1055 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
1056 | + * |
|
1057 | + * @return array |
|
1058 | + */ |
|
1059 | + public function getTriggerChars() |
|
1060 | + { |
|
1061 | + return array(",", "{", "}", ":", ";"); |
|
1062 | + } |
|
1063 | + /** |
|
1064 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
1065 | + * |
|
1066 | + * @return array |
|
1067 | + */ |
|
1068 | + public function getTriggerStates() |
|
1069 | + { |
|
1070 | + return array("T_DOCUMENT", "T_AT_MEDIA", "T_RULESET::SELECTORS", "T_RULESET", "T_RULESET_DECLARATION"); |
|
1071 | + } |
|
1072 | + /** |
|
1073 | + * Selectors. |
|
1074 | + * |
|
1075 | + * @var array |
|
1076 | + */ |
|
1077 | + private $selectors = array(); |
|
1078 | + /** |
|
1079 | + * Implements {@link aCssParserPlugin::parse()}. |
|
1080 | + * |
|
1081 | + * @param integer $index Current index |
|
1082 | + * @param string $char Current char |
|
1083 | + * @param string $previousChar Previous char |
|
1084 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
1085 | + */ |
|
1086 | + public function parse($index, $char, $previousChar, $state) |
|
1087 | + { |
|
1088 | + // Start of Ruleset and selectors |
|
1089 | + if ($char === "," && ($state === "T_DOCUMENT" || $state === "T_AT_MEDIA" || $state === "T_RULESET::SELECTORS")) |
|
1090 | + { |
|
1091 | + if ($state !== "T_RULESET::SELECTORS") |
|
1092 | + { |
|
1093 | + $this->parser->pushState("T_RULESET::SELECTORS"); |
|
1094 | + } |
|
1095 | + $this->selectors[] = $this->parser->getAndClearBuffer(",{"); |
|
1096 | + } |
|
1097 | + // End of selectors and start of declarations |
|
1098 | + elseif ($char === "{" && ($state === "T_DOCUMENT" || $state === "T_AT_MEDIA" || $state === "T_RULESET::SELECTORS")) |
|
1099 | + { |
|
1100 | + if ($this->parser->getBuffer() !== "") |
|
1101 | + { |
|
1102 | + $this->selectors[] = $this->parser->getAndClearBuffer(",{"); |
|
1103 | + if ($state == "T_RULESET::SELECTORS") |
|
1104 | + { |
|
1105 | + $this->parser->popState(); |
|
1106 | + } |
|
1107 | + $this->parser->pushState("T_RULESET"); |
|
1108 | + $this->parser->appendToken(new CssRulesetStartToken($this->selectors)); |
|
1109 | + $this->selectors = array(); |
|
1110 | + } |
|
1111 | + } |
|
1112 | + // Start of declaration |
|
1113 | + elseif ($char === ":" && $state === "T_RULESET") |
|
1114 | + { |
|
1115 | + $this->parser->pushState("T_RULESET_DECLARATION"); |
|
1116 | + $this->buffer = $this->parser->getAndClearBuffer(":;", true); |
|
1117 | + } |
|
1118 | + // Unterminated ruleset declaration |
|
1119 | + elseif ($char === ":" && $state === "T_RULESET_DECLARATION") |
|
1120 | + { |
|
1121 | + // Ignore Internet Explorer filter declarations |
|
1122 | + if ($this->buffer === "filter") |
|
1123 | + { |
|
1124 | + return false; |
|
1125 | + } |
|
1126 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated declaration", $this->buffer . ":" . $this->parser->getBuffer() . "_")); |
|
1127 | + } |
|
1128 | + // End of declaration |
|
1129 | + elseif (($char === ";" || $char === "}") && $state === "T_RULESET_DECLARATION") |
|
1130 | + { |
|
1131 | + $value = $this->parser->getAndClearBuffer(";}"); |
|
1132 | + if (strtolower(substr($value, -10, 10)) === "!important") |
|
1133 | + { |
|
1134 | + $value = trim(substr($value, 0, -10)); |
|
1135 | + $isImportant = true; |
|
1136 | + } |
|
1137 | + else |
|
1138 | + { |
|
1139 | + $isImportant = false; |
|
1140 | + } |
|
1141 | + $this->parser->popState(); |
|
1142 | + $this->parser->appendToken(new CssRulesetDeclarationToken($this->buffer, $value, $this->parser->getMediaTypes(), $isImportant)); |
|
1143 | + // Declaration ends with a right curly brace; so we have to end the ruleset |
|
1144 | + if ($char === "}") |
|
1145 | + { |
|
1146 | + $this->parser->appendToken(new CssRulesetEndToken()); |
|
1147 | + $this->parser->popState(); |
|
1148 | + } |
|
1149 | + $this->buffer = ""; |
|
1150 | + } |
|
1151 | + // End of ruleset |
|
1152 | + elseif ($char === "}" && $state === "T_RULESET") |
|
1153 | + { |
|
1154 | + $this->parser->popState(); |
|
1155 | + $this->parser->clearBuffer(); |
|
1156 | + $this->parser->appendToken(new CssRulesetEndToken()); |
|
1157 | + $this->buffer = ""; |
|
1158 | + $this->selectors = array(); |
|
1159 | + } |
|
1160 | + else |
|
1161 | + { |
|
1162 | + return false; |
|
1163 | + } |
|
1164 | + return true; |
|
1165 | + } |
|
1166 | + } |
|
1167 | 1167 | |
1168 | 1168 | /** |
1169 | 1169 | * This {@link aCssToken CSS token} represents the end of a ruleset. |
@@ -1176,9 +1176,9 @@ discard block |
||
1176 | 1176 | * @version 3.0.1 |
1177 | 1177 | */ |
1178 | 1178 | class CssRulesetEndToken extends aCssRulesetEndToken |
1179 | - { |
|
1179 | + { |
|
1180 | 1180 | |
1181 | - } |
|
1181 | + } |
|
1182 | 1182 | |
1183 | 1183 | /** |
1184 | 1184 | * This {@link aCssToken CSS token} represents a ruleset declaration. |
@@ -1191,29 +1191,29 @@ discard block |
||
1191 | 1191 | * @version 3.0.1 |
1192 | 1192 | */ |
1193 | 1193 | class CssRulesetDeclarationToken extends aCssDeclarationToken |
1194 | - { |
|
1195 | - /** |
|
1196 | - * Media types of the declaration. |
|
1197 | - * |
|
1198 | - * @var array |
|
1199 | - */ |
|
1200 | - public $MediaTypes = array("all"); |
|
1201 | - /** |
|
1202 | - * Set the properties of a ddocument- or at-rule @media level declaration. |
|
1203 | - * |
|
1204 | - * @param string $property Property of the declaration |
|
1205 | - * @param string $value Value of the declaration |
|
1206 | - * @param mixed $mediaTypes Media types of the declaration |
|
1207 | - * @param boolean $isImportant Is the !important flag is set |
|
1208 | - * @param boolean $isLast Is the declaration the last one of the ruleset |
|
1209 | - * @return void |
|
1210 | - */ |
|
1211 | - public function __construct($property, $value, $mediaTypes = null, $isImportant = false, $isLast = false) |
|
1212 | - { |
|
1213 | - parent::__construct($property, $value, $isImportant, $isLast); |
|
1214 | - $this->MediaTypes = $mediaTypes ? $mediaTypes : array("all"); |
|
1215 | - } |
|
1216 | - } |
|
1194 | + { |
|
1195 | + /** |
|
1196 | + * Media types of the declaration. |
|
1197 | + * |
|
1198 | + * @var array |
|
1199 | + */ |
|
1200 | + public $MediaTypes = array("all"); |
|
1201 | + /** |
|
1202 | + * Set the properties of a ddocument- or at-rule @media level declaration. |
|
1203 | + * |
|
1204 | + * @param string $property Property of the declaration |
|
1205 | + * @param string $value Value of the declaration |
|
1206 | + * @param mixed $mediaTypes Media types of the declaration |
|
1207 | + * @param boolean $isImportant Is the !important flag is set |
|
1208 | + * @param boolean $isLast Is the declaration the last one of the ruleset |
|
1209 | + * @return void |
|
1210 | + */ |
|
1211 | + public function __construct($property, $value, $mediaTypes = null, $isImportant = false, $isLast = false) |
|
1212 | + { |
|
1213 | + parent::__construct($property, $value, $isImportant, $isLast); |
|
1214 | + $this->MediaTypes = $mediaTypes ? $mediaTypes : array("all"); |
|
1215 | + } |
|
1216 | + } |
|
1217 | 1217 | |
1218 | 1218 | /** |
1219 | 1219 | * This {@link aCssMinifierFilter minifier filter} sets the IsLast property of any last declaration in a ruleset, |
@@ -1228,29 +1228,29 @@ discard block |
||
1228 | 1228 | * @version 3.0.1 |
1229 | 1229 | */ |
1230 | 1230 | class CssRemoveLastDelarationSemiColonMinifierFilter extends aCssMinifierFilter |
1231 | - { |
|
1232 | - /** |
|
1233 | - * Implements {@link aCssMinifierFilter::filter()}. |
|
1234 | - * |
|
1235 | - * @param array $tokens Array of objects of type aCssToken |
|
1236 | - * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
1237 | - */ |
|
1238 | - public function apply(array &$tokens) |
|
1239 | - { |
|
1240 | - for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
1241 | - { |
|
1242 | - $current = get_class($tokens[$i]); |
|
1243 | - $next = isset($tokens[$i+1]) ? get_class($tokens[$i+1]) : false; |
|
1244 | - if (($current === "CssRulesetDeclarationToken" && $next === "CssRulesetEndToken") || |
|
1245 | - ($current === "CssAtFontFaceDeclarationToken" && $next === "CssAtFontFaceEndToken") || |
|
1246 | - ($current === "CssAtPageDeclarationToken" && $next === "CssAtPageEndToken")) |
|
1247 | - { |
|
1248 | - $tokens[$i]->IsLast = true; |
|
1249 | - } |
|
1250 | - } |
|
1251 | - return 0; |
|
1252 | - } |
|
1253 | - } |
|
1231 | + { |
|
1232 | + /** |
|
1233 | + * Implements {@link aCssMinifierFilter::filter()}. |
|
1234 | + * |
|
1235 | + * @param array $tokens Array of objects of type aCssToken |
|
1236 | + * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
1237 | + */ |
|
1238 | + public function apply(array &$tokens) |
|
1239 | + { |
|
1240 | + for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
1241 | + { |
|
1242 | + $current = get_class($tokens[$i]); |
|
1243 | + $next = isset($tokens[$i+1]) ? get_class($tokens[$i+1]) : false; |
|
1244 | + if (($current === "CssRulesetDeclarationToken" && $next === "CssRulesetEndToken") || |
|
1245 | + ($current === "CssAtFontFaceDeclarationToken" && $next === "CssAtFontFaceEndToken") || |
|
1246 | + ($current === "CssAtPageDeclarationToken" && $next === "CssAtPageEndToken")) |
|
1247 | + { |
|
1248 | + $tokens[$i]->IsLast = true; |
|
1249 | + } |
|
1250 | + } |
|
1251 | + return 0; |
|
1252 | + } |
|
1253 | + } |
|
1254 | 1254 | |
1255 | 1255 | /** |
1256 | 1256 | * This {@link aCssMinifierFilter minifier filter} will remove any empty rulesets (including @keyframes at-rule block |
@@ -1264,33 +1264,33 @@ discard block |
||
1264 | 1264 | * @version 3.0.1 |
1265 | 1265 | */ |
1266 | 1266 | class CssRemoveEmptyRulesetsMinifierFilter extends aCssMinifierFilter |
1267 | - { |
|
1268 | - /** |
|
1269 | - * Implements {@link aCssMinifierFilter::filter()}. |
|
1270 | - * |
|
1271 | - * @param array $tokens Array of objects of type aCssToken |
|
1272 | - * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
1273 | - */ |
|
1274 | - public function apply(array &$tokens) |
|
1275 | - { |
|
1276 | - $r = 0; |
|
1277 | - for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
1278 | - { |
|
1279 | - $current = get_class($tokens[$i]); |
|
1280 | - $next = isset($tokens[$i + 1]) ? get_class($tokens[$i + 1]) : false; |
|
1281 | - if (($current === "CssRulesetStartToken" && $next === "CssRulesetEndToken") || |
|
1282 | - ($current === "CssAtKeyframesRulesetStartToken" && $next === "CssAtKeyframesRulesetEndToken" && !array_intersect(array("from", "0%", "to", "100%"), array_map("strtolower", $tokens[$i]->Selectors))) |
|
1283 | - ) |
|
1284 | - { |
|
1285 | - $tokens[$i] = null; |
|
1286 | - $tokens[$i + 1] = null; |
|
1287 | - $i++; |
|
1288 | - $r = $r + 2; |
|
1289 | - } |
|
1290 | - } |
|
1291 | - return $r; |
|
1292 | - } |
|
1293 | - } |
|
1267 | + { |
|
1268 | + /** |
|
1269 | + * Implements {@link aCssMinifierFilter::filter()}. |
|
1270 | + * |
|
1271 | + * @param array $tokens Array of objects of type aCssToken |
|
1272 | + * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
1273 | + */ |
|
1274 | + public function apply(array &$tokens) |
|
1275 | + { |
|
1276 | + $r = 0; |
|
1277 | + for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
1278 | + { |
|
1279 | + $current = get_class($tokens[$i]); |
|
1280 | + $next = isset($tokens[$i + 1]) ? get_class($tokens[$i + 1]) : false; |
|
1281 | + if (($current === "CssRulesetStartToken" && $next === "CssRulesetEndToken") || |
|
1282 | + ($current === "CssAtKeyframesRulesetStartToken" && $next === "CssAtKeyframesRulesetEndToken" && !array_intersect(array("from", "0%", "to", "100%"), array_map("strtolower", $tokens[$i]->Selectors))) |
|
1283 | + ) |
|
1284 | + { |
|
1285 | + $tokens[$i] = null; |
|
1286 | + $tokens[$i + 1] = null; |
|
1287 | + $i++; |
|
1288 | + $r = $r + 2; |
|
1289 | + } |
|
1290 | + } |
|
1291 | + return $r; |
|
1292 | + } |
|
1293 | + } |
|
1294 | 1294 | |
1295 | 1295 | /** |
1296 | 1296 | * This {@link aCssMinifierFilter minifier filter} will remove any empty @font-face, @keyframes, @media and @page |
@@ -1304,34 +1304,34 @@ discard block |
||
1304 | 1304 | * @version 3.0.1 |
1305 | 1305 | */ |
1306 | 1306 | class CssRemoveEmptyAtBlocksMinifierFilter extends aCssMinifierFilter |
1307 | - { |
|
1308 | - /** |
|
1309 | - * Implements {@link aCssMinifierFilter::filter()}. |
|
1310 | - * |
|
1311 | - * @param array $tokens Array of objects of type aCssToken |
|
1312 | - * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
1313 | - */ |
|
1314 | - public function apply(array &$tokens) |
|
1315 | - { |
|
1316 | - $r = 0; |
|
1317 | - for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
1318 | - { |
|
1319 | - $current = get_class($tokens[$i]); |
|
1320 | - $next = isset($tokens[$i + 1]) ? get_class($tokens[$i + 1]) : false; |
|
1321 | - if (($current === "CssAtFontFaceStartToken" && $next === "CssAtFontFaceEndToken") || |
|
1322 | - ($current === "CssAtKeyframesStartToken" && $next === "CssAtKeyframesEndToken") || |
|
1323 | - ($current === "CssAtPageStartToken" && $next === "CssAtPageEndToken") || |
|
1324 | - ($current === "CssAtMediaStartToken" && $next === "CssAtMediaEndToken")) |
|
1325 | - { |
|
1326 | - $tokens[$i] = null; |
|
1327 | - $tokens[$i + 1] = null; |
|
1328 | - $i++; |
|
1329 | - $r = $r + 2; |
|
1330 | - } |
|
1331 | - } |
|
1332 | - return $r; |
|
1333 | - } |
|
1334 | - } |
|
1307 | + { |
|
1308 | + /** |
|
1309 | + * Implements {@link aCssMinifierFilter::filter()}. |
|
1310 | + * |
|
1311 | + * @param array $tokens Array of objects of type aCssToken |
|
1312 | + * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
1313 | + */ |
|
1314 | + public function apply(array &$tokens) |
|
1315 | + { |
|
1316 | + $r = 0; |
|
1317 | + for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
1318 | + { |
|
1319 | + $current = get_class($tokens[$i]); |
|
1320 | + $next = isset($tokens[$i + 1]) ? get_class($tokens[$i + 1]) : false; |
|
1321 | + if (($current === "CssAtFontFaceStartToken" && $next === "CssAtFontFaceEndToken") || |
|
1322 | + ($current === "CssAtKeyframesStartToken" && $next === "CssAtKeyframesEndToken") || |
|
1323 | + ($current === "CssAtPageStartToken" && $next === "CssAtPageEndToken") || |
|
1324 | + ($current === "CssAtMediaStartToken" && $next === "CssAtMediaEndToken")) |
|
1325 | + { |
|
1326 | + $tokens[$i] = null; |
|
1327 | + $tokens[$i + 1] = null; |
|
1328 | + $i++; |
|
1329 | + $r = $r + 2; |
|
1330 | + } |
|
1331 | + } |
|
1332 | + return $r; |
|
1333 | + } |
|
1334 | + } |
|
1335 | 1335 | |
1336 | 1336 | /** |
1337 | 1337 | * This {@link aCssMinifierFilter minifier filter} will remove any comments from the array of parsed tokens. |
@@ -1344,27 +1344,27 @@ discard block |
||
1344 | 1344 | * @version 3.0.1 |
1345 | 1345 | */ |
1346 | 1346 | class CssRemoveCommentsMinifierFilter extends aCssMinifierFilter |
1347 | - { |
|
1348 | - /** |
|
1349 | - * Implements {@link aCssMinifierFilter::filter()}. |
|
1350 | - * |
|
1351 | - * @param array $tokens Array of objects of type aCssToken |
|
1352 | - * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
1353 | - */ |
|
1354 | - public function apply(array &$tokens) |
|
1355 | - { |
|
1356 | - $r = 0; |
|
1357 | - for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
1358 | - { |
|
1359 | - if (get_class($tokens[$i]) === "CssCommentToken") |
|
1360 | - { |
|
1361 | - $tokens[$i] = null; |
|
1362 | - $r++; |
|
1363 | - } |
|
1364 | - } |
|
1365 | - return $r; |
|
1366 | - } |
|
1367 | - } |
|
1347 | + { |
|
1348 | + /** |
|
1349 | + * Implements {@link aCssMinifierFilter::filter()}. |
|
1350 | + * |
|
1351 | + * @param array $tokens Array of objects of type aCssToken |
|
1352 | + * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
1353 | + */ |
|
1354 | + public function apply(array &$tokens) |
|
1355 | + { |
|
1356 | + $r = 0; |
|
1357 | + for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
1358 | + { |
|
1359 | + if (get_class($tokens[$i]) === "CssCommentToken") |
|
1360 | + { |
|
1361 | + $tokens[$i] = null; |
|
1362 | + $r++; |
|
1363 | + } |
|
1364 | + } |
|
1365 | + return $r; |
|
1366 | + } |
|
1367 | + } |
|
1368 | 1368 | |
1369 | 1369 | /** |
1370 | 1370 | * CSS Parser. |
@@ -1377,420 +1377,420 @@ discard block |
||
1377 | 1377 | * @version 3.0.1 |
1378 | 1378 | */ |
1379 | 1379 | class CssParser |
1380 | - { |
|
1381 | - /** |
|
1382 | - * Parse buffer. |
|
1383 | - * |
|
1384 | - * @var string |
|
1385 | - */ |
|
1386 | - private $buffer = ""; |
|
1387 | - /** |
|
1388 | - * {@link aCssParserPlugin Plugins}. |
|
1389 | - * |
|
1390 | - * @var array |
|
1391 | - */ |
|
1392 | - private $plugins = array(); |
|
1393 | - /** |
|
1394 | - * Source to parse. |
|
1395 | - * |
|
1396 | - * @var string |
|
1397 | - */ |
|
1398 | - private $source = ""; |
|
1399 | - /** |
|
1400 | - * Current state. |
|
1401 | - * |
|
1402 | - * @var integer |
|
1403 | - */ |
|
1404 | - private $state = "T_DOCUMENT"; |
|
1405 | - /** |
|
1406 | - * Exclusive state. |
|
1407 | - * |
|
1408 | - * @var string |
|
1409 | - */ |
|
1410 | - private $stateExclusive = false; |
|
1411 | - /** |
|
1412 | - * Media types state. |
|
1413 | - * |
|
1414 | - * @var mixed |
|
1415 | - */ |
|
1416 | - private $stateMediaTypes = false; |
|
1417 | - /** |
|
1418 | - * State stack. |
|
1419 | - * |
|
1420 | - * @var array |
|
1421 | - */ |
|
1422 | - private $states = array("T_DOCUMENT"); |
|
1423 | - /** |
|
1424 | - * Parsed tokens. |
|
1425 | - * |
|
1426 | - * @var array |
|
1427 | - */ |
|
1428 | - private $tokens = array(); |
|
1429 | - /** |
|
1430 | - * Constructer. |
|
1431 | - * |
|
1432 | - * Create instances of the used {@link aCssParserPlugin plugins}. |
|
1433 | - * |
|
1434 | - * @param string $source CSS source [optional] |
|
1435 | - * @param array $plugins Plugin configuration [optional] |
|
1436 | - * @return void |
|
1437 | - */ |
|
1438 | - public function __construct($source = null, array $plugins = null) |
|
1439 | - { |
|
1440 | - $plugins = array_merge(array |
|
1441 | - ( |
|
1442 | - "Comment" => true, |
|
1443 | - "String" => true, |
|
1444 | - "Url" => true, |
|
1445 | - "Expression" => true, |
|
1446 | - "Ruleset" => true, |
|
1447 | - "AtCharset" => true, |
|
1448 | - "AtFontFace" => true, |
|
1449 | - "AtImport" => true, |
|
1450 | - "AtKeyframes" => true, |
|
1451 | - "AtMedia" => true, |
|
1452 | - "AtPage" => true, |
|
1453 | - "AtVariables" => true |
|
1454 | - ), is_array($plugins) ? $plugins : array()); |
|
1455 | - // Create plugin instances |
|
1456 | - foreach ($plugins as $name => $config) |
|
1457 | - { |
|
1458 | - if ($config !== false) |
|
1459 | - { |
|
1460 | - $class = "Css" . $name . "ParserPlugin"; |
|
1461 | - $config = is_array($config) ? $config : array(); |
|
1462 | - if (class_exists($class)) |
|
1463 | - { |
|
1464 | - $this->plugins[] = new $class($this, $config); |
|
1465 | - } |
|
1466 | - else |
|
1467 | - { |
|
1468 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The plugin <code>" . $name . "</code> with the class name <code>" . $class . "</code> was not found")); |
|
1469 | - } |
|
1470 | - } |
|
1471 | - } |
|
1472 | - if (!is_null($source)) |
|
1473 | - { |
|
1474 | - $this->parse($source); |
|
1475 | - } |
|
1476 | - } |
|
1477 | - /** |
|
1478 | - * Append a token to the array of tokens. |
|
1479 | - * |
|
1480 | - * @param aCssToken $token Token to append |
|
1481 | - * @return void |
|
1482 | - */ |
|
1483 | - public function appendToken(aCssToken $token) |
|
1484 | - { |
|
1485 | - $this->tokens[] = $token; |
|
1486 | - } |
|
1487 | - /** |
|
1488 | - * Clears the current buffer. |
|
1489 | - * |
|
1490 | - * @return void |
|
1491 | - */ |
|
1492 | - public function clearBuffer() |
|
1493 | - { |
|
1494 | - $this->buffer = ""; |
|
1495 | - } |
|
1496 | - /** |
|
1497 | - * Returns and clear the current buffer. |
|
1498 | - * |
|
1499 | - * @param string $trim Chars to use to trim the returned buffer |
|
1500 | - * @param boolean $tolower if TRUE the returned buffer will get converted to lower case |
|
1501 | - * @return string |
|
1502 | - */ |
|
1503 | - public function getAndClearBuffer($trim = "", $tolower = false) |
|
1504 | - { |
|
1505 | - $r = $this->getBuffer($trim, $tolower); |
|
1506 | - $this->buffer = ""; |
|
1507 | - return $r; |
|
1508 | - } |
|
1509 | - /** |
|
1510 | - * Returns the current buffer. |
|
1511 | - * |
|
1512 | - * @param string $trim Chars to use to trim the returned buffer |
|
1513 | - * @param boolean $tolower if TRUE the returned buffer will get converted to lower case |
|
1514 | - * @return string |
|
1515 | - */ |
|
1516 | - public function getBuffer($trim = "", $tolower = false) |
|
1517 | - { |
|
1518 | - $r = $this->buffer; |
|
1519 | - if ($trim) |
|
1520 | - { |
|
1521 | - $r = trim($r, " \t\n\r\0\x0B" . $trim); |
|
1522 | - } |
|
1523 | - if ($tolower) |
|
1524 | - { |
|
1525 | - $r = strtolower($r); |
|
1526 | - } |
|
1527 | - return $r; |
|
1528 | - } |
|
1529 | - /** |
|
1530 | - * Returns the current media types state. |
|
1531 | - * |
|
1532 | - * @return array |
|
1533 | - */ |
|
1534 | - public function getMediaTypes() |
|
1535 | - { |
|
1536 | - return $this->stateMediaTypes; |
|
1537 | - } |
|
1538 | - /** |
|
1539 | - * Returns the CSS source. |
|
1540 | - * |
|
1541 | - * @return string |
|
1542 | - */ |
|
1543 | - public function getSource() |
|
1544 | - { |
|
1545 | - return $this->source; |
|
1546 | - } |
|
1547 | - /** |
|
1548 | - * Returns the current state. |
|
1549 | - * |
|
1550 | - * @return integer The current state |
|
1551 | - */ |
|
1552 | - public function getState() |
|
1553 | - { |
|
1554 | - return $this->state; |
|
1555 | - } |
|
1556 | - /** |
|
1557 | - * Returns a plugin by class name. |
|
1558 | - * |
|
1559 | - * @param string $name Class name of the plugin |
|
1560 | - * @return aCssParserPlugin |
|
1561 | - */ |
|
1562 | - public function getPlugin($class) |
|
1563 | - { |
|
1564 | - static $index = null; |
|
1565 | - if (is_null($index)) |
|
1566 | - { |
|
1567 | - $index = array(); |
|
1568 | - for ($i = 0, $l = count($this->plugins); $i < $l; $i++) |
|
1569 | - { |
|
1570 | - $index[get_class($this->plugins[$i])] = $i; |
|
1571 | - } |
|
1572 | - } |
|
1573 | - return isset($index[$class]) ? $this->plugins[$index[$class]] : false; |
|
1574 | - } |
|
1575 | - /** |
|
1576 | - * Returns the parsed tokens. |
|
1577 | - * |
|
1578 | - * @return array |
|
1579 | - */ |
|
1580 | - public function getTokens() |
|
1581 | - { |
|
1582 | - return $this->tokens; |
|
1583 | - } |
|
1584 | - /** |
|
1585 | - * Returns if the current state equals the passed state. |
|
1586 | - * |
|
1587 | - * @param integer $state State to compare with the current state |
|
1588 | - * @return boolean TRUE is the state equals to the passed state; FALSE if not |
|
1589 | - */ |
|
1590 | - public function isState($state) |
|
1591 | - { |
|
1592 | - return ($this->state == $state); |
|
1593 | - } |
|
1594 | - /** |
|
1595 | - * Parse the CSS source and return a array with parsed tokens. |
|
1596 | - * |
|
1597 | - * @param string $source CSS source |
|
1598 | - * @return array Array with tokens |
|
1599 | - */ |
|
1600 | - public function parse($source) |
|
1601 | - { |
|
1602 | - // Reset |
|
1603 | - $this->source = ""; |
|
1604 | - $this->tokens = array(); |
|
1605 | - // Create a global and plugin lookup table for trigger chars; set array of plugins as local variable and create |
|
1606 | - // several helper variables for plugin handling |
|
1607 | - $globalTriggerChars = ""; |
|
1608 | - $plugins = $this->plugins; |
|
1609 | - $pluginCount = count($plugins); |
|
1610 | - $pluginIndex = array(); |
|
1611 | - $pluginTriggerStates = array(); |
|
1612 | - $pluginTriggerChars = array(); |
|
1613 | - for ($i = 0, $l = count($plugins); $i < $l; $i++) |
|
1614 | - { |
|
1615 | - $tPluginClassName = get_class($plugins[$i]); |
|
1616 | - $pluginTriggerChars[$i] = implode("", $plugins[$i]->getTriggerChars()); |
|
1617 | - $tPluginTriggerStates = $plugins[$i]->getTriggerStates(); |
|
1618 | - $pluginTriggerStates[$i] = $tPluginTriggerStates === false ? false : "|" . implode("|", $tPluginTriggerStates) . "|"; |
|
1619 | - $pluginIndex[$tPluginClassName] = $i; |
|
1620 | - for ($ii = 0, $ll = strlen($pluginTriggerChars[$i]); $ii < $ll; $ii++) |
|
1621 | - { |
|
1622 | - $c = substr($pluginTriggerChars[$i], $ii, 1); |
|
1623 | - if (strpos($globalTriggerChars, $c) === false) |
|
1624 | - { |
|
1625 | - $globalTriggerChars .= $c; |
|
1626 | - } |
|
1627 | - } |
|
1628 | - } |
|
1629 | - // Normalise line endings |
|
1630 | - $source = str_replace("\r\n", "\n", $source); // Windows to Unix line endings |
|
1631 | - $source = str_replace("\r", "\n", $source); // Mac to Unix line endings |
|
1632 | - $this->source = $source; |
|
1633 | - // Variables |
|
1634 | - $buffer = &$this->buffer; |
|
1635 | - $exclusive = &$this->stateExclusive; |
|
1636 | - $state = &$this->state; |
|
1637 | - $c = $p = null; |
|
1638 | - // -- |
|
1639 | - for ($i = 0, $l = strlen($source); $i < $l; $i++) |
|
1640 | - { |
|
1641 | - // Set the current Char |
|
1642 | - $c = $source[$i]; // Is faster than: $c = substr($source, $i, 1); |
|
1643 | - // Normalize and filter double whitespace characters |
|
1644 | - if ($exclusive === false) |
|
1645 | - { |
|
1646 | - if ($c === "\n" || $c === "\t") |
|
1647 | - { |
|
1648 | - $c = " "; |
|
1649 | - } |
|
1650 | - if ($c === " " && $p === " ") |
|
1651 | - { |
|
1652 | - continue; |
|
1653 | - } |
|
1654 | - } |
|
1655 | - $buffer .= $c; |
|
1656 | - // Extended processing only if the current char is a global trigger char |
|
1657 | - if (strpos($globalTriggerChars, $c) !== false) |
|
1658 | - { |
|
1659 | - // Exclusive state is set; process with the exclusive plugin |
|
1660 | - if ($exclusive) |
|
1661 | - { |
|
1662 | - $tPluginIndex = $pluginIndex[$exclusive]; |
|
1663 | - if (strpos($pluginTriggerChars[$tPluginIndex], $c) !== false && ($pluginTriggerStates[$tPluginIndex] === false || strpos($pluginTriggerStates[$tPluginIndex], $state) !== false)) |
|
1664 | - { |
|
1665 | - $r = $plugins[$tPluginIndex]->parse($i, $c, $p, $state); |
|
1666 | - // Return value is TRUE => continue with next char |
|
1667 | - if ($r === true) |
|
1668 | - { |
|
1669 | - continue; |
|
1670 | - } |
|
1671 | - // Return value is numeric => set new index and continue with next char |
|
1672 | - elseif ($r !== false && $r != $i) |
|
1673 | - { |
|
1674 | - $i = $r; |
|
1675 | - continue; |
|
1676 | - } |
|
1677 | - } |
|
1678 | - } |
|
1679 | - // Else iterate through the plugins |
|
1680 | - else |
|
1681 | - { |
|
1682 | - $triggerState = "|" . $state . "|"; |
|
1683 | - for ($ii = 0, $ll = $pluginCount; $ii < $ll; $ii++) |
|
1684 | - { |
|
1685 | - // Only process if the current char is one of the plugin trigger chars |
|
1686 | - if (strpos($pluginTriggerChars[$ii], $c) !== false && ($pluginTriggerStates[$ii] === false || strpos($pluginTriggerStates[$ii], $triggerState) !== false)) |
|
1687 | - { |
|
1688 | - // Process with the plugin |
|
1689 | - $r = $plugins[$ii]->parse($i, $c, $p, $state); |
|
1690 | - // Return value is TRUE => break the plugin loop and and continue with next char |
|
1691 | - if ($r === true) |
|
1692 | - { |
|
1693 | - break; |
|
1694 | - } |
|
1695 | - // Return value is numeric => set new index, break the plugin loop and and continue with next char |
|
1696 | - elseif ($r !== false && $r != $i) |
|
1697 | - { |
|
1698 | - $i = $r; |
|
1699 | - break; |
|
1700 | - } |
|
1701 | - } |
|
1702 | - } |
|
1703 | - } |
|
1704 | - } |
|
1705 | - $p = $c; // Set the parent char |
|
1706 | - } |
|
1707 | - return $this->tokens; |
|
1708 | - } |
|
1709 | - /** |
|
1710 | - * Remove the last state of the state stack and return the removed stack value. |
|
1711 | - * |
|
1712 | - * @return integer Removed state value |
|
1713 | - */ |
|
1714 | - public function popState() |
|
1715 | - { |
|
1716 | - $r = array_pop($this->states); |
|
1717 | - $this->state = $this->states[count($this->states) - 1]; |
|
1718 | - return $r; |
|
1719 | - } |
|
1720 | - /** |
|
1721 | - * Adds a new state onto the state stack. |
|
1722 | - * |
|
1723 | - * @param integer $state State to add onto the state stack. |
|
1724 | - * @return integer The index of the added state in the state stacks |
|
1725 | - */ |
|
1726 | - public function pushState($state) |
|
1727 | - { |
|
1728 | - $r = array_push($this->states, $state); |
|
1729 | - $this->state = $this->states[count($this->states) - 1]; |
|
1730 | - return $r; |
|
1731 | - } |
|
1732 | - /** |
|
1733 | - * Sets/restores the buffer. |
|
1734 | - * |
|
1735 | - * @param string $buffer Buffer to set |
|
1736 | - * @return void |
|
1737 | - */ |
|
1738 | - public function setBuffer($buffer) |
|
1739 | - { |
|
1740 | - $this->buffer = $buffer; |
|
1741 | - } |
|
1742 | - /** |
|
1743 | - * Set the exclusive state. |
|
1744 | - * |
|
1745 | - * @param string $exclusive Exclusive state |
|
1746 | - * @return void |
|
1747 | - */ |
|
1748 | - public function setExclusive($exclusive) |
|
1749 | - { |
|
1750 | - $this->stateExclusive = $exclusive; |
|
1751 | - } |
|
1752 | - /** |
|
1753 | - * Set the media types state. |
|
1754 | - * |
|
1755 | - * @param array $mediaTypes Media types state |
|
1756 | - * @return void |
|
1757 | - */ |
|
1758 | - public function setMediaTypes(array $mediaTypes) |
|
1759 | - { |
|
1760 | - $this->stateMediaTypes = $mediaTypes; |
|
1761 | - } |
|
1762 | - /** |
|
1763 | - * Sets the current state in the state stack; equals to {@link CssParser::popState()} + {@link CssParser::pushState()}. |
|
1764 | - * |
|
1765 | - * @param integer $state State to set |
|
1766 | - * @return integer |
|
1767 | - */ |
|
1768 | - public function setState($state) |
|
1769 | - { |
|
1770 | - $r = array_pop($this->states); |
|
1771 | - array_push($this->states, $state); |
|
1772 | - $this->state = $this->states[count($this->states) - 1]; |
|
1773 | - return $r; |
|
1774 | - } |
|
1775 | - /** |
|
1776 | - * Removes the exclusive state. |
|
1777 | - * |
|
1778 | - * @return void |
|
1779 | - */ |
|
1780 | - public function unsetExclusive() |
|
1781 | - { |
|
1782 | - $this->stateExclusive = false; |
|
1783 | - } |
|
1784 | - /** |
|
1785 | - * Removes the media types state. |
|
1786 | - * |
|
1787 | - * @return void |
|
1788 | - */ |
|
1789 | - public function unsetMediaTypes() |
|
1790 | - { |
|
1791 | - $this->stateMediaTypes = false; |
|
1792 | - } |
|
1793 | - } |
|
1380 | + { |
|
1381 | + /** |
|
1382 | + * Parse buffer. |
|
1383 | + * |
|
1384 | + * @var string |
|
1385 | + */ |
|
1386 | + private $buffer = ""; |
|
1387 | + /** |
|
1388 | + * {@link aCssParserPlugin Plugins}. |
|
1389 | + * |
|
1390 | + * @var array |
|
1391 | + */ |
|
1392 | + private $plugins = array(); |
|
1393 | + /** |
|
1394 | + * Source to parse. |
|
1395 | + * |
|
1396 | + * @var string |
|
1397 | + */ |
|
1398 | + private $source = ""; |
|
1399 | + /** |
|
1400 | + * Current state. |
|
1401 | + * |
|
1402 | + * @var integer |
|
1403 | + */ |
|
1404 | + private $state = "T_DOCUMENT"; |
|
1405 | + /** |
|
1406 | + * Exclusive state. |
|
1407 | + * |
|
1408 | + * @var string |
|
1409 | + */ |
|
1410 | + private $stateExclusive = false; |
|
1411 | + /** |
|
1412 | + * Media types state. |
|
1413 | + * |
|
1414 | + * @var mixed |
|
1415 | + */ |
|
1416 | + private $stateMediaTypes = false; |
|
1417 | + /** |
|
1418 | + * State stack. |
|
1419 | + * |
|
1420 | + * @var array |
|
1421 | + */ |
|
1422 | + private $states = array("T_DOCUMENT"); |
|
1423 | + /** |
|
1424 | + * Parsed tokens. |
|
1425 | + * |
|
1426 | + * @var array |
|
1427 | + */ |
|
1428 | + private $tokens = array(); |
|
1429 | + /** |
|
1430 | + * Constructer. |
|
1431 | + * |
|
1432 | + * Create instances of the used {@link aCssParserPlugin plugins}. |
|
1433 | + * |
|
1434 | + * @param string $source CSS source [optional] |
|
1435 | + * @param array $plugins Plugin configuration [optional] |
|
1436 | + * @return void |
|
1437 | + */ |
|
1438 | + public function __construct($source = null, array $plugins = null) |
|
1439 | + { |
|
1440 | + $plugins = array_merge(array |
|
1441 | + ( |
|
1442 | + "Comment" => true, |
|
1443 | + "String" => true, |
|
1444 | + "Url" => true, |
|
1445 | + "Expression" => true, |
|
1446 | + "Ruleset" => true, |
|
1447 | + "AtCharset" => true, |
|
1448 | + "AtFontFace" => true, |
|
1449 | + "AtImport" => true, |
|
1450 | + "AtKeyframes" => true, |
|
1451 | + "AtMedia" => true, |
|
1452 | + "AtPage" => true, |
|
1453 | + "AtVariables" => true |
|
1454 | + ), is_array($plugins) ? $plugins : array()); |
|
1455 | + // Create plugin instances |
|
1456 | + foreach ($plugins as $name => $config) |
|
1457 | + { |
|
1458 | + if ($config !== false) |
|
1459 | + { |
|
1460 | + $class = "Css" . $name . "ParserPlugin"; |
|
1461 | + $config = is_array($config) ? $config : array(); |
|
1462 | + if (class_exists($class)) |
|
1463 | + { |
|
1464 | + $this->plugins[] = new $class($this, $config); |
|
1465 | + } |
|
1466 | + else |
|
1467 | + { |
|
1468 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The plugin <code>" . $name . "</code> with the class name <code>" . $class . "</code> was not found")); |
|
1469 | + } |
|
1470 | + } |
|
1471 | + } |
|
1472 | + if (!is_null($source)) |
|
1473 | + { |
|
1474 | + $this->parse($source); |
|
1475 | + } |
|
1476 | + } |
|
1477 | + /** |
|
1478 | + * Append a token to the array of tokens. |
|
1479 | + * |
|
1480 | + * @param aCssToken $token Token to append |
|
1481 | + * @return void |
|
1482 | + */ |
|
1483 | + public function appendToken(aCssToken $token) |
|
1484 | + { |
|
1485 | + $this->tokens[] = $token; |
|
1486 | + } |
|
1487 | + /** |
|
1488 | + * Clears the current buffer. |
|
1489 | + * |
|
1490 | + * @return void |
|
1491 | + */ |
|
1492 | + public function clearBuffer() |
|
1493 | + { |
|
1494 | + $this->buffer = ""; |
|
1495 | + } |
|
1496 | + /** |
|
1497 | + * Returns and clear the current buffer. |
|
1498 | + * |
|
1499 | + * @param string $trim Chars to use to trim the returned buffer |
|
1500 | + * @param boolean $tolower if TRUE the returned buffer will get converted to lower case |
|
1501 | + * @return string |
|
1502 | + */ |
|
1503 | + public function getAndClearBuffer($trim = "", $tolower = false) |
|
1504 | + { |
|
1505 | + $r = $this->getBuffer($trim, $tolower); |
|
1506 | + $this->buffer = ""; |
|
1507 | + return $r; |
|
1508 | + } |
|
1509 | + /** |
|
1510 | + * Returns the current buffer. |
|
1511 | + * |
|
1512 | + * @param string $trim Chars to use to trim the returned buffer |
|
1513 | + * @param boolean $tolower if TRUE the returned buffer will get converted to lower case |
|
1514 | + * @return string |
|
1515 | + */ |
|
1516 | + public function getBuffer($trim = "", $tolower = false) |
|
1517 | + { |
|
1518 | + $r = $this->buffer; |
|
1519 | + if ($trim) |
|
1520 | + { |
|
1521 | + $r = trim($r, " \t\n\r\0\x0B" . $trim); |
|
1522 | + } |
|
1523 | + if ($tolower) |
|
1524 | + { |
|
1525 | + $r = strtolower($r); |
|
1526 | + } |
|
1527 | + return $r; |
|
1528 | + } |
|
1529 | + /** |
|
1530 | + * Returns the current media types state. |
|
1531 | + * |
|
1532 | + * @return array |
|
1533 | + */ |
|
1534 | + public function getMediaTypes() |
|
1535 | + { |
|
1536 | + return $this->stateMediaTypes; |
|
1537 | + } |
|
1538 | + /** |
|
1539 | + * Returns the CSS source. |
|
1540 | + * |
|
1541 | + * @return string |
|
1542 | + */ |
|
1543 | + public function getSource() |
|
1544 | + { |
|
1545 | + return $this->source; |
|
1546 | + } |
|
1547 | + /** |
|
1548 | + * Returns the current state. |
|
1549 | + * |
|
1550 | + * @return integer The current state |
|
1551 | + */ |
|
1552 | + public function getState() |
|
1553 | + { |
|
1554 | + return $this->state; |
|
1555 | + } |
|
1556 | + /** |
|
1557 | + * Returns a plugin by class name. |
|
1558 | + * |
|
1559 | + * @param string $name Class name of the plugin |
|
1560 | + * @return aCssParserPlugin |
|
1561 | + */ |
|
1562 | + public function getPlugin($class) |
|
1563 | + { |
|
1564 | + static $index = null; |
|
1565 | + if (is_null($index)) |
|
1566 | + { |
|
1567 | + $index = array(); |
|
1568 | + for ($i = 0, $l = count($this->plugins); $i < $l; $i++) |
|
1569 | + { |
|
1570 | + $index[get_class($this->plugins[$i])] = $i; |
|
1571 | + } |
|
1572 | + } |
|
1573 | + return isset($index[$class]) ? $this->plugins[$index[$class]] : false; |
|
1574 | + } |
|
1575 | + /** |
|
1576 | + * Returns the parsed tokens. |
|
1577 | + * |
|
1578 | + * @return array |
|
1579 | + */ |
|
1580 | + public function getTokens() |
|
1581 | + { |
|
1582 | + return $this->tokens; |
|
1583 | + } |
|
1584 | + /** |
|
1585 | + * Returns if the current state equals the passed state. |
|
1586 | + * |
|
1587 | + * @param integer $state State to compare with the current state |
|
1588 | + * @return boolean TRUE is the state equals to the passed state; FALSE if not |
|
1589 | + */ |
|
1590 | + public function isState($state) |
|
1591 | + { |
|
1592 | + return ($this->state == $state); |
|
1593 | + } |
|
1594 | + /** |
|
1595 | + * Parse the CSS source and return a array with parsed tokens. |
|
1596 | + * |
|
1597 | + * @param string $source CSS source |
|
1598 | + * @return array Array with tokens |
|
1599 | + */ |
|
1600 | + public function parse($source) |
|
1601 | + { |
|
1602 | + // Reset |
|
1603 | + $this->source = ""; |
|
1604 | + $this->tokens = array(); |
|
1605 | + // Create a global and plugin lookup table for trigger chars; set array of plugins as local variable and create |
|
1606 | + // several helper variables for plugin handling |
|
1607 | + $globalTriggerChars = ""; |
|
1608 | + $plugins = $this->plugins; |
|
1609 | + $pluginCount = count($plugins); |
|
1610 | + $pluginIndex = array(); |
|
1611 | + $pluginTriggerStates = array(); |
|
1612 | + $pluginTriggerChars = array(); |
|
1613 | + for ($i = 0, $l = count($plugins); $i < $l; $i++) |
|
1614 | + { |
|
1615 | + $tPluginClassName = get_class($plugins[$i]); |
|
1616 | + $pluginTriggerChars[$i] = implode("", $plugins[$i]->getTriggerChars()); |
|
1617 | + $tPluginTriggerStates = $plugins[$i]->getTriggerStates(); |
|
1618 | + $pluginTriggerStates[$i] = $tPluginTriggerStates === false ? false : "|" . implode("|", $tPluginTriggerStates) . "|"; |
|
1619 | + $pluginIndex[$tPluginClassName] = $i; |
|
1620 | + for ($ii = 0, $ll = strlen($pluginTriggerChars[$i]); $ii < $ll; $ii++) |
|
1621 | + { |
|
1622 | + $c = substr($pluginTriggerChars[$i], $ii, 1); |
|
1623 | + if (strpos($globalTriggerChars, $c) === false) |
|
1624 | + { |
|
1625 | + $globalTriggerChars .= $c; |
|
1626 | + } |
|
1627 | + } |
|
1628 | + } |
|
1629 | + // Normalise line endings |
|
1630 | + $source = str_replace("\r\n", "\n", $source); // Windows to Unix line endings |
|
1631 | + $source = str_replace("\r", "\n", $source); // Mac to Unix line endings |
|
1632 | + $this->source = $source; |
|
1633 | + // Variables |
|
1634 | + $buffer = &$this->buffer; |
|
1635 | + $exclusive = &$this->stateExclusive; |
|
1636 | + $state = &$this->state; |
|
1637 | + $c = $p = null; |
|
1638 | + // -- |
|
1639 | + for ($i = 0, $l = strlen($source); $i < $l; $i++) |
|
1640 | + { |
|
1641 | + // Set the current Char |
|
1642 | + $c = $source[$i]; // Is faster than: $c = substr($source, $i, 1); |
|
1643 | + // Normalize and filter double whitespace characters |
|
1644 | + if ($exclusive === false) |
|
1645 | + { |
|
1646 | + if ($c === "\n" || $c === "\t") |
|
1647 | + { |
|
1648 | + $c = " "; |
|
1649 | + } |
|
1650 | + if ($c === " " && $p === " ") |
|
1651 | + { |
|
1652 | + continue; |
|
1653 | + } |
|
1654 | + } |
|
1655 | + $buffer .= $c; |
|
1656 | + // Extended processing only if the current char is a global trigger char |
|
1657 | + if (strpos($globalTriggerChars, $c) !== false) |
|
1658 | + { |
|
1659 | + // Exclusive state is set; process with the exclusive plugin |
|
1660 | + if ($exclusive) |
|
1661 | + { |
|
1662 | + $tPluginIndex = $pluginIndex[$exclusive]; |
|
1663 | + if (strpos($pluginTriggerChars[$tPluginIndex], $c) !== false && ($pluginTriggerStates[$tPluginIndex] === false || strpos($pluginTriggerStates[$tPluginIndex], $state) !== false)) |
|
1664 | + { |
|
1665 | + $r = $plugins[$tPluginIndex]->parse($i, $c, $p, $state); |
|
1666 | + // Return value is TRUE => continue with next char |
|
1667 | + if ($r === true) |
|
1668 | + { |
|
1669 | + continue; |
|
1670 | + } |
|
1671 | + // Return value is numeric => set new index and continue with next char |
|
1672 | + elseif ($r !== false && $r != $i) |
|
1673 | + { |
|
1674 | + $i = $r; |
|
1675 | + continue; |
|
1676 | + } |
|
1677 | + } |
|
1678 | + } |
|
1679 | + // Else iterate through the plugins |
|
1680 | + else |
|
1681 | + { |
|
1682 | + $triggerState = "|" . $state . "|"; |
|
1683 | + for ($ii = 0, $ll = $pluginCount; $ii < $ll; $ii++) |
|
1684 | + { |
|
1685 | + // Only process if the current char is one of the plugin trigger chars |
|
1686 | + if (strpos($pluginTriggerChars[$ii], $c) !== false && ($pluginTriggerStates[$ii] === false || strpos($pluginTriggerStates[$ii], $triggerState) !== false)) |
|
1687 | + { |
|
1688 | + // Process with the plugin |
|
1689 | + $r = $plugins[$ii]->parse($i, $c, $p, $state); |
|
1690 | + // Return value is TRUE => break the plugin loop and and continue with next char |
|
1691 | + if ($r === true) |
|
1692 | + { |
|
1693 | + break; |
|
1694 | + } |
|
1695 | + // Return value is numeric => set new index, break the plugin loop and and continue with next char |
|
1696 | + elseif ($r !== false && $r != $i) |
|
1697 | + { |
|
1698 | + $i = $r; |
|
1699 | + break; |
|
1700 | + } |
|
1701 | + } |
|
1702 | + } |
|
1703 | + } |
|
1704 | + } |
|
1705 | + $p = $c; // Set the parent char |
|
1706 | + } |
|
1707 | + return $this->tokens; |
|
1708 | + } |
|
1709 | + /** |
|
1710 | + * Remove the last state of the state stack and return the removed stack value. |
|
1711 | + * |
|
1712 | + * @return integer Removed state value |
|
1713 | + */ |
|
1714 | + public function popState() |
|
1715 | + { |
|
1716 | + $r = array_pop($this->states); |
|
1717 | + $this->state = $this->states[count($this->states) - 1]; |
|
1718 | + return $r; |
|
1719 | + } |
|
1720 | + /** |
|
1721 | + * Adds a new state onto the state stack. |
|
1722 | + * |
|
1723 | + * @param integer $state State to add onto the state stack. |
|
1724 | + * @return integer The index of the added state in the state stacks |
|
1725 | + */ |
|
1726 | + public function pushState($state) |
|
1727 | + { |
|
1728 | + $r = array_push($this->states, $state); |
|
1729 | + $this->state = $this->states[count($this->states) - 1]; |
|
1730 | + return $r; |
|
1731 | + } |
|
1732 | + /** |
|
1733 | + * Sets/restores the buffer. |
|
1734 | + * |
|
1735 | + * @param string $buffer Buffer to set |
|
1736 | + * @return void |
|
1737 | + */ |
|
1738 | + public function setBuffer($buffer) |
|
1739 | + { |
|
1740 | + $this->buffer = $buffer; |
|
1741 | + } |
|
1742 | + /** |
|
1743 | + * Set the exclusive state. |
|
1744 | + * |
|
1745 | + * @param string $exclusive Exclusive state |
|
1746 | + * @return void |
|
1747 | + */ |
|
1748 | + public function setExclusive($exclusive) |
|
1749 | + { |
|
1750 | + $this->stateExclusive = $exclusive; |
|
1751 | + } |
|
1752 | + /** |
|
1753 | + * Set the media types state. |
|
1754 | + * |
|
1755 | + * @param array $mediaTypes Media types state |
|
1756 | + * @return void |
|
1757 | + */ |
|
1758 | + public function setMediaTypes(array $mediaTypes) |
|
1759 | + { |
|
1760 | + $this->stateMediaTypes = $mediaTypes; |
|
1761 | + } |
|
1762 | + /** |
|
1763 | + * Sets the current state in the state stack; equals to {@link CssParser::popState()} + {@link CssParser::pushState()}. |
|
1764 | + * |
|
1765 | + * @param integer $state State to set |
|
1766 | + * @return integer |
|
1767 | + */ |
|
1768 | + public function setState($state) |
|
1769 | + { |
|
1770 | + $r = array_pop($this->states); |
|
1771 | + array_push($this->states, $state); |
|
1772 | + $this->state = $this->states[count($this->states) - 1]; |
|
1773 | + return $r; |
|
1774 | + } |
|
1775 | + /** |
|
1776 | + * Removes the exclusive state. |
|
1777 | + * |
|
1778 | + * @return void |
|
1779 | + */ |
|
1780 | + public function unsetExclusive() |
|
1781 | + { |
|
1782 | + $this->stateExclusive = false; |
|
1783 | + } |
|
1784 | + /** |
|
1785 | + * Removes the media types state. |
|
1786 | + * |
|
1787 | + * @return void |
|
1788 | + */ |
|
1789 | + public function unsetMediaTypes() |
|
1790 | + { |
|
1791 | + $this->stateMediaTypes = false; |
|
1792 | + } |
|
1793 | + } |
|
1794 | 1794 | |
1795 | 1795 | /** |
1796 | 1796 | * {@link aCssFromatter Formatter} returning the CSS source in {@link http://goo.gl/j4XdU OTBS indent style} (The One True Brace Style). |
@@ -1803,97 +1803,97 @@ discard block |
||
1803 | 1803 | * @version 3.0.1 |
1804 | 1804 | */ |
1805 | 1805 | class CssOtbsFormatter extends aCssFormatter |
1806 | - { |
|
1807 | - /** |
|
1808 | - * Implements {@link aCssFormatter::__toString()}. |
|
1809 | - * |
|
1810 | - * @return string |
|
1811 | - */ |
|
1812 | - public function __toString() |
|
1813 | - { |
|
1814 | - $r = array(); |
|
1815 | - $level = 0; |
|
1816 | - for ($i = 0, $l = count($this->tokens); $i < $l; $i++) |
|
1817 | - { |
|
1818 | - $token = $this->tokens[$i]; |
|
1819 | - $class = get_class($token); |
|
1820 | - $indent = str_repeat($this->indent, $level); |
|
1821 | - if ($class === "CssCommentToken") |
|
1822 | - { |
|
1823 | - $lines = array_map("trim", explode("\n", $token->Comment)); |
|
1824 | - for ($ii = 0, $ll = count($lines); $ii < $ll; $ii++) |
|
1825 | - { |
|
1826 | - $r[] = $indent . (substr($lines[$ii], 0, 1) == "*" ? " " : "") . $lines[$ii]; |
|
1827 | - } |
|
1828 | - } |
|
1829 | - elseif ($class === "CssAtCharsetToken") |
|
1830 | - { |
|
1831 | - $r[] = $indent . "@charset " . $token->Charset . ";"; |
|
1832 | - } |
|
1833 | - elseif ($class === "CssAtFontFaceStartToken") |
|
1834 | - { |
|
1835 | - $r[] = $indent . "@font-face {"; |
|
1836 | - $level++; |
|
1837 | - } |
|
1838 | - elseif ($class === "CssAtImportToken") |
|
1839 | - { |
|
1840 | - $r[] = $indent . "@import " . $token->Import . " " . implode(", ", $token->MediaTypes) . ";"; |
|
1841 | - } |
|
1842 | - elseif ($class === "CssAtKeyframesStartToken") |
|
1843 | - { |
|
1844 | - $r[] = $indent . "@keyframes \"" . $token->Name . "\" {"; |
|
1845 | - $level++; |
|
1846 | - } |
|
1847 | - elseif ($class === "CssAtMediaStartToken") |
|
1848 | - { |
|
1849 | - $r[] = $indent . "@media " . implode(", ", $token->MediaTypes) . " {"; |
|
1850 | - $level++; |
|
1851 | - } |
|
1852 | - elseif ($class === "CssAtPageStartToken") |
|
1853 | - { |
|
1854 | - $r[] = $indent . "@page {"; |
|
1855 | - $level++; |
|
1856 | - } |
|
1857 | - elseif ($class === "CssAtVariablesStartToken") |
|
1858 | - { |
|
1859 | - $r[] = $indent . "@variables " . implode(", ", $token->MediaTypes) . " {"; |
|
1860 | - $level++; |
|
1861 | - } |
|
1862 | - elseif ($class === "CssRulesetStartToken" || $class === "CssAtKeyframesRulesetStartToken") |
|
1863 | - { |
|
1864 | - $r[] = $indent . implode(", ", $token->Selectors) . " {"; |
|
1865 | - $level++; |
|
1866 | - } |
|
1867 | - elseif ($class == "CssAtFontFaceDeclarationToken" |
|
1868 | - || $class === "CssAtKeyframesRulesetDeclarationToken" |
|
1869 | - || $class === "CssAtPageDeclarationToken" |
|
1870 | - || $class == "CssAtVariablesDeclarationToken" |
|
1871 | - || $class === "CssRulesetDeclarationToken" |
|
1872 | - ) |
|
1873 | - { |
|
1874 | - $declaration = $indent . $token->Property . ": "; |
|
1875 | - if ($this->padding) |
|
1876 | - { |
|
1877 | - $declaration = str_pad($declaration, $this->padding, " ", STR_PAD_RIGHT); |
|
1878 | - } |
|
1879 | - $r[] = $declaration . $token->Value . ($token->IsImportant ? " !important" : "") . ";"; |
|
1880 | - } |
|
1881 | - elseif ($class === "CssAtFontFaceEndToken" |
|
1882 | - || $class === "CssAtMediaEndToken" |
|
1883 | - || $class === "CssAtKeyframesEndToken" |
|
1884 | - || $class === "CssAtKeyframesRulesetEndToken" |
|
1885 | - || $class === "CssAtPageEndToken" |
|
1886 | - || $class === "CssAtVariablesEndToken" |
|
1887 | - || $class === "CssRulesetEndToken" |
|
1888 | - ) |
|
1889 | - { |
|
1890 | - $level--; |
|
1891 | - $r[] = str_repeat($indent, $level) . "}"; |
|
1892 | - } |
|
1893 | - } |
|
1894 | - return implode("\n", $r); |
|
1895 | - } |
|
1896 | - } |
|
1806 | + { |
|
1807 | + /** |
|
1808 | + * Implements {@link aCssFormatter::__toString()}. |
|
1809 | + * |
|
1810 | + * @return string |
|
1811 | + */ |
|
1812 | + public function __toString() |
|
1813 | + { |
|
1814 | + $r = array(); |
|
1815 | + $level = 0; |
|
1816 | + for ($i = 0, $l = count($this->tokens); $i < $l; $i++) |
|
1817 | + { |
|
1818 | + $token = $this->tokens[$i]; |
|
1819 | + $class = get_class($token); |
|
1820 | + $indent = str_repeat($this->indent, $level); |
|
1821 | + if ($class === "CssCommentToken") |
|
1822 | + { |
|
1823 | + $lines = array_map("trim", explode("\n", $token->Comment)); |
|
1824 | + for ($ii = 0, $ll = count($lines); $ii < $ll; $ii++) |
|
1825 | + { |
|
1826 | + $r[] = $indent . (substr($lines[$ii], 0, 1) == "*" ? " " : "") . $lines[$ii]; |
|
1827 | + } |
|
1828 | + } |
|
1829 | + elseif ($class === "CssAtCharsetToken") |
|
1830 | + { |
|
1831 | + $r[] = $indent . "@charset " . $token->Charset . ";"; |
|
1832 | + } |
|
1833 | + elseif ($class === "CssAtFontFaceStartToken") |
|
1834 | + { |
|
1835 | + $r[] = $indent . "@font-face {"; |
|
1836 | + $level++; |
|
1837 | + } |
|
1838 | + elseif ($class === "CssAtImportToken") |
|
1839 | + { |
|
1840 | + $r[] = $indent . "@import " . $token->Import . " " . implode(", ", $token->MediaTypes) . ";"; |
|
1841 | + } |
|
1842 | + elseif ($class === "CssAtKeyframesStartToken") |
|
1843 | + { |
|
1844 | + $r[] = $indent . "@keyframes \"" . $token->Name . "\" {"; |
|
1845 | + $level++; |
|
1846 | + } |
|
1847 | + elseif ($class === "CssAtMediaStartToken") |
|
1848 | + { |
|
1849 | + $r[] = $indent . "@media " . implode(", ", $token->MediaTypes) . " {"; |
|
1850 | + $level++; |
|
1851 | + } |
|
1852 | + elseif ($class === "CssAtPageStartToken") |
|
1853 | + { |
|
1854 | + $r[] = $indent . "@page {"; |
|
1855 | + $level++; |
|
1856 | + } |
|
1857 | + elseif ($class === "CssAtVariablesStartToken") |
|
1858 | + { |
|
1859 | + $r[] = $indent . "@variables " . implode(", ", $token->MediaTypes) . " {"; |
|
1860 | + $level++; |
|
1861 | + } |
|
1862 | + elseif ($class === "CssRulesetStartToken" || $class === "CssAtKeyframesRulesetStartToken") |
|
1863 | + { |
|
1864 | + $r[] = $indent . implode(", ", $token->Selectors) . " {"; |
|
1865 | + $level++; |
|
1866 | + } |
|
1867 | + elseif ($class == "CssAtFontFaceDeclarationToken" |
|
1868 | + || $class === "CssAtKeyframesRulesetDeclarationToken" |
|
1869 | + || $class === "CssAtPageDeclarationToken" |
|
1870 | + || $class == "CssAtVariablesDeclarationToken" |
|
1871 | + || $class === "CssRulesetDeclarationToken" |
|
1872 | + ) |
|
1873 | + { |
|
1874 | + $declaration = $indent . $token->Property . ": "; |
|
1875 | + if ($this->padding) |
|
1876 | + { |
|
1877 | + $declaration = str_pad($declaration, $this->padding, " ", STR_PAD_RIGHT); |
|
1878 | + } |
|
1879 | + $r[] = $declaration . $token->Value . ($token->IsImportant ? " !important" : "") . ";"; |
|
1880 | + } |
|
1881 | + elseif ($class === "CssAtFontFaceEndToken" |
|
1882 | + || $class === "CssAtMediaEndToken" |
|
1883 | + || $class === "CssAtKeyframesEndToken" |
|
1884 | + || $class === "CssAtKeyframesRulesetEndToken" |
|
1885 | + || $class === "CssAtPageEndToken" |
|
1886 | + || $class === "CssAtVariablesEndToken" |
|
1887 | + || $class === "CssRulesetEndToken" |
|
1888 | + ) |
|
1889 | + { |
|
1890 | + $level--; |
|
1891 | + $r[] = str_repeat($indent, $level) . "}"; |
|
1892 | + } |
|
1893 | + } |
|
1894 | + return implode("\n", $r); |
|
1895 | + } |
|
1896 | + } |
|
1897 | 1897 | |
1898 | 1898 | /** |
1899 | 1899 | * This {@link aCssToken CSS token} is a utility token that extends {@link aNullToken} and returns only a empty string. |
@@ -1906,17 +1906,17 @@ discard block |
||
1906 | 1906 | * @version 3.0.1 |
1907 | 1907 | */ |
1908 | 1908 | class CssNullToken extends aCssToken |
1909 | - { |
|
1910 | - /** |
|
1911 | - * Implements {@link aCssToken::__toString()}. |
|
1912 | - * |
|
1913 | - * @return string |
|
1914 | - */ |
|
1915 | - public function __toString() |
|
1916 | - { |
|
1917 | - return ""; |
|
1918 | - } |
|
1919 | - } |
|
1909 | + { |
|
1910 | + /** |
|
1911 | + * Implements {@link aCssToken::__toString()}. |
|
1912 | + * |
|
1913 | + * @return string |
|
1914 | + */ |
|
1915 | + public function __toString() |
|
1916 | + { |
|
1917 | + return ""; |
|
1918 | + } |
|
1919 | + } |
|
1920 | 1920 | |
1921 | 1921 | /** |
1922 | 1922 | * CSS Minifier. |
@@ -1929,204 +1929,204 @@ discard block |
||
1929 | 1929 | * @version 3.0.1 |
1930 | 1930 | */ |
1931 | 1931 | class CssMinifier |
1932 | - { |
|
1933 | - /** |
|
1934 | - * {@link aCssMinifierFilter Filters}. |
|
1935 | - * |
|
1936 | - * @var array |
|
1937 | - */ |
|
1938 | - private $filters = array(); |
|
1939 | - /** |
|
1940 | - * {@link aCssMinifierPlugin Plugins}. |
|
1941 | - * |
|
1942 | - * @var array |
|
1943 | - */ |
|
1944 | - private $plugins = array(); |
|
1945 | - /** |
|
1946 | - * Minified source. |
|
1947 | - * |
|
1948 | - * @var string |
|
1949 | - */ |
|
1950 | - private $minified = ""; |
|
1951 | - /** |
|
1952 | - * Constructer. |
|
1953 | - * |
|
1954 | - * Creates instances of {@link aCssMinifierFilter filters} and {@link aCssMinifierPlugin plugins}. |
|
1955 | - * |
|
1956 | - * @param string $source CSS source [optional] |
|
1957 | - * @param array $filters Filter configuration [optional] |
|
1958 | - * @param array $plugins Plugin configuration [optional] |
|
1959 | - * @return void |
|
1960 | - */ |
|
1961 | - public function __construct($source = null, array $filters = null, array $plugins = null) |
|
1962 | - { |
|
1963 | - $filters = array_merge(array |
|
1964 | - ( |
|
1965 | - "ImportImports" => false, |
|
1966 | - "RemoveComments" => true, |
|
1967 | - "RemoveEmptyRulesets" => true, |
|
1968 | - "RemoveEmptyAtBlocks" => true, |
|
1969 | - "ConvertLevel3Properties" => false, |
|
1970 | - "ConvertLevel3AtKeyframes" => false, |
|
1971 | - "Variables" => true, |
|
1972 | - "RemoveLastDelarationSemiColon" => true |
|
1973 | - ), is_array($filters) ? $filters : array()); |
|
1974 | - $plugins = array_merge(array |
|
1975 | - ( |
|
1976 | - "Variables" => true, |
|
1977 | - "ConvertFontWeight" => false, |
|
1978 | - "ConvertHslColors" => false, |
|
1979 | - "ConvertRgbColors" => false, |
|
1980 | - "ConvertNamedColors" => false, |
|
1981 | - "CompressColorValues" => false, |
|
1982 | - "CompressUnitValues" => false, |
|
1983 | - "CompressExpressionValues" => false |
|
1984 | - ), is_array($plugins) ? $plugins : array()); |
|
1985 | - // Filters |
|
1986 | - foreach ($filters as $name => $config) |
|
1987 | - { |
|
1988 | - if ($config !== false) |
|
1989 | - { |
|
1990 | - $class = "Css" . $name . "MinifierFilter"; |
|
1991 | - $config = is_array($config) ? $config : array(); |
|
1992 | - if (class_exists($class)) |
|
1993 | - { |
|
1994 | - $this->filters[] = new $class($this, $config); |
|
1995 | - } |
|
1996 | - else |
|
1997 | - { |
|
1998 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The filter <code>" . $name . "</code> with the class name <code>" . $class . "</code> was not found")); |
|
1999 | - } |
|
2000 | - } |
|
2001 | - } |
|
2002 | - // Plugins |
|
2003 | - foreach ($plugins as $name => $config) |
|
2004 | - { |
|
2005 | - if ($config !== false) |
|
2006 | - { |
|
2007 | - $class = "Css" . $name . "MinifierPlugin"; |
|
2008 | - $config = is_array($config) ? $config : array(); |
|
2009 | - if (class_exists($class)) |
|
2010 | - { |
|
2011 | - $this->plugins[] = new $class($this, $config); |
|
2012 | - } |
|
2013 | - else |
|
2014 | - { |
|
2015 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The plugin <code>" . $name . "</code> with the class name <code>" . $class . "</code> was not found")); |
|
2016 | - } |
|
2017 | - } |
|
2018 | - } |
|
2019 | - // -- |
|
2020 | - if (!is_null($source)) |
|
2021 | - { |
|
2022 | - $this->minify($source); |
|
2023 | - } |
|
2024 | - } |
|
2025 | - /** |
|
2026 | - * Returns the minified Source. |
|
2027 | - * |
|
2028 | - * @return string |
|
2029 | - */ |
|
2030 | - public function getMinified() |
|
2031 | - { |
|
2032 | - return $this->minified; |
|
2033 | - } |
|
2034 | - /** |
|
2035 | - * Returns a plugin by class name. |
|
2036 | - * |
|
2037 | - * @param string $name Class name of the plugin |
|
2038 | - * @return aCssMinifierPlugin |
|
2039 | - */ |
|
2040 | - public function getPlugin($class) |
|
2041 | - { |
|
2042 | - static $index = null; |
|
2043 | - if (is_null($index)) |
|
2044 | - { |
|
2045 | - $index = array(); |
|
2046 | - for ($i = 0, $l = count($this->plugins); $i < $l; $i++) |
|
2047 | - { |
|
2048 | - $index[get_class($this->plugins[$i])] = $i; |
|
2049 | - } |
|
2050 | - } |
|
2051 | - return isset($index[$class]) ? $this->plugins[$index[$class]] : false; |
|
2052 | - } |
|
2053 | - /** |
|
2054 | - * Minifies the CSS source. |
|
2055 | - * |
|
2056 | - * @param string $source CSS source |
|
2057 | - * @return string |
|
2058 | - */ |
|
2059 | - public function minify($source) |
|
2060 | - { |
|
2061 | - // Variables |
|
2062 | - $r = ""; |
|
2063 | - $parser = new CssParser($source); |
|
2064 | - $tokens = $parser->getTokens(); |
|
2065 | - $filters = $this->filters; |
|
2066 | - $filterCount = count($this->filters); |
|
2067 | - $plugins = $this->plugins; |
|
2068 | - $pluginCount = count($plugins); |
|
2069 | - $pluginIndex = array(); |
|
2070 | - $pluginTriggerTokens = array(); |
|
2071 | - $globalTriggerTokens = array(); |
|
2072 | - for ($i = 0, $l = count($plugins); $i < $l; $i++) |
|
2073 | - { |
|
2074 | - $tPluginClassName = get_class($plugins[$i]); |
|
2075 | - $pluginTriggerTokens[$i] = $plugins[$i]->getTriggerTokens(); |
|
2076 | - foreach ($pluginTriggerTokens[$i] as $v) |
|
2077 | - { |
|
2078 | - if (!in_array($v, $globalTriggerTokens)) |
|
2079 | - { |
|
2080 | - $globalTriggerTokens[] = $v; |
|
2081 | - } |
|
2082 | - } |
|
2083 | - $pluginTriggerTokens[$i] = "|" . implode("|", $pluginTriggerTokens[$i]) . "|"; |
|
2084 | - $pluginIndex[$tPluginClassName] = $i; |
|
2085 | - } |
|
2086 | - $globalTriggerTokens = "|" . implode("|", $globalTriggerTokens) . "|"; |
|
2087 | - /* |
|
1932 | + { |
|
1933 | + /** |
|
1934 | + * {@link aCssMinifierFilter Filters}. |
|
1935 | + * |
|
1936 | + * @var array |
|
1937 | + */ |
|
1938 | + private $filters = array(); |
|
1939 | + /** |
|
1940 | + * {@link aCssMinifierPlugin Plugins}. |
|
1941 | + * |
|
1942 | + * @var array |
|
1943 | + */ |
|
1944 | + private $plugins = array(); |
|
1945 | + /** |
|
1946 | + * Minified source. |
|
1947 | + * |
|
1948 | + * @var string |
|
1949 | + */ |
|
1950 | + private $minified = ""; |
|
1951 | + /** |
|
1952 | + * Constructer. |
|
1953 | + * |
|
1954 | + * Creates instances of {@link aCssMinifierFilter filters} and {@link aCssMinifierPlugin plugins}. |
|
1955 | + * |
|
1956 | + * @param string $source CSS source [optional] |
|
1957 | + * @param array $filters Filter configuration [optional] |
|
1958 | + * @param array $plugins Plugin configuration [optional] |
|
1959 | + * @return void |
|
1960 | + */ |
|
1961 | + public function __construct($source = null, array $filters = null, array $plugins = null) |
|
1962 | + { |
|
1963 | + $filters = array_merge(array |
|
1964 | + ( |
|
1965 | + "ImportImports" => false, |
|
1966 | + "RemoveComments" => true, |
|
1967 | + "RemoveEmptyRulesets" => true, |
|
1968 | + "RemoveEmptyAtBlocks" => true, |
|
1969 | + "ConvertLevel3Properties" => false, |
|
1970 | + "ConvertLevel3AtKeyframes" => false, |
|
1971 | + "Variables" => true, |
|
1972 | + "RemoveLastDelarationSemiColon" => true |
|
1973 | + ), is_array($filters) ? $filters : array()); |
|
1974 | + $plugins = array_merge(array |
|
1975 | + ( |
|
1976 | + "Variables" => true, |
|
1977 | + "ConvertFontWeight" => false, |
|
1978 | + "ConvertHslColors" => false, |
|
1979 | + "ConvertRgbColors" => false, |
|
1980 | + "ConvertNamedColors" => false, |
|
1981 | + "CompressColorValues" => false, |
|
1982 | + "CompressUnitValues" => false, |
|
1983 | + "CompressExpressionValues" => false |
|
1984 | + ), is_array($plugins) ? $plugins : array()); |
|
1985 | + // Filters |
|
1986 | + foreach ($filters as $name => $config) |
|
1987 | + { |
|
1988 | + if ($config !== false) |
|
1989 | + { |
|
1990 | + $class = "Css" . $name . "MinifierFilter"; |
|
1991 | + $config = is_array($config) ? $config : array(); |
|
1992 | + if (class_exists($class)) |
|
1993 | + { |
|
1994 | + $this->filters[] = new $class($this, $config); |
|
1995 | + } |
|
1996 | + else |
|
1997 | + { |
|
1998 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The filter <code>" . $name . "</code> with the class name <code>" . $class . "</code> was not found")); |
|
1999 | + } |
|
2000 | + } |
|
2001 | + } |
|
2002 | + // Plugins |
|
2003 | + foreach ($plugins as $name => $config) |
|
2004 | + { |
|
2005 | + if ($config !== false) |
|
2006 | + { |
|
2007 | + $class = "Css" . $name . "MinifierPlugin"; |
|
2008 | + $config = is_array($config) ? $config : array(); |
|
2009 | + if (class_exists($class)) |
|
2010 | + { |
|
2011 | + $this->plugins[] = new $class($this, $config); |
|
2012 | + } |
|
2013 | + else |
|
2014 | + { |
|
2015 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The plugin <code>" . $name . "</code> with the class name <code>" . $class . "</code> was not found")); |
|
2016 | + } |
|
2017 | + } |
|
2018 | + } |
|
2019 | + // -- |
|
2020 | + if (!is_null($source)) |
|
2021 | + { |
|
2022 | + $this->minify($source); |
|
2023 | + } |
|
2024 | + } |
|
2025 | + /** |
|
2026 | + * Returns the minified Source. |
|
2027 | + * |
|
2028 | + * @return string |
|
2029 | + */ |
|
2030 | + public function getMinified() |
|
2031 | + { |
|
2032 | + return $this->minified; |
|
2033 | + } |
|
2034 | + /** |
|
2035 | + * Returns a plugin by class name. |
|
2036 | + * |
|
2037 | + * @param string $name Class name of the plugin |
|
2038 | + * @return aCssMinifierPlugin |
|
2039 | + */ |
|
2040 | + public function getPlugin($class) |
|
2041 | + { |
|
2042 | + static $index = null; |
|
2043 | + if (is_null($index)) |
|
2044 | + { |
|
2045 | + $index = array(); |
|
2046 | + for ($i = 0, $l = count($this->plugins); $i < $l; $i++) |
|
2047 | + { |
|
2048 | + $index[get_class($this->plugins[$i])] = $i; |
|
2049 | + } |
|
2050 | + } |
|
2051 | + return isset($index[$class]) ? $this->plugins[$index[$class]] : false; |
|
2052 | + } |
|
2053 | + /** |
|
2054 | + * Minifies the CSS source. |
|
2055 | + * |
|
2056 | + * @param string $source CSS source |
|
2057 | + * @return string |
|
2058 | + */ |
|
2059 | + public function minify($source) |
|
2060 | + { |
|
2061 | + // Variables |
|
2062 | + $r = ""; |
|
2063 | + $parser = new CssParser($source); |
|
2064 | + $tokens = $parser->getTokens(); |
|
2065 | + $filters = $this->filters; |
|
2066 | + $filterCount = count($this->filters); |
|
2067 | + $plugins = $this->plugins; |
|
2068 | + $pluginCount = count($plugins); |
|
2069 | + $pluginIndex = array(); |
|
2070 | + $pluginTriggerTokens = array(); |
|
2071 | + $globalTriggerTokens = array(); |
|
2072 | + for ($i = 0, $l = count($plugins); $i < $l; $i++) |
|
2073 | + { |
|
2074 | + $tPluginClassName = get_class($plugins[$i]); |
|
2075 | + $pluginTriggerTokens[$i] = $plugins[$i]->getTriggerTokens(); |
|
2076 | + foreach ($pluginTriggerTokens[$i] as $v) |
|
2077 | + { |
|
2078 | + if (!in_array($v, $globalTriggerTokens)) |
|
2079 | + { |
|
2080 | + $globalTriggerTokens[] = $v; |
|
2081 | + } |
|
2082 | + } |
|
2083 | + $pluginTriggerTokens[$i] = "|" . implode("|", $pluginTriggerTokens[$i]) . "|"; |
|
2084 | + $pluginIndex[$tPluginClassName] = $i; |
|
2085 | + } |
|
2086 | + $globalTriggerTokens = "|" . implode("|", $globalTriggerTokens) . "|"; |
|
2087 | + /* |
|
2088 | 2088 | * Apply filters |
2089 | 2089 | */ |
2090 | - for($i = 0; $i < $filterCount; $i++) |
|
2091 | - { |
|
2092 | - // Apply the filter; if the return value is larger than 0... |
|
2093 | - if ($filters[$i]->apply($tokens) > 0) |
|
2094 | - { |
|
2095 | - // ...then filter null values and rebuild the token array |
|
2096 | - $tokens = array_values(array_filter($tokens)); |
|
2097 | - } |
|
2098 | - } |
|
2099 | - $tokenCount = count($tokens); |
|
2100 | - /* |
|
2090 | + for($i = 0; $i < $filterCount; $i++) |
|
2091 | + { |
|
2092 | + // Apply the filter; if the return value is larger than 0... |
|
2093 | + if ($filters[$i]->apply($tokens) > 0) |
|
2094 | + { |
|
2095 | + // ...then filter null values and rebuild the token array |
|
2096 | + $tokens = array_values(array_filter($tokens)); |
|
2097 | + } |
|
2098 | + } |
|
2099 | + $tokenCount = count($tokens); |
|
2100 | + /* |
|
2101 | 2101 | * Apply plugins |
2102 | 2102 | */ |
2103 | - for($i = 0; $i < $tokenCount; $i++) |
|
2104 | - { |
|
2105 | - $triggerToken = "|" . get_class($tokens[$i]) . "|"; |
|
2106 | - if (strpos($globalTriggerTokens, $triggerToken) !== false) |
|
2107 | - { |
|
2108 | - for($ii = 0; $ii < $pluginCount; $ii++) |
|
2109 | - { |
|
2110 | - if (strpos($pluginTriggerTokens[$ii], $triggerToken) !== false || $pluginTriggerTokens[$ii] === false) |
|
2111 | - { |
|
2112 | - // Apply the plugin; if the return value is TRUE continue to the next token |
|
2113 | - if ($plugins[$ii]->apply($tokens[$i]) === true) |
|
2114 | - { |
|
2115 | - continue 2; |
|
2116 | - } |
|
2117 | - } |
|
2118 | - } |
|
2119 | - } |
|
2120 | - } |
|
2121 | - // Stringify the tokens |
|
2122 | - for($i = 0; $i < $tokenCount; $i++) |
|
2123 | - { |
|
2124 | - $r .= (string) $tokens[$i]; |
|
2125 | - } |
|
2126 | - $this->minified = $r; |
|
2127 | - return $r; |
|
2128 | - } |
|
2129 | - } |
|
2103 | + for($i = 0; $i < $tokenCount; $i++) |
|
2104 | + { |
|
2105 | + $triggerToken = "|" . get_class($tokens[$i]) . "|"; |
|
2106 | + if (strpos($globalTriggerTokens, $triggerToken) !== false) |
|
2107 | + { |
|
2108 | + for($ii = 0; $ii < $pluginCount; $ii++) |
|
2109 | + { |
|
2110 | + if (strpos($pluginTriggerTokens[$ii], $triggerToken) !== false || $pluginTriggerTokens[$ii] === false) |
|
2111 | + { |
|
2112 | + // Apply the plugin; if the return value is TRUE continue to the next token |
|
2113 | + if ($plugins[$ii]->apply($tokens[$i]) === true) |
|
2114 | + { |
|
2115 | + continue 2; |
|
2116 | + } |
|
2117 | + } |
|
2118 | + } |
|
2119 | + } |
|
2120 | + } |
|
2121 | + // Stringify the tokens |
|
2122 | + for($i = 0; $i < $tokenCount; $i++) |
|
2123 | + { |
|
2124 | + $r .= (string) $tokens[$i]; |
|
2125 | + } |
|
2126 | + $this->minified = $r; |
|
2127 | + return $r; |
|
2128 | + } |
|
2129 | + } |
|
2130 | 2130 | |
2131 | 2131 | /** |
2132 | 2132 | * CssMin - A (simple) css minifier with benefits |
@@ -2161,157 +2161,157 @@ discard block |
||
2161 | 2161 | * @version 3.0.1 |
2162 | 2162 | */ |
2163 | 2163 | class CssMin |
2164 | - { |
|
2165 | - /** |
|
2166 | - * Index of classes |
|
2167 | - * |
|
2168 | - * @var array |
|
2169 | - */ |
|
2170 | - private static $classIndex = array(); |
|
2171 | - /** |
|
2172 | - * Parse/minify errors |
|
2173 | - * |
|
2174 | - * @var array |
|
2175 | - */ |
|
2176 | - private static $errors = array(); |
|
2177 | - /** |
|
2178 | - * Verbose output. |
|
2179 | - * |
|
2180 | - * @var boolean |
|
2181 | - */ |
|
2182 | - private static $isVerbose = false; |
|
2183 | - /** |
|
2184 | - * {@link http://goo.gl/JrW54 Autoload} function of CssMin. |
|
2185 | - * |
|
2186 | - * @param string $class Name of the class |
|
2187 | - * @return void |
|
2188 | - */ |
|
2189 | - public static function autoload($class) |
|
2190 | - { |
|
2191 | - if (isset(self::$classIndex[$class])) |
|
2192 | - { |
|
2193 | - require(self::$classIndex[$class]); |
|
2194 | - } |
|
2195 | - } |
|
2196 | - /** |
|
2197 | - * Return errors |
|
2198 | - * |
|
2199 | - * @return array of {CssError}. |
|
2200 | - */ |
|
2201 | - public static function getErrors() |
|
2202 | - { |
|
2203 | - return self::$errors; |
|
2204 | - } |
|
2205 | - /** |
|
2206 | - * Returns if there were errors. |
|
2207 | - * |
|
2208 | - * @return boolean |
|
2209 | - */ |
|
2210 | - public static function hasErrors() |
|
2211 | - { |
|
2212 | - return count(self::$errors) > 0; |
|
2213 | - } |
|
2214 | - /** |
|
2215 | - * Initialises CssMin. |
|
2216 | - * |
|
2217 | - * @return void |
|
2218 | - */ |
|
2219 | - public static function initialise() |
|
2220 | - { |
|
2221 | - // Create the class index for autoloading or including |
|
2222 | - $paths = array(dirname(__FILE__)); |
|
2223 | - while (list($i, $path) = each($paths)) |
|
2224 | - { |
|
2225 | - $subDirectorys = glob($path . "*", GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT); |
|
2226 | - if (is_array($subDirectorys)) |
|
2227 | - { |
|
2228 | - foreach ($subDirectorys as $subDirectory) |
|
2229 | - { |
|
2230 | - $paths[] = $subDirectory; |
|
2231 | - } |
|
2232 | - } |
|
2233 | - $files = glob($path . "*.php", 0); |
|
2234 | - if (is_array($files)) |
|
2235 | - { |
|
2236 | - foreach ($files as $file) |
|
2237 | - { |
|
2238 | - $class = substr(basename($file), 0, -4); |
|
2239 | - self::$classIndex[$class] = $file; |
|
2240 | - } |
|
2241 | - } |
|
2242 | - } |
|
2243 | - krsort(self::$classIndex); |
|
2244 | - // Only use autoloading if spl_autoload_register() is available and no __autoload() is defined (because |
|
2245 | - // __autoload() breaks if spl_autoload_register() is used. |
|
2246 | - if (function_exists("spl_autoload_register") && !is_callable("__autoload")) |
|
2247 | - { |
|
2248 | - spl_autoload_register(array(__CLASS__, "autoload")); |
|
2249 | - } |
|
2250 | - // Otherwise include all class files |
|
2251 | - else |
|
2252 | - { |
|
2253 | - foreach (self::$classIndex as $class => $file) |
|
2254 | - { |
|
2255 | - if (!class_exists($class)) |
|
2256 | - { |
|
2257 | - require_once($file); |
|
2258 | - } |
|
2259 | - } |
|
2260 | - } |
|
2261 | - } |
|
2262 | - /** |
|
2263 | - * Minifies CSS source. |
|
2264 | - * |
|
2265 | - * @param string $source CSS source |
|
2266 | - * @param array $filters Filter configuration [optional] |
|
2267 | - * @param array $plugins Plugin configuration [optional] |
|
2268 | - * @return string Minified CSS |
|
2269 | - */ |
|
2270 | - public static function minify($source, array $filters = null, array $plugins = null) |
|
2271 | - { |
|
2272 | - self::$errors = array(); |
|
2273 | - $minifier = new CssMinifier($source, $filters, $plugins); |
|
2274 | - return $minifier->getMinified(); |
|
2275 | - } |
|
2276 | - /** |
|
2277 | - * Parse the CSS source. |
|
2278 | - * |
|
2279 | - * @param string $source CSS source |
|
2280 | - * @param array $plugins Plugin configuration [optional] |
|
2281 | - * @return array Array of aCssToken |
|
2282 | - */ |
|
2283 | - public static function parse($source, array $plugins = null) |
|
2284 | - { |
|
2285 | - self::$errors = array(); |
|
2286 | - $parser = new CssParser($source, $plugins); |
|
2287 | - return $parser->getTokens(); |
|
2288 | - } |
|
2289 | - /** |
|
2290 | - * -- |
|
2291 | - * |
|
2292 | - * @param boolean $to |
|
2293 | - * @return boolean |
|
2294 | - */ |
|
2295 | - public static function setVerbose($to) |
|
2296 | - { |
|
2297 | - self::$isVerbose = (boolean) $to; |
|
2298 | - return self::$isVerbose; |
|
2299 | - } |
|
2300 | - /** |
|
2301 | - * -- |
|
2302 | - * |
|
2303 | - * @param CssError $error |
|
2304 | - * @return void |
|
2305 | - */ |
|
2306 | - public static function triggerError(CssError $error) |
|
2307 | - { |
|
2308 | - self::$errors[] = $error; |
|
2309 | - if (self::$isVerbose) |
|
2310 | - { |
|
2311 | - trigger_error((string) $error, E_USER_WARNING); |
|
2312 | - } |
|
2313 | - } |
|
2314 | - } |
|
2164 | + { |
|
2165 | + /** |
|
2166 | + * Index of classes |
|
2167 | + * |
|
2168 | + * @var array |
|
2169 | + */ |
|
2170 | + private static $classIndex = array(); |
|
2171 | + /** |
|
2172 | + * Parse/minify errors |
|
2173 | + * |
|
2174 | + * @var array |
|
2175 | + */ |
|
2176 | + private static $errors = array(); |
|
2177 | + /** |
|
2178 | + * Verbose output. |
|
2179 | + * |
|
2180 | + * @var boolean |
|
2181 | + */ |
|
2182 | + private static $isVerbose = false; |
|
2183 | + /** |
|
2184 | + * {@link http://goo.gl/JrW54 Autoload} function of CssMin. |
|
2185 | + * |
|
2186 | + * @param string $class Name of the class |
|
2187 | + * @return void |
|
2188 | + */ |
|
2189 | + public static function autoload($class) |
|
2190 | + { |
|
2191 | + if (isset(self::$classIndex[$class])) |
|
2192 | + { |
|
2193 | + require(self::$classIndex[$class]); |
|
2194 | + } |
|
2195 | + } |
|
2196 | + /** |
|
2197 | + * Return errors |
|
2198 | + * |
|
2199 | + * @return array of {CssError}. |
|
2200 | + */ |
|
2201 | + public static function getErrors() |
|
2202 | + { |
|
2203 | + return self::$errors; |
|
2204 | + } |
|
2205 | + /** |
|
2206 | + * Returns if there were errors. |
|
2207 | + * |
|
2208 | + * @return boolean |
|
2209 | + */ |
|
2210 | + public static function hasErrors() |
|
2211 | + { |
|
2212 | + return count(self::$errors) > 0; |
|
2213 | + } |
|
2214 | + /** |
|
2215 | + * Initialises CssMin. |
|
2216 | + * |
|
2217 | + * @return void |
|
2218 | + */ |
|
2219 | + public static function initialise() |
|
2220 | + { |
|
2221 | + // Create the class index for autoloading or including |
|
2222 | + $paths = array(dirname(__FILE__)); |
|
2223 | + while (list($i, $path) = each($paths)) |
|
2224 | + { |
|
2225 | + $subDirectorys = glob($path . "*", GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT); |
|
2226 | + if (is_array($subDirectorys)) |
|
2227 | + { |
|
2228 | + foreach ($subDirectorys as $subDirectory) |
|
2229 | + { |
|
2230 | + $paths[] = $subDirectory; |
|
2231 | + } |
|
2232 | + } |
|
2233 | + $files = glob($path . "*.php", 0); |
|
2234 | + if (is_array($files)) |
|
2235 | + { |
|
2236 | + foreach ($files as $file) |
|
2237 | + { |
|
2238 | + $class = substr(basename($file), 0, -4); |
|
2239 | + self::$classIndex[$class] = $file; |
|
2240 | + } |
|
2241 | + } |
|
2242 | + } |
|
2243 | + krsort(self::$classIndex); |
|
2244 | + // Only use autoloading if spl_autoload_register() is available and no __autoload() is defined (because |
|
2245 | + // __autoload() breaks if spl_autoload_register() is used. |
|
2246 | + if (function_exists("spl_autoload_register") && !is_callable("__autoload")) |
|
2247 | + { |
|
2248 | + spl_autoload_register(array(__CLASS__, "autoload")); |
|
2249 | + } |
|
2250 | + // Otherwise include all class files |
|
2251 | + else |
|
2252 | + { |
|
2253 | + foreach (self::$classIndex as $class => $file) |
|
2254 | + { |
|
2255 | + if (!class_exists($class)) |
|
2256 | + { |
|
2257 | + require_once($file); |
|
2258 | + } |
|
2259 | + } |
|
2260 | + } |
|
2261 | + } |
|
2262 | + /** |
|
2263 | + * Minifies CSS source. |
|
2264 | + * |
|
2265 | + * @param string $source CSS source |
|
2266 | + * @param array $filters Filter configuration [optional] |
|
2267 | + * @param array $plugins Plugin configuration [optional] |
|
2268 | + * @return string Minified CSS |
|
2269 | + */ |
|
2270 | + public static function minify($source, array $filters = null, array $plugins = null) |
|
2271 | + { |
|
2272 | + self::$errors = array(); |
|
2273 | + $minifier = new CssMinifier($source, $filters, $plugins); |
|
2274 | + return $minifier->getMinified(); |
|
2275 | + } |
|
2276 | + /** |
|
2277 | + * Parse the CSS source. |
|
2278 | + * |
|
2279 | + * @param string $source CSS source |
|
2280 | + * @param array $plugins Plugin configuration [optional] |
|
2281 | + * @return array Array of aCssToken |
|
2282 | + */ |
|
2283 | + public static function parse($source, array $plugins = null) |
|
2284 | + { |
|
2285 | + self::$errors = array(); |
|
2286 | + $parser = new CssParser($source, $plugins); |
|
2287 | + return $parser->getTokens(); |
|
2288 | + } |
|
2289 | + /** |
|
2290 | + * -- |
|
2291 | + * |
|
2292 | + * @param boolean $to |
|
2293 | + * @return boolean |
|
2294 | + */ |
|
2295 | + public static function setVerbose($to) |
|
2296 | + { |
|
2297 | + self::$isVerbose = (boolean) $to; |
|
2298 | + return self::$isVerbose; |
|
2299 | + } |
|
2300 | + /** |
|
2301 | + * -- |
|
2302 | + * |
|
2303 | + * @param CssError $error |
|
2304 | + * @return void |
|
2305 | + */ |
|
2306 | + public static function triggerError(CssError $error) |
|
2307 | + { |
|
2308 | + self::$errors[] = $error; |
|
2309 | + if (self::$isVerbose) |
|
2310 | + { |
|
2311 | + trigger_error((string) $error, E_USER_WARNING); |
|
2312 | + } |
|
2313 | + } |
|
2314 | + } |
|
2315 | 2315 | // Initialises CssMin |
2316 | 2316 | CssMin::initialise(); |
2317 | 2317 | |
@@ -2327,196 +2327,196 @@ discard block |
||
2327 | 2327 | * @version 3.0.1 |
2328 | 2328 | */ |
2329 | 2329 | class CssImportImportsMinifierFilter extends aCssMinifierFilter |
2330 | - { |
|
2331 | - /** |
|
2332 | - * Array with already imported external stylesheets. |
|
2333 | - * |
|
2334 | - * @var array |
|
2335 | - */ |
|
2336 | - private $imported = array(); |
|
2337 | - /** |
|
2338 | - * Implements {@link aCssMinifierFilter::filter()}. |
|
2339 | - * |
|
2340 | - * @param array $tokens Array of objects of type aCssToken |
|
2341 | - * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
2342 | - */ |
|
2343 | - public function apply(array &$tokens) |
|
2344 | - { |
|
2345 | - if (!isset($this->configuration["BasePath"]) || !is_dir($this->configuration["BasePath"])) |
|
2346 | - { |
|
2347 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Base path <code>" . ($this->configuration["BasePath"] ? $this->configuration["BasePath"] : "null"). "</code> is not a directory")); |
|
2348 | - return 0; |
|
2349 | - } |
|
2350 | - for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
2351 | - { |
|
2352 | - if (get_class($tokens[$i]) === "CssAtImportToken") |
|
2353 | - { |
|
2354 | - $import = $this->configuration["BasePath"] . "/" . $tokens[$i]->Import; |
|
2355 | - // Import file was not found/is not a file |
|
2356 | - if (!is_file($import)) |
|
2357 | - { |
|
2358 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Import file <code>" . $import. "</code> was not found.", (string) $tokens[$i])); |
|
2359 | - } |
|
2360 | - // Import file already imported; remove this @import at-rule to prevent recursions |
|
2361 | - elseif (in_array($import, $this->imported)) |
|
2362 | - { |
|
2363 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Import file <code>" . $import. "</code> was already imported.", (string) $tokens[$i])); |
|
2364 | - $tokens[$i] = null; |
|
2365 | - } |
|
2366 | - else |
|
2367 | - { |
|
2368 | - $this->imported[] = $import; |
|
2369 | - $parser = new CssParser(file_get_contents($import)); |
|
2370 | - $import = $parser->getTokens(); |
|
2371 | - // The @import at-rule has media types defined requiring special handling |
|
2372 | - if (count($tokens[$i]->MediaTypes) > 0 && !(count($tokens[$i]->MediaTypes) == 1 && $tokens[$i]->MediaTypes[0] == "all")) |
|
2373 | - { |
|
2374 | - $blocks = array(); |
|
2375 | - /* |
|
2330 | + { |
|
2331 | + /** |
|
2332 | + * Array with already imported external stylesheets. |
|
2333 | + * |
|
2334 | + * @var array |
|
2335 | + */ |
|
2336 | + private $imported = array(); |
|
2337 | + /** |
|
2338 | + * Implements {@link aCssMinifierFilter::filter()}. |
|
2339 | + * |
|
2340 | + * @param array $tokens Array of objects of type aCssToken |
|
2341 | + * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
2342 | + */ |
|
2343 | + public function apply(array &$tokens) |
|
2344 | + { |
|
2345 | + if (!isset($this->configuration["BasePath"]) || !is_dir($this->configuration["BasePath"])) |
|
2346 | + { |
|
2347 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Base path <code>" . ($this->configuration["BasePath"] ? $this->configuration["BasePath"] : "null"). "</code> is not a directory")); |
|
2348 | + return 0; |
|
2349 | + } |
|
2350 | + for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
2351 | + { |
|
2352 | + if (get_class($tokens[$i]) === "CssAtImportToken") |
|
2353 | + { |
|
2354 | + $import = $this->configuration["BasePath"] . "/" . $tokens[$i]->Import; |
|
2355 | + // Import file was not found/is not a file |
|
2356 | + if (!is_file($import)) |
|
2357 | + { |
|
2358 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Import file <code>" . $import. "</code> was not found.", (string) $tokens[$i])); |
|
2359 | + } |
|
2360 | + // Import file already imported; remove this @import at-rule to prevent recursions |
|
2361 | + elseif (in_array($import, $this->imported)) |
|
2362 | + { |
|
2363 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Import file <code>" . $import. "</code> was already imported.", (string) $tokens[$i])); |
|
2364 | + $tokens[$i] = null; |
|
2365 | + } |
|
2366 | + else |
|
2367 | + { |
|
2368 | + $this->imported[] = $import; |
|
2369 | + $parser = new CssParser(file_get_contents($import)); |
|
2370 | + $import = $parser->getTokens(); |
|
2371 | + // The @import at-rule has media types defined requiring special handling |
|
2372 | + if (count($tokens[$i]->MediaTypes) > 0 && !(count($tokens[$i]->MediaTypes) == 1 && $tokens[$i]->MediaTypes[0] == "all")) |
|
2373 | + { |
|
2374 | + $blocks = array(); |
|
2375 | + /* |
|
2376 | 2376 | * Filter or set media types of @import at-rule or remove the @import at-rule if no media type is matching the parent @import at-rule |
2377 | 2377 | */ |
2378 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2379 | - { |
|
2380 | - if (get_class($import[$ii]) === "CssAtImportToken") |
|
2381 | - { |
|
2382 | - // @import at-rule defines no media type or only the "all" media type; set the media types to the one defined in the parent @import at-rule |
|
2383 | - if (count($import[$ii]->MediaTypes) == 0 || (count($import[$ii]->MediaTypes) == 1 && $import[$ii]->MediaTypes[0] == "all")) |
|
2384 | - { |
|
2385 | - $import[$ii]->MediaTypes = $tokens[$i]->MediaTypes; |
|
2386 | - } |
|
2387 | - // @import at-rule defineds one or more media types; filter out media types not matching with the parent @import at-rule |
|
2388 | - elseif (count($import[$ii]->MediaTypes > 0)) |
|
2389 | - { |
|
2390 | - foreach ($import[$ii]->MediaTypes as $index => $mediaType) |
|
2391 | - { |
|
2392 | - if (!in_array($mediaType, $tokens[$i]->MediaTypes)) |
|
2393 | - { |
|
2394 | - unset($import[$ii]->MediaTypes[$index]); |
|
2395 | - } |
|
2396 | - } |
|
2397 | - $import[$ii]->MediaTypes = array_values($import[$ii]->MediaTypes); |
|
2398 | - // If there are no media types left in the @import at-rule remove the @import at-rule |
|
2399 | - if (count($import[$ii]->MediaTypes) == 0) |
|
2400 | - { |
|
2401 | - $import[$ii] = null; |
|
2402 | - } |
|
2403 | - } |
|
2404 | - } |
|
2405 | - } |
|
2406 | - /* |
|
2378 | + for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2379 | + { |
|
2380 | + if (get_class($import[$ii]) === "CssAtImportToken") |
|
2381 | + { |
|
2382 | + // @import at-rule defines no media type or only the "all" media type; set the media types to the one defined in the parent @import at-rule |
|
2383 | + if (count($import[$ii]->MediaTypes) == 0 || (count($import[$ii]->MediaTypes) == 1 && $import[$ii]->MediaTypes[0] == "all")) |
|
2384 | + { |
|
2385 | + $import[$ii]->MediaTypes = $tokens[$i]->MediaTypes; |
|
2386 | + } |
|
2387 | + // @import at-rule defineds one or more media types; filter out media types not matching with the parent @import at-rule |
|
2388 | + elseif (count($import[$ii]->MediaTypes > 0)) |
|
2389 | + { |
|
2390 | + foreach ($import[$ii]->MediaTypes as $index => $mediaType) |
|
2391 | + { |
|
2392 | + if (!in_array($mediaType, $tokens[$i]->MediaTypes)) |
|
2393 | + { |
|
2394 | + unset($import[$ii]->MediaTypes[$index]); |
|
2395 | + } |
|
2396 | + } |
|
2397 | + $import[$ii]->MediaTypes = array_values($import[$ii]->MediaTypes); |
|
2398 | + // If there are no media types left in the @import at-rule remove the @import at-rule |
|
2399 | + if (count($import[$ii]->MediaTypes) == 0) |
|
2400 | + { |
|
2401 | + $import[$ii] = null; |
|
2402 | + } |
|
2403 | + } |
|
2404 | + } |
|
2405 | + } |
|
2406 | + /* |
|
2407 | 2407 | * Remove media types of @media at-rule block not defined in the @import at-rule |
2408 | 2408 | */ |
2409 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2410 | - { |
|
2411 | - if (get_class($import[$ii]) === "CssAtMediaStartToken") |
|
2412 | - { |
|
2413 | - foreach ($import[$ii]->MediaTypes as $index => $mediaType) |
|
2414 | - { |
|
2415 | - if (!in_array($mediaType, $tokens[$i]->MediaTypes)) |
|
2416 | - { |
|
2417 | - unset($import[$ii]->MediaTypes[$index]); |
|
2418 | - } |
|
2419 | - $import[$ii]->MediaTypes = array_values($import[$ii]->MediaTypes); |
|
2420 | - } |
|
2421 | - } |
|
2422 | - } |
|
2423 | - /* |
|
2409 | + for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2410 | + { |
|
2411 | + if (get_class($import[$ii]) === "CssAtMediaStartToken") |
|
2412 | + { |
|
2413 | + foreach ($import[$ii]->MediaTypes as $index => $mediaType) |
|
2414 | + { |
|
2415 | + if (!in_array($mediaType, $tokens[$i]->MediaTypes)) |
|
2416 | + { |
|
2417 | + unset($import[$ii]->MediaTypes[$index]); |
|
2418 | + } |
|
2419 | + $import[$ii]->MediaTypes = array_values($import[$ii]->MediaTypes); |
|
2420 | + } |
|
2421 | + } |
|
2422 | + } |
|
2423 | + /* |
|
2424 | 2424 | * If no media types left of the @media at-rule block remove the complete block |
2425 | 2425 | */ |
2426 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2427 | - { |
|
2428 | - if (get_class($import[$ii]) === "CssAtMediaStartToken") |
|
2429 | - { |
|
2430 | - if (count($import[$ii]->MediaTypes) === 0) |
|
2431 | - { |
|
2432 | - for ($iii = $ii; $iii < $ll; $iii++) |
|
2433 | - { |
|
2434 | - if (get_class($import[$iii]) === "CssAtMediaEndToken") |
|
2435 | - { |
|
2436 | - break; |
|
2437 | - } |
|
2438 | - } |
|
2439 | - if (get_class($import[$iii]) === "CssAtMediaEndToken") |
|
2440 | - { |
|
2441 | - array_splice($import, $ii, $iii - $ii + 1, array()); |
|
2442 | - $ll = count($import); |
|
2443 | - } |
|
2444 | - } |
|
2445 | - } |
|
2446 | - } |
|
2447 | - /* |
|
2426 | + for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2427 | + { |
|
2428 | + if (get_class($import[$ii]) === "CssAtMediaStartToken") |
|
2429 | + { |
|
2430 | + if (count($import[$ii]->MediaTypes) === 0) |
|
2431 | + { |
|
2432 | + for ($iii = $ii; $iii < $ll; $iii++) |
|
2433 | + { |
|
2434 | + if (get_class($import[$iii]) === "CssAtMediaEndToken") |
|
2435 | + { |
|
2436 | + break; |
|
2437 | + } |
|
2438 | + } |
|
2439 | + if (get_class($import[$iii]) === "CssAtMediaEndToken") |
|
2440 | + { |
|
2441 | + array_splice($import, $ii, $iii - $ii + 1, array()); |
|
2442 | + $ll = count($import); |
|
2443 | + } |
|
2444 | + } |
|
2445 | + } |
|
2446 | + } |
|
2447 | + /* |
|
2448 | 2448 | * If the media types of the @media at-rule equals the media types defined in the @import |
2449 | 2449 | * at-rule remove the CssAtMediaStartToken and CssAtMediaEndToken token |
2450 | 2450 | */ |
2451 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2452 | - { |
|
2453 | - if (get_class($import[$ii]) === "CssAtMediaStartToken" && count(array_diff($tokens[$i]->MediaTypes, $import[$ii]->MediaTypes)) === 0) |
|
2454 | - { |
|
2455 | - for ($iii = $ii; $iii < $ll; $iii++) |
|
2456 | - { |
|
2457 | - if (get_class($import[$iii]) == "CssAtMediaEndToken") |
|
2458 | - { |
|
2459 | - break; |
|
2460 | - } |
|
2461 | - } |
|
2462 | - if (get_class($import[$iii]) == "CssAtMediaEndToken") |
|
2463 | - { |
|
2464 | - unset($import[$ii]); |
|
2465 | - unset($import[$iii]); |
|
2466 | - $import = array_values($import); |
|
2467 | - $ll = count($import); |
|
2468 | - } |
|
2469 | - } |
|
2470 | - } |
|
2471 | - /** |
|
2472 | - * Extract CssAtImportToken and CssAtCharsetToken tokens |
|
2473 | - */ |
|
2474 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2475 | - { |
|
2476 | - $class = get_class($import[$ii]); |
|
2477 | - if ($class === "CssAtImportToken" || $class === "CssAtCharsetToken") |
|
2478 | - { |
|
2479 | - $blocks = array_merge($blocks, array_splice($import, $ii, 1, array())); |
|
2480 | - $ll = count($import); |
|
2481 | - } |
|
2482 | - } |
|
2483 | - /* |
|
2451 | + for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2452 | + { |
|
2453 | + if (get_class($import[$ii]) === "CssAtMediaStartToken" && count(array_diff($tokens[$i]->MediaTypes, $import[$ii]->MediaTypes)) === 0) |
|
2454 | + { |
|
2455 | + for ($iii = $ii; $iii < $ll; $iii++) |
|
2456 | + { |
|
2457 | + if (get_class($import[$iii]) == "CssAtMediaEndToken") |
|
2458 | + { |
|
2459 | + break; |
|
2460 | + } |
|
2461 | + } |
|
2462 | + if (get_class($import[$iii]) == "CssAtMediaEndToken") |
|
2463 | + { |
|
2464 | + unset($import[$ii]); |
|
2465 | + unset($import[$iii]); |
|
2466 | + $import = array_values($import); |
|
2467 | + $ll = count($import); |
|
2468 | + } |
|
2469 | + } |
|
2470 | + } |
|
2471 | + /** |
|
2472 | + * Extract CssAtImportToken and CssAtCharsetToken tokens |
|
2473 | + */ |
|
2474 | + for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2475 | + { |
|
2476 | + $class = get_class($import[$ii]); |
|
2477 | + if ($class === "CssAtImportToken" || $class === "CssAtCharsetToken") |
|
2478 | + { |
|
2479 | + $blocks = array_merge($blocks, array_splice($import, $ii, 1, array())); |
|
2480 | + $ll = count($import); |
|
2481 | + } |
|
2482 | + } |
|
2483 | + /* |
|
2484 | 2484 | * Extract the @font-face, @media and @page at-rule block |
2485 | 2485 | */ |
2486 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2487 | - { |
|
2488 | - $class = get_class($import[$ii]); |
|
2489 | - if ($class === "CssAtFontFaceStartToken" || $class === "CssAtMediaStartToken" || $class === "CssAtPageStartToken" || $class === "CssAtVariablesStartToken") |
|
2490 | - { |
|
2491 | - for ($iii = $ii; $iii < $ll; $iii++) |
|
2492 | - { |
|
2493 | - $class = get_class($import[$iii]); |
|
2494 | - if ($class === "CssAtFontFaceEndToken" || $class === "CssAtMediaEndToken" || $class === "CssAtPageEndToken" || $class === "CssAtVariablesEndToken") |
|
2495 | - { |
|
2496 | - break; |
|
2497 | - } |
|
2498 | - } |
|
2499 | - $class = get_class($import[$iii]); |
|
2500 | - if (isset($import[$iii]) && ($class === "CssAtFontFaceEndToken" || $class === "CssAtMediaEndToken" || $class === "CssAtPageEndToken" || $class === "CssAtVariablesEndToken")) |
|
2501 | - { |
|
2502 | - $blocks = array_merge($blocks, array_splice($import, $ii, $iii - $ii + 1, array())); |
|
2503 | - $ll = count($import); |
|
2504 | - } |
|
2505 | - } |
|
2506 | - } |
|
2507 | - // Create the import array with extracted tokens and the rulesets wrapped into a @media at-rule block |
|
2508 | - $import = array_merge($blocks, array(new CssAtMediaStartToken($tokens[$i]->MediaTypes)), $import, array(new CssAtMediaEndToken())); |
|
2509 | - } |
|
2510 | - // Insert the imported tokens |
|
2511 | - array_splice($tokens, $i, 1, $import); |
|
2512 | - // Modify parameters of the for-loop |
|
2513 | - $i--; |
|
2514 | - $l = count($tokens); |
|
2515 | - } |
|
2516 | - } |
|
2517 | - } |
|
2518 | - } |
|
2519 | - } |
|
2486 | + for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2487 | + { |
|
2488 | + $class = get_class($import[$ii]); |
|
2489 | + if ($class === "CssAtFontFaceStartToken" || $class === "CssAtMediaStartToken" || $class === "CssAtPageStartToken" || $class === "CssAtVariablesStartToken") |
|
2490 | + { |
|
2491 | + for ($iii = $ii; $iii < $ll; $iii++) |
|
2492 | + { |
|
2493 | + $class = get_class($import[$iii]); |
|
2494 | + if ($class === "CssAtFontFaceEndToken" || $class === "CssAtMediaEndToken" || $class === "CssAtPageEndToken" || $class === "CssAtVariablesEndToken") |
|
2495 | + { |
|
2496 | + break; |
|
2497 | + } |
|
2498 | + } |
|
2499 | + $class = get_class($import[$iii]); |
|
2500 | + if (isset($import[$iii]) && ($class === "CssAtFontFaceEndToken" || $class === "CssAtMediaEndToken" || $class === "CssAtPageEndToken" || $class === "CssAtVariablesEndToken")) |
|
2501 | + { |
|
2502 | + $blocks = array_merge($blocks, array_splice($import, $ii, $iii - $ii + 1, array())); |
|
2503 | + $ll = count($import); |
|
2504 | + } |
|
2505 | + } |
|
2506 | + } |
|
2507 | + // Create the import array with extracted tokens and the rulesets wrapped into a @media at-rule block |
|
2508 | + $import = array_merge($blocks, array(new CssAtMediaStartToken($tokens[$i]->MediaTypes)), $import, array(new CssAtMediaEndToken())); |
|
2509 | + } |
|
2510 | + // Insert the imported tokens |
|
2511 | + array_splice($tokens, $i, 1, $import); |
|
2512 | + // Modify parameters of the for-loop |
|
2513 | + $i--; |
|
2514 | + $l = count($tokens); |
|
2515 | + } |
|
2516 | + } |
|
2517 | + } |
|
2518 | + } |
|
2519 | + } |
|
2520 | 2520 | |
2521 | 2521 | /** |
2522 | 2522 | * {@link aCssParserPlugin Parser plugin} for preserve parsing expression() declaration values. |
@@ -2532,77 +2532,77 @@ discard block |
||
2532 | 2532 | * @version 3.0.1 |
2533 | 2533 | */ |
2534 | 2534 | class CssExpressionParserPlugin extends aCssParserPlugin |
2535 | - { |
|
2536 | - /** |
|
2537 | - * Count of left braces. |
|
2538 | - * |
|
2539 | - * @var integer |
|
2540 | - */ |
|
2541 | - private $leftBraces = 0; |
|
2542 | - /** |
|
2543 | - * Count of right braces. |
|
2544 | - * |
|
2545 | - * @var integer |
|
2546 | - */ |
|
2547 | - private $rightBraces = 0; |
|
2548 | - /** |
|
2549 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
2550 | - * |
|
2551 | - * @return array |
|
2552 | - */ |
|
2553 | - public function getTriggerChars() |
|
2554 | - { |
|
2555 | - return array("(", ")", ";", "}"); |
|
2556 | - } |
|
2557 | - /** |
|
2558 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
2559 | - * |
|
2560 | - * @return array |
|
2561 | - */ |
|
2562 | - public function getTriggerStates() |
|
2563 | - { |
|
2564 | - return false; |
|
2565 | - } |
|
2566 | - /** |
|
2567 | - * Implements {@link aCssParserPlugin::parse()}. |
|
2568 | - * |
|
2569 | - * @param integer $index Current index |
|
2570 | - * @param string $char Current char |
|
2571 | - * @param string $previousChar Previous char |
|
2572 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
2573 | - */ |
|
2574 | - public function parse($index, $char, $previousChar, $state) |
|
2575 | - { |
|
2576 | - // Start of expression |
|
2577 | - if ($char === "(" && strtolower(substr($this->parser->getSource(), $index - 10, 11)) === "expression(" && $state !== "T_EXPRESSION") |
|
2578 | - { |
|
2579 | - $this->parser->pushState("T_EXPRESSION"); |
|
2580 | - $this->leftBraces++; |
|
2581 | - } |
|
2582 | - // Count left braces |
|
2583 | - elseif ($char === "(" && $state === "T_EXPRESSION") |
|
2584 | - { |
|
2585 | - $this->leftBraces++; |
|
2586 | - } |
|
2587 | - // Count right braces |
|
2588 | - elseif ($char === ")" && $state === "T_EXPRESSION") |
|
2589 | - { |
|
2590 | - $this->rightBraces++; |
|
2591 | - } |
|
2592 | - // Possible end of expression; if left and right braces are equal the expressen ends |
|
2593 | - elseif (($char === ";" || $char === "}") && $state === "T_EXPRESSION" && $this->leftBraces === $this->rightBraces) |
|
2594 | - { |
|
2595 | - $this->leftBraces = $this->rightBraces = 0; |
|
2596 | - $this->parser->popState(); |
|
2597 | - return $index - 1; |
|
2598 | - } |
|
2599 | - else |
|
2600 | - { |
|
2601 | - return false; |
|
2602 | - } |
|
2603 | - return true; |
|
2604 | - } |
|
2605 | - } |
|
2535 | + { |
|
2536 | + /** |
|
2537 | + * Count of left braces. |
|
2538 | + * |
|
2539 | + * @var integer |
|
2540 | + */ |
|
2541 | + private $leftBraces = 0; |
|
2542 | + /** |
|
2543 | + * Count of right braces. |
|
2544 | + * |
|
2545 | + * @var integer |
|
2546 | + */ |
|
2547 | + private $rightBraces = 0; |
|
2548 | + /** |
|
2549 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
2550 | + * |
|
2551 | + * @return array |
|
2552 | + */ |
|
2553 | + public function getTriggerChars() |
|
2554 | + { |
|
2555 | + return array("(", ")", ";", "}"); |
|
2556 | + } |
|
2557 | + /** |
|
2558 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
2559 | + * |
|
2560 | + * @return array |
|
2561 | + */ |
|
2562 | + public function getTriggerStates() |
|
2563 | + { |
|
2564 | + return false; |
|
2565 | + } |
|
2566 | + /** |
|
2567 | + * Implements {@link aCssParserPlugin::parse()}. |
|
2568 | + * |
|
2569 | + * @param integer $index Current index |
|
2570 | + * @param string $char Current char |
|
2571 | + * @param string $previousChar Previous char |
|
2572 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
2573 | + */ |
|
2574 | + public function parse($index, $char, $previousChar, $state) |
|
2575 | + { |
|
2576 | + // Start of expression |
|
2577 | + if ($char === "(" && strtolower(substr($this->parser->getSource(), $index - 10, 11)) === "expression(" && $state !== "T_EXPRESSION") |
|
2578 | + { |
|
2579 | + $this->parser->pushState("T_EXPRESSION"); |
|
2580 | + $this->leftBraces++; |
|
2581 | + } |
|
2582 | + // Count left braces |
|
2583 | + elseif ($char === "(" && $state === "T_EXPRESSION") |
|
2584 | + { |
|
2585 | + $this->leftBraces++; |
|
2586 | + } |
|
2587 | + // Count right braces |
|
2588 | + elseif ($char === ")" && $state === "T_EXPRESSION") |
|
2589 | + { |
|
2590 | + $this->rightBraces++; |
|
2591 | + } |
|
2592 | + // Possible end of expression; if left and right braces are equal the expressen ends |
|
2593 | + elseif (($char === ";" || $char === "}") && $state === "T_EXPRESSION" && $this->leftBraces === $this->rightBraces) |
|
2594 | + { |
|
2595 | + $this->leftBraces = $this->rightBraces = 0; |
|
2596 | + $this->parser->popState(); |
|
2597 | + return $index - 1; |
|
2598 | + } |
|
2599 | + else |
|
2600 | + { |
|
2601 | + return false; |
|
2602 | + } |
|
2603 | + return true; |
|
2604 | + } |
|
2605 | + } |
|
2606 | 2606 | |
2607 | 2607 | /** |
2608 | 2608 | * CSS Error. |
@@ -2615,55 +2615,55 @@ discard block |
||
2615 | 2615 | * @version 3.0.1 |
2616 | 2616 | */ |
2617 | 2617 | class CssError |
2618 | - { |
|
2619 | - /** |
|
2620 | - * File. |
|
2621 | - * |
|
2622 | - * @var string |
|
2623 | - */ |
|
2624 | - public $File = ""; |
|
2625 | - /** |
|
2626 | - * Line. |
|
2627 | - * |
|
2628 | - * @var integer |
|
2629 | - */ |
|
2630 | - public $Line = 0; |
|
2631 | - /** |
|
2632 | - * Error message. |
|
2633 | - * |
|
2634 | - * @var string |
|
2635 | - */ |
|
2636 | - public $Message = ""; |
|
2637 | - /** |
|
2638 | - * Source. |
|
2639 | - * |
|
2640 | - * @var string |
|
2641 | - */ |
|
2642 | - public $Source = ""; |
|
2643 | - /** |
|
2644 | - * Constructor triggering the error. |
|
2645 | - * |
|
2646 | - * @param string $message Error message |
|
2647 | - * @param string $source Corresponding line [optional] |
|
2648 | - * @return void |
|
2649 | - */ |
|
2650 | - public function __construct($file, $line, $message, $source = "") |
|
2651 | - { |
|
2652 | - $this->File = $file; |
|
2653 | - $this->Line = $line; |
|
2654 | - $this->Message = $message; |
|
2655 | - $this->Source = $source; |
|
2656 | - } |
|
2657 | - /** |
|
2658 | - * Returns the error as formatted string. |
|
2659 | - * |
|
2660 | - * @return string |
|
2661 | - */ |
|
2662 | - public function __toString() |
|
2663 | - { |
|
2664 | - return $this->Message . ($this->Source ? ": <br /><code>" . $this->Source . "</code>": "") . "<br />in file " . $this->File . " at line " . $this->Line; |
|
2665 | - } |
|
2666 | - } |
|
2618 | + { |
|
2619 | + /** |
|
2620 | + * File. |
|
2621 | + * |
|
2622 | + * @var string |
|
2623 | + */ |
|
2624 | + public $File = ""; |
|
2625 | + /** |
|
2626 | + * Line. |
|
2627 | + * |
|
2628 | + * @var integer |
|
2629 | + */ |
|
2630 | + public $Line = 0; |
|
2631 | + /** |
|
2632 | + * Error message. |
|
2633 | + * |
|
2634 | + * @var string |
|
2635 | + */ |
|
2636 | + public $Message = ""; |
|
2637 | + /** |
|
2638 | + * Source. |
|
2639 | + * |
|
2640 | + * @var string |
|
2641 | + */ |
|
2642 | + public $Source = ""; |
|
2643 | + /** |
|
2644 | + * Constructor triggering the error. |
|
2645 | + * |
|
2646 | + * @param string $message Error message |
|
2647 | + * @param string $source Corresponding line [optional] |
|
2648 | + * @return void |
|
2649 | + */ |
|
2650 | + public function __construct($file, $line, $message, $source = "") |
|
2651 | + { |
|
2652 | + $this->File = $file; |
|
2653 | + $this->Line = $line; |
|
2654 | + $this->Message = $message; |
|
2655 | + $this->Source = $source; |
|
2656 | + } |
|
2657 | + /** |
|
2658 | + * Returns the error as formatted string. |
|
2659 | + * |
|
2660 | + * @return string |
|
2661 | + */ |
|
2662 | + public function __toString() |
|
2663 | + { |
|
2664 | + return $this->Message . ($this->Source ? ": <br /><code>" . $this->Source . "</code>": "") . "<br />in file " . $this->File . " at line " . $this->Line; |
|
2665 | + } |
|
2666 | + } |
|
2667 | 2667 | |
2668 | 2668 | /** |
2669 | 2669 | * This {@link aCssMinifierPlugin} will convert a color value in rgb notation to hexadecimal notation. |
@@ -2686,51 +2686,51 @@ discard block |
||
2686 | 2686 | * @version 3.0.1 |
2687 | 2687 | */ |
2688 | 2688 | class CssConvertRgbColorsMinifierPlugin extends aCssMinifierPlugin |
2689 | - { |
|
2690 | - /** |
|
2691 | - * Regular expression matching the value. |
|
2692 | - * |
|
2693 | - * @var string |
|
2694 | - */ |
|
2695 | - private $reMatch = "/rgb\s*\(\s*([0-9%]+)\s*,\s*([0-9%]+)\s*,\s*([0-9%]+)\s*\)/iS"; |
|
2696 | - /** |
|
2697 | - * Implements {@link aCssMinifierPlugin::minify()}. |
|
2698 | - * |
|
2699 | - * @param aCssToken $token Token to process |
|
2700 | - * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
2701 | - */ |
|
2702 | - public function apply(aCssToken &$token) |
|
2703 | - { |
|
2704 | - if (stripos($token->Value, "rgb") !== false && preg_match($this->reMatch, $token->Value, $m)) |
|
2705 | - { |
|
2706 | - for ($i = 1, $l = count($m); $i < $l; $i++) |
|
2707 | - { |
|
2708 | - if (strpos("%", $m[$i]) !== false) |
|
2709 | - { |
|
2710 | - $m[$i] = substr($m[$i], 0, -1); |
|
2711 | - $m[$i] = (int) (256 * ($m[$i] / 100)); |
|
2712 | - } |
|
2713 | - $m[$i] = str_pad(dechex($m[$i]), 2, "0", STR_PAD_LEFT); |
|
2714 | - } |
|
2715 | - $token->Value = str_replace($m[0], "#" . $m[1] . $m[2] . $m[3], $token->Value); |
|
2716 | - } |
|
2717 | - return false; |
|
2718 | - } |
|
2719 | - /** |
|
2720 | - * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
2721 | - * |
|
2722 | - * @return array |
|
2723 | - */ |
|
2724 | - public function getTriggerTokens() |
|
2725 | - { |
|
2726 | - return array |
|
2727 | - ( |
|
2728 | - "CssAtFontFaceDeclarationToken", |
|
2729 | - "CssAtPageDeclarationToken", |
|
2730 | - "CssRulesetDeclarationToken" |
|
2731 | - ); |
|
2732 | - } |
|
2733 | - } |
|
2689 | + { |
|
2690 | + /** |
|
2691 | + * Regular expression matching the value. |
|
2692 | + * |
|
2693 | + * @var string |
|
2694 | + */ |
|
2695 | + private $reMatch = "/rgb\s*\(\s*([0-9%]+)\s*,\s*([0-9%]+)\s*,\s*([0-9%]+)\s*\)/iS"; |
|
2696 | + /** |
|
2697 | + * Implements {@link aCssMinifierPlugin::minify()}. |
|
2698 | + * |
|
2699 | + * @param aCssToken $token Token to process |
|
2700 | + * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
2701 | + */ |
|
2702 | + public function apply(aCssToken &$token) |
|
2703 | + { |
|
2704 | + if (stripos($token->Value, "rgb") !== false && preg_match($this->reMatch, $token->Value, $m)) |
|
2705 | + { |
|
2706 | + for ($i = 1, $l = count($m); $i < $l; $i++) |
|
2707 | + { |
|
2708 | + if (strpos("%", $m[$i]) !== false) |
|
2709 | + { |
|
2710 | + $m[$i] = substr($m[$i], 0, -1); |
|
2711 | + $m[$i] = (int) (256 * ($m[$i] / 100)); |
|
2712 | + } |
|
2713 | + $m[$i] = str_pad(dechex($m[$i]), 2, "0", STR_PAD_LEFT); |
|
2714 | + } |
|
2715 | + $token->Value = str_replace($m[0], "#" . $m[1] . $m[2] . $m[3], $token->Value); |
|
2716 | + } |
|
2717 | + return false; |
|
2718 | + } |
|
2719 | + /** |
|
2720 | + * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
2721 | + * |
|
2722 | + * @return array |
|
2723 | + */ |
|
2724 | + public function getTriggerTokens() |
|
2725 | + { |
|
2726 | + return array |
|
2727 | + ( |
|
2728 | + "CssAtFontFaceDeclarationToken", |
|
2729 | + "CssAtPageDeclarationToken", |
|
2730 | + "CssRulesetDeclarationToken" |
|
2731 | + ); |
|
2732 | + } |
|
2733 | + } |
|
2734 | 2734 | |
2735 | 2735 | /** |
2736 | 2736 | * This {@link aCssMinifierPlugin} will convert named color values to hexadecimal notation. |
@@ -2755,215 +2755,215 @@ discard block |
||
2755 | 2755 | * @version 3.0.1 |
2756 | 2756 | */ |
2757 | 2757 | class CssConvertNamedColorsMinifierPlugin extends aCssMinifierPlugin |
2758 | - { |
|
2758 | + { |
|
2759 | 2759 | |
2760 | - /** |
|
2761 | - * Regular expression matching the value. |
|
2762 | - * |
|
2763 | - * @var string |
|
2764 | - */ |
|
2765 | - private $reMatch = null; |
|
2766 | - /** |
|
2767 | - * Regular expression replacing the value. |
|
2768 | - * |
|
2769 | - * @var string |
|
2770 | - */ |
|
2771 | - private $reReplace = "\"\${1}\" . \$this->transformation[strtolower(\"\${2}\")] . \"\${3}\""; |
|
2772 | - /** |
|
2773 | - * Transformation table used by the {@link CssConvertNamedColorsMinifierPlugin::$reReplace replace regular expression}. |
|
2774 | - * |
|
2775 | - * @var array |
|
2776 | - */ |
|
2777 | - private $transformation = array |
|
2778 | - ( |
|
2779 | - "aliceblue" => "#f0f8ff", |
|
2780 | - "antiquewhite" => "#faebd7", |
|
2781 | - "aqua" => "#0ff", |
|
2782 | - "aquamarine" => "#7fffd4", |
|
2783 | - "azure" => "#f0ffff", |
|
2784 | - "beige" => "#f5f5dc", |
|
2785 | - "black" => "#000", |
|
2786 | - "blue" => "#00f", |
|
2787 | - "blueviolet" => "#8a2be2", |
|
2788 | - "brown" => "#a52a2a", |
|
2789 | - "burlywood" => "#deb887", |
|
2790 | - "cadetblue" => "#5f9ea0", |
|
2791 | - "chartreuse" => "#7fff00", |
|
2792 | - "chocolate" => "#d2691e", |
|
2793 | - "coral" => "#ff7f50", |
|
2794 | - "cornflowerblue" => "#6495ed", |
|
2795 | - "cornsilk" => "#fff8dc", |
|
2796 | - "crimson" => "#dc143c", |
|
2797 | - "darkblue" => "#00008b", |
|
2798 | - "darkcyan" => "#008b8b", |
|
2799 | - "darkgoldenrod" => "#b8860b", |
|
2800 | - "darkgray" => "#a9a9a9", |
|
2801 | - "darkgreen" => "#006400", |
|
2802 | - "darkkhaki" => "#bdb76b", |
|
2803 | - "darkmagenta" => "#8b008b", |
|
2804 | - "darkolivegreen" => "#556b2f", |
|
2805 | - "darkorange" => "#ff8c00", |
|
2806 | - "darkorchid" => "#9932cc", |
|
2807 | - "darkred" => "#8b0000", |
|
2808 | - "darksalmon" => "#e9967a", |
|
2809 | - "darkseagreen" => "#8fbc8f", |
|
2810 | - "darkslateblue" => "#483d8b", |
|
2811 | - "darkslategray" => "#2f4f4f", |
|
2812 | - "darkturquoise" => "#00ced1", |
|
2813 | - "darkviolet" => "#9400d3", |
|
2814 | - "deeppink" => "#ff1493", |
|
2815 | - "deepskyblue" => "#00bfff", |
|
2816 | - "dimgray" => "#696969", |
|
2817 | - "dodgerblue" => "#1e90ff", |
|
2818 | - "firebrick" => "#b22222", |
|
2819 | - "floralwhite" => "#fffaf0", |
|
2820 | - "forestgreen" => "#228b22", |
|
2821 | - "fuchsia" => "#f0f", |
|
2822 | - "gainsboro" => "#dcdcdc", |
|
2823 | - "ghostwhite" => "#f8f8ff", |
|
2824 | - "gold" => "#ffd700", |
|
2825 | - "goldenrod" => "#daa520", |
|
2826 | - "gray" => "#808080", |
|
2827 | - "green" => "#008000", |
|
2828 | - "greenyellow" => "#adff2f", |
|
2829 | - "honeydew" => "#f0fff0", |
|
2830 | - "hotpink" => "#ff69b4", |
|
2831 | - "indianred" => "#cd5c5c", |
|
2832 | - "indigo" => "#4b0082", |
|
2833 | - "ivory" => "#fffff0", |
|
2834 | - "khaki" => "#f0e68c", |
|
2835 | - "lavender" => "#e6e6fa", |
|
2836 | - "lavenderblush" => "#fff0f5", |
|
2837 | - "lawngreen" => "#7cfc00", |
|
2838 | - "lemonchiffon" => "#fffacd", |
|
2839 | - "lightblue" => "#add8e6", |
|
2840 | - "lightcoral" => "#f08080", |
|
2841 | - "lightcyan" => "#e0ffff", |
|
2842 | - "lightgoldenrodyellow" => "#fafad2", |
|
2843 | - "lightgreen" => "#90ee90", |
|
2844 | - "lightgrey" => "#d3d3d3", |
|
2845 | - "lightpink" => "#ffb6c1", |
|
2846 | - "lightsalmon" => "#ffa07a", |
|
2847 | - "lightseagreen" => "#20b2aa", |
|
2848 | - "lightskyblue" => "#87cefa", |
|
2849 | - "lightslategray" => "#789", |
|
2850 | - "lightsteelblue" => "#b0c4de", |
|
2851 | - "lightyellow" => "#ffffe0", |
|
2852 | - "lime" => "#0f0", |
|
2853 | - "limegreen" => "#32cd32", |
|
2854 | - "linen" => "#faf0e6", |
|
2855 | - "maroon" => "#800000", |
|
2856 | - "mediumaquamarine" => "#66cdaa", |
|
2857 | - "mediumblue" => "#0000cd", |
|
2858 | - "mediumorchid" => "#ba55d3", |
|
2859 | - "mediumpurple" => "#9370db", |
|
2860 | - "mediumseagreen" => "#3cb371", |
|
2861 | - "mediumslateblue" => "#7b68ee", |
|
2862 | - "mediumspringgreen" => "#00fa9a", |
|
2863 | - "mediumturquoise" => "#48d1cc", |
|
2864 | - "mediumvioletred" => "#c71585", |
|
2865 | - "midnightblue" => "#191970", |
|
2866 | - "mintcream" => "#f5fffa", |
|
2867 | - "mistyrose" => "#ffe4e1", |
|
2868 | - "moccasin" => "#ffe4b5", |
|
2869 | - "navajowhite" => "#ffdead", |
|
2870 | - "navy" => "#000080", |
|
2871 | - "oldlace" => "#fdf5e6", |
|
2872 | - "olive" => "#808000", |
|
2873 | - "olivedrab" => "#6b8e23", |
|
2874 | - "orange" => "#ffa500", |
|
2875 | - "orangered" => "#ff4500", |
|
2876 | - "orchid" => "#da70d6", |
|
2877 | - "palegoldenrod" => "#eee8aa", |
|
2878 | - "palegreen" => "#98fb98", |
|
2879 | - "paleturquoise" => "#afeeee", |
|
2880 | - "palevioletred" => "#db7093", |
|
2881 | - "papayawhip" => "#ffefd5", |
|
2882 | - "peachpuff" => "#ffdab9", |
|
2883 | - "peru" => "#cd853f", |
|
2884 | - "pink" => "#ffc0cb", |
|
2885 | - "plum" => "#dda0dd", |
|
2886 | - "powderblue" => "#b0e0e6", |
|
2887 | - "purple" => "#800080", |
|
2888 | - "red" => "#f00", |
|
2889 | - "rosybrown" => "#bc8f8f", |
|
2890 | - "royalblue" => "#4169e1", |
|
2891 | - "saddlebrown" => "#8b4513", |
|
2892 | - "salmon" => "#fa8072", |
|
2893 | - "sandybrown" => "#f4a460", |
|
2894 | - "seagreen" => "#2e8b57", |
|
2895 | - "seashell" => "#fff5ee", |
|
2896 | - "sienna" => "#a0522d", |
|
2897 | - "silver" => "#c0c0c0", |
|
2898 | - "skyblue" => "#87ceeb", |
|
2899 | - "slateblue" => "#6a5acd", |
|
2900 | - "slategray" => "#708090", |
|
2901 | - "snow" => "#fffafa", |
|
2902 | - "springgreen" => "#00ff7f", |
|
2903 | - "steelblue" => "#4682b4", |
|
2904 | - "tan" => "#d2b48c", |
|
2905 | - "teal" => "#008080", |
|
2906 | - "thistle" => "#d8bfd8", |
|
2907 | - "tomato" => "#ff6347", |
|
2908 | - "turquoise" => "#40e0d0", |
|
2909 | - "violet" => "#ee82ee", |
|
2910 | - "wheat" => "#f5deb3", |
|
2911 | - "white" => "#fff", |
|
2912 | - "whitesmoke" => "#f5f5f5", |
|
2913 | - "yellow" => "#ff0", |
|
2914 | - "yellowgreen" => "#9acd32" |
|
2915 | - ); |
|
2916 | - /** |
|
2917 | - * Overwrites {@link aCssMinifierPlugin::__construct()}. |
|
2918 | - * |
|
2919 | - * The constructor will create the {@link CssConvertNamedColorsMinifierPlugin::$reReplace replace regular expression} |
|
2920 | - * based on the {@link CssConvertNamedColorsMinifierPlugin::$transformation transformation table}. |
|
2921 | - * |
|
2922 | - * @param CssMinifier $minifier The CssMinifier object of this plugin. |
|
2923 | - * @param array $configuration Plugin configuration [optional] |
|
2924 | - * @return void |
|
2925 | - */ |
|
2926 | - public function __construct(CssMinifier $minifier, array $configuration = array()) |
|
2927 | - { |
|
2928 | - $this->reMatch = "/(^|\s)+(" . implode("|", array_keys($this->transformation)) . ")(\s|$)+/eiS"; |
|
2929 | - parent::__construct($minifier, $configuration); |
|
2930 | - } |
|
2931 | - /** |
|
2932 | - * Implements {@link aCssMinifierPlugin::minify()}. |
|
2933 | - * |
|
2934 | - * @param aCssToken $token Token to process |
|
2935 | - * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
2936 | - */ |
|
2937 | - public function apply(aCssToken &$token) |
|
2938 | - { |
|
2939 | - $lcValue = strtolower($token->Value); |
|
2940 | - // Declaration value equals a value in the transformation table => simple replace |
|
2941 | - if (isset($this->transformation[$lcValue])) |
|
2942 | - { |
|
2943 | - $token->Value = $this->transformation[$lcValue]; |
|
2944 | - } |
|
2945 | - // Declaration value contains a value in the transformation table => regular expression replace |
|
2946 | - elseif (preg_match($this->reMatch, $token->Value)) |
|
2947 | - { |
|
2948 | - $token->Value = preg_replace($this->reMatch, $this->reReplace, $token->Value); |
|
2949 | - } |
|
2950 | - return false; |
|
2951 | - } |
|
2952 | - /** |
|
2953 | - * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
2954 | - * |
|
2955 | - * @return array |
|
2956 | - */ |
|
2957 | - public function getTriggerTokens() |
|
2958 | - { |
|
2959 | - return array |
|
2960 | - ( |
|
2961 | - "CssAtFontFaceDeclarationToken", |
|
2962 | - "CssAtPageDeclarationToken", |
|
2963 | - "CssRulesetDeclarationToken" |
|
2964 | - ); |
|
2965 | - } |
|
2966 | - } |
|
2760 | + /** |
|
2761 | + * Regular expression matching the value. |
|
2762 | + * |
|
2763 | + * @var string |
|
2764 | + */ |
|
2765 | + private $reMatch = null; |
|
2766 | + /** |
|
2767 | + * Regular expression replacing the value. |
|
2768 | + * |
|
2769 | + * @var string |
|
2770 | + */ |
|
2771 | + private $reReplace = "\"\${1}\" . \$this->transformation[strtolower(\"\${2}\")] . \"\${3}\""; |
|
2772 | + /** |
|
2773 | + * Transformation table used by the {@link CssConvertNamedColorsMinifierPlugin::$reReplace replace regular expression}. |
|
2774 | + * |
|
2775 | + * @var array |
|
2776 | + */ |
|
2777 | + private $transformation = array |
|
2778 | + ( |
|
2779 | + "aliceblue" => "#f0f8ff", |
|
2780 | + "antiquewhite" => "#faebd7", |
|
2781 | + "aqua" => "#0ff", |
|
2782 | + "aquamarine" => "#7fffd4", |
|
2783 | + "azure" => "#f0ffff", |
|
2784 | + "beige" => "#f5f5dc", |
|
2785 | + "black" => "#000", |
|
2786 | + "blue" => "#00f", |
|
2787 | + "blueviolet" => "#8a2be2", |
|
2788 | + "brown" => "#a52a2a", |
|
2789 | + "burlywood" => "#deb887", |
|
2790 | + "cadetblue" => "#5f9ea0", |
|
2791 | + "chartreuse" => "#7fff00", |
|
2792 | + "chocolate" => "#d2691e", |
|
2793 | + "coral" => "#ff7f50", |
|
2794 | + "cornflowerblue" => "#6495ed", |
|
2795 | + "cornsilk" => "#fff8dc", |
|
2796 | + "crimson" => "#dc143c", |
|
2797 | + "darkblue" => "#00008b", |
|
2798 | + "darkcyan" => "#008b8b", |
|
2799 | + "darkgoldenrod" => "#b8860b", |
|
2800 | + "darkgray" => "#a9a9a9", |
|
2801 | + "darkgreen" => "#006400", |
|
2802 | + "darkkhaki" => "#bdb76b", |
|
2803 | + "darkmagenta" => "#8b008b", |
|
2804 | + "darkolivegreen" => "#556b2f", |
|
2805 | + "darkorange" => "#ff8c00", |
|
2806 | + "darkorchid" => "#9932cc", |
|
2807 | + "darkred" => "#8b0000", |
|
2808 | + "darksalmon" => "#e9967a", |
|
2809 | + "darkseagreen" => "#8fbc8f", |
|
2810 | + "darkslateblue" => "#483d8b", |
|
2811 | + "darkslategray" => "#2f4f4f", |
|
2812 | + "darkturquoise" => "#00ced1", |
|
2813 | + "darkviolet" => "#9400d3", |
|
2814 | + "deeppink" => "#ff1493", |
|
2815 | + "deepskyblue" => "#00bfff", |
|
2816 | + "dimgray" => "#696969", |
|
2817 | + "dodgerblue" => "#1e90ff", |
|
2818 | + "firebrick" => "#b22222", |
|
2819 | + "floralwhite" => "#fffaf0", |
|
2820 | + "forestgreen" => "#228b22", |
|
2821 | + "fuchsia" => "#f0f", |
|
2822 | + "gainsboro" => "#dcdcdc", |
|
2823 | + "ghostwhite" => "#f8f8ff", |
|
2824 | + "gold" => "#ffd700", |
|
2825 | + "goldenrod" => "#daa520", |
|
2826 | + "gray" => "#808080", |
|
2827 | + "green" => "#008000", |
|
2828 | + "greenyellow" => "#adff2f", |
|
2829 | + "honeydew" => "#f0fff0", |
|
2830 | + "hotpink" => "#ff69b4", |
|
2831 | + "indianred" => "#cd5c5c", |
|
2832 | + "indigo" => "#4b0082", |
|
2833 | + "ivory" => "#fffff0", |
|
2834 | + "khaki" => "#f0e68c", |
|
2835 | + "lavender" => "#e6e6fa", |
|
2836 | + "lavenderblush" => "#fff0f5", |
|
2837 | + "lawngreen" => "#7cfc00", |
|
2838 | + "lemonchiffon" => "#fffacd", |
|
2839 | + "lightblue" => "#add8e6", |
|
2840 | + "lightcoral" => "#f08080", |
|
2841 | + "lightcyan" => "#e0ffff", |
|
2842 | + "lightgoldenrodyellow" => "#fafad2", |
|
2843 | + "lightgreen" => "#90ee90", |
|
2844 | + "lightgrey" => "#d3d3d3", |
|
2845 | + "lightpink" => "#ffb6c1", |
|
2846 | + "lightsalmon" => "#ffa07a", |
|
2847 | + "lightseagreen" => "#20b2aa", |
|
2848 | + "lightskyblue" => "#87cefa", |
|
2849 | + "lightslategray" => "#789", |
|
2850 | + "lightsteelblue" => "#b0c4de", |
|
2851 | + "lightyellow" => "#ffffe0", |
|
2852 | + "lime" => "#0f0", |
|
2853 | + "limegreen" => "#32cd32", |
|
2854 | + "linen" => "#faf0e6", |
|
2855 | + "maroon" => "#800000", |
|
2856 | + "mediumaquamarine" => "#66cdaa", |
|
2857 | + "mediumblue" => "#0000cd", |
|
2858 | + "mediumorchid" => "#ba55d3", |
|
2859 | + "mediumpurple" => "#9370db", |
|
2860 | + "mediumseagreen" => "#3cb371", |
|
2861 | + "mediumslateblue" => "#7b68ee", |
|
2862 | + "mediumspringgreen" => "#00fa9a", |
|
2863 | + "mediumturquoise" => "#48d1cc", |
|
2864 | + "mediumvioletred" => "#c71585", |
|
2865 | + "midnightblue" => "#191970", |
|
2866 | + "mintcream" => "#f5fffa", |
|
2867 | + "mistyrose" => "#ffe4e1", |
|
2868 | + "moccasin" => "#ffe4b5", |
|
2869 | + "navajowhite" => "#ffdead", |
|
2870 | + "navy" => "#000080", |
|
2871 | + "oldlace" => "#fdf5e6", |
|
2872 | + "olive" => "#808000", |
|
2873 | + "olivedrab" => "#6b8e23", |
|
2874 | + "orange" => "#ffa500", |
|
2875 | + "orangered" => "#ff4500", |
|
2876 | + "orchid" => "#da70d6", |
|
2877 | + "palegoldenrod" => "#eee8aa", |
|
2878 | + "palegreen" => "#98fb98", |
|
2879 | + "paleturquoise" => "#afeeee", |
|
2880 | + "palevioletred" => "#db7093", |
|
2881 | + "papayawhip" => "#ffefd5", |
|
2882 | + "peachpuff" => "#ffdab9", |
|
2883 | + "peru" => "#cd853f", |
|
2884 | + "pink" => "#ffc0cb", |
|
2885 | + "plum" => "#dda0dd", |
|
2886 | + "powderblue" => "#b0e0e6", |
|
2887 | + "purple" => "#800080", |
|
2888 | + "red" => "#f00", |
|
2889 | + "rosybrown" => "#bc8f8f", |
|
2890 | + "royalblue" => "#4169e1", |
|
2891 | + "saddlebrown" => "#8b4513", |
|
2892 | + "salmon" => "#fa8072", |
|
2893 | + "sandybrown" => "#f4a460", |
|
2894 | + "seagreen" => "#2e8b57", |
|
2895 | + "seashell" => "#fff5ee", |
|
2896 | + "sienna" => "#a0522d", |
|
2897 | + "silver" => "#c0c0c0", |
|
2898 | + "skyblue" => "#87ceeb", |
|
2899 | + "slateblue" => "#6a5acd", |
|
2900 | + "slategray" => "#708090", |
|
2901 | + "snow" => "#fffafa", |
|
2902 | + "springgreen" => "#00ff7f", |
|
2903 | + "steelblue" => "#4682b4", |
|
2904 | + "tan" => "#d2b48c", |
|
2905 | + "teal" => "#008080", |
|
2906 | + "thistle" => "#d8bfd8", |
|
2907 | + "tomato" => "#ff6347", |
|
2908 | + "turquoise" => "#40e0d0", |
|
2909 | + "violet" => "#ee82ee", |
|
2910 | + "wheat" => "#f5deb3", |
|
2911 | + "white" => "#fff", |
|
2912 | + "whitesmoke" => "#f5f5f5", |
|
2913 | + "yellow" => "#ff0", |
|
2914 | + "yellowgreen" => "#9acd32" |
|
2915 | + ); |
|
2916 | + /** |
|
2917 | + * Overwrites {@link aCssMinifierPlugin::__construct()}. |
|
2918 | + * |
|
2919 | + * The constructor will create the {@link CssConvertNamedColorsMinifierPlugin::$reReplace replace regular expression} |
|
2920 | + * based on the {@link CssConvertNamedColorsMinifierPlugin::$transformation transformation table}. |
|
2921 | + * |
|
2922 | + * @param CssMinifier $minifier The CssMinifier object of this plugin. |
|
2923 | + * @param array $configuration Plugin configuration [optional] |
|
2924 | + * @return void |
|
2925 | + */ |
|
2926 | + public function __construct(CssMinifier $minifier, array $configuration = array()) |
|
2927 | + { |
|
2928 | + $this->reMatch = "/(^|\s)+(" . implode("|", array_keys($this->transformation)) . ")(\s|$)+/eiS"; |
|
2929 | + parent::__construct($minifier, $configuration); |
|
2930 | + } |
|
2931 | + /** |
|
2932 | + * Implements {@link aCssMinifierPlugin::minify()}. |
|
2933 | + * |
|
2934 | + * @param aCssToken $token Token to process |
|
2935 | + * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
2936 | + */ |
|
2937 | + public function apply(aCssToken &$token) |
|
2938 | + { |
|
2939 | + $lcValue = strtolower($token->Value); |
|
2940 | + // Declaration value equals a value in the transformation table => simple replace |
|
2941 | + if (isset($this->transformation[$lcValue])) |
|
2942 | + { |
|
2943 | + $token->Value = $this->transformation[$lcValue]; |
|
2944 | + } |
|
2945 | + // Declaration value contains a value in the transformation table => regular expression replace |
|
2946 | + elseif (preg_match($this->reMatch, $token->Value)) |
|
2947 | + { |
|
2948 | + $token->Value = preg_replace($this->reMatch, $this->reReplace, $token->Value); |
|
2949 | + } |
|
2950 | + return false; |
|
2951 | + } |
|
2952 | + /** |
|
2953 | + * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
2954 | + * |
|
2955 | + * @return array |
|
2956 | + */ |
|
2957 | + public function getTriggerTokens() |
|
2958 | + { |
|
2959 | + return array |
|
2960 | + ( |
|
2961 | + "CssAtFontFaceDeclarationToken", |
|
2962 | + "CssAtPageDeclarationToken", |
|
2963 | + "CssRulesetDeclarationToken" |
|
2964 | + ); |
|
2965 | + } |
|
2966 | + } |
|
2967 | 2967 | |
2968 | 2968 | /** |
2969 | 2969 | * This {@link aCssMinifierFilter minifier filter} triggers on CSS Level 3 properties and will add declaration tokens |
@@ -2977,333 +2977,333 @@ discard block |
||
2977 | 2977 | * @version 3.0.1 |
2978 | 2978 | */ |
2979 | 2979 | class CssConvertLevel3PropertiesMinifierFilter extends aCssMinifierFilter |
2980 | - { |
|
2981 | - /** |
|
2982 | - * Css property transformations table. Used to convert CSS3 and proprietary properties to the browser-specific |
|
2983 | - * counterparts. |
|
2984 | - * |
|
2985 | - * @var array |
|
2986 | - */ |
|
2987 | - private $transformations = array |
|
2988 | - ( |
|
2989 | - // Property Array(Mozilla, Webkit, Opera, Internet Explorer); NULL values are placeholders and will get ignored |
|
2990 | - "animation" => array(null, "-webkit-animation", null, null), |
|
2991 | - "animation-delay" => array(null, "-webkit-animation-delay", null, null), |
|
2992 | - "animation-direction" => array(null, "-webkit-animation-direction", null, null), |
|
2993 | - "animation-duration" => array(null, "-webkit-animation-duration", null, null), |
|
2994 | - "animation-fill-mode" => array(null, "-webkit-animation-fill-mode", null, null), |
|
2995 | - "animation-iteration-count" => array(null, "-webkit-animation-iteration-count", null, null), |
|
2996 | - "animation-name" => array(null, "-webkit-animation-name", null, null), |
|
2997 | - "animation-play-state" => array(null, "-webkit-animation-play-state", null, null), |
|
2998 | - "animation-timing-function" => array(null, "-webkit-animation-timing-function", null, null), |
|
2999 | - "appearance" => array("-moz-appearance", "-webkit-appearance", null, null), |
|
3000 | - "backface-visibility" => array(null, "-webkit-backface-visibility", null, null), |
|
3001 | - "background-clip" => array(null, "-webkit-background-clip", null, null), |
|
3002 | - "background-composite" => array(null, "-webkit-background-composite", null, null), |
|
3003 | - "background-inline-policy" => array("-moz-background-inline-policy", null, null, null), |
|
3004 | - "background-origin" => array(null, "-webkit-background-origin", null, null), |
|
3005 | - "background-position-x" => array(null, null, null, "-ms-background-position-x"), |
|
3006 | - "background-position-y" => array(null, null, null, "-ms-background-position-y"), |
|
3007 | - "background-size" => array(null, "-webkit-background-size", null, null), |
|
3008 | - "behavior" => array(null, null, null, "-ms-behavior"), |
|
3009 | - "binding" => array("-moz-binding", null, null, null), |
|
3010 | - "border-after" => array(null, "-webkit-border-after", null, null), |
|
3011 | - "border-after-color" => array(null, "-webkit-border-after-color", null, null), |
|
3012 | - "border-after-style" => array(null, "-webkit-border-after-style", null, null), |
|
3013 | - "border-after-width" => array(null, "-webkit-border-after-width", null, null), |
|
3014 | - "border-before" => array(null, "-webkit-border-before", null, null), |
|
3015 | - "border-before-color" => array(null, "-webkit-border-before-color", null, null), |
|
3016 | - "border-before-style" => array(null, "-webkit-border-before-style", null, null), |
|
3017 | - "border-before-width" => array(null, "-webkit-border-before-width", null, null), |
|
3018 | - "border-border-bottom-colors" => array("-moz-border-bottom-colors", null, null, null), |
|
3019 | - "border-bottom-left-radius" => array("-moz-border-radius-bottomleft", "-webkit-border-bottom-left-radius", null, null), |
|
3020 | - "border-bottom-right-radius" => array("-moz-border-radius-bottomright", "-webkit-border-bottom-right-radius", null, null), |
|
3021 | - "border-end" => array("-moz-border-end", "-webkit-border-end", null, null), |
|
3022 | - "border-end-color" => array("-moz-border-end-color", "-webkit-border-end-color", null, null), |
|
3023 | - "border-end-style" => array("-moz-border-end-style", "-webkit-border-end-style", null, null), |
|
3024 | - "border-end-width" => array("-moz-border-end-width", "-webkit-border-end-width", null, null), |
|
3025 | - "border-fit" => array(null, "-webkit-border-fit", null, null), |
|
3026 | - "border-horizontal-spacing" => array(null, "-webkit-border-horizontal-spacing", null, null), |
|
3027 | - "border-image" => array("-moz-border-image", "-webkit-border-image", null, null), |
|
3028 | - "border-left-colors" => array("-moz-border-left-colors", null, null, null), |
|
3029 | - "border-radius" => array("-moz-border-radius", "-webkit-border-radius", null, null), |
|
3030 | - "border-border-right-colors" => array("-moz-border-right-colors", null, null, null), |
|
3031 | - "border-start" => array("-moz-border-start", "-webkit-border-start", null, null), |
|
3032 | - "border-start-color" => array("-moz-border-start-color", "-webkit-border-start-color", null, null), |
|
3033 | - "border-start-style" => array("-moz-border-start-style", "-webkit-border-start-style", null, null), |
|
3034 | - "border-start-width" => array("-moz-border-start-width", "-webkit-border-start-width", null, null), |
|
3035 | - "border-top-colors" => array("-moz-border-top-colors", null, null, null), |
|
3036 | - "border-top-left-radius" => array("-moz-border-radius-topleft", "-webkit-border-top-left-radius", null, null), |
|
3037 | - "border-top-right-radius" => array("-moz-border-radius-topright", "-webkit-border-top-right-radius", null, null), |
|
3038 | - "border-vertical-spacing" => array(null, "-webkit-border-vertical-spacing", null, null), |
|
3039 | - "box-align" => array("-moz-box-align", "-webkit-box-align", null, null), |
|
3040 | - "box-direction" => array("-moz-box-direction", "-webkit-box-direction", null, null), |
|
3041 | - "box-flex" => array("-moz-box-flex", "-webkit-box-flex", null, null), |
|
3042 | - "box-flex-group" => array(null, "-webkit-box-flex-group", null, null), |
|
3043 | - "box-flex-lines" => array(null, "-webkit-box-flex-lines", null, null), |
|
3044 | - "box-ordinal-group" => array("-moz-box-ordinal-group", "-webkit-box-ordinal-group", null, null), |
|
3045 | - "box-orient" => array("-moz-box-orient", "-webkit-box-orient", null, null), |
|
3046 | - "box-pack" => array("-moz-box-pack", "-webkit-box-pack", null, null), |
|
3047 | - "box-reflect" => array(null, "-webkit-box-reflect", null, null), |
|
3048 | - "box-shadow" => array("-moz-box-shadow", "-webkit-box-shadow", null, null), |
|
3049 | - "box-sizing" => array("-moz-box-sizing", null, null, null), |
|
3050 | - "color-correction" => array(null, "-webkit-color-correction", null, null), |
|
3051 | - "column-break-after" => array(null, "-webkit-column-break-after", null, null), |
|
3052 | - "column-break-before" => array(null, "-webkit-column-break-before", null, null), |
|
3053 | - "column-break-inside" => array(null, "-webkit-column-break-inside", null, null), |
|
3054 | - "column-count" => array("-moz-column-count", "-webkit-column-count", null, null), |
|
3055 | - "column-gap" => array("-moz-column-gap", "-webkit-column-gap", null, null), |
|
3056 | - "column-rule" => array("-moz-column-rule", "-webkit-column-rule", null, null), |
|
3057 | - "column-rule-color" => array("-moz-column-rule-color", "-webkit-column-rule-color", null, null), |
|
3058 | - "column-rule-style" => array("-moz-column-rule-style", "-webkit-column-rule-style", null, null), |
|
3059 | - "column-rule-width" => array("-moz-column-rule-width", "-webkit-column-rule-width", null, null), |
|
3060 | - "column-span" => array(null, "-webkit-column-span", null, null), |
|
3061 | - "column-width" => array("-moz-column-width", "-webkit-column-width", null, null), |
|
3062 | - "columns" => array(null, "-webkit-columns", null, null), |
|
3063 | - "filter" => array(__CLASS__, "filter"), |
|
3064 | - "float-edge" => array("-moz-float-edge", null, null, null), |
|
3065 | - "font-feature-settings" => array("-moz-font-feature-settings", null, null, null), |
|
3066 | - "font-language-override" => array("-moz-font-language-override", null, null, null), |
|
3067 | - "font-size-delta" => array(null, "-webkit-font-size-delta", null, null), |
|
3068 | - "font-smoothing" => array(null, "-webkit-font-smoothing", null, null), |
|
3069 | - "force-broken-image-icon" => array("-moz-force-broken-image-icon", null, null, null), |
|
3070 | - "highlight" => array(null, "-webkit-highlight", null, null), |
|
3071 | - "hyphenate-character" => array(null, "-webkit-hyphenate-character", null, null), |
|
3072 | - "hyphenate-locale" => array(null, "-webkit-hyphenate-locale", null, null), |
|
3073 | - "hyphens" => array(null, "-webkit-hyphens", null, null), |
|
3074 | - "force-broken-image-icon" => array("-moz-image-region", null, null, null), |
|
3075 | - "ime-mode" => array(null, null, null, "-ms-ime-mode"), |
|
3076 | - "interpolation-mode" => array(null, null, null, "-ms-interpolation-mode"), |
|
3077 | - "layout-flow" => array(null, null, null, "-ms-layout-flow"), |
|
3078 | - "layout-grid" => array(null, null, null, "-ms-layout-grid"), |
|
3079 | - "layout-grid-char" => array(null, null, null, "-ms-layout-grid-char"), |
|
3080 | - "layout-grid-line" => array(null, null, null, "-ms-layout-grid-line"), |
|
3081 | - "layout-grid-mode" => array(null, null, null, "-ms-layout-grid-mode"), |
|
3082 | - "layout-grid-type" => array(null, null, null, "-ms-layout-grid-type"), |
|
3083 | - "line-break" => array(null, "-webkit-line-break", null, "-ms-line-break"), |
|
3084 | - "line-clamp" => array(null, "-webkit-line-clamp", null, null), |
|
3085 | - "line-grid-mode" => array(null, null, null, "-ms-line-grid-mode"), |
|
3086 | - "logical-height" => array(null, "-webkit-logical-height", null, null), |
|
3087 | - "logical-width" => array(null, "-webkit-logical-width", null, null), |
|
3088 | - "margin-after" => array(null, "-webkit-margin-after", null, null), |
|
3089 | - "margin-after-collapse" => array(null, "-webkit-margin-after-collapse", null, null), |
|
3090 | - "margin-before" => array(null, "-webkit-margin-before", null, null), |
|
3091 | - "margin-before-collapse" => array(null, "-webkit-margin-before-collapse", null, null), |
|
3092 | - "margin-bottom-collapse" => array(null, "-webkit-margin-bottom-collapse", null, null), |
|
3093 | - "margin-collapse" => array(null, "-webkit-margin-collapse", null, null), |
|
3094 | - "margin-end" => array("-moz-margin-end", "-webkit-margin-end", null, null), |
|
3095 | - "margin-start" => array("-moz-margin-start", "-webkit-margin-start", null, null), |
|
3096 | - "margin-top-collapse" => array(null, "-webkit-margin-top-collapse", null, null), |
|
3097 | - "marquee " => array(null, "-webkit-marquee", null, null), |
|
3098 | - "marquee-direction" => array(null, "-webkit-marquee-direction", null, null), |
|
3099 | - "marquee-increment" => array(null, "-webkit-marquee-increment", null, null), |
|
3100 | - "marquee-repetition" => array(null, "-webkit-marquee-repetition", null, null), |
|
3101 | - "marquee-speed" => array(null, "-webkit-marquee-speed", null, null), |
|
3102 | - "marquee-style" => array(null, "-webkit-marquee-style", null, null), |
|
3103 | - "mask" => array(null, "-webkit-mask", null, null), |
|
3104 | - "mask-attachment" => array(null, "-webkit-mask-attachment", null, null), |
|
3105 | - "mask-box-image" => array(null, "-webkit-mask-box-image", null, null), |
|
3106 | - "mask-clip" => array(null, "-webkit-mask-clip", null, null), |
|
3107 | - "mask-composite" => array(null, "-webkit-mask-composite", null, null), |
|
3108 | - "mask-image" => array(null, "-webkit-mask-image", null, null), |
|
3109 | - "mask-origin" => array(null, "-webkit-mask-origin", null, null), |
|
3110 | - "mask-position" => array(null, "-webkit-mask-position", null, null), |
|
3111 | - "mask-position-x" => array(null, "-webkit-mask-position-x", null, null), |
|
3112 | - "mask-position-y" => array(null, "-webkit-mask-position-y", null, null), |
|
3113 | - "mask-repeat" => array(null, "-webkit-mask-repeat", null, null), |
|
3114 | - "mask-repeat-x" => array(null, "-webkit-mask-repeat-x", null, null), |
|
3115 | - "mask-repeat-y" => array(null, "-webkit-mask-repeat-y", null, null), |
|
3116 | - "mask-size" => array(null, "-webkit-mask-size", null, null), |
|
3117 | - "match-nearest-mail-blockquote-color" => array(null, "-webkit-match-nearest-mail-blockquote-color", null, null), |
|
3118 | - "max-logical-height" => array(null, "-webkit-max-logical-height", null, null), |
|
3119 | - "max-logical-width" => array(null, "-webkit-max-logical-width", null, null), |
|
3120 | - "min-logical-height" => array(null, "-webkit-min-logical-height", null, null), |
|
3121 | - "min-logical-width" => array(null, "-webkit-min-logical-width", null, null), |
|
3122 | - "object-fit" => array(null, null, "-o-object-fit", null), |
|
3123 | - "object-position" => array(null, null, "-o-object-position", null), |
|
3124 | - "opacity" => array(__CLASS__, "opacity"), |
|
3125 | - "outline-radius" => array("-moz-outline-radius", null, null, null), |
|
3126 | - "outline-bottom-left-radius" => array("-moz-outline-radius-bottomleft", null, null, null), |
|
3127 | - "outline-bottom-right-radius" => array("-moz-outline-radius-bottomright", null, null, null), |
|
3128 | - "outline-top-left-radius" => array("-moz-outline-radius-topleft", null, null, null), |
|
3129 | - "outline-top-right-radius" => array("-moz-outline-radius-topright", null, null, null), |
|
3130 | - "padding-after" => array(null, "-webkit-padding-after", null, null), |
|
3131 | - "padding-before" => array(null, "-webkit-padding-before", null, null), |
|
3132 | - "padding-end" => array("-moz-padding-end", "-webkit-padding-end", null, null), |
|
3133 | - "padding-start" => array("-moz-padding-start", "-webkit-padding-start", null, null), |
|
3134 | - "perspective" => array(null, "-webkit-perspective", null, null), |
|
3135 | - "perspective-origin" => array(null, "-webkit-perspective-origin", null, null), |
|
3136 | - "perspective-origin-x" => array(null, "-webkit-perspective-origin-x", null, null), |
|
3137 | - "perspective-origin-y" => array(null, "-webkit-perspective-origin-y", null, null), |
|
3138 | - "rtl-ordering" => array(null, "-webkit-rtl-ordering", null, null), |
|
3139 | - "scrollbar-3dlight-color" => array(null, null, null, "-ms-scrollbar-3dlight-color"), |
|
3140 | - "scrollbar-arrow-color" => array(null, null, null, "-ms-scrollbar-arrow-color"), |
|
3141 | - "scrollbar-base-color" => array(null, null, null, "-ms-scrollbar-base-color"), |
|
3142 | - "scrollbar-darkshadow-color" => array(null, null, null, "-ms-scrollbar-darkshadow-color"), |
|
3143 | - "scrollbar-face-color" => array(null, null, null, "-ms-scrollbar-face-color"), |
|
3144 | - "scrollbar-highlight-color" => array(null, null, null, "-ms-scrollbar-highlight-color"), |
|
3145 | - "scrollbar-shadow-color" => array(null, null, null, "-ms-scrollbar-shadow-color"), |
|
3146 | - "scrollbar-track-color" => array(null, null, null, "-ms-scrollbar-track-color"), |
|
3147 | - "stack-sizing" => array("-moz-stack-sizing", null, null, null), |
|
3148 | - "svg-shadow" => array(null, "-webkit-svg-shadow", null, null), |
|
3149 | - "tab-size" => array("-moz-tab-size", null, "-o-tab-size", null), |
|
3150 | - "table-baseline" => array(null, null, "-o-table-baseline", null), |
|
3151 | - "text-align-last" => array(null, null, null, "-ms-text-align-last"), |
|
3152 | - "text-autospace" => array(null, null, null, "-ms-text-autospace"), |
|
3153 | - "text-combine" => array(null, "-webkit-text-combine", null, null), |
|
3154 | - "text-decorations-in-effect" => array(null, "-webkit-text-decorations-in-effect", null, null), |
|
3155 | - "text-emphasis" => array(null, "-webkit-text-emphasis", null, null), |
|
3156 | - "text-emphasis-color" => array(null, "-webkit-text-emphasis-color", null, null), |
|
3157 | - "text-emphasis-position" => array(null, "-webkit-text-emphasis-position", null, null), |
|
3158 | - "text-emphasis-style" => array(null, "-webkit-text-emphasis-style", null, null), |
|
3159 | - "text-fill-color" => array(null, "-webkit-text-fill-color", null, null), |
|
3160 | - "text-justify" => array(null, null, null, "-ms-text-justify"), |
|
3161 | - "text-kashida-space" => array(null, null, null, "-ms-text-kashida-space"), |
|
3162 | - "text-overflow" => array(null, null, "-o-text-overflow", "-ms-text-overflow"), |
|
3163 | - "text-security" => array(null, "-webkit-text-security", null, null), |
|
3164 | - "text-size-adjust" => array(null, "-webkit-text-size-adjust", null, "-ms-text-size-adjust"), |
|
3165 | - "text-stroke" => array(null, "-webkit-text-stroke", null, null), |
|
3166 | - "text-stroke-color" => array(null, "-webkit-text-stroke-color", null, null), |
|
3167 | - "text-stroke-width" => array(null, "-webkit-text-stroke-width", null, null), |
|
3168 | - "text-underline-position" => array(null, null, null, "-ms-text-underline-position"), |
|
3169 | - "transform" => array("-moz-transform", "-webkit-transform", "-o-transform", null), |
|
3170 | - "transform-origin" => array("-moz-transform-origin", "-webkit-transform-origin", "-o-transform-origin", null), |
|
3171 | - "transform-origin-x" => array(null, "-webkit-transform-origin-x", null, null), |
|
3172 | - "transform-origin-y" => array(null, "-webkit-transform-origin-y", null, null), |
|
3173 | - "transform-origin-z" => array(null, "-webkit-transform-origin-z", null, null), |
|
3174 | - "transform-style" => array(null, "-webkit-transform-style", null, null), |
|
3175 | - "transition" => array("-moz-transition", "-webkit-transition", "-o-transition", null), |
|
3176 | - "transition-delay" => array("-moz-transition-delay", "-webkit-transition-delay", "-o-transition-delay", null), |
|
3177 | - "transition-duration" => array("-moz-transition-duration", "-webkit-transition-duration", "-o-transition-duration", null), |
|
3178 | - "transition-property" => array("-moz-transition-property", "-webkit-transition-property", "-o-transition-property", null), |
|
3179 | - "transition-timing-function" => array("-moz-transition-timing-function", "-webkit-transition-timing-function", "-o-transition-timing-function", null), |
|
3180 | - "user-drag" => array(null, "-webkit-user-drag", null, null), |
|
3181 | - "user-focus" => array("-moz-user-focus", null, null, null), |
|
3182 | - "user-input" => array("-moz-user-input", null, null, null), |
|
3183 | - "user-modify" => array("-moz-user-modify", "-webkit-user-modify", null, null), |
|
3184 | - "user-select" => array("-moz-user-select", "-webkit-user-select", null, null), |
|
3185 | - "white-space" => array(__CLASS__, "whiteSpace"), |
|
3186 | - "window-shadow" => array("-moz-window-shadow", null, null, null), |
|
3187 | - "word-break" => array(null, null, null, "-ms-word-break"), |
|
3188 | - "word-wrap" => array(null, null, null, "-ms-word-wrap"), |
|
3189 | - "writing-mode" => array(null, "-webkit-writing-mode", null, "-ms-writing-mode"), |
|
3190 | - "zoom" => array(null, null, null, "-ms-zoom") |
|
3191 | - ); |
|
3192 | - /** |
|
3193 | - * Implements {@link aCssMinifierFilter::filter()}. |
|
3194 | - * |
|
3195 | - * @param array $tokens Array of objects of type aCssToken |
|
3196 | - * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
3197 | - */ |
|
3198 | - public function apply(array &$tokens) |
|
3199 | - { |
|
3200 | - $r = 0; |
|
3201 | - $transformations = &$this->transformations; |
|
3202 | - for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
3203 | - { |
|
3204 | - if (get_class($tokens[$i]) === "CssRulesetDeclarationToken") |
|
3205 | - { |
|
3206 | - $tProperty = $tokens[$i]->Property; |
|
3207 | - if (isset($transformations[$tProperty])) |
|
3208 | - { |
|
3209 | - $result = array(); |
|
3210 | - if (is_callable($transformations[$tProperty])) |
|
3211 | - { |
|
3212 | - $result = call_user_func_array($transformations[$tProperty], array($tokens[$i])); |
|
3213 | - if (!is_array($result) && is_object($result)) |
|
3214 | - { |
|
3215 | - $result = array($result); |
|
3216 | - } |
|
3217 | - } |
|
3218 | - else |
|
3219 | - { |
|
3220 | - $tValue = $tokens[$i]->Value; |
|
3221 | - $tMediaTypes = $tokens[$i]->MediaTypes; |
|
3222 | - foreach ($transformations[$tProperty] as $property) |
|
3223 | - { |
|
3224 | - if ($property !== null) |
|
3225 | - { |
|
3226 | - $result[] = new CssRulesetDeclarationToken($property, $tValue, $tMediaTypes); |
|
3227 | - } |
|
3228 | - } |
|
3229 | - } |
|
3230 | - if (count($result) > 0) |
|
3231 | - { |
|
3232 | - array_splice($tokens, $i + 1, 0, $result); |
|
3233 | - $i += count($result); |
|
3234 | - $l += count($result); |
|
3235 | - } |
|
3236 | - } |
|
3237 | - } |
|
3238 | - } |
|
3239 | - return $r; |
|
3240 | - } |
|
3241 | - /** |
|
3242 | - * Transforms the Internet Explorer specific declaration property "filter" to Internet Explorer 8+ compatible |
|
3243 | - * declaratiopn property "-ms-filter". |
|
3244 | - * |
|
3245 | - * @param aCssToken $token |
|
3246 | - * @return array |
|
3247 | - */ |
|
3248 | - private static function filter($token) |
|
3249 | - { |
|
3250 | - $r = array |
|
3251 | - ( |
|
3252 | - new CssRulesetDeclarationToken("-ms-filter", "\"" . $token->Value . "\"", $token->MediaTypes), |
|
3253 | - ); |
|
3254 | - return $r; |
|
3255 | - } |
|
3256 | - /** |
|
3257 | - * Transforms "opacity: {value}" into browser specific counterparts. |
|
3258 | - * |
|
3259 | - * @param aCssToken $token |
|
3260 | - * @return array |
|
3261 | - */ |
|
3262 | - private static function opacity($token) |
|
3263 | - { |
|
3264 | - // Calculate the value for Internet Explorer filter statement |
|
3265 | - $ieValue = (int) ((float) $token->Value * 100); |
|
3266 | - $r = array |
|
3267 | - ( |
|
3268 | - // Internet Explorer >= 8 |
|
3269 | - new CssRulesetDeclarationToken("-ms-filter", "\"alpha(opacity=" . $ieValue . ")\"", $token->MediaTypes), |
|
3270 | - // Internet Explorer >= 4 <= 7 |
|
3271 | - new CssRulesetDeclarationToken("filter", "alpha(opacity=" . $ieValue . ")", $token->MediaTypes), |
|
3272 | - new CssRulesetDeclarationToken("zoom", "1", $token->MediaTypes) |
|
3273 | - ); |
|
3274 | - return $r; |
|
3275 | - } |
|
3276 | - /** |
|
3277 | - * Transforms "white-space: pre-wrap" into browser specific counterparts. |
|
3278 | - * |
|
3279 | - * @param aCssToken $token |
|
3280 | - * @return array |
|
3281 | - */ |
|
3282 | - private static function whiteSpace($token) |
|
3283 | - { |
|
3284 | - if (strtolower($token->Value) === "pre-wrap") |
|
3285 | - { |
|
3286 | - $r = array |
|
3287 | - ( |
|
3288 | - // Firefox < 3 |
|
3289 | - new CssRulesetDeclarationToken("white-space", "-moz-pre-wrap", $token->MediaTypes), |
|
3290 | - // Webkit |
|
3291 | - new CssRulesetDeclarationToken("white-space", "-webkit-pre-wrap", $token->MediaTypes), |
|
3292 | - // Opera >= 4 <= 6 |
|
3293 | - new CssRulesetDeclarationToken("white-space", "-pre-wrap", $token->MediaTypes), |
|
3294 | - // Opera >= 7 |
|
3295 | - new CssRulesetDeclarationToken("white-space", "-o-pre-wrap", $token->MediaTypes), |
|
3296 | - // Internet Explorer >= 5.5 |
|
3297 | - new CssRulesetDeclarationToken("word-wrap", "break-word", $token->MediaTypes) |
|
3298 | - ); |
|
3299 | - return $r; |
|
3300 | - } |
|
3301 | - else |
|
3302 | - { |
|
3303 | - return array(); |
|
3304 | - } |
|
3305 | - } |
|
3306 | - } |
|
2980 | + { |
|
2981 | + /** |
|
2982 | + * Css property transformations table. Used to convert CSS3 and proprietary properties to the browser-specific |
|
2983 | + * counterparts. |
|
2984 | + * |
|
2985 | + * @var array |
|
2986 | + */ |
|
2987 | + private $transformations = array |
|
2988 | + ( |
|
2989 | + // Property Array(Mozilla, Webkit, Opera, Internet Explorer); NULL values are placeholders and will get ignored |
|
2990 | + "animation" => array(null, "-webkit-animation", null, null), |
|
2991 | + "animation-delay" => array(null, "-webkit-animation-delay", null, null), |
|
2992 | + "animation-direction" => array(null, "-webkit-animation-direction", null, null), |
|
2993 | + "animation-duration" => array(null, "-webkit-animation-duration", null, null), |
|
2994 | + "animation-fill-mode" => array(null, "-webkit-animation-fill-mode", null, null), |
|
2995 | + "animation-iteration-count" => array(null, "-webkit-animation-iteration-count", null, null), |
|
2996 | + "animation-name" => array(null, "-webkit-animation-name", null, null), |
|
2997 | + "animation-play-state" => array(null, "-webkit-animation-play-state", null, null), |
|
2998 | + "animation-timing-function" => array(null, "-webkit-animation-timing-function", null, null), |
|
2999 | + "appearance" => array("-moz-appearance", "-webkit-appearance", null, null), |
|
3000 | + "backface-visibility" => array(null, "-webkit-backface-visibility", null, null), |
|
3001 | + "background-clip" => array(null, "-webkit-background-clip", null, null), |
|
3002 | + "background-composite" => array(null, "-webkit-background-composite", null, null), |
|
3003 | + "background-inline-policy" => array("-moz-background-inline-policy", null, null, null), |
|
3004 | + "background-origin" => array(null, "-webkit-background-origin", null, null), |
|
3005 | + "background-position-x" => array(null, null, null, "-ms-background-position-x"), |
|
3006 | + "background-position-y" => array(null, null, null, "-ms-background-position-y"), |
|
3007 | + "background-size" => array(null, "-webkit-background-size", null, null), |
|
3008 | + "behavior" => array(null, null, null, "-ms-behavior"), |
|
3009 | + "binding" => array("-moz-binding", null, null, null), |
|
3010 | + "border-after" => array(null, "-webkit-border-after", null, null), |
|
3011 | + "border-after-color" => array(null, "-webkit-border-after-color", null, null), |
|
3012 | + "border-after-style" => array(null, "-webkit-border-after-style", null, null), |
|
3013 | + "border-after-width" => array(null, "-webkit-border-after-width", null, null), |
|
3014 | + "border-before" => array(null, "-webkit-border-before", null, null), |
|
3015 | + "border-before-color" => array(null, "-webkit-border-before-color", null, null), |
|
3016 | + "border-before-style" => array(null, "-webkit-border-before-style", null, null), |
|
3017 | + "border-before-width" => array(null, "-webkit-border-before-width", null, null), |
|
3018 | + "border-border-bottom-colors" => array("-moz-border-bottom-colors", null, null, null), |
|
3019 | + "border-bottom-left-radius" => array("-moz-border-radius-bottomleft", "-webkit-border-bottom-left-radius", null, null), |
|
3020 | + "border-bottom-right-radius" => array("-moz-border-radius-bottomright", "-webkit-border-bottom-right-radius", null, null), |
|
3021 | + "border-end" => array("-moz-border-end", "-webkit-border-end", null, null), |
|
3022 | + "border-end-color" => array("-moz-border-end-color", "-webkit-border-end-color", null, null), |
|
3023 | + "border-end-style" => array("-moz-border-end-style", "-webkit-border-end-style", null, null), |
|
3024 | + "border-end-width" => array("-moz-border-end-width", "-webkit-border-end-width", null, null), |
|
3025 | + "border-fit" => array(null, "-webkit-border-fit", null, null), |
|
3026 | + "border-horizontal-spacing" => array(null, "-webkit-border-horizontal-spacing", null, null), |
|
3027 | + "border-image" => array("-moz-border-image", "-webkit-border-image", null, null), |
|
3028 | + "border-left-colors" => array("-moz-border-left-colors", null, null, null), |
|
3029 | + "border-radius" => array("-moz-border-radius", "-webkit-border-radius", null, null), |
|
3030 | + "border-border-right-colors" => array("-moz-border-right-colors", null, null, null), |
|
3031 | + "border-start" => array("-moz-border-start", "-webkit-border-start", null, null), |
|
3032 | + "border-start-color" => array("-moz-border-start-color", "-webkit-border-start-color", null, null), |
|
3033 | + "border-start-style" => array("-moz-border-start-style", "-webkit-border-start-style", null, null), |
|
3034 | + "border-start-width" => array("-moz-border-start-width", "-webkit-border-start-width", null, null), |
|
3035 | + "border-top-colors" => array("-moz-border-top-colors", null, null, null), |
|
3036 | + "border-top-left-radius" => array("-moz-border-radius-topleft", "-webkit-border-top-left-radius", null, null), |
|
3037 | + "border-top-right-radius" => array("-moz-border-radius-topright", "-webkit-border-top-right-radius", null, null), |
|
3038 | + "border-vertical-spacing" => array(null, "-webkit-border-vertical-spacing", null, null), |
|
3039 | + "box-align" => array("-moz-box-align", "-webkit-box-align", null, null), |
|
3040 | + "box-direction" => array("-moz-box-direction", "-webkit-box-direction", null, null), |
|
3041 | + "box-flex" => array("-moz-box-flex", "-webkit-box-flex", null, null), |
|
3042 | + "box-flex-group" => array(null, "-webkit-box-flex-group", null, null), |
|
3043 | + "box-flex-lines" => array(null, "-webkit-box-flex-lines", null, null), |
|
3044 | + "box-ordinal-group" => array("-moz-box-ordinal-group", "-webkit-box-ordinal-group", null, null), |
|
3045 | + "box-orient" => array("-moz-box-orient", "-webkit-box-orient", null, null), |
|
3046 | + "box-pack" => array("-moz-box-pack", "-webkit-box-pack", null, null), |
|
3047 | + "box-reflect" => array(null, "-webkit-box-reflect", null, null), |
|
3048 | + "box-shadow" => array("-moz-box-shadow", "-webkit-box-shadow", null, null), |
|
3049 | + "box-sizing" => array("-moz-box-sizing", null, null, null), |
|
3050 | + "color-correction" => array(null, "-webkit-color-correction", null, null), |
|
3051 | + "column-break-after" => array(null, "-webkit-column-break-after", null, null), |
|
3052 | + "column-break-before" => array(null, "-webkit-column-break-before", null, null), |
|
3053 | + "column-break-inside" => array(null, "-webkit-column-break-inside", null, null), |
|
3054 | + "column-count" => array("-moz-column-count", "-webkit-column-count", null, null), |
|
3055 | + "column-gap" => array("-moz-column-gap", "-webkit-column-gap", null, null), |
|
3056 | + "column-rule" => array("-moz-column-rule", "-webkit-column-rule", null, null), |
|
3057 | + "column-rule-color" => array("-moz-column-rule-color", "-webkit-column-rule-color", null, null), |
|
3058 | + "column-rule-style" => array("-moz-column-rule-style", "-webkit-column-rule-style", null, null), |
|
3059 | + "column-rule-width" => array("-moz-column-rule-width", "-webkit-column-rule-width", null, null), |
|
3060 | + "column-span" => array(null, "-webkit-column-span", null, null), |
|
3061 | + "column-width" => array("-moz-column-width", "-webkit-column-width", null, null), |
|
3062 | + "columns" => array(null, "-webkit-columns", null, null), |
|
3063 | + "filter" => array(__CLASS__, "filter"), |
|
3064 | + "float-edge" => array("-moz-float-edge", null, null, null), |
|
3065 | + "font-feature-settings" => array("-moz-font-feature-settings", null, null, null), |
|
3066 | + "font-language-override" => array("-moz-font-language-override", null, null, null), |
|
3067 | + "font-size-delta" => array(null, "-webkit-font-size-delta", null, null), |
|
3068 | + "font-smoothing" => array(null, "-webkit-font-smoothing", null, null), |
|
3069 | + "force-broken-image-icon" => array("-moz-force-broken-image-icon", null, null, null), |
|
3070 | + "highlight" => array(null, "-webkit-highlight", null, null), |
|
3071 | + "hyphenate-character" => array(null, "-webkit-hyphenate-character", null, null), |
|
3072 | + "hyphenate-locale" => array(null, "-webkit-hyphenate-locale", null, null), |
|
3073 | + "hyphens" => array(null, "-webkit-hyphens", null, null), |
|
3074 | + "force-broken-image-icon" => array("-moz-image-region", null, null, null), |
|
3075 | + "ime-mode" => array(null, null, null, "-ms-ime-mode"), |
|
3076 | + "interpolation-mode" => array(null, null, null, "-ms-interpolation-mode"), |
|
3077 | + "layout-flow" => array(null, null, null, "-ms-layout-flow"), |
|
3078 | + "layout-grid" => array(null, null, null, "-ms-layout-grid"), |
|
3079 | + "layout-grid-char" => array(null, null, null, "-ms-layout-grid-char"), |
|
3080 | + "layout-grid-line" => array(null, null, null, "-ms-layout-grid-line"), |
|
3081 | + "layout-grid-mode" => array(null, null, null, "-ms-layout-grid-mode"), |
|
3082 | + "layout-grid-type" => array(null, null, null, "-ms-layout-grid-type"), |
|
3083 | + "line-break" => array(null, "-webkit-line-break", null, "-ms-line-break"), |
|
3084 | + "line-clamp" => array(null, "-webkit-line-clamp", null, null), |
|
3085 | + "line-grid-mode" => array(null, null, null, "-ms-line-grid-mode"), |
|
3086 | + "logical-height" => array(null, "-webkit-logical-height", null, null), |
|
3087 | + "logical-width" => array(null, "-webkit-logical-width", null, null), |
|
3088 | + "margin-after" => array(null, "-webkit-margin-after", null, null), |
|
3089 | + "margin-after-collapse" => array(null, "-webkit-margin-after-collapse", null, null), |
|
3090 | + "margin-before" => array(null, "-webkit-margin-before", null, null), |
|
3091 | + "margin-before-collapse" => array(null, "-webkit-margin-before-collapse", null, null), |
|
3092 | + "margin-bottom-collapse" => array(null, "-webkit-margin-bottom-collapse", null, null), |
|
3093 | + "margin-collapse" => array(null, "-webkit-margin-collapse", null, null), |
|
3094 | + "margin-end" => array("-moz-margin-end", "-webkit-margin-end", null, null), |
|
3095 | + "margin-start" => array("-moz-margin-start", "-webkit-margin-start", null, null), |
|
3096 | + "margin-top-collapse" => array(null, "-webkit-margin-top-collapse", null, null), |
|
3097 | + "marquee " => array(null, "-webkit-marquee", null, null), |
|
3098 | + "marquee-direction" => array(null, "-webkit-marquee-direction", null, null), |
|
3099 | + "marquee-increment" => array(null, "-webkit-marquee-increment", null, null), |
|
3100 | + "marquee-repetition" => array(null, "-webkit-marquee-repetition", null, null), |
|
3101 | + "marquee-speed" => array(null, "-webkit-marquee-speed", null, null), |
|
3102 | + "marquee-style" => array(null, "-webkit-marquee-style", null, null), |
|
3103 | + "mask" => array(null, "-webkit-mask", null, null), |
|
3104 | + "mask-attachment" => array(null, "-webkit-mask-attachment", null, null), |
|
3105 | + "mask-box-image" => array(null, "-webkit-mask-box-image", null, null), |
|
3106 | + "mask-clip" => array(null, "-webkit-mask-clip", null, null), |
|
3107 | + "mask-composite" => array(null, "-webkit-mask-composite", null, null), |
|
3108 | + "mask-image" => array(null, "-webkit-mask-image", null, null), |
|
3109 | + "mask-origin" => array(null, "-webkit-mask-origin", null, null), |
|
3110 | + "mask-position" => array(null, "-webkit-mask-position", null, null), |
|
3111 | + "mask-position-x" => array(null, "-webkit-mask-position-x", null, null), |
|
3112 | + "mask-position-y" => array(null, "-webkit-mask-position-y", null, null), |
|
3113 | + "mask-repeat" => array(null, "-webkit-mask-repeat", null, null), |
|
3114 | + "mask-repeat-x" => array(null, "-webkit-mask-repeat-x", null, null), |
|
3115 | + "mask-repeat-y" => array(null, "-webkit-mask-repeat-y", null, null), |
|
3116 | + "mask-size" => array(null, "-webkit-mask-size", null, null), |
|
3117 | + "match-nearest-mail-blockquote-color" => array(null, "-webkit-match-nearest-mail-blockquote-color", null, null), |
|
3118 | + "max-logical-height" => array(null, "-webkit-max-logical-height", null, null), |
|
3119 | + "max-logical-width" => array(null, "-webkit-max-logical-width", null, null), |
|
3120 | + "min-logical-height" => array(null, "-webkit-min-logical-height", null, null), |
|
3121 | + "min-logical-width" => array(null, "-webkit-min-logical-width", null, null), |
|
3122 | + "object-fit" => array(null, null, "-o-object-fit", null), |
|
3123 | + "object-position" => array(null, null, "-o-object-position", null), |
|
3124 | + "opacity" => array(__CLASS__, "opacity"), |
|
3125 | + "outline-radius" => array("-moz-outline-radius", null, null, null), |
|
3126 | + "outline-bottom-left-radius" => array("-moz-outline-radius-bottomleft", null, null, null), |
|
3127 | + "outline-bottom-right-radius" => array("-moz-outline-radius-bottomright", null, null, null), |
|
3128 | + "outline-top-left-radius" => array("-moz-outline-radius-topleft", null, null, null), |
|
3129 | + "outline-top-right-radius" => array("-moz-outline-radius-topright", null, null, null), |
|
3130 | + "padding-after" => array(null, "-webkit-padding-after", null, null), |
|
3131 | + "padding-before" => array(null, "-webkit-padding-before", null, null), |
|
3132 | + "padding-end" => array("-moz-padding-end", "-webkit-padding-end", null, null), |
|
3133 | + "padding-start" => array("-moz-padding-start", "-webkit-padding-start", null, null), |
|
3134 | + "perspective" => array(null, "-webkit-perspective", null, null), |
|
3135 | + "perspective-origin" => array(null, "-webkit-perspective-origin", null, null), |
|
3136 | + "perspective-origin-x" => array(null, "-webkit-perspective-origin-x", null, null), |
|
3137 | + "perspective-origin-y" => array(null, "-webkit-perspective-origin-y", null, null), |
|
3138 | + "rtl-ordering" => array(null, "-webkit-rtl-ordering", null, null), |
|
3139 | + "scrollbar-3dlight-color" => array(null, null, null, "-ms-scrollbar-3dlight-color"), |
|
3140 | + "scrollbar-arrow-color" => array(null, null, null, "-ms-scrollbar-arrow-color"), |
|
3141 | + "scrollbar-base-color" => array(null, null, null, "-ms-scrollbar-base-color"), |
|
3142 | + "scrollbar-darkshadow-color" => array(null, null, null, "-ms-scrollbar-darkshadow-color"), |
|
3143 | + "scrollbar-face-color" => array(null, null, null, "-ms-scrollbar-face-color"), |
|
3144 | + "scrollbar-highlight-color" => array(null, null, null, "-ms-scrollbar-highlight-color"), |
|
3145 | + "scrollbar-shadow-color" => array(null, null, null, "-ms-scrollbar-shadow-color"), |
|
3146 | + "scrollbar-track-color" => array(null, null, null, "-ms-scrollbar-track-color"), |
|
3147 | + "stack-sizing" => array("-moz-stack-sizing", null, null, null), |
|
3148 | + "svg-shadow" => array(null, "-webkit-svg-shadow", null, null), |
|
3149 | + "tab-size" => array("-moz-tab-size", null, "-o-tab-size", null), |
|
3150 | + "table-baseline" => array(null, null, "-o-table-baseline", null), |
|
3151 | + "text-align-last" => array(null, null, null, "-ms-text-align-last"), |
|
3152 | + "text-autospace" => array(null, null, null, "-ms-text-autospace"), |
|
3153 | + "text-combine" => array(null, "-webkit-text-combine", null, null), |
|
3154 | + "text-decorations-in-effect" => array(null, "-webkit-text-decorations-in-effect", null, null), |
|
3155 | + "text-emphasis" => array(null, "-webkit-text-emphasis", null, null), |
|
3156 | + "text-emphasis-color" => array(null, "-webkit-text-emphasis-color", null, null), |
|
3157 | + "text-emphasis-position" => array(null, "-webkit-text-emphasis-position", null, null), |
|
3158 | + "text-emphasis-style" => array(null, "-webkit-text-emphasis-style", null, null), |
|
3159 | + "text-fill-color" => array(null, "-webkit-text-fill-color", null, null), |
|
3160 | + "text-justify" => array(null, null, null, "-ms-text-justify"), |
|
3161 | + "text-kashida-space" => array(null, null, null, "-ms-text-kashida-space"), |
|
3162 | + "text-overflow" => array(null, null, "-o-text-overflow", "-ms-text-overflow"), |
|
3163 | + "text-security" => array(null, "-webkit-text-security", null, null), |
|
3164 | + "text-size-adjust" => array(null, "-webkit-text-size-adjust", null, "-ms-text-size-adjust"), |
|
3165 | + "text-stroke" => array(null, "-webkit-text-stroke", null, null), |
|
3166 | + "text-stroke-color" => array(null, "-webkit-text-stroke-color", null, null), |
|
3167 | + "text-stroke-width" => array(null, "-webkit-text-stroke-width", null, null), |
|
3168 | + "text-underline-position" => array(null, null, null, "-ms-text-underline-position"), |
|
3169 | + "transform" => array("-moz-transform", "-webkit-transform", "-o-transform", null), |
|
3170 | + "transform-origin" => array("-moz-transform-origin", "-webkit-transform-origin", "-o-transform-origin", null), |
|
3171 | + "transform-origin-x" => array(null, "-webkit-transform-origin-x", null, null), |
|
3172 | + "transform-origin-y" => array(null, "-webkit-transform-origin-y", null, null), |
|
3173 | + "transform-origin-z" => array(null, "-webkit-transform-origin-z", null, null), |
|
3174 | + "transform-style" => array(null, "-webkit-transform-style", null, null), |
|
3175 | + "transition" => array("-moz-transition", "-webkit-transition", "-o-transition", null), |
|
3176 | + "transition-delay" => array("-moz-transition-delay", "-webkit-transition-delay", "-o-transition-delay", null), |
|
3177 | + "transition-duration" => array("-moz-transition-duration", "-webkit-transition-duration", "-o-transition-duration", null), |
|
3178 | + "transition-property" => array("-moz-transition-property", "-webkit-transition-property", "-o-transition-property", null), |
|
3179 | + "transition-timing-function" => array("-moz-transition-timing-function", "-webkit-transition-timing-function", "-o-transition-timing-function", null), |
|
3180 | + "user-drag" => array(null, "-webkit-user-drag", null, null), |
|
3181 | + "user-focus" => array("-moz-user-focus", null, null, null), |
|
3182 | + "user-input" => array("-moz-user-input", null, null, null), |
|
3183 | + "user-modify" => array("-moz-user-modify", "-webkit-user-modify", null, null), |
|
3184 | + "user-select" => array("-moz-user-select", "-webkit-user-select", null, null), |
|
3185 | + "white-space" => array(__CLASS__, "whiteSpace"), |
|
3186 | + "window-shadow" => array("-moz-window-shadow", null, null, null), |
|
3187 | + "word-break" => array(null, null, null, "-ms-word-break"), |
|
3188 | + "word-wrap" => array(null, null, null, "-ms-word-wrap"), |
|
3189 | + "writing-mode" => array(null, "-webkit-writing-mode", null, "-ms-writing-mode"), |
|
3190 | + "zoom" => array(null, null, null, "-ms-zoom") |
|
3191 | + ); |
|
3192 | + /** |
|
3193 | + * Implements {@link aCssMinifierFilter::filter()}. |
|
3194 | + * |
|
3195 | + * @param array $tokens Array of objects of type aCssToken |
|
3196 | + * @return integer Count of added, changed or removed tokens; a return value large than 0 will rebuild the array |
|
3197 | + */ |
|
3198 | + public function apply(array &$tokens) |
|
3199 | + { |
|
3200 | + $r = 0; |
|
3201 | + $transformations = &$this->transformations; |
|
3202 | + for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
3203 | + { |
|
3204 | + if (get_class($tokens[$i]) === "CssRulesetDeclarationToken") |
|
3205 | + { |
|
3206 | + $tProperty = $tokens[$i]->Property; |
|
3207 | + if (isset($transformations[$tProperty])) |
|
3208 | + { |
|
3209 | + $result = array(); |
|
3210 | + if (is_callable($transformations[$tProperty])) |
|
3211 | + { |
|
3212 | + $result = call_user_func_array($transformations[$tProperty], array($tokens[$i])); |
|
3213 | + if (!is_array($result) && is_object($result)) |
|
3214 | + { |
|
3215 | + $result = array($result); |
|
3216 | + } |
|
3217 | + } |
|
3218 | + else |
|
3219 | + { |
|
3220 | + $tValue = $tokens[$i]->Value; |
|
3221 | + $tMediaTypes = $tokens[$i]->MediaTypes; |
|
3222 | + foreach ($transformations[$tProperty] as $property) |
|
3223 | + { |
|
3224 | + if ($property !== null) |
|
3225 | + { |
|
3226 | + $result[] = new CssRulesetDeclarationToken($property, $tValue, $tMediaTypes); |
|
3227 | + } |
|
3228 | + } |
|
3229 | + } |
|
3230 | + if (count($result) > 0) |
|
3231 | + { |
|
3232 | + array_splice($tokens, $i + 1, 0, $result); |
|
3233 | + $i += count($result); |
|
3234 | + $l += count($result); |
|
3235 | + } |
|
3236 | + } |
|
3237 | + } |
|
3238 | + } |
|
3239 | + return $r; |
|
3240 | + } |
|
3241 | + /** |
|
3242 | + * Transforms the Internet Explorer specific declaration property "filter" to Internet Explorer 8+ compatible |
|
3243 | + * declaratiopn property "-ms-filter". |
|
3244 | + * |
|
3245 | + * @param aCssToken $token |
|
3246 | + * @return array |
|
3247 | + */ |
|
3248 | + private static function filter($token) |
|
3249 | + { |
|
3250 | + $r = array |
|
3251 | + ( |
|
3252 | + new CssRulesetDeclarationToken("-ms-filter", "\"" . $token->Value . "\"", $token->MediaTypes), |
|
3253 | + ); |
|
3254 | + return $r; |
|
3255 | + } |
|
3256 | + /** |
|
3257 | + * Transforms "opacity: {value}" into browser specific counterparts. |
|
3258 | + * |
|
3259 | + * @param aCssToken $token |
|
3260 | + * @return array |
|
3261 | + */ |
|
3262 | + private static function opacity($token) |
|
3263 | + { |
|
3264 | + // Calculate the value for Internet Explorer filter statement |
|
3265 | + $ieValue = (int) ((float) $token->Value * 100); |
|
3266 | + $r = array |
|
3267 | + ( |
|
3268 | + // Internet Explorer >= 8 |
|
3269 | + new CssRulesetDeclarationToken("-ms-filter", "\"alpha(opacity=" . $ieValue . ")\"", $token->MediaTypes), |
|
3270 | + // Internet Explorer >= 4 <= 7 |
|
3271 | + new CssRulesetDeclarationToken("filter", "alpha(opacity=" . $ieValue . ")", $token->MediaTypes), |
|
3272 | + new CssRulesetDeclarationToken("zoom", "1", $token->MediaTypes) |
|
3273 | + ); |
|
3274 | + return $r; |
|
3275 | + } |
|
3276 | + /** |
|
3277 | + * Transforms "white-space: pre-wrap" into browser specific counterparts. |
|
3278 | + * |
|
3279 | + * @param aCssToken $token |
|
3280 | + * @return array |
|
3281 | + */ |
|
3282 | + private static function whiteSpace($token) |
|
3283 | + { |
|
3284 | + if (strtolower($token->Value) === "pre-wrap") |
|
3285 | + { |
|
3286 | + $r = array |
|
3287 | + ( |
|
3288 | + // Firefox < 3 |
|
3289 | + new CssRulesetDeclarationToken("white-space", "-moz-pre-wrap", $token->MediaTypes), |
|
3290 | + // Webkit |
|
3291 | + new CssRulesetDeclarationToken("white-space", "-webkit-pre-wrap", $token->MediaTypes), |
|
3292 | + // Opera >= 4 <= 6 |
|
3293 | + new CssRulesetDeclarationToken("white-space", "-pre-wrap", $token->MediaTypes), |
|
3294 | + // Opera >= 7 |
|
3295 | + new CssRulesetDeclarationToken("white-space", "-o-pre-wrap", $token->MediaTypes), |
|
3296 | + // Internet Explorer >= 5.5 |
|
3297 | + new CssRulesetDeclarationToken("word-wrap", "break-word", $token->MediaTypes) |
|
3298 | + ); |
|
3299 | + return $r; |
|
3300 | + } |
|
3301 | + else |
|
3302 | + { |
|
3303 | + return array(); |
|
3304 | + } |
|
3305 | + } |
|
3306 | + } |
|
3307 | 3307 | |
3308 | 3308 | /** |
3309 | 3309 | * This {@link aCssMinifierFilter minifier filter} will convert @keyframes at-rule block to browser specific counterparts. |
@@ -3316,63 +3316,63 @@ discard block |
||
3316 | 3316 | * @version 3.0.1 |
3317 | 3317 | */ |
3318 | 3318 | class CssConvertLevel3AtKeyframesMinifierFilter extends aCssMinifierFilter |
3319 | - { |
|
3320 | - /** |
|
3321 | - * Implements {@link aCssMinifierFilter::filter()}. |
|
3322 | - * |
|
3323 | - * @param array $tokens Array of objects of type aCssToken |
|
3324 | - * @return integer Count of added, changed or removed tokens; a return value larger than 0 will rebuild the array |
|
3325 | - */ |
|
3326 | - public function apply(array &$tokens) |
|
3327 | - { |
|
3328 | - $r = 0; |
|
3329 | - $transformations = array("-moz-keyframes", "-webkit-keyframes"); |
|
3330 | - for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
3331 | - { |
|
3332 | - if (get_class($tokens[$i]) === "CssAtKeyframesStartToken") |
|
3333 | - { |
|
3334 | - for ($ii = $i; $ii < $l; $ii++) |
|
3335 | - { |
|
3336 | - if (get_class($tokens[$ii]) === "CssAtKeyframesEndToken") |
|
3337 | - { |
|
3338 | - break; |
|
3339 | - } |
|
3340 | - } |
|
3341 | - if (get_class($tokens[$ii]) === "CssAtKeyframesEndToken") |
|
3342 | - { |
|
3343 | - $add = array(); |
|
3344 | - $source = array(); |
|
3345 | - for ($iii = $i; $iii <= $ii; $iii++) |
|
3346 | - { |
|
3347 | - $source[] = clone($tokens[$iii]); |
|
3348 | - } |
|
3349 | - foreach ($transformations as $transformation) |
|
3350 | - { |
|
3351 | - $t = array(); |
|
3352 | - foreach ($source as $token) |
|
3353 | - { |
|
3354 | - $t[] = clone($token); |
|
3355 | - } |
|
3356 | - $t[0]->AtRuleName = $transformation; |
|
3357 | - $add = array_merge($add, $t); |
|
3358 | - } |
|
3359 | - if (isset($this->configuration["RemoveSource"]) && $this->configuration["RemoveSource"] === true) |
|
3360 | - { |
|
3361 | - array_splice($tokens, $i, $ii - $i + 1, $add); |
|
3362 | - } |
|
3363 | - else |
|
3364 | - { |
|
3365 | - array_splice($tokens, $ii + 1, 0, $add); |
|
3366 | - } |
|
3367 | - $l = count($tokens); |
|
3368 | - $i = $ii + count($add); |
|
3369 | - $r += count($add); |
|
3370 | - } |
|
3371 | - } |
|
3372 | - } |
|
3373 | - return $r; |
|
3374 | - } |
|
3375 | - } |
|
3319 | + { |
|
3320 | + /** |
|
3321 | + * Implements {@link aCssMinifierFilter::filter()}. |
|
3322 | + * |
|
3323 | + * @param array $tokens Array of objects of type aCssToken |
|
3324 | + * @return integer Count of added, changed or removed tokens; a return value larger than 0 will rebuild the array |
|
3325 | + */ |
|
3326 | + public function apply(array &$tokens) |
|
3327 | + { |
|
3328 | + $r = 0; |
|
3329 | + $transformations = array("-moz-keyframes", "-webkit-keyframes"); |
|
3330 | + for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
3331 | + { |
|
3332 | + if (get_class($tokens[$i]) === "CssAtKeyframesStartToken") |
|
3333 | + { |
|
3334 | + for ($ii = $i; $ii < $l; $ii++) |
|
3335 | + { |
|
3336 | + if (get_class($tokens[$ii]) === "CssAtKeyframesEndToken") |
|
3337 | + { |
|
3338 | + break; |
|
3339 | + } |
|
3340 | + } |
|
3341 | + if (get_class($tokens[$ii]) === "CssAtKeyframesEndToken") |
|
3342 | + { |
|
3343 | + $add = array(); |
|
3344 | + $source = array(); |
|
3345 | + for ($iii = $i; $iii <= $ii; $iii++) |
|
3346 | + { |
|
3347 | + $source[] = clone($tokens[$iii]); |
|
3348 | + } |
|
3349 | + foreach ($transformations as $transformation) |
|
3350 | + { |
|
3351 | + $t = array(); |
|
3352 | + foreach ($source as $token) |
|
3353 | + { |
|
3354 | + $t[] = clone($token); |
|
3355 | + } |
|
3356 | + $t[0]->AtRuleName = $transformation; |
|
3357 | + $add = array_merge($add, $t); |
|
3358 | + } |
|
3359 | + if (isset($this->configuration["RemoveSource"]) && $this->configuration["RemoveSource"] === true) |
|
3360 | + { |
|
3361 | + array_splice($tokens, $i, $ii - $i + 1, $add); |
|
3362 | + } |
|
3363 | + else |
|
3364 | + { |
|
3365 | + array_splice($tokens, $ii + 1, 0, $add); |
|
3366 | + } |
|
3367 | + $l = count($tokens); |
|
3368 | + $i = $ii + count($add); |
|
3369 | + $r += count($add); |
|
3370 | + } |
|
3371 | + } |
|
3372 | + } |
|
3373 | + return $r; |
|
3374 | + } |
|
3375 | + } |
|
3376 | 3376 | |
3377 | 3377 | /** |
3378 | 3378 | * This {@link aCssMinifierPlugin} will convert a color value in hsl notation to hexadecimal notation. |
@@ -3395,112 +3395,112 @@ discard block |
||
3395 | 3395 | * @version 3.0.1 |
3396 | 3396 | */ |
3397 | 3397 | class CssConvertHslColorsMinifierPlugin extends aCssMinifierPlugin |
3398 | - { |
|
3399 | - /** |
|
3400 | - * Regular expression matching the value. |
|
3401 | - * |
|
3402 | - * @var string |
|
3403 | - */ |
|
3404 | - private $reMatch = "/^hsl\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*%\s*,\s*([0-9]+)\s*%\s*\)/iS"; |
|
3405 | - /** |
|
3406 | - * Implements {@link aCssMinifierPlugin::minify()}. |
|
3407 | - * |
|
3408 | - * @param aCssToken $token Token to process |
|
3409 | - * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
3410 | - */ |
|
3411 | - public function apply(aCssToken &$token) |
|
3412 | - { |
|
3413 | - if (stripos($token->Value, "hsl") !== false && preg_match($this->reMatch, $token->Value, $m)) |
|
3414 | - { |
|
3415 | - $token->Value = str_replace($m[0], $this->hsl2hex($m[1], $m[2], $m[3]), $token->Value); |
|
3416 | - } |
|
3417 | - return false; |
|
3418 | - } |
|
3419 | - /** |
|
3420 | - * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
3421 | - * |
|
3422 | - * @return array |
|
3423 | - */ |
|
3424 | - public function getTriggerTokens() |
|
3425 | - { |
|
3426 | - return array |
|
3427 | - ( |
|
3428 | - "CssAtFontFaceDeclarationToken", |
|
3429 | - "CssAtPageDeclarationToken", |
|
3430 | - "CssRulesetDeclarationToken" |
|
3431 | - ); |
|
3432 | - } |
|
3433 | - /** |
|
3434 | - * Convert a HSL value to hexadecimal notation. |
|
3435 | - * |
|
3436 | - * Based on: {@link http://www.easyrgb.com/index.php?X=MATH&H=19#text19}. |
|
3437 | - * |
|
3438 | - * @param integer $hue Hue |
|
3439 | - * @param integer $saturation Saturation |
|
3440 | - * @param integer $lightness Lightnesss |
|
3441 | - * @return string |
|
3442 | - */ |
|
3443 | - private function hsl2hex($hue, $saturation, $lightness) |
|
3444 | - { |
|
3445 | - $hue = $hue / 360; |
|
3446 | - $saturation = $saturation / 100; |
|
3447 | - $lightness = $lightness / 100; |
|
3448 | - if ($saturation == 0) |
|
3449 | - { |
|
3450 | - $red = $lightness * 255; |
|
3451 | - $green = $lightness * 255; |
|
3452 | - $blue = $lightness * 255; |
|
3453 | - } |
|
3454 | - else |
|
3455 | - { |
|
3456 | - if ($lightness < 0.5 ) |
|
3457 | - { |
|
3458 | - $v2 = $lightness * (1 + $saturation); |
|
3459 | - } |
|
3460 | - else |
|
3461 | - { |
|
3462 | - $v2 = ($lightness + $saturation) - ($saturation * $lightness); |
|
3463 | - } |
|
3464 | - $v1 = 2 * $lightness - $v2; |
|
3465 | - $red = 255 * self::hue2rgb($v1, $v2, $hue + (1 / 3)); |
|
3466 | - $green = 255 * self::hue2rgb($v1, $v2, $hue); |
|
3467 | - $blue = 255 * self::hue2rgb($v1, $v2, $hue - (1 / 3)); |
|
3468 | - } |
|
3469 | - return "#" . str_pad(dechex(round($red)), 2, "0", STR_PAD_LEFT) . str_pad(dechex(round($green)), 2, "0", STR_PAD_LEFT) . str_pad(dechex(round($blue)), 2, "0", STR_PAD_LEFT); |
|
3470 | - } |
|
3471 | - /** |
|
3472 | - * Apply hue to a rgb color value. |
|
3473 | - * |
|
3474 | - * @param integer $v1 Value 1 |
|
3475 | - * @param integer $v2 Value 2 |
|
3476 | - * @param integer $hue Hue |
|
3477 | - * @return integer |
|
3478 | - */ |
|
3479 | - private function hue2rgb($v1, $v2, $hue) |
|
3480 | - { |
|
3481 | - if ($hue < 0) |
|
3482 | - { |
|
3483 | - $hue += 1; |
|
3484 | - } |
|
3485 | - if ($hue > 1) |
|
3486 | - { |
|
3487 | - $hue -= 1; |
|
3488 | - } |
|
3489 | - if ((6 * $hue) < 1) |
|
3490 | - { |
|
3491 | - return ($v1 + ($v2 - $v1) * 6 * $hue); |
|
3492 | - } |
|
3493 | - if ((2 * $hue) < 1) |
|
3494 | - { |
|
3495 | - return ($v2); |
|
3496 | - } |
|
3497 | - if ((3 * $hue) < 2) |
|
3498 | - { |
|
3499 | - return ($v1 + ($v2 - $v1) * (( 2 / 3) - $hue) * 6); |
|
3500 | - } |
|
3501 | - return $v1; |
|
3502 | - } |
|
3503 | - } |
|
3398 | + { |
|
3399 | + /** |
|
3400 | + * Regular expression matching the value. |
|
3401 | + * |
|
3402 | + * @var string |
|
3403 | + */ |
|
3404 | + private $reMatch = "/^hsl\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*%\s*,\s*([0-9]+)\s*%\s*\)/iS"; |
|
3405 | + /** |
|
3406 | + * Implements {@link aCssMinifierPlugin::minify()}. |
|
3407 | + * |
|
3408 | + * @param aCssToken $token Token to process |
|
3409 | + * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
3410 | + */ |
|
3411 | + public function apply(aCssToken &$token) |
|
3412 | + { |
|
3413 | + if (stripos($token->Value, "hsl") !== false && preg_match($this->reMatch, $token->Value, $m)) |
|
3414 | + { |
|
3415 | + $token->Value = str_replace($m[0], $this->hsl2hex($m[1], $m[2], $m[3]), $token->Value); |
|
3416 | + } |
|
3417 | + return false; |
|
3418 | + } |
|
3419 | + /** |
|
3420 | + * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
3421 | + * |
|
3422 | + * @return array |
|
3423 | + */ |
|
3424 | + public function getTriggerTokens() |
|
3425 | + { |
|
3426 | + return array |
|
3427 | + ( |
|
3428 | + "CssAtFontFaceDeclarationToken", |
|
3429 | + "CssAtPageDeclarationToken", |
|
3430 | + "CssRulesetDeclarationToken" |
|
3431 | + ); |
|
3432 | + } |
|
3433 | + /** |
|
3434 | + * Convert a HSL value to hexadecimal notation. |
|
3435 | + * |
|
3436 | + * Based on: {@link http://www.easyrgb.com/index.php?X=MATH&H=19#text19}. |
|
3437 | + * |
|
3438 | + * @param integer $hue Hue |
|
3439 | + * @param integer $saturation Saturation |
|
3440 | + * @param integer $lightness Lightnesss |
|
3441 | + * @return string |
|
3442 | + */ |
|
3443 | + private function hsl2hex($hue, $saturation, $lightness) |
|
3444 | + { |
|
3445 | + $hue = $hue / 360; |
|
3446 | + $saturation = $saturation / 100; |
|
3447 | + $lightness = $lightness / 100; |
|
3448 | + if ($saturation == 0) |
|
3449 | + { |
|
3450 | + $red = $lightness * 255; |
|
3451 | + $green = $lightness * 255; |
|
3452 | + $blue = $lightness * 255; |
|
3453 | + } |
|
3454 | + else |
|
3455 | + { |
|
3456 | + if ($lightness < 0.5 ) |
|
3457 | + { |
|
3458 | + $v2 = $lightness * (1 + $saturation); |
|
3459 | + } |
|
3460 | + else |
|
3461 | + { |
|
3462 | + $v2 = ($lightness + $saturation) - ($saturation * $lightness); |
|
3463 | + } |
|
3464 | + $v1 = 2 * $lightness - $v2; |
|
3465 | + $red = 255 * self::hue2rgb($v1, $v2, $hue + (1 / 3)); |
|
3466 | + $green = 255 * self::hue2rgb($v1, $v2, $hue); |
|
3467 | + $blue = 255 * self::hue2rgb($v1, $v2, $hue - (1 / 3)); |
|
3468 | + } |
|
3469 | + return "#" . str_pad(dechex(round($red)), 2, "0", STR_PAD_LEFT) . str_pad(dechex(round($green)), 2, "0", STR_PAD_LEFT) . str_pad(dechex(round($blue)), 2, "0", STR_PAD_LEFT); |
|
3470 | + } |
|
3471 | + /** |
|
3472 | + * Apply hue to a rgb color value. |
|
3473 | + * |
|
3474 | + * @param integer $v1 Value 1 |
|
3475 | + * @param integer $v2 Value 2 |
|
3476 | + * @param integer $hue Hue |
|
3477 | + * @return integer |
|
3478 | + */ |
|
3479 | + private function hue2rgb($v1, $v2, $hue) |
|
3480 | + { |
|
3481 | + if ($hue < 0) |
|
3482 | + { |
|
3483 | + $hue += 1; |
|
3484 | + } |
|
3485 | + if ($hue > 1) |
|
3486 | + { |
|
3487 | + $hue -= 1; |
|
3488 | + } |
|
3489 | + if ((6 * $hue) < 1) |
|
3490 | + { |
|
3491 | + return ($v1 + ($v2 - $v1) * 6 * $hue); |
|
3492 | + } |
|
3493 | + if ((2 * $hue) < 1) |
|
3494 | + { |
|
3495 | + return ($v2); |
|
3496 | + } |
|
3497 | + if ((3 * $hue) < 2) |
|
3498 | + { |
|
3499 | + return ($v1 + ($v2 - $v1) * (( 2 / 3) - $hue) * 6); |
|
3500 | + } |
|
3501 | + return $v1; |
|
3502 | + } |
|
3503 | + } |
|
3504 | 3504 | |
3505 | 3505 | /** |
3506 | 3506 | * This {@link aCssMinifierPlugin} will convert the font-weight values normal and bold to their numeric notation. |
@@ -3525,83 +3525,83 @@ discard block |
||
3525 | 3525 | * @version 3.0.1 |
3526 | 3526 | */ |
3527 | 3527 | class CssConvertFontWeightMinifierPlugin extends aCssMinifierPlugin |
3528 | - { |
|
3529 | - /** |
|
3530 | - * Array of included declaration properties this plugin will process; others declaration properties will get |
|
3531 | - * ignored. |
|
3532 | - * |
|
3533 | - * @var array |
|
3534 | - */ |
|
3535 | - private $include = array |
|
3536 | - ( |
|
3537 | - "font", |
|
3538 | - "font-weight" |
|
3539 | - ); |
|
3540 | - /** |
|
3541 | - * Regular expression matching the value. |
|
3542 | - * |
|
3543 | - * @var string |
|
3544 | - */ |
|
3545 | - private $reMatch = null; |
|
3546 | - /** |
|
3547 | - * Regular expression replace the value. |
|
3548 | - * |
|
3549 | - * @var string |
|
3550 | - */ |
|
3551 | - private $reReplace = "\"\${1}\" . \$this->transformation[\"\${2}\"] . \"\${3}\""; |
|
3552 | - /** |
|
3553 | - * Transformation table used by the {@link CssConvertFontWeightMinifierPlugin::$reReplace replace regular expression}. |
|
3554 | - * |
|
3555 | - * @var array |
|
3556 | - */ |
|
3557 | - private $transformation = array |
|
3558 | - ( |
|
3559 | - "normal" => "400", |
|
3560 | - "bold" => "700" |
|
3561 | - ); |
|
3562 | - /** |
|
3563 | - * Overwrites {@link aCssMinifierPlugin::__construct()}. |
|
3564 | - * |
|
3565 | - * The constructor will create the {@link CssConvertFontWeightMinifierPlugin::$reReplace replace regular expression} |
|
3566 | - * based on the {@link CssConvertFontWeightMinifierPlugin::$transformation transformation table}. |
|
3567 | - * |
|
3568 | - * @param CssMinifier $minifier The CssMinifier object of this plugin. |
|
3569 | - * @return void |
|
3570 | - */ |
|
3571 | - public function __construct(CssMinifier $minifier) |
|
3572 | - { |
|
3573 | - $this->reMatch = "/(^|\s)+(" . implode("|", array_keys($this->transformation)). ")(\s|$)+/eiS"; |
|
3574 | - parent::__construct($minifier); |
|
3575 | - } |
|
3576 | - /** |
|
3577 | - * Implements {@link aCssMinifierPlugin::minify()}. |
|
3578 | - * |
|
3579 | - * @param aCssToken $token Token to process |
|
3580 | - * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
3581 | - */ |
|
3582 | - public function apply(aCssToken &$token) |
|
3583 | - { |
|
3584 | - if (in_array($token->Property, $this->include) && preg_match($this->reMatch, $token->Value, $m)) |
|
3585 | - { |
|
3586 | - $token->Value = preg_replace($this->reMatch, $this->reReplace, $token->Value); |
|
3587 | - } |
|
3588 | - return false; |
|
3589 | - } |
|
3590 | - /** |
|
3591 | - * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
3592 | - * |
|
3593 | - * @return array |
|
3594 | - */ |
|
3595 | - public function getTriggerTokens() |
|
3596 | - { |
|
3597 | - return array |
|
3598 | - ( |
|
3599 | - "CssAtFontFaceDeclarationToken", |
|
3600 | - "CssAtPageDeclarationToken", |
|
3601 | - "CssRulesetDeclarationToken" |
|
3602 | - ); |
|
3603 | - } |
|
3604 | - } |
|
3528 | + { |
|
3529 | + /** |
|
3530 | + * Array of included declaration properties this plugin will process; others declaration properties will get |
|
3531 | + * ignored. |
|
3532 | + * |
|
3533 | + * @var array |
|
3534 | + */ |
|
3535 | + private $include = array |
|
3536 | + ( |
|
3537 | + "font", |
|
3538 | + "font-weight" |
|
3539 | + ); |
|
3540 | + /** |
|
3541 | + * Regular expression matching the value. |
|
3542 | + * |
|
3543 | + * @var string |
|
3544 | + */ |
|
3545 | + private $reMatch = null; |
|
3546 | + /** |
|
3547 | + * Regular expression replace the value. |
|
3548 | + * |
|
3549 | + * @var string |
|
3550 | + */ |
|
3551 | + private $reReplace = "\"\${1}\" . \$this->transformation[\"\${2}\"] . \"\${3}\""; |
|
3552 | + /** |
|
3553 | + * Transformation table used by the {@link CssConvertFontWeightMinifierPlugin::$reReplace replace regular expression}. |
|
3554 | + * |
|
3555 | + * @var array |
|
3556 | + */ |
|
3557 | + private $transformation = array |
|
3558 | + ( |
|
3559 | + "normal" => "400", |
|
3560 | + "bold" => "700" |
|
3561 | + ); |
|
3562 | + /** |
|
3563 | + * Overwrites {@link aCssMinifierPlugin::__construct()}. |
|
3564 | + * |
|
3565 | + * The constructor will create the {@link CssConvertFontWeightMinifierPlugin::$reReplace replace regular expression} |
|
3566 | + * based on the {@link CssConvertFontWeightMinifierPlugin::$transformation transformation table}. |
|
3567 | + * |
|
3568 | + * @param CssMinifier $minifier The CssMinifier object of this plugin. |
|
3569 | + * @return void |
|
3570 | + */ |
|
3571 | + public function __construct(CssMinifier $minifier) |
|
3572 | + { |
|
3573 | + $this->reMatch = "/(^|\s)+(" . implode("|", array_keys($this->transformation)). ")(\s|$)+/eiS"; |
|
3574 | + parent::__construct($minifier); |
|
3575 | + } |
|
3576 | + /** |
|
3577 | + * Implements {@link aCssMinifierPlugin::minify()}. |
|
3578 | + * |
|
3579 | + * @param aCssToken $token Token to process |
|
3580 | + * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
3581 | + */ |
|
3582 | + public function apply(aCssToken &$token) |
|
3583 | + { |
|
3584 | + if (in_array($token->Property, $this->include) && preg_match($this->reMatch, $token->Value, $m)) |
|
3585 | + { |
|
3586 | + $token->Value = preg_replace($this->reMatch, $this->reReplace, $token->Value); |
|
3587 | + } |
|
3588 | + return false; |
|
3589 | + } |
|
3590 | + /** |
|
3591 | + * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
3592 | + * |
|
3593 | + * @return array |
|
3594 | + */ |
|
3595 | + public function getTriggerTokens() |
|
3596 | + { |
|
3597 | + return array |
|
3598 | + ( |
|
3599 | + "CssAtFontFaceDeclarationToken", |
|
3600 | + "CssAtPageDeclarationToken", |
|
3601 | + "CssRulesetDeclarationToken" |
|
3602 | + ); |
|
3603 | + } |
|
3604 | + } |
|
3605 | 3605 | |
3606 | 3606 | /** |
3607 | 3607 | * This {@link aCssMinifierPlugin} will compress several unit values to their short notations. Examples: |
@@ -3630,56 +3630,56 @@ discard block |
||
3630 | 3630 | * @version 3.0.1 |
3631 | 3631 | */ |
3632 | 3632 | class CssCompressUnitValuesMinifierPlugin extends aCssMinifierPlugin |
3633 | - { |
|
3634 | - /** |
|
3635 | - * Regular expression used for matching and replacing unit values. |
|
3636 | - * |
|
3637 | - * @var array |
|
3638 | - */ |
|
3639 | - private $re = array |
|
3640 | - ( |
|
3641 | - "/(^| |-)0\.([0-9]+?)(0+)?(%|em|ex|px|in|cm|mm|pt|pc)/iS" => "\${1}.\${2}\${4}", |
|
3642 | - "/(^| )-?(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)/iS" => "\${1}0", |
|
3643 | - "/(^0\s0\s0\s0)|(^0\s0\s0$)|(^0\s0$)/iS" => "0" |
|
3644 | - ); |
|
3645 | - /** |
|
3646 | - * Regular expression matching the value. |
|
3647 | - * |
|
3648 | - * @var string |
|
3649 | - */ |
|
3650 | - private $reMatch = "/(^| |-)0\.([0-9]+?)(0+)?(%|em|ex|px|in|cm|mm|pt|pc)|(^| )-?(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)|(^0\s0\s0\s0$)|(^0\s0\s0$)|(^0\s0$)/iS"; |
|
3651 | - /** |
|
3652 | - * Implements {@link aCssMinifierPlugin::minify()}. |
|
3653 | - * |
|
3654 | - * @param aCssToken $token Token to process |
|
3655 | - * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
3656 | - */ |
|
3657 | - public function apply(aCssToken &$token) |
|
3658 | - { |
|
3659 | - if (preg_match($this->reMatch, $token->Value)) |
|
3660 | - { |
|
3661 | - foreach ($this->re as $reMatch => $reReplace) |
|
3662 | - { |
|
3663 | - $token->Value = preg_replace($reMatch, $reReplace, $token->Value); |
|
3664 | - } |
|
3665 | - } |
|
3666 | - return false; |
|
3667 | - } |
|
3668 | - /** |
|
3669 | - * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
3670 | - * |
|
3671 | - * @return array |
|
3672 | - */ |
|
3673 | - public function getTriggerTokens() |
|
3674 | - { |
|
3675 | - return array |
|
3676 | - ( |
|
3677 | - "CssAtFontFaceDeclarationToken", |
|
3678 | - "CssAtPageDeclarationToken", |
|
3679 | - "CssRulesetDeclarationToken" |
|
3680 | - ); |
|
3681 | - } |
|
3682 | - } |
|
3633 | + { |
|
3634 | + /** |
|
3635 | + * Regular expression used for matching and replacing unit values. |
|
3636 | + * |
|
3637 | + * @var array |
|
3638 | + */ |
|
3639 | + private $re = array |
|
3640 | + ( |
|
3641 | + "/(^| |-)0\.([0-9]+?)(0+)?(%|em|ex|px|in|cm|mm|pt|pc)/iS" => "\${1}.\${2}\${4}", |
|
3642 | + "/(^| )-?(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)/iS" => "\${1}0", |
|
3643 | + "/(^0\s0\s0\s0)|(^0\s0\s0$)|(^0\s0$)/iS" => "0" |
|
3644 | + ); |
|
3645 | + /** |
|
3646 | + * Regular expression matching the value. |
|
3647 | + * |
|
3648 | + * @var string |
|
3649 | + */ |
|
3650 | + private $reMatch = "/(^| |-)0\.([0-9]+?)(0+)?(%|em|ex|px|in|cm|mm|pt|pc)|(^| )-?(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)|(^0\s0\s0\s0$)|(^0\s0\s0$)|(^0\s0$)/iS"; |
|
3651 | + /** |
|
3652 | + * Implements {@link aCssMinifierPlugin::minify()}. |
|
3653 | + * |
|
3654 | + * @param aCssToken $token Token to process |
|
3655 | + * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
3656 | + */ |
|
3657 | + public function apply(aCssToken &$token) |
|
3658 | + { |
|
3659 | + if (preg_match($this->reMatch, $token->Value)) |
|
3660 | + { |
|
3661 | + foreach ($this->re as $reMatch => $reReplace) |
|
3662 | + { |
|
3663 | + $token->Value = preg_replace($reMatch, $reReplace, $token->Value); |
|
3664 | + } |
|
3665 | + } |
|
3666 | + return false; |
|
3667 | + } |
|
3668 | + /** |
|
3669 | + * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
3670 | + * |
|
3671 | + * @return array |
|
3672 | + */ |
|
3673 | + public function getTriggerTokens() |
|
3674 | + { |
|
3675 | + return array |
|
3676 | + ( |
|
3677 | + "CssAtFontFaceDeclarationToken", |
|
3678 | + "CssAtPageDeclarationToken", |
|
3679 | + "CssRulesetDeclarationToken" |
|
3680 | + ); |
|
3681 | + } |
|
3682 | + } |
|
3683 | 3683 | |
3684 | 3684 | /** |
3685 | 3685 | * This {@link aCssMinifierPlugin} compress the content of expresssion() declaration values. |
@@ -3695,39 +3695,39 @@ discard block |
||
3695 | 3695 | * @version 3.0.1 |
3696 | 3696 | */ |
3697 | 3697 | class CssCompressExpressionValuesMinifierPlugin extends aCssMinifierPlugin |
3698 | - { |
|
3699 | - /** |
|
3700 | - * Implements {@link aCssMinifierPlugin::minify()}. |
|
3701 | - * |
|
3702 | - * @param aCssToken $token Token to process |
|
3703 | - * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
3704 | - */ |
|
3705 | - public function apply(aCssToken &$token) |
|
3706 | - { |
|
3707 | - if (class_exists("JSMin") && stripos($token->Value, "expression(") !== false) |
|
3708 | - { |
|
3709 | - $value = $token->Value; |
|
3710 | - $value = substr($token->Value, stripos($token->Value, "expression(") + 10); |
|
3711 | - $value = trim(JSMin::minify($value)); |
|
3712 | - $token->Value = "expression(" . $value . ")"; |
|
3713 | - } |
|
3714 | - return false; |
|
3715 | - } |
|
3716 | - /** |
|
3717 | - * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
3718 | - * |
|
3719 | - * @return array |
|
3720 | - */ |
|
3721 | - public function getTriggerTokens() |
|
3722 | - { |
|
3723 | - return array |
|
3724 | - ( |
|
3725 | - "CssAtFontFaceDeclarationToken", |
|
3726 | - "CssAtPageDeclarationToken", |
|
3727 | - "CssRulesetDeclarationToken" |
|
3728 | - ); |
|
3729 | - } |
|
3730 | - } |
|
3698 | + { |
|
3699 | + /** |
|
3700 | + * Implements {@link aCssMinifierPlugin::minify()}. |
|
3701 | + * |
|
3702 | + * @param aCssToken $token Token to process |
|
3703 | + * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
3704 | + */ |
|
3705 | + public function apply(aCssToken &$token) |
|
3706 | + { |
|
3707 | + if (class_exists("JSMin") && stripos($token->Value, "expression(") !== false) |
|
3708 | + { |
|
3709 | + $value = $token->Value; |
|
3710 | + $value = substr($token->Value, stripos($token->Value, "expression(") + 10); |
|
3711 | + $value = trim(JSMin::minify($value)); |
|
3712 | + $token->Value = "expression(" . $value . ")"; |
|
3713 | + } |
|
3714 | + return false; |
|
3715 | + } |
|
3716 | + /** |
|
3717 | + * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
3718 | + * |
|
3719 | + * @return array |
|
3720 | + */ |
|
3721 | + public function getTriggerTokens() |
|
3722 | + { |
|
3723 | + return array |
|
3724 | + ( |
|
3725 | + "CssAtFontFaceDeclarationToken", |
|
3726 | + "CssAtPageDeclarationToken", |
|
3727 | + "CssRulesetDeclarationToken" |
|
3728 | + ); |
|
3729 | + } |
|
3730 | + } |
|
3731 | 3731 | |
3732 | 3732 | /** |
3733 | 3733 | * This {@link aCssMinifierPlugin} will convert hexadecimal color value with 6 chars to their 3 char hexadecimal |
@@ -3751,46 +3751,46 @@ discard block |
||
3751 | 3751 | * @version 3.0.1 |
3752 | 3752 | */ |
3753 | 3753 | class CssCompressColorValuesMinifierPlugin extends aCssMinifierPlugin |
3754 | - { |
|
3755 | - /** |
|
3756 | - * Regular expression matching 6 char hexadecimal color values. |
|
3757 | - * |
|
3758 | - * @var string |
|
3759 | - */ |
|
3760 | - private $reMatch = "/\#([0-9a-f]{6})/iS"; |
|
3761 | - /** |
|
3762 | - * Implements {@link aCssMinifierPlugin::minify()}. |
|
3763 | - * |
|
3764 | - * @param aCssToken $token Token to process |
|
3765 | - * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
3766 | - */ |
|
3767 | - public function apply(aCssToken &$token) |
|
3768 | - { |
|
3769 | - if (strpos($token->Value, "#") !== false && preg_match($this->reMatch, $token->Value, $m)) |
|
3770 | - { |
|
3771 | - $value = strtolower($m[1]); |
|
3772 | - if ($value[0] == $value[1] && $value[2] == $value[3] && $value[4] == $value[5]) |
|
3773 | - { |
|
3774 | - $token->Value = str_replace($m[0], "#" . $value[0] . $value[2] . $value[4], $token->Value); |
|
3775 | - } |
|
3776 | - } |
|
3777 | - return false; |
|
3778 | - } |
|
3779 | - /** |
|
3780 | - * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
3781 | - * |
|
3782 | - * @return array |
|
3783 | - */ |
|
3784 | - public function getTriggerTokens() |
|
3785 | - { |
|
3786 | - return array |
|
3787 | - ( |
|
3788 | - "CssAtFontFaceDeclarationToken", |
|
3789 | - "CssAtPageDeclarationToken", |
|
3790 | - "CssRulesetDeclarationToken" |
|
3791 | - ); |
|
3792 | - } |
|
3793 | - } |
|
3754 | + { |
|
3755 | + /** |
|
3756 | + * Regular expression matching 6 char hexadecimal color values. |
|
3757 | + * |
|
3758 | + * @var string |
|
3759 | + */ |
|
3760 | + private $reMatch = "/\#([0-9a-f]{6})/iS"; |
|
3761 | + /** |
|
3762 | + * Implements {@link aCssMinifierPlugin::minify()}. |
|
3763 | + * |
|
3764 | + * @param aCssToken $token Token to process |
|
3765 | + * @return boolean Return TRUE to break the processing of this token; FALSE to continue |
|
3766 | + */ |
|
3767 | + public function apply(aCssToken &$token) |
|
3768 | + { |
|
3769 | + if (strpos($token->Value, "#") !== false && preg_match($this->reMatch, $token->Value, $m)) |
|
3770 | + { |
|
3771 | + $value = strtolower($m[1]); |
|
3772 | + if ($value[0] == $value[1] && $value[2] == $value[3] && $value[4] == $value[5]) |
|
3773 | + { |
|
3774 | + $token->Value = str_replace($m[0], "#" . $value[0] . $value[2] . $value[4], $token->Value); |
|
3775 | + } |
|
3776 | + } |
|
3777 | + return false; |
|
3778 | + } |
|
3779 | + /** |
|
3780 | + * Implements {@link aMinifierPlugin::getTriggerTokens()} |
|
3781 | + * |
|
3782 | + * @return array |
|
3783 | + */ |
|
3784 | + public function getTriggerTokens() |
|
3785 | + { |
|
3786 | + return array |
|
3787 | + ( |
|
3788 | + "CssAtFontFaceDeclarationToken", |
|
3789 | + "CssAtPageDeclarationToken", |
|
3790 | + "CssRulesetDeclarationToken" |
|
3791 | + ); |
|
3792 | + } |
|
3793 | + } |
|
3794 | 3794 | |
3795 | 3795 | /** |
3796 | 3796 | * This {@link aCssToken CSS token} represents a CSS comment. |
@@ -3803,33 +3803,33 @@ discard block |
||
3803 | 3803 | * @version 3.0.1 |
3804 | 3804 | */ |
3805 | 3805 | class CssCommentToken extends aCssToken |
3806 | - { |
|
3807 | - /** |
|
3808 | - * Comment as Text. |
|
3809 | - * |
|
3810 | - * @var string |
|
3811 | - */ |
|
3812 | - public $Comment = ""; |
|
3813 | - /** |
|
3814 | - * Set the properties of a comment token. |
|
3815 | - * |
|
3816 | - * @param string $comment Comment including comment delimiters |
|
3817 | - * @return void |
|
3818 | - */ |
|
3819 | - public function __construct($comment) |
|
3820 | - { |
|
3821 | - $this->Comment = $comment; |
|
3822 | - } |
|
3823 | - /** |
|
3824 | - * Implements {@link aCssToken::__toString()}. |
|
3825 | - * |
|
3826 | - * @return string |
|
3827 | - */ |
|
3828 | - public function __toString() |
|
3829 | - { |
|
3830 | - return $this->Comment; |
|
3831 | - } |
|
3832 | - } |
|
3806 | + { |
|
3807 | + /** |
|
3808 | + * Comment as Text. |
|
3809 | + * |
|
3810 | + * @var string |
|
3811 | + */ |
|
3812 | + public $Comment = ""; |
|
3813 | + /** |
|
3814 | + * Set the properties of a comment token. |
|
3815 | + * |
|
3816 | + * @param string $comment Comment including comment delimiters |
|
3817 | + * @return void |
|
3818 | + */ |
|
3819 | + public function __construct($comment) |
|
3820 | + { |
|
3821 | + $this->Comment = $comment; |
|
3822 | + } |
|
3823 | + /** |
|
3824 | + * Implements {@link aCssToken::__toString()}. |
|
3825 | + * |
|
3826 | + * @return string |
|
3827 | + */ |
|
3828 | + public function __toString() |
|
3829 | + { |
|
3830 | + return $this->Comment; |
|
3831 | + } |
|
3832 | + } |
|
3833 | 3833 | |
3834 | 3834 | /** |
3835 | 3835 | * {@link aCssParserPlugin Parser plugin} for parsing comments. |
@@ -3844,61 +3844,61 @@ discard block |
||
3844 | 3844 | * @version 3.0.1 |
3845 | 3845 | */ |
3846 | 3846 | class CssCommentParserPlugin extends aCssParserPlugin |
3847 | - { |
|
3848 | - /** |
|
3849 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
3850 | - * |
|
3851 | - * @return array |
|
3852 | - */ |
|
3853 | - public function getTriggerChars() |
|
3854 | - { |
|
3855 | - return array("*", "/"); |
|
3856 | - } |
|
3857 | - /** |
|
3858 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
3859 | - * |
|
3860 | - * @return array |
|
3861 | - */ |
|
3862 | - public function getTriggerStates() |
|
3863 | - { |
|
3864 | - return false; |
|
3865 | - } |
|
3866 | - /** |
|
3867 | - * Stored buffer for restore. |
|
3868 | - * |
|
3869 | - * @var string |
|
3870 | - */ |
|
3871 | - private $restoreBuffer = ""; |
|
3872 | - /** |
|
3873 | - * Implements {@link aCssParserPlugin::parse()}. |
|
3874 | - * |
|
3875 | - * @param integer $index Current index |
|
3876 | - * @param string $char Current char |
|
3877 | - * @param string $previousChar Previous char |
|
3878 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
3879 | - */ |
|
3880 | - public function parse($index, $char, $previousChar, $state) |
|
3881 | - { |
|
3882 | - if ($char === "*" && $previousChar === "/" && $state !== "T_COMMENT") |
|
3883 | - { |
|
3884 | - $this->parser->pushState("T_COMMENT"); |
|
3885 | - $this->parser->setExclusive(__CLASS__); |
|
3886 | - $this->restoreBuffer = substr($this->parser->getAndClearBuffer(), 0, -2); |
|
3887 | - } |
|
3888 | - elseif ($char === "/" && $previousChar === "*" && $state === "T_COMMENT") |
|
3889 | - { |
|
3890 | - $this->parser->popState(); |
|
3891 | - $this->parser->unsetExclusive(); |
|
3892 | - $this->parser->appendToken(new CssCommentToken("/*" . $this->parser->getAndClearBuffer())); |
|
3893 | - $this->parser->setBuffer($this->restoreBuffer); |
|
3894 | - } |
|
3895 | - else |
|
3896 | - { |
|
3897 | - return false; |
|
3898 | - } |
|
3899 | - return true; |
|
3900 | - } |
|
3901 | - } |
|
3847 | + { |
|
3848 | + /** |
|
3849 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
3850 | + * |
|
3851 | + * @return array |
|
3852 | + */ |
|
3853 | + public function getTriggerChars() |
|
3854 | + { |
|
3855 | + return array("*", "/"); |
|
3856 | + } |
|
3857 | + /** |
|
3858 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
3859 | + * |
|
3860 | + * @return array |
|
3861 | + */ |
|
3862 | + public function getTriggerStates() |
|
3863 | + { |
|
3864 | + return false; |
|
3865 | + } |
|
3866 | + /** |
|
3867 | + * Stored buffer for restore. |
|
3868 | + * |
|
3869 | + * @var string |
|
3870 | + */ |
|
3871 | + private $restoreBuffer = ""; |
|
3872 | + /** |
|
3873 | + * Implements {@link aCssParserPlugin::parse()}. |
|
3874 | + * |
|
3875 | + * @param integer $index Current index |
|
3876 | + * @param string $char Current char |
|
3877 | + * @param string $previousChar Previous char |
|
3878 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
3879 | + */ |
|
3880 | + public function parse($index, $char, $previousChar, $state) |
|
3881 | + { |
|
3882 | + if ($char === "*" && $previousChar === "/" && $state !== "T_COMMENT") |
|
3883 | + { |
|
3884 | + $this->parser->pushState("T_COMMENT"); |
|
3885 | + $this->parser->setExclusive(__CLASS__); |
|
3886 | + $this->restoreBuffer = substr($this->parser->getAndClearBuffer(), 0, -2); |
|
3887 | + } |
|
3888 | + elseif ($char === "/" && $previousChar === "*" && $state === "T_COMMENT") |
|
3889 | + { |
|
3890 | + $this->parser->popState(); |
|
3891 | + $this->parser->unsetExclusive(); |
|
3892 | + $this->parser->appendToken(new CssCommentToken("/*" . $this->parser->getAndClearBuffer())); |
|
3893 | + $this->parser->setBuffer($this->restoreBuffer); |
|
3894 | + } |
|
3895 | + else |
|
3896 | + { |
|
3897 | + return false; |
|
3898 | + } |
|
3899 | + return true; |
|
3900 | + } |
|
3901 | + } |
|
3902 | 3902 | |
3903 | 3903 | /** |
3904 | 3904 | * This {@link aCssToken CSS token} represents the start of a @variables at-rule block. |
@@ -3911,33 +3911,33 @@ discard block |
||
3911 | 3911 | * @version 3.0.1 |
3912 | 3912 | */ |
3913 | 3913 | class CssAtVariablesStartToken extends aCssAtBlockStartToken |
3914 | - { |
|
3915 | - /** |
|
3916 | - * Media types of the @variables at-rule block. |
|
3917 | - * |
|
3918 | - * @var array |
|
3919 | - */ |
|
3920 | - public $MediaTypes = array(); |
|
3921 | - /** |
|
3922 | - * Set the properties of a @variables at-rule token. |
|
3923 | - * |
|
3924 | - * @param array $mediaTypes Media types |
|
3925 | - * @return void |
|
3926 | - */ |
|
3927 | - public function __construct($mediaTypes = null) |
|
3928 | - { |
|
3929 | - $this->MediaTypes = $mediaTypes ? $mediaTypes : array("all"); |
|
3930 | - } |
|
3931 | - /** |
|
3932 | - * Implements {@link aCssToken::__toString()}. |
|
3933 | - * |
|
3934 | - * @return string |
|
3935 | - */ |
|
3936 | - public function __toString() |
|
3937 | - { |
|
3938 | - return ""; |
|
3939 | - } |
|
3940 | - } |
|
3914 | + { |
|
3915 | + /** |
|
3916 | + * Media types of the @variables at-rule block. |
|
3917 | + * |
|
3918 | + * @var array |
|
3919 | + */ |
|
3920 | + public $MediaTypes = array(); |
|
3921 | + /** |
|
3922 | + * Set the properties of a @variables at-rule token. |
|
3923 | + * |
|
3924 | + * @param array $mediaTypes Media types |
|
3925 | + * @return void |
|
3926 | + */ |
|
3927 | + public function __construct($mediaTypes = null) |
|
3928 | + { |
|
3929 | + $this->MediaTypes = $mediaTypes ? $mediaTypes : array("all"); |
|
3930 | + } |
|
3931 | + /** |
|
3932 | + * Implements {@link aCssToken::__toString()}. |
|
3933 | + * |
|
3934 | + * @return string |
|
3935 | + */ |
|
3936 | + public function __toString() |
|
3937 | + { |
|
3938 | + return ""; |
|
3939 | + } |
|
3940 | + } |
|
3941 | 3941 | |
3942 | 3942 | /** |
3943 | 3943 | * {@link aCssParserPlugin Parser plugin} for parsing @variables at-rule block with including declarations. |
@@ -3953,96 +3953,96 @@ discard block |
||
3953 | 3953 | * @version 3.0.1 |
3954 | 3954 | */ |
3955 | 3955 | class CssAtVariablesParserPlugin extends aCssParserPlugin |
3956 | - { |
|
3957 | - /** |
|
3958 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
3959 | - * |
|
3960 | - * @return array |
|
3961 | - */ |
|
3962 | - public function getTriggerChars() |
|
3963 | - { |
|
3964 | - return array("@", "{", "}", ":", ";"); |
|
3965 | - } |
|
3966 | - /** |
|
3967 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
3968 | - * |
|
3969 | - * @return array |
|
3970 | - */ |
|
3971 | - public function getTriggerStates() |
|
3972 | - { |
|
3973 | - return array("T_DOCUMENT", "T_AT_VARIABLES::PREPARE", "T_AT_VARIABLES", "T_AT_VARIABLES_DECLARATION"); |
|
3974 | - } |
|
3975 | - /** |
|
3976 | - * Implements {@link aCssParserPlugin::parse()}. |
|
3977 | - * |
|
3978 | - * @param integer $index Current index |
|
3979 | - * @param string $char Current char |
|
3980 | - * @param string $previousChar Previous char |
|
3981 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
3982 | - */ |
|
3983 | - public function parse($index, $char, $previousChar, $state) |
|
3984 | - { |
|
3985 | - // Start of @variables at-rule block |
|
3986 | - if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 10)) === "@variables") |
|
3987 | - { |
|
3988 | - $this->parser->pushState("T_AT_VARIABLES::PREPARE"); |
|
3989 | - $this->parser->clearBuffer(); |
|
3990 | - return $index + 10; |
|
3991 | - } |
|
3992 | - // Start of @variables declarations |
|
3993 | - elseif ($char === "{" && $state === "T_AT_VARIABLES::PREPARE") |
|
3994 | - { |
|
3995 | - $this->parser->setState("T_AT_VARIABLES"); |
|
3996 | - $mediaTypes = array_filter(array_map("trim", explode(",", $this->parser->getAndClearBuffer("{")))); |
|
3997 | - $this->parser->appendToken(new CssAtVariablesStartToken($mediaTypes)); |
|
3998 | - } |
|
3999 | - // Start of @variables declaration |
|
4000 | - if ($char === ":" && $state === "T_AT_VARIABLES") |
|
4001 | - { |
|
4002 | - $this->buffer = $this->parser->getAndClearBuffer(":"); |
|
4003 | - $this->parser->pushState("T_AT_VARIABLES_DECLARATION"); |
|
4004 | - } |
|
4005 | - // Unterminated @variables declaration |
|
4006 | - elseif ($char === ":" && $state === "T_AT_VARIABLES_DECLARATION") |
|
4007 | - { |
|
4008 | - // Ignore Internet Explorer filter declarations |
|
4009 | - if ($this->buffer === "filter") |
|
4010 | - { |
|
4011 | - return false; |
|
4012 | - } |
|
4013 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated @variables declaration", $this->buffer . ":" . $this->parser->getBuffer() . "_")); |
|
4014 | - } |
|
4015 | - // End of @variables declaration |
|
4016 | - elseif (($char === ";" || $char === "}") && $state === "T_AT_VARIABLES_DECLARATION") |
|
4017 | - { |
|
4018 | - $value = $this->parser->getAndClearBuffer(";}"); |
|
4019 | - if (strtolower(substr($value, -10, 10)) === "!important") |
|
4020 | - { |
|
4021 | - $value = trim(substr($value, 0, -10)); |
|
4022 | - $isImportant = true; |
|
4023 | - } |
|
4024 | - else |
|
4025 | - { |
|
4026 | - $isImportant = false; |
|
4027 | - } |
|
4028 | - $this->parser->popState(); |
|
4029 | - $this->parser->appendToken(new CssAtVariablesDeclarationToken($this->buffer, $value, $isImportant)); |
|
4030 | - $this->buffer = ""; |
|
4031 | - } |
|
4032 | - // End of @variables at-rule block |
|
4033 | - elseif ($char === "}" && $state === "T_AT_VARIABLES") |
|
4034 | - { |
|
4035 | - $this->parser->popState(); |
|
4036 | - $this->parser->clearBuffer(); |
|
4037 | - $this->parser->appendToken(new CssAtVariablesEndToken()); |
|
4038 | - } |
|
4039 | - else |
|
4040 | - { |
|
4041 | - return false; |
|
4042 | - } |
|
4043 | - return true; |
|
4044 | - } |
|
4045 | - } |
|
3956 | + { |
|
3957 | + /** |
|
3958 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
3959 | + * |
|
3960 | + * @return array |
|
3961 | + */ |
|
3962 | + public function getTriggerChars() |
|
3963 | + { |
|
3964 | + return array("@", "{", "}", ":", ";"); |
|
3965 | + } |
|
3966 | + /** |
|
3967 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
3968 | + * |
|
3969 | + * @return array |
|
3970 | + */ |
|
3971 | + public function getTriggerStates() |
|
3972 | + { |
|
3973 | + return array("T_DOCUMENT", "T_AT_VARIABLES::PREPARE", "T_AT_VARIABLES", "T_AT_VARIABLES_DECLARATION"); |
|
3974 | + } |
|
3975 | + /** |
|
3976 | + * Implements {@link aCssParserPlugin::parse()}. |
|
3977 | + * |
|
3978 | + * @param integer $index Current index |
|
3979 | + * @param string $char Current char |
|
3980 | + * @param string $previousChar Previous char |
|
3981 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
3982 | + */ |
|
3983 | + public function parse($index, $char, $previousChar, $state) |
|
3984 | + { |
|
3985 | + // Start of @variables at-rule block |
|
3986 | + if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 10)) === "@variables") |
|
3987 | + { |
|
3988 | + $this->parser->pushState("T_AT_VARIABLES::PREPARE"); |
|
3989 | + $this->parser->clearBuffer(); |
|
3990 | + return $index + 10; |
|
3991 | + } |
|
3992 | + // Start of @variables declarations |
|
3993 | + elseif ($char === "{" && $state === "T_AT_VARIABLES::PREPARE") |
|
3994 | + { |
|
3995 | + $this->parser->setState("T_AT_VARIABLES"); |
|
3996 | + $mediaTypes = array_filter(array_map("trim", explode(",", $this->parser->getAndClearBuffer("{")))); |
|
3997 | + $this->parser->appendToken(new CssAtVariablesStartToken($mediaTypes)); |
|
3998 | + } |
|
3999 | + // Start of @variables declaration |
|
4000 | + if ($char === ":" && $state === "T_AT_VARIABLES") |
|
4001 | + { |
|
4002 | + $this->buffer = $this->parser->getAndClearBuffer(":"); |
|
4003 | + $this->parser->pushState("T_AT_VARIABLES_DECLARATION"); |
|
4004 | + } |
|
4005 | + // Unterminated @variables declaration |
|
4006 | + elseif ($char === ":" && $state === "T_AT_VARIABLES_DECLARATION") |
|
4007 | + { |
|
4008 | + // Ignore Internet Explorer filter declarations |
|
4009 | + if ($this->buffer === "filter") |
|
4010 | + { |
|
4011 | + return false; |
|
4012 | + } |
|
4013 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated @variables declaration", $this->buffer . ":" . $this->parser->getBuffer() . "_")); |
|
4014 | + } |
|
4015 | + // End of @variables declaration |
|
4016 | + elseif (($char === ";" || $char === "}") && $state === "T_AT_VARIABLES_DECLARATION") |
|
4017 | + { |
|
4018 | + $value = $this->parser->getAndClearBuffer(";}"); |
|
4019 | + if (strtolower(substr($value, -10, 10)) === "!important") |
|
4020 | + { |
|
4021 | + $value = trim(substr($value, 0, -10)); |
|
4022 | + $isImportant = true; |
|
4023 | + } |
|
4024 | + else |
|
4025 | + { |
|
4026 | + $isImportant = false; |
|
4027 | + } |
|
4028 | + $this->parser->popState(); |
|
4029 | + $this->parser->appendToken(new CssAtVariablesDeclarationToken($this->buffer, $value, $isImportant)); |
|
4030 | + $this->buffer = ""; |
|
4031 | + } |
|
4032 | + // End of @variables at-rule block |
|
4033 | + elseif ($char === "}" && $state === "T_AT_VARIABLES") |
|
4034 | + { |
|
4035 | + $this->parser->popState(); |
|
4036 | + $this->parser->clearBuffer(); |
|
4037 | + $this->parser->appendToken(new CssAtVariablesEndToken()); |
|
4038 | + } |
|
4039 | + else |
|
4040 | + { |
|
4041 | + return false; |
|
4042 | + } |
|
4043 | + return true; |
|
4044 | + } |
|
4045 | + } |
|
4046 | 4046 | |
4047 | 4047 | /** |
4048 | 4048 | * This {@link aCssToken CSS token} represents the end of a @variables at-rule block. |
@@ -4055,17 +4055,17 @@ discard block |
||
4055 | 4055 | * @version 3.0.1 |
4056 | 4056 | */ |
4057 | 4057 | class CssAtVariablesEndToken extends aCssAtBlockEndToken |
4058 | - { |
|
4059 | - /** |
|
4060 | - * Implements {@link aCssToken::__toString()}. |
|
4061 | - * |
|
4062 | - * @return string |
|
4063 | - */ |
|
4064 | - public function __toString() |
|
4065 | - { |
|
4066 | - return ""; |
|
4067 | - } |
|
4068 | - } |
|
4058 | + { |
|
4059 | + /** |
|
4060 | + * Implements {@link aCssToken::__toString()}. |
|
4061 | + * |
|
4062 | + * @return string |
|
4063 | + */ |
|
4064 | + public function __toString() |
|
4065 | + { |
|
4066 | + return ""; |
|
4067 | + } |
|
4068 | + } |
|
4069 | 4069 | |
4070 | 4070 | /** |
4071 | 4071 | * This {@link aCssToken CSS token} represents a declaration of a @variables at-rule block. |
@@ -4078,17 +4078,17 @@ discard block |
||
4078 | 4078 | * @version 3.0.1 |
4079 | 4079 | */ |
4080 | 4080 | class CssAtVariablesDeclarationToken extends aCssDeclarationToken |
4081 | - { |
|
4082 | - /** |
|
4083 | - * Implements {@link aCssToken::__toString()}. |
|
4084 | - * |
|
4085 | - * @return string |
|
4086 | - */ |
|
4087 | - public function __toString() |
|
4088 | - { |
|
4089 | - return ""; |
|
4090 | - } |
|
4091 | - } |
|
4081 | + { |
|
4082 | + /** |
|
4083 | + * Implements {@link aCssToken::__toString()}. |
|
4084 | + * |
|
4085 | + * @return string |
|
4086 | + */ |
|
4087 | + public function __toString() |
|
4088 | + { |
|
4089 | + return ""; |
|
4090 | + } |
|
4091 | + } |
|
4092 | 4092 | |
4093 | 4093 | /** |
4094 | 4094 | * This {@link aCssToken CSS token} represents the start of a @page at-rule block. |
@@ -4101,33 +4101,33 @@ discard block |
||
4101 | 4101 | * @version 3.0.1 |
4102 | 4102 | */ |
4103 | 4103 | class CssAtPageStartToken extends aCssAtBlockStartToken |
4104 | - { |
|
4105 | - /** |
|
4106 | - * Selector. |
|
4107 | - * |
|
4108 | - * @var string |
|
4109 | - */ |
|
4110 | - public $Selector = ""; |
|
4111 | - /** |
|
4112 | - * Sets the properties of the @page at-rule. |
|
4113 | - * |
|
4114 | - * @param string $selector Selector |
|
4115 | - * @return void |
|
4116 | - */ |
|
4117 | - public function __construct($selector = "") |
|
4118 | - { |
|
4119 | - $this->Selector = $selector; |
|
4120 | - } |
|
4121 | - /** |
|
4122 | - * Implements {@link aCssToken::__toString()}. |
|
4123 | - * |
|
4124 | - * @return string |
|
4125 | - */ |
|
4126 | - public function __toString() |
|
4127 | - { |
|
4128 | - return "@page" . ($this->Selector ? " " . $this->Selector : "") . "{"; |
|
4129 | - } |
|
4130 | - } |
|
4104 | + { |
|
4105 | + /** |
|
4106 | + * Selector. |
|
4107 | + * |
|
4108 | + * @var string |
|
4109 | + */ |
|
4110 | + public $Selector = ""; |
|
4111 | + /** |
|
4112 | + * Sets the properties of the @page at-rule. |
|
4113 | + * |
|
4114 | + * @param string $selector Selector |
|
4115 | + * @return void |
|
4116 | + */ |
|
4117 | + public function __construct($selector = "") |
|
4118 | + { |
|
4119 | + $this->Selector = $selector; |
|
4120 | + } |
|
4121 | + /** |
|
4122 | + * Implements {@link aCssToken::__toString()}. |
|
4123 | + * |
|
4124 | + * @return string |
|
4125 | + */ |
|
4126 | + public function __toString() |
|
4127 | + { |
|
4128 | + return "@page" . ($this->Selector ? " " . $this->Selector : "") . "{"; |
|
4129 | + } |
|
4130 | + } |
|
4131 | 4131 | |
4132 | 4132 | /** |
4133 | 4133 | * {@link aCssParserPlugin Parser plugin} for parsing @page at-rule block with including declarations. |
@@ -4143,103 +4143,103 @@ discard block |
||
4143 | 4143 | * @version 3.0.1 |
4144 | 4144 | */ |
4145 | 4145 | class CssAtPageParserPlugin extends aCssParserPlugin |
4146 | - { |
|
4147 | - /** |
|
4148 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
4149 | - * |
|
4150 | - * @return array |
|
4151 | - */ |
|
4152 | - public function getTriggerChars() |
|
4153 | - { |
|
4154 | - return array("@", "{", "}", ":", ";"); |
|
4155 | - } |
|
4156 | - /** |
|
4157 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
4158 | - * |
|
4159 | - * @return array |
|
4160 | - */ |
|
4161 | - public function getTriggerStates() |
|
4162 | - { |
|
4163 | - return array("T_DOCUMENT", "T_AT_PAGE::SELECTOR", "T_AT_PAGE", "T_AT_PAGE_DECLARATION"); |
|
4164 | - } |
|
4165 | - /** |
|
4166 | - * Implements {@link aCssParserPlugin::parse()}. |
|
4167 | - * |
|
4168 | - * @param integer $index Current index |
|
4169 | - * @param string $char Current char |
|
4170 | - * @param string $previousChar Previous char |
|
4171 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
4172 | - */ |
|
4173 | - public function parse($index, $char, $previousChar, $state) |
|
4174 | - { |
|
4175 | - // Start of @page at-rule block |
|
4176 | - if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 5)) === "@page") |
|
4177 | - { |
|
4178 | - $this->parser->pushState("T_AT_PAGE::SELECTOR"); |
|
4179 | - $this->parser->clearBuffer(); |
|
4180 | - return $index + 5; |
|
4181 | - } |
|
4182 | - // Start of @page declarations |
|
4183 | - elseif ($char === "{" && $state === "T_AT_PAGE::SELECTOR") |
|
4184 | - { |
|
4185 | - $selector = $this->parser->getAndClearBuffer("{"); |
|
4186 | - $this->parser->setState("T_AT_PAGE"); |
|
4187 | - $this->parser->clearBuffer(); |
|
4188 | - $this->parser->appendToken(new CssAtPageStartToken($selector)); |
|
4189 | - } |
|
4190 | - // Start of @page declaration |
|
4191 | - elseif ($char === ":" && $state === "T_AT_PAGE") |
|
4192 | - { |
|
4193 | - $this->parser->pushState("T_AT_PAGE_DECLARATION"); |
|
4194 | - $this->buffer = $this->parser->getAndClearBuffer(":", true); |
|
4195 | - } |
|
4196 | - // Unterminated @font-face declaration |
|
4197 | - elseif ($char === ":" && $state === "T_AT_PAGE_DECLARATION") |
|
4198 | - { |
|
4199 | - // Ignore Internet Explorer filter declarations |
|
4200 | - if ($this->buffer === "filter") |
|
4201 | - { |
|
4202 | - return false; |
|
4203 | - } |
|
4204 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated @page declaration", $this->buffer . ":" . $this->parser->getBuffer() . "_")); |
|
4205 | - } |
|
4206 | - // End of @page declaration |
|
4207 | - elseif (($char === ";" || $char === "}") && $state == "T_AT_PAGE_DECLARATION") |
|
4208 | - { |
|
4209 | - $value = $this->parser->getAndClearBuffer(";}"); |
|
4210 | - if (strtolower(substr($value, -10, 10)) == "!important") |
|
4211 | - { |
|
4212 | - $value = trim(substr($value, 0, -10)); |
|
4213 | - $isImportant = true; |
|
4214 | - } |
|
4215 | - else |
|
4216 | - { |
|
4217 | - $isImportant = false; |
|
4218 | - } |
|
4219 | - $this->parser->popState(); |
|
4220 | - $this->parser->appendToken(new CssAtPageDeclarationToken($this->buffer, $value, $isImportant)); |
|
4221 | - // -- |
|
4222 | - if ($char === "}") |
|
4223 | - { |
|
4224 | - $this->parser->popState(); |
|
4225 | - $this->parser->appendToken(new CssAtPageEndToken()); |
|
4226 | - } |
|
4227 | - $this->buffer = ""; |
|
4228 | - } |
|
4229 | - // End of @page at-rule block |
|
4230 | - elseif ($char === "}" && $state === "T_AT_PAGE") |
|
4231 | - { |
|
4232 | - $this->parser->popState(); |
|
4233 | - $this->parser->clearBuffer(); |
|
4234 | - $this->parser->appendToken(new CssAtPageEndToken()); |
|
4235 | - } |
|
4236 | - else |
|
4237 | - { |
|
4238 | - return false; |
|
4239 | - } |
|
4240 | - return true; |
|
4241 | - } |
|
4242 | - } |
|
4146 | + { |
|
4147 | + /** |
|
4148 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
4149 | + * |
|
4150 | + * @return array |
|
4151 | + */ |
|
4152 | + public function getTriggerChars() |
|
4153 | + { |
|
4154 | + return array("@", "{", "}", ":", ";"); |
|
4155 | + } |
|
4156 | + /** |
|
4157 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
4158 | + * |
|
4159 | + * @return array |
|
4160 | + */ |
|
4161 | + public function getTriggerStates() |
|
4162 | + { |
|
4163 | + return array("T_DOCUMENT", "T_AT_PAGE::SELECTOR", "T_AT_PAGE", "T_AT_PAGE_DECLARATION"); |
|
4164 | + } |
|
4165 | + /** |
|
4166 | + * Implements {@link aCssParserPlugin::parse()}. |
|
4167 | + * |
|
4168 | + * @param integer $index Current index |
|
4169 | + * @param string $char Current char |
|
4170 | + * @param string $previousChar Previous char |
|
4171 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
4172 | + */ |
|
4173 | + public function parse($index, $char, $previousChar, $state) |
|
4174 | + { |
|
4175 | + // Start of @page at-rule block |
|
4176 | + if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 5)) === "@page") |
|
4177 | + { |
|
4178 | + $this->parser->pushState("T_AT_PAGE::SELECTOR"); |
|
4179 | + $this->parser->clearBuffer(); |
|
4180 | + return $index + 5; |
|
4181 | + } |
|
4182 | + // Start of @page declarations |
|
4183 | + elseif ($char === "{" && $state === "T_AT_PAGE::SELECTOR") |
|
4184 | + { |
|
4185 | + $selector = $this->parser->getAndClearBuffer("{"); |
|
4186 | + $this->parser->setState("T_AT_PAGE"); |
|
4187 | + $this->parser->clearBuffer(); |
|
4188 | + $this->parser->appendToken(new CssAtPageStartToken($selector)); |
|
4189 | + } |
|
4190 | + // Start of @page declaration |
|
4191 | + elseif ($char === ":" && $state === "T_AT_PAGE") |
|
4192 | + { |
|
4193 | + $this->parser->pushState("T_AT_PAGE_DECLARATION"); |
|
4194 | + $this->buffer = $this->parser->getAndClearBuffer(":", true); |
|
4195 | + } |
|
4196 | + // Unterminated @font-face declaration |
|
4197 | + elseif ($char === ":" && $state === "T_AT_PAGE_DECLARATION") |
|
4198 | + { |
|
4199 | + // Ignore Internet Explorer filter declarations |
|
4200 | + if ($this->buffer === "filter") |
|
4201 | + { |
|
4202 | + return false; |
|
4203 | + } |
|
4204 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated @page declaration", $this->buffer . ":" . $this->parser->getBuffer() . "_")); |
|
4205 | + } |
|
4206 | + // End of @page declaration |
|
4207 | + elseif (($char === ";" || $char === "}") && $state == "T_AT_PAGE_DECLARATION") |
|
4208 | + { |
|
4209 | + $value = $this->parser->getAndClearBuffer(";}"); |
|
4210 | + if (strtolower(substr($value, -10, 10)) == "!important") |
|
4211 | + { |
|
4212 | + $value = trim(substr($value, 0, -10)); |
|
4213 | + $isImportant = true; |
|
4214 | + } |
|
4215 | + else |
|
4216 | + { |
|
4217 | + $isImportant = false; |
|
4218 | + } |
|
4219 | + $this->parser->popState(); |
|
4220 | + $this->parser->appendToken(new CssAtPageDeclarationToken($this->buffer, $value, $isImportant)); |
|
4221 | + // -- |
|
4222 | + if ($char === "}") |
|
4223 | + { |
|
4224 | + $this->parser->popState(); |
|
4225 | + $this->parser->appendToken(new CssAtPageEndToken()); |
|
4226 | + } |
|
4227 | + $this->buffer = ""; |
|
4228 | + } |
|
4229 | + // End of @page at-rule block |
|
4230 | + elseif ($char === "}" && $state === "T_AT_PAGE") |
|
4231 | + { |
|
4232 | + $this->parser->popState(); |
|
4233 | + $this->parser->clearBuffer(); |
|
4234 | + $this->parser->appendToken(new CssAtPageEndToken()); |
|
4235 | + } |
|
4236 | + else |
|
4237 | + { |
|
4238 | + return false; |
|
4239 | + } |
|
4240 | + return true; |
|
4241 | + } |
|
4242 | + } |
|
4243 | 4243 | |
4244 | 4244 | /** |
4245 | 4245 | * This {@link aCssToken CSS token} represents the end of a @page at-rule block. |
@@ -4252,9 +4252,9 @@ discard block |
||
4252 | 4252 | * @version 3.0.1 |
4253 | 4253 | */ |
4254 | 4254 | class CssAtPageEndToken extends aCssAtBlockEndToken |
4255 | - { |
|
4255 | + { |
|
4256 | 4256 | |
4257 | - } |
|
4257 | + } |
|
4258 | 4258 | |
4259 | 4259 | /** |
4260 | 4260 | * This {@link aCssToken CSS token} represents a declaration of a @page at-rule block. |
@@ -4267,9 +4267,9 @@ discard block |
||
4267 | 4267 | * @version 3.0.1 |
4268 | 4268 | */ |
4269 | 4269 | class CssAtPageDeclarationToken extends aCssDeclarationToken |
4270 | - { |
|
4270 | + { |
|
4271 | 4271 | |
4272 | - } |
|
4272 | + } |
|
4273 | 4273 | |
4274 | 4274 | /** |
4275 | 4275 | * This {@link aCssToken CSS token} represents the start of a @media at-rule block. |
@@ -4282,27 +4282,27 @@ discard block |
||
4282 | 4282 | * @version 3.0.1 |
4283 | 4283 | */ |
4284 | 4284 | class CssAtMediaStartToken extends aCssAtBlockStartToken |
4285 | - { |
|
4286 | - /** |
|
4287 | - * Sets the properties of the @media at-rule. |
|
4288 | - * |
|
4289 | - * @param array $mediaTypes Media types |
|
4290 | - * @return void |
|
4291 | - */ |
|
4292 | - public function __construct(array $mediaTypes = array()) |
|
4293 | - { |
|
4294 | - $this->MediaTypes = $mediaTypes; |
|
4295 | - } |
|
4296 | - /** |
|
4297 | - * Implements {@link aCssToken::__toString()}. |
|
4298 | - * |
|
4299 | - * @return string |
|
4300 | - */ |
|
4301 | - public function __toString() |
|
4302 | - { |
|
4303 | - return "@media " . implode(",", $this->MediaTypes) . "{"; |
|
4304 | - } |
|
4305 | - } |
|
4285 | + { |
|
4286 | + /** |
|
4287 | + * Sets the properties of the @media at-rule. |
|
4288 | + * |
|
4289 | + * @param array $mediaTypes Media types |
|
4290 | + * @return void |
|
4291 | + */ |
|
4292 | + public function __construct(array $mediaTypes = array()) |
|
4293 | + { |
|
4294 | + $this->MediaTypes = $mediaTypes; |
|
4295 | + } |
|
4296 | + /** |
|
4297 | + * Implements {@link aCssToken::__toString()}. |
|
4298 | + * |
|
4299 | + * @return string |
|
4300 | + */ |
|
4301 | + public function __toString() |
|
4302 | + { |
|
4303 | + return "@media " . implode(",", $this->MediaTypes) . "{"; |
|
4304 | + } |
|
4305 | + } |
|
4306 | 4306 | |
4307 | 4307 | /** |
4308 | 4308 | * {@link aCssParserPlugin Parser plugin} for parsing @media at-rule block. |
@@ -4319,62 +4319,62 @@ discard block |
||
4319 | 4319 | * @version 3.0.1 |
4320 | 4320 | */ |
4321 | 4321 | class CssAtMediaParserPlugin extends aCssParserPlugin |
4322 | - { |
|
4323 | - /** |
|
4324 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
4325 | - * |
|
4326 | - * @return array |
|
4327 | - */ |
|
4328 | - public function getTriggerChars() |
|
4329 | - { |
|
4330 | - return array("@", "{", "}"); |
|
4331 | - } |
|
4332 | - /** |
|
4333 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
4334 | - * |
|
4335 | - * @return array |
|
4336 | - */ |
|
4337 | - public function getTriggerStates() |
|
4338 | - { |
|
4339 | - return array("T_DOCUMENT", "T_AT_MEDIA::PREPARE", "T_AT_MEDIA"); |
|
4340 | - } |
|
4341 | - /** |
|
4342 | - * Implements {@link aCssParserPlugin::parse()}. |
|
4343 | - * |
|
4344 | - * @param integer $index Current index |
|
4345 | - * @param string $char Current char |
|
4346 | - * @param string $previousChar Previous char |
|
4347 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
4348 | - */ |
|
4349 | - public function parse($index, $char, $previousChar, $state) |
|
4350 | - { |
|
4351 | - if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 6)) === "@media") |
|
4352 | - { |
|
4353 | - $this->parser->pushState("T_AT_MEDIA::PREPARE"); |
|
4354 | - $this->parser->clearBuffer(); |
|
4355 | - return $index + 6; |
|
4356 | - } |
|
4357 | - elseif ($char === "{" && $state === "T_AT_MEDIA::PREPARE") |
|
4358 | - { |
|
4359 | - $mediaTypes = array_filter(array_map("trim", explode(",", $this->parser->getAndClearBuffer("{")))); |
|
4360 | - $this->parser->setMediaTypes($mediaTypes); |
|
4361 | - $this->parser->setState("T_AT_MEDIA"); |
|
4362 | - $this->parser->appendToken(new CssAtMediaStartToken($mediaTypes)); |
|
4363 | - } |
|
4364 | - elseif ($char === "}" && $state === "T_AT_MEDIA") |
|
4365 | - { |
|
4366 | - $this->parser->appendToken(new CssAtMediaEndToken()); |
|
4367 | - $this->parser->clearBuffer(); |
|
4368 | - $this->parser->unsetMediaTypes(); |
|
4369 | - $this->parser->popState(); |
|
4370 | - } |
|
4371 | - else |
|
4372 | - { |
|
4373 | - return false; |
|
4374 | - } |
|
4375 | - return true; |
|
4376 | - } |
|
4377 | - } |
|
4322 | + { |
|
4323 | + /** |
|
4324 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
4325 | + * |
|
4326 | + * @return array |
|
4327 | + */ |
|
4328 | + public function getTriggerChars() |
|
4329 | + { |
|
4330 | + return array("@", "{", "}"); |
|
4331 | + } |
|
4332 | + /** |
|
4333 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
4334 | + * |
|
4335 | + * @return array |
|
4336 | + */ |
|
4337 | + public function getTriggerStates() |
|
4338 | + { |
|
4339 | + return array("T_DOCUMENT", "T_AT_MEDIA::PREPARE", "T_AT_MEDIA"); |
|
4340 | + } |
|
4341 | + /** |
|
4342 | + * Implements {@link aCssParserPlugin::parse()}. |
|
4343 | + * |
|
4344 | + * @param integer $index Current index |
|
4345 | + * @param string $char Current char |
|
4346 | + * @param string $previousChar Previous char |
|
4347 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
4348 | + */ |
|
4349 | + public function parse($index, $char, $previousChar, $state) |
|
4350 | + { |
|
4351 | + if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 6)) === "@media") |
|
4352 | + { |
|
4353 | + $this->parser->pushState("T_AT_MEDIA::PREPARE"); |
|
4354 | + $this->parser->clearBuffer(); |
|
4355 | + return $index + 6; |
|
4356 | + } |
|
4357 | + elseif ($char === "{" && $state === "T_AT_MEDIA::PREPARE") |
|
4358 | + { |
|
4359 | + $mediaTypes = array_filter(array_map("trim", explode(",", $this->parser->getAndClearBuffer("{")))); |
|
4360 | + $this->parser->setMediaTypes($mediaTypes); |
|
4361 | + $this->parser->setState("T_AT_MEDIA"); |
|
4362 | + $this->parser->appendToken(new CssAtMediaStartToken($mediaTypes)); |
|
4363 | + } |
|
4364 | + elseif ($char === "}" && $state === "T_AT_MEDIA") |
|
4365 | + { |
|
4366 | + $this->parser->appendToken(new CssAtMediaEndToken()); |
|
4367 | + $this->parser->clearBuffer(); |
|
4368 | + $this->parser->unsetMediaTypes(); |
|
4369 | + $this->parser->popState(); |
|
4370 | + } |
|
4371 | + else |
|
4372 | + { |
|
4373 | + return false; |
|
4374 | + } |
|
4375 | + return true; |
|
4376 | + } |
|
4377 | + } |
|
4378 | 4378 | |
4379 | 4379 | /** |
4380 | 4380 | * This {@link aCssToken CSS token} represents the end of a @media at-rule block. |
@@ -4387,9 +4387,9 @@ discard block |
||
4387 | 4387 | * @version 3.0.1 |
4388 | 4388 | */ |
4389 | 4389 | class CssAtMediaEndToken extends aCssAtBlockEndToken |
4390 | - { |
|
4390 | + { |
|
4391 | 4391 | |
4392 | - } |
|
4392 | + } |
|
4393 | 4393 | |
4394 | 4394 | /** |
4395 | 4395 | * This {@link aCssToken CSS token} represents the start of a @keyframes at-rule block. |
@@ -4402,43 +4402,43 @@ discard block |
||
4402 | 4402 | * @version 3.0.1 |
4403 | 4403 | */ |
4404 | 4404 | class CssAtKeyframesStartToken extends aCssAtBlockStartToken |
4405 | - { |
|
4406 | - /** |
|
4407 | - * Name of the at-rule. |
|
4408 | - * |
|
4409 | - * @var string |
|
4410 | - */ |
|
4411 | - public $AtRuleName = "keyframes"; |
|
4412 | - /** |
|
4413 | - * Name |
|
4414 | - * |
|
4415 | - * @var string |
|
4416 | - */ |
|
4417 | - public $Name = ""; |
|
4418 | - /** |
|
4419 | - * Sets the properties of the @page at-rule. |
|
4420 | - * |
|
4421 | - * @param string $selector Selector |
|
4422 | - * @return void |
|
4423 | - */ |
|
4424 | - public function __construct($name, $atRuleName = null) |
|
4425 | - { |
|
4426 | - $this->Name = $name; |
|
4427 | - if (!is_null($atRuleName)) |
|
4428 | - { |
|
4429 | - $this->AtRuleName = $atRuleName; |
|
4430 | - } |
|
4431 | - } |
|
4432 | - /** |
|
4433 | - * Implements {@link aCssToken::__toString()}. |
|
4434 | - * |
|
4435 | - * @return string |
|
4436 | - */ |
|
4437 | - public function __toString() |
|
4438 | - { |
|
4439 | - return "@" . $this->AtRuleName . " \"" . $this->Name . "\"{"; |
|
4440 | - } |
|
4441 | - } |
|
4405 | + { |
|
4406 | + /** |
|
4407 | + * Name of the at-rule. |
|
4408 | + * |
|
4409 | + * @var string |
|
4410 | + */ |
|
4411 | + public $AtRuleName = "keyframes"; |
|
4412 | + /** |
|
4413 | + * Name |
|
4414 | + * |
|
4415 | + * @var string |
|
4416 | + */ |
|
4417 | + public $Name = ""; |
|
4418 | + /** |
|
4419 | + * Sets the properties of the @page at-rule. |
|
4420 | + * |
|
4421 | + * @param string $selector Selector |
|
4422 | + * @return void |
|
4423 | + */ |
|
4424 | + public function __construct($name, $atRuleName = null) |
|
4425 | + { |
|
4426 | + $this->Name = $name; |
|
4427 | + if (!is_null($atRuleName)) |
|
4428 | + { |
|
4429 | + $this->AtRuleName = $atRuleName; |
|
4430 | + } |
|
4431 | + } |
|
4432 | + /** |
|
4433 | + * Implements {@link aCssToken::__toString()}. |
|
4434 | + * |
|
4435 | + * @return string |
|
4436 | + */ |
|
4437 | + public function __toString() |
|
4438 | + { |
|
4439 | + return "@" . $this->AtRuleName . " \"" . $this->Name . "\"{"; |
|
4440 | + } |
|
4441 | + } |
|
4442 | 4442 | |
4443 | 4443 | /** |
4444 | 4444 | * This {@link aCssToken CSS token} represents the start of a ruleset of a @keyframes at-rule block. |
@@ -4451,33 +4451,33 @@ discard block |
||
4451 | 4451 | * @version 3.0.1 |
4452 | 4452 | */ |
4453 | 4453 | class CssAtKeyframesRulesetStartToken extends aCssRulesetStartToken |
4454 | - { |
|
4455 | - /** |
|
4456 | - * Array of selectors. |
|
4457 | - * |
|
4458 | - * @var array |
|
4459 | - */ |
|
4460 | - public $Selectors = array(); |
|
4461 | - /** |
|
4462 | - * Set the properties of a ruleset token. |
|
4463 | - * |
|
4464 | - * @param array $selectors Selectors of the ruleset |
|
4465 | - * @return void |
|
4466 | - */ |
|
4467 | - public function __construct(array $selectors = array()) |
|
4468 | - { |
|
4469 | - $this->Selectors = $selectors; |
|
4470 | - } |
|
4471 | - /** |
|
4472 | - * Implements {@link aCssToken::__toString()}. |
|
4473 | - * |
|
4474 | - * @return string |
|
4475 | - */ |
|
4476 | - public function __toString() |
|
4477 | - { |
|
4478 | - return implode(",", $this->Selectors) . "{"; |
|
4479 | - } |
|
4480 | - } |
|
4454 | + { |
|
4455 | + /** |
|
4456 | + * Array of selectors. |
|
4457 | + * |
|
4458 | + * @var array |
|
4459 | + */ |
|
4460 | + public $Selectors = array(); |
|
4461 | + /** |
|
4462 | + * Set the properties of a ruleset token. |
|
4463 | + * |
|
4464 | + * @param array $selectors Selectors of the ruleset |
|
4465 | + * @return void |
|
4466 | + */ |
|
4467 | + public function __construct(array $selectors = array()) |
|
4468 | + { |
|
4469 | + $this->Selectors = $selectors; |
|
4470 | + } |
|
4471 | + /** |
|
4472 | + * Implements {@link aCssToken::__toString()}. |
|
4473 | + * |
|
4474 | + * @return string |
|
4475 | + */ |
|
4476 | + public function __toString() |
|
4477 | + { |
|
4478 | + return implode(",", $this->Selectors) . "{"; |
|
4479 | + } |
|
4480 | + } |
|
4481 | 4481 | |
4482 | 4482 | /** |
4483 | 4483 | * This {@link aCssToken CSS token} represents the end of a ruleset of a @keyframes at-rule block. |
@@ -4490,9 +4490,9 @@ discard block |
||
4490 | 4490 | * @version 3.0.1 |
4491 | 4491 | */ |
4492 | 4492 | class CssAtKeyframesRulesetEndToken extends aCssRulesetEndToken |
4493 | - { |
|
4493 | + { |
|
4494 | 4494 | |
4495 | - } |
|
4495 | + } |
|
4496 | 4496 | |
4497 | 4497 | /** |
4498 | 4498 | * This {@link aCssToken CSS token} represents a ruleset declaration of a @keyframes at-rule block. |
@@ -4505,9 +4505,9 @@ discard block |
||
4505 | 4505 | * @version 3.0.1 |
4506 | 4506 | */ |
4507 | 4507 | class CssAtKeyframesRulesetDeclarationToken extends aCssDeclarationToken |
4508 | - { |
|
4508 | + { |
|
4509 | 4509 | |
4510 | - } |
|
4510 | + } |
|
4511 | 4511 | |
4512 | 4512 | /** |
4513 | 4513 | * {@link aCssParserPlugin Parser plugin} for parsing @keyframes at-rule blocks, rulesets and declarations. |
@@ -4520,154 +4520,154 @@ discard block |
||
4520 | 4520 | * @version 3.0.1 |
4521 | 4521 | */ |
4522 | 4522 | class CssAtKeyframesParserPlugin extends aCssParserPlugin |
4523 | - { |
|
4524 | - /** |
|
4525 | - * @var string Keyword |
|
4526 | - */ |
|
4527 | - private $atRuleName = ""; |
|
4528 | - /** |
|
4529 | - * Selectors. |
|
4530 | - * |
|
4531 | - * @var array |
|
4532 | - */ |
|
4533 | - private $selectors = array(); |
|
4534 | - /** |
|
4535 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
4536 | - * |
|
4537 | - * @return array |
|
4538 | - */ |
|
4539 | - public function getTriggerChars() |
|
4540 | - { |
|
4541 | - return array("@", "{", "}", ":", ",", ";"); |
|
4542 | - } |
|
4543 | - /** |
|
4544 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
4545 | - * |
|
4546 | - * @return array |
|
4547 | - */ |
|
4548 | - public function getTriggerStates() |
|
4549 | - { |
|
4550 | - return array("T_DOCUMENT", "T_AT_KEYFRAMES::NAME", "T_AT_KEYFRAMES", "T_AT_KEYFRAMES_RULESETS", "T_AT_KEYFRAMES_RULESET", "T_AT_KEYFRAMES_RULESET_DECLARATION"); |
|
4551 | - } |
|
4552 | - /** |
|
4553 | - * Implements {@link aCssParserPlugin::parse()}. |
|
4554 | - * |
|
4555 | - * @param integer $index Current index |
|
4556 | - * @param string $char Current char |
|
4557 | - * @param string $previousChar Previous char |
|
4558 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
4559 | - */ |
|
4560 | - public function parse($index, $char, $previousChar, $state) |
|
4561 | - { |
|
4562 | - // Start of @keyframes at-rule block |
|
4563 | - if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 10)) === "@keyframes") |
|
4564 | - { |
|
4565 | - $this->atRuleName = "keyframes"; |
|
4566 | - $this->parser->pushState("T_AT_KEYFRAMES::NAME"); |
|
4567 | - $this->parser->clearBuffer(); |
|
4568 | - return $index + 10; |
|
4569 | - } |
|
4570 | - // Start of @keyframes at-rule block (@-moz-keyframes) |
|
4571 | - elseif ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 15)) === "@-moz-keyframes") |
|
4572 | - { |
|
4573 | - $this->atRuleName = "-moz-keyframes"; |
|
4574 | - $this->parser->pushState("T_AT_KEYFRAMES::NAME"); |
|
4575 | - $this->parser->clearBuffer(); |
|
4576 | - return $index + 15; |
|
4577 | - } |
|
4578 | - // Start of @keyframes at-rule block (@-webkit-keyframes) |
|
4579 | - elseif ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 18)) === "@-webkit-keyframes") |
|
4580 | - { |
|
4581 | - $this->atRuleName = "-webkit-keyframes"; |
|
4582 | - $this->parser->pushState("T_AT_KEYFRAMES::NAME"); |
|
4583 | - $this->parser->clearBuffer(); |
|
4584 | - return $index + 18; |
|
4585 | - } |
|
4586 | - // Start of @keyframes rulesets |
|
4587 | - elseif ($char === "{" && $state === "T_AT_KEYFRAMES::NAME") |
|
4588 | - { |
|
4589 | - $name = $this->parser->getAndClearBuffer("{\"'"); |
|
4590 | - $this->parser->setState("T_AT_KEYFRAMES_RULESETS"); |
|
4591 | - $this->parser->clearBuffer(); |
|
4592 | - $this->parser->appendToken(new CssAtKeyframesStartToken($name, $this->atRuleName)); |
|
4593 | - } |
|
4594 | - // Start of @keyframe ruleset and selectors |
|
4595 | - if ($char === "," && $state === "T_AT_KEYFRAMES_RULESETS") |
|
4596 | - { |
|
4597 | - $this->selectors[] = $this->parser->getAndClearBuffer(",{"); |
|
4598 | - } |
|
4599 | - // Start of a @keyframes ruleset |
|
4600 | - elseif ($char === "{" && $state === "T_AT_KEYFRAMES_RULESETS") |
|
4601 | - { |
|
4602 | - if ($this->parser->getBuffer() !== "") |
|
4603 | - { |
|
4604 | - $this->selectors[] = $this->parser->getAndClearBuffer(",{"); |
|
4605 | - $this->parser->pushState("T_AT_KEYFRAMES_RULESET"); |
|
4606 | - $this->parser->appendToken(new CssAtKeyframesRulesetStartToken($this->selectors)); |
|
4607 | - $this->selectors = array(); |
|
4608 | - } |
|
4609 | - } |
|
4610 | - // Start of @keyframes ruleset declaration |
|
4611 | - elseif ($char === ":" && $state === "T_AT_KEYFRAMES_RULESET") |
|
4612 | - { |
|
4613 | - $this->parser->pushState("T_AT_KEYFRAMES_RULESET_DECLARATION"); |
|
4614 | - $this->buffer = $this->parser->getAndClearBuffer(":;", true); |
|
4615 | - } |
|
4616 | - // Unterminated @keyframes ruleset declaration |
|
4617 | - elseif ($char === ":" && $state === "T_AT_KEYFRAMES_RULESET_DECLARATION") |
|
4618 | - { |
|
4619 | - // Ignore Internet Explorer filter declarations |
|
4620 | - if ($this->buffer === "filter") |
|
4621 | - { |
|
4622 | - return false; |
|
4623 | - } |
|
4624 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated @keyframes ruleset declaration", $this->buffer . ":" . $this->parser->getBuffer() . "_")); |
|
4625 | - } |
|
4626 | - // End of declaration |
|
4627 | - elseif (($char === ";" || $char === "}") && $state === "T_AT_KEYFRAMES_RULESET_DECLARATION") |
|
4628 | - { |
|
4629 | - $value = $this->parser->getAndClearBuffer(";}"); |
|
4630 | - if (strtolower(substr($value, -10, 10)) === "!important") |
|
4631 | - { |
|
4632 | - $value = trim(substr($value, 0, -10)); |
|
4633 | - $isImportant = true; |
|
4634 | - } |
|
4635 | - else |
|
4636 | - { |
|
4637 | - $isImportant = false; |
|
4638 | - } |
|
4639 | - $this->parser->popState(); |
|
4640 | - $this->parser->appendToken(new CssAtKeyframesRulesetDeclarationToken($this->buffer, $value, $isImportant)); |
|
4641 | - // Declaration ends with a right curly brace; so we have to end the ruleset |
|
4642 | - if ($char === "}") |
|
4643 | - { |
|
4644 | - $this->parser->appendToken(new CssAtKeyframesRulesetEndToken()); |
|
4645 | - $this->parser->popState(); |
|
4646 | - } |
|
4647 | - $this->buffer = ""; |
|
4648 | - } |
|
4649 | - // End of @keyframes ruleset |
|
4650 | - elseif ($char === "}" && $state === "T_AT_KEYFRAMES_RULESET") |
|
4651 | - { |
|
4652 | - $this->parser->clearBuffer(); |
|
4523 | + { |
|
4524 | + /** |
|
4525 | + * @var string Keyword |
|
4526 | + */ |
|
4527 | + private $atRuleName = ""; |
|
4528 | + /** |
|
4529 | + * Selectors. |
|
4530 | + * |
|
4531 | + * @var array |
|
4532 | + */ |
|
4533 | + private $selectors = array(); |
|
4534 | + /** |
|
4535 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
4536 | + * |
|
4537 | + * @return array |
|
4538 | + */ |
|
4539 | + public function getTriggerChars() |
|
4540 | + { |
|
4541 | + return array("@", "{", "}", ":", ",", ";"); |
|
4542 | + } |
|
4543 | + /** |
|
4544 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
4545 | + * |
|
4546 | + * @return array |
|
4547 | + */ |
|
4548 | + public function getTriggerStates() |
|
4549 | + { |
|
4550 | + return array("T_DOCUMENT", "T_AT_KEYFRAMES::NAME", "T_AT_KEYFRAMES", "T_AT_KEYFRAMES_RULESETS", "T_AT_KEYFRAMES_RULESET", "T_AT_KEYFRAMES_RULESET_DECLARATION"); |
|
4551 | + } |
|
4552 | + /** |
|
4553 | + * Implements {@link aCssParserPlugin::parse()}. |
|
4554 | + * |
|
4555 | + * @param integer $index Current index |
|
4556 | + * @param string $char Current char |
|
4557 | + * @param string $previousChar Previous char |
|
4558 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
4559 | + */ |
|
4560 | + public function parse($index, $char, $previousChar, $state) |
|
4561 | + { |
|
4562 | + // Start of @keyframes at-rule block |
|
4563 | + if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 10)) === "@keyframes") |
|
4564 | + { |
|
4565 | + $this->atRuleName = "keyframes"; |
|
4566 | + $this->parser->pushState("T_AT_KEYFRAMES::NAME"); |
|
4567 | + $this->parser->clearBuffer(); |
|
4568 | + return $index + 10; |
|
4569 | + } |
|
4570 | + // Start of @keyframes at-rule block (@-moz-keyframes) |
|
4571 | + elseif ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 15)) === "@-moz-keyframes") |
|
4572 | + { |
|
4573 | + $this->atRuleName = "-moz-keyframes"; |
|
4574 | + $this->parser->pushState("T_AT_KEYFRAMES::NAME"); |
|
4575 | + $this->parser->clearBuffer(); |
|
4576 | + return $index + 15; |
|
4577 | + } |
|
4578 | + // Start of @keyframes at-rule block (@-webkit-keyframes) |
|
4579 | + elseif ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 18)) === "@-webkit-keyframes") |
|
4580 | + { |
|
4581 | + $this->atRuleName = "-webkit-keyframes"; |
|
4582 | + $this->parser->pushState("T_AT_KEYFRAMES::NAME"); |
|
4583 | + $this->parser->clearBuffer(); |
|
4584 | + return $index + 18; |
|
4585 | + } |
|
4586 | + // Start of @keyframes rulesets |
|
4587 | + elseif ($char === "{" && $state === "T_AT_KEYFRAMES::NAME") |
|
4588 | + { |
|
4589 | + $name = $this->parser->getAndClearBuffer("{\"'"); |
|
4590 | + $this->parser->setState("T_AT_KEYFRAMES_RULESETS"); |
|
4591 | + $this->parser->clearBuffer(); |
|
4592 | + $this->parser->appendToken(new CssAtKeyframesStartToken($name, $this->atRuleName)); |
|
4593 | + } |
|
4594 | + // Start of @keyframe ruleset and selectors |
|
4595 | + if ($char === "," && $state === "T_AT_KEYFRAMES_RULESETS") |
|
4596 | + { |
|
4597 | + $this->selectors[] = $this->parser->getAndClearBuffer(",{"); |
|
4598 | + } |
|
4599 | + // Start of a @keyframes ruleset |
|
4600 | + elseif ($char === "{" && $state === "T_AT_KEYFRAMES_RULESETS") |
|
4601 | + { |
|
4602 | + if ($this->parser->getBuffer() !== "") |
|
4603 | + { |
|
4604 | + $this->selectors[] = $this->parser->getAndClearBuffer(",{"); |
|
4605 | + $this->parser->pushState("T_AT_KEYFRAMES_RULESET"); |
|
4606 | + $this->parser->appendToken(new CssAtKeyframesRulesetStartToken($this->selectors)); |
|
4607 | + $this->selectors = array(); |
|
4608 | + } |
|
4609 | + } |
|
4610 | + // Start of @keyframes ruleset declaration |
|
4611 | + elseif ($char === ":" && $state === "T_AT_KEYFRAMES_RULESET") |
|
4612 | + { |
|
4613 | + $this->parser->pushState("T_AT_KEYFRAMES_RULESET_DECLARATION"); |
|
4614 | + $this->buffer = $this->parser->getAndClearBuffer(":;", true); |
|
4615 | + } |
|
4616 | + // Unterminated @keyframes ruleset declaration |
|
4617 | + elseif ($char === ":" && $state === "T_AT_KEYFRAMES_RULESET_DECLARATION") |
|
4618 | + { |
|
4619 | + // Ignore Internet Explorer filter declarations |
|
4620 | + if ($this->buffer === "filter") |
|
4621 | + { |
|
4622 | + return false; |
|
4623 | + } |
|
4624 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated @keyframes ruleset declaration", $this->buffer . ":" . $this->parser->getBuffer() . "_")); |
|
4625 | + } |
|
4626 | + // End of declaration |
|
4627 | + elseif (($char === ";" || $char === "}") && $state === "T_AT_KEYFRAMES_RULESET_DECLARATION") |
|
4628 | + { |
|
4629 | + $value = $this->parser->getAndClearBuffer(";}"); |
|
4630 | + if (strtolower(substr($value, -10, 10)) === "!important") |
|
4631 | + { |
|
4632 | + $value = trim(substr($value, 0, -10)); |
|
4633 | + $isImportant = true; |
|
4634 | + } |
|
4635 | + else |
|
4636 | + { |
|
4637 | + $isImportant = false; |
|
4638 | + } |
|
4639 | + $this->parser->popState(); |
|
4640 | + $this->parser->appendToken(new CssAtKeyframesRulesetDeclarationToken($this->buffer, $value, $isImportant)); |
|
4641 | + // Declaration ends with a right curly brace; so we have to end the ruleset |
|
4642 | + if ($char === "}") |
|
4643 | + { |
|
4644 | + $this->parser->appendToken(new CssAtKeyframesRulesetEndToken()); |
|
4645 | + $this->parser->popState(); |
|
4646 | + } |
|
4647 | + $this->buffer = ""; |
|
4648 | + } |
|
4649 | + // End of @keyframes ruleset |
|
4650 | + elseif ($char === "}" && $state === "T_AT_KEYFRAMES_RULESET") |
|
4651 | + { |
|
4652 | + $this->parser->clearBuffer(); |
|
4653 | 4653 | |
4654 | - $this->parser->popState(); |
|
4655 | - $this->parser->appendToken(new CssAtKeyframesRulesetEndToken()); |
|
4656 | - } |
|
4657 | - // End of @keyframes rulesets |
|
4658 | - elseif ($char === "}" && $state === "T_AT_KEYFRAMES_RULESETS") |
|
4659 | - { |
|
4660 | - $this->parser->clearBuffer(); |
|
4661 | - $this->parser->popState(); |
|
4662 | - $this->parser->appendToken(new CssAtKeyframesEndToken()); |
|
4663 | - } |
|
4664 | - else |
|
4665 | - { |
|
4666 | - return false; |
|
4667 | - } |
|
4668 | - return true; |
|
4669 | - } |
|
4670 | - } |
|
4654 | + $this->parser->popState(); |
|
4655 | + $this->parser->appendToken(new CssAtKeyframesRulesetEndToken()); |
|
4656 | + } |
|
4657 | + // End of @keyframes rulesets |
|
4658 | + elseif ($char === "}" && $state === "T_AT_KEYFRAMES_RULESETS") |
|
4659 | + { |
|
4660 | + $this->parser->clearBuffer(); |
|
4661 | + $this->parser->popState(); |
|
4662 | + $this->parser->appendToken(new CssAtKeyframesEndToken()); |
|
4663 | + } |
|
4664 | + else |
|
4665 | + { |
|
4666 | + return false; |
|
4667 | + } |
|
4668 | + return true; |
|
4669 | + } |
|
4670 | + } |
|
4671 | 4671 | |
4672 | 4672 | /** |
4673 | 4673 | * This {@link aCssToken CSS token} represents the end of a @keyframes at-rule block. |
@@ -4680,9 +4680,9 @@ discard block |
||
4680 | 4680 | * @version 3.0.1 |
4681 | 4681 | */ |
4682 | 4682 | class CssAtKeyframesEndToken extends aCssAtBlockEndToken |
4683 | - { |
|
4683 | + { |
|
4684 | 4684 | |
4685 | - } |
|
4685 | + } |
|
4686 | 4686 | |
4687 | 4687 | /** |
4688 | 4688 | * This {@link aCssToken CSS token} represents a @import at-rule. |
@@ -4695,41 +4695,41 @@ discard block |
||
4695 | 4695 | * @version 3.0.1.b1 (2001-02-22) |
4696 | 4696 | */ |
4697 | 4697 | class CssAtImportToken extends aCssToken |
4698 | - { |
|
4699 | - /** |
|
4700 | - * Import path of the @import at-rule. |
|
4701 | - * |
|
4702 | - * @var string |
|
4703 | - */ |
|
4704 | - public $Import = ""; |
|
4705 | - /** |
|
4706 | - * Media types of the @import at-rule. |
|
4707 | - * |
|
4708 | - * @var array |
|
4709 | - */ |
|
4710 | - public $MediaTypes = array(); |
|
4711 | - /** |
|
4712 | - * Set the properties of a @import at-rule token. |
|
4713 | - * |
|
4714 | - * @param string $import Import path |
|
4715 | - * @param array $mediaTypes Media types |
|
4716 | - * @return void |
|
4717 | - */ |
|
4718 | - public function __construct($import, $mediaTypes) |
|
4719 | - { |
|
4720 | - $this->Import = $import; |
|
4721 | - $this->MediaTypes = $mediaTypes ? $mediaTypes : array(); |
|
4722 | - } |
|
4723 | - /** |
|
4724 | - * Implements {@link aCssToken::__toString()}. |
|
4725 | - * |
|
4726 | - * @return string |
|
4727 | - */ |
|
4728 | - public function __toString() |
|
4729 | - { |
|
4730 | - return "@import \"" . $this->Import . "\"" . (count($this->MediaTypes) > 0 ? " " . implode(",", $this->MediaTypes) : ""). ";"; |
|
4731 | - } |
|
4732 | - } |
|
4698 | + { |
|
4699 | + /** |
|
4700 | + * Import path of the @import at-rule. |
|
4701 | + * |
|
4702 | + * @var string |
|
4703 | + */ |
|
4704 | + public $Import = ""; |
|
4705 | + /** |
|
4706 | + * Media types of the @import at-rule. |
|
4707 | + * |
|
4708 | + * @var array |
|
4709 | + */ |
|
4710 | + public $MediaTypes = array(); |
|
4711 | + /** |
|
4712 | + * Set the properties of a @import at-rule token. |
|
4713 | + * |
|
4714 | + * @param string $import Import path |
|
4715 | + * @param array $mediaTypes Media types |
|
4716 | + * @return void |
|
4717 | + */ |
|
4718 | + public function __construct($import, $mediaTypes) |
|
4719 | + { |
|
4720 | + $this->Import = $import; |
|
4721 | + $this->MediaTypes = $mediaTypes ? $mediaTypes : array(); |
|
4722 | + } |
|
4723 | + /** |
|
4724 | + * Implements {@link aCssToken::__toString()}. |
|
4725 | + * |
|
4726 | + * @return string |
|
4727 | + */ |
|
4728 | + public function __toString() |
|
4729 | + { |
|
4730 | + return "@import \"" . $this->Import . "\"" . (count($this->MediaTypes) > 0 ? " " . implode(",", $this->MediaTypes) : ""). ";"; |
|
4731 | + } |
|
4732 | + } |
|
4733 | 4733 | |
4734 | 4734 | /** |
4735 | 4735 | * {@link aCssParserPlugin Parser plugin} for parsing @import at-rule. |
@@ -4744,76 +4744,76 @@ discard block |
||
4744 | 4744 | * @version 3.0.1 |
4745 | 4745 | */ |
4746 | 4746 | class CssAtImportParserPlugin extends aCssParserPlugin |
4747 | - { |
|
4748 | - /** |
|
4749 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
4750 | - * |
|
4751 | - * @return array |
|
4752 | - */ |
|
4753 | - public function getTriggerChars() |
|
4754 | - { |
|
4755 | - return array("@", ";", ",", "\n"); |
|
4756 | - } |
|
4757 | - /** |
|
4758 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
4759 | - * |
|
4760 | - * @return array |
|
4761 | - */ |
|
4762 | - public function getTriggerStates() |
|
4763 | - { |
|
4764 | - return array("T_DOCUMENT", "T_AT_IMPORT"); |
|
4765 | - } |
|
4766 | - /** |
|
4767 | - * Implements {@link aCssParserPlugin::parse()}. |
|
4768 | - * |
|
4769 | - * @param integer $index Current index |
|
4770 | - * @param string $char Current char |
|
4771 | - * @param string $previousChar Previous char |
|
4772 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
4773 | - */ |
|
4774 | - public function parse($index, $char, $previousChar, $state) |
|
4775 | - { |
|
4776 | - if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 7)) === "@import") |
|
4777 | - { |
|
4778 | - $this->parser->pushState("T_AT_IMPORT"); |
|
4779 | - $this->parser->clearBuffer(); |
|
4780 | - return $index + 7; |
|
4781 | - } |
|
4782 | - elseif (($char === ";" || $char === "\n") && $state === "T_AT_IMPORT") |
|
4783 | - { |
|
4784 | - $this->buffer = $this->parser->getAndClearBuffer(";"); |
|
4785 | - $pos = false; |
|
4786 | - foreach (array(")", "\"", "'") as $needle) |
|
4787 | - { |
|
4788 | - if (($pos = strrpos($this->buffer, $needle)) !== false) |
|
4789 | - { |
|
4790 | - break; |
|
4791 | - } |
|
4792 | - } |
|
4793 | - $import = substr($this->buffer, 0, $pos + 1); |
|
4794 | - if (stripos($import, "url(") === 0) |
|
4795 | - { |
|
4796 | - $import = substr($import, 4, -1); |
|
4797 | - } |
|
4798 | - $import = trim($import, " \t\n\r\0\x0B'\""); |
|
4799 | - $mediaTypes = array_filter(array_map("trim", explode(",", trim(substr($this->buffer, $pos + 1), " \t\n\r\0\x0B{")))); |
|
4800 | - if ($pos) |
|
4801 | - { |
|
4802 | - $this->parser->appendToken(new CssAtImportToken($import, $mediaTypes)); |
|
4803 | - } |
|
4804 | - else |
|
4805 | - { |
|
4806 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Invalid @import at-rule syntax", $this->parser->buffer)); |
|
4807 | - } |
|
4808 | - $this->parser->popState(); |
|
4809 | - } |
|
4810 | - else |
|
4811 | - { |
|
4812 | - return false; |
|
4813 | - } |
|
4814 | - return true; |
|
4815 | - } |
|
4816 | - } |
|
4747 | + { |
|
4748 | + /** |
|
4749 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
4750 | + * |
|
4751 | + * @return array |
|
4752 | + */ |
|
4753 | + public function getTriggerChars() |
|
4754 | + { |
|
4755 | + return array("@", ";", ",", "\n"); |
|
4756 | + } |
|
4757 | + /** |
|
4758 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
4759 | + * |
|
4760 | + * @return array |
|
4761 | + */ |
|
4762 | + public function getTriggerStates() |
|
4763 | + { |
|
4764 | + return array("T_DOCUMENT", "T_AT_IMPORT"); |
|
4765 | + } |
|
4766 | + /** |
|
4767 | + * Implements {@link aCssParserPlugin::parse()}. |
|
4768 | + * |
|
4769 | + * @param integer $index Current index |
|
4770 | + * @param string $char Current char |
|
4771 | + * @param string $previousChar Previous char |
|
4772 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
4773 | + */ |
|
4774 | + public function parse($index, $char, $previousChar, $state) |
|
4775 | + { |
|
4776 | + if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 7)) === "@import") |
|
4777 | + { |
|
4778 | + $this->parser->pushState("T_AT_IMPORT"); |
|
4779 | + $this->parser->clearBuffer(); |
|
4780 | + return $index + 7; |
|
4781 | + } |
|
4782 | + elseif (($char === ";" || $char === "\n") && $state === "T_AT_IMPORT") |
|
4783 | + { |
|
4784 | + $this->buffer = $this->parser->getAndClearBuffer(";"); |
|
4785 | + $pos = false; |
|
4786 | + foreach (array(")", "\"", "'") as $needle) |
|
4787 | + { |
|
4788 | + if (($pos = strrpos($this->buffer, $needle)) !== false) |
|
4789 | + { |
|
4790 | + break; |
|
4791 | + } |
|
4792 | + } |
|
4793 | + $import = substr($this->buffer, 0, $pos + 1); |
|
4794 | + if (stripos($import, "url(") === 0) |
|
4795 | + { |
|
4796 | + $import = substr($import, 4, -1); |
|
4797 | + } |
|
4798 | + $import = trim($import, " \t\n\r\0\x0B'\""); |
|
4799 | + $mediaTypes = array_filter(array_map("trim", explode(",", trim(substr($this->buffer, $pos + 1), " \t\n\r\0\x0B{")))); |
|
4800 | + if ($pos) |
|
4801 | + { |
|
4802 | + $this->parser->appendToken(new CssAtImportToken($import, $mediaTypes)); |
|
4803 | + } |
|
4804 | + else |
|
4805 | + { |
|
4806 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Invalid @import at-rule syntax", $this->parser->buffer)); |
|
4807 | + } |
|
4808 | + $this->parser->popState(); |
|
4809 | + } |
|
4810 | + else |
|
4811 | + { |
|
4812 | + return false; |
|
4813 | + } |
|
4814 | + return true; |
|
4815 | + } |
|
4816 | + } |
|
4817 | 4817 | |
4818 | 4818 | /** |
4819 | 4819 | * This {@link aCssToken CSS token} represents the start of a @font-face at-rule block. |
@@ -4826,17 +4826,17 @@ discard block |
||
4826 | 4826 | * @version 3.0.1 |
4827 | 4827 | */ |
4828 | 4828 | class CssAtFontFaceStartToken extends aCssAtBlockStartToken |
4829 | - { |
|
4830 | - /** |
|
4831 | - * Implements {@link aCssToken::__toString()}. |
|
4832 | - * |
|
4833 | - * @return string |
|
4834 | - */ |
|
4835 | - public function __toString() |
|
4836 | - { |
|
4837 | - return "@font-face{"; |
|
4838 | - } |
|
4839 | - } |
|
4829 | + { |
|
4830 | + /** |
|
4831 | + * Implements {@link aCssToken::__toString()}. |
|
4832 | + * |
|
4833 | + * @return string |
|
4834 | + */ |
|
4835 | + public function __toString() |
|
4836 | + { |
|
4837 | + return "@font-face{"; |
|
4838 | + } |
|
4839 | + } |
|
4840 | 4840 | |
4841 | 4841 | /** |
4842 | 4842 | * {@link aCssParserPlugin Parser plugin} for parsing @font-face at-rule block with including declarations. |
@@ -4852,102 +4852,102 @@ discard block |
||
4852 | 4852 | * @version 3.0.1 |
4853 | 4853 | */ |
4854 | 4854 | class CssAtFontFaceParserPlugin extends aCssParserPlugin |
4855 | - { |
|
4856 | - /** |
|
4857 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
4858 | - * |
|
4859 | - * @return array |
|
4860 | - */ |
|
4861 | - public function getTriggerChars() |
|
4862 | - { |
|
4863 | - return array("@", "{", "}", ":", ";"); |
|
4864 | - } |
|
4865 | - /** |
|
4866 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
4867 | - * |
|
4868 | - * @return array |
|
4869 | - */ |
|
4870 | - public function getTriggerStates() |
|
4871 | - { |
|
4872 | - return array("T_DOCUMENT", "T_AT_FONT_FACE::PREPARE", "T_AT_FONT_FACE", "T_AT_FONT_FACE_DECLARATION"); |
|
4873 | - } |
|
4874 | - /** |
|
4875 | - * Implements {@link aCssParserPlugin::parse()}. |
|
4876 | - * |
|
4877 | - * @param integer $index Current index |
|
4878 | - * @param string $char Current char |
|
4879 | - * @param string $previousChar Previous char |
|
4880 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
4881 | - */ |
|
4882 | - public function parse($index, $char, $previousChar, $state) |
|
4883 | - { |
|
4884 | - // Start of @font-face at-rule block |
|
4885 | - if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 10)) === "@font-face") |
|
4886 | - { |
|
4887 | - $this->parser->pushState("T_AT_FONT_FACE::PREPARE"); |
|
4888 | - $this->parser->clearBuffer(); |
|
4889 | - return $index + 10; |
|
4890 | - } |
|
4891 | - // Start of @font-face declarations |
|
4892 | - elseif ($char === "{" && $state === "T_AT_FONT_FACE::PREPARE") |
|
4893 | - { |
|
4894 | - $this->parser->setState("T_AT_FONT_FACE"); |
|
4895 | - $this->parser->clearBuffer(); |
|
4896 | - $this->parser->appendToken(new CssAtFontFaceStartToken()); |
|
4897 | - } |
|
4898 | - // Start of @font-face declaration |
|
4899 | - elseif ($char === ":" && $state === "T_AT_FONT_FACE") |
|
4900 | - { |
|
4901 | - $this->parser->pushState("T_AT_FONT_FACE_DECLARATION"); |
|
4902 | - $this->buffer = $this->parser->getAndClearBuffer(":", true); |
|
4903 | - } |
|
4904 | - // Unterminated @font-face declaration |
|
4905 | - elseif ($char === ":" && $state === "T_AT_FONT_FACE_DECLARATION") |
|
4906 | - { |
|
4907 | - // Ignore Internet Explorer filter declarations |
|
4908 | - if ($this->buffer === "filter") |
|
4909 | - { |
|
4910 | - return false; |
|
4911 | - } |
|
4912 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated @font-face declaration", $this->buffer . ":" . $this->parser->getBuffer() . "_")); |
|
4913 | - } |
|
4914 | - // End of @font-face declaration |
|
4915 | - elseif (($char === ";" || $char === "}") && $state === "T_AT_FONT_FACE_DECLARATION") |
|
4916 | - { |
|
4917 | - $value = $this->parser->getAndClearBuffer(";}"); |
|
4918 | - if (strtolower(substr($value, -10, 10)) === "!important") |
|
4919 | - { |
|
4920 | - $value = trim(substr($value, 0, -10)); |
|
4921 | - $isImportant = true; |
|
4922 | - } |
|
4923 | - else |
|
4924 | - { |
|
4925 | - $isImportant = false; |
|
4926 | - } |
|
4927 | - $this->parser->popState(); |
|
4928 | - $this->parser->appendToken(new CssAtFontFaceDeclarationToken($this->buffer, $value, $isImportant)); |
|
4929 | - $this->buffer = ""; |
|
4930 | - // -- |
|
4931 | - if ($char === "}") |
|
4932 | - { |
|
4933 | - $this->parser->appendToken(new CssAtFontFaceEndToken()); |
|
4934 | - $this->parser->popState(); |
|
4935 | - } |
|
4936 | - } |
|
4937 | - // End of @font-face at-rule block |
|
4938 | - elseif ($char === "}" && $state === "T_AT_FONT_FACE") |
|
4939 | - { |
|
4940 | - $this->parser->appendToken(new CssAtFontFaceEndToken()); |
|
4941 | - $this->parser->clearBuffer(); |
|
4942 | - $this->parser->popState(); |
|
4943 | - } |
|
4944 | - else |
|
4945 | - { |
|
4946 | - return false; |
|
4947 | - } |
|
4948 | - return true; |
|
4949 | - } |
|
4950 | - } |
|
4855 | + { |
|
4856 | + /** |
|
4857 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
4858 | + * |
|
4859 | + * @return array |
|
4860 | + */ |
|
4861 | + public function getTriggerChars() |
|
4862 | + { |
|
4863 | + return array("@", "{", "}", ":", ";"); |
|
4864 | + } |
|
4865 | + /** |
|
4866 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
4867 | + * |
|
4868 | + * @return array |
|
4869 | + */ |
|
4870 | + public function getTriggerStates() |
|
4871 | + { |
|
4872 | + return array("T_DOCUMENT", "T_AT_FONT_FACE::PREPARE", "T_AT_FONT_FACE", "T_AT_FONT_FACE_DECLARATION"); |
|
4873 | + } |
|
4874 | + /** |
|
4875 | + * Implements {@link aCssParserPlugin::parse()}. |
|
4876 | + * |
|
4877 | + * @param integer $index Current index |
|
4878 | + * @param string $char Current char |
|
4879 | + * @param string $previousChar Previous char |
|
4880 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
4881 | + */ |
|
4882 | + public function parse($index, $char, $previousChar, $state) |
|
4883 | + { |
|
4884 | + // Start of @font-face at-rule block |
|
4885 | + if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 10)) === "@font-face") |
|
4886 | + { |
|
4887 | + $this->parser->pushState("T_AT_FONT_FACE::PREPARE"); |
|
4888 | + $this->parser->clearBuffer(); |
|
4889 | + return $index + 10; |
|
4890 | + } |
|
4891 | + // Start of @font-face declarations |
|
4892 | + elseif ($char === "{" && $state === "T_AT_FONT_FACE::PREPARE") |
|
4893 | + { |
|
4894 | + $this->parser->setState("T_AT_FONT_FACE"); |
|
4895 | + $this->parser->clearBuffer(); |
|
4896 | + $this->parser->appendToken(new CssAtFontFaceStartToken()); |
|
4897 | + } |
|
4898 | + // Start of @font-face declaration |
|
4899 | + elseif ($char === ":" && $state === "T_AT_FONT_FACE") |
|
4900 | + { |
|
4901 | + $this->parser->pushState("T_AT_FONT_FACE_DECLARATION"); |
|
4902 | + $this->buffer = $this->parser->getAndClearBuffer(":", true); |
|
4903 | + } |
|
4904 | + // Unterminated @font-face declaration |
|
4905 | + elseif ($char === ":" && $state === "T_AT_FONT_FACE_DECLARATION") |
|
4906 | + { |
|
4907 | + // Ignore Internet Explorer filter declarations |
|
4908 | + if ($this->buffer === "filter") |
|
4909 | + { |
|
4910 | + return false; |
|
4911 | + } |
|
4912 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Unterminated @font-face declaration", $this->buffer . ":" . $this->parser->getBuffer() . "_")); |
|
4913 | + } |
|
4914 | + // End of @font-face declaration |
|
4915 | + elseif (($char === ";" || $char === "}") && $state === "T_AT_FONT_FACE_DECLARATION") |
|
4916 | + { |
|
4917 | + $value = $this->parser->getAndClearBuffer(";}"); |
|
4918 | + if (strtolower(substr($value, -10, 10)) === "!important") |
|
4919 | + { |
|
4920 | + $value = trim(substr($value, 0, -10)); |
|
4921 | + $isImportant = true; |
|
4922 | + } |
|
4923 | + else |
|
4924 | + { |
|
4925 | + $isImportant = false; |
|
4926 | + } |
|
4927 | + $this->parser->popState(); |
|
4928 | + $this->parser->appendToken(new CssAtFontFaceDeclarationToken($this->buffer, $value, $isImportant)); |
|
4929 | + $this->buffer = ""; |
|
4930 | + // -- |
|
4931 | + if ($char === "}") |
|
4932 | + { |
|
4933 | + $this->parser->appendToken(new CssAtFontFaceEndToken()); |
|
4934 | + $this->parser->popState(); |
|
4935 | + } |
|
4936 | + } |
|
4937 | + // End of @font-face at-rule block |
|
4938 | + elseif ($char === "}" && $state === "T_AT_FONT_FACE") |
|
4939 | + { |
|
4940 | + $this->parser->appendToken(new CssAtFontFaceEndToken()); |
|
4941 | + $this->parser->clearBuffer(); |
|
4942 | + $this->parser->popState(); |
|
4943 | + } |
|
4944 | + else |
|
4945 | + { |
|
4946 | + return false; |
|
4947 | + } |
|
4948 | + return true; |
|
4949 | + } |
|
4950 | + } |
|
4951 | 4951 | |
4952 | 4952 | /** |
4953 | 4953 | * This {@link aCssToken CSS token} represents the end of a @font-face at-rule block. |
@@ -4960,9 +4960,9 @@ discard block |
||
4960 | 4960 | * @version 3.0.1 |
4961 | 4961 | */ |
4962 | 4962 | class CssAtFontFaceEndToken extends aCssAtBlockEndToken |
4963 | - { |
|
4963 | + { |
|
4964 | 4964 | |
4965 | - } |
|
4965 | + } |
|
4966 | 4966 | |
4967 | 4967 | /** |
4968 | 4968 | * This {@link aCssToken CSS token} represents a declaration of a @font-face at-rule block. |
@@ -4975,9 +4975,9 @@ discard block |
||
4975 | 4975 | * @version 3.0.1 |
4976 | 4976 | */ |
4977 | 4977 | class CssAtFontFaceDeclarationToken extends aCssDeclarationToken |
4978 | - { |
|
4978 | + { |
|
4979 | 4979 | |
4980 | - } |
|
4980 | + } |
|
4981 | 4981 | |
4982 | 4982 | /** |
4983 | 4983 | * This {@link aCssToken CSS token} represents a @charset at-rule. |
@@ -4990,33 +4990,33 @@ discard block |
||
4990 | 4990 | * @version 3.0.1 |
4991 | 4991 | */ |
4992 | 4992 | class CssAtCharsetToken extends aCssToken |
4993 | - { |
|
4994 | - /** |
|
4995 | - * Charset of the @charset at-rule. |
|
4996 | - * |
|
4997 | - * @var string |
|
4998 | - */ |
|
4999 | - public $Charset = ""; |
|
5000 | - /** |
|
5001 | - * Set the properties of @charset at-rule token. |
|
5002 | - * |
|
5003 | - * @param string $charset Charset of the @charset at-rule token |
|
5004 | - * @return void |
|
5005 | - */ |
|
5006 | - public function __construct($charset) |
|
5007 | - { |
|
5008 | - $this->Charset = $charset; |
|
5009 | - } |
|
5010 | - /** |
|
5011 | - * Implements {@link aCssToken::__toString()}. |
|
5012 | - * |
|
5013 | - * @return string |
|
5014 | - */ |
|
5015 | - public function __toString() |
|
5016 | - { |
|
5017 | - return "@charset " . $this->Charset . ";"; |
|
5018 | - } |
|
5019 | - } |
|
4993 | + { |
|
4994 | + /** |
|
4995 | + * Charset of the @charset at-rule. |
|
4996 | + * |
|
4997 | + * @var string |
|
4998 | + */ |
|
4999 | + public $Charset = ""; |
|
5000 | + /** |
|
5001 | + * Set the properties of @charset at-rule token. |
|
5002 | + * |
|
5003 | + * @param string $charset Charset of the @charset at-rule token |
|
5004 | + * @return void |
|
5005 | + */ |
|
5006 | + public function __construct($charset) |
|
5007 | + { |
|
5008 | + $this->Charset = $charset; |
|
5009 | + } |
|
5010 | + /** |
|
5011 | + * Implements {@link aCssToken::__toString()}. |
|
5012 | + * |
|
5013 | + * @return string |
|
5014 | + */ |
|
5015 | + public function __toString() |
|
5016 | + { |
|
5017 | + return "@charset " . $this->Charset . ";"; |
|
5018 | + } |
|
5019 | + } |
|
5020 | 5020 | |
5021 | 5021 | /** |
5022 | 5022 | * {@link aCssParserPlugin Parser plugin} for parsing @charset at-rule. |
@@ -5031,53 +5031,53 @@ discard block |
||
5031 | 5031 | * @version 3.0.1 |
5032 | 5032 | */ |
5033 | 5033 | class CssAtCharsetParserPlugin extends aCssParserPlugin |
5034 | - { |
|
5035 | - /** |
|
5036 | - * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
5037 | - * |
|
5038 | - * @return array |
|
5039 | - */ |
|
5040 | - public function getTriggerChars() |
|
5041 | - { |
|
5042 | - return array("@", ";", "\n"); |
|
5043 | - } |
|
5044 | - /** |
|
5045 | - * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
5046 | - * |
|
5047 | - * @return array |
|
5048 | - */ |
|
5049 | - public function getTriggerStates() |
|
5050 | - { |
|
5051 | - return array("T_DOCUMENT", "T_AT_CHARSET"); |
|
5052 | - } |
|
5053 | - /** |
|
5054 | - * Implements {@link aCssParserPlugin::parse()}. |
|
5055 | - * |
|
5056 | - * @param integer $index Current index |
|
5057 | - * @param string $char Current char |
|
5058 | - * @param string $previousChar Previous char |
|
5059 | - * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
5060 | - */ |
|
5061 | - public function parse($index, $char, $previousChar, $state) |
|
5062 | - { |
|
5063 | - if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 8)) === "@charset") |
|
5064 | - { |
|
5065 | - $this->parser->pushState("T_AT_CHARSET"); |
|
5066 | - $this->parser->clearBuffer(); |
|
5067 | - return $index + 8; |
|
5068 | - } |
|
5069 | - elseif (($char === ";" || $char === "\n") && $state === "T_AT_CHARSET") |
|
5070 | - { |
|
5071 | - $charset = $this->parser->getAndClearBuffer(";"); |
|
5072 | - $this->parser->popState(); |
|
5073 | - $this->parser->appendToken(new CssAtCharsetToken($charset)); |
|
5074 | - } |
|
5075 | - else |
|
5076 | - { |
|
5077 | - return false; |
|
5078 | - } |
|
5079 | - return true; |
|
5080 | - } |
|
5081 | - } |
|
5034 | + { |
|
5035 | + /** |
|
5036 | + * Implements {@link aCssParserPlugin::getTriggerChars()}. |
|
5037 | + * |
|
5038 | + * @return array |
|
5039 | + */ |
|
5040 | + public function getTriggerChars() |
|
5041 | + { |
|
5042 | + return array("@", ";", "\n"); |
|
5043 | + } |
|
5044 | + /** |
|
5045 | + * Implements {@link aCssParserPlugin::getTriggerStates()}. |
|
5046 | + * |
|
5047 | + * @return array |
|
5048 | + */ |
|
5049 | + public function getTriggerStates() |
|
5050 | + { |
|
5051 | + return array("T_DOCUMENT", "T_AT_CHARSET"); |
|
5052 | + } |
|
5053 | + /** |
|
5054 | + * Implements {@link aCssParserPlugin::parse()}. |
|
5055 | + * |
|
5056 | + * @param integer $index Current index |
|
5057 | + * @param string $char Current char |
|
5058 | + * @param string $previousChar Previous char |
|
5059 | + * @return mixed TRUE will break the processing; FALSE continue with the next plugin; integer set a new index and break the processing |
|
5060 | + */ |
|
5061 | + public function parse($index, $char, $previousChar, $state) |
|
5062 | + { |
|
5063 | + if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 8)) === "@charset") |
|
5064 | + { |
|
5065 | + $this->parser->pushState("T_AT_CHARSET"); |
|
5066 | + $this->parser->clearBuffer(); |
|
5067 | + return $index + 8; |
|
5068 | + } |
|
5069 | + elseif (($char === ";" || $char === "\n") && $state === "T_AT_CHARSET") |
|
5070 | + { |
|
5071 | + $charset = $this->parser->getAndClearBuffer(";"); |
|
5072 | + $this->parser->popState(); |
|
5073 | + $this->parser->appendToken(new CssAtCharsetToken($charset)); |
|
5074 | + } |
|
5075 | + else |
|
5076 | + { |
|
5077 | + return false; |
|
5078 | + } |
|
5079 | + return true; |
|
5080 | + } |
|
5081 | + } |
|
5082 | 5082 | |
5083 | 5083 | ?> |
5084 | 5084 | \ No newline at end of file |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function __construct(CssParser $parser, array $configuration = null) |
136 | 136 | { |
137 | - $this->configuration = $configuration; |
|
138 | - $this->parser = $parser; |
|
137 | + $this->configuration = $configuration; |
|
138 | + $this->parser = $parser; |
|
139 | 139 | } |
140 | 140 | /** |
141 | 141 | * Returns the array of chars triggering the parser plugin. |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function __construct(CssMinifier $minifier, array $configuration = array()) |
198 | 198 | { |
199 | - $this->configuration = $configuration; |
|
200 | - $this->minifier = $minifier; |
|
199 | + $this->configuration = $configuration; |
|
200 | + $this->minifier = $minifier; |
|
201 | 201 | } |
202 | 202 | /** |
203 | 203 | * Apply the plugin to the token. |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function __construct(CssMinifier $minifier, array $configuration = array()) |
252 | 252 | { |
253 | - $this->configuration = $configuration; |
|
254 | - $this->minifier = $minifier; |
|
253 | + $this->configuration = $configuration; |
|
254 | + $this->minifier = $minifier; |
|
255 | 255 | } |
256 | 256 | /** |
257 | 257 | * Filter the tokens. |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | { |
306 | 306 | $this->tokens = $tokens; |
307 | 307 | $this->indent = !is_null($indent) ? $indent : $this->indent; |
308 | - $this->padding = !is_null($padding) ? $padding : $this->padding; |
|
308 | + $this->padding = !is_null($padding) ? $padding : $this->padding; |
|
309 | 309 | } |
310 | 310 | /** |
311 | 311 | * Returns the array of aCssToken as formatted string. |
@@ -362,10 +362,10 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public function __construct($property, $value, $isImportant = false, $isLast = false) |
364 | 364 | { |
365 | - $this->Property = $property; |
|
366 | - $this->Value = $value; |
|
367 | - $this->IsImportant = $isImportant; |
|
368 | - $this->IsLast = $isLast; |
|
365 | + $this->Property = $property; |
|
366 | + $this->Value = $value; |
|
367 | + $this->IsImportant = $isImportant; |
|
368 | + $this->IsLast = $isLast; |
|
369 | 369 | } |
370 | 370 | /** |
371 | 371 | * Implements {@link aCssToken::__toString()}. |
@@ -435,13 +435,13 @@ discard block |
||
435 | 435 | */ |
436 | 436 | public function __toString() |
437 | 437 | { |
438 | - $r = array(); |
|
438 | + $r = array(); |
|
439 | 439 | $level = 0; |
440 | 440 | for ($i = 0, $l = count($this->tokens); $i < $l; $i++) |
441 | 441 | { |
442 | 442 | $token = $this->tokens[$i]; |
443 | 443 | $class = get_class($token); |
444 | - $indent = str_repeat($this->indent, $level); |
|
444 | + $indent = str_repeat($this->indent, $level); |
|
445 | 445 | if ($class === "CssCommentToken") |
446 | 446 | { |
447 | 447 | $lines = array_map("trim", explode("\n", $token->Comment)); |
@@ -585,14 +585,14 @@ discard block |
||
585 | 585 | { |
586 | 586 | if (stripos($token->Value, "var") !== false && preg_match_all($this->reMatch, $token->Value, $m)) |
587 | 587 | { |
588 | - $mediaTypes = $token->MediaTypes; |
|
588 | + $mediaTypes = $token->MediaTypes; |
|
589 | 589 | if (!in_array("all", $mediaTypes)) |
590 | 590 | { |
591 | 591 | $mediaTypes[] = "all"; |
592 | 592 | } |
593 | 593 | for ($i = 0, $l = count($m[0]); $i < $l; $i++) |
594 | 594 | { |
595 | - $variable = trim($m[1][$i]); |
|
595 | + $variable = trim($m[1][$i]); |
|
596 | 596 | foreach ($mediaTypes as $mediaType) |
597 | 597 | { |
598 | 598 | if (isset($this->variables[$mediaType], $this->variables[$mediaType][$variable])) |
@@ -617,8 +617,7 @@ discard block |
||
617 | 617 | */ |
618 | 618 | public function getTriggerTokens() |
619 | 619 | { |
620 | - return array |
|
621 | - ( |
|
620 | + return array( |
|
622 | 621 | "CssAtFontFaceDeclarationToken", |
623 | 622 | "CssAtPageDeclarationToken", |
624 | 623 | "CssRulesetDeclarationToken" |
@@ -658,11 +657,11 @@ discard block |
||
658 | 657 | */ |
659 | 658 | public function apply(array &$tokens) |
660 | 659 | { |
661 | - $variables = array(); |
|
662 | - $defaultMediaTypes = array("all"); |
|
663 | - $mediaTypes = array(); |
|
664 | - $remove = array(); |
|
665 | - for($i = 0, $l = count($tokens); $i < $l; $i++) |
|
660 | + $variables = array(); |
|
661 | + $defaultMediaTypes = array("all"); |
|
662 | + $mediaTypes = array(); |
|
663 | + $remove = array(); |
|
664 | + for ($i = 0, $l = count($tokens); $i < $l; $i++) |
|
666 | 665 | { |
667 | 666 | // @variables at-rule block found |
668 | 667 | if (get_class($tokens[$i]) === "CssAtVariablesStartToken") |
@@ -677,7 +676,7 @@ discard block |
||
677 | 676 | } |
678 | 677 | } |
679 | 678 | // Read the variable declaration tokens |
680 | - for($i = $i; $i < $l; $i++) |
|
679 | + for ($i = $i; $i < $l; $i++) |
|
681 | 680 | { |
682 | 681 | // Found a variable declaration => read the variable values |
683 | 682 | if (get_class($tokens[$i]) === "CssAtVariablesDeclarationToken") |
@@ -698,9 +697,9 @@ discard block |
||
698 | 697 | } |
699 | 698 | } |
700 | 699 | // Variables in @variables at-rule blocks |
701 | - foreach($variables as $mediaType => $null) |
|
700 | + foreach ($variables as $mediaType => $null) |
|
702 | 701 | { |
703 | - foreach($variables[$mediaType] as $variable => $value) |
|
702 | + foreach ($variables[$mediaType] as $variable => $value) |
|
704 | 703 | { |
705 | 704 | // If a var() statement in a variable value found... |
706 | 705 | if (stripos($value, "var") !== false && preg_match_all("/var\((.+)\)/iSU", $value, $m)) |
@@ -883,7 +882,7 @@ discard block |
||
883 | 882 | // escape chars is uneven do not end the string |
884 | 883 | if ($previousChar == "\\") |
885 | 884 | { |
886 | - $source = $this->parser->getSource(); |
|
885 | + $source = $this->parser->getSource(); |
|
887 | 886 | $c = 1; |
888 | 887 | $i = $index - 2; |
889 | 888 | while (substr($source, $i, 1) === "\\") |
@@ -1211,7 +1210,7 @@ discard block |
||
1211 | 1210 | public function __construct($property, $value, $mediaTypes = null, $isImportant = false, $isLast = false) |
1212 | 1211 | { |
1213 | 1212 | parent::__construct($property, $value, $isImportant, $isLast); |
1214 | - $this->MediaTypes = $mediaTypes ? $mediaTypes : array("all"); |
|
1213 | + $this->MediaTypes = $mediaTypes ? $mediaTypes : array("all"); |
|
1215 | 1214 | } |
1216 | 1215 | } |
1217 | 1216 | |
@@ -1239,8 +1238,8 @@ discard block |
||
1239 | 1238 | { |
1240 | 1239 | for ($i = 0, $l = count($tokens); $i < $l; $i++) |
1241 | 1240 | { |
1242 | - $current = get_class($tokens[$i]); |
|
1243 | - $next = isset($tokens[$i+1]) ? get_class($tokens[$i+1]) : false; |
|
1241 | + $current = get_class($tokens[$i]); |
|
1242 | + $next = isset($tokens[$i + 1]) ? get_class($tokens[$i + 1]) : false; |
|
1244 | 1243 | if (($current === "CssRulesetDeclarationToken" && $next === "CssRulesetEndToken") || |
1245 | 1244 | ($current === "CssAtFontFaceDeclarationToken" && $next === "CssAtFontFaceEndToken") || |
1246 | 1245 | ($current === "CssAtPageDeclarationToken" && $next === "CssAtPageEndToken")) |
@@ -1276,14 +1275,14 @@ discard block |
||
1276 | 1275 | $r = 0; |
1277 | 1276 | for ($i = 0, $l = count($tokens); $i < $l; $i++) |
1278 | 1277 | { |
1279 | - $current = get_class($tokens[$i]); |
|
1278 | + $current = get_class($tokens[$i]); |
|
1280 | 1279 | $next = isset($tokens[$i + 1]) ? get_class($tokens[$i + 1]) : false; |
1281 | 1280 | if (($current === "CssRulesetStartToken" && $next === "CssRulesetEndToken") || |
1282 | 1281 | ($current === "CssAtKeyframesRulesetStartToken" && $next === "CssAtKeyframesRulesetEndToken" && !array_intersect(array("from", "0%", "to", "100%"), array_map("strtolower", $tokens[$i]->Selectors))) |
1283 | 1282 | ) |
1284 | 1283 | { |
1285 | - $tokens[$i] = null; |
|
1286 | - $tokens[$i + 1] = null; |
|
1284 | + $tokens[$i] = null; |
|
1285 | + $tokens[$i + 1] = null; |
|
1287 | 1286 | $i++; |
1288 | 1287 | $r = $r + 2; |
1289 | 1288 | } |
@@ -1316,15 +1315,15 @@ discard block |
||
1316 | 1315 | $r = 0; |
1317 | 1316 | for ($i = 0, $l = count($tokens); $i < $l; $i++) |
1318 | 1317 | { |
1319 | - $current = get_class($tokens[$i]); |
|
1318 | + $current = get_class($tokens[$i]); |
|
1320 | 1319 | $next = isset($tokens[$i + 1]) ? get_class($tokens[$i + 1]) : false; |
1321 | 1320 | if (($current === "CssAtFontFaceStartToken" && $next === "CssAtFontFaceEndToken") || |
1322 | 1321 | ($current === "CssAtKeyframesStartToken" && $next === "CssAtKeyframesEndToken") || |
1323 | 1322 | ($current === "CssAtPageStartToken" && $next === "CssAtPageEndToken") || |
1324 | 1323 | ($current === "CssAtMediaStartToken" && $next === "CssAtMediaEndToken")) |
1325 | 1324 | { |
1326 | - $tokens[$i] = null; |
|
1327 | - $tokens[$i + 1] = null; |
|
1325 | + $tokens[$i] = null; |
|
1326 | + $tokens[$i + 1] = null; |
|
1328 | 1327 | $i++; |
1329 | 1328 | $r = $r + 2; |
1330 | 1329 | } |
@@ -1437,8 +1436,7 @@ discard block |
||
1437 | 1436 | */ |
1438 | 1437 | public function __construct($source = null, array $plugins = null) |
1439 | 1438 | { |
1440 | - $plugins = array_merge(array |
|
1441 | - ( |
|
1439 | + $plugins = array_merge(array( |
|
1442 | 1440 | "Comment" => true, |
1443 | 1441 | "String" => true, |
1444 | 1442 | "Url" => true, |
@@ -1457,7 +1455,7 @@ discard block |
||
1457 | 1455 | { |
1458 | 1456 | if ($config !== false) |
1459 | 1457 | { |
1460 | - $class = "Css" . $name . "ParserPlugin"; |
|
1458 | + $class = "Css" . $name . "ParserPlugin"; |
|
1461 | 1459 | $config = is_array($config) ? $config : array(); |
1462 | 1460 | if (class_exists($class)) |
1463 | 1461 | { |
@@ -1604,19 +1602,19 @@ discard block |
||
1604 | 1602 | $this->tokens = array(); |
1605 | 1603 | // Create a global and plugin lookup table for trigger chars; set array of plugins as local variable and create |
1606 | 1604 | // several helper variables for plugin handling |
1607 | - $globalTriggerChars = ""; |
|
1608 | - $plugins = $this->plugins; |
|
1605 | + $globalTriggerChars = ""; |
|
1606 | + $plugins = $this->plugins; |
|
1609 | 1607 | $pluginCount = count($plugins); |
1610 | 1608 | $pluginIndex = array(); |
1611 | 1609 | $pluginTriggerStates = array(); |
1612 | 1610 | $pluginTriggerChars = array(); |
1613 | 1611 | for ($i = 0, $l = count($plugins); $i < $l; $i++) |
1614 | 1612 | { |
1615 | - $tPluginClassName = get_class($plugins[$i]); |
|
1613 | + $tPluginClassName = get_class($plugins[$i]); |
|
1616 | 1614 | $pluginTriggerChars[$i] = implode("", $plugins[$i]->getTriggerChars()); |
1617 | - $tPluginTriggerStates = $plugins[$i]->getTriggerStates(); |
|
1615 | + $tPluginTriggerStates = $plugins[$i]->getTriggerStates(); |
|
1618 | 1616 | $pluginTriggerStates[$i] = $tPluginTriggerStates === false ? false : "|" . implode("|", $tPluginTriggerStates) . "|"; |
1619 | - $pluginIndex[$tPluginClassName] = $i; |
|
1617 | + $pluginIndex[$tPluginClassName] = $i; |
|
1620 | 1618 | for ($ii = 0, $ll = strlen($pluginTriggerChars[$i]); $ii < $ll; $ii++) |
1621 | 1619 | { |
1622 | 1620 | $c = substr($pluginTriggerChars[$i], $ii, 1); |
@@ -1627,13 +1625,13 @@ discard block |
||
1627 | 1625 | } |
1628 | 1626 | } |
1629 | 1627 | // Normalise line endings |
1630 | - $source = str_replace("\r\n", "\n", $source); // Windows to Unix line endings |
|
1631 | - $source = str_replace("\r", "\n", $source); // Mac to Unix line endings |
|
1632 | - $this->source = $source; |
|
1628 | + $source = str_replace("\r\n", "\n", $source); // Windows to Unix line endings |
|
1629 | + $source = str_replace("\r", "\n", $source); // Mac to Unix line endings |
|
1630 | + $this->source = $source; |
|
1633 | 1631 | // Variables |
1634 | 1632 | $buffer = &$this->buffer; |
1635 | - $exclusive = &$this->stateExclusive; |
|
1636 | - $state = &$this->state; |
|
1633 | + $exclusive = &$this->stateExclusive; |
|
1634 | + $state = &$this->state; |
|
1637 | 1635 | $c = $p = null; |
1638 | 1636 | // -- |
1639 | 1637 | for ($i = 0, $l = strlen($source); $i < $l; $i++) |
@@ -1811,13 +1809,13 @@ discard block |
||
1811 | 1809 | */ |
1812 | 1810 | public function __toString() |
1813 | 1811 | { |
1814 | - $r = array(); |
|
1812 | + $r = array(); |
|
1815 | 1813 | $level = 0; |
1816 | 1814 | for ($i = 0, $l = count($this->tokens); $i < $l; $i++) |
1817 | 1815 | { |
1818 | 1816 | $token = $this->tokens[$i]; |
1819 | 1817 | $class = get_class($token); |
1820 | - $indent = str_repeat($this->indent, $level); |
|
1818 | + $indent = str_repeat($this->indent, $level); |
|
1821 | 1819 | if ($class === "CssCommentToken") |
1822 | 1820 | { |
1823 | 1821 | $lines = array_map("trim", explode("\n", $token->Comment)); |
@@ -1960,8 +1958,7 @@ discard block |
||
1960 | 1958 | */ |
1961 | 1959 | public function __construct($source = null, array $filters = null, array $plugins = null) |
1962 | 1960 | { |
1963 | - $filters = array_merge(array |
|
1964 | - ( |
|
1961 | + $filters = array_merge(array( |
|
1965 | 1962 | "ImportImports" => false, |
1966 | 1963 | "RemoveComments" => true, |
1967 | 1964 | "RemoveEmptyRulesets" => true, |
@@ -1971,8 +1968,7 @@ discard block |
||
1971 | 1968 | "Variables" => true, |
1972 | 1969 | "RemoveLastDelarationSemiColon" => true |
1973 | 1970 | ), is_array($filters) ? $filters : array()); |
1974 | - $plugins = array_merge(array |
|
1975 | - ( |
|
1971 | + $plugins = array_merge(array( |
|
1976 | 1972 | "Variables" => true, |
1977 | 1973 | "ConvertFontWeight" => false, |
1978 | 1974 | "ConvertHslColors" => false, |
@@ -1987,7 +1983,7 @@ discard block |
||
1987 | 1983 | { |
1988 | 1984 | if ($config !== false) |
1989 | 1985 | { |
1990 | - $class = "Css" . $name . "MinifierFilter"; |
|
1986 | + $class = "Css" . $name . "MinifierFilter"; |
|
1991 | 1987 | $config = is_array($config) ? $config : array(); |
1992 | 1988 | if (class_exists($class)) |
1993 | 1989 | { |
@@ -2004,7 +2000,7 @@ discard block |
||
2004 | 2000 | { |
2005 | 2001 | if ($config !== false) |
2006 | 2002 | { |
2007 | - $class = "Css" . $name . "MinifierPlugin"; |
|
2003 | + $class = "Css" . $name . "MinifierPlugin"; |
|
2008 | 2004 | $config = is_array($config) ? $config : array(); |
2009 | 2005 | if (class_exists($class)) |
2010 | 2006 | { |
@@ -2059,10 +2055,10 @@ discard block |
||
2059 | 2055 | public function minify($source) |
2060 | 2056 | { |
2061 | 2057 | // Variables |
2062 | - $r = ""; |
|
2058 | + $r = ""; |
|
2063 | 2059 | $parser = new CssParser($source); |
2064 | 2060 | $tokens = $parser->getTokens(); |
2065 | - $filters = $this->filters; |
|
2061 | + $filters = $this->filters; |
|
2066 | 2062 | $filterCount = count($this->filters); |
2067 | 2063 | $plugins = $this->plugins; |
2068 | 2064 | $pluginCount = count($plugins); |
@@ -2071,8 +2067,8 @@ discard block |
||
2071 | 2067 | $globalTriggerTokens = array(); |
2072 | 2068 | for ($i = 0, $l = count($plugins); $i < $l; $i++) |
2073 | 2069 | { |
2074 | - $tPluginClassName = get_class($plugins[$i]); |
|
2075 | - $pluginTriggerTokens[$i] = $plugins[$i]->getTriggerTokens(); |
|
2070 | + $tPluginClassName = get_class($plugins[$i]); |
|
2071 | + $pluginTriggerTokens[$i] = $plugins[$i]->getTriggerTokens(); |
|
2076 | 2072 | foreach ($pluginTriggerTokens[$i] as $v) |
2077 | 2073 | { |
2078 | 2074 | if (!in_array($v, $globalTriggerTokens)) |
@@ -2081,13 +2077,13 @@ discard block |
||
2081 | 2077 | } |
2082 | 2078 | } |
2083 | 2079 | $pluginTriggerTokens[$i] = "|" . implode("|", $pluginTriggerTokens[$i]) . "|"; |
2084 | - $pluginIndex[$tPluginClassName] = $i; |
|
2080 | + $pluginIndex[$tPluginClassName] = $i; |
|
2085 | 2081 | } |
2086 | 2082 | $globalTriggerTokens = "|" . implode("|", $globalTriggerTokens) . "|"; |
2087 | 2083 | /* |
2088 | 2084 | * Apply filters |
2089 | 2085 | */ |
2090 | - for($i = 0; $i < $filterCount; $i++) |
|
2086 | + for ($i = 0; $i < $filterCount; $i++) |
|
2091 | 2087 | { |
2092 | 2088 | // Apply the filter; if the return value is larger than 0... |
2093 | 2089 | if ($filters[$i]->apply($tokens) > 0) |
@@ -2100,12 +2096,12 @@ discard block |
||
2100 | 2096 | /* |
2101 | 2097 | * Apply plugins |
2102 | 2098 | */ |
2103 | - for($i = 0; $i < $tokenCount; $i++) |
|
2099 | + for ($i = 0; $i < $tokenCount; $i++) |
|
2104 | 2100 | { |
2105 | 2101 | $triggerToken = "|" . get_class($tokens[$i]) . "|"; |
2106 | 2102 | if (strpos($globalTriggerTokens, $triggerToken) !== false) |
2107 | 2103 | { |
2108 | - for($ii = 0; $ii < $pluginCount; $ii++) |
|
2104 | + for ($ii = 0; $ii < $pluginCount; $ii++) |
|
2109 | 2105 | { |
2110 | 2106 | if (strpos($pluginTriggerTokens[$ii], $triggerToken) !== false || $pluginTriggerTokens[$ii] === false) |
2111 | 2107 | { |
@@ -2119,7 +2115,7 @@ discard block |
||
2119 | 2115 | } |
2120 | 2116 | } |
2121 | 2117 | // Stringify the tokens |
2122 | - for($i = 0; $i < $tokenCount; $i++) |
|
2118 | + for ($i = 0; $i < $tokenCount; $i++) |
|
2123 | 2119 | { |
2124 | 2120 | $r .= (string) $tokens[$i]; |
2125 | 2121 | } |
@@ -2344,7 +2340,7 @@ discard block |
||
2344 | 2340 | { |
2345 | 2341 | if (!isset($this->configuration["BasePath"]) || !is_dir($this->configuration["BasePath"])) |
2346 | 2342 | { |
2347 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Base path <code>" . ($this->configuration["BasePath"] ? $this->configuration["BasePath"] : "null"). "</code> is not a directory")); |
|
2343 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Base path <code>" . ($this->configuration["BasePath"] ? $this->configuration["BasePath"] : "null") . "</code> is not a directory")); |
|
2348 | 2344 | return 0; |
2349 | 2345 | } |
2350 | 2346 | for ($i = 0, $l = count($tokens); $i < $l; $i++) |
@@ -2355,12 +2351,12 @@ discard block |
||
2355 | 2351 | // Import file was not found/is not a file |
2356 | 2352 | if (!is_file($import)) |
2357 | 2353 | { |
2358 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Import file <code>" . $import. "</code> was not found.", (string) $tokens[$i])); |
|
2354 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Import file <code>" . $import . "</code> was not found.", (string) $tokens[$i])); |
|
2359 | 2355 | } |
2360 | 2356 | // Import file already imported; remove this @import at-rule to prevent recursions |
2361 | 2357 | elseif (in_array($import, $this->imported)) |
2362 | 2358 | { |
2363 | - CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Import file <code>" . $import. "</code> was already imported.", (string) $tokens[$i])); |
|
2359 | + CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Import file <code>" . $import . "</code> was already imported.", (string) $tokens[$i])); |
|
2364 | 2360 | $tokens[$i] = null; |
2365 | 2361 | } |
2366 | 2362 | else |
@@ -2375,7 +2371,7 @@ discard block |
||
2375 | 2371 | /* |
2376 | 2372 | * Filter or set media types of @import at-rule or remove the @import at-rule if no media type is matching the parent @import at-rule |
2377 | 2373 | */ |
2378 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2374 | + for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2379 | 2375 | { |
2380 | 2376 | if (get_class($import[$ii]) === "CssAtImportToken") |
2381 | 2377 | { |
@@ -2406,7 +2402,7 @@ discard block |
||
2406 | 2402 | /* |
2407 | 2403 | * Remove media types of @media at-rule block not defined in the @import at-rule |
2408 | 2404 | */ |
2409 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2405 | + for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2410 | 2406 | { |
2411 | 2407 | if (get_class($import[$ii]) === "CssAtMediaStartToken") |
2412 | 2408 | { |
@@ -2423,7 +2419,7 @@ discard block |
||
2423 | 2419 | /* |
2424 | 2420 | * If no media types left of the @media at-rule block remove the complete block |
2425 | 2421 | */ |
2426 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2422 | + for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2427 | 2423 | { |
2428 | 2424 | if (get_class($import[$ii]) === "CssAtMediaStartToken") |
2429 | 2425 | { |
@@ -2448,7 +2444,7 @@ discard block |
||
2448 | 2444 | * If the media types of the @media at-rule equals the media types defined in the @import |
2449 | 2445 | * at-rule remove the CssAtMediaStartToken and CssAtMediaEndToken token |
2450 | 2446 | */ |
2451 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2447 | + for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2452 | 2448 | { |
2453 | 2449 | if (get_class($import[$ii]) === "CssAtMediaStartToken" && count(array_diff($tokens[$i]->MediaTypes, $import[$ii]->MediaTypes)) === 0) |
2454 | 2450 | { |
@@ -2471,7 +2467,7 @@ discard block |
||
2471 | 2467 | /** |
2472 | 2468 | * Extract CssAtImportToken and CssAtCharsetToken tokens |
2473 | 2469 | */ |
2474 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2470 | + for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2475 | 2471 | { |
2476 | 2472 | $class = get_class($import[$ii]); |
2477 | 2473 | if ($class === "CssAtImportToken" || $class === "CssAtCharsetToken") |
@@ -2483,7 +2479,7 @@ discard block |
||
2483 | 2479 | /* |
2484 | 2480 | * Extract the @font-face, @media and @page at-rule block |
2485 | 2481 | */ |
2486 | - for($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2482 | + for ($ii = 0, $ll = count($import); $ii < $ll; $ii++) |
|
2487 | 2483 | { |
2488 | 2484 | $class = get_class($import[$ii]); |
2489 | 2485 | if ($class === "CssAtFontFaceStartToken" || $class === "CssAtMediaStartToken" || $class === "CssAtPageStartToken" || $class === "CssAtVariablesStartToken") |
@@ -2651,8 +2647,8 @@ discard block |
||
2651 | 2647 | { |
2652 | 2648 | $this->File = $file; |
2653 | 2649 | $this->Line = $line; |
2654 | - $this->Message = $message; |
|
2655 | - $this->Source = $source; |
|
2650 | + $this->Message = $message; |
|
2651 | + $this->Source = $source; |
|
2656 | 2652 | } |
2657 | 2653 | /** |
2658 | 2654 | * Returns the error as formatted string. |
@@ -2661,7 +2657,7 @@ discard block |
||
2661 | 2657 | */ |
2662 | 2658 | public function __toString() |
2663 | 2659 | { |
2664 | - return $this->Message . ($this->Source ? ": <br /><code>" . $this->Source . "</code>": "") . "<br />in file " . $this->File . " at line " . $this->Line; |
|
2660 | + return $this->Message . ($this->Source ? ": <br /><code>" . $this->Source . "</code>" : "") . "<br />in file " . $this->File . " at line " . $this->Line; |
|
2665 | 2661 | } |
2666 | 2662 | } |
2667 | 2663 | |
@@ -2710,7 +2706,7 @@ discard block |
||
2710 | 2706 | $m[$i] = substr($m[$i], 0, -1); |
2711 | 2707 | $m[$i] = (int) (256 * ($m[$i] / 100)); |
2712 | 2708 | } |
2713 | - $m[$i] = str_pad(dechex($m[$i]), 2, "0", STR_PAD_LEFT); |
|
2709 | + $m[$i] = str_pad(dechex($m[$i]), 2, "0", STR_PAD_LEFT); |
|
2714 | 2710 | } |
2715 | 2711 | $token->Value = str_replace($m[0], "#" . $m[1] . $m[2] . $m[3], $token->Value); |
2716 | 2712 | } |
@@ -2723,8 +2719,7 @@ discard block |
||
2723 | 2719 | */ |
2724 | 2720 | public function getTriggerTokens() |
2725 | 2721 | { |
2726 | - return array |
|
2727 | - ( |
|
2722 | + return array( |
|
2728 | 2723 | "CssAtFontFaceDeclarationToken", |
2729 | 2724 | "CssAtPageDeclarationToken", |
2730 | 2725 | "CssRulesetDeclarationToken" |
@@ -2774,8 +2769,7 @@ discard block |
||
2774 | 2769 | * |
2775 | 2770 | * @var array |
2776 | 2771 | */ |
2777 | - private $transformation = array |
|
2778 | - ( |
|
2772 | + private $transformation = array( |
|
2779 | 2773 | "aliceblue" => "#f0f8ff", |
2780 | 2774 | "antiquewhite" => "#faebd7", |
2781 | 2775 | "aqua" => "#0ff", |
@@ -2956,8 +2950,7 @@ discard block |
||
2956 | 2950 | */ |
2957 | 2951 | public function getTriggerTokens() |
2958 | 2952 | { |
2959 | - return array |
|
2960 | - ( |
|
2953 | + return array( |
|
2961 | 2954 | "CssAtFontFaceDeclarationToken", |
2962 | 2955 | "CssAtPageDeclarationToken", |
2963 | 2956 | "CssRulesetDeclarationToken" |
@@ -2984,8 +2977,7 @@ discard block |
||
2984 | 2977 | * |
2985 | 2978 | * @var array |
2986 | 2979 | */ |
2987 | - private $transformations = array |
|
2988 | - ( |
|
2980 | + private $transformations = array( |
|
2989 | 2981 | // Property Array(Mozilla, Webkit, Opera, Internet Explorer); NULL values are placeholders and will get ignored |
2990 | 2982 | "animation" => array(null, "-webkit-animation", null, null), |
2991 | 2983 | "animation-delay" => array(null, "-webkit-animation-delay", null, null), |
@@ -3217,8 +3209,8 @@ discard block |
||
3217 | 3209 | } |
3218 | 3210 | else |
3219 | 3211 | { |
3220 | - $tValue = $tokens[$i]->Value; |
|
3221 | - $tMediaTypes = $tokens[$i]->MediaTypes; |
|
3212 | + $tValue = $tokens[$i]->Value; |
|
3213 | + $tMediaTypes = $tokens[$i]->MediaTypes; |
|
3222 | 3214 | foreach ($transformations[$tProperty] as $property) |
3223 | 3215 | { |
3224 | 3216 | if ($property !== null) |
@@ -3247,8 +3239,7 @@ discard block |
||
3247 | 3239 | */ |
3248 | 3240 | private static function filter($token) |
3249 | 3241 | { |
3250 | - $r = array |
|
3251 | - ( |
|
3242 | + $r = array( |
|
3252 | 3243 | new CssRulesetDeclarationToken("-ms-filter", "\"" . $token->Value . "\"", $token->MediaTypes), |
3253 | 3244 | ); |
3254 | 3245 | return $r; |
@@ -3263,8 +3254,7 @@ discard block |
||
3263 | 3254 | { |
3264 | 3255 | // Calculate the value for Internet Explorer filter statement |
3265 | 3256 | $ieValue = (int) ((float) $token->Value * 100); |
3266 | - $r = array |
|
3267 | - ( |
|
3257 | + $r = array( |
|
3268 | 3258 | // Internet Explorer >= 8 |
3269 | 3259 | new CssRulesetDeclarationToken("-ms-filter", "\"alpha(opacity=" . $ieValue . ")\"", $token->MediaTypes), |
3270 | 3260 | // Internet Explorer >= 4 <= 7 |
@@ -3283,8 +3273,7 @@ discard block |
||
3283 | 3273 | { |
3284 | 3274 | if (strtolower($token->Value) === "pre-wrap") |
3285 | 3275 | { |
3286 | - $r = array |
|
3287 | - ( |
|
3276 | + $r = array( |
|
3288 | 3277 | // Firefox < 3 |
3289 | 3278 | new CssRulesetDeclarationToken("white-space", "-moz-pre-wrap", $token->MediaTypes), |
3290 | 3279 | // Webkit |
@@ -3340,8 +3329,8 @@ discard block |
||
3340 | 3329 | } |
3341 | 3330 | if (get_class($tokens[$ii]) === "CssAtKeyframesEndToken") |
3342 | 3331 | { |
3343 | - $add = array(); |
|
3344 | - $source = array(); |
|
3332 | + $add = array(); |
|
3333 | + $source = array(); |
|
3345 | 3334 | for ($iii = $i; $iii <= $ii; $iii++) |
3346 | 3335 | { |
3347 | 3336 | $source[] = clone($tokens[$iii]); |
@@ -3423,8 +3412,7 @@ discard block |
||
3423 | 3412 | */ |
3424 | 3413 | public function getTriggerTokens() |
3425 | 3414 | { |
3426 | - return array |
|
3427 | - ( |
|
3415 | + return array( |
|
3428 | 3416 | "CssAtFontFaceDeclarationToken", |
3429 | 3417 | "CssAtPageDeclarationToken", |
3430 | 3418 | "CssRulesetDeclarationToken" |
@@ -3442,18 +3430,18 @@ discard block |
||
3442 | 3430 | */ |
3443 | 3431 | private function hsl2hex($hue, $saturation, $lightness) |
3444 | 3432 | { |
3445 | - $hue = $hue / 360; |
|
3446 | - $saturation = $saturation / 100; |
|
3447 | - $lightness = $lightness / 100; |
|
3433 | + $hue = $hue / 360; |
|
3434 | + $saturation = $saturation / 100; |
|
3435 | + $lightness = $lightness / 100; |
|
3448 | 3436 | if ($saturation == 0) |
3449 | 3437 | { |
3450 | - $red = $lightness * 255; |
|
3451 | - $green = $lightness * 255; |
|
3452 | - $blue = $lightness * 255; |
|
3438 | + $red = $lightness * 255; |
|
3439 | + $green = $lightness * 255; |
|
3440 | + $blue = $lightness * 255; |
|
3453 | 3441 | } |
3454 | 3442 | else |
3455 | 3443 | { |
3456 | - if ($lightness < 0.5 ) |
|
3444 | + if ($lightness < 0.5) |
|
3457 | 3445 | { |
3458 | 3446 | $v2 = $lightness * (1 + $saturation); |
3459 | 3447 | } |
@@ -3463,8 +3451,8 @@ discard block |
||
3463 | 3451 | } |
3464 | 3452 | $v1 = 2 * $lightness - $v2; |
3465 | 3453 | $red = 255 * self::hue2rgb($v1, $v2, $hue + (1 / 3)); |
3466 | - $green = 255 * self::hue2rgb($v1, $v2, $hue); |
|
3467 | - $blue = 255 * self::hue2rgb($v1, $v2, $hue - (1 / 3)); |
|
3454 | + $green = 255 * self::hue2rgb($v1, $v2, $hue); |
|
3455 | + $blue = 255 * self::hue2rgb($v1, $v2, $hue - (1 / 3)); |
|
3468 | 3456 | } |
3469 | 3457 | return "#" . str_pad(dechex(round($red)), 2, "0", STR_PAD_LEFT) . str_pad(dechex(round($green)), 2, "0", STR_PAD_LEFT) . str_pad(dechex(round($blue)), 2, "0", STR_PAD_LEFT); |
3470 | 3458 | } |
@@ -3496,7 +3484,7 @@ discard block |
||
3496 | 3484 | } |
3497 | 3485 | if ((3 * $hue) < 2) |
3498 | 3486 | { |
3499 | - return ($v1 + ($v2 - $v1) * (( 2 / 3) - $hue) * 6); |
|
3487 | + return ($v1 + ($v2 - $v1) * ((2 / 3) - $hue) * 6); |
|
3500 | 3488 | } |
3501 | 3489 | return $v1; |
3502 | 3490 | } |
@@ -3532,8 +3520,7 @@ discard block |
||
3532 | 3520 | * |
3533 | 3521 | * @var array |
3534 | 3522 | */ |
3535 | - private $include = array |
|
3536 | - ( |
|
3523 | + private $include = array( |
|
3537 | 3524 | "font", |
3538 | 3525 | "font-weight" |
3539 | 3526 | ); |
@@ -3554,8 +3541,7 @@ discard block |
||
3554 | 3541 | * |
3555 | 3542 | * @var array |
3556 | 3543 | */ |
3557 | - private $transformation = array |
|
3558 | - ( |
|
3544 | + private $transformation = array( |
|
3559 | 3545 | "normal" => "400", |
3560 | 3546 | "bold" => "700" |
3561 | 3547 | ); |
@@ -3570,7 +3556,7 @@ discard block |
||
3570 | 3556 | */ |
3571 | 3557 | public function __construct(CssMinifier $minifier) |
3572 | 3558 | { |
3573 | - $this->reMatch = "/(^|\s)+(" . implode("|", array_keys($this->transformation)). ")(\s|$)+/eiS"; |
|
3559 | + $this->reMatch = "/(^|\s)+(" . implode("|", array_keys($this->transformation)) . ")(\s|$)+/eiS"; |
|
3574 | 3560 | parent::__construct($minifier); |
3575 | 3561 | } |
3576 | 3562 | /** |
@@ -3594,8 +3580,7 @@ discard block |
||
3594 | 3580 | */ |
3595 | 3581 | public function getTriggerTokens() |
3596 | 3582 | { |
3597 | - return array |
|
3598 | - ( |
|
3583 | + return array( |
|
3599 | 3584 | "CssAtFontFaceDeclarationToken", |
3600 | 3585 | "CssAtPageDeclarationToken", |
3601 | 3586 | "CssRulesetDeclarationToken" |
@@ -3636,8 +3621,7 @@ discard block |
||
3636 | 3621 | * |
3637 | 3622 | * @var array |
3638 | 3623 | */ |
3639 | - private $re = array |
|
3640 | - ( |
|
3624 | + private $re = array( |
|
3641 | 3625 | "/(^| |-)0\.([0-9]+?)(0+)?(%|em|ex|px|in|cm|mm|pt|pc)/iS" => "\${1}.\${2}\${4}", |
3642 | 3626 | "/(^| )-?(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)/iS" => "\${1}0", |
3643 | 3627 | "/(^0\s0\s0\s0)|(^0\s0\s0$)|(^0\s0$)/iS" => "0" |
@@ -3672,8 +3656,7 @@ discard block |
||
3672 | 3656 | */ |
3673 | 3657 | public function getTriggerTokens() |
3674 | 3658 | { |
3675 | - return array |
|
3676 | - ( |
|
3659 | + return array( |
|
3677 | 3660 | "CssAtFontFaceDeclarationToken", |
3678 | 3661 | "CssAtPageDeclarationToken", |
3679 | 3662 | "CssRulesetDeclarationToken" |
@@ -3720,8 +3703,7 @@ discard block |
||
3720 | 3703 | */ |
3721 | 3704 | public function getTriggerTokens() |
3722 | 3705 | { |
3723 | - return array |
|
3724 | - ( |
|
3706 | + return array( |
|
3725 | 3707 | "CssAtFontFaceDeclarationToken", |
3726 | 3708 | "CssAtPageDeclarationToken", |
3727 | 3709 | "CssRulesetDeclarationToken" |
@@ -3783,8 +3765,7 @@ discard block |
||
3783 | 3765 | */ |
3784 | 3766 | public function getTriggerTokens() |
3785 | 3767 | { |
3786 | - return array |
|
3787 | - ( |
|
3768 | + return array( |
|
3788 | 3769 | "CssAtFontFaceDeclarationToken", |
3789 | 3770 | "CssAtPageDeclarationToken", |
3790 | 3771 | "CssRulesetDeclarationToken" |
@@ -4717,8 +4698,8 @@ discard block |
||
4717 | 4698 | */ |
4718 | 4699 | public function __construct($import, $mediaTypes) |
4719 | 4700 | { |
4720 | - $this->Import = $import; |
|
4721 | - $this->MediaTypes = $mediaTypes ? $mediaTypes : array(); |
|
4701 | + $this->Import = $import; |
|
4702 | + $this->MediaTypes = $mediaTypes ? $mediaTypes : array(); |
|
4722 | 4703 | } |
4723 | 4704 | /** |
4724 | 4705 | * Implements {@link aCssToken::__toString()}. |
@@ -4727,7 +4708,7 @@ discard block |
||
4727 | 4708 | */ |
4728 | 4709 | public function __toString() |
4729 | 4710 | { |
4730 | - return "@import \"" . $this->Import . "\"" . (count($this->MediaTypes) > 0 ? " " . implode(",", $this->MediaTypes) : ""). ";"; |
|
4711 | + return "@import \"" . $this->Import . "\"" . (count($this->MediaTypes) > 0 ? " " . implode(",", $this->MediaTypes) : "") . ";"; |
|
4731 | 4712 | } |
4732 | 4713 | } |
4733 | 4714 |
@@ -449,52 +449,43 @@ discard block |
||
449 | 449 | { |
450 | 450 | $r[] = $indent . (substr($lines[$ii], 0, 1) == "*" ? " " : "") . $lines[$ii]; |
451 | 451 | } |
452 | - } |
|
453 | - elseif ($class === "CssAtCharsetToken") |
|
452 | + } elseif ($class === "CssAtCharsetToken") |
|
454 | 453 | { |
455 | 454 | $r[] = $indent . "@charset " . $token->Charset . ";"; |
456 | - } |
|
457 | - elseif ($class === "CssAtFontFaceStartToken") |
|
455 | + } elseif ($class === "CssAtFontFaceStartToken") |
|
458 | 456 | { |
459 | 457 | $r[] = $indent . "@font-face"; |
460 | 458 | $r[] = $this->indent . $indent . "{"; |
461 | 459 | $level++; |
462 | - } |
|
463 | - elseif ($class === "CssAtImportToken") |
|
460 | + } elseif ($class === "CssAtImportToken") |
|
464 | 461 | { |
465 | 462 | $r[] = $indent . "@import " . $token->Import . " " . implode(", ", $token->MediaTypes) . ";"; |
466 | - } |
|
467 | - elseif ($class === "CssAtKeyframesStartToken") |
|
463 | + } elseif ($class === "CssAtKeyframesStartToken") |
|
468 | 464 | { |
469 | 465 | $r[] = $indent . "@keyframes \"" . $token->Name . "\""; |
470 | 466 | $r[] = $this->indent . $indent . "{"; |
471 | 467 | $level++; |
472 | - } |
|
473 | - elseif ($class === "CssAtMediaStartToken") |
|
468 | + } elseif ($class === "CssAtMediaStartToken") |
|
474 | 469 | { |
475 | 470 | $r[] = $indent . "@media " . implode(", ", $token->MediaTypes); |
476 | 471 | $r[] = $this->indent . $indent . "{"; |
477 | 472 | $level++; |
478 | - } |
|
479 | - elseif ($class === "CssAtPageStartToken") |
|
473 | + } elseif ($class === "CssAtPageStartToken") |
|
480 | 474 | { |
481 | 475 | $r[] = $indent . "@page"; |
482 | 476 | $r[] = $this->indent . $indent . "{"; |
483 | 477 | $level++; |
484 | - } |
|
485 | - elseif ($class === "CssAtVariablesStartToken") |
|
478 | + } elseif ($class === "CssAtVariablesStartToken") |
|
486 | 479 | { |
487 | 480 | $r[] = $indent . "@variables " . implode(", ", $token->MediaTypes); |
488 | 481 | $r[] = $this->indent . $indent . "{"; |
489 | 482 | $level++; |
490 | - } |
|
491 | - elseif ($class === "CssRulesetStartToken" || $class === "CssAtKeyframesRulesetStartToken") |
|
483 | + } elseif ($class === "CssRulesetStartToken" || $class === "CssAtKeyframesRulesetStartToken") |
|
492 | 484 | { |
493 | 485 | $r[] = $indent . implode(", ", $token->Selectors); |
494 | 486 | $r[] = $this->indent . $indent . "{"; |
495 | 487 | $level++; |
496 | - } |
|
497 | - elseif ($class == "CssAtFontFaceDeclarationToken" |
|
488 | + } elseif ($class == "CssAtFontFaceDeclarationToken" |
|
498 | 489 | || $class === "CssAtKeyframesRulesetDeclarationToken" |
499 | 490 | || $class === "CssAtPageDeclarationToken" |
500 | 491 | || $class == "CssAtVariablesDeclarationToken" |
@@ -507,8 +498,7 @@ discard block |
||
507 | 498 | $declaration = str_pad($declaration, $this->padding, " ", STR_PAD_RIGHT); |
508 | 499 | } |
509 | 500 | $r[] = $declaration . $token->Value . ($token->IsImportant ? " !important" : "") . ";"; |
510 | - } |
|
511 | - elseif ($class === "CssAtFontFaceEndToken" |
|
501 | + } elseif ($class === "CssAtFontFaceEndToken" |
|
512 | 502 | || $class === "CssAtMediaEndToken" |
513 | 503 | || $class === "CssAtKeyframesEndToken" |
514 | 504 | || $class === "CssAtKeyframesRulesetEndToken" |
@@ -721,8 +711,7 @@ discard block |
||
721 | 711 | if (!($plugin = $this->minifier->getPlugin("CssVariablesMinifierPlugin"))) |
722 | 712 | { |
723 | 713 | CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The plugin <code>CssVariablesMinifierPlugin</code> was not found but is required for <code>" . __CLASS__ . "</code>")); |
724 | - } |
|
725 | - else |
|
714 | + } else |
|
726 | 715 | { |
727 | 716 | $plugin->setVariables($variables); |
728 | 717 | } |
@@ -797,8 +786,7 @@ discard block |
||
797 | 786 | { |
798 | 787 | $this->parser->popState(); |
799 | 788 | $this->parser->unsetExclusive(); |
800 | - } |
|
801 | - else |
|
789 | + } else |
|
802 | 790 | { |
803 | 791 | return false; |
804 | 792 | } |
@@ -898,8 +886,7 @@ discard block |
||
898 | 886 | $this->parser->popState(); |
899 | 887 | $this->parser->unsetExclusive(); |
900 | 888 | $this->delimiterChar = null; |
901 | - } |
|
902 | - else |
|
889 | + } else |
|
903 | 890 | { |
904 | 891 | return false; |
905 | 892 | } |
@@ -974,8 +961,7 @@ discard block |
||
974 | 961 | if ($ii == $ll) |
975 | 962 | { |
976 | 963 | $declarations[$ii]->IsLast = true; |
977 | - } |
|
978 | - else |
|
964 | + } else |
|
979 | 965 | { |
980 | 966 | $declarations[$ii]->IsLast = false; |
981 | 967 | } |
@@ -1133,8 +1119,7 @@ discard block |
||
1133 | 1119 | { |
1134 | 1120 | $value = trim(substr($value, 0, -10)); |
1135 | 1121 | $isImportant = true; |
1136 | - } |
|
1137 | - else |
|
1122 | + } else |
|
1138 | 1123 | { |
1139 | 1124 | $isImportant = false; |
1140 | 1125 | } |
@@ -1156,8 +1141,7 @@ discard block |
||
1156 | 1141 | $this->parser->appendToken(new CssRulesetEndToken()); |
1157 | 1142 | $this->buffer = ""; |
1158 | 1143 | $this->selectors = array(); |
1159 | - } |
|
1160 | - else |
|
1144 | + } else |
|
1161 | 1145 | { |
1162 | 1146 | return false; |
1163 | 1147 | } |
@@ -1462,8 +1446,7 @@ discard block |
||
1462 | 1446 | if (class_exists($class)) |
1463 | 1447 | { |
1464 | 1448 | $this->plugins[] = new $class($this, $config); |
1465 | - } |
|
1466 | - else |
|
1449 | + } else |
|
1467 | 1450 | { |
1468 | 1451 | CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The plugin <code>" . $name . "</code> with the class name <code>" . $class . "</code> was not found")); |
1469 | 1452 | } |
@@ -1825,46 +1808,37 @@ discard block |
||
1825 | 1808 | { |
1826 | 1809 | $r[] = $indent . (substr($lines[$ii], 0, 1) == "*" ? " " : "") . $lines[$ii]; |
1827 | 1810 | } |
1828 | - } |
|
1829 | - elseif ($class === "CssAtCharsetToken") |
|
1811 | + } elseif ($class === "CssAtCharsetToken") |
|
1830 | 1812 | { |
1831 | 1813 | $r[] = $indent . "@charset " . $token->Charset . ";"; |
1832 | - } |
|
1833 | - elseif ($class === "CssAtFontFaceStartToken") |
|
1814 | + } elseif ($class === "CssAtFontFaceStartToken") |
|
1834 | 1815 | { |
1835 | 1816 | $r[] = $indent . "@font-face {"; |
1836 | 1817 | $level++; |
1837 | - } |
|
1838 | - elseif ($class === "CssAtImportToken") |
|
1818 | + } elseif ($class === "CssAtImportToken") |
|
1839 | 1819 | { |
1840 | 1820 | $r[] = $indent . "@import " . $token->Import . " " . implode(", ", $token->MediaTypes) . ";"; |
1841 | - } |
|
1842 | - elseif ($class === "CssAtKeyframesStartToken") |
|
1821 | + } elseif ($class === "CssAtKeyframesStartToken") |
|
1843 | 1822 | { |
1844 | 1823 | $r[] = $indent . "@keyframes \"" . $token->Name . "\" {"; |
1845 | 1824 | $level++; |
1846 | - } |
|
1847 | - elseif ($class === "CssAtMediaStartToken") |
|
1825 | + } elseif ($class === "CssAtMediaStartToken") |
|
1848 | 1826 | { |
1849 | 1827 | $r[] = $indent . "@media " . implode(", ", $token->MediaTypes) . " {"; |
1850 | 1828 | $level++; |
1851 | - } |
|
1852 | - elseif ($class === "CssAtPageStartToken") |
|
1829 | + } elseif ($class === "CssAtPageStartToken") |
|
1853 | 1830 | { |
1854 | 1831 | $r[] = $indent . "@page {"; |
1855 | 1832 | $level++; |
1856 | - } |
|
1857 | - elseif ($class === "CssAtVariablesStartToken") |
|
1833 | + } elseif ($class === "CssAtVariablesStartToken") |
|
1858 | 1834 | { |
1859 | 1835 | $r[] = $indent . "@variables " . implode(", ", $token->MediaTypes) . " {"; |
1860 | 1836 | $level++; |
1861 | - } |
|
1862 | - elseif ($class === "CssRulesetStartToken" || $class === "CssAtKeyframesRulesetStartToken") |
|
1837 | + } elseif ($class === "CssRulesetStartToken" || $class === "CssAtKeyframesRulesetStartToken") |
|
1863 | 1838 | { |
1864 | 1839 | $r[] = $indent . implode(", ", $token->Selectors) . " {"; |
1865 | 1840 | $level++; |
1866 | - } |
|
1867 | - elseif ($class == "CssAtFontFaceDeclarationToken" |
|
1841 | + } elseif ($class == "CssAtFontFaceDeclarationToken" |
|
1868 | 1842 | || $class === "CssAtKeyframesRulesetDeclarationToken" |
1869 | 1843 | || $class === "CssAtPageDeclarationToken" |
1870 | 1844 | || $class == "CssAtVariablesDeclarationToken" |
@@ -1877,8 +1851,7 @@ discard block |
||
1877 | 1851 | $declaration = str_pad($declaration, $this->padding, " ", STR_PAD_RIGHT); |
1878 | 1852 | } |
1879 | 1853 | $r[] = $declaration . $token->Value . ($token->IsImportant ? " !important" : "") . ";"; |
1880 | - } |
|
1881 | - elseif ($class === "CssAtFontFaceEndToken" |
|
1854 | + } elseif ($class === "CssAtFontFaceEndToken" |
|
1882 | 1855 | || $class === "CssAtMediaEndToken" |
1883 | 1856 | || $class === "CssAtKeyframesEndToken" |
1884 | 1857 | || $class === "CssAtKeyframesRulesetEndToken" |
@@ -1992,8 +1965,7 @@ discard block |
||
1992 | 1965 | if (class_exists($class)) |
1993 | 1966 | { |
1994 | 1967 | $this->filters[] = new $class($this, $config); |
1995 | - } |
|
1996 | - else |
|
1968 | + } else |
|
1997 | 1969 | { |
1998 | 1970 | CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The filter <code>" . $name . "</code> with the class name <code>" . $class . "</code> was not found")); |
1999 | 1971 | } |
@@ -2009,8 +1981,7 @@ discard block |
||
2009 | 1981 | if (class_exists($class)) |
2010 | 1982 | { |
2011 | 1983 | $this->plugins[] = new $class($this, $config); |
2012 | - } |
|
2013 | - else |
|
1984 | + } else |
|
2014 | 1985 | { |
2015 | 1986 | CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": The plugin <code>" . $name . "</code> with the class name <code>" . $class . "</code> was not found")); |
2016 | 1987 | } |
@@ -2362,8 +2333,7 @@ discard block |
||
2362 | 2333 | { |
2363 | 2334 | CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Import file <code>" . $import. "</code> was already imported.", (string) $tokens[$i])); |
2364 | 2335 | $tokens[$i] = null; |
2365 | - } |
|
2366 | - else |
|
2336 | + } else |
|
2367 | 2337 | { |
2368 | 2338 | $this->imported[] = $import; |
2369 | 2339 | $parser = new CssParser(file_get_contents($import)); |
@@ -2595,8 +2565,7 @@ discard block |
||
2595 | 2565 | $this->leftBraces = $this->rightBraces = 0; |
2596 | 2566 | $this->parser->popState(); |
2597 | 2567 | return $index - 1; |
2598 | - } |
|
2599 | - else |
|
2568 | + } else |
|
2600 | 2569 | { |
2601 | 2570 | return false; |
2602 | 2571 | } |
@@ -3214,8 +3183,7 @@ discard block |
||
3214 | 3183 | { |
3215 | 3184 | $result = array($result); |
3216 | 3185 | } |
3217 | - } |
|
3218 | - else |
|
3186 | + } else |
|
3219 | 3187 | { |
3220 | 3188 | $tValue = $tokens[$i]->Value; |
3221 | 3189 | $tMediaTypes = $tokens[$i]->MediaTypes; |
@@ -3297,8 +3265,7 @@ discard block |
||
3297 | 3265 | new CssRulesetDeclarationToken("word-wrap", "break-word", $token->MediaTypes) |
3298 | 3266 | ); |
3299 | 3267 | return $r; |
3300 | - } |
|
3301 | - else |
|
3268 | + } else |
|
3302 | 3269 | { |
3303 | 3270 | return array(); |
3304 | 3271 | } |
@@ -3359,8 +3326,7 @@ discard block |
||
3359 | 3326 | if (isset($this->configuration["RemoveSource"]) && $this->configuration["RemoveSource"] === true) |
3360 | 3327 | { |
3361 | 3328 | array_splice($tokens, $i, $ii - $i + 1, $add); |
3362 | - } |
|
3363 | - else |
|
3329 | + } else |
|
3364 | 3330 | { |
3365 | 3331 | array_splice($tokens, $ii + 1, 0, $add); |
3366 | 3332 | } |
@@ -3450,14 +3416,12 @@ discard block |
||
3450 | 3416 | $red = $lightness * 255; |
3451 | 3417 | $green = $lightness * 255; |
3452 | 3418 | $blue = $lightness * 255; |
3453 | - } |
|
3454 | - else |
|
3419 | + } else |
|
3455 | 3420 | { |
3456 | 3421 | if ($lightness < 0.5 ) |
3457 | 3422 | { |
3458 | 3423 | $v2 = $lightness * (1 + $saturation); |
3459 | - } |
|
3460 | - else |
|
3424 | + } else |
|
3461 | 3425 | { |
3462 | 3426 | $v2 = ($lightness + $saturation) - ($saturation * $lightness); |
3463 | 3427 | } |
@@ -3884,15 +3848,13 @@ discard block |
||
3884 | 3848 | $this->parser->pushState("T_COMMENT"); |
3885 | 3849 | $this->parser->setExclusive(__CLASS__); |
3886 | 3850 | $this->restoreBuffer = substr($this->parser->getAndClearBuffer(), 0, -2); |
3887 | - } |
|
3888 | - elseif ($char === "/" && $previousChar === "*" && $state === "T_COMMENT") |
|
3851 | + } elseif ($char === "/" && $previousChar === "*" && $state === "T_COMMENT") |
|
3889 | 3852 | { |
3890 | 3853 | $this->parser->popState(); |
3891 | 3854 | $this->parser->unsetExclusive(); |
3892 | 3855 | $this->parser->appendToken(new CssCommentToken("/*" . $this->parser->getAndClearBuffer())); |
3893 | 3856 | $this->parser->setBuffer($this->restoreBuffer); |
3894 | - } |
|
3895 | - else |
|
3857 | + } else |
|
3896 | 3858 | { |
3897 | 3859 | return false; |
3898 | 3860 | } |
@@ -4020,8 +3982,7 @@ discard block |
||
4020 | 3982 | { |
4021 | 3983 | $value = trim(substr($value, 0, -10)); |
4022 | 3984 | $isImportant = true; |
4023 | - } |
|
4024 | - else |
|
3985 | + } else |
|
4025 | 3986 | { |
4026 | 3987 | $isImportant = false; |
4027 | 3988 | } |
@@ -4035,8 +3996,7 @@ discard block |
||
4035 | 3996 | $this->parser->popState(); |
4036 | 3997 | $this->parser->clearBuffer(); |
4037 | 3998 | $this->parser->appendToken(new CssAtVariablesEndToken()); |
4038 | - } |
|
4039 | - else |
|
3999 | + } else |
|
4040 | 4000 | { |
4041 | 4001 | return false; |
4042 | 4002 | } |
@@ -4211,8 +4171,7 @@ discard block |
||
4211 | 4171 | { |
4212 | 4172 | $value = trim(substr($value, 0, -10)); |
4213 | 4173 | $isImportant = true; |
4214 | - } |
|
4215 | - else |
|
4174 | + } else |
|
4216 | 4175 | { |
4217 | 4176 | $isImportant = false; |
4218 | 4177 | } |
@@ -4232,8 +4191,7 @@ discard block |
||
4232 | 4191 | $this->parser->popState(); |
4233 | 4192 | $this->parser->clearBuffer(); |
4234 | 4193 | $this->parser->appendToken(new CssAtPageEndToken()); |
4235 | - } |
|
4236 | - else |
|
4194 | + } else |
|
4237 | 4195 | { |
4238 | 4196 | return false; |
4239 | 4197 | } |
@@ -4353,22 +4311,19 @@ discard block |
||
4353 | 4311 | $this->parser->pushState("T_AT_MEDIA::PREPARE"); |
4354 | 4312 | $this->parser->clearBuffer(); |
4355 | 4313 | return $index + 6; |
4356 | - } |
|
4357 | - elseif ($char === "{" && $state === "T_AT_MEDIA::PREPARE") |
|
4314 | + } elseif ($char === "{" && $state === "T_AT_MEDIA::PREPARE") |
|
4358 | 4315 | { |
4359 | 4316 | $mediaTypes = array_filter(array_map("trim", explode(",", $this->parser->getAndClearBuffer("{")))); |
4360 | 4317 | $this->parser->setMediaTypes($mediaTypes); |
4361 | 4318 | $this->parser->setState("T_AT_MEDIA"); |
4362 | 4319 | $this->parser->appendToken(new CssAtMediaStartToken($mediaTypes)); |
4363 | - } |
|
4364 | - elseif ($char === "}" && $state === "T_AT_MEDIA") |
|
4320 | + } elseif ($char === "}" && $state === "T_AT_MEDIA") |
|
4365 | 4321 | { |
4366 | 4322 | $this->parser->appendToken(new CssAtMediaEndToken()); |
4367 | 4323 | $this->parser->clearBuffer(); |
4368 | 4324 | $this->parser->unsetMediaTypes(); |
4369 | 4325 | $this->parser->popState(); |
4370 | - } |
|
4371 | - else |
|
4326 | + } else |
|
4372 | 4327 | { |
4373 | 4328 | return false; |
4374 | 4329 | } |
@@ -4631,8 +4586,7 @@ discard block |
||
4631 | 4586 | { |
4632 | 4587 | $value = trim(substr($value, 0, -10)); |
4633 | 4588 | $isImportant = true; |
4634 | - } |
|
4635 | - else |
|
4589 | + } else |
|
4636 | 4590 | { |
4637 | 4591 | $isImportant = false; |
4638 | 4592 | } |
@@ -4660,8 +4614,7 @@ discard block |
||
4660 | 4614 | $this->parser->clearBuffer(); |
4661 | 4615 | $this->parser->popState(); |
4662 | 4616 | $this->parser->appendToken(new CssAtKeyframesEndToken()); |
4663 | - } |
|
4664 | - else |
|
4617 | + } else |
|
4665 | 4618 | { |
4666 | 4619 | return false; |
4667 | 4620 | } |
@@ -4778,8 +4731,7 @@ discard block |
||
4778 | 4731 | $this->parser->pushState("T_AT_IMPORT"); |
4779 | 4732 | $this->parser->clearBuffer(); |
4780 | 4733 | return $index + 7; |
4781 | - } |
|
4782 | - elseif (($char === ";" || $char === "\n") && $state === "T_AT_IMPORT") |
|
4734 | + } elseif (($char === ";" || $char === "\n") && $state === "T_AT_IMPORT") |
|
4783 | 4735 | { |
4784 | 4736 | $this->buffer = $this->parser->getAndClearBuffer(";"); |
4785 | 4737 | $pos = false; |
@@ -4800,14 +4752,12 @@ discard block |
||
4800 | 4752 | if ($pos) |
4801 | 4753 | { |
4802 | 4754 | $this->parser->appendToken(new CssAtImportToken($import, $mediaTypes)); |
4803 | - } |
|
4804 | - else |
|
4755 | + } else |
|
4805 | 4756 | { |
4806 | 4757 | CssMin::triggerError(new CssError(__FILE__, __LINE__, __METHOD__ . ": Invalid @import at-rule syntax", $this->parser->buffer)); |
4807 | 4758 | } |
4808 | 4759 | $this->parser->popState(); |
4809 | - } |
|
4810 | - else |
|
4760 | + } else |
|
4811 | 4761 | { |
4812 | 4762 | return false; |
4813 | 4763 | } |
@@ -4919,8 +4869,7 @@ discard block |
||
4919 | 4869 | { |
4920 | 4870 | $value = trim(substr($value, 0, -10)); |
4921 | 4871 | $isImportant = true; |
4922 | - } |
|
4923 | - else |
|
4872 | + } else |
|
4924 | 4873 | { |
4925 | 4874 | $isImportant = false; |
4926 | 4875 | } |
@@ -4940,8 +4889,7 @@ discard block |
||
4940 | 4889 | $this->parser->appendToken(new CssAtFontFaceEndToken()); |
4941 | 4890 | $this->parser->clearBuffer(); |
4942 | 4891 | $this->parser->popState(); |
4943 | - } |
|
4944 | - else |
|
4892 | + } else |
|
4945 | 4893 | { |
4946 | 4894 | return false; |
4947 | 4895 | } |
@@ -5065,14 +5013,12 @@ discard block |
||
5065 | 5013 | $this->parser->pushState("T_AT_CHARSET"); |
5066 | 5014 | $this->parser->clearBuffer(); |
5067 | 5015 | return $index + 8; |
5068 | - } |
|
5069 | - elseif (($char === ";" || $char === "\n") && $state === "T_AT_CHARSET") |
|
5016 | + } elseif (($char === ";" || $char === "\n") && $state === "T_AT_CHARSET") |
|
5070 | 5017 | { |
5071 | 5018 | $charset = $this->parser->getAndClearBuffer(";"); |
5072 | 5019 | $this->parser->popState(); |
5073 | 5020 | $this->parser->appendToken(new CssAtCharsetToken($charset)); |
5074 | - } |
|
5075 | - else |
|
5021 | + } else |
|
5076 | 5022 | { |
5077 | 5023 | return false; |
5078 | 5024 | } |
@@ -34,89 +34,89 @@ |
||
34 | 34 | |
35 | 35 | |
36 | 36 | */ |
37 | - // -- Class Name : HtmlMin |
|
38 | - // -- Purpose : PHP class to minify html code. |
|
39 | - // -- Usage: echo PHPWee\Minify::html($myhtml); |
|
40 | - // -- notes: aply data-no-min to a style or script node to exempt it |
|
41 | - // -- HTML 4, XHTML, and HTML 5 compliant |
|
37 | + // -- Class Name : HtmlMin |
|
38 | + // -- Purpose : PHP class to minify html code. |
|
39 | + // -- Usage: echo PHPWee\Minify::html($myhtml); |
|
40 | + // -- notes: aply data-no-min to a style or script node to exempt it |
|
41 | + // -- HTML 4, XHTML, and HTML 5 compliant |
|
42 | 42 | |
43 | - class HtmlMin{ |
|
44 | - // -- Function Name : minify - Params : $html, $js = true, $css = true |
|
45 | - public static function minify($html, $js = true, $css = true){ |
|
46 | - $doc = new \DOMDocument(); |
|
47 | - $doc->preserveWhiteSpace = false; |
|
48 | - @$doc->loadHTML($html); |
|
49 | - $xpath = new \DOMXPath($doc); |
|
50 | - foreach ($xpath->query('//comment()') as $comment) { |
|
51 | - $val= $comment->nodeValue; |
|
52 | - if( strpos($val,'[')!==0){ |
|
53 | - $comment->parentNode->removeChild($comment); |
|
54 | - } |
|
55 | - } |
|
56 | - $doc->normalizeDocument(); |
|
57 | - $textnodes = $xpath->query('//text()'); |
|
58 | - $skip = ["style","pre","code","script","textarea"]; |
|
59 | - foreach($textnodes as $t){ |
|
60 | - $xp = $t->getNodePath(); |
|
61 | - $doskip = false; |
|
62 | - foreach($skip as $pattern){ |
|
63 | - if(strpos($xp,"/$pattern")!==false){ |
|
64 | - $doskip = true; |
|
65 | - break; |
|
66 | - } |
|
67 | - } |
|
68 | - if($doskip){ |
|
69 | - continue; |
|
70 | - } |
|
71 | - $t->nodeValue = preg_replace("/\s{2,}/", " ", $t->nodeValue); |
|
72 | - } |
|
73 | - $doc->normalizeDocument(); |
|
74 | - $divnodes = $xpath->query('//div|//p|//nav|//footer|//article|//script|//hr|//br'); |
|
75 | - foreach($divnodes as $d){ |
|
76 | - $candidates = []; |
|
77 | - if(count($d->childNodes)){ |
|
78 | - $candidates[] = $d->firstChild; |
|
79 | - $candidates[] = $d->lastChild; |
|
80 | - $candidates[] = $d->previousSibling; |
|
81 | - $candidates[] = $d->nextSibling; |
|
82 | - } |
|
83 | - foreach($candidates as $c){ |
|
84 | - if($c==null){ |
|
85 | - continue; |
|
86 | - } |
|
87 | - if($c->nodeType==3){ |
|
88 | - $c->nodeValue = trim($c->nodeValue); |
|
89 | - } |
|
90 | - } |
|
91 | - } |
|
92 | - $doc->normalizeDocument(); |
|
93 | - if($js){ |
|
94 | - $scriptnodes = $xpath->query('//script'); |
|
95 | - foreach($scriptnodes as $d){ |
|
96 | - if($d->hasAttribute("type") && strtolower($d->getAttribute("type"))!=='text/javascript' ){ |
|
97 | - continue; |
|
98 | - } |
|
99 | - if($d->hasAttribute("data-no-min")){ |
|
100 | - continue; |
|
101 | - } |
|
102 | - if(trim($d->nodeValue)==""){ |
|
103 | - continue; |
|
104 | - } |
|
105 | - $d->nodeValue = JSMin::minify( $d->nodeValue); |
|
106 | - } |
|
107 | - } |
|
108 | - if($css){ |
|
109 | - $cssnodes = $xpath->query('//style'); |
|
110 | - foreach($cssnodes as $d){ |
|
111 | - if($d->hasAttribute("data-no-min")){ |
|
112 | - continue; |
|
113 | - } |
|
114 | - if(trim($d->nodeValue)==""){ |
|
115 | - continue; |
|
116 | - } |
|
117 | - $d->nodeValue = CssMin::minify( $d->nodeValue); |
|
118 | - } |
|
119 | - } |
|
120 | - return ($doc->saveHTML()); |
|
121 | - } |
|
122 | - } |
|
123 | 43 | \ No newline at end of file |
44 | + class HtmlMin{ |
|
45 | + // -- Function Name : minify - Params : $html, $js = true, $css = true |
|
46 | + public static function minify($html, $js = true, $css = true){ |
|
47 | + $doc = new \DOMDocument(); |
|
48 | + $doc->preserveWhiteSpace = false; |
|
49 | + @$doc->loadHTML($html); |
|
50 | + $xpath = new \DOMXPath($doc); |
|
51 | + foreach ($xpath->query('//comment()') as $comment) { |
|
52 | + $val= $comment->nodeValue; |
|
53 | + if( strpos($val,'[')!==0){ |
|
54 | + $comment->parentNode->removeChild($comment); |
|
55 | + } |
|
56 | + } |
|
57 | + $doc->normalizeDocument(); |
|
58 | + $textnodes = $xpath->query('//text()'); |
|
59 | + $skip = ["style","pre","code","script","textarea"]; |
|
60 | + foreach($textnodes as $t){ |
|
61 | + $xp = $t->getNodePath(); |
|
62 | + $doskip = false; |
|
63 | + foreach($skip as $pattern){ |
|
64 | + if(strpos($xp,"/$pattern")!==false){ |
|
65 | + $doskip = true; |
|
66 | + break; |
|
67 | + } |
|
68 | + } |
|
69 | + if($doskip){ |
|
70 | + continue; |
|
71 | + } |
|
72 | + $t->nodeValue = preg_replace("/\s{2,}/", " ", $t->nodeValue); |
|
73 | + } |
|
74 | + $doc->normalizeDocument(); |
|
75 | + $divnodes = $xpath->query('//div|//p|//nav|//footer|//article|//script|//hr|//br'); |
|
76 | + foreach($divnodes as $d){ |
|
77 | + $candidates = []; |
|
78 | + if(count($d->childNodes)){ |
|
79 | + $candidates[] = $d->firstChild; |
|
80 | + $candidates[] = $d->lastChild; |
|
81 | + $candidates[] = $d->previousSibling; |
|
82 | + $candidates[] = $d->nextSibling; |
|
83 | + } |
|
84 | + foreach($candidates as $c){ |
|
85 | + if($c==null){ |
|
86 | + continue; |
|
87 | + } |
|
88 | + if($c->nodeType==3){ |
|
89 | + $c->nodeValue = trim($c->nodeValue); |
|
90 | + } |
|
91 | + } |
|
92 | + } |
|
93 | + $doc->normalizeDocument(); |
|
94 | + if($js){ |
|
95 | + $scriptnodes = $xpath->query('//script'); |
|
96 | + foreach($scriptnodes as $d){ |
|
97 | + if($d->hasAttribute("type") && strtolower($d->getAttribute("type"))!=='text/javascript' ){ |
|
98 | + continue; |
|
99 | + } |
|
100 | + if($d->hasAttribute("data-no-min")){ |
|
101 | + continue; |
|
102 | + } |
|
103 | + if(trim($d->nodeValue)==""){ |
|
104 | + continue; |
|
105 | + } |
|
106 | + $d->nodeValue = JSMin::minify( $d->nodeValue); |
|
107 | + } |
|
108 | + } |
|
109 | + if($css){ |
|
110 | + $cssnodes = $xpath->query('//style'); |
|
111 | + foreach($cssnodes as $d){ |
|
112 | + if($d->hasAttribute("data-no-min")){ |
|
113 | + continue; |
|
114 | + } |
|
115 | + if(trim($d->nodeValue)==""){ |
|
116 | + continue; |
|
117 | + } |
|
118 | + $d->nodeValue = CssMin::minify( $d->nodeValue); |
|
119 | + } |
|
120 | + } |
|
121 | + return ($doc->saveHTML()); |
|
122 | + } |
|
123 | + } |
|
124 | 124 | \ No newline at end of file |
@@ -40,81 +40,81 @@ |
||
40 | 40 | // -- notes: aply data-no-min to a style or script node to exempt it |
41 | 41 | // -- HTML 4, XHTML, and HTML 5 compliant |
42 | 42 | |
43 | - class HtmlMin{ |
|
43 | + class HtmlMin { |
|
44 | 44 | // -- Function Name : minify - Params : $html, $js = true, $css = true |
45 | - public static function minify($html, $js = true, $css = true){ |
|
45 | + public static function minify($html, $js = true, $css = true) { |
|
46 | 46 | $doc = new \DOMDocument(); |
47 | 47 | $doc->preserveWhiteSpace = false; |
48 | 48 | @$doc->loadHTML($html); |
49 | 49 | $xpath = new \DOMXPath($doc); |
50 | 50 | foreach ($xpath->query('//comment()') as $comment) { |
51 | - $val= $comment->nodeValue; |
|
52 | - if( strpos($val,'[')!==0){ |
|
51 | + $val = $comment->nodeValue; |
|
52 | + if (strpos($val, '[') !== 0) { |
|
53 | 53 | $comment->parentNode->removeChild($comment); |
54 | 54 | } |
55 | 55 | } |
56 | 56 | $doc->normalizeDocument(); |
57 | 57 | $textnodes = $xpath->query('//text()'); |
58 | - $skip = ["style","pre","code","script","textarea"]; |
|
59 | - foreach($textnodes as $t){ |
|
58 | + $skip = ["style", "pre", "code", "script", "textarea"]; |
|
59 | + foreach ($textnodes as $t) { |
|
60 | 60 | $xp = $t->getNodePath(); |
61 | 61 | $doskip = false; |
62 | - foreach($skip as $pattern){ |
|
63 | - if(strpos($xp,"/$pattern")!==false){ |
|
62 | + foreach ($skip as $pattern) { |
|
63 | + if (strpos($xp, "/$pattern") !== false) { |
|
64 | 64 | $doskip = true; |
65 | 65 | break; |
66 | 66 | } |
67 | 67 | } |
68 | - if($doskip){ |
|
68 | + if ($doskip) { |
|
69 | 69 | continue; |
70 | 70 | } |
71 | 71 | $t->nodeValue = preg_replace("/\s{2,}/", " ", $t->nodeValue); |
72 | 72 | } |
73 | 73 | $doc->normalizeDocument(); |
74 | 74 | $divnodes = $xpath->query('//div|//p|//nav|//footer|//article|//script|//hr|//br'); |
75 | - foreach($divnodes as $d){ |
|
75 | + foreach ($divnodes as $d) { |
|
76 | 76 | $candidates = []; |
77 | - if(count($d->childNodes)){ |
|
77 | + if (count($d->childNodes)) { |
|
78 | 78 | $candidates[] = $d->firstChild; |
79 | 79 | $candidates[] = $d->lastChild; |
80 | 80 | $candidates[] = $d->previousSibling; |
81 | 81 | $candidates[] = $d->nextSibling; |
82 | 82 | } |
83 | - foreach($candidates as $c){ |
|
84 | - if($c==null){ |
|
83 | + foreach ($candidates as $c) { |
|
84 | + if ($c == null) { |
|
85 | 85 | continue; |
86 | 86 | } |
87 | - if($c->nodeType==3){ |
|
87 | + if ($c->nodeType == 3) { |
|
88 | 88 | $c->nodeValue = trim($c->nodeValue); |
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
92 | 92 | $doc->normalizeDocument(); |
93 | - if($js){ |
|
93 | + if ($js) { |
|
94 | 94 | $scriptnodes = $xpath->query('//script'); |
95 | - foreach($scriptnodes as $d){ |
|
96 | - if($d->hasAttribute("type") && strtolower($d->getAttribute("type"))!=='text/javascript' ){ |
|
95 | + foreach ($scriptnodes as $d) { |
|
96 | + if ($d->hasAttribute("type") && strtolower($d->getAttribute("type")) !== 'text/javascript') { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | - if($d->hasAttribute("data-no-min")){ |
|
99 | + if ($d->hasAttribute("data-no-min")) { |
|
100 | 100 | continue; |
101 | 101 | } |
102 | - if(trim($d->nodeValue)==""){ |
|
102 | + if (trim($d->nodeValue) == "") { |
|
103 | 103 | continue; |
104 | 104 | } |
105 | - $d->nodeValue = JSMin::minify( $d->nodeValue); |
|
105 | + $d->nodeValue = JSMin::minify($d->nodeValue); |
|
106 | 106 | } |
107 | 107 | } |
108 | - if($css){ |
|
108 | + if ($css) { |
|
109 | 109 | $cssnodes = $xpath->query('//style'); |
110 | - foreach($cssnodes as $d){ |
|
111 | - if($d->hasAttribute("data-no-min")){ |
|
110 | + foreach ($cssnodes as $d) { |
|
111 | + if ($d->hasAttribute("data-no-min")) { |
|
112 | 112 | continue; |
113 | 113 | } |
114 | - if(trim($d->nodeValue)==""){ |
|
114 | + if (trim($d->nodeValue) == "") { |
|
115 | 115 | continue; |
116 | 116 | } |
117 | - $d->nodeValue = CssMin::minify( $d->nodeValue); |
|
117 | + $d->nodeValue = CssMin::minify($d->nodeValue); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | return ($doc->saveHTML()); |
@@ -19,17 +19,17 @@ |
||
19 | 19 | |
20 | 20 | class Minify{ |
21 | 21 | |
22 | - public static function html($html){ |
|
23 | - return HtmlMin::minify($html); |
|
24 | - } |
|
22 | + public static function html($html){ |
|
23 | + return HtmlMin::minify($html); |
|
24 | + } |
|
25 | 25 | |
26 | - public static function css($css){ |
|
27 | - return CssMin::minify($css); |
|
28 | - } |
|
26 | + public static function css($css){ |
|
27 | + return CssMin::minify($css); |
|
28 | + } |
|
29 | 29 | |
30 | - public static function js($js){ |
|
31 | - return JsMin::minify($js); |
|
32 | - } |
|
30 | + public static function js($js){ |
|
31 | + return JsMin::minify($js); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | } |
35 | 35 |
@@ -17,17 +17,17 @@ |
||
17 | 17 | |
18 | 18 | |
19 | 19 | |
20 | -class Minify{ |
|
20 | +class Minify { |
|
21 | 21 | |
22 | - public static function html($html){ |
|
22 | + public static function html($html) { |
|
23 | 23 | return HtmlMin::minify($html); |
24 | 24 | } |
25 | 25 | |
26 | - public static function css($css){ |
|
26 | + public static function css($css) { |
|
27 | 27 | return CssMin::minify($css); |
28 | 28 | } |
29 | 29 | |
30 | - public static function js($js){ |
|
30 | + public static function js($js) { |
|
31 | 31 | return JsMin::minify($js); |
32 | 32 | } |
33 | 33 |
@@ -30,8 +30,8 @@ |
||
30 | 30 | |
31 | 31 | |
32 | 32 | function print_performance_graph($subject,$minified,$html){ |
33 | - $before = strlen(gzcompress($html)); |
|
34 | - $after = strlen(gzcompress($minified)); |
|
35 | - $improvement = 100 * (1-($after/$before)); |
|
36 | - echo "<table style='width:100%; border:1px solid grey;text-align:center'><tr><th colspan=3><b>$subject</th><tr><th>Gzipped Bytes Before PHPWee</th><th>Gzipped Bytes After PHPWee</th><th>% Performance Boost</th></tr><tr><td>$before before</td><td>$after after</td><td> $improvement % faster </td></table><br><br>"; |
|
33 | + $before = strlen(gzcompress($html)); |
|
34 | + $after = strlen(gzcompress($minified)); |
|
35 | + $improvement = 100 * (1-($after/$before)); |
|
36 | + echo "<table style='width:100%; border:1px solid grey;text-align:center'><tr><th colspan=3><b>$subject</th><tr><th>Gzipped Bytes Before PHPWee</th><th>Gzipped Bytes After PHPWee</th><th>% Performance Boost</th></tr><tr><td>$before before</td><td>$after after</td><td> $improvement % faster </td></table><br><br>"; |
|
37 | 37 | } |
38 | 38 | \ No newline at end of file |
@@ -3,35 +3,35 @@ |
||
3 | 3 | |
4 | 4 | $html = file_get_contents("http://en.wikipedia.org/wiki/Minification_%28programming%29"); |
5 | 5 | $minified = PHPWee\Minify::html($html); |
6 | -echo print_performance_graph("Wikipedia",$minified,$html); |
|
6 | +echo print_performance_graph("Wikipedia", $minified, $html); |
|
7 | 7 | |
8 | 8 | |
9 | 9 | $html = file_get_contents("http://www.codeproject.com/Articles/759094/Step-by-Step-PHP-Tutorials-for-Beginners-Creating"); |
10 | 10 | $minified = PHPWee\Minify::html($html); |
11 | -echo print_performance_graph("The Code Project",$minified,$html); |
|
11 | +echo print_performance_graph("The Code Project", $minified, $html); |
|
12 | 12 | |
13 | 13 | |
14 | 14 | $html = file_get_contents("https://github.com/php/php-src"); |
15 | 15 | $minified = PHPWee\Minify::html($html); |
16 | -print_performance_graph("GiHub",$minified,$html); |
|
16 | +print_performance_graph("GiHub", $minified, $html); |
|
17 | 17 | |
18 | 18 | |
19 | 19 | $html = file_get_contents("http://www.w3schools.com/php/"); |
20 | 20 | $minified = PHPWee\Minify::html($html); |
21 | -print_performance_graph("W3Schools",$minified,$html); |
|
21 | +print_performance_graph("W3Schools", $minified, $html); |
|
22 | 22 | |
23 | 23 | |
24 | 24 | $html = file_get_contents("http://searchturbine.com"); |
25 | 25 | $minified = PHPWee\Minify::html($html); |
26 | -print_performance_graph("SearchTurbine",$minified,$html); |
|
26 | +print_performance_graph("SearchTurbine", $minified, $html); |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /////////////////////////////////////////////////////////////// |
30 | 30 | |
31 | 31 | |
32 | -function print_performance_graph($subject,$minified,$html){ |
|
32 | +function print_performance_graph($subject, $minified, $html) { |
|
33 | 33 | $before = strlen(gzcompress($html)); |
34 | 34 | $after = strlen(gzcompress($minified)); |
35 | - $improvement = 100 * (1-($after/$before)); |
|
35 | + $improvement = 100 * (1 - ($after / $before)); |
|
36 | 36 | echo "<table style='width:100%; border:1px solid grey;text-align:center'><tr><th colspan=3><b>$subject</th><tr><th>Gzipped Bytes Before PHPWee</th><th>Gzipped Bytes After PHPWee</th><th>% Performance Boost</th></tr><tr><td>$before before</td><td>$after after</td><td> $improvement % faster </td></table><br><br>"; |
37 | 37 | } |
38 | 38 | \ No newline at end of file |
@@ -148,7 +148,7 @@ |
||
148 | 148 | |
149 | 149 | $this->_files = $this->_files[$offset]; |
150 | 150 | |
151 | - /* check for common upload errors */ |
|
151 | + /* check for common upload errors */ |
|
152 | 152 | if (isset($this->_files['error'])) { |
153 | 153 | $this->error = $this->commonErrors[$this->_files['error']]; |
154 | 154 | } |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @param mixed $offset |
123 | 123 | */ |
124 | - public function offsetExists($offset){} |
|
124 | + public function offsetExists($offset) {} |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * \ArrayAccess unused method |
128 | 128 | * |
129 | 129 | * @param mixed $offset |
130 | 130 | */ |
131 | - public function offsetUnset($offset){} |
|
131 | + public function offsetUnset($offset) {} |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * \ArrayAccess - get array value from object |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | { |
301 | 301 | if ($isNameProvided) { |
302 | 302 | $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING); |
303 | - }else{ |
|
303 | + } else { |
|
304 | 304 | $this->name = uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q'))); |
305 | 305 | } |
306 | 306 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | $isDirectoryValid = $this->isDirectoryValid($dir); |
379 | 379 | |
380 | 380 | if (!$isDirectoryValid) { |
381 | - $this->error = 'Can not create a directory \''.$dir.'\', please check write permission'; |
|
381 | + $this->error = 'Can not create a directory \'' . $dir . '\', please check write permission'; |
|
382 | 382 | return false; |
383 | 383 | } |
384 | 384 | |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | |
418 | 418 | /* check image size based on the settings */ |
419 | 419 | if ($this->_files['size'] < $minSize || $this->_files['size'] > $maxSize) { |
420 | - $min = $minSize.' bytes ('.intval($minSize / 1000).' kb)'; |
|
421 | - $max = $maxSize.' bytes ('.intval($maxSize / 1000).' kb)'; |
|
422 | - $this->error = 'Image size should be minimum '.$min.', upto maximum '.$max; |
|
420 | + $min = $minSize . ' bytes (' . intval($minSize / 1000) . ' kb)'; |
|
421 | + $max = $maxSize . ' bytes (' . intval($maxSize / 1000) . ' kb)'; |
|
422 | + $this->error = 'Image size should be minimum ' . $min . ', upto maximum ' . $max; |
|
423 | 423 | return false; |
424 | 424 | } |
425 | 425 |
@@ -300,7 +300,7 @@ |
||
300 | 300 | { |
301 | 301 | if ($isNameProvided) { |
302 | 302 | $this->name = filter_var($isNameProvided, FILTER_SANITIZE_STRING); |
303 | - }else{ |
|
303 | + } else{ |
|
304 | 304 | $this->name = uniqid('', true) . '_' . str_shuffle(implode(range('e', 'q'))); |
305 | 305 | } |
306 | 306 |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | if ($thumbnail_aspect_ratio < $source_aspect_ratio) { |
66 | 66 | $src_h = $imgHeight; |
67 | 67 | $src_w = $imgHeight * $thumbnail_aspect_ratio; |
68 | - $src_x = (int) (($imgWidth - $src_w)/2); |
|
68 | + $src_x = (int) (($imgWidth - $src_w) / 2); |
|
69 | 69 | $src_y = 0; |
70 | 70 | } else { |
71 | 71 | $src_w = $imgWidth; |
72 | 72 | $src_h = (int) ($imgWidth / $thumbnail_aspect_ratio); |
73 | 73 | $src_x = 0; |
74 | - $src_y = (int) (($imgHeight - $src_h)/2); |
|
74 | + $src_y = (int) (($imgHeight - $src_h) / 2); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Checks whether image upsizing is enabled |
@@ -86,26 +86,26 @@ discard block |
||
86 | 86 | if ($newHeight > $newHeightOrig) { |
87 | 87 | $newHeight = $newHeightOrig; |
88 | 88 | $src_h = $newHeight; |
89 | - $src_y = (int) (($imgHeight - $src_h)/2); |
|
89 | + $src_y = (int) (($imgHeight - $src_h) / 2); |
|
90 | 90 | } |
91 | 91 | |
92 | - $src_x=0; |
|
92 | + $src_x = 0; |
|
93 | 93 | $src_w = $imgWidth; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // If the given height is larger then the image height, then resize it. |
97 | 97 | if ($newHeightOrig > $imgHeight) { |
98 | 98 | $newHeight = $imgHeight; |
99 | - $src_y=0; |
|
99 | + $src_y = 0; |
|
100 | 100 | $src_h = $imgHeight; |
101 | - $src_w = (int) ($src_h * ( $newWidth / $newHeight )); |
|
102 | - $src_x = (int) (($imgWidth - $src_w)/2); |
|
101 | + $src_w = (int) ($src_h * ($newWidth / $newHeight)); |
|
102 | + $src_x = (int) (($imgWidth - $src_w) / 2); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } else { |
106 | 106 | |
107 | 107 | // First, calculate the height. |
108 | - $height = (int) ($newWidth / $imgWidth * $imgHeight); // 75 |
|
108 | + $height = (int) ($newWidth / $imgWidth * $imgHeight); // 75 |
|
109 | 109 | |
110 | 110 | // If the height is too large, set it to the maximum height and calculate the width. |
111 | 111 | if ($height > $newHeight) { |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | ); |
170 | 170 | |
171 | 171 | if ($destination !== false) { // checks if was destination provided |
172 | - if(substr( $destination, -1 ) == '/' ) { // check whether prowided destination was folder or file. |
|
172 | + if (substr($destination, -1) == '/') { // check whether prowided destination was folder or file. |
|
173 | 173 | $create = !is_dir($destination) ? @mkdir($destination, $permission, true) : true; // if it was folder, it will crtete it if needed |
174 | 174 | if ($create) { |
175 | 175 | $path_parts = pathinfo($image); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | $path_parts = pathinfo($destination); |
187 | - $create = !is_dir($path_parts['dirname'].'/') ? @mkdir($path_parts['dirname'].'/', $permission, true) : true; |
|
187 | + $create = !is_dir($path_parts['dirname'] . '/') ? @mkdir($path_parts['dirname'] . '/', $permission, true) : true; |
|
188 | 188 | if (!$create) { |
189 | 189 | return false; // TODO: throw error/exception |
190 | 190 | } |
@@ -193,35 +193,35 @@ discard block |
||
193 | 193 | case "jpeg": |
194 | 194 | case "jpg": |
195 | 195 | $q = 90; // function's default value - if everything else fails, this is used. |
196 | - if( false !== $image ) { |
|
197 | - if ((!empty($quality['jpg']['fallback'])) AND ( (int) $quality['jpg']['fallback'] ) AND ( $quality['jpg']['fallback'] > 0 ) AND ( $quality['jpg']['fallback'] <=100 ) ) { |
|
196 | + if (false !== $image) { |
|
197 | + if ((!empty($quality['jpg']['fallback'])) AND ((int) $quality['jpg']['fallback']) AND ($quality['jpg']['fallback'] > 0) AND ($quality['jpg']['fallback'] <= 100)) { |
|
198 | 198 | $q = $quality['jpg']['fallback']; |
199 | 199 | } |
200 | 200 | |
201 | - if ((!empty($quality['jpg']['orig'])) AND true ===$quality['jpg']['orig'] ){ |
|
202 | - if (extension_loaded('imagick')){ |
|
201 | + if ((!empty($quality['jpg']['orig'])) AND true === $quality['jpg']['orig']) { |
|
202 | + if (extension_loaded('imagick')) { |
|
203 | 203 | $im = new \Imagick($image); |
204 | 204 | $q = $im->getImageCompressionQuality(); |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | - if((!empty($quality['jpg']['max'])) AND $quality['jpg']['max'] < $q ){ |
|
208 | + if ((!empty($quality['jpg']['max'])) AND $quality['jpg']['max'] < $q) { |
|
209 | 209 | $q = $quality['jpg']['max']; |
210 | 210 | } |
211 | 211 | |
212 | - if((!empty($quality['jpg']['min'])) AND $quality['jpg']['min'] > $q ){ |
|
212 | + if ((!empty($quality['jpg']['min'])) AND $quality['jpg']['min'] > $q) { |
|
213 | 213 | $q = $quality['jpg']['min']; |
214 | 214 | } |
215 | 215 | } |
216 | - return imagejpeg($tmp, $destination, $q ); |
|
216 | + return imagejpeg($tmp, $destination, $q); |
|
217 | 217 | break; |
218 | 218 | case "png": |
219 | - if ((!empty($quality['png'])) AND ( (int) $quality['png'] ) AND ( $quality['png'] >= -1 ) AND ( $quality['png'] <=9 ) ) { |
|
219 | + if ((!empty($quality['png'])) AND ((int) $quality['png']) AND ($quality['png'] >= -1) AND ($quality['png'] <= 9)) { |
|
220 | 220 | $q = $quality['png']; |
221 | 221 | } else { |
222 | 222 | $q = -1; // -1 is zlib's default value which is currently ( 11/2018 ) equal to 6 |
223 | 223 | } |
224 | - return imagepng($tmp, $destination, $q ); |
|
224 | + return imagepng($tmp, $destination, $q); |
|
225 | 225 | break; |
226 | 226 | case "gif": |
227 | 227 | return imagegif($tmp, $destination); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | // check full path of image uploaded |
83 | 83 | |
84 | - public function testFullpath(){ |
|
84 | + public function testFullpath(){ |
|
85 | 85 | $this->bulletproof->setLocation('uploads'); |
86 | 86 | $this->bulletproof->setName('2012'); |
87 | 87 | $this->bulletproof->setMime(['jpeg']); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | |
94 | 94 | // check json return value of image |
95 | - public function testJsonOutput(){ |
|
95 | + public function testJsonOutput(){ |
|
96 | 96 | $upload = $this->bulletproof->setName('we_belive_in_json')->upload(); |
97 | 97 | $this->assertSame($upload->getJson(), |
98 | 98 | '{"name":"we_belive_in_json","mime":"jpeg","height":345,"width":384,"size":17438,"storage":"uploads","path":"uploads\/we_belive_in_json.jpeg"}'); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function testImageSizeFailWithMsg () { |
120 | 120 | $this->bulletproof->setSize(888, 9999); |
121 | 121 | $upload = $this->bulletproof->upload(); |
122 | - $this->assertEquals($this->bulletproof->getError(), 'Image size should be minumum 888 bytes (0 kb), upto maximum 9999 bytes (9 kb)'); |
|
122 | + $this->assertEquals($this->bulletproof->getError(), 'Image size should be minumum 888 bytes (0 kb), upto maximum 9999 bytes (9 kb)'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | // check invalid dimension fails with msg |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | // check if the name provide in the html input is read by bulletproof |
31 | - public function testImageNameIsSame () { |
|
31 | + public function testImageNameIsSame() { |
|
32 | 32 | $this->bulletproof->setName('samayo'); |
33 | 33 | $this->assertEquals($this->bulletproof->getName(), 'samayo'); |
34 | 34 | } |
35 | 35 | |
36 | 36 | |
37 | 37 | // test image accepts certain mime types |
38 | - public function testMimeTypes () { |
|
38 | + public function testMimeTypes() { |
|
39 | 39 | $this->bulletproof->setMime(['jpeg']); |
40 | 40 | $upload = $this->bulletproof->upload(); |
41 | 41 | $this->assertEquals($upload->getMime(), 'jpeg'); |
42 | 42 | } |
43 | 43 | |
44 | 44 | // check dimensions params |
45 | - public function testDimensions () { |
|
45 | + public function testDimensions() { |
|
46 | 46 | // give it out of range (minimum dimentions than the class requires) |
47 | 47 | $this->bulletproof->setDimension(1, 'b'); |
48 | 48 | $upload = $this->bulletproof->upload(); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | |
53 | 53 | // check size of the image is correct |
54 | - public function testSize () { |
|
54 | + public function testSize() { |
|
55 | 55 | $this->bulletproof->upload(); |
56 | 56 | $this->assertEquals($this->bulletproof->getSize(), 17438); // 17438 is size of the monkey.jpg |
57 | 57 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | // check if setting image storage is correct |
76 | - public function testLocation () { |
|
76 | + public function testLocation() { |
|
77 | 77 | $this->bulletproof->setLocation('uploads'); |
78 | 78 | $this->assertEquals($this->bulletproof->getStorage(), 'uploads'); |
79 | 79 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | // check full path of image uploaded |
83 | 83 | |
84 | - public function testFullpath(){ |
|
84 | + public function testFullpath() { |
|
85 | 85 | $this->bulletproof->setLocation('uploads'); |
86 | 86 | $this->bulletproof->setName('2012'); |
87 | 87 | $this->bulletproof->setMime(['jpeg']); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | |
94 | 94 | // check json return value of image |
95 | - public function testJsonOutput(){ |
|
95 | + public function testJsonOutput() { |
|
96 | 96 | $upload = $this->bulletproof->setName('we_belive_in_json')->upload(); |
97 | 97 | $this->assertSame($upload->getJson(), |
98 | 98 | '{"name":"we_belive_in_json","mime":"jpeg","height":345,"width":384,"size":17438,"storage":"uploads","path":"uploads\/we_belive_in_json.jpeg"}'); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | // check invalid mimetype fails |
103 | 103 | |
104 | - public function testMimeTypeFail () { |
|
104 | + public function testMimeTypeFail() { |
|
105 | 105 | $this->bulletproof->setMime(['gif']); |
106 | 106 | $upload = $this->bulletproof->upload(); |
107 | 107 | $this->assertFalse($upload); |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | |
110 | 110 | // check invalid mimetype fails with msg |
111 | 111 | |
112 | - public function testMimeTypeFailWithMsg () { |
|
112 | + public function testMimeTypeFailWithMsg() { |
|
113 | 113 | $this->bulletproof->setMime(['gif']); |
114 | 114 | $upload = $this->bulletproof->upload(); |
115 | 115 | $this->assertEquals($this->bulletproof->getError(), 'Invalid File! Only (gif) image types are allowed'); |
116 | 116 | } |
117 | 117 | |
118 | 118 | // check invalid size with msg |
119 | - public function testImageSizeFailWithMsg () { |
|
119 | + public function testImageSizeFailWithMsg() { |
|
120 | 120 | $this->bulletproof->setSize(888, 9999); |
121 | 121 | $upload = $this->bulletproof->upload(); |
122 | 122 | $this->assertEquals($this->bulletproof->getError(), 'Image size should be minumum 888 bytes (0 kb), upto maximum 9999 bytes (9 kb)'); |
123 | 123 | } |
124 | 124 | |
125 | 125 | // check invalid dimension fails with msg |
126 | -public function testImageDimensionFailWithMsg () { |
|
126 | +public function testImageDimensionFailWithMsg() { |
|
127 | 127 | $this->bulletproof->setDimension(42, 43); |
128 | 128 | $this->bulletproof->upload(); |
129 | 129 | $this->assertEquals($this->bulletproof->getError(), 'Image height/width should be less than 43/42 pixels'); |