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 update($akID = null) { $this->edit($akID); $key = CollectionKey::getByID($akID); $category = Category::getByHandle('collection'); $this->executeUpdate($key, \URL::to('/dashboard/pages/attributes', 'view')); }
protected function installAttributeType($pkg) { $attributeHandle = 'related_pages'; \Loader::model('attribute/categories/collection'); AttributeType::add($attributeHandle, t('Related Pages'), \Package::getByHandle($this->pkgHandle)); AttributeKeyCategory::getByHandle('collection')->associateAttributeKeyType(AttributeType::getByHandle($attributeHandle)); }
public function install() { $pkg = parent::install(); \Loader::model('attribute/categories/collection'); $col = AttributeKeyCategory::getByHandle('collection'); $at = AttributeType::add('icon_selector', t('Icon Selector'), $pkg); $col->associateAttributeKeyType($at); }
public function view($ptID = false) { $this->setupPageType($ptID); $this->requireAsset('core/app/editable-fields'); $this->set('pagetype', $this->pagetype); $this->set('defaultPage', $this->defaultPage); $category = AttributeKeyCategory::getByHandle('collection'); $this->set('category', $category); }
public function install() { $pkg = parent::install(); \Loader::model('attribute/categories/collection'); $col = AttributeKeyCategory::getByHandle('collection'); //Install attribute and attach to the Colletion Category $gallery = AttributeType::add('mixed_gallery', t('Mixed Gallery'), $pkg); $col->associateAttributeKeyType($gallery); }
public function getList($akCategoryHandle = false) { $r = $this->entityManager->getRepository('\\Concrete\\Core\\Entity\\Attribute\\Type'); if ($akCategoryHandle == false) { return $r->findAll(); } else { $category = Category::getByHandle($akCategoryHandle); return $category->getAttributeTypes(); } }
public function on_start() { parent::on_start(); $this->set('category', AttributeKeyCategory::getByHandle('user')); $otypes = AttributeType::getList('user'); $types = array(); foreach ($otypes as $at) { $types[$at->getAttributeTypeID()] = $at->getAttributeTypeDisplayName(); } $this->set('types', $types); }
private function addAttributes($pkg) { \Loader::model('attribute/categories/collection'); $col = AttributeKeyCategory::getByHandle('collection'); $fileSelector = AttributeType::add('multifile_picker', t('Multiple File Picker'), $pkg); $col->associateAttributeKeyType($fileSelector); $userSelector = AttributeType::add('multiuser_picker', t('Multiple User Picker'), $pkg); $col->associateAttributeKeyType($userSelector); $pageSelector = AttributeType::add('multipage_picker', t('Multiple Page Picker'), $pkg); $col->associateAttributeKeyType($pageSelector); }
public function import(\SimpleXMLElement $sx) { if (isset($sx->attributecategories)) { foreach ($sx->attributecategories->category as $akc) { $pkg = static::getPackageObject($akc['package']); $akx = \Concrete\Core\Attribute\Key\Category::getByHandle($akc['handle']); if (!is_object($akx)) { $akx = \Concrete\Core\Attribute\Key\Category::add((string) $akc['handle'], (string) $akc['allow-sets'], $pkg); } } } }
public function import(\SimpleXMLElement $sx) { if (isset($sx->attributekeys)) { foreach ($sx->attributekeys->attributekey as $ak) { $akc = \Concrete\Core\Attribute\Key\Category::getByHandle($ak['category']); $controller = $akc->getController(); $attribute = $controller->getAttributeKeyByHandle((string) $ak['handle']); if (!$attribute) { $pkg = static::getPackageObject($ak['package']); $type = Type::getByHandle((string) $ak['type']); $key = $controller->import($type, $ak, $pkg); } } } }
private function installAttributeKeys($pkg) { $dbTableDemoAT = AttributeType::getByHandle("db_table_demo"); if (!$dbTableDemoAT) { $dbTableDemoAT = AttributeType::add("db_table_demo", "Database Table Demo", $pkg); $cakc = AttributeKeyCategory::getByHandle('collection'); $cakc->associateAttributeKeyType($dbTableDemoAT); $uakc = AttributeKeyCategory::getByHandle('user'); $uakc->associateAttributeKeyType($dbTableDemoAT); $fakc = AttributeKeyCategory::getByHandle('file'); $fakc->associateAttributeKeyType($dbTableDemoAT); } $this->addPageAttributeKeys($pkg); $this->addUserAttributeKeys($pkg); $this->addFileAttributeKeys($pkg); }
public function view() { $pk = PermissionKey::getByHandle('edit_page_properties'); $pk->setPermissionObject($this->page); $assignment = $pk->getMyAssignment(); $allowed = $assignment->getAttributesAllowedArray(); $category = AttributeKeyCategory::getByHandle('collection'); $controller = $category->getController(); $sets = $controller->getSetManager()->getAttributeSets(); $leftovers = $controller->getSetManager()->getUnassignedAttributeKeys(); $selectedAttributes = $this->page->getSetCollectionAttributes(); $selectedAttributeIDs = array(); foreach ($selectedAttributes as $ak) { $selectedAttributeIDs[] = $ak->getAttributeKeyID(); } $data = array(); foreach ($sets as $set) { $obj = new stdClass(); $obj->title = $set->getAttributeSetDisplayName(); $obj->attributes = array(); foreach ($set->getAttributeKeys() as $ak) { if (in_array($ak->getAttributeKeyID(), $allowed)) { $obj->attributes[] = $ak; } } if (count($obj->attributes)) { $data[] = $obj; } } if (count($leftovers)) { $obj = new stdClass(); $obj->title = t('Other'); $obj->attributes = array(); foreach ($leftovers as $ak) { if (in_array($ak->getAttributeKeyID(), $allowed)) { $obj->attributes[] = $ak; } } if (count($obj->attributes)) { $data[] = $obj; } } $this->set('selectedAttributeIDs', $selectedAttributeIDs); $this->set('assignment', $assignment); $this->set('attributes', $data); }
public function import(\SimpleXMLElement $sx) { if (isset($sx->attributesets)) { foreach ($sx->attributesets->attributeset as $as) { $set = \Concrete\Core\Attribute\Set::getByHandle((string) $as['handle']); $akc = \Concrete\Core\Attribute\Key\Category::getByHandle($as['category']); $controller = $akc->getController(); $manager = $controller->getSetManager(); if (!is_object($set)) { $pkg = static::getPackageObject($as['package']); $set = $manager->addSet((string) $as['handle'], (string) $as['name'], $pkg, $as['locked']); } foreach ($as->children() as $ask) { $ak = $controller->getAttributeKeyByHandle((string) $ask['handle']); if (is_object($ak)) { $manager->addKey($set, $ak); } } } } }
public function import(\SimpleXMLElement $sx) { if (isset($sx->attributetypes)) { foreach ($sx->attributetypes->attributetype as $at) { $pkg = static::getPackageObject($at['package']); $name = (string) $at['name']; if (!$name) { $name = \Core::make('helper/text')->unhandle($at['handle']); } $type = Type::getByHandle($at['handle']); if (!is_object($type)) { $type = Type::add((string) $at['handle'], $name, $pkg); } if (isset($at->categories)) { foreach ($at->categories->children() as $cat) { $catobj = \Concrete\Core\Attribute\Key\Category::getByHandle((string) $cat['handle']); $catobj->getController()->associateAttributeKeyType($type); } } } } }
public function execute(Batch $batch) { $types = $batch->getObjectCollection('attribute_key_category'); if (!$types) { return; } foreach ($types->getCategories() as $type) { if (!$type->getPublisherValidator()->skipItem()) { $pkg = null; if ($type->getPackage()) { $pkg = \Package::getByHandle($type->getPackage()); } $type = Type::add($type->getHandle(), $type->getName(), $pkg); $categories = $type->getCategories(); foreach ($categories as $category) { $co = Category::getByHandle($category); if (is_object($co)) { $co->associateAttributeKeyType($type); } } } } }
public function upgrade() { $pkg = Package::getByHandle('vivid_store'); if (version_compare($pkg->getPackageVersion(), '2.1', '<')) { Installer::renameDatabaseTables($pkg); Installer::refreshDatabase($pkg); /** Version 1.1 ***********************************************/ /**************************************************************/ /* * 1. Installs new payment method: Invoice * */ $invoicePM = PaymentMethod::getByHandle('invoice'); if (!is_object($invoicePM)) { PaymentMethod::add('invoice', 'Invoice', $pkg); } /** Version 2.0 ***********************************************/ /**************************************************************/ /* * 1. Installs new PageType: store_product * 2. Installs a parent page to publish products under * 3. Install Product block * 4. Set pagetype defaults * 5. Give default for measurement units * 6. Install a fileset for digital downloads * 7. Install product attributes * */ /* * 1. Installs new PageType: store_product */ $this->installStoreProductPageType($pkg); /* * 2. Installs a parent page to publish products under */ //first check and make sure the config isn't set. $publishTarget = Config::get('vividstore.productPublishTarget'); if ($publishTarget < 1 || empty($publishTarget)) { //if not, install the proudct detail page if needed. $productParentPage = Page::getByPath('/product-detail'); if ($productParentPage->isError()) { $home = Page::getByID(HOME_CID); $pageType = PageType::getByHandle('page'); $pageTemplate = PageTemplate::getByHandle('full'); $productParentPage = $home->add($pageType, array('cName' => t('Product Detail'), 'cHandle' => 'product-detail', 'pkgID' => $pkg->pkgID), $pageTemplate); Page::getByPath('/product-detail')->setAttribute('exclude_nav', 1); } //set the config to publish under the new page. Config::save('vividstore.productPublishTarget', $productParentPage->getCollectionID()); } /* * 3. Install Product Block */ $productBlock = BlockType::getByHandle("vivid_product"); if (!is_object($productBlock)) { BlockType::installBlockTypeFromPackage('vivid_product', $pkg); } /* * 3. Install Product PageType Defaults */ $pageType = PageType::getByHandle('store_product'); $template = $pageType->getPageTypeDefaultPageTemplateObject(); $pageObj = $pageType->getPageTypePageTemplateDefaultPageObject($template); $bt = BlockType::getByHandle('vivid_product'); $blocks = $pageObj->getBlocks('Main'); if ($blocks[0] && $blocks[0]->getBlockTypeHandle() == "content") { $blocks[0]->deleteBlock(); } if (count($blocks) < 1) { $data = array('productLocation' => 'page', 'showProductName' => 1, 'showProductDescription' => 1, 'showProductDetails' => 1, 'showProductPrice' => 1, 'showImage' => 1, 'showCartButton' => 1, 'showGroups' => 1); $pageObj->addBlock($bt, 'Main', $data); } /* * 5. Measurement Units. */ $sizeUnits = Config::get('vividstore.sizeUnit'); if (empty($sizeUnits)) { Config::save('vividstore.sizeUnit', 'in'); } $weightUnits = Config::get('vividstore.weightUnit'); if (empty($weightUnits)) { Config::save('vividstore.weightUnit', 'lb'); } /* * 6. Fileset for digital downloads */ $fs = FileSet::getByName('Digital Downloads'); if (!is_object($fs)) { FileSet::add("Digital Downloads"); } /* * 7. Product Attributes page */ $attrPage = Page::getByPath('/dashboard/store/products/attributes'); if (!is_object($attrPage) || $attrPage->isError()) { SinglePage::add('/dashboard/store/products/attributes', $pkg); } /* * Add email order attribute */ $text = AttributeType::getByHandle('text'); $oakc = AttributeKeyCategory::getByHandle('store_order'); $orderCustSet = AttributeSet::getByHandle('order_customer'); $email = StoreOrderKey::getByHandle('email'); if (!is_object($email)) { StoreOrderKey::add($text, array('akHandle' => 'email', 'akName' => t('Email')), $pkg)->setAttributeSet($orderCustSet); } // convert legacy config items to current config storage // applies for version 2.1.1 and below $db = Database::get(); $configitems = $db->GetAll("SELECT * FROM Config WHERE configGroup='vividstore'"); if (!empty($configitems)) { foreach ($configitems as $config) { Config::save('vividstore.' . $config['configItem'], $config['configValue']); } $db->Execute("DELETE FROM Config WHERE configGroup='vividstore'"); } } Installer::addOrderStatusesToDatabase($pkg); $paypalPM = PaymentMethod::getByHandle('paypal_standard'); if (!is_object($paypalPM)) { PaymentMethod::add('paypal_standard', 'PayPal Standard', $pkg); } $co = Config::get('vividstore.cartOverlay'); if (empty($co)) { Config::save('vividstore.cartOverlay', false); } parent::upgrade(); }
public static function installProductAttributes(Package $pkg) { //create custom attribute category for products $pakc = AttributeKeyCategory::getByHandle('store_product'); if (!is_object($pakc)) { $pakc = AttributeKeyCategory::add('store_product', AttributeKeyCategory::ASET_ALLOW_SINGLE, $pkg); $pakc->associateAttributeKeyType(AttributeType::getByHandle('text')); $pakc->associateAttributeKeyType(AttributeType::getByHandle('textarea')); $pakc->associateAttributeKeyType(AttributeType::getByHandle('number')); $pakc->associateAttributeKeyType(AttributeType::getByHandle('address')); $pakc->associateAttributeKeyType(AttributeType::getByHandle('boolean')); $pakc->associateAttributeKeyType(AttributeType::getByHandle('date_time')); } }
public static function import(\SimpleXMLElement $ak) { $type = AttributeType::getByHandle($ak['type']); $akCategoryHandle = $ak['category']; $pkg = false; if ($ak['package']) { $pkg = Package::getByHandle($ak['package']); } $akIsInternal = 0; if ($ak['internal']) { $akIsInternal = 1; } $db = Loader::db(); $akc = AttributeKeyCategory::getByHandle($akCategoryHandle); $akID = $db->GetOne('select akID from AttributeKeys where akHandle = ? and akCategoryID = ?', array($ak['handle'], $akc->getAttributeKeyCategoryID())); if (!$akID) { $akn = self::add($akCategoryHandle, $type, array('akHandle' => $ak['handle'], 'akName' => $ak['name'], 'akIsInternal' => $akIsInternal, 'akIsSearchableIndexed' => $ak['indexed'], 'akIsAutoCreated' => 1, 'akIsSearchable' => $ak['searchable']), $pkg); $akn->getController()->importKey($ak); } }
protected function installSite() { $this->output(t('Installing Site object...')); /** * @var $service Service */ $service = \Core::make('site'); $site = $service->getDefault(); $em = $this->connection->getEntityManager(); $type_service = \Core::make('site/type'); $type = $type_service->getDefault(); if (!is_object($type)) { $type = $type_service->installDefault(); } if (!is_object($site) || $site->getSiteID() < 1) { $locale = 'en_US'; if (\Config::get('concrete.multilingual.default_locale')) { $locale = \Config::get('concrete.multilingual.default_locale'); } $site = $service->installDefault($locale); // migrate name $site->setSiteName(\Config::get('concrete.site')); // migrate theme $c = \Page::getByID(HOME_CID); $site->setThemeID($c->getCollectionThemeID()); $em->persist($site); $em->flush(); } $site = $service->getDefault(); $this->connection->executeQuery('update Pages set siteTreeID = ? where cIsSystemPage = 0', [$site->getSiteTreeID()]); $this->connection->executeQuery('update Stacks set siteTreeID = ?', [$site->getSiteTreeID()]); $this->connection->executeQuery('update PageTypes set siteTypeID = ? where ptIsInternal = 0', [$type->getSiteTypeID()]); // migrate social links $links = $em->getRepository('Concrete\\Core\\Entity\\Sharing\\SocialNetwork\\Link')->findAll(); foreach ($links as $link) { $link->setSite($site); $em->persist($link); } $em->flush(); $category = Category::getByHandle('site'); if (!is_object($category)) { $category = Category::add('site'); } else { $category = $category->getController(); } $types = Type::getList(); foreach ($types as $type) { $category->associateAttributeKeyType($type); } $siteConfig = $site->getConfigRepository(); // migrate bookmark icons $favicon_fid = \Config::get('concrete.misc.favicon_fid'); if ($favicon_fid) { $siteConfig->save('misc.favicon_fid', $favicon_fid); } $iphone_home_screen_thumbnail_fid = \Config::get('concrete.misc.iphone_home_screen_thumbnail_fid'); if ($iphone_home_screen_thumbnail_fid) { $siteConfig->save('misc.iphone_home_screen_thumbnail_fid', $iphone_home_screen_thumbnail_fid); } $modern_tile_thumbnail_fid = \Config::get('concrete.misc.modern_tile_thumbnail_fid'); if ($modern_tile_thumbnail_fid) { $siteConfig->save('misc.modern_tile_thumbnail_fid', $modern_tile_thumbnail_fid); } $modern_tile_thumbnail_bgcolor = \Config::get('concrete.misc.modern_tile_thumbnail_bgcolor'); if ($modern_tile_thumbnail_bgcolor) { $siteConfig->save('misc.modern_tile_thumbnail_bgcolor', $modern_tile_thumbnail_bgcolor); } // migrate url $canonical_url = \Config::get('seo.canonical_url'); if ($canonical_url) { $siteConfig->save('seo.canonical_url', $canonical_url); } $canonical_ssl_url = \Config::get('seo.canonical_ssl_url'); if ($canonical_ssl_url) { $siteConfig->save('seo.canonical_ssl_url', $canonical_ssl_url); } // migrate tracking code $header = \Config::get('seo.tracking.code.header'); if ($header) { $siteConfig->save('seo.tracking.code.header', $header); } $footer = \Config::get('seo.tracking.code.footer'); if ($footer) { $siteConfig->save('seo.tracking.code.footer', $footer); } // migrate public profiles $r = \Config::get('concrete.user.profiles_enabled'); if ($r) { $siteConfig->save('user.profiles_enabled', $r); } $r = \Config::get('concrete.user.gravatar.enabled'); if ($r) { $siteConfig->save('user.gravatar.enabled', $r); } $r = \Config::get('concrete.user.gravatar.max_level'); if ($r) { $siteConfig->save('user.gravatar.max_level', $r); } $r = \Config::get('concrete.user.gravatar.image_set'); if ($r) { $siteConfig->save('user.gravatar.image_set', $r); } }
protected function getCategoryObject() { return Category::getByHandle('user'); }
protected function importAttributeSets(\SimpleXMLElement $sx) { if (isset($sx->attributesets)) { foreach ($sx->attributesets->attributeset as $as) { $set = \Concrete\Core\Attribute\Set::getByHandle((string) $as['handle']); $akc = AttributeKeyCategory::getByHandle($as['category']); if (!is_object($set)) { $pkg = static::getPackageObject($as['package']); $set = $akc->addSet((string) $as['handle'], (string) $as['name'], $pkg, $as['locked']); } foreach ($as->children() as $ask) { $ak = $akc->getAttributeKeyByHandle((string) $ask['handle']); if (is_object($ak)) { $set->addKey($ak); } } } } }
public function add_attribute_types() { // add attribute type price $at_price = AttributeType::getByHandle('price'); if (!is_object($at_price)) { $at_price = AttributeType::add('price', 'Price', $this->pkg); } // add attribute type composer menu $at_cm = AttributeType::getByHandle('composer_menu'); if (!is_object($at_cm)) { $at_cm = AttributeType::add('composer_menu', 'Composer Menu', $this->pkg); } // associate attribute types with category $akc = AttributeKeyCategory::getByHandle('collection'); $akc->associateAttributeKeyType($at_price); $akc->associateAttributeKeyType($at_cm); }
public function skipItem() { $category = Category::getByHandle($this->object->getHandle()); return is_object($category); }
public function install() { $pkg = parent::install(); // Dashboard Page $sp = SinglePage::add('/dashboard/forums', $pkg); if (is_object($sp)) { $sp->update(array('cName' => t('Forums'), 'cDescription' => t('Forums Dashboard'))); } // Add Sidebar block set BlockTypeSet::add('forums', 'Forums', $pkg); // Add forum moderator user group $forumGroup = Group::getByName('Forum Moderators'); if (!is_object($authorGroup)) { Group::add('Forum Moderators', t('Forum Moderators, delete, edit, approve')); } // install blocks BlockType::installBlockTypeFromPackage('webli_forum_post', $pkg); BlockType::installBlockTypeFromPackage('webli_forum_list', $pkg); BlockType::installBlockTypeFromPackage('webli_forum_search', $pkg); BlockType::installBlockTypeFromPackage('webli_forum_archive', $pkg); BlockType::installBlockTypeFromPackage('webli_forum_tags', $pkg); // Add Collection Attribute Set $akCat = AttributeKeyCategory::getByHandle('collection'); $akCat->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE); $akCatSet = $akCat->addSet('forums', t('Forums'), $pkg); // Add Collection Attributes $attribute = CollectionAttributeKey::getByHandle('forum_post'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('textarea'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_post', 'akName' => t('Forum Post'), 'akIsSearchableIndexed' => true, 'akTextareaDisplayMode' => 'rich_text'), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_category'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('boolean'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_category', 'akName' => t('Forum Category')), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_email'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('text'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_email', 'akName' => t('Forum Email Address'), 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_name'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('text'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_name', 'akName' => t('Forum Name'), 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_pin'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('boolean'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_pin', 'akName' => t('Pin Forum Post')), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_post_approved'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('boolean'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_post_approved', 'akName' => t('Forum Post Approved')), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('tags'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('select'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'tags', 'akName' => t('Tags'), 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_image'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('image_file'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_image', 'akName' => t('Forum Image')), $pkg)->setAttributeSet($akCatSet); $addAttribute = CollectionAttributeKey::getByHandle('forum_image'); } // Add top level Forums Page $forumPage = \Page::getByPath('/forums'); if (!is_object($forumPage) || $forumPage->cID == null) { $parentPage = \Page::getByID(1); $pageType = \PageType::getByHandle('right_sidebar'); $template = \PageTemplate::getByHandle('right_sidebar'); $forumsPage = $parentPage->add($pageType, array('cName' => t('Forums'), 'cDescription' => t('Top Level Forums Page'), 'cHandle ' => 'forums'), $template); //Add forum_category page attribute $forumsPage->setAttribute('forum_category', 1); } // Add top Forum Search Results Page $forumSearchPage = \Page::getByPath('/forum-search'); if (!is_object($forumSearchPage) || $forumSearch->cID == null) { $parentPage = \Page::getByID(1); $pageType = \PageType::getByHandle('right_sidebar'); $template = \PageTemplate::getByHandle('right_sidebar'); $forumSearchPage = $parentPage->add($pageType, array('cName' => t('Forum Search'), 'cDescription' => t('Forum Search Page'), 'cHandle ' => 'forum-search'), $template); $forumSearchPage->setAttribute('exclude_nav', 1); } // Add Forum Post Page Template if (!is_object(PageTemplate::getByHandle('forum_post'))) { $pageTemplate = PageTemplate::add('forum_post', 'Forum Post', 'landing.png', $pkg); } // Add Forum Post Page Type if (!is_object(PageType::getByHandle('forum_post'))) { $data = array('handle' => 'forum_post', 'name' => 'Forum Post', 'ptLaunchInComposer' => true, 'ptIsFrequentlyAdded' => true, 'defaultTemplate' => PageTemplate::getByHandle('forum_post'), 'allowedTemplates' => 'C', 'templates' => array(PageTemplate::getByHandle('forum_post'))); $pt = PageType::add($data, $pkg); } /* Get blog_post page template */ $pageType = \PageType::getByHandle('forum_post'); $ctTemplate = $pageType->getPageTypeDefaultPageTemplateObject(); $forumPostTemplate = $pageType->getPageTypePageTemplateDefaultPageObject($ctTemplate); /* Add Composer Layouts */ $basics = $pageType->addPageTypeComposerFormLayoutSet('Basics', 'Basic Info'); $post = $pageType->addPageTypeComposerFormLayoutSet('Forum Post', 'Forum Post'); /* Add Built in Properties */ $cct = ComposerControlType::getByHandle('core_page_property'); /* Post Title */ $control = $cct->getPageTypeComposerControlByIdentifier('name'); $control->addToPageTypeComposerFormLayoutSet($basics); /* Post Slug */ $control = $cct->getPageTypeComposerControlByIdentifier('url_slug'); $control->addToPageTypeComposerFormLayoutSet($basics); /* Post Publish Location */ $control = $cct->getPageTypeComposerControlByIdentifier('publish_target'); $control->addToPageTypeComposerFormLayoutSet($basics); /* Post Date */ $control = $cct->getPageTypeComposerControlByIdentifier('date_time'); $control->addToPageTypeComposerFormLayoutSet($basics); /* Post Author */ $control = $cct->getPageTypeComposerControlByIdentifier('user'); $control->addToPageTypeComposerFormLayoutSet($basics); /* Add Attributes */ $cct = ComposerControlType::getByHandle('collection_attribute'); /* Forum Pin */ $attributeId = CollectionAttributeKey::getByHandle('forum_pin')->getAttributeKeyID(); $control = $cct->getPageTypeComposerControlByIdentifier($attributeId); $control->addToPageTypeComposerFormLayoutSet($post); /* Forum Post Approved */ $attributeId = CollectionAttributeKey::getByHandle('forum_post_approved')->getAttributeKeyID(); $control = $cct->getPageTypeComposerControlByIdentifier($attributeId); $control->addToPageTypeComposerFormLayoutSet($post); /* Forum Post */ $attributeId = CollectionAttributeKey::getByHandle('forum_post')->getAttributeKeyID(); $control = $cct->getPageTypeComposerControlByIdentifier($attributeId); $control->addToPageTypeComposerFormLayoutSet($post); /* Forum Image */ $attributeId = CollectionAttributeKey::getByHandle('forum_image')->getAttributeKeyID(); $control = $cct->getPageTypeComposerControlByIdentifier($attributeId); $control->addToPageTypeComposerFormLayoutSet($post); /* Forum Tags */ $attributeId = CollectionAttributeKey::getByHandle('tags')->getAttributeKeyID(); $control = $cct->getPageTypeComposerControlByIdentifier($attributeId); $control->addToPageTypeComposerFormLayoutSet($post); /* Add default Blocks to page template */ $ctTemplate = $pageType->getPageTypeDefaultPageTemplateObject(); $forumPostTemplate = $pageType->getPageTypePageTemplateDefaultPageObject($ctTemplate); //Add exclude_nav page attributeto Forum Post Template $forumPostTemplate->setAttribute('exclude_nav', 1); // Get Forum Category Page $forumCategoryPage = Page::getByPath('/forums'); //Add forum_category page attribute $forumCategoryPage->setAttribute('forum_category', 1); // Get Forum Search Page $forumSearchPage = Page::getByPath('/forum-search'); //Add exclude_nav page attribute $forumSearchPage->setAttribute('exclude_nav', 1); // Install Blocks //install Forum Post Block $forumPost = BlockType::getByHandle('webli_forum_post'); $forumPostData = array(); $forumCategoryPage->addBlock($forumPost, 'Main', $forumPostData); //install forum post block to forum_post template $forumPostTemplate->addBlock($forumPost, 'Forum Post', $forumPostData); //install Forum List Block on Forums top level page $forumList = BlockType::getByHandle('webli_forum_list'); $forumListData = array(); $forumListData['num'] = 25; $forumListData['paginate'] = 1; $forumListData['cParentID'] = $forumCategoryPage->getCollectionID(); $forumListData['orderBy'] = 'chrono_desc'; $forumListData['use_content'] = 1; $forumListData['truncateSummaries'] = 1; $forumListData['truncateChars'] = 200; $forumListData['display_author'] = 1; $forumListData['includeDate'] = 1; $forumListData['includeName'] = 1; $forumListData['includeDescription'] = 1; $forumListData['date_format'] = 'l F j, Y g:ia'; $forumListData['forum_pin'] = 1; $forumListData['forumReplies'] = 3; $forumListData['thumb_width'] = 250; $forumListData['thumb_height'] = 150; $forumListData['crop'] = 1; $forumListData['noResultsMessage'] = 'No Forum Posts available to view.'; $forumCategoryPage->addBlock($forumList, 'Main', $forumListData); // Install Forum Search Block on forum_post Page template $forumSearch = BlockType::getByHandle('webli_forum_search'); $forumSearchData = array(); $forumSearchData['title'] = 'Forum Search'; $forumSearchData['postTo_cID'] = $forumSearchPage->getCollectionID(); $forumSearchData['baseSearchPath'] = 'PARENT'; $forumPostTemplate->addBlock($forumSearch, 'Sidebar', $forumSearchData); //install Forum Search Block Forums forum_category Page $forumSearchData = array(); $forumSearchData['title'] = 'Forum Search'; $forumSearchData['postTo_cID'] = $forumSearchPage->getCollectionID(); $forumSearchData['baseSearchPath'] = $forumCategoryPage->getCollectionPath(); $forumCategoryPage->addBlock($forumSearch, 'Sidebar', $forumSearchData); //install Forum Search Block on Forum Search Page $forumSearchData = array(); $forumSearchData['title'] = 'Forum Search'; $forumSearchData['buttonText'] = 'Search'; $forumSearchData['baseSearchPath'] = $forumCategoryPage->getCollectionPath(); $forumSearchPage->addBlock($forumSearch, 'Main', $forumSearchData); //install Forum Archive Block on forum_post template $forumArchive = BlockType::getByHandle('webli_forum_archive'); $forumArchiveData = array(); $forumArchiveData['title'] = 'Forum Archive'; $forumArchiveData['cParentID'] = 'PARENT'; $forumPostTemplate->addBlock($forumArchive, 'Sidebar', $forumArchiveData); //install Forum Archive Block $forumArchiveData = array(); $forumArchiveData['title'] = 'Forum Archive'; $forumArchiveData['cParentID'] = $forumCategoryPage->getCollectionID(); $forumCategoryPage->addBlock($forumArchive, 'Sidebar', $forumArchiveData); $forumSearchPage->addBlock($forumArchive, 'Sidebar', $forumArchiveData); //install Forum Tags Block on forum_post template $forumTags = BlockType::getByHandle('webli_forum_tags'); $forumTagsData = array(); $forumTagsData['title'] = 'Forum Tags'; $forumTagsData['cParentID'] = 'PARENT'; $forumTagsData['postTo_cID'] = $forumSearchPage->getCollectionID(); $forumTagsData['baseSearchPath'] = $forumCategoryPage->getCollectionPath(); $forumTagsData['min_height'] = 15; $forumTagsData['max_height'] = 30; $forumPostTemplate->addBlock($forumTags, 'Sidebar', $forumTagsData); //install Forum Tags Block $forumTagsData = array(); $forumTagsData['title'] = 'Forum Tags'; $forumTagsData['cParentID'] = $forumCategoryPage->getCollectionID(); $forumTagsData['postTo_cID'] = $forumSearchPage->getCollectionID(); $forumTagsData['baseSearchPath'] = $forumCategoryPage->getCollectionPath(); $forumTagsData['min_height'] = 15; $forumTagsData['max_height'] = 30; $forumCategoryPage->addBlock($forumTags, 'Sidebar', $forumTagsData); $forumSearchPage->addBlock($forumTags, 'Sidebar', $forumTagsData); //install Conversations block to forum_post template $conversations = BlockType::getByHandle('core_conversation'); $conversationsData = array(); $conversationsData['attachmentsEnabled'] = 0; $conversationsData['addMessageLabel'] = t('Add a Comment'); $conversationsData['itemsPerPage'] = 25; $conversationsData['enablePosting'] = 1; $conversationsData['enableCommentRating'] = 1; $conversationsData['paginate'] = 1; $conversationsData['displayMode'] = 'threaded'; $conversationsData['displayPostingForm'] = 'bottom'; $forumPostTemplate->addBlock($conversations, 'Forum Replies', $conversationsData); $db = Loader::db(); // insert default page category values $db->Execute('insert into btWebliForums ( cID, display_title, display_author, display_date, date_format, display_tags, enable_comments, enable_breadcrumb, crop_image, display_image, image_height, image_width, display_avatars, forum_search_block, forum_archive_block, forum_tags_block, rich_text, page_template, page_type ) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array(0, 1, 1, 1, 'l F j, Y g:ia', 1, 1, 1, 0, 1, 350, 250, 1, 1, 1, 1, 1, $pageTemplate->getPageTemplateID(), $pageType->getPageTypeID())); // Add Sample Forum Post $forumsPage = \Page::getByPath('/forums'); if (is_object($forumsPage) || $forumsPage->cID != null) { $pageType = \PageType::getByHandle('forum_post'); $template = \PageTemplate::getByHandle('forum_post'); $samplePost = $forumsPage->add($pageType, array('cName' => 'My First Forum Post', 'cDescription' => 'First Forum Post', 'cHandle ' => 'first-forum-post'), $template); $samplePost->setAttribute('forum_post', t(' <p>Hey, Congratulations, you have installed Forums for Concrete5. Forums will give visitors to your site frontend editing capabilities to add Forum Messages and reply to existing messages.</p> <p>Administrators have access to the Forums Dashboard Page to customize and manage your forums.</p> <p>So get your forum started and if you have any comments or questions visit <a href="http://forums.webli.us" target="_blank">forums.webli.us</a></p>')); $samplePost->setAttribute('forum_post_approved', 1); $samplePost->setAttribute('tags', array('Forums', t('Frist Message'))); } $cms = Core::make('app'); $cms->clearCaches(); }
public function set($setHandle) { $set = AttributeSet::getByHandle($setHandle); $akc = AttributeKeyCategory::getByHandle($this->category); $ak = $akc->getAttributeKeyByHandle($this->handle); if (!is_object($ak)) { return false; } $set->addKey($ak); return true; }
/** * This is how old attribute keys used to install themselves. They extended * this class and would call parent::add(). Do NOT use this method. It is here * for backward compatibility. * @deprecated */ public static function add($handle, $type, $args, $pkg = false) { $category = Category::getByHandle($handle); $controller = $category->getController(); if (!$controller instanceof LegacyCategory) { throw new \Exception(t('You cannot use the legacy attribute add method with any category but the legacy category.')); } return $controller->addAttributeKey($type, $args, $pkg); }
public function edit($akID = 0) { if ($this->post('akID')) { $akID = $this->post('akID'); } $key = StoreProductKey::getByID($akID); $type = $key->getAttributeType(); $this->set('key', $key); $this->set('type', $type); $this->set('category', AttributeKeyCategory::getByHandle('store_product')); if ($this->isPost()) { $cnt = $type->getController(); $cnt->setAttributeKey($key); $e = $cnt->validateKey($this->post()); if ($e->has()) { $this->set('error', $e); } else { $type = AttributeType::getByID($this->post('atID')); $args = array('akHandle' => $this->post('akHandle'), 'akName' => $this->post('akName'), 'akIsSearchable' => $this->post('akIsSearchable'), 'akIsSearchableIndexed' => $this->post('akIsSearchableIndexed'), 'akIsAutoCreated' => 0, 'akIsEditable' => 1); $key->update($this->post()); $this->redirect('/dashboard/store/products/attributes', 'updated'); } } }
public function on_start() { $this->set('category', AttributeKeyCategory::getByHandle('attribute_form')); }
/** * @return mixed \Concrete\Core\Attribute\Key\Category || null */ private function attributeKeyCategory($handle) { if (is_null($this->{"akc_{$handle}"})) { $attributeCategory = \Concrete\Core\Attribute\Key\Category::getByHandle($handle); if (is_object($attributeCategory) && $attributeCategory->getAttributeKeyCategoryID() >= 1) { $this->{"akc_{$handle}"} = $attributeCategory; } } return $this->{"akc_{$handle}"}; }