Aural.inc in Advanced CSS/JS Aggregation 6
File
advagg_css_compress/css-compressor-3.x/src/lib/Combine/Aural.inc
View source
<?php
class CSSCompression_Combine_Aural {
private $Control;
private $Combine;
private $raural = "/(^|(?<!\\\\);)(cue|pause)-(before|after):(.*?)((?<!\\\\);|\$)/";
public function __construct(CSSCompression_Control $control, CSSCompression_Combine $combine) {
$this->Control = $control;
$this->Combine = $combine;
}
public function combine($val) {
$storage = $this
->storage($val);
$pos = 0;
while (preg_match($this->raural, $val, $match, PREG_OFFSET_CAPTURE, $pos)) {
$prop = $match[2][0];
if (isset($storage[$prop])) {
$colon = strlen($match[1][0]);
$val = substr_replace($val, $storage[$prop], $match[0][1] + $colon, strlen($match[0][0]) - $colon);
$pos = $match[0][1] + strlen($storage[$prop]) - $colon - 1;
$storage[$prop] = '';
}
else {
$pos = $match[0][1] + strlen($match[0][0]) - 1;
}
}
return $val;
}
private function storage($val) {
$storage = array();
$pos = 0;
while (preg_match($this->raural, $val, $match, PREG_OFFSET_CAPTURE, $pos)) {
if (!isset($storage[$match[2][0]])) {
$storage[$match[2][0]] = array(
$match[3][0] => $match[4][0],
);
}
$storage[$match[2][0]][$match[3][0]] = $match[4][0];
$pos = $match[0][1] + strlen($match[0][0]) - 1;
}
foreach ($storage as $tag => $arr) {
if (count($arr) == 2 && !$this->Combine
->checkUncombinables($arr)) {
$storage[$tag] = "{$tag}:" . $arr['before'] . ' ' . $arr['after'] . ';';
}
else {
unset($storage[$tag]);
}
}
return $storage;
}
public function access($method, $args) {
if (method_exists($this, $method)) {
return call_user_func_array(array(
$this,
$method,
), $args);
}
else {
throw new CSSCompression_Exception("Unknown method in Aural Class - " . $method);
}
}
}