示例#1
0
 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() . ')');
     }
 }
示例#2
0
 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);
 }
示例#3
0
 /**
  * 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()));
 }