Exemplo n.º 1
0
 /**
  * @param bool $routeInit
  * @param null $menuItemTranslation
  */
 public function renderSite($routeInit = true, $menuItemTranslation = null)
 {
     $tpl = $this->template;
     if (is_object($menuItemTranslation)) {
         $this->loadVirtualRoutes();
         $menuItemTranslation = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItemTranslation')->findOneById($menuItemTranslation->id);
         if (!$this->getCurrentDomain()) {
             $this->setCurrentDomain($this->getRequestDomain());
         }
         // must set before check route, because the locale must be set
         $this->setupPage($menuItemTranslation);
         $virtualRouteContent = $this->checkVirtualRoute();
         if ($virtualRouteContent === false && $this->request->isXmlHttpRequest() === false && $this->isHTTPS() === false && $this->currentMenuItem->https === true) {
             $this->redirectToURL('https://' . $this->getRequestRoute());
         }
         $this->sitefullRoute = rtrim($this->buildFullUrl($this->currentMenuItem), '/');
         if ($routeInit == true) {
             if ($virtualRouteContent !== false) {
                 // virtual route content
                 $this->response->send($virtualRouteContent, true);
             }
             if ($this->currentMenuItem->checkPermission === true && $this->currentMenuItem->parent !== null && $this->user->isLoggedIn() === false) {
                 return $this->menuItemNotFound();
             }
             // read the template content
             $mainTemplateString = $menuItemTranslation->menuItem->template ? $menuItemTranslation->menuItem->template->html : $this->getDefaultMenuItemTemplate();
             if ($this->getFoundURI(false) != trim($this->getRequestRoute(false, false), '/')) {
                 $this->blockParser->setCheckRouteError(true);
                 $tpl->setTemplate('string:' . $mainTemplateString);
                 $content = $tpl->prepareTemplate();
                 $routeExistModules = $this->blockParser->moduleRouteExist($content);
                 if ($routeExistModules === false) {
                     return $this->menuItemNotFound();
                 } else {
                     if ($this->request->isXmlHttpRequest() === true) {
                         // only exec modules where we find the route
                         $this->core->response->send($this->blockParser->parse($routeExistModules));
                     } else {
                         $this->siteManager->addAdminPanel();
                         echo $this->blockParser->parse($content);
                     }
                 }
             } else {
                 $this->siteManager->addAdminPanel();
                 $tpl->renderString($mainTemplateString);
             }
             // cache page if cache enable
             $this->cache->setCacheContent();
         } else {
             $tpl->renderString($menuItemTranslation->menuItem->template->html);
         }
     } else {
         $this->menuItemNotFound();
     }
 }
Exemplo n.º 2
0
Arquivo: Route.php Projeto: fraym/core
 /**
  * @param null $menuItemTranslation
  */
 public function renderSite($menuItemTranslation = null)
 {
     $tpl = $this->template;
     if (is_object($menuItemTranslation)) {
         $this->loadRoutes();
         $menuItemTranslation = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItemTranslation')->findOneById($menuItemTranslation->id);
         // must set before check route, because the locale must be set
         $this->setupPage($menuItemTranslation);
         if (!$this->getCurrentDomain()) {
             $this->setCurrentDomain($this->getRequestDomain());
         }
         $virtualRouteContent = $this->getVirtualRouteContent();
         $this->sitefullRoute = $this->currentMenuItem->getUrl(true);
         if ($virtualRouteContent !== false) {
             // virtual route content
             $this->response->send($virtualRouteContent, true);
         }
         if ($this->currentMenuItem->checkPermission === true && $this->currentMenuItem->parent !== null && $this->user->isLoggedIn() === false) {
             return $this->menuItemNotFound();
         }
         if ($this->getFoundUri(false) === trim($this->getRequestRoute(false, false), '/') || $this->getVirtualRouteContent(true)) {
             $this->siteManager->addAdminPanel();
             $tpl->renderMainTemplate();
         } else {
             return $this->menuItemNotFound();
         }
         if ($this->template->isCachingDisabled() === false) {
             // cache page if cache enable
             $this->cache->setCacheContent();
         }
     } else {
         $this->menuItemNotFound();
     }
 }