public NavigationItemCollection GetChildItems(int id) { NavigationItemCollection items = new NavigationItemCollection(); foreach (NavigationItem item in Navigations) { if (item.ParentID == id) items.Add(item); } return items; }
public TopLinkSettings2() { Navigations = new NavigationItemCollection(); MaxID = 0; MaxID++; NavigationItem item = new NavigationItem(); item.ID = MaxID; item.Name = "首页"; item.UrlInfo = "index"; item.NewWindow = false; item.OnlyLoginCanSee = false; item.SortOrder = MaxID; item.Type = MaxLabs.bbsMax.Enums.NavigationType.Internal; item.IsTopLink = true; Navigations.Add(item); }
public NavigationSettings() { Navigations = new NavigationItemCollection(); MaxID = 0; //foreach (KeyValuePair<string, string> pair in NavigationSettings.InternalLinks()) //{ // if (pair.Key == "index") // { MaxID++; NavigationItem item = new NavigationItem(); item.ID = MaxID; item.Name = "首页"; item.UrlInfo = "index"; item.NewWindow = false; item.OnlyLoginCanSee = false; item.SortOrder = MaxID; item.Type = MaxLabs.bbsMax.Enums.NavigationType.Internal; Navigations.Add(item); // } //} }
public void ClearCache() { m_ParentItems = null; m_HashNavigations = null; m_GuestItemsCount = null; m_GuestParentItems = null; m_ItemsCount = null; foreach (NavigationItem item in Navigations) { item.ClearCache(); } }
private void Save() { MessageDisplay msgDisplay = CreateMessageDisplay("name", "url"); int parentid = _Request.Get <int>("parent", Method.Post, 0); int[] newids = _Request.GetList <int>("newid", Method.Post, new int[] { }); int maxID; if (IsTopLink) { maxID = AllSettings.Current.TopLinkSettings2.MaxID; } else { maxID = AllSettings.Current.NavigationSettings.MaxID; } NavigationItemCollection items = new NavigationItemCollection(); int i = 0; int[] oldids = _Request.GetList <int>("old_id", Method.Post, new int[] { }); foreach (int id in oldids) { NavigationItem item = new NavigationItem(); item.ParentID = parentid; item.SortOrder = _Request.Get <int>("old_sortorder_" + id, Method.Post, 0); item.Type = (NavigationType)_Request.Get <int>("old_type_" + id, Method.Post, 0); item.Name = _Request.Get("old_name_" + id, Method.Post, ""); if (item.Type == NavigationType.Custom) { item.UrlInfo = _Request.Get("old_url_" + id, Method.Post, ""); } else { item.UrlInfo = _Request.Get("old_urlinfo_" + id, Method.Post, ""); } item.NewWindow = _Request.IsChecked("old_newwindow_" + id, Method.Post, false); item.OnlyLoginCanSee = _Request.IsChecked("old_logincansee_" + id, Method.Post, false); TempNavigations.Add(item); i++; if (string.IsNullOrEmpty(item.Name) && string.IsNullOrEmpty(item.UrlInfo)) { continue; } else { if (string.IsNullOrEmpty(item.Name)) { msgDisplay.AddError("name", i - 1, "名称不能为空"); } if (string.IsNullOrEmpty(item.UrlInfo)) { msgDisplay.AddError("url", i - 1, "地址不能为空"); } } maxID++; item.ID = maxID; item.IsTopLink = IsTopLink; items.Add(item); } foreach (int newid in newids) { NavigationItem item = new NavigationItem(); item.ParentID = parentid; item.SortOrder = _Request.Get <int>("sortorder_" + newid, Method.Post, 0); item.Type = (NavigationType)_Request.Get <int>("type_" + newid, Method.Post, 0); item.Name = _Request.Get("name_" + newid, Method.Post, ""); if (item.Type == NavigationType.Custom) { item.UrlInfo = _Request.Get("url_" + newid, Method.Post, ""); } else { item.UrlInfo = _Request.Get("urlinfo_" + newid, Method.Post, ""); } item.NewWindow = _Request.IsChecked("newwindow_" + newid, Method.Post, false); item.OnlyLoginCanSee = _Request.IsChecked("logincansee_" + newid, Method.Post, false); TempNavigations.Add(item); i++; if (string.IsNullOrEmpty(item.Name) && string.IsNullOrEmpty(item.UrlInfo)) { continue; } else { if (string.IsNullOrEmpty(item.Name)) { msgDisplay.AddError("name", i - 1, "名称不能为空"); } if (string.IsNullOrEmpty(item.UrlInfo)) { msgDisplay.AddError("url", i - 1, "地址不能为空"); } } maxID++; item.ID = maxID; item.IsTopLink = IsTopLink; items.Add(item); } if (msgDisplay.HasAnyError()) { return; } NavigationSettingsBase settings; if (IsTopLink) { settings = SettingManager.CloneSetttings <TopLinkSettings2>(AllSettings.Current.TopLinkSettings2); } else { settings = SettingManager.CloneSetttings <NavigationSettings>(AllSettings.Current.NavigationSettings); } settings.MaxID = maxID; settings.Navigations.AddRange(items); try { SettingManager.SaveSettings(settings); if (IsTopLink) { AllSettings.Current.TopLinkSettings2.ClearCache(); } else { AllSettings.Current.NavigationSettings.ClearCache(); } Return(true); } catch (Exception ex) { msgDisplay.AddError(ex.Message); } }
private void Save() { MessageDisplay msgDisplay = CreateMessageDisplay("name", "url"); int parentid = _Request.Get<int>("parent", Method.Post, 0); int[] newids = _Request.GetList<int>("newid", Method.Post, new int[] { }); int maxID; if (IsTopLink) maxID = AllSettings.Current.TopLinkSettings2.MaxID; else maxID = AllSettings.Current.NavigationSettings.MaxID; NavigationItemCollection items = new NavigationItemCollection(); int i = 0; int[] oldids = _Request.GetList<int>("old_id", Method.Post, new int[] { }); foreach (int id in oldids) { NavigationItem item = new NavigationItem(); item.ParentID = parentid; item.SortOrder = _Request.Get<int>("old_sortorder_" + id, Method.Post, 0); item.Type = (NavigationType)_Request.Get<int>("old_type_" + id, Method.Post, 0); item.Name = _Request.Get("old_name_" + id, Method.Post, ""); if (item.Type == NavigationType.Custom) item.UrlInfo = _Request.Get("old_url_" + id, Method.Post, ""); else item.UrlInfo = _Request.Get("old_urlinfo_" + id, Method.Post, ""); item.NewWindow = _Request.IsChecked("old_newwindow_" + id, Method.Post, false); item.OnlyLoginCanSee = _Request.IsChecked("old_logincansee_" + id, Method.Post, false); TempNavigations.Add(item); i++; if (string.IsNullOrEmpty(item.Name) && string.IsNullOrEmpty(item.UrlInfo)) { continue; } else { if (string.IsNullOrEmpty(item.Name)) msgDisplay.AddError("name", i-1, "名称不能为空"); if (string.IsNullOrEmpty(item.UrlInfo)) msgDisplay.AddError("url", i-1, "地址不能为空"); } maxID++; item.ID = maxID; item.IsTopLink = IsTopLink; items.Add(item); } foreach (int newid in newids) { NavigationItem item = new NavigationItem(); item.ParentID = parentid; item.SortOrder = _Request.Get<int>("sortorder_" + newid, Method.Post, 0); item.Type = (NavigationType)_Request.Get<int>("type_" + newid, Method.Post, 0); item.Name = _Request.Get("name_" + newid, Method.Post, ""); if (item.Type == NavigationType.Custom) item.UrlInfo = _Request.Get("url_" + newid, Method.Post, ""); else item.UrlInfo = _Request.Get("urlinfo_" + newid, Method.Post, ""); item.NewWindow = _Request.IsChecked("newwindow_" + newid, Method.Post, false); item.OnlyLoginCanSee = _Request.IsChecked("logincansee_" + newid, Method.Post, false); TempNavigations.Add(item); i++; if (string.IsNullOrEmpty(item.Name) && string.IsNullOrEmpty(item.UrlInfo)) { continue; } else { if (string.IsNullOrEmpty(item.Name)) msgDisplay.AddError("name", i-1, "名称不能为空"); if (string.IsNullOrEmpty(item.UrlInfo)) msgDisplay.AddError("url", i-1, "地址不能为空"); } maxID++; item.ID = maxID; item.IsTopLink = IsTopLink; items.Add(item); } if (msgDisplay.HasAnyError()) return; NavigationSettingsBase settings; if (IsTopLink) settings = SettingManager.CloneSetttings<TopLinkSettings2>(AllSettings.Current.TopLinkSettings2); else settings = SettingManager.CloneSetttings<NavigationSettings>(AllSettings.Current.NavigationSettings); settings.MaxID = maxID; settings.Navigations.AddRange(items); try { SettingManager.SaveSettings(settings); if (IsTopLink) AllSettings.Current.TopLinkSettings2.ClearCache(); else AllSettings.Current.NavigationSettings.ClearCache(); Return(true); } catch (Exception ex) { msgDisplay.AddError(ex.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="NavigationItem"/> class. /// </summary> public NavigationItem() { this.items = new NavigationItemCollection(this); }
private void Save() { MessageDisplay msgDisplay = CreateMessageDisplay(); int[] ids = _Request.GetList<int>("id", Method.Post, new int[] { }); NavigationSettingsBase settings; if(IsTopLink) settings = SettingManager.CloneSetttings<TopLinkSettings2>(AllSettings.Current.TopLinkSettings2); else settings = SettingManager.CloneSetttings<NavigationSettings>(AllSettings.Current.NavigationSettings); NavigationItemCollection items = new NavigationItemCollection(); int i = 0; foreach (int id in ids) { NavigationItem item = settings.Navigations.GetValue(id); if (item != null) { item.SortOrder = _Request.Get<int>("parent_sortorder_" + id, Method.Post, 0); item.Name = _Request.Get("parent_name_" + id); if (item.Type == NavigationType.Custom) { item.UrlInfo = _Request.Get("parent_url_" + id, Method.Post, string.Empty); } item.NewWindow = _Request.IsChecked("parent_newwindow_" + id, Method.Post, false); item.OnlyLoginCanSee = _Request.IsChecked("parent_logincansee_" + id, Method.Post, false); if (string.IsNullOrEmpty(item.Name)) { msgDisplay.AddError("", i, "名称不能为空"); } if(string.IsNullOrEmpty(item.UrlInfo)) { msgDisplay.AddError("", i, "链接地址不能为空"); } item.IsTopLink = IsTopLink; i++; items.Add(item); } } if(msgDisplay.HasAnyError()) return; settings.Navigations = items; try { SettingManager.SaveSettings(settings); if (IsTopLink) AllSettings.Current.TopLinkSettings2.ClearCache(); else AllSettings.Current.NavigationSettings.ClearCache(); } catch(Exception ex) { msgDisplay.AddError(ex.Message); } }
private void Save() { MessageDisplay msgDisplay = CreateMessageDisplay(); int[] ids = _Request.GetList <int>("id", Method.Post, new int[] { }); NavigationSettingsBase settings; if (IsTopLink) { settings = SettingManager.CloneSetttings <TopLinkSettings2>(AllSettings.Current.TopLinkSettings2); } else { settings = SettingManager.CloneSetttings <NavigationSettings>(AllSettings.Current.NavigationSettings); } NavigationItemCollection items = new NavigationItemCollection(); int i = 0; foreach (int id in ids) { NavigationItem item = settings.Navigations.GetValue(id); if (item != null) { item.SortOrder = _Request.Get <int>("parent_sortorder_" + id, Method.Post, 0); item.Name = _Request.Get("parent_name_" + id); if (item.Type == NavigationType.Custom) { item.UrlInfo = _Request.Get("parent_url_" + id, Method.Post, string.Empty); } item.NewWindow = _Request.IsChecked("parent_newwindow_" + id, Method.Post, false); item.OnlyLoginCanSee = _Request.IsChecked("parent_logincansee_" + id, Method.Post, false); if (string.IsNullOrEmpty(item.Name)) { msgDisplay.AddError("", i, "名称不能为空"); } if (string.IsNullOrEmpty(item.UrlInfo)) { msgDisplay.AddError("", i, "链接地址不能为空"); } item.IsTopLink = IsTopLink; i++; items.Add(item); } } if (msgDisplay.HasAnyError()) { return; } settings.Navigations = items; try { SettingManager.SaveSettings(settings); if (IsTopLink) { AllSettings.Current.TopLinkSettings2.ClearCache(); } else { AllSettings.Current.NavigationSettings.ClearCache(); } } catch (Exception ex) { msgDisplay.AddError(ex.Message); } }