getControlState('user'); } public function setUserToChange(DbUser $user) { if ($user->IsGuest && !$this->Page->IsCallBack) { throw new TInvalidDataValueException( Prado::localize( 'Language preference change impossible for guest user' ) ); } $this->setControlState('user', $user); } public function onPreRender($param) { parent::onPreRender($param); $this->Languages->DataSource = $this->_getLanguages(); $this->Languages->DataValueField = 'Name'; $this->Languages->DataTextField = 'Label'; $this->Languages->dataBind(); $this->Languages->setSelectedValue( $this->Application->Globalization->getCulture() ); } public function saveLang($sender, $param) { $this->getFacade()->setLanguagePreference( $this->UserToChange, $this->Languages->SelectedValue ); $this->Response->redirect( $this->Service->constructUrl( $this->Service->getRequestedPage()->PagePath ) ); } private function _getLanguages() { $langs = array_map( function($lang) { return new LanguageDTO($lang); }, $this->Application->Globalization->getAllowedCultures() ); usort($langs, ['LanguageDTO', '__compare']); return $langs; } } ?>