public function getScopeItems() { $items = parent::getScopeItems(); $items['innerContent'] = $this->error->content; $items['titleContent'] = $this->error->title; return $items; }
public function on_start() { Events::addListener('on_before_render', function () { $c = Page::getCurrentPage(); if (is_object($c) && $c->isEditMode()) { $view = View::getInstance(); $html = new Html(); $view->addHeaderItem($html->css('area_hints.css', 'area_hints')); } }); }
private function validateUser() { // check to see if this is a valid user account $user = new User(); if (!$user->checkLogin()) { $isActive = $user->isActive(); $user->logout(); if ($user->isError()) { switch ($user->getError()) { case USER_SESSION_EXPIRED: return Redirect::to('/login', 'session_invalidated')->send(); } } elseif (!$isActive) { return Redirect::to('/login', 'account_deactivated')->send(); } else { $v = new View('/frontend/user_error'); $v->setViewTheme('concrete'); $contents = $v->render(); return $this->app->make(ResponseFactoryInterface::class)->forbidden($contents); } } }
protected function getAssetsToOutput() { $ouput = parent::getAssetsToOutput(); $return = array(); foreach ($ouput as $position => $assets) { foreach ($assets as $asset) { $asset->setAssetPosition(Asset::ASSET_POSITION_HEADER); $asset->setAssetSupportsMinification(false); $asset->setAssetSupportsCombination(false); $return[$position][] = $asset; } } return $return; }
/** * @param Version $version * @return View */ public function getView(Version $version) { $view = new View('image-editor/editor'); $view->addScopeItems(array('editor' => $this, 'fv' => $version)); return $view; }
/** * @return View */ public static function getInstance() { return View::getRequestInstance(); }
/** * @inheritdoc */ public function collection(Collection $collection, $code = Response::HTTP_OK, $headers = array()) { if (!$this->app) { throw new \RuntimeException('Cannot resolve collections without a reference to the application'); } $request = $this->request; if ($collection->isError() && $collection->getError() == COLLECTION_NOT_FOUND) { if ($response = $this->collectionNotFound($collection, $request, $headers)) { return $response; } } if ($collection->getCollectionPath() != '/page_not_found') { if (!isset($collection->cPathFetchIsCanonical) || !$collection->cPathFetchIsCanonical) { // Handle redirect URL (additional page paths) /** @var Url $url */ $url = $this->app->make('url/manager')->resolve([$collection]); $query = $url->getQuery(); $query->modify($request->getQueryString()); $url = $url->setQuery($query); return $this->redirect($url, Response::HTTP_MOVED_PERMANENTLY, $headers); } } // maintenance mode if ($collection->getCollectionPath() != '/login') { $smm = $this->config->get('concrete.maintenance_mode'); if ($smm == 1 && !Key::getByHandle('view_in_maintenance_mode')->validate() && ($_SERVER['REQUEST_METHOD'] != 'POST' || Loader::helper('validation/token')->validate() == false)) { $v = new View('/frontend/maintenance_mode'); $router = $this->app->make(RouterInterface::class); $tmpTheme = $router->getThemeByRoute('/frontend/maintenance_mode'); $v->setViewTheme($tmpTheme[0]); $v->addScopeItems(['c' => $collection]); $request->setCurrentPage($collection); if (isset($tmpTheme[1])) { $v->setViewTemplate($tmpTheme[1]); } return $this->view($v, $code, $headers); } } if ($collection->getCollectionPointerExternalLink() != '') { return $this->redirect($collection->getCollectionPointerExternalLink()); } $cp = new Checker($collection); if ($cp->isError() && $cp->getError() == COLLECTION_FORBIDDEN) { return $this->forbidden($request->getUri(), Response::HTTP_FORBIDDEN, $headers); } if (!$collection->isActive() && !$cp->canViewPageVersions()) { return $this->notFound('', Response::HTTP_NOT_FOUND, $headers); } $scheduledVersion = Version::get($collection, "SCHEDULED"); if ($publishDate = $scheduledVersion->cvPublishDate) { $datetime = $this->app->make('helper/date'); $now = $datetime->date('Y-m-d G:i:s'); if (strtotime($now) >= strtotime($publishDate)) { $scheduledVersion->approve(); $collection->loadVersionObject('ACTIVE'); } } if ($cp->canEditPageContents() || $cp->canEditPageProperties() || $cp->canViewPageVersions()) { $collection->loadVersionObject('RECENT'); } $vp = new Checker($collection->getVersionObject()); // returns the $vp object, which we then check if (is_object($vp) && $vp->isError()) { switch ($vp->getError()) { case COLLECTION_NOT_FOUND: return $this->notFound('', Response::HTTP_NOT_FOUND, $headers); break; case COLLECTION_FORBIDDEN: return $this->forbidden($request->getUri(), Response::HTTP_FORBIDDEN, $headers); break; } } // Now that we've passed all permissions checks, and we have a page, we check to see if we // ought to redirect based on base url or trailing slash settings $cms = $this->app; $site = $this->app['site']->getSite(); $response = $cms->handleCanonicalURLRedirection($request, $site); if (!$response) { $response = $cms->handleURLSlashes($request, $site); } if (isset($response)) { return $response; } $dl = $cms->make('multilingual/detector'); if ($dl->isEnabled()) { $dl->setupSiteInterfaceLocalization($collection); } if (!$request->getPath() && $request->isMethod('GET') && !$request->query->has('cID')) { // This is a request to the home page –http://www.mysite.com/ // First, we check to see if we need to redirect to a default multilingual section. if ($dl->isEnabled() && $site->getConfigRepository()->get('multilingual.redirect_home_to_default_locale')) { // Let's retrieve the default language $ms = $dl->getPreferredSection(); if (is_object($ms)) { return $this->redirect(\URL::to($ms)); } } // Otherwise, let's check to see if our home page, which we have loaded already, has a path (like /en) // If it does, we'll redirect to the path. if ($collection->getCollectionPath() != '') { return $this->redirect(\URL::to($collection)); } } $request->setCurrentPage($collection); $c = $collection; // process.php needs this require DIR_BASE_CORE . '/bootstrap/process.php'; $u = new User(); // On page view event. $pe = new Event($collection); $pe->setUser($u); $pe->setRequest($request); $this->app['director']->dispatch('on_page_view', $pe); // Core menu items $item = new RelationListItem(); $menu = $this->app->make('helper/concrete/ui/menu'); $menu->addMenuItem($item); $controller = $collection->getPageController(); // we update the current page with the one bound to this controller. $collection->setController($controller); return $this->controller($controller); }
/** * @access private */ public function addFooterItem($item) { return parent::addFooterItem($item); }
public function render($label, $customTemplate, $description) { $obj = $this->getPageTypeComposerControlDraftValue(); if (!is_object($obj)) { if ($this->page) { // we HAVE a page, but we don't have a block object, which means something has gone wrong. // we've lost the association. So we abort. View::element('page_types/composer/controls/invalid_block'); return; } $obj = $this->getBlockTypeObject(); } $this->getController($obj); $app = Application::getFacadeApplication(); $env = Environment::get(); $form = $app->make('helper/form'); $set = $this->getPageTypeComposerFormLayoutSetControlObject()->getPageTypeComposerFormLayoutSetObject(); if ($customTemplate) { $rec = $env->getRecord(DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES_COMPOSER . '/' . $customTemplate); if ($rec->exists()) { $template = DIRNAME_BLOCK_TEMPLATES_COMPOSER . '/' . $customTemplate; } else { foreach (PackageList::get()->getPackages() as $pkg) { $file = (is_dir(DIR_PACKAGES . '/' . $pkg->getPackageHandle()) ? DIR_PACKAGES : DIR_PACKAGES_CORE) . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES_COMPOSER . '/' . $customTemplate; if (file_exists($file)) { $template = DIRNAME_BLOCK_TEMPLATES_COMPOSER . '/' . $customTemplate; break; } } } } if (!isset($template)) { $template = FILENAME_BLOCK_COMPOSER; } $this->inc($template, ['control' => $this, 'obj' => $obj, 'description' => $description]); }