/** * 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; }
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); } } } } }
/** * 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; }
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(); } }
public function skipItem() { $set = Set::getByHandle($this->object->getHandle()); return is_object($set); }