public function __construct($cmsPage = null) { if (!$cmsPage) { // Retrieve page instance from controller $cmsPage = \Cms\Classes\Controller::getController()->getPage(); } $this->haircutTiles = $cmsPage->settings['haircut_tiles']; $this->productTiles = $cmsPage->settings['product_tiles']; }
protected function playerPartialExists($name) { if (array_key_exists($name, $this->playerPartialFlags)) { return $this->playerPartialFlags[$name]; } $controller = Controller::getController(); if (!$controller) { throw new ApplicationException('Media tags can only be processed for front-end requests.'); } $partial = Partial::loadCached($controller->getTheme(), $name); return $this->playerPartialFlags[$name] = !!$partial; }
public function launchGreenhouse() { $controller = Controller::getController() ?: new Controller(); if (isset($_POST['lti_message_type'])) { $this['messageType'] = $_POST['lti_message_type']; switch ($this['messageType']) { case "ContentItemSelectionRequest": //Present text editor dialog to select a component $this['return_url'] = $_POST["content_item_return_url"]; break; case "basic-lti-launch-request": //load requested component $this->loadComponents(); break; } } else { //return xml configuration file for LTI tool $this->returnXML($controller); } }
/** * Handler for the pages.menuitem.resolveItem event. * Returns information about a menu item. The result is an array * with the following keys: * - url - the menu item URL. Not required for menu item types that return all available records. * The URL should be returned relative to the website root and include the subdirectory, if any. * Use the URL::to() helper to generate the URLs. * - isActive - determines whether the menu item is active. Not required for menu item types that * return all available records. * - items - an array of arrays with the same keys (url, isActive, items) + the title key. * The items array should be added only if the $item's $nesting property value is TRUE. * @param \RainLab\Pages\Classes\MenuItem $item Specifies the menu item. * @param \Cms\Classes\Theme $theme Specifies the current theme. * @param string $url Specifies the current page URL, normalized, in lower case * The URL is specified relative to the website root, it includes the subdirectory name, if any. * @return mixed Returns an array. Returns null if the item cannot be resolved. */ public static function resolveMenuItem($item, $url, $theme) { $result = null; if ($item->type == 'cms-page') { if (!$item->reference) { return; } $page = self::loadCached($theme, $item->reference); $controller = Controller::getController() ?: new Controller(); $pageUrl = $controller->pageUrl($item->reference, [], false); $result = []; $result['url'] = $pageUrl; $result['isActive'] = $pageUrl == $url; $result['mtime'] = $page ? $page->mtime : null; } return $result; }
/** * Helper that makes a URL for a page in the active theme. * @param mixed $page Specifies the Cms Page file name. * @return string */ public static function url($page, $params = [], $absolute = true) { /* * Reuse existing controller or create a new one, * assuming that the method is called not during the front-end * request processing. */ $controller = Controller::getController(); if (!$controller) { $controller = new Controller(); } return $controller->pageUrl($page, $params, true, $absolute); }
public function boot() { Event::listen('cms.router.beforeRoute', function ($url) { return Controller::instance()->initCmsPage($url); }); Event::listen('cms.page.beforeRenderPage', function ($controller, $page) { /* * Before twig renders */ $twig = $controller->getTwig(); $loader = $controller->getLoader(); Controller::instance()->injectPageTwig($page, $loader, $twig); /* * Get rendered content */ $contents = Controller::instance()->getPageContents($page); if (strlen($contents)) { return $contents; } }); Event::listen('cms.page.initComponents', function ($controller, $page) { Controller::instance()->initPageComponents($controller, $page); }); Event::listen('cms.block.render', function ($blockName, $blockContents) { $page = CmsController::getController()->getPage(); if (!isset($page->apiBag['staticPage'])) { return; } $contents = Controller::instance()->getPlaceholderContents($page, $blockName, $blockContents); if (strlen($contents)) { return $contents; } }); Event::listen('pages.menuitem.listTypes', function () { return ['static-page' => 'rainlab.pages::lang.menuitem.static_page', 'all-static-pages' => 'rainlab.pages::lang.menuitem.all_static_pages']; }); Event::listen('pages.menuitem.getTypeInfo', function ($type) { if ($type == 'url') { return []; } if ($type == 'static-page' || $type == 'all-static-pages') { return StaticPage::getMenuTypeInfo($type); } }); Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) { if ($type == 'static-page' || $type == 'all-static-pages') { return StaticPage::resolveMenuItem($item, $url, $theme); } }); Event::listen('backend.form.extendFieldsBefore', function ($formWidget) { if ($formWidget->model instanceof \Cms\Classes\Partial) { Snippet::extendPartialForm($formWidget); } }); Event::listen('cms.template.save', function ($controller, $template, $type) { Plugin::clearCache(); }); Event::listen('cms.template.processSettingsBeforeSave', function ($controller, $dataHolder) { $dataHolder->settings = Snippet::processTemplateSettingsArray($dataHolder->settings); }); Event::listen('cms.template.processSettingsAfterLoad', function ($controller, $template) { Snippet::processTemplateSettings($template); }); Event::listen('cms.template.processTwigContent', function ($template, $dataHolder) { if ($template instanceof \Cms\Classes\Layout) { $dataHolder->content = Controller::instance()->parseSyntaxFields($dataHolder->content); } }); Event::listen('backend.richeditor.listTypes', function () { return ['static-page' => 'rainlab.pages::lang.menuitem.static_page']; }); Event::listen('backend.richeditor.getTypeInfo', function ($type) { if ($type === 'static-page') { return StaticPage::getRichEditorTypeInfo($type); } }); }
protected function makeUrl() { $controller = Controller::getController() ?: new Controller(); return $controller->pageUrl($this->getUrlPageName(), $this->getUrlParams()); }
/** * Parses the static page markup and renders snippets defined on the page. * @param string $pageName Specifies the static page file name (the name of the corresponding content block file). * @param \Cms\Classes\Theme $theme Specifies a parent theme. * @param string $markup Specifies the markup string to process. * @return string Returns the processed string. */ public static function processPageMarkup($pageName, $theme, $markup) { $map = self::extractSnippetsFromMarkupCached($theme, $pageName, $markup); $controller = CmsController::getController(); $partialSnippetMap = SnippetManager::instance()->getPartialSnippetMap($theme); $controller = CmsController::getController(); foreach ($map as $snippetDeclaration => $snippetInfo) { $snippetCode = $snippetInfo['code']; if (!isset($snippetInfo['component'])) { if (!array_key_exists($snippetCode, $partialSnippetMap)) { throw new ApplicationException(sprintf('Partial for the snippet %s is not found', $snippetCode)); } $partialName = $partialSnippetMap[$snippetCode]; $generatedMarkup = $controller->renderPartial($partialName, $snippetInfo['properties']); } else { $generatedMarkup = $controller->renderComponent($snippetCode); } $pattern = preg_quote($snippetDeclaration); $markup = mb_ereg_replace($pattern, $generatedMarkup, $markup); } return $markup; }
/** * {@inheritDoc} */ public function getReceiptUrl() { if ($this->return_page) { $controller = Controller::getController() ?: new Controller(); return $controller->pageUrl($this->return_page, $this->getUrlParams()); } return $this->getUrlAttribute(); }
/** * Helper that makes a URL for a page in the active theme. * @param mixed $page Specifies the Cms Page file name. * @param array $params Route parameters to consider in the URL. * @return string */ public static function url($page, $params = [], $absolute = true) { /* @deprecated remove if year >= 2016 -- remove 3rd argument */ if ($absolute !== true) { traceLog('Deprecated warning: Third argument of Page::url() has no affect, consider removing it.'); } /* * Reuse existing controller or create a new one, * assuming that the method is called not during the front-end * request processing. */ $controller = Controller::getController(); if (!$controller) { $controller = new Controller(); } return $controller->pageUrl($page, $params, true); }