public function testFetchDescriptionKeywordsConsiderNamespaceWideLocation() { $dirTmp = CM_Bootloader::getInstance()->getDirTmp(); $render = $this->getMockBuilder('CM_Frontend_Render')->setMethods(array('getTemplatePath', 'getLayoutPath'))->getMock(); $render->expects($this->any())->method('getTemplatePath')->will($this->returnValue(null)); $render->expects($this->exactly(2))->method('getLayoutPath')->will($this->returnCallback(function ($templateName) use($dirTmp) { $templateFile = new CM_File($dirTmp . $templateName); $templateFile->ensureParentDirectory(); $templateFile->write('test-' . $templateName); return $templateFile->getPath(); })); /** @var CM_Frontend_Render $render */ $page = $this->getMockBuilder('CM_Page_Abstract')->getMockForAbstractClass(); /** @var CM_Page_Abstract $page */ $renderAdapter = new CM_RenderAdapter_Page($render, $page); $this->assertSame('test-Page/Abstract/meta-description.tpl', $renderAdapter->fetchDescription()); $this->assertSame('test-Page/Abstract/meta-keywords.tpl', $renderAdapter->fetchKeywords()); }
/** * @return string */ public function fetch() { $render = $this->getRender(); $page = $this->_getPage(); $layoutClass = $page->getLayout($render->getEnvironment()); $layout = new $layoutClass(['page' => $page]); $document = $this->_getDocument(); $renderAdapterPage = new CM_RenderAdapter_Page($render, $page); $renderAdapterLayout = new CM_RenderAdapter_Layout($render, $layout); $page->checkAccessible($render->getEnvironment()); $viewResponse = new CM_Frontend_ViewResponse($document); $frontend = $render->getGlobalResponse(); $frontend->treeExpand($viewResponse); $viewResponse->setTemplateName('default'); $document->prepare($render->getEnvironment(), $viewResponse); $viewResponse->set('viewResponse', $viewResponse); $viewResponse->set('page', $page); $viewResponse->set('layoutContent', $renderAdapterLayout->fetch()); $viewResponse->set('title', $renderAdapterPage->fetchTitleWithBranding()); $viewResponse->set('metaDescription', $renderAdapterPage->fetchDescription()); $viewResponse->set('metaKeywords', $renderAdapterPage->fetchKeywords()); $webFontLoaderConfig = $render->getSite()->getWebFontLoaderConfig(); if ($webFontLoaderConfig) { $viewResponse->set('webFontLoaderConfig', CM_Params::encode($webFontLoaderConfig, true)); } $environmentDefault = new CM_Frontend_Environment($render->getEnvironment()->getSite()); $renderDefault = new CM_Frontend_Render($environmentDefault); $viewResponse->set('renderDefault', $renderDefault); $viewResponse->set('languageList', new CM_Paging_Language_Enabled()); $frontend->getOnloadHeaderJs()->append('cm.options = ' . CM_Params::encode($this->_getOptions(), true)); if ($viewer = $render->getViewer()) { $frontend->getOnloadHeaderJs()->append('cm.viewer = ' . CM_Params::encode($viewer, true)); } $frontend->getOnloadReadyJs()->append('cm.getLayout()._ready();'); $frontend->getOnloadHeaderJs()->append('cm.ready();'); $html = $render->fetchViewResponse($viewResponse); $frontend->treeCollapse(); return $html; }
function smarty_function_page(array $params, Smarty_Internal_Template $template) { /** @var CM_Frontend_Render $render */ $render = $template->smarty->getTemplateVars('render'); $view = null; if (isset($params['view'])) { $view = $params['view']; unset($params['view']); if (!$view instanceof CM_Page_Abstract) { throw new CM_Exception('Unexpected page instance'); } } if ($view) { $renderAdapter = CM_RenderAdapter_Page::factory($render, $view); return $renderAdapter->fetch(); } else { return '<div class="page-placeholder"></div>'; } }
/** * @param CM_Page_Abstract $page * @param CM_Model_User|null $viewer * @param CM_Site_Abstract|null $site * @return CM_Dom_NodeList */ protected function _renderPage(CM_Page_Abstract $page, CM_Model_User $viewer = null, CM_Site_Abstract $site = null) { if (null === $site) { $site = CM_Site_Abstract::factory(); } $host = parse_url($site->getUrl(), PHP_URL_HOST); $request = new CM_Http_Request_Get('?' . http_build_query($page->getParams()->getParamsEncoded()), array('host' => $host), null, $viewer); $response = new CM_Http_Response_Page($request, $this->getServiceManager()); $page->prepareResponse($response->getRender()->getEnvironment(), $response); $renderAdapter = new CM_RenderAdapter_Page($response->getRender(), $page); $html = $renderAdapter->fetch(); return new CM_Dom_NodeList($html, true); }
/** * @return string */ public function fetchKeywords() { return $this->_renderAdapterPage->fetchKeywords(); }
/** * @param CM_Page_Abstract $page * @return string */ protected function _renderPage(CM_Page_Abstract $page) { $renderAdapterPage = new CM_RenderAdapter_Page($this->getRender(), $page); $this->_title = $renderAdapterPage->fetchTitleWithBranding(); return $renderAdapterPage->fetch(); }