function set_id($id) { $this->_frame->set_id($id); }
/** * Recursively adds {@link Frame} objects to the tree * * Recursively build a tree of Frame objects based on a dom tree. * No layout information is calculated at this time, although the * tree may be adjusted (i.e. nodes and frames for generated content * and images may be created). * * @param DomNode $node the current DomNode being considered * @return Frame */ protected function _build_tree_r(DomNode $node) { $frame = new Frame($node); $frame->set_id($id = uniqid(rand())); $this->_registry[$id] = $frame; if (!$node->hasChildNodes()) { return $frame; } foreach ($node->childNodes as $child) { // Skip non-displaying nodes if (in_array($child->nodeName, self::$_HIDDEN_TAGS)) { continue; } // Skip empty #text nodes if ($child->nodeName == "#text" && $child->nodeValue == "") { continue; } // Add a container frame for images if ($child->nodeName == "img") { $img_node = $child->ownerDocument->createElement("img_inner"); // Move attributes to inner node foreach ($child->attributes as $attr => $attr_node) { // Skip style, but move all other attributes if ($attr == "style") { continue; } $img_node->setAttribute($attr, $attr_node->value); } foreach ($child->attributes as $attr => $node) { if ($attr == "style") { continue; } $child->removeAttribute($attr); } $child->appendChild($img_node); } $frame->append_child($this->_build_tree_r($child), false); } return $frame; }