public function __construct() { parent::__construct(); $request = $this->request; $arHandle = $request->query->get('arHandle'); $bID = $request->query->get('bID'); $a = \Area::get($this->page, $arHandle); if (!is_object($a)) { throw new \Exception('Invalid Area'); } $this->area = $a; if (!$a->isGlobalArea()) { $b = \Block::getByID($bID, $this->page, $a); $this->set('isGlobalArea', false); } else { $stack = \Stack::getByName($arHandle); $sc = ConcretePage::getByID($stack->getCollectionID(), 'RECENT'); $b = \Block::getByID($bID, $sc, STACKS_AREA_NAME); $b->setBlockAreaObject($a); // set the original area object $this->set('isGlobalArea', true); } $this->block = $b; $this->permissions = new \Permissions($b); $this->set('bp', $this->permissions); $this->set('b', $b); }
public function getImportData($blockNode) { $args = array(); $content = (string) $blockNode->stack; $stack = Stack::getByName($content); $args['stID'] = $stack->getCollectionID(); return $args; }
public function setPermissionObject(Area $a) { $ax = $a; if ($a->isGlobalArea()) { $cx = Stack::getByName($a->getAreaHandle()); $a = Area::get($cx, STACKS_AREA_NAME); } $this->permissionObject = $a; // if the area overrides the collection permissions explicitly (with a one on the override column) we check if ($a->overrideCollectionPermissions()) { $this->permissionObjectToCheck = $a; } else { if ($a->getAreaCollectionInheritID() > 0) { // in theory we're supposed to be inheriting some permissions from an area with the same handle, // set on the collection id specified above (inheritid). however, if someone's come along and // reverted that area to the page's permissions, there won't be any permissions, and we // won't see anything. so we have to check $areac = Page::getByID($a->getAreaCollectionInheritID()); $inheritArea = Area::get($areac, $a->getAreaHandlE()); if (is_object($inheritArea) && $inheritArea->overrideCollectionPermissions()) { // okay, so that area is still around, still has set permissions on it. So we // pass our current area to our grouplist, userinfolist objects, knowing that they will // smartly inherit the correct items. $this->permissionObjectToCheck = $inheritArea; } } if (!$this->permissionObjectToCheck) { $this->permissionObjectToCheck = $a->getAreaCollectionObject(); } } }
protected function importStacksContent(SimpleXMLElement $sx) { if (isset($sx->stacks)) { foreach($sx->stacks->stack as $p) { $stack = Stack::getByName($p['name']); if (isset($p->area)) { $this->importPageAreas($stack, $p); } } } }
public static function export(SimpleXMLElement $x) { $db = Loader::db(); $r = $db->Execute('select stName, cID, stType from Stacks order by stName asc'); if ($r->NumRows()) { $gas = $x->addChild('stacks'); while ($row = $r->FetchRow()) { $stack = Stack::getByName($row['stName']); $stack->export($gas); } } }
protected function getBlockToEdit() { $ax = $this->area; $cx = $this->page; if ($this->area->isGlobalArea()) { $ax = STACKS_AREA_NAME; $cx = \Stack::getByName($_REQUEST['arHandle']); } $b = \Block::getByID($_REQUEST['bID'], $cx, $ax); $nvc = $cx->getVersionToModify(); if ($this->area->isGlobalArea()) { $xvc = $this->page->getVersionToModify(); // we need to create a new version of THIS page as well. $xvc->relateVersionEdits($nvc); } $b->loadNewCollection($nvc); if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { // if we're editing a scrapbook display block, we add a new block in this position for the real block type // set the block to the display order // delete the scrapbook display block, and save the data /* $originalDisplayOrder = $b->getBlockDisplayOrder(); $btx = BlockType::getByHandle($_b->getBlockTypeHandle()); $nb = $nvc->addBlock($btx, $ax, array()); $nb->setAbsoluteBlockDisplayOrder($originalDisplayOrder); $b->deleteBlock(); $b = &$nb; */ $originalDisplayOrder = $b->getBlockDisplayOrder(); $cnt = $b->getController(); $ob = \Block::getByID($cnt->getOriginalBlockID()); $ob->loadNewCollection($nvc); if (!is_object($ax)) { $ax = Area::getOrCreate($cx, $ax); } $ob->setBlockAreaObject($ax); $nb = $ob->duplicate($nvc); $nb->setAbsoluteBlockDisplayOrder($originalDisplayOrder); $b->deleteBlock(); $b =& $nb; } else { if ($b->isAlias()) { // then this means that the block we're updating is an alias. If you update an alias, you're actually going // to duplicate the original block, and update the newly created block. If you update an original, your changes // propagate to the aliases $nb = $b->duplicate($nvc); $b->deleteBlock(); $b = $nb; } } return $b; }
protected function getBlockToEdit() { $ax = $this->area; $cx = $this->page; if ($this->area->isGlobalArea()) { $ax = STACKS_AREA_NAME; $cx = \Stack::getByName($_REQUEST['arHandle']); } $b = \Block::getByID($_REQUEST['bID'], $cx, $ax); $nvc = $cx->getVersionToModify(); if ($this->area->isGlobalArea()) { $xvc = $this->page->getVersionToModify(); // we need to create a new version of THIS page as well. $xvc->relateVersionEdits($nvc); } $b->loadNewCollection($nvc); //if this block is being changed, make sure it's a new version of the block. if ($b->isAlias()) { $nb = $b->duplicate($nvc); $b->deleteBlock(); $b = $nb; } return $b; }
if (!$ap->canAddBlock($bt)) { $badPermissions = true; } } else { //edit survey mode // this really ought to be refactored if (!$a->isGlobalArea()) { $b = Block::getByID($_REQUEST['bID'], $c, $a); if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { $b = Block::getByID($b->getController()->getOriginalBlockID()); $b->setBlockAreaObject($a); $b->loadNewCollection($c); $bID = $b->getBlockID(); } } else { $b = Block::getByID($_REQUEST['bID'], Stack::getByName($a->getAreaHandle()), STACKS_AREA_NAME); $b->setBlockAreaObject($a); // set the original area object } $bp = new Permissions($b); if (!$bp->canWrite()) { $badPermissions = true; } } } else { $badPermissions = true; } if ($badPermissions) { echo t('Invalid Permissions'); die; }
<? defined('C5_EXECUTE') or die("Access Denied."); $c = Page::getByID($_REQUEST['cID']); $a = Area::get($c, $_REQUEST['arHandle']); if (!$a->isGlobalArea()) { $b = Block::getByID($_REQUEST['bID'], $c, $a); } else { $b = Block::getByID($_REQUEST['bID'], Stack::getByName($_REQUEST['arHandle']), STACKS_AREA_NAME); $b->setBlockAreaObject($a); // set the original area object $isGlobalArea = true; } $bp = new Permissions($b); if (!$bp->canWrite()) { die(t("Access Denied.")); } if ($_REQUEST['btask'] != 'view' && $_REQUEST['btask'] != 'view_edit_mode') { include(DIR_FILES_ELEMENTS_CORE . '/dialog_header.php'); } $bv = new BlockView(); if ($isGlobalArea && $_REQUEST['btask'] != 'view_edit_mode') { echo '<div class="ccm-ui"><div class="alert-message block-message warning">'; echo t('This block is contained within a global area. Changing its content will change it everywhere that global area is referenced.'); echo('</div></div>'); } if(($c->isMasterCollection()) && (!in_array($_REQUEST['btask'], array('child_pages','composer','view_edit_mode')))) {
$scrapbookName = $_REQUEST['scrapbookName']; if ($scrapbookName) { $scrapbookHelper->setDefault($scrapbookName); } $c = Page::getByID($_REQUEST['cID']); // add a block to a pile $cp = new Permissions($c); if (!$cp->canViewPage()) { exit; } if (($_REQUEST['btask'] == 'add' || $_REQUEST['ctask'] == 'add') && $scrapbookName) { if ($_REQUEST['btask'] == 'add') { $a = Area::get($c, $_REQUEST['arHandle']); if ($a->isGlobalArea()) { $ax = STACKS_AREA_NAME; $cx = Stack::getByName($_REQUEST['arHandle']); } $b = Block::getByID($_REQUEST['bID'], $cx, $ax); if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { $bi = $b->getInstance(); $b = Block::getByID($bi->getOriginalBlockID()); } $ap = new Permissions($a); if (!$ap->canViewArea()) { exit; } $obj =& $b; } else { $obj =& $c; } if ($_REQUEST['pID']) {
if ($abltb > 0 || $abrtb > 0 || $abctb > 0 || $c->isEditMode()) { ?> </div> <?php } ?> </div> <?php } ?> <?php $a = new GlobalArea('Header Nav'); $blocks = $a->getTotalBlocksInArea($c); if ($blocks > 0 || $c->isEditMode()) { $stack = Stack::getByName('Header Nav'); if ($stack) { $getStacks = $stack->getBlocks(); foreach ($getStacks as $getStack) { if ($getStack->getBlockFilename() !== 'off_canvas') { echo '<div class="c5h-navigation-wrap clearfix">'; } else { echo ''; } } } $a->setCustomTemplate('autonav', 'top_bar'); $a->display(); if ($stack) { $getStacks = $stack->getBlocks(); foreach ($getStacks as $getStack) {
<?php /* Home for all modals which are hidden on page load */ // Error modal if (isset($error) && $error !== '') { if ($error instanceof Exception) { $_error[] = $error->getMessage(); } elseif ($error instanceof ValidationErrorHelper) { $_error = $error->getList(); } elseif (is_array($error)) { $_error = $error; } elseif (is_string($error)) { $_error[] = $error; } } $sl = Stack::getByName('Social Logins'); if ($sl) { ob_start(); $sl->display(); // Set the social logins stack as accessible to client-side apps $this->addFooterItem('<script type="text/javascript">window.JanesWalk = Object.assign({}, window.JanesWalk, {stacks: {"Social Logins": ' . json_encode(ob_get_contents()) . '}});</script>'); ob_end_clean(); } ?> <div id="modals"></div>
*/ /* //unique class for every single menu item $classes[] = 'nav-item-' . $ni->cID; */ //Put all classes together into one space-separated string $ni->classes = implode(" ", $classes); } /****************************************************************************** * DESIGNERS: CUSTOMIZE THE HTML STARTING HERE... */ $site = Config::get('concrete.site'); $logoStack = Stack::getByName('topbar_logo'); $iconStack = Stack::getByName('topbar_icon'); $searchStack = Stack::getByName('topbar_search'); $buttonStack = Stack::getByName('topbar_button'); $siteBranding = Config::get('c5hub.fundamental.navigation.branding'); $containToGridConfig = Config::get('c5hub.fundamental.navigation.contain_to_grid'); $stickyConfig = Config::get('c5hub.fundamental.navigation.sticky'); $divider = Config::get('c5hub.fundamental.navigation.divider'); $position = Config::get('c5hub.fundamental.navigation.position'); $brandingPosition = Config::get('c5hub.fundamental.navigation.branding_position'); $topBarWrapper = 'top-bar-wrapper'; if ($containToGridConfig == true) { $containToGrid = 'contain-to-grid'; } if ($stickyConfig == true) { $sticky = 'sticky'; } $topBarOptions = implode(' ', array($topBarWrapper, $containToGrid, $sticky)); if ($containToGridConfig == true || $stickyConfig == true) {
} */ /* //unique class for every single menu item $classes[] = 'nav-item-' . $ni->cID; */ //Put all classes together into one space-separated string $ni->classes = implode(" ", $classes); } /****************************************************************************** * DESIGNERS: CUSTOMIZE THE HTML STARTING HERE... */ $site = Config::get('concrete.site'); $logoStack = Stack::getByName('topbar_logo'); $iconStack = Stack::getByName('topbar_icon'); $searchStack = Stack::getByName('topbar_search'); echo '<div class="contain-to-grid sticky">'; echo ' <nav class="top-bar" data-topbar>'; echo ' <ul class="title-area">'; if (is_object($logoStack) && !is_object($iconStack)) { echo ' <li class="logo">'; $logoStack->display(); echo ' </li>'; } elseif (is_object($iconStack) && !is_object($logoStack)) { echo ' <li class="name">'; echo ' <a href="/">'; $iconStack->display(); echo ' <h1>' . $site . '</h1>'; echo ' </a>'; echo ' </li>'; } else {
> <div class="c5h-section-<?php echo $alignment; ?> -wrap" <?php echo $wrapperStyles; ?> > <?php echo $containToGridTop; ?> <div class="c5h-section-stack"> <?php if ($controller->sectionStackName) { $stack = Stack::getByName($controller->sectionStackName); if (is_object($stack)) { $stack = $stack->display(); } } ?> </div> <div class="c5h-section-icon"> <?php echo $icon; ?> </div><!-- END .c5h-section-icon --> <div class="c5h-section-content clearfix"> <div class="c5h-section-title"> <?php
data-reveal-id="c5h-modal-<?php echo $bID; ?> "><?php echo $modalLinkText; ?> </a> <div id="c5h-modal-<?php echo $bID; ?> " class="reveal-modal<?php echo $modalSize; ?> " data-reveal> <div class="c5h-modal-stack ccm-page"> <?php if ($controller->modalStackName) { $stack = Stack::getByName($controller->modalStackName); if (is_object($stack)) { $stack = $stack->display(); } } ?> </div> <?php echo $modalContent; ?> <a class="close-reveal-modal">×</a> </div>
public function getGlobalBlocks() { $db = Loader::db(); $v = array( Stack::ST_TYPE_GLOBAL_AREA ); $rs = $db->GetCol('select stName from Stacks where Stacks.stType = ?', $v ); $blocks = array(); if (count($rs) > 0) { $pcp = new Permissions($this); foreach($rs as $garHandle) { if ($pcp->canViewPageVersions()) { $s = Stack::getByName($garHandle, 'RECENT'); } else { $s = Stack::getByName($garHandle, 'ACTIVE'); } if (is_object($s)) { $blocksTmp = $s->getBlocks(STACKS_AREA_NAME); $blocks = array_merge($blocks, $blocksTmp); } } } return $blocks; }
<? defined('C5_EXECUTE') or die("Access Denied."); ?> <br/> <? if ($cp->canAdminPage() && is_object($a)) { $ax = $a; if ($a->isGlobalArea()) { $cx = Stack::getByName($a->getAreaHandle()); $a = Area::get($cx, STACKS_AREA_NAME); } $btArray = BlockTypeList::getAreaBlockTypes($a, $cp); // if the area overrides the collection permissions explicitly (with a one on the override column) we check if ($a->overrideCollectionPermissions()) { $gl = new GroupList($a); $ul = new UserInfoList($a); } else { // now it gets more complicated. $permsSet = false; if ($a->getAreaCollectionInheritID() > 0) { // in theory we're supposed to be inheriting some permissions from an area with the same handle, // set on the collection id specified above (inheritid). however, if someone's come along and // reverted that area to the page's permissions, there won't be any permissions, and we // won't see anything. so we have to check $areac = Page::getByID($a->getAreaCollectionInheritID()); $inheritArea = Area::get($areac, $_GET['arHandle']);
public function submit() { if ($this->validateAction() && $this->canAccess()) { $c = $this->page; $a = \Area::get($this->page, $_REQUEST['arHandle']); $ax = $a; $cx = $c; if ($a->isGlobalArea()) { $ax = STACKS_AREA_NAME; $cx = \Stack::getByName($_REQUEST['arHandle']); } $b = \Block::getByID($_REQUEST['bID'], $cx, $ax); $pr = new \Concrete\Core\Page\EditResponse(); $pr->setPage($this->page); $bi = $b->getInstance(); if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { $_b = \Block::getByID($bi->getOriginalBlockID()); $bi = $_b->getInstance(); // for validation } $e = $bi->validate($_POST); $pr->setAdditionalDataAttribute('aID', $a->getAreaID()); $pr->setAdditionalDataAttribute('arHandle', $a->getAreaHandle()); $pr->setError($e); if (!is_object($e) || $e instanceof \Concrete\Core\Error\Error && !$e->has()) { $bt = BlockType::getByHandle($b->getBlockTypeHandle()); if (!$bt->includeAll()) { // we make sure to create a new version, if necessary $nvc = $cx->getVersionToModify(); } else { $nvc = $cx; // keep the same one } if ($a->isGlobalArea()) { $xvc = $c->getVersionToModify(); // we need to create a new version of THIS page as well. $xvc->relateVersionEdits($nvc); } $ob = $b; // replace the block with the version of the block in the later version (if applicable) $b = \Block::getByID($_REQUEST['bID'], $nvc, $ax); if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { // if we're editing a scrapbook display block, we add a new block in this position for the real block type // set the block to the display order // delete the scrapbook display block, and save the data /* $originalDisplayOrder = $b->getBlockDisplayOrder(); $btx = BlockType::getByHandle($_b->getBlockTypeHandle()); $nb = $nvc->addBlock($btx, $ax, array()); $nb->setAbsoluteBlockDisplayOrder($originalDisplayOrder); $b->deleteBlock(); $b = &$nb; */ $originalDisplayOrder = $b->getBlockDisplayOrder(); $cnt = $b->getController(); $ob = \Block::getByID($cnt->getOriginalBlockID()); $ob->loadNewCollection($nvc); if (!is_object($ax)) { $ax = Area::getOrCreate($cx, $ax); } $ob->setBlockAreaObject($ax); $nb = $ob->duplicate($nvc); $nb->setAbsoluteBlockDisplayOrder($originalDisplayOrder); $b->deleteBlock(); $b =& $nb; } else { if ($b->isAlias()) { // then this means that the block we're updating is an alias. If you update an alias, you're actually going // to duplicate the original block, and update the newly created block. If you update an original, your changes // propagate to the aliases $nb = $ob->duplicate($nvc); $b->deleteBlock(); $b =& $nb; } } $pr->setAdditionalDataAttribute('bID', $b->getBlockID()); // we can update the block that we're submitting $b->update($_POST); } $pr->outputJSON(); } }
/** * displays the Area in the page * ex: $a = new Area('Main'); $a->display($c); * @param Page|Collection $c * @param Block[] $alternateBlockArray optional array of blocks to render instead of default behavior * @return void */ function display(&$c, $alternateBlockArray = null) { if (!intval($c->cID)) { //Invalid Collection return false; } if ($this->arIsGlobal) { $stack = Stack::getByName($this->arHandle); } $currentPage = Page::getCurrentPage(); $ourArea = self::getOrCreate($c, $this->arHandle, $this->arIsGlobal); if (count($this->customTemplateArray) > 0) { $ourArea->customTemplateArray = $this->customTemplateArray; } if (count($this->attributes) > 0) { $ourArea->attributes = $this->attributes; } if ($this->maximumBlocks > -1) { $ourArea->maximumBlocks = $this->maximumBlocks; } $ap = new Permissions($ourArea); if (!$ap->canViewArea()) { return false; } $blocksToDisplay = $alternateBlockArray ? $alternateBlockArray : $ourArea->getAreaBlocksArray($c, $ap); $this->totalBlocks = $ourArea->getTotalBlocksInArea(); $u = new User(); $bv = new BlockView(); // now, we iterate through these block groups (which are actually arrays of block objects), and display them on the page if ($this->showControls && $c->isEditMode() && $ap->canViewAreaControls()) { $bv->renderElement('block_area_header', array('a' => $ourArea)); } $bv->renderElement('block_area_header_view', array('a' => $ourArea)); //display layouts tied to this area //Might need to move this to a better position $areaLayouts = $this->getAreaLayouts($c); if (is_array($areaLayouts) && count($areaLayouts)) { foreach ($areaLayouts as $layout) { $layout->display($c, $this); } if ($this->showControls && ($c->isArrangeMode() || $c->isEditMode())) { echo '<div class="ccm-layouts-block-arrange-placeholder ccm-block-arrange"></div>'; } } $blockPositionInArea = 1; //for blockWrapper output foreach ($blocksToDisplay as $b) { $includeEditStrip = false; $bv = new BlockView(); $bv->setAreaObject($ourArea); // this is useful for rendering areas from one page // onto the next and including interactive elements if ($currentPage->getCollectionID() != $c->getCollectionID()) { $b->setBlockActionCollectionID($c->getCollectionID()); } if ($this->arIsGlobal && is_object($stack)) { $b->setBlockActionCollectionID($stack->getCollectionID()); } $p = new Permissions($b); if ($c->isEditMode() && $this->showControls && $p->canViewEditInterface()) { $includeEditStrip = true; } if ($p->canViewBlock()) { if (!$c->isEditMode()) { $this->outputBlockWrapper(true, $b, $blockPositionInArea); } if ($includeEditStrip) { $bv->renderElement('block_controls', array('a' => $ourArea, 'b' => $b, 'p' => $p)); $bv->renderElement('block_header', array('a' => $ourArea, 'b' => $b, 'p' => $p)); } $bv->render($b); if ($includeEditStrip) { $bv->renderElement('block_footer'); } if (!$c->isEditMode()) { $this->outputBlockWrapper(false, $b, $blockPositionInArea); } } $blockPositionInArea++; } $bv->renderElement('block_area_footer_view', array('a' => $ourArea)); if ($this->showControls && $c->isEditMode() && $ap->canViewAreaControls()) { $bv->renderElement('block_area_footer', array('a' => $ourArea)); } }
*/ /* //unique class for every single menu item $classes[] = 'nav-item-' . $ni->cID; */ //Put all classes together into one space-separated string $ni->classes = implode(" ", $classes); } /****************************************************************************** * DESIGNERS: CUSTOMIZE THE HTML STARTING HERE... */ $site = Config::get('concrete.site'); $logoStack = Stack::getByName('offcanvas_logo'); //$iconStack = Stack::getByName('topbar_icon'); $topStack = Stack::getByName('offcanvas_top'); $bottomStack = Stack::getByName('offcanvas_bottom'); $siteBranding = Config::get('c5hub.fundamental.navigation.branding'); $position = Config::get('c5hub.fundamental.off_canvas.position'); //$brandingPosition = Config::get('c5hub.fundamental.navigation.branding_position'); echo '<div class="off-canvas-wrap " data-offcanvas>'; echo ' <div class="inner-wrap">'; echo ' <nav class="tab-bar">'; echo ' <div class="' . $position . '-small">'; echo ' <a role="button" aria-expanded="false" aria-controls="" class="' . $position . '-off-canvas-toggle menu-icon" >'; echo ' <span></span>'; echo ' </a>'; echo ' </div>'; if ($siteBranding == true) { if (is_object($logoStack) && !is_object($iconStack)) { echo ' <section class="middle tab-bar-section">'; $logoStack->display();