public function CSSCompression_Combine_Background::combine in Advanced CSS/JS Aggregation 6
Same name and namespace in other branches
- 7 advagg_css_compress/css-compressor-3.x/src/lib/Combine/Background.inc \CSSCompression_Combine_Background::combine()
Combines multiple background props into single definition
Parameters
(string) val: Rule Set:
File
- advagg_css_compress/
css-compressor-3.x/ src/ lib/ Combine/ Background.inc, line 58
Class
- CSSCompression_Combine_Background
- CSS Compressor [VERSION] [DATE] Corey Hart @ http://www.codenothing.com
Code
public function combine($val) {
$storage = array();
// Find all possible occurences and build the replacement
$pos = 0;
while (preg_match($this->rbackground, $val, $match, PREG_OFFSET_CAPTURE, $pos)) {
$storage[$match[2][0]] = $match[3][0];
$pos = $match[0][1] + strlen($match[0][0]) - 1;
}
// Run background checks and get replacement str
foreach ($this->groupings as $props) {
if ($replace = $this->Combine
->searchDefinitions('background', $storage, $props)) {
break;
}
}
// If replacement string found, run it on all declarations
if ($replace) {
$pos = 0;
while (preg_match($this->rbackground, $val, $match, PREG_OFFSET_CAPTURE, $pos)) {
$colon = strlen($match[1][0]);
$val = substr_replace($val, $replace, $match[0][1] + $colon, strlen($match[0][0]) - $colon);
$pos = $match[0][1] + strlen($replace) - $colon - 1;
$replace = '';
}
}
// Return converted val
return $val;
}