public CmsMenuViewModel(ICmsMenu menu, RenderContext context) { if (menu != null) { this.Name = menu.Name; this.Icon = menu.Icon; this.Url = menu.Url; this.DisplayName = menu.GetDisplayName(context); if (menu.Items != null) { foreach (var item in menu.Items) { CmsMenuViewModel itemmodel = new CmsMenuViewModel(item, context); this.Items.Add(itemmodel); } } if (menu is ITopMenu) { var topmenu = menu as ITopMenu; this.BadgeIcon = topmenu.BadgeIcon; this.Name = this.DisplayName; } } }
public CmsMenuViewModel(ICmsMenu menu, RenderContext context) { this.CmsMenu = menu; if (menu != null) { this.Order = menu.Order; this.Name = menu.Name; this.Icon = menu.Icon; this.Url = menu.Url; this.DisplayName = menu.GetDisplayName(context); Guid WebSiteId = default(Guid); if (menu is IHeaderMenu) { var topmenu = menu as IHeaderMenu; this.BadgeIcon = topmenu.BadgeIcon; this.Name = this.DisplayName; } else { if (context.WebSite != null) { WebSiteId = context.WebSite.Id; } } this.Url = appendSiteId(this.Url, WebSiteId); List <ICmsMenu> subitems = null; if (menu is IDynamicMenu) { var dynamic = menu as IDynamicMenu; if (!dynamic.Show(context)) { this.Hide = true; } else { subitems = dynamic.ShowSubItems(context); } } else { subitems = menu.SubItems; } if (subitems != null && subitems.Any()) { foreach (var item in subitems) { var model = new CmsMenuViewModel(item, context); this.Items.Add(model); } } } }
public static string GetPermissionString(CmsMenuViewModel menu) { if (menu == null) { return(null); } if (menu.CmsMenu != null) { return(Kooboo.Sites.Authorization.MenuService.GetPermissionString(menu.CmsMenu)); } else { return(menu.Name); } }