static function AddLanguageOptions(Select $field, Condition $where = null) { $sql = Access::SqlBuilder(); $tblLang = Language::Schema()->Table(); $orderBy = $sql->OrderList($sql->OrderAsc($tblLang->Field('Name'))); $langs = Language::Schema()->Fetch(false, $where, $orderBy); foreach ($langs as $lang) { $field->AddOption($lang->GetID(), $lang->GetName() . ' (' . $lang->GetCode() . ')'); } }
private function AddLanguageField() { $name = 'Language'; $lang = $this->user->GetLanguage(); $field = new Select($name, $lang ? $lang->GetID() : ''); $field->AddOption('', Trans('Core.PleaseSelect')); $sql = Access::SqlBuilder(); $tbl = Language::Schema()->Table(); $where = $sql->Equals($tbl->Field('IsBackendTranslated'), $sql->Value(true)); DBSelectUtil::AddLanguageOptions($field, $where); $this->AddField($field); $this->SetRequired($name); }
/** * Saves the site */ protected function OnSuccess() { $action = Action::Update(); if (!$this->site->Exists()) { $action = Action::Create(); $this->site->SetUser(self::Guard()->GetUser()); } $this->site->SetName($this->Value('Name')); $this->site->SetUrl($this->Value('Url')); $this->site->SetLanguage(Language::Schema()->ByID($this->Value('Language'))); $this->site->SetSitemapActive((bool) $this->Value('SitemapActive')); $this->site->SetSitemapCacheLifetime((int) $this->Value('SitemapCacheLifetime')); $this->site->Save(); $logger = new Logger(self::Guard()->GetUser()); $logger->ReportSiteAction($this->site, $action); if ($this->CanAssignGroup()) { $this->SaveRights(); } Response::Redirect(BackendRouter::ModuleUrl(new SiteList())); }