Exemplo n.º 1
0
 /**
  * @param CM_Params                  $params
  * @param CM_Http_Response_View_Ajax $response
  * @throws CM_Exception_Invalid
  * @return array
  */
 public function loadPage(CM_Params $params, CM_Http_Response_View_Ajax $response)
 {
     $request = new CM_Http_Request_Get($params->getString('path'), $this->getRequest()->getHeaders(), $this->getRequest()->getServer(), $this->getRequest()->getViewer());
     $count = 0;
     $paths = array($request->getPath());
     do {
         $url = $this->getRender()->getUrl(CM_Util::link($request->getPath(), $request->getQuery()));
         if ($count++ > 10) {
             throw new CM_Exception_Invalid('Page redirect loop detected (' . implode(' -> ', $paths) . ').');
         }
         $responsePage = new CM_Http_Response_Page_Embed($request, $this->getServiceManager());
         $responsePage->process();
         $request = $responsePage->getRequest();
         $paths[] = $request->getPath();
         if ($redirectUrl = $responsePage->getRedirectUrl()) {
             $redirectExternal = 0 !== mb_stripos($redirectUrl, $this->getRender()->getUrl());
             if ($redirectExternal) {
                 return array('redirectExternal' => $redirectUrl);
             }
         }
     } while ($redirectUrl);
     foreach ($responsePage->getCookies() as $name => $cookieParameters) {
         $response->setCookie($name, $cookieParameters['value'], $cookieParameters['expire'], $cookieParameters['path']);
     }
     $page = $responsePage->getPage();
     $this->_setStringRepresentation(get_class($page));
     $frontend = $responsePage->getRender()->getGlobalResponse();
     $html = $responsePage->getContent();
     $js = $frontend->getJs();
     $autoId = $frontend->getTreeRoot()->getValue()->getAutoId();
     $frontend->clear();
     $title = $responsePage->getTitle();
     $layoutClass = get_class($page->getLayout($this->getRender()->getEnvironment()));
     $menuList = array_merge($this->getSite()->getMenus(), $responsePage->getRender()->getMenuList());
     $menuEntryHashList = $this->_getMenuEntryHashList($menuList, get_class($page), $page->getParams());
     $jsTracking = $responsePage->getRender()->getServiceManager()->getTrackings()->getJs();
     return array('autoId' => $autoId, 'html' => $html, 'js' => $js, 'title' => $title, 'url' => $url, 'layoutClass' => $layoutClass, 'menuEntryHashList' => $menuEntryHashList, 'jsTracking' => $jsTracking);
 }
Exemplo n.º 2
0
 /**
  * @expectedException CM_Exception
  * @expectedExceptionMessage Cannot pop
  */
 public function testPopPathPrefixNoMatch()
 {
     $request = new CM_Http_Request_Get('/part0/part1/part2');
     $request->popPathPrefix('/foo');
 }
Exemplo n.º 3
0
Arquivo: TH.php Projeto: aladin1394/CM
 /**
  * @param string             $pageClass
  * @param CM_Model_User|null $viewer OPTIONAL
  * @param array              $params OPTIONAL
  * @return CM_Page_Abstract
  */
 public static function createPage($pageClass, CM_Model_User $viewer = null, $params = array())
 {
     $request = new CM_Http_Request_Get('?' . http_build_query($params), array(), $viewer);
     return new $pageClass(CM_Params::factory($request->getQuery(), true), $request->getViewer());
 }
Exemplo n.º 4
0
 public function testIsSupportedWithoutUserAgent()
 {
     $request = new CM_Http_Request_Get('/', []);
     $this->assertSame(true, $request->isSupported());
 }