コード例 #1
0
 /**
  * Installs a BlockType that is passed via a btHandle string. The core or override directories are parsed.
  */
 public static function installBlockType($btHandle, $pkg = false)
 {
     $env = Environment::get();
     $pkgHandle = false;
     if (is_object($pkg)) {
         $pkgHandle = $pkg->getPackageHandle();
     }
     $class = static::getBlockTypeMappedClass($btHandle, $pkgHandle);
     $app = Facade::getFacadeApplication();
     $bta = $app->build($class);
     $path = dirname($env->getPath(DIRNAME_BLOCKS . '/' . $btHandle . '/' . FILENAME_BLOCK_DB, $pkgHandle));
     //Attempt to run the subclass methods (install schema from db.xml, etc.)
     $r = $bta->install($path);
     // Prevent the database records being stored in wrong language
     $loc = Localization::getInstance();
     $loc->pushActiveContext('system');
     //Install the block
     $bt = new \Concrete\Core\Entity\Block\BlockType\BlockType();
     $bt->loadFromController($bta);
     if (is_object($pkg)) {
         $bt->setPackageID($pkg->getPackageID());
     }
     $bt->setBlockTypeHandle($btHandle);
     $loc->popActiveContext();
     $em = \ORM::entityManager();
     $em->persist($bt);
     $em->flush();
     if ($bta->getBlockTypeDefaultSet()) {
         $set = Set::getByHandle($bta->getBlockTypeDefaultSet());
         if (is_object($set)) {
             $set->addBlockType($bt);
         }
     }
     return $bt;
 }
コード例 #2
0
 public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->blocktypesets)) {
         foreach ($sx->blocktypesets->blocktypeset as $bts) {
             $pkg = static::getPackageObject($bts['package']);
             $set = Set::getByHandle((string) $bts['handle']);
             if (!is_object($set)) {
                 $set = Set::add((string) $bts['handle'], (string) $bts['name'], $pkg);
             }
             foreach ($bts->children() as $btk) {
                 $bt = BlockType::getByHandle((string) $btk['handle']);
                 if (is_object($bt)) {
                     $set->addBlockType($bt);
                 }
             }
         }
     }
 }
コード例 #3
0
 public function execute(Batch $batch)
 {
     $sets = $batch->getObjectCollection('block_type_set');
     if (!$sets) {
         return;
     }
     foreach ($sets->getSets() as $set) {
         if (!$set->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($set->getPackage()) {
                 $pkg = \Package::getByHandle($set->getPackage());
             }
             $set = Set::add($set->getHandle(), $set->getName(), $pkg);
             $types = $set->getTypes();
             foreach ($types as $handle) {
                 $bt = BlockType::getByHandle($handle);
                 if (is_object($bt)) {
                     $set->addBlockType($bt);
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: add.php プロジェクト: ppiedaderawnet/concrete5
 public function view()
 {
     $btl = new BlockTypeList();
     $blockTypes = $btl->get();
     $dsh = $this->app->make('helper/concrete/dashboard');
     if ($this->page->isMasterCollection()) {
         $bt = BlockType::getByHandle(BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY);
         $blockTypes[] = $bt;
     }
     $requestTab = $this->request('tab');
     $session = $this->app->make('session');
     if ($requestTab) {
         $session->set('panels_page_add_block_tab', $requestTab);
         $tab = $requestTab;
     } else {
         $tab = $session->get('panels_page_add_block_tab');
     }
     $sp = (new Pile())->getDefault();
     $contents = $sp->getPileContentObjects('date_desc');
     $stacks = new StackList();
     //if (\Core::make('multilingual/detector')->isEnabled()) {
     //    $stacks->filterByPageLanguage($this->page);
     //}
     $stacks->filterByUserAdded();
     if ($dsh->inDashboard() || strpos($this->page->getCollectionPath(), '/account') === 0) {
         $sets = Set::getList(array());
     } else {
         $sets = Set::getList();
     }
     $this->set('stacks', $stacks->getResults());
     $this->set('contents', $contents);
     $this->set('tab', $tab);
     $this->set('blockTypes', $blockTypes);
     $this->set('sets', $sets);
     $this->set('ih', $this->app->make('helper/concrete/ui'));
     $this->set('ci', $this->app->make('helper/concrete/urls'));
 }
コード例 #5
0
ファイル: BlockType.php プロジェクト: ceko/concrete5-1
 /**
  * Installs a BlockType that is passed via a btHandle string. The core or override directories are parsed.
  */
 public static function installBlockType($btHandle, $pkg = false)
 {
     $env = Environment::get();
     $pkgHandle = false;
     if (is_object($pkg)) {
         $pkgHandle = $pkg->getPackageHandle();
     }
     $class = static::getBlockTypeMappedClass($btHandle, $pkgHandle);
     $bta = new $class();
     $path = dirname($env->getPath(DIRNAME_BLOCKS . '/' . $btHandle . '/' . FILENAME_BLOCK_DB, $pkgHandle));
     //Attempt to run the subclass methods (install schema from db.xml, etc.)
     $r = $bta->install($path);
     $currentLocale = Localization::activeLocale();
     if ($currentLocale != 'en_US') {
         // Prevent the database records being stored in wrong language
         Localization::changeLocale('en_US');
     }
     //Install the block
     $bt = new static();
     $bt->loadFromController($bta);
     if ($pkg instanceof Package) {
         $bt->pkgID = $pkg->getPackageID();
     } else {
         $bt->pkgID = 0;
     }
     $bt->btHandle = $btHandle;
     if ($currentLocale != 'en_US') {
         Localization::changeLocale($currentLocale);
     }
     $em = DB::get()->getEntityManager();
     $em->persist($bt);
     $em->flush();
     if ($bta->getBlockTypeDefaultSet()) {
         $set = Set::getByHandle($bta->getBlockTypeDefaultSet());
         if (is_object($set)) {
             $set->addBlockType($bt);
         }
     }
     return $bt;
 }
コード例 #6
0
 /**
  * Returns an array of package items (e.g. blocks, themes)
  */
 public function getPackageItems()
 {
     $items = array();
     $items['attribute_categories'] = AttributeKeyCategory::getListByPackage($this);
     $items['permission_categories'] = PermissionKeyCategory::getListByPackage($this);
     $items['permission_access_entity_types'] = PermissionAccessEntityType::getListByPackage($this);
     $items['attribute_keys'] = AttributeKey::getListByPackage($this);
     $items['attribute_sets'] = AttributeSet::getListByPackage($this);
     $items['group_sets'] = GroupSet::getListByPackage($this);
     $items['page_types'] = PageType::getListByPackage($this);
     $items['page_templates'] = PageTemplate::getListByPackage($this);
     $items['mail_importers'] = MailImporter::getListByPackage($this);
     $items['gathering_item_template_types'] = GatheringItemTemplateType::getListByPackage($this);
     $items['gathering_item_templates'] = GatheringItemTemplate::getListByPackage($this);
     $items['gathering_data_sources'] = GatheringDataSource::getListByPackage($this);
     $items['features'] = Feature::getListByPackage($this);
     $items['feature_categories'] = FeatureCategory::getListByPackage($this);
     $btl = new BlockTypeList();
     $btl->filterByPackage($this);
     $blocktypes = $btl->get();
     $items['block_types'] = $blocktypes;
     $items['block_type_sets'] = BlockTypeSet::getListByPackage($this);
     $items['page_themes'] = PageTheme::getListByPackage($this);
     $items['permissions'] = PermissionKey::getListByPackage($this);
     $items['single_pages'] = SinglePage::getListByPackage($this);
     $items['attribute_types'] = AttributeType::getListByPackage($this);
     $items['captcha_libraries'] = SystemCaptchaLibrary::getListByPackage($this);
     $items['content_editor_snippets'] = SystemContentEditorSnippet::getListByPackage($this);
     $items['conversation_editors'] = ConversationEditor::getListByPackage($this);
     $items['conversation_rating_types'] = ConversationRatingType::getListByPackage($this);
     $items['page_type_publish_target_types'] = PageTypePublishTargetType::getListByPackage($this);
     $items['page_type_composer_control_types'] = PageTypeComposerControlType::getListByPackage($this);
     $items['antispam_libraries'] = SystemAntispamLibrary::getListByPackage($this);
     $items['community_point_actions'] = UserPointAction::getListByPackage($this);
     $items['jobs'] = Job::getListByPackage($this);
     $items['workflow_types'] = WorkflowType::getListByPackage($this);
     ksort($items);
     return $items;
 }
コード例 #7
0
 public function run()
 {
     $this->x = new SimpleXMLElement("<concrete5-cif></concrete5-cif>");
     $this->x->addAttribute('version', '1.0');
     // First, attribute categories
     AttributeKeyCategory::exportList($this->x);
     // Features
     Feature::exportList($this->x);
     FeatureCategory::exportList($this->x);
     ConversationEditor::exportList($this->x);
     ConversationRatingType::exportList($this->x);
     // composer
     PageTypePublishTargetType::exportList($this->x);
     PageTypeComposerControlType::exportList($this->x);
     PageType::exportList($this->x);
     // attribute types
     AttributeType::exportList($this->x);
     // then block types
     BlockTypeList::exportList($this->x);
     // now block type sets (including user)
     BlockTypeSet::exportList($this->x);
     // gathering
     GatheringDataSource::exportList($this->x);
     GatheringItemTemplate::exportList($this->x);
     // now attribute keys (including user)
     AttributeKey::exportList($this->x);
     // now attribute keys (including user)
     AttributeSet::exportList($this->x);
     PageTemplate::exportList($this->x);
     // now theme
     PageTheme::exportList($this->x);
     // now packages
     PackageList::export($this->x);
     // permission access entity types
     PermissionAccessEntityType::exportList($this->x);
     // now task permissions
     PermissionKey::exportList($this->x);
     // workflow types
     WorkflowType::exportList($this->x);
     // now jobs
     Job::exportList($this->x);
     // now single pages
     $singlepages = $this->x->addChild("singlepages");
     $db = Loader::db();
     $r = $db->Execute('select cID from Pages where cFilename is not null and cFilename <> "" and cID not in (select cID from Stacks) order by cID asc');
     while ($row = $r->FetchRow()) {
         $pc = Page::getByID($row['cID'], 'RECENT');
         $pc->export($singlepages);
     }
     // now stacks/global areas
     StackList::export($this->x);
     // now content pages
     $pages = $this->x->addChild("pages");
     $db = Loader::db();
     $r = $db->Execute('select Pages.cID from Pages where cIsTemplate = 0 and cFilename is null or cFilename = "" order by cID asc');
     while ($row = $r->FetchRow()) {
         $pc = Page::getByID($row['cID'], 'RECENT');
         if ($pc->getPageTypeHandle() == STACKS_PAGE_TYPE) {
             continue;
         }
         $pc->export($pages);
     }
     SystemCaptchaLibrary::exportList($this->x);
     \Concrete\Core\Sharing\SocialNetwork\Link::exportList($this->x);
     \Concrete\Core\Page\Feed::exportList($this->x);
     \Concrete\Core\File\Image\Thumbnail\Type\Type::exportList($this->x);
     Config::exportList($this->x);
     Tree::exportList($this->x);
 }
コード例 #8
0
 protected function addBlockTypes()
 {
     $this->output(t('Adding block types...'));
     $desktopSet = \Concrete\Core\Block\BlockType\Set::getByHandle('core_desktop');
     if (!is_object($desktopSet)) {
         $desktopSet = \Concrete\Core\Block\BlockType\Set::add('core_desktop', 'Desktop');
     }
     $expressSet = \Concrete\Core\Block\BlockType\Set::getByHandle('express');
     if (!is_object($expressSet)) {
         $expressSet = \Concrete\Core\Block\BlockType\Set::add('express', 'Express');
     }
     $formSet = \Concrete\Core\Block\BlockType\Set::getByHandle('form');
     if (!is_object($formSet)) {
         $formSet = \Concrete\Core\Block\BlockType\Set::add('form', 'Forms');
     }
     $bt = BlockType::getByHandle('express_form');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('express_form');
     }
     $formSet->addBlockType($bt);
     $bt = BlockType::getByHandle('express_entry_list');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('express_entry_list');
     }
     $expressSet->addBlockType($bt);
     $bt = BlockType::getByHandle('express_entry_detail');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('express_entry_detail');
     }
     $expressSet->addBlockType($bt);
     $bt = BlockType::getByHandle('dashboard_site_activity');
     if (is_object($bt)) {
         $bt->delete();
     }
     $bt = BlockType::getByHandle('dashboard_app_status');
     if (is_object($bt)) {
         $bt->delete();
     }
     $bt = BlockType::getByHandle('dashboard_featured_theme');
     if (is_object($bt)) {
         $bt->delete();
     }
     $bt = BlockType::getByHandle('dashboard_featured_addon');
     if (is_object($bt)) {
         $bt->delete();
     }
     $bt = BlockType::getByHandle('dashboard_newsflow_latest');
     if (is_object($bt)) {
         $bt->delete();
     }
     $bt = BlockType::getByHandle('desktop_site_activity');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('desktop_site_activity');
     }
     $desktopSet->addBlockType($bt);
     $bt = BlockType::getByHandle('desktop_app_status');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('desktop_app_status');
     }
     $desktopSet->addBlockType($bt);
     $bt = BlockType::getByHandle('desktop_featured_theme');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('desktop_featured_theme');
     }
     $desktopSet->addBlockType($bt);
     $bt = BlockType::getByHandle('desktop_featured_addon');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('desktop_featured_addon');
     }
     $desktopSet->addBlockType($bt);
     $bt = BlockType::getByHandle('desktop_newsflow_latest');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('desktop_newsflow_latest');
     }
     $desktopSet->addBlockType($bt);
     $bt = BlockType::getByHandle('desktop_latest_form');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('desktop_latest_form');
     }
     $desktopSet->addBlockType($bt);
     $bt = BlockType::getByHandle('desktop_waiting_for_me');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('desktop_waiting_for_me');
     }
     $desktopSet->addBlockType($bt);
     $bt = BlockType::getByHandle('desktop_waiting_for_me');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('desktop_waiting_for_me');
     }
     $desktopSet->addBlockType($bt);
     $bt = BlockType::getByHandle('page_title');
     if (is_object($bt)) {
         $bt->refresh();
     }
     $bt = BlockType::getByHandle('page_list');
     if (is_object($bt)) {
         $bt->refresh();
     }
     $bt = BlockType::getByHandle('next_previous');
     if (is_object($bt)) {
         $bt->refresh();
     }
     $bt = BlockType::getByHandle('autonav');
     if (is_object($bt)) {
         $bt->refresh();
     }
 }
コード例 #9
0
 protected function run_install($pkg)
 {
     $db = Loader::db();
     BlockTypeSet::add('commerce', 'Commerce', $pkg);
     $db->Execute('update BlockTypeSets set btsDisplayOrder = 1 where btsHandle != "commerce"');
 }
コード例 #10
0
 public function skipItem()
 {
     $set = Set::getByHandle($this->object->getHandle());
     return is_object($set);
 }
コード例 #11
0
 public function getPackageItems(Package $package)
 {
     return Set::getListByPackage($package);
 }
コード例 #12
0
 public function setPropertiesFromArray($arr)
 {
     return parent::setPropertiesFromArray($arr);
 }