private function setLangFromUri() { $config = new Config(); if ($config->remoteLangFrom === 'uri') { $langList = new Bobr_LangList(); if (!empty($langList->items)) { $pattern = '@'; // Vytvorime si matchovaci patternu. foreach ($langList->getItems() as $lang) { $pattern .= $lang->symbol . '|'; } // Odstranime posledni znamenko. (je to |) $pattern = substr($pattern, 0, -1) . '@'; // Zjistime jestli podoporovany jazyk je v uri if (0 < preg_match($pattern, $this->get[Bobr_Request_HttpRequest::GET_VARIABLE], $matches)) { // Vytrovime samostatnou promenou a ulozime do ni symbol jazyka. $this->get[Bobr_Request_HttpGet::GET_LANG_VARIABLE] = $matches[0]; // Odebereme z uri symbol jazyka, vadil by pri dalsi praci. $this->get[Bobr_Request_HttpRequest::GET_VARIABLE] = str_replace($matches[0] . '/', '', $this->get[Bobr_Request_HttpRequest::GET_VARIABLE]); print_Re($this); return TRUE; } $this->get[self::GET_LANG_VARIABLE] = $config->defaultLang; Bobr_Request_HttpRequest::redirect($config->webRoot . $config->defaultLang . '/'); } else { throw new ErrorException('Neni podpora pro jazyky.'); //HttpRequest::redirect($config->webRoot . $config->defaultLang . '/'); } } }
/** * Vraci vlastni instanci * * @return Bobr_Request_HttpRequest */ public static function getInstance() { if (NULL === self::$instance) { return self::$instance = new self(); } else { return self::$instance; } }
protected function logoutAction() { try { $userLogin = new Bobr_User_UserLogin(); $userLogin->logOut(); Lib_Messanger::addNote('Uzivatel byl odhlasen.'); Bobr_Request_HttpRequest::redirect(Link::build('login/login')); } catch (UserLoginException $e) { echo $e->getMessage(); } return ''; }
/** * Zjisti zda-li se jedna o statickou routu. * Pokud ano nastavi ji a vrati TRUE. * * @return boolean */ private function checkStaticRoute() { $route = new Bobr_Request_Route(); $uri = Bobr_Request_HttpRequest::uri(); if (NULL !== $route->loadByUri($uri, $this->lang)) { $this->setPageId($route->pageId); $this->setCommand($route->command); return TRUE; } else { return FALSE; } }
/** * Detects form submission and loads HTTP values. * @param Nette\Web\IHttpRequest optional request object * @return void */ public function processHttpRequest($httpRequest = NULL) { $this->submittedBy = FALSE; if ($httpRequest === NULL) { $httpRequest = Bobr_Request_HttpRequest::getInstance(); } $httpRequest->setEncoding($this->encoding); if ($this->isPost) { if (!$httpRequest->isMethod('post')) { return; } $data = self::arrayAppend($httpRequest->getPost(), $httpRequest->getFiles()); } else { if (!$httpRequest->isMethod('get')) { return; } $data = $httpRequest->getGet()->get(); } $tracker = $this->getComponent(self::TRACKER_ID, FALSE); if ($tracker) { if (!isset($data[self::TRACKER_ID]) || $data[self::TRACKER_ID] !== $tracker->getValue()) { return; } } else { if (!count($data)) { return; } } $this->submittedBy = TRUE; $this->loadHttpData($data); $this->submit(); }
/** * Zvaliduje session a nastavi uzivatele. * * @return Bobr */ private function setUser() { // Zvalidujem platnost Session new Bobr_SessionValidator(); $validator = new Bobr_User_UserValidator(); // Zvalidujem uzivatele v session if (FALSE === $validator->validate()) { // Uzivatel nebyl validni nastavime anonymouse $user = Bobr_Session::getInstance()->user = new Bobr_User_User(2); echo '<p>Nastavil jsem <b>' . $user->nick . '</b>.</p>'; } else { $user = Bobr_Session::getInstance()->user; echo '<p>Uzivatel <b>' . $user->nick . '</b> mel j*z vytvorenou session.</p>'; } $user = Bobr_Session::getInstance()->user; $webInstanceValidatdor = new Bobr_WebInstanceValidator(); if (TRUE === $webInstanceValidatdor->validate(Lib_Tools::getWebInstance())) { echo '<p>Uzivatel ma pristup na tuto web instanci</p>'; } else { Lib_Messanger::addError('Nemate pristup na tuto stranku.'); //@todo tato hlaska se pri presmerovani vymaze!! Bobr_Request_HttpRequest::redirect('/'); } return $this; }