/** * Overrides base class to determine if the content has pxe context assigned, and if so * process it accordingly. If the content element has a pxe tag (which would only be a span) then process the tag, * add the content, and close the tag.. otherwise just add the content normally * and let the pxe producer handle wrapping tags * @param IdmlContent $element * @param int $depth */ public function visitContentEnd(IdmlContent $element, $depth = 0) { if (!$element->hasContent()) { //skip empty content tags return; } if (IdmlPxeHelper::hasPxeTag($element)) { parent::visitContentEnd($element, $depth); $this->closeElement($element, $depth); } elseif (IdmlPxeHelper::hasPxeParents($element)) { //get last parent and put this content inside it by assigning it $parents = IdmlPxeHelper::getPxeParents($element, true); if (count($parents) > 0) { parent::visitContentEnd($element, $depth); $this->closeElement($element, $depth); } } else { parent::visitContentEnd($element, $depth); } }
/** * Moves the element's pxe tag, class, and hash into the parents attribute and assigns * a new pxe tag to the element. The new pxe tag is pushed onto the parent stack * @param IdmlElement $element * @param string $newTag * @param string $newHash */ public function pushTagToElement(IdmlElement $element, $newTag, $newHash) { $currentTag = IdmlPxeHelper::getPxeTag($element); if (IdmlPxeHelper::hasPxeClass($element)) { $currentClass = IdmlPxeHelper::getPxeClass($element); if (strlen($currentClass)) { $currentTag .= "." . $currentClass; } } $currentHash = $element->attributes["data-pxe-hash"]; $parentList = IdmlPxeHelper::getPxeParents($element) . " " . $currentTag . "#" . $currentHash; if (strpos($newTag, ".")) { list($tagName, $tagClass) = explode(".", $newTag); } else { $tagName = $newTag; $tagClass = ""; } IdmlPxeHelper::setPxeTag($element, $tagName); IdmlPxeHelper::setPxeClass($element, $tagClass); $element->attributes["data-pxe-hash"] = $newHash; IdmlPxeHelper::setPxeParents($element, trim($parentList)); $this->pushParentTag($newTag, $newHash, $element); //Apply this change to all the child elements if (count($element->childrenElements) > 0) { $newChildParentList = $parentList . ' ' . IdmlPxeHelper::getFullPxeTag($element); foreach ($element->childrenElements as $child) { $this->updateElementParents($child, $parentList, $newChildParentList); } } }