public function __construct(Application $app, $config, Block $b, Page $c, Area $a) { parent::__construct(); $p = new \Permissions($b); $this->permissions = $p; $this->block = $b; $this->page = $c; $this->area = $a; $this->setAttribute('data-block-menu', 'block-menu-b' . $b->getBlockID()); $this->setAttribute('class', 'ccm-edit-mode-block-menu'); $btw = $b->getBlockTypeObject(); $btOriginal = $btw; $bID = $b->getBlockID(); $aID = $a->getAreaID(); $heightPlus = 20; $btHandle = $btw->getBlockTypeHandle(); $editInline = false; if ($btw->supportsInlineEdit()) { $editInline = true; } if ($btw->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { $_bi = $b->getInstance(); $_bo = Block::getByID($_bi->getOriginalBlockID()); $btOriginal = BlockType::getByHandle($_bo->getBlockTypeHandle()); $btHandle = $btOriginal->getBlockTypeHandle(); $heightPlus = 80; if ($btOriginal->supportsInlineEdit()) { $editInline = true; } } $canDesign = $p->canEditBlockDesign() && $config->get('concrete.design.enable_custom') == true; $canModifyGroups = $p->canEditBlockPermissions() && $config->get('concrete.permissions.model') != 'simple' && !$a->isGlobalArea(); $canEditName = $p->canEditBlockName(); $canEditCacheSettings = $p->canEditBlockCacheSettings(); $canEditCustomTemplate = $p->canEditBlockCustomTemplate(); $canScheduleGuestAccess = $config->get('concrete.permissions.model') != 'simple' && $p->canGuestsViewThisBlock() && $p->canScheduleGuestAccess() && !$a->isGlobalArea(); $canAliasBlockOut = $c->isMasterCollection() && !$a->isGlobalArea(); if ($canAliasBlockOut) { $ct = Type::getByID($c->getPageTypeID()); } $isAlias = $b->isAlias(); $u = new \User(); $numChildren = !$isAlias ? $b->getNumChildren() : 0; if ($isAlias) { $deleteMessage = t('Do you want to delete this block?'); } elseif ($numChildren) { $deleteMessage = t('Do you want to delete this block? This item is an original. If you delete it, you will delete all blocks aliased to it'); } else { $deleteMessage = t('Do you want to delete this block?'); } if ($btOriginal->getBlockTypeHandle() == BLOCK_HANDLE_STACK_PROXY) { if (is_object($_bo)) { $bi = $_bo->getInstance(); } else { $bi = $b->getInstance(); } $stack = \Stack::getByID($bi->stID); if (is_object($stack)) { $sp = new \Permissions($stack); if ($sp->canWrite()) { $this->addItem(new LinkItem(\URL::to('/dashboard/blocks/stacks', 'view_details', $stack->getCollectionID()), t('Manage Stack Contents'))); } } } else { if ($p->canEditBlock() && $b->isEditable()) { if ($editInline) { if ($b->getBlockTypeHandle() == BLOCK_HANDLE_LAYOUT_PROXY) { $this->addItem(new LinkItem('javascript:void(0)', t('Edit Layout'), ['data-menu-action' => 'edit_inline', 'data-area-enable-grid-container' => $a->isGridContainerEnabled(), 'data-area-grid-maximum-columns' => $a->getAreaGridMaximumColumns()])); } else { $this->addItem(new LinkItem('javascript:void(0)', t('Edit Block'), ['data-menu-action' => 'edit_inline', 'data-area-enable-grid-container' => $a->isGridContainerEnabled(), 'data-area-grid-maximum-columns' => $a->getAreaGridMaximumColumns()])); } } else { $this->addItem(new LinkItem('javascript:void(0)', t('Edit Block'), ['data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/edit'), 'dialog-title' => t('Edit %s', t($btOriginal->getBlockTypeName())), 'dialog-width' => $btOriginal->getBlockTypeInterfaceWidth(), 'dialog-height' => $btOriginal->getBlockTypeInterfaceHeight() + $heightPlus])); } } } if ($b->getBlockTypeHandle() != BLOCK_HANDLE_LAYOUT_PROXY && $b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY) { $this->addItem(new LinkItem('javascript:void(0)', t('Copy to Clipboard'), ['data-menu-action' => 'block_scrapbook', 'data-token' => $app->make('token')->generate('tools/clipboard/to')])); } if ($p->canDeleteBlock()) { $this->addItem(new LinkItem('javascript:void(0)', t('Delete'), ['data-menu-action' => 'delete_block', 'data-menu-delete-message' => $deleteMessage])); } if ($b->getBlockTypeHandle() != BLOCK_HANDLE_LAYOUT_PROXY) { if ($canDesign || $canEditCustomTemplate || $canEditName || $canEditCacheSettings) { $this->addItem(new DividerItem()); if ($canDesign || $canEditCustomTemplate) { $this->addItem(new LinkItem('#', t('Design & Custom Template'), ['data-menu-action' => 'block_design'])); } if ($b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY && ($canEditName || $canEditCacheSettings)) { $this->addItem(new LinkItem('#', t('Advanced'), ['dialog-title' => t('Advanced Block Settings'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/cache'), 'dialog-width' => 500, 'dialog-height' => 320])); } } } if ($b->getBlockTypeHandle() != BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY && ($canModifyGroups || $canScheduleGuestAccess || $canAliasBlockOut)) { $this->addItem(new DividerItem()); if ($canModifyGroups) { $this->addItem(new LinkItem('#', t('Permissions'), ['dialog-title' => t('Block Permissions'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/permissions/list'), 'dialog-width' => 350, 'dialog-height' => 450])); } if ($canScheduleGuestAccess) { $this->addItem(new LinkItem('#', t('Schedule Guest Access'), ['dialog-title' => t('Schedule Guest Access'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/permissions/guest_access'), 'dialog-width' => 500, 'dialog-height' => 320])); } if ($canAliasBlockOut) { $this->addItem(new LinkItem('#', t('Setup on Child Pages'), ['dialog-title' => t('Setup on Child Pages'), 'data-menu-action' => 'block_dialog', 'data-menu-href' => \URL::to('/ccm/system/dialogs/block/aliasing'), 'dialog-width' => 500, 'dialog-height' => 'auto'])); } } }
public function up(Schema $schema) { $bt = BlockType::getByHandle('google_map'); if (is_object($bt)) { $bt->refresh(); } }
/** * Gets a list of block types that are not installed, used to get blocks that can be installed * This function only surveys the web/blocks directory - it's not looking at the package level. * * @return BlockType[] */ public static function getAvailableList() { $blocktypes = array(); $dir = DIR_FILES_BLOCK_TYPES; $db = Loader::db(); $btHandles = $db->GetCol("select btHandle from BlockTypes order by btDisplayOrder asc, btName asc, btID asc"); $aDir = array(); if (is_dir($dir)) { $handle = opendir($dir); while (($file = readdir($handle)) !== false) { if (strpos($file, '.') === false) { $fdir = $dir . '/' . $file; if (is_dir($fdir) && !in_array($file, $btHandles) && file_exists($fdir . '/' . FILENAME_BLOCK_CONTROLLER)) { $bt = BlockType::getByHandle($file); if (!is_object($bt)) { $bt = new BlockTypeEntity(); $bt->setBlockTypeHandle($file); $class = $bt->getBlockTypeClass(); $bta = new $class(); $bt->setBlockTypeName($bta->getBlockTypeName()); $bt->setBlockTypeDescription($bta->getBlockTypeDescription()); $bt->hasCustomViewTemplate = file_exists(DIR_FILES_BLOCK_TYPES . '/' . $file . '/' . FILENAME_BLOCK_VIEW); $bt->hasCustomEditTemplate = file_exists(DIR_FILES_BLOCK_TYPES . '/' . $file . '/' . FILENAME_BLOCK_EDIT); $bt->hasCustomAddTemplate = file_exists(DIR_FILES_BLOCK_TYPES . '/' . $file . '/' . FILENAME_BLOCK_ADD); $bt->installed = false; } else { $bt->installed = true; } $blocktypes[] = $bt; } } } } return $blocktypes; }
public function up(Schema $schema) { /** Add query log db table */ try { $table = $schema->getTable('SystemDatabaseQueryLog'); } catch (Exception $e) { $table = null; } if (!$table instanceof Table) { $ql = $schema->createTable('SystemDatabaseQueryLog'); $ql->addColumn('query', 'text'); $ql->addColumn('params', 'text', array('notnull' => false)); $ql->addColumn('executionMS', 'string'); } /** Add query log single pages */ $sp = Page::getByPath('/dashboard/system/optimization/query_log'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/system/optimization/query_log'); $sp->update(array('cName' => 'Database Query Log')); $sp->setAttribute('meta_keywords', 'queries, database, mysql'); } /** Refresh image block */ $bt = BlockType::getByHandle('image'); if (is_object($bt)) { $bt->refresh(); } }
public function install() { $pkg = parent::install(); $bt = BlockType::getByHandle('text_list'); if (!is_object($bt)) { $bt = BlockType::installBlockType('text_list', $pkg); } }
public function install() { $pkg = parent::install(); $bt = BlockType::getByHandle('login_dialog'); if (!is_object($bt)) { $bt = BlockType::installBlockType('login_dialog', $pkg); } }
public function down(Schema $schema) { // this down() migration is auto-generated, please modify it to your needs $schema->getTable('Logs')->dropColumn('testcolumn'); $schema->getTable('Files')->changeColumn('fPassword', array('type' => \Doctrine\DBAL\Types\Type::getType('string'))); $file = BlockType::getByHandle('file'); $file->delete(); }
public function up(Schema $schema) { $bt = BlockType::getByHandle('page_list'); if (is_object($bt)) { $bt->refresh(); } $bt = BlockType::getByHandle('form'); if (is_object($bt)) { $bt->refresh(); } }
protected function updateBlocks() { $this->output(t('Refreshing blocks.')); $bt = BlockType::getByHandle('express_entry_detail'); if (is_object($bt)) { $bt->refresh(); } $bt = BlockType::getByHandle('page_attribute_display'); if (is_object($bt)) { $bt->refresh(); } }
public static function saveData($p) { $blocks = $p->getBlocks('Main'); foreach ($blocks as $b) { if ($b->getBlockTypeHandle() == 'content' || $b->getBlockTypeHandle() == 'core_page_type_composer_control_output') { $b->deleteBlock(); } } Loader::model("attribute/categories/collection"); $cak = CollectionAttributeKey::getByHandle('tags'); $cak->saveAttributeForm($p); $cck = CollectionAttributeKey::getByHandle('meta_title'); $cck->saveAttributeForm($p); $cck = CollectionAttributeKey::getByHandle('meta_description'); $cck->saveAttributeForm($p); $cck = CollectionAttributeKey::getByHandle('meta_keywords'); $cck->saveAttributeForm($p); $cck = CollectionAttributeKey::getByHandle('blog_category'); $cck->saveAttributeForm($p); //$cnv = CollectionAttributeKey::getByHandle('exclude_nav'); //$cnv->saveAttributeForm($p); $ct = CollectionAttributeKey::getByHandle('thumbnail'); $ct->saveAttributeForm($p); $ca = CollectionAttributeKey::getByHandle('blog_author'); $ca->saveAttributeForm($p); $set = AttributeSet::getByHandle('problog_additional_attributes'); $setAttribs = $set->getAttributeKeys(); if ($setAttribs) { foreach ($setAttribs as $ak) { $aksv = CollectionAttributeKey::getByHandle($ak->akHandle); $aksv->saveAttributeForm($p); } } $bt = BlockType::getByHandle('content'); if (empty($_POST['blogBody'])) { $content = ' '; } else { $content = $_POST['blogBody']; } $data = array('content' => $content); $b = $p->addBlock($bt, 'Main', $data); $b->setCustomTemplate('blog_post'); $b->setAbsoluteBlockDisplayOrder('1'); $db = Loader::db(); $pTemplate = $db->getOne("SELECT ptComposerFormLayoutSetControlID FROM PageTypeComposerOutputControls WHERE pTemplateID = ? AND ptID = ?", array($p->getPageTemplateID(), $p->getPageTypeID())); if ($pTemplate) { $db->Replace('PageTypeComposerOutputBlocks', array('cID' => $p->getCollectionID(), 'arHandle' => 'Main', 'cbDisplayOrder' => 0, 'ptComposerFormLayoutSetControlID' => $pTemplate, 'bID' => $b->getBlockID()), 'cID', true); } Events::fire('on_problog_submit', $p); $ba = Loader::helper('blog_actions'); $ba->doSubscription($p); $p->reindex(); }
public function getItemsFromRequest($array) { $items = array(); foreach ($array as $id) { $item = \Concrete\Core\Block\BlockType\BlockType::getByID($id); if (is_object($item)) { $blockType = new \PortlandLabs\Concrete5\MigrationTool\Entity\Export\BlockType(); $blockType->setItemId($item->getBlockTypeID()); $items[] = $blockType; } } return $items; }
public function import(\SimpleXMLElement $sx) { if (isset($sx->blocktypes)) { foreach ($sx->blocktypes->blocktype as $bt) { if (!is_object(BlockType::getByHandle((string) $bt['handle']))) { $pkg = static::getPackageObject($bt['package']); if (is_object($pkg)) { BlockType::installBlockTypeFromPackage((string) $bt['handle'], $pkg); } else { BlockType::installBlockType((string) $bt['handle']); } } } } }
public function importPageAreas(Page $page, \SimpleXMLElement $px) { foreach ($px->area as $ax) { if (isset($ax->blocks)) { foreach ($ax->blocks->block as $bx) { if ($bx['type'] != '') { // we check this because you might just get a block node with only an mc-block-id, if it's an alias $bt = BlockType::getByHandle((string) $bx['type']); if (!is_object($bt)) { throw new \Exception(t('Invalid block type handle: %s', strval($bx['type']))); } $btc = $bt->getController(); $btc->import($page, (string) $ax['name'], $bx); } else { if ($bx['mc-block-id'] != '') { // we find that block in the master collection block pool and alias it out $bID = array_search((string) $bx['mc-block-id'], ContentImporter::getMasterCollectionTemporaryBlockIDs()); if ($bID) { $mc = Page::getByID($page->getMasterCollectionID(), 'RECENT'); $block = Block::getByID($bID, $mc, (string) $ax['name']); $block->alias($page); if ($block->getBlockTypeHandle() == BLOCK_HANDLE_LAYOUT_PROXY) { // we have to go get the blocks on that page in this layout. $btc = $block->getController(); $arLayout = $btc->getAreaLayoutObject(); $columns = $arLayout->getAreaLayoutColumns(); foreach ($columns as $column) { $area = $column->getAreaObject(); $blocks = $area->getAreaBlocksArray($mc); foreach ($blocks as $_b) { $_b->alias($page); } } } } } } } } if (isset($ax->style)) { $area = \Area::get($page, (string) $ax['name']); $set = StyleSet::import($ax->style); $page->setCustomStyleSet($area, $set); } } }
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); } } } } }
public function up(Schema $schema) { /* delete customize page themes dashboard single page */ $customize = Page::getByPath('/dashboard/pages/themes/customize'); if (is_object($customize) && !$customize->isError()) { $customize->delete(); } /* Add inspect single page back if it's missing */ $sp = Page::getByPath('/dashboard/pages/themes/inspect'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/pages/themes/inspect'); $sp->setAttribute('meta_keywords', 'inspect, templates'); $sp->setAttribute('exclude_nav', 1); } $sp = Page::getByPath('/members/directory'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/members/directory'); $sp->setAttribute('exclude_nav', 1); } $bt = BlockType::getByHandle('feature'); if (is_object($bt)) { $bt->refresh(); } $bt = BlockType::getByHandle('image_slider'); if (is_object($bt)) { $bt->refresh(); } $db = Database::get(); $sm = $db->getSchemaManager(); $schemaTables = $sm->listTableNames(); if (in_array('signuprequests', $schemaTables)) { $db->query('alter table signuprequests rename SignupRequestsTmp'); $db->query('alter table SignupRequestsTmp rename SignupRequests'); } if (in_array('userbannedips', $schemaTables)) { $db->query('alter table userbannedips rename UserBannedIPsTmp'); $db->query('alter table UserBannedIPsTmp rename UserBannedIPs'); } // Clean up File stupidity $r = $db->Execute('select Files.fID from Files left join FileVersions on (Files.fID = FileVersions.fID) where FileVersions.fID is null'); while ($row = $r->FetchRow()) { $db->Execute('delete from Files where fID = ?', array($row['fID'])); } }
public function execute(Batch $batch) { $types = $batch->getObjectCollection('block_type'); if (!$types) { return; } foreach ($types->getTypes() as $type) { if (!$type->getPublisherValidator()->skipItem()) { $pkg = null; if ($type->getPackage()) { $pkg = \Package::getByHandle($type->getPackage()); } if (is_object($pkg)) { BlockType::installBlockTypeFromPackage($type->getHandle(), $pkg); } else { BlockType::installBlockType($type->getHandle()); } } } }
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); } } } } }
public function up(Schema $schema) { \Concrete\Core\Database\Schema\Schema::refreshCoreXMLSchema(array('ConversationPermissionAddMessageAccessList', 'ConversationSubscriptions', 'Conversations')); // Subscribe admin to conversations by default, if we have no subscriptions $users = \Conversation::getDefaultSubscribedUsers(); if (count($users) == 0) { $admin = \UserInfo::getByID(USER_SUPER_ID); if (is_object($admin)) { $users = array($admin); \Conversation::setDefaultSubscribedUsers($users); } } $db = \Database::get(); $db->Execute('DROP TABLE IF EXISTS PageStatistics'); $pp = $schema->getTable('PagePaths'); if (!$pp->hasColumn('ppGeneratedFromURLSlugs')) { $db->Execute('alter table PagePaths add column ppGeneratedFromURLSlugs tinyint(1) unsigned not null default 0'); // we have to do this directly because the page path calls below will die otherwise. } $bt = BlockType::getByHandle('page_list'); if (is_object($bt)) { $bt->refresh(); } $bt = BlockType::getByHandle('page_title'); if (is_object($bt)) { $bt->refresh(); } $bt = BlockType::getByHandle('form'); if (is_object($bt)) { $bt->refresh(); } $c = \Page::getByPath('/dashboard/system/seo/urls'); if (is_object($c) && !$c->isError()) { $c->update(array('cName' => 'URLs and Redirection')); } $sp = \Page::getByPath('/dashboard/system/environment/entities'); if (!is_object($sp) || $sp->isError()) { $sp = \SinglePage::add('/dashboard/system/environment/entities'); $sp->update(array('cName' => 'Database Entities')); $sp->setAttribute('meta_keywords', 'database, entities, doctrine, orm'); } $pkx = Category::getByHandle('multilingual_section'); if (!is_object($pkx)) { $pkx = Category::add('multilingual_section'); } $pkx->associateAccessEntityType(Type::getByHandle('group')); $pkx->associateAccessEntityType(Type::getByHandle('user')); $pkx->associateAccessEntityType(Type::getByHandle('group_combination')); $db->Execute("alter table QueueMessages modify column body longtext not null"); $ms = $schema->getTable('MultilingualSections'); if (!$ms->hasColumn('msNumPlurals')) { $ms->addColumn('msNumPlurals', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 2)); $this->updateSectionPlurals = true; } if (!$ms->hasColumn('msPluralRule')) { $ms->addColumn('msPluralRule', 'string', array('notnull' => true, 'length' => 400, 'default' => '(n != 1)')); $this->updateSectionPlurals = true; } if (!$ms->hasColumn('msPluralCases')) { $ms->addColumn('msPluralCases', 'string', array('notnull' => true, 'length' => 1000, 'default' => "one@1\nother@0, 2~16, 100, 1000, 10000, 100000, 1000000, …")); $this->updateSectionPlurals = true; } $mt = $schema->getTable('MultilingualTranslations'); if (!$mt->hasColumn('msgidPlural')) { $mt->addColumn('msgidPlural', 'text', array('notnull' => false)); $this->updateMultilingualTranslations = true; } if (!$mt->hasColumn('msgstrPlurals')) { $mt->addColumn('msgstrPlurals', 'text', array('notnull' => false)); $this->updateMultilingualTranslations = true; } $cms = $schema->getTable('ConversationMessages'); if (!$cms->hasColumn('cnvMessageAuthorName')) { $cms->addColumn('cnvMessageAuthorName', 'string', array('notnull' => false, 'length' => 255)); } if (!$cms->hasColumn('cnvMessageAuthorEmail')) { $cms->addColumn('cnvMessageAuthorEmail', 'string', array('notnull' => false, 'length' => 255)); } if (!$cms->hasColumn('cnvMessageAuthorWebsite')) { $cms->addColumn('cnvMessageAuthorWebsite', 'string', array('notnull' => false, 'length' => 255)); } $this->updatePermissionDurationObjects(); $key = Key::getByHandle('add_conversation_message'); if (is_object($key) && !$key->permissionKeyHasCustomClass()) { $key->setPermissionKeyHasCustomClass(true); } $this->installMaintenanceModePermission(); }
/** * Utility method for clearing all application caches. */ public function clearCaches() { \Events::dispatch('on_cache_flush'); $this['cache']->flush(); $this['cache/expensive']->flush(); $config = $this['config']; // Delete and re-create the cache directory $cacheDir = $config->get('concrete.cache.directory'); if (is_dir($cacheDir)) { $fh = Core::make('helper/file'); $fh->removeAll($cacheDir, true); } $this->setupFilesystem(); $pageCache = PageCache::getLibrary(); if (is_object($pageCache)) { $pageCache->flush(); } // clear the environment overrides cache $env = \Environment::get(); $env->clearOverrideCache(); // Clear localization cache Localization::clearCache(); // clear block type cache BlockType::clearCache(); // Clear precompiled script bytecode caches OpCache::clear(); }
public function skipItem() { $type = BlockType::getByHandle($this->object->getHandle()); return is_object($type); }
/** * Utility method for clearing all application caches. */ public function clearCaches() { \Events::dispatch('on_cache_flush'); $this['cache']->flush(); $this['cache/expensive']->flush(); $config = $this['config']; // Delete and re-create the cache directory $cacheDir = $config->get('concrete.cache.directory'); if (is_dir($cacheDir)) { $fh = Core::make('helper/file'); $fh->removeAll($cacheDir, true); } $this->setupFilesystem(); $pageCache = PageCache::getLibrary(); if (is_object($pageCache)) { $pageCache->flush(); } // Clear the file thumbnail path cache $connection = $this['database']; $sql = $connection->getDatabasePlatform()->getTruncateTableSQL('FileImageThumbnailPaths'); try { $connection->executeUpdate($sql); } catch (\Exception $e) { } // clear the environment overrides cache $env = \Environment::get(); $env->clearOverrideCache(); // Clear localization cache Localization::clearCache(); // clear block type cache BlockType::clearCache(); // Clear precompiled script bytecode caches OpCache::clear(); \Events::dispatch('on_cache_flush_end'); }
public function getRssImgUrl() { $uh = Loader::helper('concrete/urls'); $bt = BlockType::getByHandle('problog_list'); $rssIconUrl = $uh->getBlockTypeAssetsURL($bt, '/images/rss.png'); return $rssIconUrl; }
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 getTargetItemContentObject(TargetItemInterface $targetItem) { return \Concrete\Core\Block\BlockType\BlockType::getByHandle($targetItem->getItemID()); }
public function up(Schema $schema) { $ft = FlagType::getByhandle('spam'); if (!is_object($ft)) { FlagType::add('spam'); } $bt = BlockType::getByHandle('image_slider'); $bt->refresh(); $types = array(Type::getByHandle('group'), Type::getByHandle('user'), Type::getByHandle('group_set'), Type::getByHandle('group_combination')); $categories = array(Category::getByHandle('conversation'), Category::getByHandle('conversation_message')); foreach ($categories as $category) { foreach ($types as $pe) { if (is_object($category) && is_object($pe)) { $category->associateAccessEntityType($pe); } } } try { $gat = AuthenticationType::getByHandle('google'); } catch (Exception $e) { $gat = AuthenticationType::add('google', 'Google'); if (is_object($gat)) { $gat->disable(); } } // fix register page permissions $g1 = \Group::getByID(GUEST_GROUP_ID); $register = \Page::getByPath('/register', "RECENT"); $register->assignPermissions($g1, array('view_page')); // add new permissions, set it to the same value as edit page permissions on all pages. $epk = PermissionKey::getByHandle('edit_page_permissions'); $msk = PermissionKey::getByHandle('edit_page_multilingual_settings'); $ptk = PermissionKey::getByHandle('edit_page_page_type'); if (!is_object($msk)) { $msk = PermissionKey::add('page', 'edit_page_multilingual_settings', 'Edit Multilingual Settings', 'Controls whether a user can see the multilingual settings menu, re-map a page or set a page as ignored in multilingual settings.', false, false); } if (!is_object($ptk)) { $ptk = PermissionKey::add('page', 'edit_page_page_type', 'Edit Page Type', 'Change the type of an existing page.', false, false); } $db = \Database::get(); $r = $db->Execute('select cID from Pages where cInheritPermissionsFrom = "OVERRIDE" order by cID asc'); while ($row = $r->FetchRow()) { $c = Page::getByID($row['cID']); if (is_object($c) && !$c->isError()) { $epk->setPermissionObject($c); $msk->setPermissionObject($c); $ptk->setPermissionObject($c); $rpa = $epk->getPermissionAccessObject(); if (is_object($rpa)) { $pt = $msk->getPermissionAssignmentObject(); if (is_object($pt)) { $pt->clearPermissionAssignment(); $pt->assignPermissionAccess($rpa); } $pt = $ptk->getPermissionAssignmentObject(); if (is_object($pt)) { $pt->clearPermissionAssignment(); $pt->assignPermissionAccess($rpa); } } } } // add new page type permissions $epk = PermissionKey::getByHandle('edit_page_type_permissions'); $msk = PermissionKey::getByHandle('edit_page_type'); $dsk = PermissionKey::getByHandle('delete_page_type'); if (!is_object($msk)) { $msk = PermissionKey::add('page_type', 'edit_page_type', 'Edit Page Type', '', false, false); } if (!is_object($dsk)) { $dsk = PermissionKey::add('page_type', 'delete_page_type', 'Delete Page Type', '', false, false); } $list = \Concrete\Core\Page\Type\Type::getList(); foreach ($list as $pagetype) { $epk->setPermissionObject($pagetype); $msk->setPermissionObject($pagetype); $dsk->setPermissionObject($pagetype); $rpa = $epk->getPermissionAccessObject(); if (is_object($rpa)) { $pt = $msk->getPermissionAssignmentObject(); if (is_object($pt)) { $pt->clearPermissionAssignment(); $pt->assignPermissionAccess($rpa); } $pt = $dsk->getPermissionAssignmentObject(); if (is_object($pt)) { $pt->clearPermissionAssignment(); $pt->assignPermissionAccess($rpa); } } } // add new multilingual tables. $sm = $db->getSchemaManager(); $schemaTables = $sm->listTableNames(); if (!in_array('MultilingualPageRelations', $schemaTables)) { $mpr = $schema->createTable('MultilingualPageRelations'); $mpr->addColumn('mpRelationID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0)); $mpr->addColumn('cID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0)); $mpr->addColumn('mpLanguage', 'string', array('notnull' => true, 'default' => '')); $mpr->addColumn('mpLocale', 'string', array('notnull' => true)); $mpr->setPrimaryKey(array('mpRelationID', 'cID', 'mpLocale')); } if (!in_array('MultilingualSections', $schemaTables)) { $mus = $schema->createTable('MultilingualSections'); $mus->addColumn('cID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0)); $mus->addColumn('msLanguage', 'string', array('notnull' => true, 'default' => '')); $mus->addColumn('msCountry', 'string', array('notnull' => true, 'default' => '')); $mus->setPrimaryKey(array('cID')); } if (!in_array('MultilingualTranslations', $schemaTables)) { $mts = $schema->createTable('MultilingualTranslations'); $mts->addColumn('mtID', 'integer', array('autoincrement' => true, 'unsigned' => true)); $mts->addColumn('mtSectionID', 'integer', array('unsigned' => true, 'notnull' => true, 'default' => 0)); $mts->addColumn('msgid', 'text', array('notnull' => false)); $mts->addColumn('msgstr', 'text', array('notnull' => false)); $mts->addColumn('context', 'text', array('notnull' => false)); $mts->addColumn('comments', 'text', array('notnull' => false)); $mts->addColumn('reference', 'text', array('notnull' => false)); $mts->addColumn('flags', 'text', array('notnull' => false)); $mts->addColumn('updated', 'datetime', array('notnull' => false)); $mts->setPrimaryKey(array('mtID')); } // block type $bt = BlockType::getByHandle('switch_language'); if (!is_object($bt)) { $bt = BlockType::installBlockType('switch_language'); } // single pages $sp = Page::getByPath('/dashboard/system/multilingual'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/system/multilingual'); $sp->update(array('cName' => 'Multilingual')); $sp->setAttribute('meta_keywords', 'multilingual, localization, internationalization, i18n'); } $sp = Page::getByPath('/dashboard/system/multilingual/setup'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/system/multilingual/setup'); $sp->update(array('cName' => 'Multilingual Setup')); } $sp = Page::getByPath('/dashboard/system/multilingual/page_report'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/system/multilingual/page_report'); $sp->update(array('cName' => 'Page Report')); } $sp = Page::getByPath('/dashboard/system/multilingual/translate_interface'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/system/multilingual/translate_interface'); $sp->update(array('cName' => 'Translate Interface')); } $sp = Page::getByPath('/dashboard/pages/types/attributes'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/pages/types/attributes'); $sp->update(array('cName' => 'Page Type Attributes')); } }
<?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
/** * {@inheritDoc} */ public function add($data, $c = false, $a = false) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'add', array($data, $c, $a)); return parent::add($data, $c, $a); }
$class = 'ccm-block-edit'; } $class .= $b->isAliasOfMasterCollection() || $b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY ? " ccm-block-alias" : ""; if ($b->getBlockTypeHandle() == BLOCK_HANDLE_STACK_PROXY) { $class .= ' ccm-block-stack '; } $editInline = false; if ($btw->supportsInlineEdit()) { $editInline = true; } $aID = $a->getAreaID(); $btHandle = $btw->getBlockTypeHandle(); if ($btw->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { $_bi = $b->getInstance(); $_bo = Block::getByID($_bi->getOriginalBlockID()); $btOriginal = \Concrete\Core\Block\BlockType\BlockType::getByHandle($_bo->getBlockTypeHandle()); $btHandle = $btOriginal->getBlockTypeHandle(); } ?> <div data-cID="<?php echo $c->getCollectionID(); ?> " data-area-id="<?php echo $a->getAreaID(); ?> " data-block-id="<?php echo $b->getBlockID();
public function import($page, $arHandle, \SimpleXMLElement $blockNode) { $db = Database::connection(); // handle the adodb stuff $args = $this->getImportData($blockNode, $page); $blockData = array(); $bt = BlockType::getByHandle($this->btHandle); $b = $page->addBlock($bt, $arHandle, $args); $bName = (string) $blockNode['name']; $bFilename = (string) $blockNode['custom-template']; if ($bName) { $blockData['bName'] = $bName; } if ($bFilename) { $blockData['bFilename'] = $bFilename; } if (count($blockData)) { $b->updateBlockInformation($blockData); } if ($page->isMasterCollection() && $blockNode['mc-block-id'] != '') { ContentImporter::addMasterCollectionBlockID($b, (string) $blockNode['mc-block-id']); } // now we insert stuff that isn't part of the btTable // we have to do this this way because we need a bID $this->importAdditionalData($b, $blockNode); // now we handle the styles if (isset($blockNode->style)) { $set = StyleSet::import($blockNode->style); $b->setCustomStyleSet($set); } // now we handle block caching $cache = (int) $blockNode['cache-output']; if ($cache) { $b->setCustomCacheSettings(true, $blockNode['cache-output-on-post'], $blockNode['cache-output-for-registered-users'], $blockNode['cache-output-lifetime']); } }
/** * refreshes the BlockType's database schema throws an Exception if error. */ public function refresh() { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $pkgHandle = false; if ($this->pkgID > 0) { $pkgHandle = $this->getPackageHandle(); } $class = \Concrete\Core\Block\BlockType\BlockType::getBlockTypeMappedClass($this->btHandle, $pkgHandle); $bta = $app->build($class); $this->loadFromController($bta); $em = \ORM::entityManager(); $em->persist($this); $em->flush(); $env = Environment::get(); $r = $env->getRecord(DIRNAME_BLOCKS . '/' . $this->btHandle . '/' . FILENAME_BLOCK_DB, $this->getPackageHandle()); if ($r->exists()) { $parser = Schema::getSchemaParser(simplexml_load_file($r->file)); $parser->setIgnoreExistingTables(false); $toSchema = $parser->parse($db); $fromSchema = $db->getSchemaManager()->createSchema(); $comparator = new \Doctrine\DBAL\Schema\Comparator(); $schemaDiff = $comparator->compare($fromSchema, $toSchema); $saveQueries = $schemaDiff->toSaveSql($db->getDatabasePlatform()); foreach ($saveQueries as $query) { $db->query($query); } } }