/** * Sets the SEO url valule if is a old url. * * @access protected * @return false|RedirectResponse * @author Etienne de Longeaux <*****@*****.**> */ protected function isNoScope() { $locale = $this->request->getLocale(); if ($this->is_scop_authorized && $this->container->has("sfynx.browser.lib.mobiledetect") && $this->container->has("sfynx.browser.lib.browscap")) { // we get the browser \Sfynx\ToolBundle\Util\PiFileManager::mkdirr($this->browscap_cache_dir, 0777); if ($this->request->attributes->has('sfynx-browser')) { $this->browser = $this->request->attributes->get('sfynx-browser'); } else { $this->browser = $this->container->get("sfynx.browser.lib.browscap")->getBrowser(); } if ($this->request->attributes->has('sfynx-mobiledetect')) { $this->mobiledetect = $this->request->attributes->get('sfynx-mobiledetect'); } else { $this->mobiledetect = $this->container->get("sfynx.browser.lib.mobiledetect"); } // we set globals information $globals = $this->scop_globals; $nav_desktop = strtolower($this->browser->Browser); $nav_mobile = strtolower($this->browser->Platform); $isNoScope = false; if (!$this->browser->isMobileDevice && (!isset($globals["navigator"][$nav_desktop]) || floatval($this->browser->Version) <= $globals["navigator"][$nav_desktop])) { $isNoScope = true; } elseif ($this->browser->isMobileDevice && !$this->mobiledetect->isTablet() && (!isset($globals["mobile"][$nav_mobile]) || floatval($this->browser->Platform_Version) <= $globals["mobile"][$nav_mobile])) { $isNoScope = true; } elseif ($this->browser->isMobileDevice && $this->mobiledetect->isTablet() && (!isset($globals["tablet"][$nav_mobile]) || floatval($this->browser->Platform_Version) <= $globals["tablet"][$nav_mobile])) { $isNoScope = true; } if ($this->browser->Version == 0.0 || $this->browser->Platform_Version == 0.0) { $isNoScope = false; } if ($isNoScope) { if (!$this->browser->isMobileDevice) { if (isset($globals["navigator"][$nav_desktop]) && floatval($this->browser->Version) <= $globals["navigator"][$nav_desktop]) { $isNav = false; } else { $isNav = true; } } elseif ($bc->getBrowser()->isMobileDevice) { if (isset($globals["navigator"][$nav_mobile]) && floatval($this->browser->Platform_Version) <= $globals["navigator"][$nav_mobile]) { $isNav = false; } else { $isNav = true; } } $isCookies = $this->browser->Cookies; $isJs = $this->browser->JavaScript; // we set response $response = new \Symfony\Component\HttpFoundation\Response($this->request->getUri()); $response->headers->set('Content-Type', 'text/html'); $response = $this->container->get('templating')->renderResponse('SfynxTemplateBundle:Template\\Nonav:nonav.html.twig', array('locale' => $locale, 'isCookies' => $isCookies, 'isJs' => $isJs, 'isNav' => $isNav), $response); // we apply all events allowed to change the response $event_response = new ResponseEvent($response, $this->date_expire); $this->container->get('event_dispatcher')->dispatch(SfynxCmfEvents::HANDLER_REQUEST_CHANGERESPONSE_NOSCOPE, $event_response); $response = $event_response->getResponse(); return $response; } } return false; }
/** * Invoked to modify the controller that should be executed. * * @param GetResponseEvent $event The event * * @access public * @return void * @author Etienne de Longeaux <*****@*****.**> */ public function onKernelRequest(GetResponseEvent $event) { if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) { // ne rien faire si ce n'est pas la requête principale return; } // Set request $this->request = $event->getRequest($event); // Sets parameter template values. $this->setParams(); // if ($this->request->cookies->has('sfynx-layout')) { $this->layout = $this->request->cookies->get('sfynx-layout'); } else { $this->layout = $this->container->getParameter('sfynx.auth.theme.layout.front.pc') . $this->init_pc_layout; } if ($this->request->cookies->has('sfynx-screen')) { $this->screen = $this->request->cookies->get('sfynx-screen'); } else { $this->screen = "layout"; } if ($this->is_browser_authorized && !$this->request->cookies->has('sfynx-layout') && $this->container->has("sfynx.browser.lib.mobiledetect") && $this->container->has("sfynx.browser.lib.browscap")) { // we get the browser PiFileManager::mkdirr($this->browscap_cache_dir, 0777); if ($this->request->attributes->has('sfynx-browser')) { $this->browser = $this->request->attributes->get('sfynx-browser'); } else { $this->browser = $this->container->get("sfynx.browser.lib.browscap")->getBrowser(); } if ($this->request->attributes->has('sfynx-mobiledetect')) { $this->mobiledetect = $this->request->attributes->get('sfynx-mobiledetect'); } else { $this->mobiledetect = $this->container->get("sfynx.browser.lib.mobiledetect"); } // $this->request->attributes->set('sfynx-browser', $this->browser); $this->request->attributes->set('sfynx-mobiledetect', $this->mobiledetect); // if ($this->browser->isMobileDevice) { if (!$this->mobiledetect->isTablet()) { $this->screen = "layout-poor"; } elseif ($this->mobiledetect->isTablet()) { $this->screen = "layout-medium"; } else { $this->screen = 'layout-medium'; } $this->layout = $this->container->getParameter('sfynx.auth.theme.layout.front.mobile') . $this->init_mobile_layout . '\\' . $this->screen . '.html.twig'; $this->request->setRequestFormat('mobile'); } } // we add sfynx-layout and sfynx-screen info in the request $this->request->attributes->set('sfynx-layout', $this->layout); $this->request->attributes->set('sfynx-screen', $this->screen); }