protected function main() { $locale = $this->Request->get('locale'); if (isset($_SESSION['guest_block'])) { unset($_SESSION['guest_block']); } if (isset($_SESSION['langs'])) { unset($_SESSION['langs']); } if (isset($_SESSION['welcome'])) { unset($_SESSION['welcome']); } if (isset($_SESSION['welcome_guest'])) { unset($_SESSION['welcome_guest']); } $_SESSION['locale'] = $locale; $this->Registry->Locale->set($locale); Cookie::set('locale', $locale); if (!empty($_SESSION['langs'])) { unset($_SESSION['langs']); } //echo __METHOD__.' '.__LINE__.' getting Tr object for locale: '.$locale; //$this->Tr = Translator::factory($this->Registry, $locale); //echo __METHOD__.' '.__LINE__.' '.print_r($this->Tr->getMessages(), 1);//$this->Tr->get('Questions'); Responder::redirectToPage($this->Request->get('redirect')); }
protected function main() { $locale = $this->Registry->Router->getSegment(1); /** * Redirect url is passed as query string (?redirect=http://someurl) * because we cannot pass the url as a uri segment because url itself * has many segments */ $redirect = $_GET['redirect']; if (isset($_SESSION['guest_block'])) { unset($_SESSION['guest_block']); } if (isset($_SESSION['langs'])) { unset($_SESSION['langs']); } if (isset($_SESSION['welcome'])) { unset($_SESSION['welcome']); } if (isset($_SESSION['welcome_guest'])) { unset($_SESSION['welcome_guest']); } $_SESSION['locale'] = $locale; $this->Registry->Locale->set($locale); Cookie::set('locale', $locale, 126144000); if (!empty($_SESSION['langs'])) { unset($_SESSION['langs']); } Responder::redirectToPage($redirect); }