Esempio 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);
 }
Esempio n. 2
0
 public function testPopPathPrefix()
 {
     $request = new CM_Http_Request_Get('/part0/part1/part2');
     $request->popPathPrefix('/part0/part1/');
     $this->assertSame('/part2', $request->getPath());
 }