Exemplo n.º 1
0
 /**
  * Returns an array with styles that apply to the node
  * based on the $this->rules
  * 
  * @todo prioritize the rules according to w3c specifications
  * 
  * @param \DOMNode $node
  * @return array
  */
 public function getStylesFromCssRules($node)
 {
     $css_selector = new Selector($node->ownerDocument);
     $css = array();
     foreach ($this->rules as $rule) {
         $selector = $rule['selector'];
         if ($css_selector->nodeMatch($node, $selector)) {
             foreach ($rule['style'] as $style) {
                 list($k, $v) = explode(':', $style);
                 $v = trim($v, "\r\n\t ");
                 $k = trim($k, "\r\n\t ");
                 if ($k && $v !== '') {
                     $css[$k] = trim($v, "\r\n\t ");
                 }
             }
         }
     }
     return $css;
 }