public function visitTextFrame(IdmlTextFrame $element, $outer_depth = 0) { // For the outermost TextFrame whose parent is IdmlPage, do not do the special anchor processing $parentElement = $element->parentIdmlObject(); if ($element->parentIdmlObject() == null) { $this->addPageElement("<!-- OUTERTEXTFRAME {$element->story->UID} -->", $outer_depth, ''); return; // yes visit children } else { $stack = $this->getAncestors($element, 'IdmlPage'); // close all open tags back to the root $this->rewind($stack, $outer_depth); $inner_depth = get_class($element->parentIdmlObject()) == 'IdmlCharacterRange' ? $outer_depth - 3 : $outer_depth; $this->addPageElement("<!-- ANCHORED TEXTFRAME {$element->story->UID} -->", $inner_depth, ''); $this->addPageElement("<div data-idml='IdmlTextFrame {$element->UID}'>", $inner_depth); $this->addPageElement("<!-- ANCHOR {$element->story->UID} -->", $inner_depth + 1, ''); // Create a new producer for recursion . . . $thisClass = get_class($this); assert($thisClass == 'IdmlProduceFixedLayout' || $thisClass == 'IdmlProduceReflowable' || $thisClass == 'IdmlProduceHtmlDiagnostic'); $currentRecursivePageNumber = $this->pageNumber; $htmlProducer = new $thisClass($currentRecursivePageNumber); // . . . then walk the tree starting from the current text frame's story . . . if ($element->story && $element->visible) { $element->story->accept($htmlProducer, $inner_depth + 1); } // . . . and finally stuff the content that _it_ produces back into this object. . . $innerContent = $htmlProducer->getBodyContent(); $diagnosticContent = $htmlProducer->getDiagnosticContent(); $this->addPageElement($innerContent, 0, $diagnosticContent); // . . . and copy the page number of the inner object to the outer object. $this->pageNumber = $htmlProducer->pageNumber; $this->addPageElement("<!-- /ANCHOR {$element->story->UID} -->", $inner_depth + 1, ''); $this->addPageElement("</div><!-- IdmlTextFrame {$element->UID}-->", $inner_depth); $this->addPageElement("<!-- /ANCHORED TEXTFRAME {$element->story->UID} -->", $inner_depth, ''); // reopen all tags from the root down to where we were before we were interrupted $this->fastForward($stack, $outer_depth); // Important: Instruct IdmlTextFrame not to continue any deeper return 'do not visit children'; } }
/** * Create an HTML aside from the IDML TextFrame. * @param IdmlTextFrame $element * @param int $outer_depth */ protected function createAside(IdmlTextFrame $element, $outer_depth = 0) { $inner_depth = get_class($element->parentIdmlObject()) == 'IdmlCharacterRange' ? $outer_depth - 3 : $outer_depth; $this->addPageElement("<!-- ANCHOR {$element->story->UID} -->", $inner_depth + 1, ''); $this->writeAsideBegin($element, $inner_depth + 1); // Create a new producer for recursion . . . // NOTE: Logic using a 2nd producer has been eliminated. We think it is no longer effective // Code is left in place in case things go horribly awry. // $thisClass = get_class($this); // $currentRecursivePageNumber = $this->pageNumber; // $htmlProducer = new $thisClass($currentRecursivePageNumber); // . . . then walk the tree starting from the current text frame's story . . . if ($element->story && $element->visible) { $element->story->accept($this, $outer_depth + 1); // $element->story->accept($htmlProducer, $inner_depth+1); } // . . . and finally stuff the content that _it_ produces back into this object // Copy the page elements to a new array first to prevent side effects // $innerContent = $htmlProducer->getPageElements(); // $pageElements = $this->pageElements; // $this->pageElements = array_merge($pageElements, $innerContent); // $diagnosticContent = $htmlProducer->getDiagnosticPageElements(); // $diagnosticPageElements = $this->diagnosticPageElements; // $this->diagnosticPageElements = array_merge($diagnosticPageElements, $diagnosticContent); $this->writeAsideEnd($outer_depth + 1); $this->addPageElement("<!-- /ANCHOR {$element->story->UID} -->", $inner_depth + 1, ''); if (!is_null($element->rotationOffset)) { $this->addPageElement('<div style="height:' . $element->rotationOffset . 'px;">', 0); $this->addPageElement('</div>', 0); $element->rotationOffset = null; } }
public function visitTextFrame(IdmlTextFrame $element, $depth = 0) { /* find the parent and if it is a character range, drop that from the parent list */ $parentElement = $element->parentIdmlObject(); if (is_a($parentElement, "IdmlCharacterRange") && count($this->parentStack) > 3) { $element->attributes["_pxe_stashed_parent"] = array_pop($this->parentStack); } }