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);
         }
     }
 }
 public function execute(Batch $batch)
 {
     $keys = $batch->getObjectCollection('attribute_key');
     /**
      * @var AttributeKey
      */
     if (!$keys) {
         return;
     }
     foreach ($keys->getKeys() as $key) {
         if (!$key->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($key->getPackage()) {
                 $pkg = \Package::getByHandle($key->getPackage());
             }
             $category = $key->getCategory();
             if (is_object($category)) {
                 $publisher = $category->getPublisher();
                 $o = $publisher->publish($key, $pkg);
                 $typePublisher = $key->getTypePublisher();
                 if (is_object($typePublisher)) {
                     $typePublisher->publish($key, $o);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 public function getItems(Batch $batch)
 {
     $users = array();
     foreach ($batch->getPages() as $page) {
         if ($page->getUser() && !in_array($page->getUser(), $users)) {
             $users[] = $page->getUser();
         }
     }
     $pageTypes = $batch->getObjectCollection('page_type');
     if (is_object($pageTypes)) {
         foreach ($pageTypes->getTypes() as $type) {
             $defaults = $type->getDefaultPageCollection();
             foreach ($defaults->getPages() as $page) {
                 if ($page->getUser() && !in_array($page->getUser(), $users)) {
                     $users[] = $page->getUser();
                 }
             }
         }
     }
     $items = array();
     foreach ($users as $user) {
         $item = new Item();
         $item->setIdentifier($user);
         $items[] = $item;
     }
     return $items;
 }
Ejemplo n.º 4
0
 public function transform($entity, ItemInterface $item, TargetItem $targetItem, Batch $batch)
 {
     $mapper = new \PortlandLabs\Concrete5\MigrationTool\Batch\ContentMapper\Type\Attribute();
     $ak = $mapper->getTargetItemContentObject($targetItem);
     if (is_object($ak)) {
         $type = $ak->getAttributeKeyType()->getAttributeTypeHandle();
     } else {
         $collection = $batch->getObjectCollection('attribute_key');
         foreach ($collection->getKeys() as $key) {
             if ($key->getHandle() == $item->getIdentifier()) {
                 $type = $key->getType();
                 break;
             }
         }
     }
     if (isset($type)) {
         $manager = \Core::make('migration/manager/import/attribute/value');
         try {
             $driver = $manager->driver($type);
         } catch (\Exception $e) {
         }
         if (isset($driver)) {
             $xml = simplexml_load_string($entity->getValue());
             $value = $driver->parse($xml);
             $attribute = $entity->getAttribute();
             $attribute->setAttributeValue($value);
             $manager = \ORM::entityManager('migration_tools');
             $manager->persist($attribute);
             $manager->remove($entity);
             $manager->flush();
         }
     }
 }
 public function execute(Batch $batch)
 {
     $inspector = \Core::make('import/value_inspector');
     $feeds = $batch->getObjectCollection('page_feed');
     if (!$feeds) {
         return;
     }
     foreach ($feeds->getFeeds() as $feed) {
         if (!$feed->getPublisherValidator()->skipItem()) {
             $f = new Feed();
             $parentID = intval($inspector->inspect($feed->getParent())->getReplacedValue());
             $pageType = intval($inspector->inspect($feed->getPageType())->getReplacedValue());
             $f->setTitle($feed->getTitle());
             $f->setHandle($feed->getHandle());
             $f->setDescription($feed->getDescription());
             $f->setParentID($parentID);
             $f->setPageTypeID($pageType);
             $f->setIncludeAllDescendents($feed->getIncludeAllDescendants());
             $f->setDisplayFeaturedOnly($feed->getDisplayFeaturedOnly());
             $f->setDisplayAliases($feed->getDisplayAliases());
             if ($feed->getContentType() == 'description') {
                 $f->displayShortDescriptionContent();
             } else {
                 $f->displayAreaContent($feed->getContentTypeArea());
             }
             $f->save();
         }
     }
 }
 public function execute(Batch $batch)
 {
     $sets = $batch->getObjectCollection('attribute_set');
     if (!$sets) {
         return;
     }
     foreach ($sets->getSets() as $set) {
         $akc = Category::getByHandle($set->getCategory());
         if (!$set->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($set->getPackage()) {
                 $pkg = \Package::getByHandle($set->getPackage());
             }
             $setObject = $akc->addSet($set->getHandle(), $set->getName(), $pkg, intval($set->getIsLocked()));
         } else {
             $setObject = \Concrete\Core\Attribute\Set::getByHandle($set->getHandle());
         }
         if (is_object($setObject)) {
             $attributes = $set->getAttributes();
             foreach ($attributes as $handle) {
                 $ak = $akc->getAttributeKeyByHandle($handle);
                 if (is_object($ak)) {
                     $setObject->addKey($ak);
                 }
             }
         }
     }
 }
 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 execute(Batch $batch)
 {
     // Has the batch already been created? If so, we move to trash.
     $orphaned = \Page::getByPath('/!import_batches/' . $batch->getID());
     if (is_object($orphaned) && !$orphaned->isError()) {
         $orphaned->moveToTrash();
     }
 }
 public function execute(Batch $batch)
 {
     $this->batch = $batch;
     // First, create the top level page for the batch.
     $batches = \Page::getByPath('/!import_batches');
     $type = Type::getByHandle('import_batch');
     $batchParent = $batches->add($type, array('cName' => $batch->getID(), 'cHandle' => $batch->getID(), 'pkgID' => \Package::getByHandle('migration_tool')->getPackageID()));
     $pages = $this->getPagesOrderedForImport($batch);
     if (!$pages) {
         return;
     }
     // Now loop through all pages, and build them
     foreach ($pages as $page) {
         $data = array();
         $ui = $this->getTargetItem('user', $page->getUser());
         if ($ui != '') {
             $data['uID'] = $ui->getUserID();
         } else {
             $data['uID'] = USER_SUPER_ID;
         }
         $cDatePublic = $page->getPublicDate();
         if ($cDatePublic) {
             $data['cDatePublic'] = $cDatePublic;
         }
         $type = $this->getTargetItem('page_type', $page->getType());
         if ($type) {
             $data['ptID'] = $type->getPageTypeID();
         }
         $template = $this->getTargetItem('page_template', $page->getTemplate());
         if (is_object($template)) {
             $data['pTemplateID'] = $template->getPageTemplateID();
         }
         if ($page->getPackage()) {
             $pkg = \Package::getByHandle($page->getPackage());
             if (is_object($pkg)) {
                 $data['pkgID'] = $pkg->getPackageID();
             }
         }
         // TODO exception if parent not found
         if ($page->getBatchPath() != '') {
             $lastSlash = strrpos($page->getBatchPath(), '/');
             $parentPath = substr($page->getBatchPath(), 0, $lastSlash);
             $data['cHandle'] = substr($page->getBatchPath(), $lastSlash + 1);
             if (!$parentPath) {
                 $parent = $batchParent;
             } else {
                 $parent = \Page::getByPath('/!import_batches/' . $this->batch->getID() . $parentPath);
             }
         } else {
             $parent = $batchParent;
         }
         $data['name'] = $page->getName();
         $data['cDescription'] = $page->getDescription();
         $parent->add($type, $data);
     }
 }
 public function itemExists(ItemInterface $item, Batch $batch)
 {
     if (is_object($item->getContentObject())) {
         return true;
     }
     foreach ($batch->getPages() as $page) {
         if ($page->getBatchPath() == $item->getReference()) {
             return true;
         }
     }
 }
 public function execute(Batch $batch)
 {
     $words = $batch->getObjectCollection('banned_word');
     if (!$words) {
         return;
     }
     foreach ($words->getWords() as $word) {
         if (!$word->getPublisherValidator()->skipItem()) {
             BannedWord::add(str_rot13($word->getWord()));
         }
     }
 }
 public function itemExists(ItemInterface $item, Batch $batch)
 {
     if (is_object($item->getContentObject())) {
         return true;
     }
     $feeds = $batch->getObjectCollection('page_feed');
     foreach ($feeds->getFeeds() as $feed) {
         if ($feed->getHandle() == $item->getReference()) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 13
0
 public function add_batch()
 {
     if (!$this->token->validate('add_batch')) {
         $this->error->add($this->token->getErrorMessage());
     }
     if (!$this->error->has()) {
         $batch = new Batch();
         $batch->setNotes($this->request->request->get('notes'));
         $this->entityManager->persist($batch);
         $this->entityManager->flush();
         $this->flash('success', t('Batch added successfully.'));
         $this->redirect('/dashboard/system/migration/import', 'view_batch', $batch->getId());
     }
     $this->view();
 }
 public function execute(Batch $batch)
 {
     $links = $batch->getObjectCollection('social_link');
     if (!$links) {
         return;
     }
     foreach ($links->getLinks() as $link) {
         if (!$link->getPublisherValidator()->skipItem()) {
             $l = new Link();
             $l->setServiceHandle($link->getService());
             $l->setURL($link->getURL());
             $l->save();
         }
     }
 }
 public function execute(Batch $batch)
 {
     $packages = $batch->getObjectCollection('package');
     if (!$packages) {
         return;
     }
     foreach ($packages->getPackages() as $package) {
         if (!$package->getPublisherValidator()->skipItem()) {
             $pkg = \Package::getClass($package->getHandle());
             if (!$pkg->isPackageInstalled()) {
                 $pkg->install();
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $types = $batch->getObjectCollection('workflow_progress_category');
     if (!$types) {
         return;
     }
     foreach ($types->getCategories() as $category) {
         if (!$category->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($category->getPackage()) {
                 $pkg = \Package::getByHandle($category->getPackage());
             }
             \Concrete\Core\Workflow\Progress\Category::add($category->getHandle(), $pkg);
         }
     }
 }
 public function execute(Batch $batch)
 {
     $categories = $batch->getObjectCollection('permission_key_category');
     if (!$categories) {
         return;
     }
     foreach ($categories->getCategories() as $category) {
         if (!$category->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($category->getPackage()) {
                 $pkg = \Package::getByHandle($category->getPackage());
             }
             Category::add($category->getHandle(), $pkg);
         }
     }
 }
 public function execute(Batch $batch)
 {
     $types = $batch->getObjectCollection('page_type_publish_target_type');
     if (!$types) {
         return;
     }
     foreach ($types->getTypes() as $type) {
         if (!$type->getPublisherValidator()->skipItem()) {
             $pkg = false;
             if ($type->getPackage()) {
                 $pkg = \Package::getByHandle($type->getPackage());
             }
             Type::add($type->getHandle(), $type->getName(), $pkg);
         }
     }
 }
 public function execute(Batch $batch)
 {
     $templates = $batch->getObjectCollection('page_template');
     if (!$templates) {
         return;
     }
     foreach ($templates->getTemplates() as $template) {
         if (!$template->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($template->getPackage()) {
                 $pkg = \Package::getByHandle($template->getPackage());
             }
             Template::add($template->getHandle(), $template->getName(), $template->getIcon(), $pkg, $template->getIsInternal());
         }
     }
 }
Ejemplo n.º 20
0
 public function getBatchTargetItems(Batch $batch)
 {
     $collection = $batch->getObjectCollection('page_type');
     $items = array();
     if ($collection) {
         foreach ($collection->getTypes() as $type) {
             if (!$type->getPublisherValidator()->skipItem()) {
                 $item = new TargetItem($this);
                 $item->setItemId($type->getHandle());
                 $item->setItemName($type->getName());
                 $items[] = $item;
             }
         }
     }
     return $items;
 }
 public function execute(Batch $batch)
 {
     $themes = $batch->getObjectCollection('theme');
     if (!$themes) {
         return;
     }
     foreach ($themes->getThemes() as $theme) {
         if (!$theme->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($theme->getPackage()) {
                 $pkg = \Package::getByHandle($theme->getPackage());
             }
             $t = Theme::add($theme->getHandle(), $pkg);
             if ($theme->getIsActivated()) {
                 $t->applyToSite();
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $snippets = $batch->getObjectCollection('content_editor_snippet');
     if (!$snippets) {
         return;
     }
     foreach ($snippets->getSnippets() as $snippet) {
         if (!$snippet->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($snippet->getPackage()) {
                 $pkg = \Package::getByHandle($snippet->getPackage());
             }
             $t = Snippet::add($snippet->getHandle(), $snippet->getNAme(), $pkg);
             if ($snippet->getIsActivated()) {
                 $t->activate();
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $libraries = $batch->getObjectCollection('captcha_library');
     if (!$libraries) {
         return;
     }
     foreach ($libraries->getLibraries() as $library) {
         if (!$library->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($library->getPackage()) {
                 $pkg = \Package::getByHandle($library->getPackage());
             }
             $l = Library::add($library->getHandle(), $library->getName(), $pkg);
             if ($library->getIsActivated()) {
                 $l->activate();
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $editors = $batch->getObjectCollection('conversation_editor');
     if ($editors) {
         foreach ($editors->getEditors() as $editor) {
             if (!$editor->getPublisherValidator()->skipItem()) {
                 $pkg = null;
                 if ($editor->getPackage()) {
                     $pkg = \Package::getByHandle($editor->getPackage());
                 }
                 $ce = Editor::add($editor->getHandle(), $editor->getName(), $pkg);
                 if ($editor->getIsActive()) {
                     $ce->activate();
                 }
             }
         }
     }
     $types = $batch->getObjectCollection('conversation_flag_type');
     if ($types) {
         foreach ($types->getTypes() as $type) {
             if (!$type->getPublisherValidator()->skipItem()) {
                 $pkg = null;
                 if ($type->getPackage()) {
                     $pkg = \Package::getByHandle($type->getPackage());
                 }
                 $ce = \Concrete\Core\Conversation\FlagType\FlagType::add($type->getHandle());
             }
         }
     }
     $types = $batch->getObjectCollection('conversation_rating_type');
     if ($types) {
         foreach ($types->getTypes() as $type) {
             if (!$type->getPublisherValidator()->skipItem()) {
                 $pkg = null;
                 if ($type->getPackage()) {
                     $pkg = \Package::getByHandle($type->getPackage());
                 }
                 \Concrete\Core\Conversation\Rating\Type::add($type->getHandle(), $type->getName(), $type->getPoints(), $pkg);
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $types = $batch->getObjectCollection('page_type');
     /**
      * @var \PortlandLabs\Concrete5\MigrationTool\Entity\Import\PageType\PageType
      */
     if (!$types) {
         return;
     }
     foreach ($types->getTypes() as $type) {
         if (!$type->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($type->getPackage()) {
                 $pkg = \Package::getByHandle($type->getPackage());
             }
             $defaultTemplate = Template::getByHandle($type->getDefaultTemplate());
             $templates = array();
             if ($type->getAllowedTemplates() == 'C' || $type->getAllowedTemplates() == 'X') {
                 foreach ($type->getTemplates() as $templateHandle) {
                     $templates[] = Template::getByHandle($templateHandle);
                 }
             }
             $data = array('handle' => $type->getHandle(), 'name' => $type->getName(), 'defaultTemplate' => $defaultTemplate, 'allowedtempates' => $type->getAllowedTemplates(), 'internal' => $type->getIsInternal(), 'ptLaunchInComposer' => $type->getLaunchInComposer(), 'ptIsFrequentlyAdded' => $type->getIsFrequentlyAdded(), 'templates' => $templates);
             $pageType = \Concrete\Core\Page\Type\Type::add($data, $pkg);
             foreach ($type->getLayoutSets() as $set) {
                 $layoutSet = $pageType->addPageTypeComposerFormLayoutSet($set->getName(), $set->getDescription());
                 /**
                  * @var \PortlandLabs\Concrete5\MigrationTool\Entity\Import\PageType\ComposerFormLayoutSetControl
                  */
                 foreach ($set->getControls() as $controlEntity) {
                     $controlType = \Concrete\Core\Page\Type\Composer\Control\Type\Type::getByHandle($controlEntity->getHandle());
                     $control = $controlType->configureFromImportHandle($controlEntity->getItemIdentifier());
                     $setControl = $control->addToPageTypeComposerFormLayoutSet($layoutSet, true);
                     $setControl->updateFormLayoutSetControlRequired($controlEntity->getIsRequired());
                     $setControl->updateFormLayoutSetControlCustomTemplate($controlEntity->getCustomTemplate());
                     $setControl->updateFormLayoutSetControlCustomTemplate($controlEntity->getCustomLabel());
                     $setControl->updateFormLayoutSetControlDescription($controlEntity->getDescription());
                 }
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $values = $batch->getObjectCollection('config_value');
     if (!$values) {
         return;
     }
     foreach ($values->getValues() as $value) {
         if (!$value->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($value->getPackage()) {
                 $pkg = \Package::getByHandle($value->getPackage());
             }
             if (is_object($pkg)) {
                 \Config::save($pkg->getPackageHandle() . '::' . $value->getConfigKey(), $value->getConfigValue());
             } else {
                 \Config::save($value->getConfigKey(), $value->getConfigValue());
             }
         }
     }
 }
 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());
                 }
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $types = $batch->getObjectCollection('block_type');
     if (!$types) {
         return;
     }
     foreach ($types->getTypes() as $type) {
         if (!$type->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($type->getPackage()) {
                 $pkg = \Package::getByHandle($type->getPackage());
             }
             if (is_object($pkg)) {
                 BlockType::installBlockTypeFromPackage($type->getHandle(), $pkg);
             } else {
                 BlockType::installBlockType($type->getHandle());
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $types = $batch->getObjectCollection('thumbnail_type');
     if (!$types) {
         return;
     }
     foreach ($types->getTypes() as $type) {
         if (!$type->getPublisherValidator()->skipItem()) {
             $t = new \Concrete\Core\File\Image\Thumbnail\Type\Type();
             $t->setName($type->getName());
             $t->setHandle($type->getHandle());
             $t->setWidth($type->getWidth());
             $t->setHeight($type->getHeight());
             if ($type->getIsRequired()) {
                 $t->requireType();
             }
             $t->save();
         }
     }
 }
 public function execute(Batch $batch)
 {
     $jobs = $batch->getObjectCollection('job');
     if (!$jobs) {
         return;
     }
     foreach ($jobs->getJobs() as $job) {
         if (!$job->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($job->getPackage()) {
                 $pkg = \Package::getByHandle($job->getPackage());
             }
             if (is_object($pkg)) {
                 Job::installByPackage($job->getHandle(), $pkg);
             } else {
                 Job::installByHandle($job->getHandle());
             }
         }
     }
 }