public static function get_p_css($e, $p) { $inline = ""; //controllo sullo stile inline if (isset($e->attr["style"])) { $inline = BasicChecks::GetElementStyleInline($e->attr["style"], $p); //verifico "!important" $posizione = stripos($inline, "!important"); if ($posizione !== false) { //tolgo "!important" e ritorno il valore della proprietà //echo str_ireplace("!important", "", $inlinea_inline); $inline = str_ireplace($p, "", $inline); $inline = str_ireplace(":", "", $inline); $inline = str_ireplace("!important", "", $inline); return $inline; } } //Internal control over the style and the external styles //$best: will store 'the value of the priority rule that has'more' contained in the high-style indoor / outdoor //about the item and its $ e '$ p //controllo sullo stile interno e sugli stili esterni //$best: memorizzera' il valore della regola che ha priorita' piu' alta contenuta nello stile interno/esterno //relativamente all'elemento $e e alla proprita' $p $best = null; //id if (isset($e->attr["id"])) { $id = BasicChecks::GetElementStyleId($e, $e->attr["id"], $p); $best = BasicChecks::getPriorityInfo($best, $id); } //classe if (isset($e->attr["class"])) { $class = BasicChecks::GetElementStyleClass($e, $e->attr["class"], $p); $best = BasicChecks::getPriorityInfo($best, $class); } //tag $tag = BasicChecks::GetElementStyle($e, $e->tag, $p); $best = BasicChecks::getPriorityInfo($best, $tag); // * try, in the instructions inside / outside // apply any property 'of * if: // internal or external style is not 'declare the property' for the element $ p $ and // if that is declared in * important, but not that of the IOE and style ' // //cerco *, nel foglio interno/esterno //applico l'eventuale proprieta' di * se: //nello stile interno o esterno non e' dichiarata la proprieta' $p per l'elemento $e //se quella dichiarata in * è important, ma quella dello stile i o e non lo e' $best_all = BasicChecks::GetElementStyle($e, '*', $p); if ($best == null || stripos($best["valore"], "!important") === false && stripos($best_all["valore"], "!important") !== false) { $best = $best_all; } // if coming here was not the style inline! important since the early control // inline style has always priority 'rule, unless a rule in a style indoor / outdoor does not contain! important // //se arrivo qui lo stile inline non ha !important dato che lo controllo all'inizio //lo stile inline ha sempre priorita' massima, a meno che una regola in uno stile interno/esterno non contenga !important if ($inline != null && $inline != "") { if (stripos($best["valore"], "!important") === false) { //non c'e' !important nel foglio di stile return $inline; } } // inline style if there is not $ p 'returns the value of $ best // //se nello stile inline $p non c'e' restituisco il valore di $best //echo("<p>regola</p>"); //print_r($best["css_rule"]); //css array containing the CSS rules are printed in output //array css contiene le regole dei css che verranno stampate in output global $array_css; if (isset($best["css_rule"])) { $same = false; if (sizeof($array_css) > 0) { $size_of_best = sizeof($best["css_rule"]["prev"]); foreach ($array_css as $rule) { $size_of_prev_rules = sizeof($rule["prev"]); if ($size_of_prev_rules == $size_of_best) { for ($i = 0; $i < $size_of_prev_rules; $i++) { if ($rule["prev"][$i] == $best["css_rule"]["prev"][$i]) { $same = true; } else { $same = false; break; } } if ($same == true) { break; } } } } if ($same == false) { array_push($array_css, $best["css_rule"]); } } return $best["valore"]; }