PluginProbe
MaxButtons – Create buttons / 6.28
MaxButtons – Create buttons v6.28
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
← All changes | classes/maxCSSParser.php +269 -266 6.256.28 View file →
@@ -1,14 +1,14 @@
1 1 <?php
2 2 namespace MaxButtons;
3 3 defined('ABSPATH') or die('No direct access permitted');
4 4 /* Class to Parse CSS. Load as array with diffent pseudo-types,
5 - ability to add nested and new root blocks
5 + ability to add nested and new root blocks
6 6 parses via scss
7 7 ability to use complicated css stuff via scss mixins parsing like gradient
8 - auto-discovery for -unit field types to set units (like px, or %)
8 + auto-discovery for -unit field types to set units (like px, or %)
9 9 auto-discovery of fields via domobj.
10 -
10 +
11 11 */
12 12
13 13 use \Exception as Exception;
14 14
@@ -13,261 +13,262 @@
13 13 use \Exception as Exception;
14 14
15 15 class maxCSSParser
16 16 {
17 - protected $struct = array();
17 + protected $struct = array();
18 18 protected $domObj = '';
19 - protected $pseudo = array("hover","active","responsive");
20 -
21 - protected $data;
19 + protected $pseudo = array("hover","active","responsive");
20 +
21 + protected $data;
22 22 protected $output_css;
23 -
23 +
24 24 protected $inline = array();
25 25 protected $responsive = array();
26 -
27 - public $anchor_class = '.maxbutton'; // used for matching buttons in parse_part
28 -
26 +
27 + public $anchor_class = '.maxbutton'; // used for matching buttons in parse_part
28 +
29 29 // settings
30 30 protected $elements_ignore_zero = array(
31 31 'text-shadow-left',
32 - 'text_shadow-top',
32 + 'text_shadow-top',
33 33 'text-shadow-width',
34 34 'box-shadow-offset-left',
35 - 'box-shadow-offset-top',
35 + 'box-shadow-offset-top',
36 36 'box-shadow-width',
37 - 'box-shadow-spread',
38 - ); // items to ignore if value is zero, otherwise they become unremovable ( where 0 is still something on display)
39 -
37 + 'box-shadow-spread',
38 + ); // items to ignore if value is zero, otherwise they become unremovable ( where 0 is still something on display)
39 +
40 40 protected $important = false;
41 -
41 +
42 42 // log possible problems and incidents for debugging;
43 43 protected $parse_log = array();
44 -
44 +
45 45 function __construct()
46 46 {
47 - //$root[] = array("a" => array("hover","active","responsive"));
47 + //$root[] = array("a" => array("hover","active","responsive"));
48 48
49 49 }
50 -
50 +
51 51 function loadDom($domObj)
52 - {
52 + {
53 53 $this->domObj = $domObj;
54 54
55 55 $root = $domObj->find(0,0);
56 - $struct[$root->tag] = array();
57 -
56 + $struct[$root->tag] = array();
57 +
58 58 $children = $root->children();
59 -
60 - if (count($children) > 0)
59 +
60 + if (count($children) > 0)
61 61 $struct[$root->tag] = $this->loadRecursive(array(), $children);
62 -
63 62
63 +
64 64 $this->struct = $struct;
65 65
66 66
67 67 }
68 -
68 +
69 69 function loadRecursive($struct, $children)
70 70 {
71 71 foreach($children as $domChild)
72 72 {
73 73
74 - $class = $domChild->class;
75 - $class = str_replace(" ",".", $class); // combine seperate classes
76 -
77 - $struct[$class]["tag"] = $domChild->tag;
78 -
79 - $child_children = $domChild->children();
74 + $class = $domChild->class;
75 + $class = str_replace(" ",".", $class); // combine seperate classes
76 + $struct[$class]["tag"] = $domChild->tag;
80 77
81 - if (count($child_children) > 0)
78 + $child_children = $domChild->children();
79 +
80 + if (count($child_children) > 0)
82 81 {
83 -
82 +
84 83 $struct[$class]["children"] = $this->loadRecursive(array(), $child_children);
85 84 }
86 85 }
87 -
86 +
88 87 return $struct;
89 88 }
90 -
91 -
89 +
90 +
92 91 function parse($data)
93 - {
94 - $this->clear();
95 -
96 - $struct = $this->struct;
92 + {
93 + $this->clear();
97 94
98 - $this->data = $data;
95 + $struct = $this->struct;
99 96
100 -
97 + $this->data = $data;
98 +
99 +
101 100 if (isset($data["settings"])) // room for settings in parser
102 101 {
103 102 $settings = $data["settings"];
104 - $this->important = (isset($settings["important"])) ? $settings["important"] : false;
105 -
106 - unset($this->data["settings"]);
103 + $this->important = (isset($settings["important"])) ? $settings["important"] : false;
104 +
105 + unset($this->data["settings"]);
107 106 }
108 107
109 - $elements = array_shift($struct); // first element is a 'stub' root.
108 + $elements = array_shift($struct); // first element is a 'stub' root.
110 109
111 110 if ( is_null($elements) )
112 - return;
111 + return;
113 112
114 113
115 114 foreach($elements as $el => $el_data)
116 115 {
117 116
118 - $this->parse_part($el,$el_data);
117 + $this->parse_part($el,$el_data);
119 118 }
120 119
121 120
122 121 $this->parse_responsive();
123 -
122 +
124 123 maxUtils::startTime('compile CSS');
125 124 $css = $this->compile($this->output_css);
125 +
126 126 maxUtils::endTime('compile CSS');
127 127
128 128
129 129 return $css;
130 -
130 +
131 131 }
132 -
133 - // reset output values.
134 - protected function clear()
132 +
133 + // reset output values.
134 + protected function clear()
135 135 {
136 - $this->data = '';
137 - $this->output_css = '';
136 + $this->data = '';
137 + $this->output_css = '';
138 138 $this->inline = array();
139 139 //$this->struct = array();
140 140 $this->responsive = array();
141 -
141 +
142 142 }
143 -
143 +
144 144 protected function compile($css)
145 145 {
146 146 $scss = new \Leafo\ScssPhp\Compiler();
147 147 $scss->setImportPaths(MB()->get_plugin_path() . "assets/scss");
148 -
149 - $minify = get_option("maxbuttons_minify", 1);
148 +
149 + $minify = get_option("maxbuttons_minify", 1);
150 150 if ($minify == 1)
151 151 $scss->setFormatter('\Leafo\ScssPhp\Formatter\Compressed');
152 -
152 +
153 153 $compile = " @import '_mixins.scss'; " . $css;
154 154 //maxUtils::addTime("CSSParser: Compile start ");
155 -
155 +
156 156 try
157 157 {
158 158 $css = $scss->compile($compile);
159 - } catch (Exception $e) {
160 -
161 - $css = $this->output_css;
162 - }
159 + } catch (Exception $e) {
163 160
161 + $css = $this->output_css;
162 + }
163 +
164 164 //maxUtils::addTime("CSSParser: Compile end ");
165 165
166 166 return $css;
167 167 }
168 -
168 +
169 169 function parse_part($element, $el_data, $el_add = '')
170 170 {
171 171 maxUtils::addTime("CSSParser: Parse $element ");
172 -
173 -
174 - $tag = $el_data["tag"];
172 +
173 +
174 + $tag = $el_data["tag"];
175 175 $element_data = $this->findData($this->data, $element);
176 -
177 - // not using scss selectors here since there is trouble w/ the :pseudo selector, which should be put on the maxbutton / a tag.
176 +
177 + // not using scss selectors here since there is trouble w/ the :pseudo selector, which should be put on the maxbutton / a tag.
178 178 if ($element != '')
179 179 { $el_add .= " ." . $element;
180 -
180 +
181 181 }
182 -
183 - if (isset($element_data["responsive"]))
182 +
183 + if (isset($element_data["responsive"]))
184 184 {
185 185 $responsive = $element_data["responsive"]; // doing that at the end
186 - unset($element_data["responsive"]);
186 + unset($element_data["responsive"]);
187 187
188 188 $this->responsive[$el_add] = $responsive;
189 189 }
190 -
190 +
191 191 foreach($element_data as $pseudo => $values)
192 192 {
193 -
194 - if ($pseudo != 'normal')
193 +
194 + if ($pseudo != 'normal')
195 195 {
196 - // select the maxbutton case, ending with either space or next class -dot.
196 + // select the maxbutton case, ending with either space or next class -dot.
197 197 // Anchor class in default situation should be .maxbutton
198 - $anchor_class = $this->anchor_class;
199 -
200 - $count = 0;
201 -
198 + $anchor_class = $this->anchor_class;
199 +
200 + $count = 0;
201 +
202 202 /* If PS Selector replacement doesn't match anchor class selector this probably means the parse is done in a higher level
203 - e.g. container level, so no proper will be set. In case 0 count replacement, just put it on current */
203 + e.g. container level, so no proper will be set. In case 0 count replacement, just put it on current */
204 204 $ps_selector = preg_replace('/' . $anchor_class . '$|' . $anchor_class . '([.| ])/i',"$anchor_class:$pseudo\$1",$el_add, -1, $count);
205 205
206 +
206 207 if ($count === 0)
207 208 {
208 - $ps_selector = $el_add . ":" . $pseudo;
209 + $ps_selector = $el_add . ":" . $pseudo;
209 210 }
210 -
211 -
212 - $this->output_css .= " $ps_selector { ";
211 +
212 +
213 + $this->output_css .= " $ps_selector { ";
213 214 }
214 215 else {
215 216 $this->output_css .= " $el_add { ";
216 217 }
217 -
218 +
218 219 $values = $this->doMixins($values);
219 220
220 221 foreach($values as $cssTag => $cssVal)
221 222 {
222 -
223 +
223 224 $statement = $this->parse_cssline($values, $cssTag,$cssVal); ///"$cssTag $css_sep $cssVal$unit$css_end ";
224 225
225 226 if ($statement)
226 227 {
227 228 $this->output_css .= $statement ;
228 -
229 +
229 230 if (! isset($this->inline[$pseudo][$element])) $this->inline[$pseudo][$element] = '';
230 231 $this->inline[$pseudo][$element] .= $statement;
231 - }
232 + }
232 233 }
233 234
234 - $this->output_css .= " } ";
235 + $this->output_css .= " } ";
235 236 }
236 - if (isset($el_data["children"]))
237 + if (isset($el_data["children"]))
237 238 {
238 239 foreach($el_data["children"] as $child_id => $child_data)
239 240 {
240 -
241 +
241 242 $this->parse_part($child_id, $child_data, $el_add);
242 243 }
243 244 }
244 245
245 246 }
246 -
247 +
247 248 function parse_cssline($values, $cssTag, $cssVal, $css_end = ';')
248 249 {
249 250
250 251 // unit check - two ways; either unitable items is first or unit declaration.
251 - if (isset($values[$cssTag . "_unit"]))
252 + if (isset($values[$cssTag . "_unit"]))
252 253 {
253 - $unit = $values[$cssTag . "_unit"];
254 + $unit = $values[$cssTag . "_unit"];
254 255 }
255 256 elseif(strpos($cssTag, "_unit") !== false)
256 257 {
257 - return false; // no print, should be found under first def.
258 + return false; // no print, should be found under first def.
258 259 }
259 260 else $unit = '';
260 -
261 261
262 - $important = ($this->is_important()) ? " !important" : "";
263 - $important = ($cssTag == '@include') ? "" : $important; // mixin's problem, no checking here.
264 -
262 +
263 + $important = ($this->is_important()) ? " !important" : "";
264 + $important = ($cssTag == '@include') ? "" : $important; // mixin's problem, no checking here.
265 +
265 266 $css_sep = ($cssTag == '@include') ? $css_sep = '' : ':';
266 -
267 +
267 268 if ($cssVal == 0 && in_array($cssTag, $this->elements_ignore_zero))
268 - return false;
269 -
269 + return false;
270 +
270 271 if($cssVal !== '' && $cssTag !== '')
271 272 {
272 273 $statement = "$cssTag $css_sep $cssVal$unit$important$css_end ";
273 274 return $statement;
@@ -272,119 +273,119 @@
272 273 $statement = "$cssTag $css_sep $cssVal$unit$important$css_end ";
273 274 return $statement;
274 275 }
275 276 return false;
276 -
277 +
277 278 }
278 -
279 +
279 280 function parse_responsive()
280 281 {
281 282
282 - $responsive = $this->responsive;
283 - if (! is_array($responsive) || count($responsive) == 0)
284 - return;
283 + $responsive = $this->responsive;
284 + if (! is_array($responsive) || count($responsive) == 0)
285 + return;
285 286
286 287 $media_queries = maxUtils::get_media_query(2); // query names
287 -
288 - $output = '';
289 -
290 - $query_array = array();
291 288
289 + $output = '';
292 290
291 + $query_array = array();
292 +
293 +
293 294 foreach($responsive as $element => $queries)
294 295 {
295 296 foreach($queries as $query => $qdata)
296 297 foreach($qdata as $index => $data)
297 298 {{
298 - $query_array[$query][$index][$element] = $data;
299 -
299 + $query_array[$query][$index][$element] = $data;
300 +
300 301 }}
301 302 }
302 -
303 303
304 -
304 +
305 +
305 306 foreach($query_array as $query => $vdata):
306 307
307 - if ($query == 'custom')
308 + if ($query == 'custom')
308 309 {
309 310
310 - // first discover the custom size properties.
311 + // first discover the custom size properties.
311 312 foreach($vdata as $index => $data):
312 313 foreach($data as $element => $values):
313 314
314 - if (isset($values["custom_maxwidth"]) || isset($values["custom_minwidth"]) )
315 + if (isset($values["custom_maxwidth"]) || isset($values["custom_minwidth"]) )
315 316 {
316 -
317 +
317 318 $minwidth = (isset($values["custom_minwidth"])) ? intval($values["custom_minwidth"]) : -1;
318 - $maxwidth = (isset($values["custom_maxwidth"])) ? intval($values["custom_maxwidth"]) : -1;
319 -
320 -
321 - unset($vdata[$index][$element]["custom_minwidth"]);
319 + $maxwidth = (isset($values["custom_maxwidth"])) ? intval($values["custom_maxwidth"]) : -1;
320 +
321 +
322 + unset($vdata[$index][$element]["custom_minwidth"]);
322 323 unset($vdata[$index][$element]["custom_maxwidth"]);
323 -
324 -
325 - // make it always an integer
326 - if ($minwidth == '') $minwidth = 0;
327 - if ($maxwidth == '') $maxwidth = 0;
328 -
329 - // if minwidth is not set and maxwidth zero or not set - ignore since it would result in an empty media line.
330 - //if ($minwidth <= 0 && $maxwidth <= 0)
324 +
325 +
326 + // make it always an integer
327 + if ($minwidth == '') $minwidth = 0;
328 + if ($maxwidth == '') $maxwidth = 0;
329 +
330 + // if minwidth is not set and maxwidth zero or not set - ignore since it would result in an empty media line.
331 + //if ($minwidth <= 0 && $maxwidth <= 0)
331 332 //{
332 333 //continue;
333 334 //}
334 -
335 - if ($minwidth > 0 && $maxwidth > 0)
336 - $qdef = "only screen and (min-width: $minwidth" . "px) and (max-width: $maxwidth" . "px)";
337 - if ($minwidth >= 0 && $maxwidth <= 0)
338 - $qdef = "only screen and (min-width: $minwidth" . "px) ";
339 - if ($minwidth <= 0 && $maxwidth > 0)
340 - $qdef = "only screen and (max-width: $maxwidth" . "px) ";
341 -
335 +
336 + if ($minwidth > 0 && $maxwidth > 0)
337 + $qdef = "only screen and (min-width: $minwidth" . "px) and (max-width: $maxwidth" . "px)";
338 + if ($minwidth >= 0 && $maxwidth <= 0)
339 + $qdef = "only screen and (min-width: $minwidth" . "px) ";
340 + if ($minwidth <= 0 && $maxwidth > 0)
341 + $qdef = "only screen and (max-width: $maxwidth" . "px) ";
342 +
342 343 //break;
343 344
344 - }
345 - endforeach; //foreach data
346 -
347 - // The problem is that every 'custom' query needs to run with a different qdef unlike other queries.
348 -
345 + }
346 + endforeach; //foreach data
347 +
348 + // The problem is that every 'custom' query needs to run with a different qdef unlike other queries.
349 +
349 350 $qdata = array($vdata[$index]);
350 -
351 - $output = $this->parse_responsive_definition($output, $qdef, $qdata);
352 - endforeach; // foreach vdata
351 +
352 + $output = $this->parse_responsive_definition($output, $qdef, $qdata);
353 + endforeach; // foreach vdata
353 354 }
354 355 else
355 356 {
356 -
357 - $qdef = $media_queries[$query];
357 +
358 + $qdef = $media_queries[$query];
358 359 $output = $this->parse_responsive_definition($output, $qdef, $vdata);
359 360 }
360 361
361 362 endforeach;
362 -
363 -
363 +
364 +
364 365 $this->output_css .= $output;
365 366 }
366 -
367 +
367 368 protected function parse_responsive_definition($output, $qdef, $vdata)
368 369 {
369 -
370 +
370 371 if (! isset($qdef) || $qdef == '') {
371 -
372 - return; // no definition.
372 +
373 + return; // no definition.
373 374 }
374 375
375 -
376 - $output .= "@media ". $qdef . " { ";
377 376
378 -
377 + $output .= "@media ". $qdef . " { ";
378 +
379 +
379 380 foreach($vdata as $index => $data)
380 381 {
381 -
382 +
382 383 foreach($data as $element => $values) {
383 384 //foreach($vdat as $index => $values):
384 - $output .= $element . " { ";
385 + $output .= $element . " { ";
385 386 $css_end = ';';
386 -
387 +
387 388 // same as parse part, maybe merge in future
388 389 foreach($values as $cssTag => $cssVal)
389 390 {
390 391 // unit check - two ways; either unitable items is first or unit declaration.
@@ -390,60 +391,62 @@
390 391 // unit check - two ways; either unitable items is first or unit declaration.
391 392 $statement = $this->parse_cssline($values, $cssTag,$cssVal);
392 393 if($statement)
393 394 $output .= $statement;
394 -
395 +
395 396 }
396 397
397 - $output .= " } ";
398 + $output .= " } ";
398 399 // endforeach;
399 400 }
400 401
401 -
402 +
402 403 }
403 - $output .= " } ";
404 -
405 - //endforeach;
406 -
404 + $output .= " } ";
405 +
406 + //endforeach;
407 +
407 408 return $output;
408 409 }
409 -
410 +
410 411 private function is_important()
411 412 {
412 413
413 414 if ($this->important == 1)
414 415 return true;
415 - else
416 + else
416 417 return false;
417 418 }
418 -
419 +
419 420 function findData($data, $el)
420 421 {
421 - $classes = explode(".", $el);
422 + $classes = explode(".", $el);
422 423
423 - foreach($data as $part => $values)
424 + foreach($data as $part => $values)
424 425 {
425 426 if (in_array($part, $classes))
427 + {
426 428 return $data[$part];
429 + }
427 430 }
428 431 return array();
429 432 }
430 -
433 +
431 434 function doMixins($values)
432 435 {
433 436 $mixins = array("gradient", "box-shadow", "text-shadow");
434 -
435 - foreach($mixins as $mixin)
437 +
438 + foreach($mixins as $mixin)
436 439 {
437 440
438 441 $results = preg_grep("/^$mixin/i",array_keys($values) );
439 - if (count($results) === 0)
440 - continue; // no mixins.
441 -
442 + if (count($results) === 0)
443 + continue; // no mixins.
444 +
442 445 $mixin_array = array();
443 446 foreach($results as $result)
444 447 {
445 - $mixin_array[$result] = $values[$result];
448 + $mixin_array[$result] = $values[$result];
446 449 }
447 450
448 451 if (count($mixin_array) > 0)
449 452 {
@@ -448,156 +451,156 @@
448 451 if (count($mixin_array) > 0)
449 452 {
450 453 switch($mixin)
451 454 {
452 - case "gradient":
455 + case "gradient":
453 456 $values = $this->mixin_gradient($mixin_array, $values);
454 -
457 +
455 458 break;
456 - case "box-shadow":
459 + case "box-shadow":
457 460 $values = $this->mixin_boxshadow($mixin_array, $values);
458 - break;
459 - case "text-shadow":
461 + break;
462 + case "text-shadow":
460 463 $values = $this->mixin_textshadow($mixin_array, $values);
461 464 break;
462 465 }
463 466 }
464 467
465 -
466 - }
468 +
469 + }
467 470 return $values;
468 471 }
469 -
472 +
470 473 function mixin_gradient($results, $values)
471 474 {
472 475
473 476 $start = isset($results["gradient-start-color"]) ? $results["gradient-start-color"] : '';
474 - $end = isset( $results["gradient-end-color"] ) ? $results["gradient-end-color"] : '';
475 - $start_opacity = isset( $results["gradient-start-opacity"] ) ? $results["gradient-start-opacity"] : '';
476 - $end_opacity = isset( $results["gradient-end-opacity"] ) ? $results["gradient-end-opacity"] : '';
477 - $stop = (isset( $results["gradient-stop"]) && $results["gradient-stop"] != '') ? $results["gradient-stop"] . "%" : '45%';
477 + $end = isset( $results["gradient-end-color"] ) ? $results["gradient-end-color"] : '';
478 + $start_opacity = isset( $results["gradient-start-opacity"] ) ? $results["gradient-start-opacity"] : '';
479 + $end_opacity = isset( $results["gradient-end-opacity"] ) ? $results["gradient-end-opacity"] : '';
480 + $stop = (isset( $results["gradient-stop"]) && $results["gradient-stop"] != '') ? $results["gradient-stop"] . "%" : '45%';
478 481 // default to use ( old situation )
479 482 $use_gradient = (isset($results['gradient-use-gradient']) && $results['gradient-use-gradient'] != '') ? $results['gradient-use-gradient'] : 1;
480 -
483 +
481 484 $start = maxUtils::hex2rgba($start, $start_opacity);
482 - $end = maxUtils::hex2rgba($end, $end_opacity);
483 -
485 + $end = maxUtils::hex2rgba($end, $end_opacity);
486 +
484 487 $important = ($this->is_important()) ? "!important" : "";
485 - //$values = $this->add_include($values, "linear-gradient($start,$end,$stop,$important)");
488 + //$values = $this->add_include($values, "linear-gradient($start,$end,$stop,$important)");
486 489
487 490 if ($use_gradient == 1)
488 491 {
489 - $values = $this->add_include($values, "linear-gradient($start,$end,$stop,$important)");
492 + $values = $this->add_include($values, "linear-gradient($start,$end,$stop,$important)");
490 493 }
491 494 else {
492 - $values['background-color'] = $start;
495 + $values['background-color'] = $start;
493 496 }
494 497
495 - // remove the non-css keys from the value array ( field names )
498 + // remove the non-css keys from the value array ( field names )
496 499 $values = array_diff_key($values, $results);
497 500
498 501 return $values;
499 -
502 +
500 503 }
501 -
504 +
502 505 function mixin_boxshadow($results, $values)
503 506 {
504 - $width = $results["box-shadow-width"];
505 - $left = $results["box-shadow-offset-left"];
506 - $top = $results["box-shadow-offset-top"];
507 - $spread = isset($results['box-shadow-spread']) ? $results['box-shadow-spread'] : 0;
508 - $color = isset($results["box-shadow-color"]) ? $results["box-shadow-color"] : '';
509 -
510 - $important = ($this->is_important()) ? "!important" : "";
511 -
512 - if ($width == 0 && $left == 0 && $top == 0)
513 - return $values;
514 -
515 - $values = $this->add_include($values, "box-shadow($left, $top, $width, $color,$spread, false, $important) ");
507 + $width = isset($results["box-shadow-width"]) ? $results["box-shadow-width"] : 0;
508 + $left = isset($results["box-shadow-offset-left"]) ? $results["box-shadow-offset-left"] : 0;
509 + $top = isset($results["box-shadow-offset-top"]) ? $results["box-shadow-offset-top"] : 0;
510 + $spread = isset($results['box-shadow-spread']) ? $results['box-shadow-spread'] : 0;
511 + $color = isset($results["box-shadow-color"]) ? $results["box-shadow-color"] : '';
512 +
513 + $important = ($this->is_important()) ? "!important" : "";
514 +
515 + if ($width == 0 && $left == 0 && $top == 0)
516 + return $values;
517 +
518 + $values = $this->add_include($values, "box-shadow($left, $top, $width, $color,$spread, false, $important) ");
516 519 $values = array_diff_key($values, $results);
517 520
518 - return $values;
521 + return $values;
519 522 }
520 -
523 +
521 524 function mixin_textshadow($results, $values)
522 525 {
523 - $width = isset($results["text-shadow-width"]) ? $results["text-shadow-width"] : 0;
524 - $left = isset($results["text-shadow-left"]) ? $results["text-shadow-left"] : 0;
525 - $top = isset($results["text-shadow-top"]) ? $results["text-shadow-top"] : 0;
526 - $color = isset($results["text-shadow-color"]) ? $results["text-shadow-color"] : '';
527 - $important = ($this->is_important()) ? "!important" : "";
528 -
529 - if ($width == 0 && $left == 0 && $top == 0)
526 + $width = isset($results["text-shadow-width"]) ? $results["text-shadow-width"] : 0;
527 + $left = isset($results["text-shadow-left"]) ? $results["text-shadow-left"] : 0;
528 + $top = isset($results["text-shadow-top"]) ? $results["text-shadow-top"] : 0;
529 + $color = isset($results["text-shadow-color"]) ? $results["text-shadow-color"] : '';
530 + $important = ($this->is_important()) ? "!important" : "";
531 +
532 + if ($width == 0 && $left == 0 && $top == 0)
530 533 {
531 534 $values = array_diff_key($values, $results); // remove them from the values, prevent incorrect output.
532 - return $values;
535 + return $values;
533 536 }
534 -
535 - $values = $this->add_include($values, "text-shadow ($left,$top,$width,$color $important)");
536 -
537 +
538 + $values = $this->add_include($values, "text-shadow ($left,$top,$width,$color $important)");
539 +
537 540 $values = array_diff_key($values, $results);
538 -
541 +
539 542 return $values;
540 543 }
541 -
544 +
542 545 private function add_include($values, $include)
543 546 {
544 - if (isset($values["@include"]))
545 - $values["@include"] .= "; @include " . $include;
547 + if (isset($values["@include"]))
548 + $values["@include"] .= "; @include " . $include;
546 549 else
547 - $values["@include"] = $include;
548 - return $values;
550 + $values["@include"] = $include;
551 + return $values;
549 552 }
550 -
553 +
551 554 function outputInline($domObj, $pseudo = 'normal')
552 555 {
553 556 $domObj = $domObj->load($domObj->save());
554 -
557 +
555 558 $inline = $this->inline;
556 -
557 - // ISSUE #43 Sometimes this breaks
558 - if (! isset($inline[$pseudo]))
559 +
560 + // ISSUE #43 Sometimes this breaks
561 + if (! isset($inline[$pseudo]))
559 562 return $domObj;
560 563
561 564 $elements = array_keys($inline[$pseudo]);
562 565 if ($pseudo != 'normal') // gather all elements
563 566 $elements = array_merge($elements, array_keys($inline["normal"]));
564 -
567 +
565 568 foreach($elements as $element )
566 569 {
567 - $styles = isset($inline[$pseudo][$element]) ? $inline[$pseudo][$element] : '';
568 -
570 + $styles = isset($inline[$pseudo][$element]) ? $inline[$pseudo][$element] : '';
571 +
569 572 if ($pseudo != 'normal') // parse all possible missing styles from pseudo el.
570 - $normstyle = $this->compile($inline['normal'][$element]);
571 -
572 - $normstyle = '';
573 + $normstyle = $this->compile($inline['normal'][$element]);
574 +
575 + $normstyle = '';
573 576 if ($pseudo != 'normal') // parse all possible missing styles from pseudo el.
574 - $normstyle = $this->compile($inline['normal'][$element]);
575 -
577 + $normstyle = $this->compile($inline['normal'][$element]);
578 +
576 579 maxUtils::addTime("CSSParser: Parse inline done");
577 -
580 +
578 581 $styles = $normstyle . $this->compile($styles);
579 -
580 - $element = trim(str_replace("."," ", $element)); // molten css class, seperator.
581 -
582 +
583 + $element = trim(str_replace("."," ", $element)); // molten css class, seperator.
584 +
582 585 $el = $domObj->find('[class*="' . $element . '"]', 0);
583 - if (is_null($el)) echo "NULL";
586 +
584 587 $el->style = $styles;
585 -
588 +
586 589 }
587 -
590 +
588 591 return $domObj;
589 -
590 - }
591 -
592 - function output()
592 +
593 + }
594 +
595 + function output()
593 596 {
594 -
595 -
597 +
598 +
596 599 }
597 -
600 +
598 601 }
599 602
600 -class compileException extends Exception {
603 +class compileException extends Exception {
601 604 protected $code = -1;
602 605
603 606 }