/// <summary> /// Binds the data. /// </summary> private void BindData() { this.ForumEditor.DataSource = ForumEditorHelper.GetFilteredEditorList(); // TODO: vzrus: UseFullTextSearch check box is data layer specific and can be hidden by YAF.Classes.Data.LegacyDb.FullTextSupported property.) this.DataBind(); // load Board Setting collection information... var settingCollection = new YafBoardSettingCollection(this.Get <YafBoardSettings>()); // handle checked fields... foreach (var name in settingCollection.SettingsBool.Keys) { Control control = this.HostSettingsTabs.FindControlRecursive(name); if (control is CheckBox && settingCollection.SettingsBool[name].CanRead) { // get the value from the property... ((CheckBox)control).Checked = (bool) Convert.ChangeType( settingCollection.SettingsBool[name].GetValue(this.Get <YafBoardSettings>(), null), typeof(bool)); } } // handle string fields... foreach (var name in settingCollection.SettingsString.Keys) { Control control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsString[name].CanRead) { // get the value from the property... ((TextBox)control).Text = (string) Convert.ChangeType( settingCollection.SettingsString[name].GetValue(this.Get <YafBoardSettings>(), null), typeof(string)); } else if (control is DropDownList && settingCollection.SettingsString[name].CanRead) { ListItem listItem = ((DropDownList)control).Items.FindByValue( settingCollection.SettingsString[name].GetValue(this.Get <YafBoardSettings>(), null) .ToString()); if (listItem != null) { listItem.Selected = true; } } } // handle int fields... foreach (var name in settingCollection.SettingsInt.Keys) { Control control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsInt[name].CanRead) { ((TextBox)control).CssClass = name.Equals("ServerTimeCorrection") ? "NumericServerTimeCorrection" : "Numeric"; // get the value from the property... ((TextBox)control).Text = settingCollection.SettingsInt[name].GetValue(this.Get <YafBoardSettings>(), null).ToString(); } else if (control is DropDownList && settingCollection.SettingsInt[name].CanRead) { ListItem listItem = ((DropDownList)control).Items.FindByValue( settingCollection.SettingsInt[name].GetValue(this.Get <YafBoardSettings>(), null).ToString()); if (listItem != null) { listItem.Selected = true; } } } // handle double fields... foreach (var name in settingCollection.SettingsDouble.Keys) { Control control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsDouble[name].CanRead) { ((TextBox)control).CssClass = "Numeric"; // get the value from the property... ((TextBox)control).Text = settingCollection.SettingsDouble[name].GetValue(this.Get <YafBoardSettings>(), null).ToString(); } else if (control is DropDownList && settingCollection.SettingsDouble[name].CanRead) { ListItem listItem = ((DropDownList)control).Items.FindByValue( settingCollection.SettingsDouble[name].GetValue(this.Get <YafBoardSettings>(), null) .ToString()); if (listItem != null) { listItem.Selected = true; } } } // special field handling... this.AvatarSize.Text = (this.Get <YafBoardSettings>().AvatarSize != 0) ? this.Get <YafBoardSettings>().AvatarSize.ToString() : string.Empty; this.MaxFileSize.Text = (this.Get <YafBoardSettings>().MaxFileSize != 0) ? this.Get <YafBoardSettings>().MaxFileSize.ToString() : string.Empty; this.SQLVersion.Text = this.HtmlEncode(this.Get <YafBoardSettings>().SQLVersion); if (General.GetCurrentTrustLevel() <= AspNetHostingPermissionLevel.Medium) { return; } this.AppCores.Text = Platform.Processors; this.AppMemory.Text = "{0} MB of {1} MB".FormatWith( Platform.AllocatedMemory.ToType <long>() / 1000000, Platform.MappedMemory.ToType <long>() / 1000000); this.AppOSName.Text = Platform.VersionString; this.AppRuntime.Text = "{0} {1}".FormatWith(Platform.RuntimeName, Platform.RuntimeString); }
/// <summary> /// Saves the Host Settings /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Save_Click([NotNull] object sender, [NotNull] EventArgs e) { // write all the settings back to the settings class // load Board Setting collection information... var settingCollection = new YafBoardSettingCollection(this.Get <YafBoardSettings>()); // handle checked fields... foreach (var name in settingCollection.SettingsBool.Keys) { Control control = this.HostSettingsTabs.FindControlRecursive(name); if (control is CheckBox && settingCollection.SettingsBool[name].CanWrite) { settingCollection.SettingsBool[name].SetValue( this.Get <YafBoardSettings>(), ((CheckBox)control).Checked, null); } } // handle string fields... foreach (var name in settingCollection.SettingsString.Keys) { Control control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsString[name].CanWrite) { settingCollection.SettingsString[name].SetValue( this.Get <YafBoardSettings>(), ((TextBox)control).Text.Trim(), null); } else if (control is DropDownList && settingCollection.SettingsString[name].CanWrite) { settingCollection.SettingsString[name].SetValue( this.Get <YafBoardSettings>(), Convert.ToString(((DropDownList)control).SelectedItem.Value), null); } } // handle int fields... foreach (var name in settingCollection.SettingsInt.Keys) { Control control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsInt[name].CanWrite) { var value = ((TextBox)control).Text.Trim(); int i; if (value.IsNotSet()) { i = 0; } else { int.TryParse(value, out i); } settingCollection.SettingsInt[name].SetValue(this.Get <YafBoardSettings>(), i, null); } else if (control is DropDownList && settingCollection.SettingsInt[name].CanWrite) { settingCollection.SettingsInt[name].SetValue( this.Get <YafBoardSettings>(), ((DropDownList)control).SelectedItem.Value.ToType <int>(), null); } } // handle double fields... foreach (var name in settingCollection.SettingsDouble.Keys) { Control control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsDouble[name].CanWrite) { var value = ((TextBox)control).Text.Trim(); double i; if (value.IsNotSet()) { i = 0; } else { double.TryParse(value, out i); } settingCollection.SettingsDouble[name].SetValue(this.Get <YafBoardSettings>(), i, null); } else if (control is DropDownList && settingCollection.SettingsDouble[name].CanWrite) { settingCollection.SettingsDouble[name].SetValue( this.Get <YafBoardSettings>(), Convert.ToDouble(((DropDownList)control).SelectedItem.Value), null); } } // save the settings to the database ((YafLoadBoardSettings)this.Get <YafBoardSettings>()).SaveRegistry(); // reload all settings from the DB this.PageContext.BoardSettings = null; YafBuildLink.Redirect(ForumPages.admin_admin); }
/// <summary> /// Binds the data. /// </summary> private void BindData() { this.ForumEditor.DataSource = ForumEditorHelper.GetFilteredEditorList(); this.DataBind(); // load Board Setting collection information... var settingCollection = new YafBoardSettingCollection(this.Get <YafBoardSettings>()); // handle checked fields... foreach (var name in settingCollection.SettingsBool.Keys) { var control = this.HostSettingsTabs.FindControlRecursive(name); if (control is CheckBox && settingCollection.SettingsBool[name].CanRead) { // get the value from the property... ((CheckBox)control).Checked = (bool) Convert.ChangeType( settingCollection.SettingsBool[name].GetValue(this.Get <YafBoardSettings>(), null), typeof(bool)); } } // handle string fields... foreach (var name in settingCollection.SettingsString.Keys) { var control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsString[name].CanRead) { // get the value from the property... ((TextBox)control).Text = (string) Convert.ChangeType( settingCollection.SettingsString[name].GetValue(this.Get <YafBoardSettings>(), null), typeof(string)); } else if (control is DropDownList && settingCollection.SettingsString[name].CanRead) { var listItem = ((DropDownList)control).Items.FindByValue( settingCollection.SettingsString[name].GetValue(this.Get <YafBoardSettings>(), null) .ToString()); if (listItem != null) { listItem.Selected = true; } } } // handle int fields... foreach (var name in settingCollection.SettingsInt.Keys) { var control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsInt[name].CanRead) { if (!name.Equals("ServerTimeCorrection")) { ((TextBox)control).TextMode = TextBoxMode.Number; } // get the value from the property... ((TextBox)control).Text = settingCollection.SettingsInt[name].GetValue(this.Get <YafBoardSettings>(), null).ToString(); } else if (control is DropDownList && settingCollection.SettingsInt[name].CanRead) { var listItem = ((DropDownList)control).Items.FindByValue( settingCollection.SettingsInt[name].GetValue(this.Get <YafBoardSettings>(), null).ToString()); if (listItem != null) { listItem.Selected = true; } } } // handle double fields... foreach (var name in settingCollection.SettingsDouble.Keys) { var control = this.HostSettingsTabs.FindControlRecursive(name); if (control is TextBox && settingCollection.SettingsDouble[name].CanRead) { ((TextBox)control).CssClass = "Numeric"; // get the value from the property... ((TextBox)control).Text = settingCollection.SettingsDouble[name].GetValue(this.Get <YafBoardSettings>(), null).ToString(); } else if (control is DropDownList && settingCollection.SettingsDouble[name].CanRead) { var listItem = ((DropDownList)control).Items.FindByValue( settingCollection.SettingsDouble[name].GetValue(this.Get <YafBoardSettings>(), null) .ToString()); if (listItem != null) { listItem.Selected = true; } } } // special field handling... this.AvatarSize.Text = this.Get <YafBoardSettings>().AvatarSize != 0 ? this.Get <YafBoardSettings>().AvatarSize.ToString() : string.Empty; this.MaxFileSize.Text = this.Get <YafBoardSettings>().MaxFileSize != 0 ? this.Get <YafBoardSettings>().MaxFileSize.ToString() : string.Empty; this.SQLVersion.Text = this.HtmlEncode(this.Get <YafBoardSettings>().SQLVersion); this.AppCores.Text = Platform.Processors; this.AppMemory.Text = "{0} MB of {1} MB".FormatWith( Platform.AllocatedMemory.ToType <long>() / 1000000, Platform.MappedMemory.ToType <long>() / 1000000); this.AppOSName.Text = Platform.VersionString; this.AppRuntime.Text = "{0} {1}".FormatWith(Platform.RuntimeName, Platform.RuntimeString); }
/// <summary> /// Binds the data. /// </summary> private void BindData() { this.ForumEditor.DataSource = ForumEditorHelper.GetFilteredEditorList(); this.DataBind(); // load Board Setting collection information... var settingCollection = new YafBoardSettingCollection(this.Get <YafBoardSettings>()); // handle checked fields... settingCollection.SettingsBool.Keys.ForEach( name => { var control = this.HostSettingsTabs.FindControlRecursive(name); if (control is CheckBox box && settingCollection.SettingsBool[name].CanRead) { // get the value from the property... box.Checked = (bool)Convert.ChangeType( settingCollection.SettingsBool[name].GetValue(this.Get <YafBoardSettings>(), null), typeof(bool)); } }); // handle string fields... settingCollection.SettingsString.Keys.ForEach( name => { var control = this.HostSettingsTabs.FindControlRecursive(name); switch (control) { case TextBox box when settingCollection.SettingsString[name].CanRead: // get the value from the property... box.Text = (string)Convert.ChangeType( settingCollection.SettingsString[name].GetValue(this.Get <YafBoardSettings>(), null), typeof(string)); break; case DropDownList list when settingCollection.SettingsString[name].CanRead: { var listItem = list.Items.FindByValue( settingCollection.SettingsString[name].GetValue( this.Get <YafBoardSettings>(), null).ToString()); if (listItem != null) { listItem.Selected = true; } break; } } }); // handle int fields... settingCollection.SettingsInt.Keys.ForEach( name => { var control = this.HostSettingsTabs.FindControlRecursive(name); switch (control) { case TextBox box when settingCollection.SettingsInt[name].CanRead: { if (!name.Equals("ServerTimeCorrection")) { box.TextMode = TextBoxMode.Number; } // get the value from the property... box.Text = settingCollection.SettingsInt[name] .GetValue(this.Get <YafBoardSettings>(), null).ToString(); break; } case DropDownList list when settingCollection.SettingsInt[name].CanRead: { var listItem = list.Items.FindByValue( settingCollection.SettingsInt[name].GetValue(this.Get <YafBoardSettings>(), null) .ToString()); if (listItem != null) { listItem.Selected = true; } break; } } }); // handle double fields... settingCollection.SettingsDouble.Keys.ForEach( name => { var control = this.HostSettingsTabs.FindControlRecursive(name); switch (control) { case TextBox box when settingCollection.SettingsDouble[name].CanRead: box.CssClass = "form-control"; // get the value from the property... box.Text = settingCollection.SettingsDouble[name] .GetValue(this.Get <YafBoardSettings>(), null).ToString(); break; case DropDownList list when settingCollection.SettingsDouble[name].CanRead: { var listItem = list.Items.FindByValue( settingCollection.SettingsDouble[name].GetValue( this.Get <YafBoardSettings>(), null).ToString()); if (listItem != null) { listItem.Selected = true; } break; } } }); // special field handling... this.AvatarSize.Text = this.Get <YafBoardSettings>().AvatarSize != 0 ? this.Get <YafBoardSettings>().AvatarSize.ToString() : string.Empty; this.MaxFileSize.Text = this.Get <YafBoardSettings>().MaxFileSize != 0 ? this.Get <YafBoardSettings>().MaxFileSize.ToString() : string.Empty; this.SQLVersion.Text = this.HtmlEncode(this.Get <IDbFunction>().GetSQLVersion()); this.AppCores.Text = YafSystemInfo.Processors; this.AppMemory.Text = $"{YafSystemInfo.AllocatedMemory.ToType<long>() / 1000000} MB of {YafSystemInfo.MappedMemory.ToType<long>() / 1000000} MB"; this.AppOSName.Text = YafSystemInfo.VersionString; this.AppRuntime.Text = $"{YafSystemInfo.RuntimeName} {YafSystemInfo.RuntimeString}"; }
/// <summary> /// The bind data. /// </summary> private void BindData() { ForumEditor.DataSource = PageContext.EditorModuleManager.GetEditorsTable(); // TODO: vzrus: UseFullTextSearch check box is data layer specific and can be hidden by YAF.Classes.Data.DB.FullTextSupported property. DataBind(); // load Board Setting collection information... var settingCollection = new YafBoardSettingCollection(PageContext.BoardSettings); // handle checked fields... foreach (string name in settingCollection.SettingsBool.Keys) { Control control = ControlHelper.FindControlRecursive(this.HostSettingsTabs, name); if (control != null && control is CheckBox && settingCollection.SettingsBool[name].CanRead) { // get the value from the property... ((CheckBox)control).Checked = (bool)Convert.ChangeType(settingCollection.SettingsBool[name].GetValue(PageContext.BoardSettings, null), typeof(bool)); } } // handle string fields... foreach (string name in settingCollection.SettingsString.Keys) { Control control = ControlHelper.FindControlRecursive(this.HostSettingsTabs, name); if (control != null && control is TextBox && settingCollection.SettingsString[name].CanRead) { // get the value from the property... ((TextBox)control).Text = (string)Convert.ChangeType(settingCollection.SettingsString[name].GetValue(PageContext.BoardSettings, null), typeof(string)); } else if (control != null && control is DropDownList && settingCollection.SettingsString[name].CanRead) { ListItem listItem = ((DropDownList)control).Items.FindByValue(settingCollection.SettingsString[name].GetValue(PageContext.BoardSettings, null).ToString()); if (listItem != null) { listItem.Selected = true; } } } // handle int fields... foreach (string name in settingCollection.SettingsInt.Keys) { Control control = ControlHelper.FindControlRecursive(this.HostSettingsTabs, name); if (control != null && control is TextBox && settingCollection.SettingsInt[name].CanRead) { // get the value from the property... ((TextBox)control).Text = settingCollection.SettingsInt[name].GetValue(PageContext.BoardSettings, null).ToString(); } else if (control != null && control is DropDownList && settingCollection.SettingsInt[name].CanRead) { ListItem listItem = ((DropDownList)control).Items.FindByValue(settingCollection.SettingsInt[name].GetValue(PageContext.BoardSettings, null).ToString()); if (listItem != null) { listItem.Selected = true; } } } // handle double fields... foreach (string name in settingCollection.SettingsDouble.Keys) { Control control = ControlHelper.FindControlRecursive(this.HostSettingsTabs, name); if (control != null && control is TextBox && settingCollection.SettingsDouble[name].CanRead) { // get the value from the property... ((TextBox)control).Text = settingCollection.SettingsDouble[name].GetValue(PageContext.BoardSettings, null).ToString(); } else if (control != null && control is DropDownList && settingCollection.SettingsDouble[name].CanRead) { ListItem listItem = ((DropDownList)control).Items.FindByValue(settingCollection.SettingsDouble[name].GetValue(PageContext.BoardSettings, null).ToString()); if (listItem != null) { listItem.Selected = true; } } } // special field handling... AvatarSize.Text = (PageContext.BoardSettings.AvatarSize != 0) ? PageContext.BoardSettings.AvatarSize.ToString() : string.Empty; MaxFileSize.Text = (PageContext.BoardSettings.MaxFileSize != 0) ? PageContext.BoardSettings.MaxFileSize.ToString() : string.Empty; SQLVersion.Text = HtmlEncode(PageContext.BoardSettings.SQLVersion); }