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()); } } } } } } }
public function import(\SimpleXMLElement $sx) { $folderService = new FolderService(\Core::make('app'), \Database::connection()); $siteTree = null; if (isset($this->home)) { $siteTree = $this->home->getSiteTreeObject(); } if (isset($sx->stacks)) { $nodes = array(); $i = 0; foreach ($sx->stacks->children() as $p) { $p->originalPos = $i; $nodes[] = $p; ++$i; } usort($nodes, array('static', 'setupPageNodeOrder')); foreach ($nodes as $p) { $parent = null; $path = (string) $p['path']; if ($p->getName() == 'folder') { $type = 'folder'; } else { $type = (string) $p['type']; } $name = (string) $p['name']; if ($path) { $lastSlash = strrpos($path, '/'); $parentPath = substr($path, 0, $lastSlash); if ($parentPath) { $parent = $folderService->getByPath($parentPath); } } switch ($type) { case 'folder': $folder = $folderService->getByPath($path); if (!is_object($folder)) { $folderService->add($name, $parent); } break; case 'global_area': $s = Stack::getByName($name, 'RECENT', $siteTree); if (!is_object($s)) { Stack::addGlobalArea($name, $siteTree); } break; default: //stack $s = Stack::getByPath($path, 'RECENT', $siteTree); if (!is_object($s)) { Stack::addStack($name, $parent); } } } } }
public function skipItem() { $stack = Stack::getByName($this->object->getName()); if (is_object($stack)) { $blocks = $stack->getBlocks(); if (count($blocks)) { return true; } } return false; }
public static function export(\SimpleXMLElement $x) { $db = Loader::db(); $r = $db->Execute('select stName, cID, stType from Stacks order by stName asc'); if ($r->NumRows()) { $gas = $x->addChild('stacks'); while ($row = $r->FetchRow()) { $stack = Stack::getByName($row['stName']); if (is_object($stack)) { $stack->export($gas); } } } }
public function import(\SimpleXMLElement $sx) { $siteTree = null; if (isset($this->home)) { $siteTree = $this->home->getSiteTreeObject(); } if (isset($sx->stacks)) { foreach ($sx->stacks->stack as $p) { $path = (string) $p['path']; if ($path) { $stack = Stack::getByPath($path, 'RECENT', $siteTree); } else { $stack = Stack::getByName((string) $p['name'], 'RECENT', $siteTree); } if (isset($p->area)) { $this->importPageAreas($stack, $p); } } } }
public function execute(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)) { if ($stack->getType()) { $type = Stack::mapImportTextToType($stack->getType()); Stack::addStack($stack->getName(), $type); } else { Stack::addStack($stack->getName()); } } } } }