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;
 }
Ejemplo n.º 4
0
 public function get($itemsToGet = 0, $offset = 0)
 {
     if ($this->getQuery() == '') {
         $this->setBaseQuery();
     }
     $stacks = array();
     $this->setItemsPerPage($itemsToGet);
     $r = DatabaseItemList::get($itemsToGet, $offset);
     foreach ($r as $row) {
         $s = Stack::getByID($row['cID'], 'RECENT');
         $stacks[] = $s;
     }
     return $stacks;
 }
 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());
                 }
             }
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * @param Stack $stack
  *
  * @return bool
  */
 protected static function isValidStack($stack)
 {
     return $stack->getPageTypeHandle() == STACKS_PAGE_TYPE;
 }
Ejemplo n.º 8
0
 /**
  * Get the stack object.
  *
  * @return null|\Concrete\Core\Page\Stack\Stack
  */
 public function getStackObject()
 {
     if ($this->stack_id > 0) {
         return Stack::getById($this->stack_id);
     }
 }
Ejemplo n.º 9
0
 /**
  * @param string $stackName
  * @param int    $type
  *
  * @return Page
  */
 public static function addStack($stackName, $type = 0, $multilingualStackToReturn = self::MULTILINGUAL_CONTENT_SOURCE_CURRENT)
 {
     $return = false;
     $db = \Database::connection();
     if (Core::make('multilingual/detector')->isEnabled()) {
         $returnFromSection = Stack::getMultilingualSectionFromType($multilingualStackToReturn);
         $list = Section::getList();
         foreach ($list as $section) {
             $cID = $db->GetOne('select cID from Stacks where stName = ? and stMultilingualSection = ?', array($stackName, $section->getCollectionID()));
             if (!$cID) {
                 $category = StackCategory::getCategoryFromMultilingualSection($section);
                 if (!is_object($category)) {
                     $category = StackCategory::createFromMultilingualSection($section);
                 }
                 $stack = Stack::addStackToCategory($category->getPage(), $stackName, $type);
                 if (is_object($returnFromSection) && $returnFromSection->getCollectionID() == $section->getCollectionID()) {
                     $return = $stack;
                 }
             }
         }
         StackList::rescanMultilingualStacks();
     } else {
         $parent = \Page::getByPath(STACKS_PAGE_PATH);
         $return = Stack::addStackToCategory($parent, $stackName, $type);
     }
     return $return;
 }
Ejemplo n.º 10
0
 /**
  * @param $queryRow
  *
  * @return \Stack
  */
 public function getResult($queryRow)
 {
     $stack = Stack::getByID($queryRow['cID'], 'ACTIVE');
     return $stack ?: parent::getResult($queryRow);
 }
Ejemplo n.º 11
0
 public function setPropertiesFromArray($arr)
 {
     return parent::setPropertiesFromArray($arr);
 }
Ejemplo n.º 12
0
 protected function _duplicateAll($cParent, $cNewParent, $preserveUserID = false, Site $site = null)
 {
     $db = Database::connection();
     $cID = $cParent->getCollectionID();
     $q = 'select cID, ptHandle from Pages p left join PageTypes pt on p.ptID = pt.ptID where cParentID = ? order by cDisplayOrder asc';
     $r = $db->executeQuery($q, [$cID]);
     if ($r) {
         while ($row = $r->fetchRow()) {
             // This is a terrible hack.
             if ($row['ptHandle'] === STACKS_PAGE_TYPE) {
                 $tc = Stack::getByID($row['cID']);
             } else {
                 $tc = self::getByID($row['cID']);
             }
             $nc = $tc->duplicate($cNewParent, $preserveUserID, $site);
             $tc->_duplicateAll($tc, $nc, $preserveUserID, $site);
         }
     }
 }