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() . ')'); } }
/** * Adds the user group field */ private function AddUserGroupField() { $name = 'UserGroup'; $field = new Select($name, ''); $field->AddOption('', Trans('Core.ContainerForm.NoGroup')); if ($this->container->Exists() && $this->container->GetUserGroup()) { $field->SetValue($this->container->GetUserGroup()->GetID()); } DBSelectUtil::AddUserGroupOptions($field); $this->AddField($field); }
private function AddTagNameField() { $name = 'TagName'; $select = new Select($name, $this->block->GetTagName()); $select->AddOption('', Trans('Core.PleaseSelect')); $values = BlockTag::AllowedValues(); foreach ($values as $value) { $select->AddOption($value, $value); } $this->AddField($select); $this->SetRequired($name); }
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); }
private function AddContainerField() { $name = 'Container'; $value = $this->container->Exists() ? $this->container->GetContainer()->GetID() : ''; $select = new Select($name, $value); $select->AddOption('', Trans('Core.PleaseSelect')); $sql = Access::SqlBuilder(); $tblContainer = Container::Schema()->Table(); $orderBy = $sql->OrderList($sql->OrderAsc($tblContainer->Field('Name'))); $containers = Container::Schema()->Fetch(false, null, $orderBy); foreach ($containers as $container) { $select->AddOption($container->GetID(), $container->GetName()); } $this->AddField($select); $this->SetRequired($name); }
/** * Adds the module type option, if allowed * @param Select $select The select box * @param string $type The module type */ private function AddModuleTypeOption(Select $select, $type) { if ($type != 'BuiltIn-Container' || !Request::GetData('container') && Container::Schema()->Count() > 0) { $select->AddOption($type, Trans($type)); } }
/** * Adds the template select field * @param FrontendModule $module The module for template selection */ protected final function AddTemplateField() { $name = 'Template'; $field = new Select($name, (string) $this->Content()->GetTemplate()); $field->AddOption('', Trans("Core.ContentForm.{$name}.Default")); $folder = PathUtil::ModuleCustomTemplatesFolder($this->FrontendModule()); if (Folder::Exists($folder)) { $files = Folder::GetFiles($folder); foreach ($files as $file) { $value = Path::FilenameNoExtension($file); $field->AddOption($value, $value); } } $this->AddField($field, false, Trans("Core.ContentForm.{$name}")); }
private function AddTypeField() { $name = 'Type'; $value = $this->page->Exists() ? $this->page->GetType() : (string) PageType::Normal(); $field = new Select($name, $value); $types = PageType::AllowedValues(); $ex404 = FrontendRouter::Page404($this->site); foreach ($types as $type) { if ($type == (string) PageType::NotFound() && $ex404 && !$ex404->Equals($this->page)) { continue; } $field->AddOption($type, Trans('Core.PageForm.Type.' . ucfirst($type))); } $this->AddField($field); }
private function AddTypeField() { $name = 'Type'; $value = 'PageItem'; if ($this->naviItem->Exists() && $this->naviItem->GetUrlItem()) { $value = 'UrlItem'; } $field = new Select($name, $value); $field->AddOption('PageItem', Trans('BuiltIn.NavigationItem.Type.PageItem')); $field->AddOption('UrlItem', Trans('BuiltIn.NavigationItem.Type.UrlItem')); $this->AddField($field); }
/** * Adds the smtp security field */ private function AddSmtpSecurityField() { $name = 'SmtpSecurity'; $field = new Select($name, $this->settings->GetSmtpSecurity()); $values = SmtpSecurity::AllowedValues(); foreach ($values as $value) { $field->AddOption($value, Trans("Core.SettingsForm.SmtpSecurity.{$value}")); } $this->AddField($field); }