示例#1
0
 public static function getByHandle($akHandle)
 {
     $ak = CacheLocal::getEntry('file_attribute_key_by_handle', $akHandle);
     if (is_object($ak)) {
         return $ak;
     } else {
         if ($ak == -1) {
             return false;
         }
     }
     $ak = -1;
     $db = Loader::db();
     $q = "SELECT ak.akID FROM AttributeKeys ak INNER JOIN AttributeKeyCategories akc ON ak.akCategoryID = akc.akCategoryID  WHERE ak.akHandle = ? AND akc.akCategoryHandle = 'file'";
     $akID = $db->GetOne($q, array($akHandle));
     if ($akID > 0) {
         $ak = self::getByID($akID);
     } else {
         // else we check to see if it's listed in the initial registry
         $ia = FileTypeList::getImporterAttribute($akHandle);
         if (is_object($ia)) {
             // we create this attribute and return it.
             $at = AttributeType::getByHandle($ia->akType);
             $args = array('akHandle' => $akHandle, 'akName' => $ia->akName, 'akIsSearchable' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => $ia->akIsEditable);
             $ak = static::add($at, $args);
         }
     }
     CacheLocal::set('file_attribute_key_by_handle', $akHandle, $ak);
     if ($ak === -1) {
         return false;
     }
     return $ak;
 }
 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 add($type, $key, $settings = null, $pkg = null)
 {
     if (is_string($type)) {
         $type = \Concrete\Core\Attribute\Type::getByHandle($type);
     }
     // Legacy array support for $key
     $asID = false;
     if (is_array($key)) {
         $handle = $key['akHandle'];
         $name = $key['akName'];
         if (isset($key['asID'])) {
             $asID = $key['asID'];
         }
         $key = $this->createAttributeKey();
         $key->setAttributeKeyHandle($handle);
         $key->setAttributeKeyName($name);
     }
     // Legacy support for third parameter which used to be package
     if ($settings instanceof Package || $settings instanceof \Concrete\Core\Package\Package) {
         $pkg = $settings;
         unset($settings);
     }
     if (!$settings) {
         $settings = $type->getController()->getAttributeKeySettings();
     }
     $key->setAttributeType($type);
     $this->entityManager->persist($key);
     $this->entityManager->flush();
     $settings->setAttributeKey($key);
     $key->setAttributeKeySettings($settings);
     $this->entityManager->persist($settings);
     $this->entityManager->flush();
     if (is_object($pkg)) {
         $key->setPackage($pkg);
     }
     // Modify the category's search indexer.
     $indexer = $this->getSearchIndexer();
     if (is_object($indexer)) {
         $indexer->updateRepositoryColumns($this, $key);
     }
     $this->entityManager->persist($key);
     $this->entityManager->flush();
     /* legacy support, attribute set */
     if ($asID) {
         $manager = $this->getSetManager();
         $factory = new SetFactory($this->entityManager);
         $set = $factory->getByID($asID);
         if (is_object($set)) {
             $manager->addKey($set, $key);
         }
     }
     return $key;
 }
示例#4
0
 protected function setUp()
 {
     parent::setUp();
     $this->installAttributeCategoryAndObject();
     AttributeType::add('boolean', 'Boolean');
     AttributeType::add('textarea', 'Textarea');
     AttributeType::add('text', 'text');
     foreach ($this->keys as $akHandle => $args) {
         $args['akHandle'] = $akHandle;
         $type = AttributeType::getByHandle($args['type']);
         $this->keys[] = call_user_func_array(array($this->getAttributeKeyClass(), 'add'), array($type, $args));
     }
 }
 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 install()
 {
     $pkg = parent::install();
     //Add dashboard page
     $sp = SinglePage::add('/dashboard/open_graph_tags_lite', $pkg);
     if (is_object($sp)) {
         $sp->update(array('cName' => t('Open Graph Tags Lite'), 'cDescription' => t('Auto insert Open Graph Tags (OGP) into HEAD tag')));
     }
     $sp = SinglePage::add('/dashboard/open_graph_tags_lite/settings', $pkg);
     if (is_object($sp)) {
         $sp->update(array('cName' => t('Open Graph Tags Settings'), 'cDescription' => ''));
     }
     //Add og:image attribute
     $cak = CollectionAttributeKey::getByHandle('og_image');
     if (!is_object($cak)) {
         $at = AttributeType::getByHandle('image_file');
         CollectionAttributeKey::add($at, array('akHandle' => 'og_image', 'akName' => t('og:image')));
     }
 }
 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);
                 }
             }
         }
     }
 }
示例#9
0
 public static function import(\SimpleXMLElement $ak)
 {
     $type = AttributeType::getByHandle($ak['type']);
     $pkg = false;
     if ($ak['package']) {
         $pkg = Package::getByHandle($ak['package']);
     }
     $akn = static::add($type, array('akHandle' => $ak['handle'], 'akName' => $ak['name'], 'akIsSearchableIndexed' => $ak['indexed'], 'akIsSearchable' => $ak['searchable'], 'uakProfileDisplay' => $ak['profile-displayed'], 'uakProfileEdit' => $ak['profile-editable'], 'uakProfileEditRequired' => $ak['profile-required'], 'uakRegisterEdit' => $ak['register-editable'], 'uakRegisterEditRequired' => $ak['register-required'], 'uakMemberListDisplay' => $ak['member-list-displayed']), $pkg);
     $akn->getController()->importKey($ak);
 }
示例#10
0
    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();
    }
示例#11
0
文件: form.php 项目: baardev/lbtb
<?php

defined('C5_EXECUTE') or die("Access Denied.");
use URL;
use Concrete\Core\Block\BlockType\BlockType;
use Concrete\Core\Attribute\Type as AttributeType;
use Concrete\Core\Page\Type\Type as CollectionType;
$c = Page::getCurrentPage();
$fm = Loader::helper('form');
$bt = BlockType::getByHandle('related_pages');
$akIDs = explode(',', $akID);
$at = AttributeType::getByHandle('select');
$atID = $at->getAttributeTypeID();
$list = $controller->getList(array('AttributeKeys.atID' => $atID));
$AJAXselect = URL::to('/problog/tools/nab_attribute');
//var_dump($AJAXselect);
?>
<div id="ccm-relatedpagesPane-add" class="ccm-relatedpagesPane">
	<div class="ccm-block-field-group">
	  <h4><?php 
echo t('Number and Type of Pages');
?>
</h4>
	  <?php 
echo t('Display');
?>
	  <input type="text" name="num" value="<?php 
echo $num;
?>
" style="width: 30px">
	  <?php 
 protected function importAttributes(\SimpleXMLElement $sx)
 {
     if (isset($sx->attributekeys)) {
         foreach ($sx->attributekeys->attributekey as $ak) {
             $akc = AttributeKeyCategory::getByHandle($ak['category']);
             $pkg = static::getPackageObject($ak['package']);
             $type = AttributeType::getByHandle($ak['type']);
             $txt = Loader::helper('text');
             $c1 = '\\Concrete\\Core\\Attribute\\Key\\' . $txt->camelcase($akc->getAttributeKeyCategoryHandle()) . 'Key';
             $ak = call_user_func(array($c1, 'import'), $ak);
         }
     }
 }
示例#13
0
 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'));
     }
 }
 protected function importAttributeTypes()
 {
     $types = array('express' => 'Express Entity', 'email' => 'Email Address', 'telephone' => 'Telephone', 'url' => 'URL');
     $categories = array('file', 'user', 'collection');
     foreach ($types as $handle => $name) {
         $type = Type::getByHandle($handle);
         if (!is_object($type)) {
             $type = Type::add($handle, $name);
             foreach ($categories as $category) {
                 $cat = Category::getByHandle($category);
                 $cat->getController()->associateAttributeKeyType($type);
             }
         }
     }
 }
示例#15
0
 /**
  * @return AttributeType
  */
 private function attributeType($handle)
 {
     if (is_null($this->{"at_{$handle}"})) {
         $attributeType = \Concrete\Core\Attribute\Type::getByHandle($handle);
         if (is_object($attributeType) && $attributeType->getAttributeTypeID() >= 1) {
             $this->{"at_{$handle}"} = $attributeType;
         }
     }
     return $this->{"at_{$handle}"};
 }
示例#16
0
 public function upgrade()
 {
     parent::upgrade();
     // Install Single Pages
     $sP = Page::getByPath('/dashboard/fundamental');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental', $this);
         $sP->update(array('cName' => t("Fundamental Theme Settings")));
         // Set up Default Config Settings
         // Navigation
         Config::save('c5hub.fundamental.navigation.position', 'right');
         Config::save('c5hub.fundamental.navigation.branding', true);
         Config::save('c5hub.fundamental.navigation.branding_position', 'branding-left');
         Config::save('c5hub.fundamental.navigation.contain_to_grid', true);
         Config::save('c5hub.fundamental.navigation.sticky', false);
         Config::save('c5hub.fundamental.navigation.custom_back_text', true);
         Config::save('c5hub.fundamental.navigation.back_text', 'Back');
         Config::save('c5hub.fundamental.navigation.is_hover', true);
         Config::save('c5hub.fundamental.navigation.mobile_show_parent_link', true);
         Config::save('c5hub.fundamental.navigation.scroll_top', false);
         Config::save('c5hub.fundamental.navigation.divider', false);
         // Page Meta
         Config::save('c5hub.fundamental.page_meta_alignment', 'text-left');
         Config::save('c5hub.fundamental.page_meta_title', true);
         Config::save('c5hub.fundamental.page_meta_description', true);
         // Background Images
         Config::save('c5hub.fundamental.body_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.body_background_image_size', 'auto');
         Config::save('c5hub.fundamental.body_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.top_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.top_background_image_size', 'auto');
         Config::save('c5hub.fundamental.top_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.branding_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.branding_background_image_size', 'auto');
         Config::save('c5hub.fundamental.branding_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.navigation_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.navigation_background_image_size', 'auto');
         Config::save('c5hub.fundamental.navigation_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.header_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.header_background_image_size', 'auto');
         Config::save('c5hub.fundamental.header_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.banner_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.banner_background_image_size', 'auto');
         Config::save('c5hub.fundamental.banner_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.page_info_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.page_info_background_image_size', 'auto');
         Config::save('c5hub.fundamental.page_info_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.main_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.main_background_image_size', 'auto');
         Config::save('c5hub.fundamental.main_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.footer_top_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.footer_top_background_image_size', 'auto');
         Config::save('c5hub.fundamental.footer_top_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.footer_bottom_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.footer_bottom_background_image_size', 'auto');
         Config::save('c5hub.fundamental.footer_bottom_background_image_attachment', 'scroll');
         // Attribution
         Config::save('c5hub.fundamental.footer_attribution', '/ <a href="http://c5hub.com" target="_blank" title="concrete5 themes & add-ons">Responsive concrete5 Theme by <b>c5Hub</b></a>');
         // White Label
         Config::save('concrete.marketplace.enabled', true);
         Config::save('concrete.marketplace.intelligent_search', true);
         Config::save('concrete.external.news_overlay', true);
         Config::save('concrete.external.news', true);
     }
     $sP = Page::getByPath('/dashboard/fundamental/navigation');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/navigation', $this);
         $sP->update(array('cName' => t("Navigation")));
     }
     $sP = Page::getByPath('/dashboard/fundamental/off_canvas_navigation');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/off_canvas_navigation', $this);
         $sP->update(array('cName' => t("Off Canvas Navigation")));
         // Off Canvas Navigation
         Config::save('c5hub.fundamental.off_canvas.position', 'right');
         Config::save('c5hub.fundamental.off_canvas.open_method', 'move');
         Config::save('c5hub.fundamental.off_canvas.close_on_click', false);
     }
     $sP = Page::getByPath('/dashboard/fundamental/page_meta');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/page_meta', $this);
         $sP->update(array('cName' => t("Page Meta")));
     }
     $sP = Page::getByPath('/dashboard/fundamental/background_images');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/background_images', $this);
         $sP->update(array('cName' => t("Background Images")));
     }
     $sP = Page::getByPath('/dashboard/fundamental/attribution');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/attribution', $this);
         $sP->update(array('cName' => t("Attribution")));
     }
     $sP = Page::getByPath('/dashboard/fundamental/white_label');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/white_label', $this);
         $sP->update(array('cName' => t("White Label")));
     }
     $sP = Page::getByPath('/dashboard/fundamental/general');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/general', $this);
         $sP->update(array('cName' => t("General")));
         // General
         Config::save('c5hub.fundamental.general.boxed', false);
         Config::save('c5hub.fundamental.general.sticky_footer', false);
     }
     $sP = Page::getByPath('/dashboard/fundamental/masonry_grid');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/masonry_grid', $this);
         $sP->update(array('cName' => t("Masonry Grid")));
         // Masonry Grid
         Config::save('c5hub.fundamental.masonry_grid_columns_desktop', 4);
         Config::save('c5hub.fundamental.masonry_grid_columns_tablet', 4);
         Config::save('c5hub.fundamental.masonry_grid_columns_mobile', 12);
     }
     // Install Page Types
     if (!PageTemplate::getByHandle('blog_entry')) {
         PageTemplate::add('blog_entry', 'Blog Entry', 'left_sidebar.png', $pkg);
     }
     if (!PageTemplate::getByHandle('custom')) {
         PageTemplate::add('custom', 'Custom', 'full.png', $pkg);
     }
     if (!PageTemplate::getByHandle('blank')) {
         PageTemplate::add('blank', t('Blank'), 'full.png', $pkg);
     }
     // Install Blocks
     if (!BlockType::getByHandle('fundamental_simple_document')) {
         BlockType::installBlockTypeFromPackage('fundamental_simple_document', $this);
     }
     if (!BlockType::getByHandle('fundamental_section')) {
         BlockType::installBlockTypeFromPackage('fundamental_section', $this);
     }
     if (!BlockType::getByHandle('fundamental_slick_slider')) {
         BlockType::installBlockTypeFromPackage('fundamental_slick_slider', $this);
     }
     // Install Thumbnail Types
     $small = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('small');
     if (!is_object($small)) {
         $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type();
         $type->setName('Small');
         $type->setHandle('small');
         $type->setWidth(740);
         $type->save();
     }
     $medium = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('medium');
     if (!is_object($medium)) {
         $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type();
         $type->setName('Medium');
         $type->setHandle('medium');
         $type->setWidth(940);
         $type->save();
     }
     $large = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('large');
     if (!is_object($large)) {
         $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type();
         $type->setName('Large');
         $type->setHandle('large');
         $type->setWidth(1140);
         $type->save();
     }
     $xlarge = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('xlarge');
     if (!is_object($xlarge)) {
         $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type();
         $type->setName('XLarge');
         $type->setHandle('xlarge');
         $type->setWidth(9999);
         $type->save();
     }
     // Attributes
     $navIconKey = CollectionAttributeKey::getByHandle('nav_icon');
     if (!$navIconKey || !intval($navIconKey->getAttributeKeyID())) {
         $navIconType = AttributeType::getByHandle('select');
         $navIconKey = CollectionAttributeKey::add($navIconType, array('akHandle' => 'nav_icon', 'akName' => t('Nav Icon'), 'akIsSearchable' => false), $pkg);
         ## Add Options
         $options = $this->getIconClasses();
         foreach ($options as $opt) {
             $navIconKeyOption = SelectAttributeTypeOption::add($navIconKey, $opt, 0);
         }
     }
     $thumbnailKey = CollectionAttributeKey::getByHandle('thumbnail');
     if (!$thumbnailKey || !intval($thumbnailKey->getAttributeKeyID())) {
         $thumbnailType = AttributeType::getByHandle('image_file');
         $thumbnailKey = CollectionAttributeKey::add($thumbnailType, array('akHandle' => 'thumbnail', 'akName' => t('Thumbnail'), 'akIsSearchable' => false), $pkg);
     }
     $disableTitleKey = CollectionAttributeKey::getByHandle('disable_page_info_title');
     if (!$disableTitleKey || !intval($disableTitleKey->getAttributeKeyID())) {
         $disableTitleType = AttributeType::getByHandle('boolean');
         $disableTitleKey = CollectionAttributeKey::add($disableTitleType, array('akHandle' => 'disable_page_info_title', 'akName' => t('Disable Page Info Title'), 'akIsSearchable' => false), $pkg);
     }
     $disableDescriptionKey = CollectionAttributeKey::getByHandle('disable_page_info_description');
     if (!$disableDescriptionKey || !intval($disableDescriptionKey->getAttributeKeyID())) {
         $disableDescriptionType = AttributeType::getByHandle('boolean');
         $disableDescriptionKey = CollectionAttributeKey::add($disableDescriptionType, array('akHandle' => 'disable_page_info_description', 'akName' => t('Disable Page Info Description'), 'akIsSearchable' => false), $pkg);
     }
     $areaCountKey = CollectionAttributeKey::getByHandle('area_count');
     if (!$areaCountKey || !intval($areaCountKey->getAttributeKeyID())) {
         $areaCountType = AttributeType::getByHandle('number');
         $areaCountKey = CollectionAttributeKey::add($areaCountType, array('akHandle' => 'area_count', 'akName' => t('Area Count'), 'akIsSearchable' => false), $pkg);
     }
 }
示例#17
0
 public function getAttributeTypeObject()
 {
     $ato = \Concrete\Core\Attribute\Type::getByHandle($this->getAttributeKey()->getAttributeTypeHandle());
     return $ato;
 }
示例#18
0
 protected function importAttributes(\SimpleXMLElement $sx)
 {
     if (isset($sx->attributekeys)) {
         foreach ($sx->attributekeys->attributekey as $ak) {
             $akc = AttributeKeyCategory::getByHandle($ak['category']);
             $type = AttributeType::getByHandle($ak['type']);
             $txt = Loader::helper('text');
             $c1 = overrideable_core_class('\\Core\\Attribute\\Key\\' . $txt->camelcase($akc->getAttributeKeyCategoryHandle()) . 'Key', DIRNAME_CLASSES . '/Attribute/Key/' . $txt->camelcase($akc->getAttributeKeyCategoryHandle()) . 'Key.php', (string) $akc->getPackageHandle());
             $ak = call_user_func(array($c1, 'import'), $ak);
         }
     }
 }
示例#19
0
文件: view.php 项目: baardev/lbtb
<?php

defined('C5_EXECUTE') or die(_("Access Denied."));
use Concrete\Package\Problog\Attribute\Select\SelectBlog;
use Concrete\Core\Attribute\Type as AttributeType;
use Concrete\Core\Attribute\Key\CollectionKey as CollectionAttributeKey;
if ($title != '') {
    echo '<h3>' . t($title) . '</h3>';
}
?>
    <div class="ccm-page-list">

    <?php 
$tagCounts = array();
$ak = CollectionAttributeKey::getByHandle('blog_category');
$akc = new SelectBlog(AttributeType::getByHandle('select'));
$akc->setAttributeKey($ak);
$ttags = $akc->getOptionUsageArray($pp);
$tags = array();
foreach ($ttags as $t) {
    $tagCounts[] = $t->getSelectAttributeOptionUsageCount();
    $tags[] = $t;
}
shuffle($tags);
for ($i = 0; $i < $ttags->count(); $i++) {
    $akct = $tags[$i];
    //$qs = $akc->field('atSelectOptionID') . '[]=' . $akct->getSelectAttributeOptionID();
    echo '<a href="' . $search . 'categories/' . rawurlencode(str_replace(' ', '_', $akct->getSelectAttributeOptionValue())) . '/">' . $akct->getSelectAttributeOptionValue() . ' (' . $akct->getSelectAttributeOptionUsageCount() . ')</a><br/>';
}
?>
</div><br/>
示例#20
0
 protected function importAttributeTypes(\SimpleXMLElement $sx)
 {
     if (isset($sx->attributetypes)) {
         foreach ($sx->attributetypes->attributetype as $at) {
             $pkg = static::getPackageObject($at['package']);
             $name = $at['name'];
             if (!$name) {
                 $name = Core::make('helper/text')->unhandle($at['handle']);
             }
             $type = AttributeType::getByHandle($at['handle']);
             if (!is_object($type)) {
                 $type = AttributeType::add($at['handle'], $name, $pkg);
             }
             if (isset($at->categories)) {
                 foreach ($at->categories->children() as $cat) {
                     $catobj = AttributeKeyCategory::getByHandle((string) $cat['handle']);
                     $catobj->associateAttributeKeyType($type);
                 }
             }
         }
     }
 }
示例#21
0
 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()
 {
     $type = Type::getByHandle($this->object->getHandle());
     return is_object($type);
 }
示例#23
0
文件: Key.php 项目: jkoudys/concrete5
 /**
  * Renders a view for this attribute key. If no view is default we display it's "view"
  * Valid views are "view", "form" or a custom view (if the attribute has one in its directory)
  * Additionally, an attribute does not have to have its own interface. If it doesn't, then whatever
  * is printed in the corresponding $view function in the attribute's controller is printed out.
  */
 public function render($view = 'view', $value = false, $return = false)
 {
     $at = AttributeType::getByHandle($this->atHandle);
     $resp = $at->render($view, $this, $value, $return);
     if ($return) {
         return $resp;
     } else {
         print $resp;
     }
 }
示例#24
0
 public function install_pb_user_attributes($pkg)
 {
     $euku = AttributeKeyCategory::getByHandle('user');
     $euku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_MULTIPLE);
     $uset = $euku->addSet('author_info', t('Author Info'), $pkg);
     $texta = AttributeType::getByHandle('textarea');
     $sbbio = UserAttributeKey::getByHandle('user_bio');
     if (!is_object($sbbio)) {
         UserAttributeKey::add($texta, array('akHandle' => 'user_bio', 'akName' => t('About the author'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => true, 'uakRegisterEdit' => true, 'uakProfileEditRequired' => true, 'akCheckedByDefault' => true, 'displayOrder' => '3'), $pkg)->setAttributeSet($uset);
     }
     $textt = AttributeType::getByHandle('text');
     $sbname = UserAttributeKey::getByHandle('first_name');
     if (!is_object($sbname)) {
         UserAttributeKey::add($textt, array('akHandle' => 'first_name', 'akName' => t('First Name'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => true, 'uakRegisterEdit' => true, 'uakProfileEditRequired' => true, 'akCheckedByDefault' => true, 'displayOrder' => '1'), $pkg)->setAttributeSet($uset);
     }
     $sblname = UserAttributeKey::getByHandle('last_name');
     if (!is_object($sblname)) {
         UserAttributeKey::add($textt, array('akHandle' => 'last_name', 'akName' => t('Last Name'), 'akIsSearchable' => false, 'uakProfileEdit' => true, 'uakProfileEditRequired' => true, 'uakRegisterEdit' => true, 'uakProfileEditRequired' => true, 'akCheckedByDefault' => true, 'displayOrder' => '2'), $pkg)->setAttributeSet($uset);
     }
     /**
      *  To Do:  rework and add back at later date.
      *  Permissions can be manual for the time being.
      */
     //        $group = Group::getByName('ProBlog Editor');
     //        if (!$group || $group->getGroupID() < 1) {
     //            $group = Group::add('ProBlog Editor','Can create and edit Blog posts');
     //        }
     //
     //        $pk = PermissionKey::getByHandle('problog_post');
     //        if (!$pk || $pk->getPermissionKeyID() < 1) {
     //            $pk = AdminPermissionKey::add('admin','problog_post',t('Create Blog Posts'),t('User can use ProBlog frontend features.'),true,false,$pkg);
     //        }
     //
     //        $pe = GroupPermissionAccessEntity::getOrCreate($group);
     //
     //        $pa = AdminPermissionAccess::create($pk);
     //
     //        $pka = new PermissionAssignment();
     //        $pka->setPermissionKeyObject($pk);
     //        $pka->assignPermissionAccess($pa);
     //
     //        $pa->addListItem($pe, false, 10);
     //
     //        $agroup = Group::getByName('ProBlog Approver');
     //        if (!$agroup || $group->getGroupID() < 1) {
     //            $agroup = Group::add('ProBlog Approver','Can Approve Blog posts');
     //        }
     //
     //        $apk = PermissionKey::getByHandle('problog_approve');
     //        if (!$apk || $apk->getPermissionKeyID() < 1) {
     //            $apk = AdminPermissionKey::add('admin','problog_approve',t('Approve Blog Posts'),t('User can Approve ProBlog posts.'),true,false,$pkg);
     //        }
     //
     //        $ape = GroupPermissionAccessEntity::getOrCreate($agroup);
     //
     //        $apa = AdminPermissionAccess::create($apk);
     //
     //        $apka = new PermissionAssignment();
     //        $apka->setPermissionKeyObject($apk);
     //        $apka->assignPermissionAccess($apa);
     //
     //        $apa->addListItem($ape, false, 10); //add approver
     //        $pa->addListItem($ape, false, 10); //append approver to edit
 }
示例#25
0
 public function addAttributeKey($type, $args, $pkg = false)
 {
     if (!is_object($type)) {
         $type = \Concrete\Core\Attribute\Type::getByHandle($type);
     }
     $controller = $type->getController();
     $settings = $controller->saveKey($args);
     if (!is_object($settings)) {
         $settings = $controller->getAttributeKeySettings();
     }
     // $key is actually an array.
     $handle = $args['akHandle'];
     $name = $args['akName'];
     $key = new LegacyKey();
     $key->setAttributeKeyHandle($handle);
     $key->setAttributeKeyName($name);
     $key->setAttributeType($type);
     $this->entityManager->persist($key);
     $this->entityManager->flush();
     $settings->setAttributeKey($key);
     $this->entityManager->persist($settings);
     $this->entityManager->flush();
     $key->setAttributeKeySettings($settings);
     $key->setAttributeCategoryEntity($this->getCategoryEntity());
     if (is_object($pkg)) {
         $key->setPackage($pkg);
     }
     // Modify the category's search indexer.
     $indexer = $this->getSearchIndexer();
     if (is_object($indexer)) {
         $indexer->updateRepositoryColumns($this, $key);
     }
     $this->entityManager->persist($key);
     $this->entityManager->flush();
     $this->clearAttributeSet($key);
     if (isset($args['asID']) && $args['asID'] > 0) {
         $key->setAttributeSet(Set::getByID($args['asID']));
     }
     $this->entityManager->flush();
     return $key;
 }
 public function configurePackage($pkg)
 {
     $theme = Theme::getByHandle('worldskills');
     if (!is_object($theme)) {
         $theme = Theme::add('worldskills', $pkg);
     }
     // add skill ID attribute
     $attributeKey = CollectionAttributeKey::getByHandle('worldskills_skill_id');
     if (!is_object($attributeKey)) {
         $type = AttributeType::getByHandle('text');
         $args = array('akHandle' => 'worldskills_skill_id', 'akName' => t('Skill ID'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1);
         CollectionAttributeKey::add($type, $args, $pkg);
     }
     // add skill page type
     $pageType = \PageType::getByHandle('worldskills_skill');
     if (!is_object($pageType)) {
         $template = \PageTemplate::getByHandle('full');
         \PageType::add(array('handle' => 'worldskills_skill', 'name' => 'Skill', 'defaultTemplate' => $template, 'allowedTemplates' => 'C', 'templates' => array($template), 'ptLaunchInComposer' => 0, 'ptIsFrequentlyAdded' => 0), $pkg)->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all')));
     }
     // add member ID attribute
     $attributeKey = CollectionAttributeKey::getByHandle('worldskills_member_id');
     if (!is_object($attributeKey)) {
         $type = AttributeType::getByHandle('text');
         $args = array('akHandle' => 'worldskills_member_id', 'akName' => t('Member ID'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1);
         CollectionAttributeKey::add($type, $args, $pkg);
     }
     // add member page type
     $pageType = \PageType::getByHandle('worldskills_member');
     if (!is_object($pageType)) {
         $template = \PageTemplate::getByHandle('full');
         \PageType::add(array('handle' => 'worldskills_member', 'name' => 'Member', 'defaultTemplate' => $template, 'allowedTemplates' => 'C', 'templates' => array($template), 'ptLaunchInComposer' => 0, 'ptIsFrequentlyAdded' => 0), $pkg)->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all')));
     }
     // add skill block
     $blockType = \BlockType::getByHandle('worldskills_skill');
     if (!is_object($blockType)) {
         \BlockType::installBlockTypeFromPackage('worldskills_skill', $pkg);
     }
     // add skill list block
     $blockType = \BlockType::getByHandle('worldskills_skill_list');
     if (!is_object($blockType)) {
         \BlockType::installBlockTypeFromPackage('worldskills_skill_list', $pkg);
     }
     // add people block
     $blockType = \BlockType::getByHandle('worldskills_people');
     if (!is_object($blockType)) {
         \BlockType::installBlockTypeFromPackage('worldskills_people', $pkg);
     }
     // add member block
     $blockType = \BlockType::getByHandle('worldskills_member');
     if (!is_object($blockType)) {
         \BlockType::installBlockTypeFromPackage('worldskills_member', $pkg);
     }
     // add member list block
     $blockType = \BlockType::getByHandle('worldskills_member_list');
     if (!is_object($blockType)) {
         \BlockType::installBlockTypeFromPackage('worldskills_member_list', $pkg);
     }
     try {
         $authenticationType = AuthenticationType::getByHandle('worldskills');
     } catch (\Exception $e) {
         $authenticationType = AuthenticationType::add('worldskills', 'WorldSkills Auth', 0, $pkg);
         $authenticationType->disable();
     }
     $page = \SinglePage::add('/dashboard/system/basics/worldskills', $pkg);
     if (is_object($pag)) {
         $page->updateCollectionName('WorldSkills');
     }
     \Config::save('worldskills.api_url', \Config::get('worldskills.api_url', 'https://api.worldskills.org'));
     \Config::save('worldskills.authorize_url', \Config::get('worldskills.authorize_url', 'https://auth.worldskills.org'));
 }
示例#27
0
 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 getCollectionSelectValues($attrHandle = '')
 {
     // Loader::model('attribute/type');
     // Loader::model('attribute/categories/collection');
     $ak = CollectionAttributeKey::getByHandle($attrHandle);
     $satc = new SelectAttributeTypeController(AttributeType::getByHandle('select'));
     $satc->setAttributeKey($ak);
     return $satc->getOptions();
 }