Esempio n. 1
0
        public static string GetPermissionString(ICmsMenu menu)
        {
            if (menu == null)
            {
                return(null);
            }
            if (menu is ISideBarMenu)
            {
                var sidebarmenu = menu as ISideBarMenu;
                if (sidebarmenu.Parent == SideBarSection.Root)
                {
                    return(sidebarmenu.Name);
                }
                else
                {
                    return(sidebarmenu.Parent.ToString() + "/" + sidebarmenu.Name);
                }
            }

            else if (menu is IFeatureMenu)
            {
                return("feature/" + menu.Name);
            }

            return(null);
        }
Esempio n. 2
0
        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;
                }
            }
        }
Esempio n. 3
0
        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);
                    }
                }
            }
        }
Esempio n. 4
0
        internal static MenuItem ConvertToOld(ICmsMenu menu, RenderContext Context)
        {
            Guid siteid = default(Guid);

            if (Context.WebSite != null)
            {
                siteid = Context.WebSite.Id;
            }

            if (menu != null && menu.CanShow(Context))
            {
                MenuItem result = new MenuItem();
                result.Icon        = menu.Icon;
                result.Name        = menu.Name;
                result.DisplayName = menu.GetDisplayName(Context);
                result.Icon        = menu.Icon;
                if (siteid == default(Guid))
                {
                    result.Url = menu.Url;
                }
                else
                {
                    Dictionary <string, string> para = new Dictionary <string, string>();
                    para.Add("SiteId", siteid.ToString());
                    result.Url = Kooboo.Lib.Helper.UrlHelper.AppendQueryString(menu.Url, para);
                }

                if (menu.Items != null && menu.Items.Any())
                {
                    foreach (var item in menu.Items)
                    {
                        var menuitem = ConvertToOld(item, Context);
                        if (menuitem != null)
                        {
                            result.Items.Add(menuitem);
                        }
                    }
                }
                return(result);
            }

            return(null);
        }