public function getPassThruBlockController(Block $b) { return $this->passThruBlocks[$b->getBlockID()]; }
/** * Gets the generic Block object attached to this controller's instance. * * @return Block $b */ public function getBlockObject() { if (is_object($this->block)) { return $this->block; } return Block::getByID($this->bID); }
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 setPropertiesFromArray($arr) { return parent::setPropertiesFromArray($arr); }
public function recordPageTypeComposerOutputBlock(\Concrete\Core\Block\Block $block) { $app = Application::getFacadeApplication(); $db = $app->make('database')->connection(); $setControl = $this->getPageTypeComposerFormLayoutSetControlObject(); $db->executeQuery('insert into PageTypeComposerOutputBlocks (cID, arHandle, ptComposerFormLayoutSetControlID, cbDisplayOrder, bID) values (?, ?, ?, ?, ?)', [$block->getBlockCollectionID(), $block->getAreaHandle(), $setControl->getPageTypeComposerFormLayoutSetControlID(), $block->getBlockDisplayOrder(), $block->getBlockID()]); }
/** * @param Block $b */ public function setPermissionObject($b) { $this->permissionObject = $b; // if the area overrides the collection permissions explicitly (with a one on the override column) we check if ($b->overrideAreaPermissions()) { $this->permissionObjectToCheck = $b; } else { $a = $b->getBlockAreaObject(); if ($a instanceof SubArea && !$a->overrideCollectionPermissions()) { $a = $a->getSubAreaParentPermissionsObject(); } if (is_object($a)) { if ($a->overrideCollectionPermissions()) { $this->permissionObjectToCheck = $a; } elseif ($a->getAreaCollectionInheritID()) { $mcID = $a->getAreaCollectionInheritID(); $mc = Page::getByID($mcID, 'RECENT'); $ma = Area::get($mc, $a->getAreaHandle()); if ($ma->overrideCollectionPermissions()) { $this->permissionObjectToCheck = $ma; } else { $this->permissionObjectToCheck = $ma->getAreaCollectionObject(); } } else { $this->permissionObjectToCheck = $a->getAreaCollectionObject(); } } else { $this->permissionObjectToCheck = Page::getCurrentPage(); } } }
public function __construct(StyleSet $set = null, Block $b, $theme = null) { $this->arHandle = $b->getAreaHandle(); $this->bID = $b->getBlockID(); $this->set = $set; $this->theme = $theme; $this->bFilename = $b->getBlockFilename(); }
public function __construct(Block $block) { $c = $block->getBlockCollectionObject(); $type = $c->getPageTypeObject(); $template = $c->getPageTemplateObject(); $control = $block->getController()->getComposerOutputControlObject(); if (is_object($control)) { $control = FormLayoutSetControl::getByID($control->getPageTypeComposerFormLayoutSetControlID()); $label = $control->getPageTypeComposerFormLayoutSetControlCustomLabel(); if (!$label) { $cc = $control->getPageTypeComposerControlObject(); $label = $cc->getPageTypeComposerControlDisplayName(); } $components = array($type->getPageTypeDisplayName(), $template->getPageTemplateDisplayName(), $block->getAreaHandle(), $label); $this->block = $block; $this->setIdentifier($block->getBlockID()); $this->setDisplayName(implode(' > ', $components)); } }
public function view() { $c = Page::getCurrentPage(); $blogify = Loader::helper('blogify'); $this->set('blogify', $blogify); $this->set('html', Loader::helper('html')); $this->set('th', Loader::helper("text")); $this->set('blogBockID', $this->bID); $this->set('uh', Loader::helper('concrete/urls')); $this->set('link', Loader::helper('navigation')->getLinkToCollection($c)); $this->set('rss_img_url', $this->getRssImgUrl()); $blog_settings = $blogify->getBlogSettings(); //$searchn= Page::getByID($blog_settings['search_path']); $this->set('blog_settings', $blog_settings); $searchn = Page::getByPath('/blogsearch'); $this->set('search', Loader::helper('navigation')->getLinkToCollection($searchn) . '/'); $this->set('bt', Blocktype::getByHandle('problog_list')); $this->set('subscribe_link', URL::to('/problog/tools/subscribe')); $u = new User(); $user = UserInfo::getByID($u->uID); if ($user) { $this->set('manager', $user->getUserBlogEditor()); } if (intval($this->cParentID) > 0) { $this->set('pp', Page::getByID($this->cParentID)); } $cArray = array(); $b = Block::getByID($this->bID); $template = strtolower($b->getBlockFilename()); if (substr_count($template, 'categories') == 0 && substr_count($template, 'tag') == 0 && substr_count($template, 'archive') == 0) { $cArray = $this->getPages(); } $nh = Loader::helper('navigation'); $this->set('nh', $nh); $this->set('cArray', $cArray); $embedlykey = $blog_settings['embedly']; if ($embedlykey) { $this->addFooterItem(Loader::helper('html')->javascript('jquery.embedly.js', 'problog')); $this->addFooterItem("\n<script type=\"text/javascript\">\n\$(document).ready(function () {\n \$('.embedly').each(function () {\n var w = \$(this).parent().width();\n \t\$(this).embedly({\n \t\tkey: '{$embedlykey}',\n \t\tquery: {\n \t\t\tmaxwidth: w,\n \t\t},\n \t});\n });\n});\n</script>\n"); } }
public function recordPageTypeComposerOutputBlock(\Concrete\Core\Block\Block $block) { $db = Loader::db(); $setControl = $this->getPageTypeComposerFormLayoutSetControlObject(); $db->Execute('insert into PageTypeComposerOutputBlocks (cID, arHandle, ptComposerFormLayoutSetControlID, cbDisplayOrder, bID) values (?, ?, ?, ?, ?)', array($block->getBlockCollectionID(), $block->getAreaHandle(), $setControl->getPageTypeComposerFormLayoutSetControlID(), $block->getBlockDisplayOrder(), $block->getBlockID())); }
public function getPassThruBlockController(Block $b) { $bID = $b->getBlockID(); return isset($this->passThruBlocks[$bID]) ? $this->passThruBlocks[$bID] : null; }
public function moveBlockToDisplayOrderPosition($afterBlock) { // first, we increase the display order of all blocks found after this one. $db = Loader::db(); $c = $this->getBlockCollectionObject(); if ($afterBlock instanceof Block) { $block = Block::getByID($afterBlock->getBlockID(), $this->getBlockCollectionObject(), $this->getBlockAreaObject()); $q = "update CollectionVersionBlocks set cbDisplayOrder = cbDisplayOrder + 1 where cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ? and cbDisplayOrder > ?"; $v = array($c->getCollectionID(), $c->getVersionID(), $this->arHandle, $block->getBlockDisplayOrder()); $db->Execute($q, $v); // now we set this block's display order to 1 + the current block $q = "update CollectionVersionBlocks set cbDisplayOrder = ? where bID = ? and cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ?"; $v = array($block->getBlockDisplayOrder() + 1, $this->getBlockID(), $c->getCollectionID(), $c->getVersionID(), $this->arHandle); $db->Execute($q, $v); } else { $q = "update CollectionVersionBlocks set cbDisplayOrder = cbDisplayOrder + 1 where cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ?"; $v = array($c->getCollectionID(), $c->getVersionID(), $this->arHandle); $db->Execute($q, $v); $q = "update CollectionVersionBlocks set cbDisplayOrder = ? where bID = ? and cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ?"; $v = array(0, $this->getBlockID(), $c->getCollectionID(), $c->getVersionID(), $this->arHandle); $db->Execute($q, $v); } }
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 static function get(Block $b) { $o = null; if ($b->overrideBlockTypeCacheSettings()) { $c = $b->getBlockCollectionObject(); $cID = $c->getCollectionID(); $cvID = $c->getVersionID(); $a = $b->getBlockAreaObject(); $arHandle = $a->getAreaHandle(); if ($a->isGlobalArea()) { // then we need to check against the global area name. We currently have the wrong area handle passed in $arHandle = STACKS_AREA_NAME; } $bID = $b->getBlockID(); $db = Database::get(); $r = $db->GetRow('select * from CollectionVersionBlocksCacheSettings where cID = ? and cvID = ? and arHandle = ? and bID = ?', array($cID, $cvID, $arHandle, $bID)); if ($r['bID']) { $o = new static(); $o->btCacheBlockOutput = (bool) $r['btCacheBlockOutput']; $o->btCacheBlockOutputOnPost = (bool) $r['btCacheBlockOutputOnPost']; $o->btCacheBlockOutputForRegisteredUsers = (bool) $r['btCacheBlockOutputForRegisteredUsers']; $o->btCacheBlockOutputLifetime = $r['btCacheBlockOutputLifetime']; } } if (!isset($o)) { if ($controller = $b->getController()) { $o = new static(); $o->btCacheBlockOutput = $controller->cacheBlockOutput(); $o->btCacheBlockOutputOnPost = $controller->cacheBlockOutputOnPost(); $o->btCacheBlockOutputForRegisteredUsers = $controller->cacheBlockOutputForRegisteredUsers(); $o->btCacheBlockOutputLifetime = $controller->getBlockTypeCacheOutputLifetime(); } else { $o = new static(); $o->btCacheBlockOutput = false; $o->btCacheBlockOutputOnPost = false; $o->btCacheBlockOutputForRegisteredUsers = false; $o->btCacheBlockOutputLifetime = false; } } return $o; }