public function execute(Batch $batch)
 {
     $values = $batch->getObjectCollection('tree');
     if (!$values) {
         return;
     }
     foreach ($values->getTrees() as $t) {
         $name = (string) $t->getName();
         $tree = Topic::getByName($name);
         if (is_object($tree)) {
             // We already have a tree. But we know we're going to have sub-nodes
             // of this tree in the import, so let's keep the same tree so that pointers
             // to attributes work, but let's clear it out.
             $root = $tree->getRootTreeNodeObject();
             $root->populateChildren();
             $children = $root->getChildNodes();
             foreach ($children as $child) {
                 $child->delete();
             }
         } else {
             $tree = Topic::add($name);
         }
         $parent = $tree->getRootTreeNodeObject();
         foreach ($t->getRootNodes() as $node) {
             $this->add($node, $parent);
         }
     }
 }
 /**
  * @param TopicsAttributeKey $source
  * @param CoreAttributeKey $destination
  */
 public function publish(AttributeKey $source, CoreAttributeKey $destination)
 {
     $controller = $destination->getController();
     $name = (string) $source->getTreeName();
     $tree = \Concrete\Core\Tree\Type\Topic::getByName($name);
     $node = $tree->getNodeByDisplayPath($source->getNodePath());
     $controller->setNodes($node->getTreeNodeID(), $tree->getTreeID());
 }
 public function topicTreeExists($name, $batch)
 {
     $tree = Topic::getByName($name);
     if (is_object($tree)) {
         return true;
     }
     $r = \ORM::entityManager()->getRepository('\\PortlandLabs\\Concrete5\\MigrationTool\\Entity\\Import\\Tree');
     $tree = $r->findOneByName($name);
     if (is_object($tree)) {
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
 public function submit()
 {
     $vs = Loader::helper('validation/strings');
     $sec = Loader::helper('security');
     $name = $sec->sanitizeString($this->post('topicTreeName'));
     if (!$this->token->validate('submit')) {
         $this->error->add(t($this->token->getErrorMessage()));
     }
     if (!$vs->notempty($name)) {
         $this->error->add(t('You must specify a valid name for your tree.'));
     }
     if (!PermissionKey::getByHandle('add_topic_tree')->validate()) {
         $this->error->add(t('You do not have permission to add this tree.'));
     }
     if (!$this->error->has()) {
         $tree = TopicTree::add($name);
         $this->redirect('/dashboard/system/attributes/topics', 'tree_added', $tree->getTreeID());
     }
 }
Exemplo n.º 5
0
 public function view($treeID = false)
 {
     $defaultTree = TopicTree::getDefault();
     $tree = TopicTree::getByID(Loader::helper('security')->sanitizeInt($treeID));
     if (!$tree) {
         $tree = $defaultTree;
     }
     $this->set('tree', $tree);
     $this->requireAsset('core/topics');
     $trees = array();
     if (is_object($defaultTree)) {
         $trees[] = $defaultTree;
         foreach (TopicTree::getList() as $ctree) {
             if ($ctree->getTreeID() != $defaultTree->getTreeID()) {
                 $trees[] = $ctree;
             }
         }
     }
     $this->set('trees', $trees);
 }
Exemplo n.º 6
0
 public function type_form()
 {
     $this->requireAsset('core/topics');
     $this->requireAsset('javascript', 'jquery/form');
     $this->load();
     $tt = new TopicTree();
     $defaultTree = $tt->getDefault();
     $topicTreeList = $tt->getList();
     $tree = $tt->getByID(Core::make('helper/security')->sanitizeInt($this->akTopicTreeID));
     if (!$tree) {
         $tree = $defaultTree;
     }
     $this->set('tree', $tree);
     $trees = array();
     if (is_object($defaultTree)) {
         $trees[] = $defaultTree;
         foreach ($topicTreeList as $ctree) {
             if ($ctree->getTreeID() != $defaultTree->getTreeID()) {
                 $trees[] = $ctree;
             }
         }
     }
     $this->set('trees', $trees);
     $this->set('parentNode', $this->akTopicParentNodeID);
 }
Exemplo n.º 7
0
 public function getImportData($blockNode, $page)
 {
     $args = array();
     $treeName = (string) $blockNode->data->tree;
     $page = (string) $blockNode->data->cParentID;
     $tree = Topic::getByName($treeName);
     $args['topicTreeID'] = $tree->getTreeID();
     $args['cParentID'] = 0;
     $args['title'] = (string) $blockNode->data->title;
     $args['mode'] = (string) $blockNode->data->mode;
     if (!$args['mode']) {
         $args['mode'] = 'S';
     }
     $args['topicAttributeKeyHandle'] = (string) $blockNode->data->topicAttributeKeyHandle;
     if ($page) {
         if (preg_match('/\\{ccm:export:page:(.*?)\\}/i', $page, $matches)) {
             $c = \Page::getByPath($matches[1]);
             $args['externalTarget'] = 1;
             $args['cParentID'] = $c->getCollectionID();
         }
     }
     return $args;
 }
 public function skipItem()
 {
     $tree = Topic::getByName($this->object->getName());
     return is_object($tree);
 }