public function up(Schema $schema) { $type = Type::getByHandle(STACK_CATEGORY_PAGE_TYPE); if (!is_object($type)) { Type::add(array('internal' => true, 'name' => 'Stack Category', 'handle' => STACK_CATEGORY_PAGE_TYPE)); } }
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()); } } } } }
protected function installPagetypes($pkg) { $type = Type::getByHandle('import_batch'); if (!is_object($type)) { Type::add(array('internal' => true, 'name' => 'Import Batch', 'handle' => 'import_batch')); } }
protected function installDesktops() { $this->output(t('Installing Desktops...')); $template = Template::getByHandle('desktop'); if (!is_object($template)) { Template::add('desktop', t('Desktop'), FILENAME_PAGE_TEMPLATE_DEFAULT_ICON, null, true); } $type = \Concrete\Core\Page\Type\Type::getByHandle('core_desktop'); if (!is_object($type)) { \Concrete\Core\Page\Type\Type::add(array('handle' => 'core_desktop', 'name' => 'Desktop', 'internal' => true)); } $category = Category::getByHandle('collection')->getController(); $attribute = CollectionKey::getByHandle('is_desktop'); if (!is_object($attribute)) { $key = new PageKey(); $key->setAttributeKeyHandle('is_desktop'); $key->setAttributeKeyName('Is Desktop'); $key->setIsAttributeKeyInternal(true); $category->add('boolean', $key); } $attribute = CollectionKey::getByHandle('desktop_priority'); if (!is_object($attribute)) { $key = new PageKey(); $key->setAttributeKeyHandle('desktop_priority'); $key->setAttributeKeyName('Desktop Priority'); $key->setIsAttributeKeyInternal(true); $category->add('number', $key); } $desktop = Page::getByPath('/dashboard/welcome'); if (is_object($desktop) && !$desktop->isError()) { $desktop->moveToTrash(); } $desktop = Page::getByPath('/desktop'); if (is_object($desktop) && !$desktop->isError()) { $desktop->moveToTrash(); } $page = \Page::getByPath("/account/messages"); if (is_object($page) && !$page->isError()) { $page->moveToTrash(); } // Private Messages tweak SinglePage::add('/account/messages'); $ci = new ContentImporter(); $ci->importContentFile(DIR_BASE_CORE . '/config/install/upgrade/desktops.xml'); $desktop = Page::getByPath('/dashboard/welcome'); $desktop->movePageDisplayOrderToTop(); \Config::save('concrete.misc.login_redirect', 'DESKTOP'); }
public function add_blog_page($pkg) { /* * Add new Post template */ //$tmplt = Template::add('pb_post', 'ProBlog Post', 'right_sidebar.png', $pkg); $tmplt = Template::getByHandle('right_sidebar'); /* * Add new Post Page Type using new Template */ $setBlogAt = Page::getByPath('/blog'); $type = CollectionType::add(array('handle' => 'pb_post', 'name' => 'ProBlog Post', 'defaultTemplate' => $tmplt, 'allowedTemplates' => 'C', 'templates' => array($tmplt), 'ptLaunchInComposer' => 1, 'ptIsFrequentlyAdded' => 1), $pkg); /* * Add our new blog_section PublishTarget Type */ $pt_target = PublishTarget::add('blog_section', 'Choose From Blog Section Pages', $pkg); $configuration = new BlogSectionConfiguration($pt_target); /* * Set Post Page Type to use Parent Page Configuration */ $type->setConfiguredPageTypePublishTargetObject($configuration); /* * Create Post Page Type Form Layout Sets */ $info = $type->addPageTypeComposerFormLayoutSet('General Info', 'Basic Blog Post Information'); $post = $type->addPageTypeComposerFormLayoutSet('Post Content', 'Your Post Content'); $metas = $type->addPageTypeComposerFormLayoutSet('Post Metas', 'Your Post Meta Data'); $options = $type->addPageTypeComposerFormLayoutSet('Post Options', 'Your Post Options'); /* * Create Post Page Type Form Layout Controls */ $core_att_controls = PageTypeComposerControlType::getByHandle('core_page_property'); $page_att_controls = PageTypeComposerControlType::getByHandle('collection_attribute'); $block_controls = PageTypeComposerControlType::getByHandle('block'); /* * ++++++++++++++++++++++ * Info Tab * ++++++++++++++++++++++ */ /* Post Title */ $name = $core_att_controls->getPageTypeComposerControlByIdentifier('name'); $name->setPageTypeComposerControlName(t('Post Title')); $name->addToPageTypeComposerFormLayoutSet($info); /* Post Slug */ $slug = $core_att_controls->getPageTypeComposerControlByIdentifier('url_slug'); $slug->setPageTypeComposerControlName(t('Post Slug')); $slug->addToPageTypeComposerFormLayoutSet($info); /* Post Author */ $control_id = CollectionAttributeKey::getByHandle('blog_author')->getAttributeKeyID(); $blog_author = $page_att_controls->getPageTypeComposerControlByIdentifier($control_id); $blog_author->addToPageTypeComposerFormLayoutSet($info); /* Post Thumbnail */ $control_id = CollectionAttributeKey::getByHandle('thumbnail')->getAttributeKeyID(); $thumbnail = $page_att_controls->getPageTypeComposerControlByIdentifier($control_id); $thumbnail->addToPageTypeComposerFormLayoutSet($info); /* Post Description */ $description = $core_att_controls->getPageTypeComposerControlByIdentifier('description'); $description->addToPageTypeComposerFormLayoutSet($info); /* * ++++++++++++++++++++++ * Post Tab * ++++++++++++++++++++++ */ /* Event Content */ $control_id = BlockType::getByHandle('content')->getBlockTypeID(); $post_content = $block_controls->getPageTypeComposerControlByIdentifier($control_id); $post_content->addToPageTypeComposerFormLayoutSet($post); /* * ++++++++++++++++++++++ * Metas Tab * ++++++++++++++++++++++ */ /* Meta Title */ $control_id = CollectionAttributeKey::getByHandle('meta_title')->getAttributeKeyID(); $meta_title = $page_att_controls->getPageTypeComposerControlByIdentifier($control_id); $meta_title->addToPageTypeComposerFormLayoutSet($metas); /* Meta Description */ $control_id = CollectionAttributeKey::getByHandle('meta_description')->getAttributeKeyID(); $meta_description = $page_att_controls->getPageTypeComposerControlByIdentifier($control_id); $meta_description->addToPageTypeComposerFormLayoutSet($metas); /* Meta Keywords */ $control_id = CollectionAttributeKey::getByHandle('meta_keywords')->getAttributeKeyID(); $meta_keywords = $page_att_controls->getPageTypeComposerControlByIdentifier($control_id); $meta_keywords->addToPageTypeComposerFormLayoutSet($metas); /* * ++++++++++++++++++++++ * Options Tab * ++++++++++++++++++++++ */ /* Post Location */ $target = $core_att_controls->getPageTypeComposerControlByIdentifier('publish_target'); $target->addToPageTypeComposerFormLayoutSet($options); /* Post Date */ $public = $core_att_controls->getPageTypeComposerControlByIdentifier('date_time'); $public->addToPageTypeComposerFormLayoutSet($options); /* Post Tags */ $control_id = CollectionAttributeKey::getByHandle('tags')->getAttributeKeyID(); $tags = $page_att_controls->getPageTypeComposerControlByIdentifier($control_id); $tags->addToPageTypeComposerFormLayoutSet($options); /* Post Blog Category */ $control_id = CollectionAttributeKey::getByHandle('blog_category')->getAttributeKeyID(); $blog_category = $page_att_controls->getPageTypeComposerControlByIdentifier($control_id); $blog_category->addToPageTypeComposerFormLayoutSet($options); /* Send to subscribers */ $control_id = CollectionAttributeKey::getByHandle('send_subscription')->getAttributeKeyID(); $send_subscribe = $page_att_controls->getPageTypeComposerControlByIdentifier($control_id); $send_subscribe->addToPageTypeComposerFormLayoutSet($options); /* Post To Twitter */ $control_id = CollectionAttributeKey::getByHandle('post_to_twitter')->getAttributeKeyID(); $twitter = $page_att_controls->getPageTypeComposerControlByIdentifier($control_id); $twitter->addToPageTypeComposerFormLayoutSet($options); /* Composer Optimize */ $control_id = CollectionAttributeKey::getByHandle('composer_optimizer')->getAttributeKeyID(); $composer_optimize = $page_att_controls->getPageTypeComposerControlByIdentifier($control_id); $composer_optimize->addToPageTypeComposerFormLayoutSet($options); $db = Loader::db(); $cocID = $db->getOne("SELECT ptComposerOutputControlID FROM PageTypeComposerOutputControls WHERE pTemplateID = ? AND ptID = ?", array($tmplt->getPageTemplateID(), $type->getPageTypeID())); $this->install_pb_page_defaults($pkg, $cocID); }