Combines multiply defined selectors by merging the rule sets, latter declarations overide declaratins at top of file

Parameters

(array) selectors: Array of selectors broken down by setup:

(array) details: Array of rule sets broken down by setup:

1 call to CSSCompression_Organize::reduceSelectors()
CSSCompression_Organize::organize in advagg_css_compress/css-compressor-3.x/src/lib/Organize.inc
Look to see if we can combine selectors to reduce the number of definitions.

File

advagg_css_compress/css-compressor-3.x/src/lib/Organize.inc, line 57

Class

CSSCompression_Organize
CSS Compressor [VERSION] [DATE] Corey Hart @ http://www.codenothing.com

Code

private function reduceSelectors($selectors, $details) {
    $keys = array_keys($selectors);
    $max = array_pop($keys) + 1;
    for ($i = 0; $i < $max; $i++) {
        if (!isset($selectors[$i])) {
            continue;
        }
        for ($k = $i + 1; $k < $max; $k++) {
            if (!isset($selectors[$k])) {
                continue;
            }
            if ($selectors[$i] == $selectors[$k]) {
                // Prevent noticies
                if (!isset($details[$i])) {
                    $details[$i] = '';
                }
                if (!isset($details[$k])) {
                    $details[$k] = '';
                }
                // We kill the last semicolon before organization, so account for that.
                if ($details[$i] != '' && $details[$k] != '' && !preg_match($this->rlastsemi, $details[$i])) {
                    $details[$i] .= ';' . $details[$k];
                }
                else {
                    $details[$i] .= $details[$k];
                }
                // Remove the second part
                unset($selectors[$k], $details[$k]);
            }
        }
    }
    return array(
        $selectors,
        $details,
    );
}