コード例 #1
0
 public function execute(Batch $batch)
 {
     $this->batch = $batch;
     $stacks = $batch->getObjectCollection('stack');
     if (!$stacks) {
         return;
     }
     foreach ($stacks->getStacks() as $stack) {
         if (!$stack->getPublisherValidator()->skipItem()) {
             $s = Stack::getByName($stack->getName());
             if (is_object($s)) {
                 foreach ($stack->getBlocks() as $block) {
                     $bt = $this->getTargetItem('block_type', $block->getType());
                     if (is_object($bt)) {
                         $value = $block->getBlockValue();
                         $publisher = $value->getPublisher();
                         $area = new Area();
                         $area->setName(STACKS_AREA_NAME);
                         $b = $publisher->publish($batch, $bt, $s, $area, $value);
                         $styleSet = $block->getStyleSet();
                         if (is_object($styleSet)) {
                             $styleSetPublisher = $styleSet->getPublisher();
                             $publishedStyleSet = $styleSetPublisher->publish();
                             $b->setCustomStyleSet($publishedStyleSet);
                         }
                         if ($block->getCustomTemplate()) {
                             $b->setCustomTemplate($block->getCustomTemplate());
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
 public function publish(Batch $batch, BlockType $bt, Page $page, Area $area, BlockValue $value)
 {
     $data = array();
     $data['slID'] = array();
     $records = $value->getRecords();
     foreach ($records as $record) {
         $value = $record->getData();
         $value = $value['service'];
         // because it comes out as an array
         $socialLink = Link::getByServiceHandle($value);
         if (is_object($socialLink)) {
             $data['slID'][] = $socialLink->getID();
         }
     }
     $b = $page->addBlock($bt, $area->getName(), $data);
     return $b;
 }
コード例 #3
0
 public function publish(Batch $batch, BlockType $bt, Page $page, Area $area, BlockValue $value)
 {
     $routine = new PublishPageContentRoutine();
     $routine->setBatch($batch);
     /* @var $value AreaLayoutBlockValue */
     $layout = $value->getAreaLayout();
     $publisher = $layout->getPublisher();
     $layoutObject = $publisher->publish($layout);
     $columns = $layout->getColumns();
     $i = 0;
     $layoutBlock = $page->addBlock($bt, $area->getName(), array('arLayoutID' => $layoutObject->getAreaLayoutID()));
     foreach ($layoutObject->getAreaLayoutColumns() as $columnObject) {
         $column = $columns[$i];
         foreach ($column->getBlocks() as $block) {
             $subValue = $block->getBlockValue();
             $publisher = $subValue->getPublisher();
             $subarea = new Area();
             $subAreaName = $area->getName() . SubArea::AREA_SUB_DELIMITER . $columnObject->getAreaLayoutColumnDisplayID();
             $subarea->setName($subAreaName);
             /*
              * @var $publisher BlockPublisherInterface
              */
             $subBlockType = $routine->getTargetItem('block_type', $block->getType());
             if (is_object($subBlockType)) {
                 $b = $publisher->publish($batch, $subBlockType, $page, $subarea, $subValue);
                 $styleSet = $block->getStyleSet();
                 if (is_object($styleSet)) {
                     $styleSetPublisher = $styleSet->getPublisher();
                     $publishedStyleSet = $styleSetPublisher->publish();
                     $b->setCustomStyleSet($publishedStyleSet);
                 }
                 if ($block->getCustomTemplate()) {
                     $b->setCustomTemplate($block->getCustomTemplate());
                 }
             }
         }
         ++$i;
     }
     return $layoutBlock;
 }
コード例 #4
0
 public function publish(Batch $batch, BlockType $bt, Page $page, Area $area, BlockValue $value)
 {
     $records = $value->getRecords();
     $inspector = \Core::make('import/value_inspector');
     if (count($records) == 1) {
         $data = array();
         foreach ($records[0]->getData() as $key => $value) {
             $result = $inspector->inspect($value);
             $data[$key] = $result->getReplacedValue();
         }
         $b = $page->addBlock($bt, $area->getName(), $data);
     } elseif (count($records) > 1) {
         foreach ($records as $record) {
             if (strcasecmp($record->getTable(), $bt->getController()->getBlockTypeDatabaseTable()) == 0) {
                 // This is the data record.
                 $data = array();
                 foreach ($record->getData() as $key => $value) {
                     $result = $inspector->inspect($value);
                     $data[$key] = $result->getReplacedValue();
                 }
                 $b = $page->addBlock($bt, $area->getName(), $data);
             }
         }
         // Now we import the OTHER records.
         foreach ($records as $record) {
             if (strcasecmp($record->getTable(), $bt->getController()->getBlockTypeDatabaseTable()) != 0) {
                 $aar = new BlockRecord($record->getTable());
                 $aar->bID = $b->getBlockID();
                 foreach ($record->getData() as $key => $value) {
                     $result = $inspector->inspect($value);
                     $aar->{$key} = $result->getReplacedValue();
                 }
                 $aar->Save();
             }
         }
     } else {
         $b = $page->addBlock($bt, $area->getName(), array());
     }
     return $b;
 }
コード例 #5
0
 private function parseArea($node)
 {
     $area = new Area();
     $area->setName('Main');
     $block = $this->parseBlocks($node);
     $block->setArea($area);
     $area->blocks->add($block);
     return $area;
 }
コード例 #6
0
 protected function parseArea($node)
 {
     $area = new Area();
     $area->setName((string) $node['name']);
     if (isset($node->style)) {
         $styleSet = $this->styleSetImporter->import($node->style);
         $area->setStyleSet($styleSet);
     }
     // Parse areas
     $nodes = false;
     if ($node->blocks->block) {
         $nodes = $node->blocks->block;
     } elseif ($node->block) {
         // 5.6
         $nodes = $node->block;
     }
     if ($nodes) {
         $i = 0;
         foreach ($nodes as $blockNode) {
             if ($blockNode['type']) {
                 $block = $this->parseBlock($blockNode);
             } elseif ($blockNode['mc-block-id'] != '') {
                 $block = new Block();
                 $block->setDefaultsOutputIdentifier((string) $blockNode['mc-block-id']);
             }
             if (isset($block)) {
                 $block->setPosition($i);
                 $block->setArea($area);
                 $area->blocks->add($block);
                 ++$i;
             }
         }
     }
     return $area;
 }
コード例 #7
0
 public function publish(Batch $batch, BlockType $bt, Page $page, Area $area, BlockValue $value)
 {
     $btc = $bt->getController();
     $bx = simplexml_load_string($value->getValue());
     return $btc->import($page, $area->getName(), $bx);
 }