public function importPageAreas(Page $page, \SimpleXMLElement $px)
 {
     foreach ($px->area as $ax) {
         if (isset($ax->blocks)) {
             foreach ($ax->blocks->block as $bx) {
                 if ($bx['type'] != '') {
                     // we check this because you might just get a block node with only an mc-block-id, if it's an alias
                     $bt = BlockType::getByHandle((string) $bx['type']);
                     if (!is_object($bt)) {
                         throw new \Exception(t('Invalid block type handle: %s', strval($bx['type'])));
                     }
                     $btc = $bt->getController();
                     $btc->import($page, (string) $ax['name'], $bx);
                 } else {
                     if ($bx['mc-block-id'] != '') {
                         // we find that block in the master collection block pool and alias it out
                         $bID = array_search((string) $bx['mc-block-id'], ContentImporter::getMasterCollectionTemporaryBlockIDs());
                         if ($bID) {
                             $mc = Page::getByID($page->getMasterCollectionID(), 'RECENT');
                             $block = Block::getByID($bID, $mc, (string) $ax['name']);
                             $block->alias($page);
                             if ($block->getBlockTypeHandle() == BLOCK_HANDLE_LAYOUT_PROXY) {
                                 // we have to go get the blocks on that page in this layout.
                                 $btc = $block->getController();
                                 $arLayout = $btc->getAreaLayoutObject();
                                 $columns = $arLayout->getAreaLayoutColumns();
                                 foreach ($columns as $column) {
                                     $area = $column->getAreaObject();
                                     $blocks = $area->getAreaBlocksArray($mc);
                                     foreach ($blocks as $_b) {
                                         $_b->alias($page);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (isset($ax->style)) {
             $area = \Area::get($page, (string) $ax['name']);
             $set = StyleSet::import($ax->style);
             $page->setCustomStyleSet($area, $set);
         }
     }
 }
예제 #2
0
 public function import($page, $arHandle, \SimpleXMLElement $blockNode)
 {
     $db = Database::connection();
     // handle the adodb stuff
     $args = $this->getImportData($blockNode, $page);
     $blockData = array();
     $bt = BlockType::getByHandle($this->btHandle);
     $b = $page->addBlock($bt, $arHandle, $args);
     $bName = (string) $blockNode['name'];
     $bFilename = (string) $blockNode['custom-template'];
     if ($bName) {
         $blockData['bName'] = $bName;
     }
     if ($bFilename) {
         $blockData['bFilename'] = $bFilename;
     }
     if (count($blockData)) {
         $b->updateBlockInformation($blockData);
     }
     if ($page->isMasterCollection() && $blockNode['mc-block-id'] != '') {
         ContentImporter::addMasterCollectionBlockID($b, (string) $blockNode['mc-block-id']);
     }
     // now we insert stuff that isn't part of the btTable
     // we have to do this this way because we need a bID
     $this->importAdditionalData($b, $blockNode);
     // now we handle the styles
     if (isset($blockNode->style)) {
         $set = StyleSet::import($blockNode->style);
         $b->setCustomStyleSet($set);
     }
     // now we handle block caching
     $cache = (int) $blockNode['cache-output'];
     if ($cache) {
         $b->setCustomCacheSettings(true, $blockNode['cache-output-on-post'], $blockNode['cache-output-for-registered-users'], $blockNode['cache-output-lifetime']);
     }
 }
예제 #3
0
 protected function importAdditionalData($b, $blockNode)
 {
     $controller = $b->getController();
     $arLayout = $controller->getAreaLayoutObject();
     $columns = $arLayout->getAreaLayoutColumns();
     $layoutArea = $b->getBlockAreaObject();
     $arLayout->setAreaObject($b->getBlockAreaObject());
     $page = $b->getBlockCollectionObject();
     $i = 0;
     foreach ($blockNode->arealayout->columns->column as $columnNode) {
         $column = $columns[$i];
         $as = new SubArea($column->getAreaLayoutColumnDisplayID(), $layoutArea->getAreaHandle(), $layoutArea->getAreaID());
         $as->load($page);
         $column->setAreaID($as->getAreaID());
         $area = $column->getAreaObject();
         if ($columnNode->style) {
             $set = StyleSet::import($columnNode->style);
             $page->setCustomStyleSet($area, $set);
         }
         foreach ($columnNode->block as $bx) {
             $bt = \BlockType::getByHandle($bx['type']);
             if (!is_object($bt)) {
                 throw new \Exception(t('Invalid block type handle: %s', strval($bx['type'])));
             }
             $btc = $bt->getController();
             $btc->import($page, $area->getAreaHandle(), $bx);
         }
         ++$i;
     }
 }
 /**
  * {@inheritDoc}
  */
 public function import(\SimpleXMLElement $node)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'import', array($node));
     return parent::import($node);
 }