Esempio n. 1
0
 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());
 }
Esempio n. 2
0
 /**
  * @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;
 }
Esempio n. 3
0
 /**
  * @return string
  */
 public function fetchDescription()
 {
     return $this->_renderAdapterPage->fetchDescription();
 }