Beispiel #1
0
        public virtual String Render(List <CommunityRoleModulePermission> permissions, int IdLanguage, String Baseurl)
        {
            Boolean available = IsValid(permissions);

            if (available || ShowDisabledItems)
            {
                String renderMenuItem = "<li {0}>{1}{2}</li>\n\r";
                String renderSubItems = "";

                switch (Type)
                {
                case MenuItemType.IconManage:
                case MenuItemType.IconNewItem:
                case MenuItemType.IconStatistic:
                    return(RenderIcon(available, IdLanguage, Baseurl));

                case MenuItemType.Link:
                case MenuItemType.Text:

                    // if children>0 are only ICONS !!
                    foreach (_MenuItem item in Childrens.Where(m => m.Deleted == BaseStatusDeleted.None && m.IsEnabled).OrderByDescending(m => m.DisplayOrder))
                    {
                        renderSubItems += item.Render(permissions, IdLanguage, Baseurl);
                    }
                    if (renderSubItems == "" && Type == MenuItemType.Text)
                    {
                        return("");
                    }
                    else
                    {
                        return(String.Format(renderMenuItem, String.IsNullOrEmpty(CssClass) ? "" : " class=\"" + CssClass + "\"", RenderItem(available, IdLanguage, Baseurl),
                                             String.IsNullOrEmpty(renderSubItems) ? "" : " <span class=\"actions\">" + renderSubItems + "</span>"));
                    }

                case MenuItemType.Separator:
                    return(String.Format(renderMenuItem, String.IsNullOrEmpty(CssClass) ? "" : " class=\"" + CssClass + "\"", "<h2 class=\"separator\"> &nbsp; </h2>", ""));

                case MenuItemType.LinkContainer:
                case MenuItemType.TextContainer:

                    foreach (_MenuItem item in Childrens.Where(m => m.Deleted == BaseStatusDeleted.None && m.IsEnabled).OrderBy(m => m.DisplayOrder))
                    {
                        renderSubItems += item.Render(permissions, IdLanguage, Baseurl);
                    }
                    if (renderSubItems == "" && Type == MenuItemType.TextContainer)
                    {
                        return("");
                    }
                    else
                    {
                        return(String.Format(renderMenuItem, String.IsNullOrEmpty(CssClass) ? "" : " class=\"" + CssClass + "\"", RenderContainerItem(available, IdLanguage, Baseurl),
                                             String.IsNullOrEmpty(renderSubItems) ? "" : " <ul>" + renderSubItems + "</ul>"));
                    }

                default:
                    break;
                }
            }
            return("");
        }
Beispiel #2
0
        protected internal virtual dtoTree ToTree()
        {
            dtoTree tree = new dtoTree()
            {
                Id = Id, Type = Type, Deleted = Deleted, Name = Name, Items = new List <dtoTree>()
            };

            foreach (_MenuItem item in Childrens.Where(i => i.Deleted == BaseStatusDeleted.None).OrderBy(i => i.DisplayOrder))
            {
                tree.Items.Add(item.ToTree());
            }
            return(tree);
        }