/** * Parse from DOM node. * * @param DOMElement $node */ public function parse(DOMElement $node) { $this->tag = 'audio'; parent::parse($node); $this->boundary = IdmlParserHelper::parseBoundary($node); $loopAttrib = $node->hasAttribute('SoundLoop') ? $node->getAttribute('SoundLoop') : 'false'; $autoplayAttrib = $node->hasAttribute('PlayOnPageTurn') ? $node->getAttribute('PlayOnPageTurn') : 'false'; $this->loop = $loopAttrib == 'true' ? true : false; $this->autoplay = $autoplayAttrib == 'true' ? true : false; }
/** * Parse from DOM node. * @param DOMElement $node */ public function parse(DOMElement $node) { parent::parse($node); // $this->styleInfo['inlineStyle']->translateSingleColumnWidth(); //set Css width for column /* if($this->hasIdmlProperty('SingleColumnWidth')) { $val = $this->getIdmlProperty('SingleColumnWidth'); if(is_numeric($val)) { $val = round($val); $this->addCssProperty('width', $val . 'pt'); } } */ /* //add needed column info to parent table because IdmlHtmlProducer needs this at the IdmlTable element level if($this->styleInfo["inlineStyle"]->hasCssProperty('width')) { $table = $this->parentIdmlObject(); if(IdmlParserHelper::getIdmlObjectType($table) == "Table") { $table->cols[] = $this; $colwidth = $this->styleInfo["inlineStyle"]->getCssPropertyString('width'); if($colwidth) { $table->colGroupStyles[] = $colwidth; } } } else { CakeLog::debug("[IdmlTableColumn::parse] column width not found? ".__FILE__." Line ".__LINE__); } */ if ($node->hasAttribute('SingleColumnWidth')) { $singleColumnWidth = round($node->getAttribute('SingleColumnWidth')); $table = $this->parentIdmlObject(); if (IdmlParserHelper::getIdmlObjectType($table) == "Table") { $table->cols[] = $this; $colwidth = 'width:' . $singleColumnWidth . 'pt;'; $table->colGroupStyles[] = $colwidth; } } else { CakeLog::debug("[IdmlTableColumn::parse] column width not found? " . __FILE__ . " Line " . __LINE__); } //IdmlTableColumn has no children to parse }
/** * Parse children. We override this because the xml DOM hierarchy has rows, columns, and cells as children of table * we need to change the idml element hierarchy so tables are parents of rows which are parents of cells * @param DOMElement $parentNode */ protected function parseChildren($parentNode) { foreach ($parentNode->childNodes as $childNode) { if (IdmlParserHelper::isParsableChildIdmlObjectNode($childNode)) { $parsableObject = IdmlElementFactory::createFromNode($childNode); if (is_object($parsableObject)) { //set the parent first since sometimes parse requires or sets parent data $parsableObject->parentElement = $this; if (!IdmlParserHelper::isIdmlTagNode($childNode) && IdmlParserHelper::getIdmlObjectType($parsableObject) != "TableCell") { $this->childrenElements[] = $parsableObject; //don't set IdmlTable as parent for IdmlTableCell } $parsableObject->parse($childNode); } } } }
public function parse(DOMElement $node) { parent::parse($node); //parse and set row attributes that are based upon parent table $rownum = $node->hasAttribute('Name') ? intval($node->getAttribute('Name')) : 0; $table = $this->parentIdmlObject(); if (IdmlParserHelper::getIdmlObjectType($table) == "Table") { //set this row in the table rows array by index $table->rows[$rownum] = $this; //from Indesign the order of rows is header, body, footer //we must set what type of row this is and whether it is first and/or last in its group if ($table->headerRowCount && $rownum < $table->headerRowCount) { $this->rowType = 'thead'; $rowGroupStart = 0; $rowGroupEnd = $table->headerRowCount - 1; } elseif ($table->bodyRowCount && $rownum < $table->headerRowCount + $table->bodyRowCount) { $this->rowType = 'tbody'; $rowGroupStart = $table->headerRowCount; $rowGroupEnd = $table->headerRowCount + $table->bodyRowCount - 1; } elseif ($table->footerRowCount && $rownum < $table->headerRowCount + $table->bodyRowCount + $table->footerRowCount) { $this->rowType = 'tfoot'; $rowGroupStart = $table->headerRowCount + $table->bodyRowCount; $rowGroupEnd = $table->headerRowCount + $table->bodyRowCount + $table->footerRowCount - 1; } else { //this is a problem as we can't place the row? CakeLog::debug("[IdmlTableRow::parse] unable to identify tablerow type and place in group " . __FILE__ . " Line " . __LINE__); } if ($rownum == $rowGroupStart) { $this->isFirstRow = true; } if ($rownum == $rowGroupEnd) { $this->isLastRow = true; } } else { //something is wrong so log this? CakeLog::debug("[IdmlTableRow::parse] parent is not an IdmlTable?" . __FILE__ . " Line " . __LINE__); } //TableRow has no children to parse }
/** * Parse from DOM node. *` * @param DOMElement $node */ public function parse(DOMElement $node) { $this->tag = 'video'; parent::parse($node); $this->boundary = IdmlParserHelper::parseBoundary($node); // Get all the IDML attributes needed for setting HTML attributes $controlsAttrib = $node->hasAttribute('ShowControls') ? $node->getAttribute('ShowControls') : 'true'; $loopAttrib = $node->hasAttribute('MovieLoop') ? $node->getAttribute('MovieLoop') : 'false'; $autoplayAttrib = $node->hasAttribute('PlayOnPageTurn') ? $node->getAttribute('PlayOnPageTurn') : 'false'; $playmodeAttrib = $node->hasAttribute('PlayMode') ? $node->getAttribute('PlayMode') : 'Once'; // Set the various HTML attributes $this->controls = $controlsAttrib == 'true' ? true : false; if ($playmodeAttrib == 'Once' || $autoplayAttrib == 'true') { $this->autoplay = true; } else { $this->autoplay = false; } if ($loopAttrib == 'true' || $playmodeAttrib == 'RepeatPlay') { $this->loop = true; } else { $this->loop = false; } }
public function parse(DOMElement $node) { parent::parse($node); //we must set the <col style='width:...' /> for this column in the table $this->rowspan = $node->hasAttribute('RowSpan') ? intval($node->getAttribute('RowSpan')) : -1; $this->colspan = $node->hasAttribute('ColumnSpan') ? intval($node->getAttribute('ColumnSpan')) : -1; // Right now the parent is a table element, but we need the parent to be the corresponding row for this cell. // Find the right row in the table array and assign it as this cell's parent ImdlElement. $colrow = $node->hasAttribute('Name') ? $node->getAttribute('Name') : '0:0'; $colrowArray = explode(":", $colrow); // <col>:<row> $this->colnumber = intval($colrowArray[0]); $this->rownumber = intval($colrowArray[1]); $row = $this->parentElement->rows[$this->rownumber]; if (IdmlParserHelper::getIdmlObjectType($row) == "TableRow") { /*@var $row IdmlTableRow*/ $row->childrenElements[] = $this; $this->parentElement = $row; //assign this cell as child of the table row } else { CakeLog::debug("[IdmlTableCell::parse] cannot find parent row in table for cell? " . __FILE__ . " Line " . __LINE__); } $this->parseChildren($node); }
/** * Parse children. * * @param DOMNode $parentNode */ private function parseChildren($parentNode) { //same logic/code as for IdmlElement method - more comprehensive and easier to maintain foreach ($parentNode->childNodes as $childNode) { if (IdmlParserHelper::isParsableChildIdmlObjectNode($childNode)) { if (Configure::read("dev.idmlHtmlDebugOutput") == true) { CakeLog::debug(sprintf("[IdmlStory::parseChildren] Parse Story %8s %30s --> %sKb", $this->UID, $childNode->nodeName, round(memory_get_usage(true) / 1024))); } $parsableObject = IdmlElementFactory::createFromNode($childNode); //we must set the parent before parsing since children need parent $parsableObject->parentElement = $this; $parsableObject->parse($childNode); $this->childrenElements[] = $parsableObject; } } }
/** * Parse properties for character style. * * @param DOMElement $propertiesNode */ private function parseProperties(DOMElement $propertiesNode) { $leadingNodes = $propertiesNode->getElementsByTagName('Leading'); if ($leadingNodes->length == 1) { $leadingNode = $leadingNodes->item(0); $this->lineHeightUnit = $leadingNode->hasAttribute('type') ? $leadingNode->getAttribute('type') : 'unit'; $this->lineHeightUnit = IdmlParserHelper::convertUnitIntoCssUnit($this->lineHeightUnit); $this->lineHeightValue = IdmlParserHelper::getTextContent($leadingNode); } $appliedFontNodes = $propertiesNode->getElementsByTagName('AppliedFont'); if ($appliedFontNodes->length == 1) { $appliedFontNode = $appliedFontNodes->item(0); $this->appliedFont = IdmlParserHelper::getTextContent($appliedFontNode); } }
public function visitTableCell(IdmlTableCell $element, $depth = 0) { $cssClassNames = array(); $element->attribs['class'] = implode(' ', $cssClassNames); $strAttr = $this->getHTMLAttributesString($element, $element->attribs); $span = ''; if ($element->rowspan == 0 || $element->rowspan > 1) { $span .= 'rowspan="' . $element->rowspan . '"'; // rowspan of 0 tells the browser to span the cell to the last row } if ($element->colspan == 0 || $element->colspan > 1) { $span .= ' colspan="' . $element->colspan . '"'; // colspan of 0 tells the browser to span the cell to the last column of the colgroup } $row = $element->parentIdmlObject(); if (IdmlParserHelper::getIdmlObjectType($row) == "TableRow") { /*@var $row IdmlTableRow*/ if ($row->rowType == 'thead') { $html = "<th {$span} {$strAttr}>"; $element->idmlTag = 'th'; } else { $html = "<td {$span} {$strAttr}>"; $element->idmlTag = 'td'; } $this->addPageElement($html, $depth); } else { CakeLog::debug("[IdmlProduceHtml::visitTableCell] parent element is not a TableRow "); } }
/** * Parse from DOM node. * * @param DOMElement $node */ public function parse(DOMElement $node) { parent::parse($node); $justification = $node->hasAttribute(IdmlAttributes::Justification) ? $node->getAttribute(IdmlAttributes::Justification) : 'left'; if (isset($this->story->page)) { $pagePosition = $this->story->page->pagePosition; } else { $pagePosition = 'left'; } $this->textAlign = IdmlParserHelper::convertJustification($justification, $pagePosition); // Change the TabList property cluster into an array for easier handling IdmlDeclarationParser::arrayifyDupes($this->contextualStyle->idmlContextualElement, $this->contextualStyle); // Check for nested styles; if any exist, set up the helper class object $this->parseNestedStyle(); $this->parseChildren($node); }
/** * Parse children. * @param DOMElement $parentNode */ protected function parseChildren($parentNode) { foreach ($parentNode->childNodes as $childNode) { if (IdmlParserHelper::isParsableChildIdmlObjectNode($childNode)) { $parsableObject = IdmlElementFactory::createFromNode($childNode); if (is_object($parsableObject)) { //set the parent first since sometimes parse requires or sets parent data $parsableObject->parentElement = $this; //set this parsable child object as a child of the parent (bypassing xml parent) $this->childrenElements[] = $parsableObject; $parsableObject->parse($childNode); } } } }
/** * Parse from DOM node. * @param DOMElement $node */ public function parse(DOMElement $node) { parent::parse($node); $actualPpi = $node->hasAttribute(IdmlAttributes::ActualPpi) ? $node->getAttribute(IdmlAttributes::ActualPpi) : ''; $xy = explode(' ', $actualPpi); if (count($xy) == 2) { $this->ppiX = $xy[0]; $this->ppiY = $xy[1]; } // Get original width and height (in InDesign units of 72ppi) $graphicBoundNodes = $node->getElementsByTagName('GraphicBounds'); $graphicBoundNode = $graphicBoundNodes->item(0); if ($graphicBoundNode) { $top = $graphicBoundNode->getAttribute(IdmlAttributes::Top); $left = $graphicBoundNode->getAttribute(IdmlAttributes::Left); $bottom = $graphicBoundNode->getAttribute(IdmlAttributes::Bottom); $right = $graphicBoundNode->getAttribute(IdmlAttributes::Right); $this->boundary = new IdmlBoundary($top, $left, $bottom, $right); $this->width = $this->boundary->getWidth(); $this->height = $this->boundary->getHeight(); } // Load image content. $xpath = new DOMXPath($node->ownerDocument); $q = "./Properties/Contents"; $contentNodes = $xpath->query($q, $node); if ($contentNodes->length > 0) { $contentNode = $contentNodes->item(0); $this->imageContent = IdmlParserHelper::getCData($contentNode); $this->embeddedImage = true; } $this->idmlTag = "img"; $this->processImage(); }
/** * Parse from DOM node. * * @param DOMElement $node */ public function parse(DOMElement $node) { parent::parse($node); $this->UID = $node->hasAttribute(IdmlAttributes::Self) ? $node->getAttribute(IdmlAttributes::Self) : null; $this->setTransform($node); $visible = $node->hasAttribute(IdmlAttributes::Visible) ? $node->getAttribute(IdmlAttributes::Visible) : 'true'; $this->visible = strtolower($visible) == 'true' ? true : false; $this->boundary = IdmlParserHelper::parseBoundary($node); $ffiList = $node->getElementsByTagName('FrameFittingOption'); if ($ffiList->length > 0) { $ffiNode = $ffiList->item(0); $topCrop = $ffiNode->hasAttribute(IdmlAttributes::TopCrop) ? $ffiNode->getAttribute(IdmlAttributes::TopCrop) : 0; $leftCrop = $ffiNode->hasAttribute(IdmlAttributes::LeftCrop) ? $ffiNode->getAttribute(IdmlAttributes::LeftCrop) : 0; $bottomCrop = $ffiNode->hasAttribute(IdmlAttributes::BottomCrop) ? $ffiNode->getAttribute(IdmlAttributes::BottomCrop) : 0; $rightCrop = $ffiNode->hasAttribute(IdmlAttributes::RightCrop) ? $ffiNode->getAttribute(IdmlAttributes::RightCrop) : 0; $this->frameFittingOption = new IdmlFrameFitting($topCrop, $leftCrop, $bottomCrop, $rightCrop); } $this->parseChildren($node); }
/** * @param DOMNode $node * @return IdmlElement $object */ public static function createFromNode(DOMNode $node) { if (IdmlParserHelper::isParsableChildIdmlObjectNode($node)) { $object = null; switch ($node->nodeName) { case 'Rectangle': // @TODO - determine whether spans should be used for rectangles parallel to the axes, and code accordingly // $object = new IdmlRectangle(); $object = new IdmlPolygon(); break; case 'TextFrame': $object = new IdmlTextFrame(); break; case 'Element': $object = new IdmlElement(); break; case 'CharacterStyleRange': $object = new IdmlCharacterRange(); break; case 'ParagraphStyleRange': $object = new IdmlParagraphRange(); break; case 'Image': case 'PDF': /* Adobe Illustrator PDF image */ /* Adobe Illustrator PDF image */ case 'EPS': /* Encapsulated Postscript image */ $object = new IdmlImage(); break; case 'Group': $object = new IdmlGroup(); break; case 'Story': $object = new IdmlStory(); break; case 'Change': $object = new IdmlChange(); break; case 'Content': $object = new IdmlContent(); break; case 'Br': $object = new IdmlBrContent(); break; case 'XMLElement': $object = new IdmlXmlElement(); break; case 'Table': $object = new IdmlTable(); break; case 'Cell': $object = new IdmlTableCell(); break; case 'Column': $object = new IdmlTableColumn(); break; case 'Row': $object = new IdmlTableRow(); break; case 'HyperlinkTextSource': $object = new IdmlHyperlink(); break; case 'HyperlinkTextDestination': $object = new IdmlHyperlinkDestination(); break; case 'Sound': $object = new IdmlSound(); break; case 'Movie': $object = new IdmlMovie(); break; case 'TextVariableInstance': $object = new IdmlTextVariableInstance(); break; case 'GraphicLine': $object = new IdmlGraphicLine(); break; case 'Polygon': $object = new IdmlPolygon(); break; case 'Oval': $object = new IdmlOval(); break; default: CakeLog::debug("[IdmlElementFactory::createFromNode] '{$node->nodeName}' not implemented"); $object = null; } return $object; } }
/** * this logic is needed in more than one location since the hierarchy is being navigated and used in several ways * at this point it only filters out XMLElements that are really just duplicate structures that sometimes get created * when Tags are applied in an Indesign document * @param IdmlElement $element * @return boolean */ private function shouldProcessElement(IdmlElement $element) { $elementType = IdmlParserHelper::getIdmlObjectType($element); if ($elementType != 'XmlElement' || $elementType == 'XmlElement' && (!$element->xmlContent || $element->xmlContent == $this->currentStoryID)) { return true; } else { return false; } }
/** The readDesignMap function obtains the filename pointers to the MasterSpreads, Resources, Spreads, * Stories, and XML from the designmap, which is the manifest that contains references to the names and locations * of the package's XML files. * * @return boolean true on success, false on failure. */ public function readDesignMap() { //first read the BackStory.xml file to see if any Stories, Hyperlinks, etc. should be ignored ... $this->readBackingStoryAndSetHiddenIds(); // The designmap contains references to everything in the package $designmap = $this->tempDir . '/designmap.xml'; if (!file_exists($designmap)) { $this->idmlAssembler->getProgressUpdater()->setWarning("{$designmap} does not exist."); return false; } // create DOMDocument and DOMXPath objects $doc = new DomDocument(); $b = $doc->load($designmap); if ($b === false) { return false; } $xpath = new DOMXPath($doc); // Parse the preferences file, which contains the width and height of our pages $tags = $xpath->query('//idPkg:Preferences'); assert($tags->length == 1); $attr = $tags->item(0)->attributes->getNamedItem('src'); $filename = "{$this->tempDir}/{$attr->value}"; $this->preferences = new IdmlPreferences(); $this->preferences->load($filename); IdmlAssembler::updateBookSize($this->preferences->pageWidth, $this->preferences->pageHeight); // The Declaration Manager deals with declared Colors, declared Styles, and declared Style Groups $manager = IdmlDeclarationManager::getInstance(); // Parse the graphics file which contains color declarations (this must be done before parsing the Styles) $tags = $xpath->query('//idPkg:Graphic'); assert($tags->length == 1); $attr = $tags->item(0)->attributes->getNamedItem('src'); $filename = "{$this->tempDir}/{$attr->value}"; $manager->loadDeclaredColors($filename); // There should always be exactly one Styles file *** Version 2: non-PEARSON *** $tags = $xpath->query('//idPkg:Styles'); assert($tags->length == 1); $attr = $tags->item(0)->attributes->getNamedItem('src'); $filename = "{$this->tempDir}/{$attr->value}"; $manager->loadDeclaredStyles($filename); /* // There should always be exactly one Styles file *** Version 1: PEARSON PXE *** $tags = $xpath->query('//idPkg:Styles'); assert( $tags->length == 1 ); $attr = $tags->item(0)->attributes->getNamedItem('src'); $filename = "{$this->tempDir}/{$attr->value}"; $this->style = new IdmlStyles($this); $this->style->filename = $filename; $this->style->load(); */ // Parse fonts file. $tags = $xpath->query('//idPkg:Fonts'); assert($tags->length == 1); $attr = $tags->item(0)->attributes->getNamedItem('src'); $filename = "{$this->tempDir}/{$attr->value}"; IdmlFontManager::getInstance()->loadFonts($filename); // There should always be exactly one Tags file $tags = $xpath->query('//idPkg:Tags'); assert($tags->length == 1); $attr = $tags->item(0)->attributes->getNamedItem('src'); $filename = "{$this->tempDir}/{$attr->value}"; $this->tags = new IdmlTags($this); $this->tags->filename = $filename; $this->tags->load(); // There are possibly several MasterSpread files, which are referenced by real spreads and accessed by their UID's. $tags = $xpath->query('//idPkg:MasterSpread'); foreach ($tags as $tag) { $attr = $tag->attributes->getNamedItem('src'); $filename = "{$this->tempDir}/{$attr->value}"; $matches = null; $found = preg_match('|MasterSpreads/MasterSpread_(.*)\\.xml|', $attr->value, $matches); // u154 <-- MasterSpreads/MasterSpread_u154.xml if ($found == 1) { $UID = $matches[1]; $masterSpread = new IdmlMasterSpread($this); $masterSpread->filename = $filename; $this->masterSpreads[$UID] = $masterSpread; } else { $this->idmlAssembler->getProgressUpdater()->setWarning("Unable to determine UID for MasterSpread '{$attr->value}'."); } } // There are most likely many Spread files, and they are ordered in the designmap // according to the book's page ordering. $tags = $xpath->query('//idPkg:Spread'); foreach ($tags as $tag) { $attr = $tag->attributes->getNamedItem('src'); $filename = "{$this->tempDir}/{$attr->value}"; $spread = new IdmlSpread($this); $spread->filename = $filename; $this->spreads[] = $spread; } // There are most likely many Story files, which are referenced by TextFrames and accessed by a parentStoryUID. $tags = $xpath->query('//idPkg:Story'); foreach ($tags as $tag) { $attr = $tag->attributes->getNamedItem('src'); $filename = "{$this->tempDir}/{$attr->value}"; $matches = null; $found = preg_match('|Stories/Story_(.*)\\.xml|', $attr->value, $matches); // u154 <-- Stories/Story_u154.xml if ($found == 1) { $UID = $matches[1]; if (!array_key_exists($UID, $this->chaucerHidden)) { //create/store the story if it is not hidden by a designer $story = new IdmlStory($UID); $story->filename = $filename; $this->stories[$UID] = $story; } } else { $this->idmlAssembler->getProgressUpdater()->setWarning("Unable to determine UID for Story '{$attr->value}'."); } } //Parse hyperlink information $this->hyperlinks = array(); $tags = $xpath->query('//Hyperlink'); $hyperlinkMgr = IdmlHyperlinkManager::getInstance(); foreach ($tags as $tag) { $properties = IdmlParserHelper::getAllDomNodeAttributesAndProperties($tag); // This code is (we think) PXE processing code if (!array_key_exists($properties['Self'], $this->chaucerHidden)) { // create/store the hyperlink if it is not hidden by a designer // The $destNode can be either a HyperlinkURLDestination or a HyperlinkPageDestination in the IDML, // and is referenced by the Hyperlink element. $destId = $properties['Destination']; $destNode = $xpath->query('//*[@Self="' . $destId . '"]'); if ($destNode->length > 0) { $destNode = $destNode->item(0); $properties['Destination'] = IdmlParserHelper::getAllDomNodeAttributesAndProperties($destNode); $properties['Destination']['DestinationType'] = $destNode->nodeName; } $this->hyperlinks[$properties['Self']] = $properties; } // The remainder of this foreach is specifically written for non-PXE IDML $hyperlinkSource = $properties['Source']; $external = false; // unless the link goes to a page outside the epub // If the Destination property is an array, the destination is a link to either // a page within the epub (with the page UID in the data), or or an external link. // So the destination can be set here. if (is_array($properties['Destination'])) { $anchor = false; // link is to a page, not an anchor if ($properties['Destination']['DestinationType'] == 'HyperlinkURLDestination') { // External page: use as is $hyperlinkDestination = $properties['Destination']['DestinationURL']; $external = true; // This links to a page outside the epub } else { // Internal page. Use the page UID; add the package index and the .html suffix $hyperlinkDestination = $properties['Destination']['DestinationPage']; } } else { $anchor = true; // link is to an anchor on a page. $hyperlinkDestination = 'Hyperlink_' . $properties['DestinationUniqueKey']; } $hyperlinkMgr->setSourceDestination($hyperlinkSource, $hyperlinkDestination, $anchor, $external); } //Parse layer information $layers = $xpath->query('//Layer'); $layerManager = IdmlLayerManager::getInstance(); foreach ($layers as $layer) { $layerManager->addLayer($layer); } return true; }
/** * Parse the portion of a spread.xml file that contains a <TextFrame> * * @param DOMElement $node is a single <TextFrame> node within the IDML document */ public function parse(DOMElement $node) { parent::parse($node); $attributes = $node->attributes; $this->UID = $attributes->getNamedItem('Self')->value; // like 'uf9' $this->parentStoryUID = $attributes->getNamedItem('ParentStory')->value; // like 'ue5' $this->contentType = $attributes->getNamedItem('ContentType')->value; // like 'TextType' $this->visible = $attributes->getNamedItem('Visible')->value == 'false' ? false : true; // like 'true' $this->setTransform($node); $this->boundary = IdmlParserHelper::parseBoundary($node); $this->prevTextFrame = $attributes->getNamedItem(IdmlAttributes::PreviousTextFrame)->value == 'n' ? null : $attributes->getNamedItem(IdmlAttributes::PreviousTextFrame)->value; $this->nextTextFrame = $attributes->getNamedItem(IdmlAttributes::NextTextFrame)->value == 'n' ? null : $attributes->getNamedItem(IdmlAttributes::NextTextFrame)->value; $this->textColumnCount = isset($this->contextualStyle->idmlKeyValues['TextFramePreference->TextColumnCount']) ? (int) $this->contextualStyle->idmlKeyValues['TextFramePreference->TextColumnCount'] : null; $this->columnWidth = isset($this->contextualStyle->idmlKeyValues['TextFramePreference->TextColumnFixedWidth']) ? $this->contextualStyle->idmlKeyValues['TextFramePreference->TextColumnFixedWidth'] : null; // If we *do_not_have* a previous text frame then it is either a single text frame or the first of a series of // linked ones. In case of linked ones we output only the first one. if (!$this->prevTextFrame) { $this->loadParentStory(); } else { if (IdmlAssembler::getInstance()->isFixedLayout()) { CakeLog::debug("[IdmlTextFrame::parse] Encountered an InDesign threaded frame in a fixed layout book (story {$this->parentStoryUID}). Run Chaucer FixedLayoutPreflight.jsx script within InDesign and re-export the IDML."); } } }
public function parseChildrenRecursively($node, $nodeNamespace) { // Within the node there are many, many attributes that we *may* be interested in foreach ($node->attributes as $key => $attr) { // For example <ParagraphStyle FontStyle="Regular" /> becomes: $idmlKeyValues['FontStyle'] => 'Regular' // For example, <Properties><AppliedFont>Minion Pro</AppliedFont></Properties> becomes: $idmlKeyValues['Properties::AppliedFont'] => 'Minion Pro' if ($nodeNamespace != '') { $key = $nodeNamespace . '->' . $key; } $this->idmlKeyValues[$key] = $attr->value; } // Now loop through all child elements foreach ($node->childNodes as $childNode) { if ($childNode->nodeType != XML_ELEMENT_NODE) { continue; } if (IdmlParserHelper::isParsableChildIdmlObjectNode($childNode) == true) { continue; } if ($nodeNamespace == '') { $key = $childNode->tagName; } else { $key = $nodeNamespace . '::' . $childNode->tagName; } $value = $childNode->textContent; $key = $this->makeUniqueKey($key); $this->idmlKeyValues[$key] = $value; $this->parseChildrenRecursively($childNode, $key); } }