Example #1
0
 public function doGet(\Innomatic\Webapp\WebAppRequest $req, \Innomatic\Webapp\WebAppResponse $res)
 {
     // Start Innomatic
     $innomatic = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     $innomatic->setInterface(\Innomatic\Core\InnomaticContainer::INTERFACE_EXTERNAL);
     $root = \Innomatic\Core\RootContainer::instance('\\Innomatic\\Core\\RootContainer');
     $innomatic_home = $root->getHome() . 'innomatic/';
     $innomatic->bootstrap($innomatic_home, $innomatic_home . 'core/conf/innomatic.ini');
     // Start Innomatic domain
     \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->startDomain(\Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getName());
     // Innomedia page
     $scope_page = 'frontend';
     // Check if the page exists in the page tree
     $pageSearch = PageTree::findPageByPath(substr($req->getPathInfo(), 1));
     if ($pageSearch === false) {
         // This is a static page (excluding the home page).
         $location = explode('/', $req->getPathInfo());
         $module_name = isset($location[1]) ? $location[1] : '';
         $page_name = isset($location[2]) ? $location[2] : '';
         $pageId = isset($location[3]) ? $location[3] : 0;
     } else {
         // This is the home page or a content page.
         $module_name = $pageSearch['module'];
         $page_name = $pageSearch['page'];
         $pageId = $pageSearch['page_id'];
     }
     // Define Innomatic context
     $home = \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getHome();
     $context = Context::instance('\\Innomedia\\Context');
     $context->setRequest($req)->setResponse($res)->process();
     // Build Innomedia page
     $page = new Page($module_name, $page_name, $pageId, $scope_page);
     $page->parsePage();
     // Check if the page is valid
     if (!$page->isValid()) {
         $res->sendError(\Innomatic\Webapp\WebAppResponse::SC_NOT_FOUND, $req->getRequestURI());
     } else {
         $page->build();
     }
 }
Example #2
0
 /**
  * Processes and initializes the context.
  *
  * @return void
  */
 public function process()
 {
     // Initialize the session.
     $this->session = new \Innomatic\Php\PHPSession();
     $this->session->start();
     // Set 'session.gc_maxlifetime' and 'session.cookie_lifetime' to the value
     // defined by the 'sessionLifetime' parameter in web.xml.
     $lifetime = \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getInitParameter('sessionLifetime');
     if ($lifetime !== false) {
         $this->session->setLifeTime($lifetime);
     }
     // Check if the locale has been passed as parameter.
     if ($this->request->parameterExists('innomedia_setlocale')) {
         // Store the locale into the session.
         $this->session->put('innomedia_locale', $this->request->getParameter('innomedia_setlocale'));
     }
     // Retrieve the locale from the session, if set.
     if ($this->session->isValid('innomedia_locale')) {
         $this->locales[] = $this->session->get('innomedia_locale');
     }
     // Add the locales supported by the web agent.
     $this->locales = array_merge($this->locales, $this->request->getLocales());
 }
 /**
  * Prefix the context path, our webapp emulator and append the request
  * parameters to the redirection string before calling sendRedirect.
  *
  * @param $request WebAppRequest
  * @param $redirectPath string
  * @return string
  */
 protected function getURL(\Innomatic\Webapp\WebAppRequest $request, $redirectPath)
 {
     $result = '';
     $container = \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer');
     $processor = $container->getProcessor();
     $webAppPath = $request->getUrlPath();
     if (!is_null($webAppPath) && $webAppPath != '/') {
         $result = $request->generateControllerPath($webAppPath, true);
     }
     $result .= '/webservices' . $redirectPath;
     $query = $request->getQueryString();
     if (!is_null($query)) {
         $result .= '?' . $query;
     }
     return $result;
 }
 /**
  * Prefix the context path, our webapp emulator and append the request
  * parameters to the redirection string before calling sendRedirect.
  *
  * @param $request WebAppRequest
  * @param $redirectPath string
  * @return string
  */
 protected function getURL(\Innomatic\Webapp\WebAppRequest $request, $redirectPath)
 {
     $result = '';
     $webAppPath = $request->getUrlPath();
     if (!is_null($webAppPath) && $webAppPath != '/') {
         $result = $request->generateControllerPath($webAppPath, true);
     }
     $result .= '/domain' . $redirectPath;
     $query = $request->getQueryString();
     if (!is_null($query)) {
         $result .= '?' . $query;
     }
     return $result;
 }