예제 #1
0
 public function addCssFonts()
 {
     if (!is_object(IdmlAssembler::getInstance()->getProcessor())) {
         return;
     }
     $dir = new Folder(APP . "Data/Pxe/Fonts");
     $files = $dir->find();
     foreach ($files as $file) {
         IdmlAssembler::getInstance()->getProcessor()->addFontToBook($dir->pwd() . DS . $file);
     }
 }
예제 #2
0
 /**
  * Constructor.
  *
  * @param IdmlResourceManager $resourceManager Default is null or if you want to inject the object you can pass the param.
  */
 public function __construct(IdmlResourceManager $resourceManager = null)
 {
     if (is_null($resourceManager)) {
         $this->resourceManager = IdmlAssembler::getInstance()->resourceManager;
     } else {
         $this->resourceManager = $resourceManager;
     }
     $this->boundary = IdmlBoundary::createDefault();
     $this->height = null;
     $this->width = null;
     $this->ppiX = null;
     $this->ppiY = null;
     $this->idmlTag = "img";
 }
예제 #3
0
 public function processBook()
 {
     $idmlAssembler = IdmlAssembler::getInstance();
     $idmlAssembler->init($this);
     $idmlAssembler->addIDMLPackages($this->sourceFiles);
     $idmlAssembler->preparation();
     $idmlAssembler->parse();
     $idmlAssembler->produce();
     // Saving the book CSS here is different from the original PXE implementation.
     // It clobbers the template.css for PXE created by the old (now obsolete) Style Manager.
     if (!$idmlAssembler->pxeTagsAdded) {
         $bookCss = IdmlDeclarationManager::getInstance()->convertIdmlToCSS();
         $this->saveBookCSS($bookCss, 'template.css', false);
     }
     $idmlAssembler->adjustMaxSteps();
     return true;
 }
예제 #4
0
 /**
  * Parse from DOM node.
  * 
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $link = IdmlAssembler::getInstance()->getCurrentPackage()->getHyperlinkBySource($node->getAttribute("Self"));
     $this->idAttribute = $node->hasAttribute(IdmlAttributes::Self) ? $node->getAttribute(IdmlAttributes::Self) : null;
     $this->name = $node->hasAttribute(IdmlAttributes::Name) ? $node->getAttribute(IdmlAttributes::Name) : null;
     if (count($link) > 0) {
         if (is_array($link['Destination'])) {
             $this->linkType = $link['Destination']['DestinationType'];
             if (array_key_exists('DestinationURL', $link['Destination'])) {
                 $this->href = $link['Destination']['DestinationURL'];
             }
         } else {
             $this->href = $link['Destination'];
         }
         if (!strlen($this->idmlTag)) {
             $this->idmlTag = 'a';
         }
     }
     $this->parseChildren($node);
 }
예제 #5
0
 /**
  *  This function is called by the spread, after it has determined which page the text frame is on.
  *  It is entirely legitimate to exit without assigning anything to $this->idmlStory in which case this becomes an
  *  empty TextFrame.
  */
 protected function loadParentStory()
 {
     // Lookup and parse the story into memory
     $package = IdmlAssembler::getInstance()->getCurrentPackage();
     if ($package) {
         $story = $package->loadStory($this->parentStoryUID);
         // Sanity check
         $storyClass = get_class($story);
         if (substr($storyClass, 0, 14) == 'Mock_IdmlStory') {
             $storyClass = 'IdmlStory';
         }
         if ($story == null || $storyClass != 'IdmlStory') {
             $this->story = null;
             return;
         }
         // Finally, now that we are sure this story has not been placed already (in some other text frame),
         // keep a reference to it.
         $this->story = $story;
         $story->idmlTextFrame = $this;
     }
 }
예제 #6
0
 /**
  * This accept function is called by the parent IdmlSpread.
  * 
  * @param IdmlVisitor $visitor
  * @param $depth is how deep in the traversal we are
  */
 public function accept(IdmlVisitor $visitor, $depth)
 {
     // Skip the page in case it does not have any children elements.
     if (IdmlAssembler::getInstance()->isReflowable()) {
         if (count($this->childrenElements) == 0 || $this->hasOnlyEmptyTextFrames()) {
             return;
         }
     }
     $visitor->visitPage($this, $depth);
     // First walk the elements of the associated master spread.
     if (IdmlAssembler::getInstance()->isFixedLayout()) {
         $this->visitMasterPageItems($visitor, $this->inDesignPageName, $depth + 1);
     }
     // Then walk the elements of this page itself
     foreach ($this->childrenElements as $childElement) {
         $childElement->accept($visitor, $depth + 1);
     }
     $visitor->visitPageEnd($this, $depth);
 }
예제 #7
0
 /**
  * Save page.
  * @return Page $pageFile
  */
 protected function savePage()
 {
     $content = $this->getPageContent();
     if (Configure::read("dev.idmlHtmlDebugOutput")) {
         // DEBUG
         $this->diagnosticTool($content);
         // <-- Turn off in production
         // DEBUG
     }
     $processor = IdmlAssembler::getProcessor();
     if ($processor) {
         $currentPageToSave = $this->pageNumber;
         if (!Configure::read("dev.idmlPostProcessing")) {
             $pageFile = $processor->savePageHTML($content, $currentPageToSave, '', 0, null, $this->pageObject->properties);
             $processor->savePageCSS('', $currentPageToSave);
         } else {
             $postProcessor = new IdmlPostProcessor();
             $cleanHtml = $postProcessor->removeEmptyElements($content);
             // $num = $postProcessor->numElementsDeleted;
             $dual = $postProcessor->segregateCssFromHtml($cleanHtml);
             $html = $dual['html'];
             $css = $dual['css'];
             $pageFile = $processor->savePageHTML($html, $currentPageToSave, '', 0, null, $this->pageObject->properties);
             $processor->savePageCSS($css, $currentPageToSave);
         }
         IdmlAssembler::getInstance()->actualPages++;
     }
     $this->pageNumber++;
     return $pageFile->getIdentifier();
 }
예제 #8
0
 /**
  * Get the current IdmlProcessor object
  * @return IdmlProcessor object
  */
 public static function getProcessor()
 {
     self::$instance = IdmlAssembler::getInstance();
     if (self::$instance) {
     }
     return self::$instance->processor;
     return null;
 }