public function testSave() { $bt = BlockType::installBlockType($this->btHandle); $btx = BlockType::getByID(1); $class = $btx->getBlockTypeClass(); $btc = new $class(); $bID = 1; foreach ($this->requestData as $type => $requestData) { $nb = $bt->add($requestData); $data = $this->expectedRecordData[$type]; $db = Loader::db(); $r = $db->GetRow('select * from `' . $btc->getBlockTypeDatabaseTable() . '` where bID = ?', array($bID)); foreach ($data as $key => $value) { $this->assertTrue($r[$key] == $value, 'Key `' . $key . '` did not equal expected value `' . $value . '` instead equalled `' . $r[$key] . '` (type `' . $type . '`)'); } $bID++; ob_start(); $bv = new BlockView($nb); $bv->render('view'); $contents = ob_get_contents(); ob_end_clean(); $contents = trim($contents); if (isset($this->expectedOutput[$type])) { $this->assertTrue($this->expectedOutput[$type] == $contents, 'Output `' . $contents . '` did not equal expected output `' . $this->expectedOutput[$type] . '` (type `' . $type . '`)'); } } }
public function view() { $bv = new BlockView($this->block); if (isset($_REQUEST['arGridMaximumColumns'])) { $this->area->setAreaGridMaximumColumns(intval($_REQUEST['arGridMaximumColumns'])); } if (isset($_REQUEST['arEnableGridContainer']) && $_REQUEST['arEnableGridContainer'] == 1) { $this->area->enableGridContainer(); } $bv->addScopeItems(array('c' => $this->page, 'a' => $this->area, 'dialogController' => $this)); $this->set('bv', $bv); }
public function render() { $btc = $this->block->getInstance(); $bv = new BlockView($this->block); if (isset($_REQUEST['arEnableGridContainer']) && $_REQUEST['arEnableGridContainer'] == 1) { $this->area->enableGridContainer(); } $this->area->forceControlsToDisplay(); // we always want to show them controls. $bv->addScopeItems(array('c' => $this->page, 'a' => $this->area, 'dialogController' => $this)); $this->set('bv', $bv); $this->view = new DialogView('/backend/block'); }
public function render() { $loc = Localization::getInstance(); $loc->setActiveContext('site'); $c = $this->block->getBlockCollectionObject(); $dl = Core::make('multilingual/detector'); $dl->setupSiteInterfaceLocalization($this->page); $btc = $this->block->getInstance(); $bv = new BlockView($this->block); if (isset($_REQUEST['arEnableGridContainer']) && $_REQUEST['arEnableGridContainer'] == 1) { $this->area->enableGridContainer(); } $this->area->forceControlsToDisplay(); // we always want to show them controls. $bv->addScopeItems(array('c' => $this->page, 'a' => $this->area, 'dialogController' => $this)); $this->set('bv', $bv); $this->view = new DialogView('/backend/block'); }
public function view() { $bv = new BlockView($this->blockType); $bv->setAreaObject($this->area); // Handle special posted area parameters here if (isset($_REQUEST['arGridMaximumColumns'])) { $this->area->setAreaGridMaximumColumns(intval($_REQUEST['arGridMaximumColumns'])); } if (isset($_REQUEST['arEnableGridContainer']) && $_REQUEST['arEnableGridContainer'] == 1) { $this->area->enableGridContainer(); } $bv->addScopeItems(array('a' => $this->a, 'cp' => $this->permissions, 'ap' => $this->areaPermissions)); $this->set('blockView', $bv); $this->set('blockType', $this->blockType); $this->set('btHandle', $this->blockType->getBlockTypeHandle()); $this->set("blockTypeController", $this->blockTypeController); $this->set('area', $this->area); }
public function view() { $btc = $this->block->getInstance(); $btc->outputAutoHeaderItems(); $bv = new BlockView($this->block); $bv->addScopeItems(array('c' => $this->page, 'a' => $this->area, 'dialogController' => $this)); $this->set('bv', $bv); $canEditCustomTemplate = false; if ($this->permissions->canEditBlockCustomTemplate()) { $canEditCustomTemplate = true; switch ($this->block->getBlockTypeHandle()) { case BLOCK_HANDLE_SCRAPBOOK_PROXY: $bi = $this->block->getInstance(); $bx = \Block::getByID($bi->getOriginalBlockID()); $bt = \BlockType::getByID($bx->getBlockTypeID()); $bFilename = $bx->getBlockFilename(); break; case BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY: $bi = $this->block->getInstance(); $output = $bi->getComposerOutputControlObject(); $control = FormLayoutSetControl::getByID($output->getPageTypeComposerFormLayoutSetControlID()); $object = $control->getPageTypeComposerControlObject(); if ($object instanceof BlockControl) { $bt = $object->getBlockTypeObject(); } $bFilename = $this->block->getBlockFilename(); break; default: $bt = \BlockType::getByID($this->block->getBlockTypeID()); $bFilename = $this->block->getBlockFilename(); break; } $templates = array(); if (is_object($bt)) { $templates = $bt->getBlockTypeCustomTemplates(); } $this->set('bFilename', $bFilename); $this->set('templates', $templates); } $this->set('canEditCustomTemplate', $canEditCustomTemplate); }
public function setupRender() { parent::setupRender(); if ($this->block) { $obj = $this->block; } else { $obj = $this->blocktype; } $bvt = new BlockViewTemplate($obj); $bvt->setBlockCustomTemplate('amp.php'); $this->setViewTemplate($bvt->getTemplate()); if ($obj->getBlockTypeHandle() == 'youtube') { $this->addHeaderAsset('<script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script>'); } }
protected function getPageFeedContent(Page $p) { switch ($this->pfContentToDisplay) { case 'S': return $p->getCollectionDescription(); case 'A': $a = new \Area($this->getAreaHandleToDisplay()); $blocks = $a->getAreaBlocksArray($p); $r = Request::getInstance(); $r->setCurrentPage($p); ob_start(); foreach ($blocks as $b) { $bv = new BlockView($b); $bv->render('view'); } $content = ob_get_contents(); ob_end_clean(); return $content; } }
/** * Renders a particular view of a block type, using the public $controller variable as the block type's controller * * @param string template 'view' for the default * @return void */ public function render($view = 'view') { $bv = new BlockView($this); $bv->render($view); }
<?php use Concrete\Core\Block\View\BlockView; defined('C5_EXECUTE') or die("Access Denied."); $bo = Block::getByID($bOriginalID); $bp = new Permissions($bo); $bo->setProxyBlock($b); if ($bp->canWrite()) { $bv = new BlockView($bo); ?> <div class="ccm-ui"> <div class="alert alert-info"> <?php echo t("This block was copied from another location. Editing it will create a new instance of it."); ?> </div> </div> <?php $bv->addScopeItems($view->getScopeItems()); $bv->render('edit'); }
public function isEditable() { $bv = new BlockView($this); $path = $bv->getBlockPath(FILENAME_BLOCK_EDIT); if (file_exists($path . '/' . FILENAME_BLOCK_EDIT)) { return true; } return false; }
<?php use Concrete\Core\Block\View\BlockView; defined('C5_EXECUTE') or die("Access Denied."); $c = Page::getByID($_REQUEST['cID'], "ACTIVE"); $bt = BlockType::getByHandle('autonav'); $bt->controller->collection = $c; $bt->controller->orderBy = $_REQUEST['orderBy']; $bt->controller->cID = $_REQUEST['cID']; $bt->controller->displayPages = $_REQUEST['displayPages']; $bt->controller->displaySubPages = $_REQUEST['displaySubPages']; $bt->controller->displaySubPageLevels = $_REQUEST['displaySubPageLevels']; $bt->controller->displaySubPageLevelsNum = $_REQUEST['displaySubPageLevelsNum']; $bt->controller->displayUnavailablePages = $_REQUEST['displayUnavailablePages']; $bt->controller->displaySystemPages = $_REQUEST['displaySystemPages']; if ($bt->controller->displayPages == "custom") { $bt->controller->displayPagesCID = $_REQUEST['displayPagesCID']; $bt->controller->displayPagesIncludeSelf = $_REQUEST['displayPagesIncludeSelf']; } $bv = new BlockView($bt); $bv->render('view'); exit;
protected function computeView() { $bFilename = $this->bFilename; $obj = $this->obj; // if we've passed in "templates/" as the first part, we strip that off. if (strpos($bFilename, 'templates/') === 0) { $bFilename = substr($bFilename, 10); } // The filename might be a directory name with .php-appended (BlockView does that), strip it. $bFilenameWithoutDotPhp = $bFilename; if (substr($bFilename, -4) === ".php") { $bFilenameWithoutDotPhp = substr($bFilename, 0, strlen($bFilename) - 4); } if ($bFilename) { if (is_file(DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) { $template = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename; $bv = new BlockView($obj); $this->baseURL = $bv->getBlockURL(); $this->basePath = $bv->getBlockPath($this->render); } else { if (is_file(DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) { $template = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename; $this->baseURL = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle(); $this->basePath = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle(); } else { if (is_dir(DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) { $template = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename . '/' . $this->render; $this->basePath = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename; $this->baseURL = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename; } else { if (is_dir(DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) { $template = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename . '/' . $this->render; $this->basePath = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename; $this->baseURL = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename; } else { if ($bFilename !== $bFilenameWithoutDotPhp) { if (is_dir(DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp)) { $template = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp . '/' . $this->render; $this->basePath = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp; $this->baseURL = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp; } else { if (is_dir(DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp)) { $template = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp . '/' . $this->render; $this->basePath = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp; $this->baseURL = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp; } } } } } } } // we check all installed packages if (!isset($template)) { $pl = PackageList::get(); $packages = $pl->getPackages(); foreach ($packages as $pkg) { $d = ''; if (is_dir(DIR_PACKAGES . '/' . $pkg->getPackageHandle())) { $d = DIR_PACKAGES . '/' . $pkg->getPackageHandle(); } else { if (is_dir(DIR_PACKAGES_CORE . '/' . $pkg->getPackageHandle())) { $d = DIR_PACKAGES_CORE . '/' . $pkg->getPackageHandle(); } } if ($d != '') { $baseStub = is_dir(DIR_PACKAGES . '/' . $pkg->getPackageHandle()) ? DIR_REL . '/' . DIRNAME_PACKAGES . '/' . $pkg->getPackageHandle() : ASSETS_URL . '/' . DIRNAME_PACKAGES . '/' . $pkg->getPackageHandle(); if (is_file($d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . $bFilename)) { $template = $d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . $bFilename; $this->baseURL = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle(); $this->basePath = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle(); } else { if (is_file($d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) { $template = $d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename; $this->baseURL = $baseStub . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle(); $this->basePath = $d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle(); } else { if (is_dir($d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) { $template = $d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename . '/' . $this->render; $this->baseURL = $baseStub . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename; } } } } if ($this->baseURL != '') { continue; } } } } else { if (file_exists(DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '.php')) { $template = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '.php'; $bv = new BlockView($obj); $this->baseURL = $bv->getBlockURL(); $this->basePath = $bv->getBlockPath($this->render); } else { if (file_exists(DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . $this->render)) { $template = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . $this->render; $this->baseURL = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle(); } } } if (!isset($template)) { $bv = new BlockView($obj); $template = $bv->getBlockPath($this->render) . '/' . $this->render; $this->baseURL = $bv->getBlockURL($this->render); } if ($this->basePath == '') { $this->basePath = dirname($template); } $this->template = $template; }
public function view() { $btc = $this->block->getInstance(); $btc->outputAutoHeaderItems(); $bv = new BlockView($this->block); $bv->addScopeItems(array('c' => $this->page, 'a' => $this->area, 'dialogController' => $this)); $this->set('bv', $bv); $canEditCustomTemplate = false; if ($this->permissions->canEditBlockCustomTemplate()) { $canEditCustomTemplate = true; if ($this->block->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { $bi = $this->block->getInstance(); $bx = \Block::getByID($bi->getOriginalBlockID()); $bt = \BlockType::getByID($bx->getBlockTypeID()); } else { $bt = \BlockType::getByID($this->block->getBlockTypeID()); } $templates = $bt->getBlockTypeCustomTemplates(); $this->set('templates', $templates); } $this->set('canEditCustomTemplate', $canEditCustomTemplate); }
</button> </li> </ul> <?php } ?> </div> </nav> <div id="ccm-stack-container"> <?php $a = Area::get($stackToEdit, STACKS_AREA_NAME); $a->forceControlsToDisplay(); View::element('block_area_header', array('a' => $a)); foreach ($blocks as $b) { $bv = new BlockView($b); $bv->setAreaObject($a); $p = new Permissions($b); if ($p->canViewBlock()) { $bv->render('view'); } } //View::element('block_area_footer', array('a' => $a)); print '</div>'; // No, we don't include the footer because we don't want all area controls available. // But the footer element has a closing DIV we need. ?> </div> <?php if ($deleteLabels !== null) {
/** * displays the Area in the page * ex: $a = new Area('Main'); $a->display($c);. * * @param Page $c * @param Block[] $alternateBlockArray optional array of blocks to render instead of default behavior * * @return bool */ public function display($c = false, $alternateBlockArray = null) { if (!$c) { $c = Page::getCurrentPage(); } $v = View::getRequestInstance(); if (!is_object($c) || $c->isError()) { return false; } $this->load($c); $ap = new Permissions($this); if (!$ap->canViewArea()) { return false; } $blocksToDisplay = $alternateBlockArray ? $alternateBlockArray : $this->getAreaBlocksArray(); $u = new User(); // 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()) { View::element('block_area_header', array('a' => $this)); } else { View::element('block_area_header_view', array('a' => $this)); } foreach ($blocksToDisplay as $b) { $bv = new BlockView($b); $bv->setAreaObject($this); $p = new Permissions($b); if ($p->canViewBlock()) { if (!$c->isEditMode()) { echo $this->enclosingStart; } $bv->render('view'); if (!$c->isEditMode()) { echo $this->enclosingEnd; } } } if ($this->showControls && $c->isEditMode() && $ap->canViewAreaControls()) { View::element('block_area_footer', array('a' => $this)); } else { View::element('block_area_footer_view', array('a' => $this)); } }
protected function getPageFeedContent(Page $p) { $content = false; switch ($this->pfContentToDisplay) { case 'S': $content = $p->getCollectionDescription(); break; case 'A': $a = new \Area($this->getAreaHandleToDisplay()); $blocks = $a->getAreaBlocksArray($p); $r = Request::getInstance(); $r->setCurrentPage($p); ob_start(); foreach ($blocks as $b) { $bv = new BlockView($b); $bv->render('view'); } $content = ob_get_contents(); ob_end_clean(); break; } $f = $p->getAttribute('thumbnail'); if (is_object($f)) { $content = '<p><img src="' . $f->getURL() . '" /></p>' . $content; } return $content; }