/// <summary>
        /// 绑定左菜单
        /// </summary>
        public void BindLeftMenu()
        {
            if (InitMenuTabCollection != null && InitMenuTabCollection.Count > 0)
            {
                List <MenuTabItem> TokenItems = InitMenuTabCollection.ToList();

                System.Text.StringBuilder sb = new System.Text.StringBuilder();



                for (int i = 0; i < TokenItems.Count; i++)
                {
                    if (String.IsNullOrEmpty(TokenItems[i].Parent) && TokenItems[i].Visible)
                    {
                        MenuTabItem item = TokenItems[i];

                        if (!item.IsAdministrator || IsAdministrator || (IsAdmin && AdvancedPermissions))
                        {
                            String ChildHtml = String.Empty;
                            bool   is_active = false;
                            bool   is_Child  = false;

                            List <MenuTabItem> ChildList = InitMenuTabCollection.FindByParent(TokenItems[i].Token);
                            if (ChildList.Count > 0)
                            {
                                ChildHtml = BindLeftMenuBySubmenu(ChildList, out is_active);
                                is_Child  = true;
                            }

                            if (item.Token.ToLower() == Token.ToLower())
                            {
                                is_active = true;
                            }

                            String active_class = is_active ? "active open" : "";
                            String item_url     = (ChildList != null && ChildList.Count > 0) || String.IsNullOrEmpty(item.Src) ? "javascript:;" : String.Format("{0}Index_Manager.aspx?PortalId={1}&TabId={2}&ModuleId={3}&Token={4}&language={5}{6}", ModulePath, PortalId, TabId, ModuleId, item.Token, language, ConvertParameter(item.Parameter));;
                            String item_icon    = string.IsNullOrEmpty(item.Icon) ? "" : String.Format("<i class=\"{0}\"></i>", item.Icon);

                            sb.AppendFormat("<li class=\"{0}\">", active_class).AppendLine();

                            sb.AppendFormat("<a href=\"{0}\">{1} <span class=\"{2}\"> {2} </span> <span class=\"selected\"></span>", item_url, item_icon, ViewMenuText(item));
                            if (is_Child)
                            {
                                sb.Append("<i class=\"icon-arrow\"></i> ");
                            }

                            sb.Append("</a>").AppendLine();
                            sb.Append(ChildHtml).AppendLine();

                            sb.Append("</li>").AppendLine();
                        }
                    }
                }
                liLeftMenu.Text = sb.ToString();
            }
        }
        /// <summary>
        /// 绑定控件到容器
        /// </summary>
        public void BindContainer()
        {
            MenuTabItem _MenuTabItem = InitMenuTabCollection.ContainsKey(Token) ? InitMenuTabCollection[Token] : new MenuTabItem();

            if (_MenuTabItem != null && !String.IsNullOrEmpty(_MenuTabItem.Token) && !this.DesignMode)
            {
                //判断是否为管理员菜单,当前用户是否为管理员
                if (!(!_MenuTabItem.IsAdministrator || IsAdministrator || (IsAdmin && AdvancedPermissions)))
                {
                    phContainer.Visible = false;
                    mTips.MsgType       = EnumTips.Warning;
                    mTips.Content       = ViewResourceText("HasModuleAccess", "You are not permitted to access this page! :(");
                    mTips.Put();
                }
                else
                {
                    //加载相应的控件
                    BaseModule ManageContent = new BaseModule();
                    string     ContentSrc    = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, _MenuTabItem.Src));

                    if (System.IO.File.Exists(MapPath(ContentSrc)))
                    {
                        ManageContent = (BaseModule)LoadControl(ContentSrc);
                        ManageContent.ModuleConfiguration = ModuleConfiguration;
                        ManageContent.ID = _MenuTabItem.Token;
                        ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", _MenuTabItem.Src));
                        phContainer.Controls.Add(ManageContent);
                    }
                }

                //标题
                Page.Title = String.Format("{0} - {1} - {2}", ViewMenuText(_MenuTabItem), ModuleConfiguration.ModuleTitle, PortalSettings.ActiveTab.LocalizedTabName);
            }
            else if (!String.IsNullOrEmpty(Token) && Token.ToLower() == "error")
            {
                //加载相应的控件
                BaseModule ManageContent = new BaseModule();
                string     ContentSrc    = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, "Manager_ErrorCatch.ascx"));

                if (System.IO.File.Exists(MapPath(ContentSrc)))
                {
                    ManageContent = (BaseModule)LoadControl(ContentSrc);
                    ManageContent.ModuleConfiguration = ModuleConfiguration;
                    ManageContent.ID = "ErrorCatch";
                    ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", "Manager_ErrorCatch.ascx"));
                    phContainer.Controls.Add(ManageContent);
                }
                //标题
                Page.Title = String.Format("{0} - {1}", "Error", ModuleConfiguration.ModuleTitle);
            }

            //首页地址
            hlHome.NavigateUrl = Globals.NavigateURL(TabId);
        }
        /// <summary>
        /// 绑定列表数据到容器
        /// </summary>
        private void BindContainer()
        {
            MenuTabItem _MenuTabItem = MenuTabCollection.Exists(r => r.Token.ToLower() == UIToken.ToLower()) ? MenuTabCollection.Find(r => r.Token.ToLower() == UIToken.ToLower()) : new MenuTabItem();

            if (_MenuTabItem != null && !String.IsNullOrEmpty(_MenuTabItem.Token) && !this.DesignMode)
            {
                //加载相应的控件
                BaseModule ManageContent = new BaseModule();
                string     ContentSrc    = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, _MenuTabItem.Src));

                if (System.IO.File.Exists(MapPath(ContentSrc)))
                {
                    ManageContent = (BaseModule)LoadControl(ContentSrc);
                    ManageContent.ModuleConfiguration = ModuleConfiguration;
                    ManageContent.ID = _MenuTabItem.Token;
                    ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", _MenuTabItem.Src));
                    phContainer.Controls.Add(ManageContent);
                }
            }
            else if (!String.IsNullOrEmpty(Token) && Token.ToLower() == "error")
            {
                //加载相应的控件
                BaseModule ManageContent = new BaseModule();
                string     ContentSrc    = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, "Manager_ErrorCatch.ascx"));

                if (System.IO.File.Exists(MapPath(ContentSrc)))
                {
                    ManageContent = (BaseModule)LoadControl(ContentSrc);
                    ManageContent.ModuleConfiguration = ModuleConfiguration;
                    ManageContent.ID = "ErrorCatch";
                    ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", "Manager_ErrorCatch.ascx"));
                    phContainer.Controls.Add(ManageContent);
                }
                //标题
                Page.Title = String.Format("{0} - {1}", "Error", ModuleConfiguration.ModuleTitle);
            }
        }
        public String ViewMenuText(MenuTabItem item)
        {
            String ResourceName = String.Format("Menu_{0}", item.Token);

            return(ViewResourceText(ResourceName, item.Title));
        }
Exemple #5
0
 /// <summary>
 /// 插入MenuTab项
 /// </summary>
 /// <param name="__MenuTabItem">MenuTab项</param>
 /// <returns>插入后的数量</returns>
 public Int32 Add(MenuTabItem __MenuTabItem)
 {
     _MenuTabItem.Add(__MenuTabItem.Token.ToLower(), __MenuTabItem);
     return(_MenuTabItem.Count);
 }