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 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()); } } } } }