public function import(\SimpleXMLElement $sx) { if (isset($sx->pagetypepublishtargettypes)) { foreach ($sx->pagetypepublishtargettypes->type as $th) { $pkg = static::getPackageObject($th['package']); $ce = Type::add((string) $th['handle'], (string) $th['name'], $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 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); }