protected void Page_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Title", typeof(string))); dt.Columns.Add(new DataColumn("ImageUrl", typeof(string))); DataRow dr; IXPathNavigable navigable; // Selector: ClassName.ViewName.PlaceName.ProfileId.UserId Selector selector = new Selector(string.Empty, string.Empty, string.Empty, ProfileManager.GetProfileIdByUser().ToString(), Mediachase.IBN.Business.Security.UserID.ToString()); // don't hide items for administrator if (Mediachase.IBN.Business.Security.IsUserInGroup(Mediachase.IBN.Business.InternalSecureGroups.Administrator)) { navigable = XmlBuilder.GetCustomizationXml(null, StructureType.Navigation, selector); } else { navigable = XmlBuilder.GetXml(StructureType.Navigation, selector); } XPathNavigator tabs = navigable.CreateNavigator().SelectSingleNode("Navigation/Tabs"); foreach (XPathNavigator tabItem in tabs.SelectChildren(string.Empty, string.Empty)) { dr = dt.NewRow(); string title = UtilHelper.GetResFileString(tabItem.GetAttribute("text", string.Empty)); string id = tabItem.GetAttribute("id", string.Empty); string enableHandler = tabItem.GetAttribute("enableHandler", string.Empty); if (!string.IsNullOrEmpty(enableHandler)) { ICommandEnableHandler enHandler = (ICommandEnableHandler)AssemblyUtil.LoadObject(enableHandler); if (enHandler != null && !enHandler.IsEnable(sender, id)) { continue; } } string imageUrl = tabItem.GetAttribute("imageUrl", string.Empty); if (string.IsNullOrEmpty(imageUrl)) { imageUrl = "~/Images/ext/default/s.gif"; } string type = tabItem.GetAttribute("contentType", string.Empty).ToLower(); if (string.IsNullOrEmpty(type)) { type = "default"; } string configUrl = tabItem.GetAttribute("configUrl", string.Empty); string checkUrl = configUrl; if (checkUrl.IndexOf("?") >= 0) { checkUrl = checkUrl.Substring(0, checkUrl.IndexOf("?")); } if (type.Equals("default") && string.IsNullOrEmpty(checkUrl)) { checkUrl = "~/Apps/Shell/Pages/TreeSource.aspx"; configUrl = "~/Apps/Shell/Pages/TreeSource.aspx?tab=" + id; } if (File.Exists(Server.MapPath(checkUrl))) { switch (type) { case "default": ClientScript.RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString("N"), string.Format("leftTemplate_AddMenuTab('{0}', '{1}', '{2}');", id, title, ResolveClientUrl(configUrl)), true); break; case "custom": break; default: break; } } dr["Title"] = title; dr["ImageUrl"] = imageUrl; dt.Rows.Add(dr); } TabItems.DataSource = dt.DefaultView; TabItems.DataBind(); RegisterScripts(); //Register navigation commands string profileId = ProfileManager.GetProfileIdByUser().ToString(); string userId = Mediachase.IBN.Business.Security.UserID.ToString(); IList <XmlCommand> list = XmlCommand.GetListNavigationCommands("", "", "", profileId, userId); CommandManager cm = CommandManager.GetCurrent(this.Page); foreach (XmlCommand cmd in list) { cm.AddCommand("", "", "", profileId, userId, cmd.CommandName); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Title", typeof(string))); dt.Columns.Add(new DataColumn("ImageUrl", typeof(string))); DataRow dr; IXPathNavigable navigable = XmlBuilder.GetXml(StructureType.Navigation); XPathNavigator tabs = navigable.CreateNavigator().SelectSingleNode("Navigation/Tabs"); foreach (XPathNavigator tabItem in tabs.SelectChildren(string.Empty, string.Empty)) { dr = dt.NewRow(); string title = UtilHelper.GetResFileString(tabItem.GetAttribute("text", string.Empty)); string id = tabItem.GetAttribute("id", string.Empty); CommandParameters param = new CommandParameters(id); param.CommandArguments = new Dictionary <string, string>(); param.CommandArguments.Add("permissions", tabItem.GetAttribute("permissions", string.Empty)); string enableHandler = String.Empty; if (!ProfileConfiguration.Instance.EnablePermissions) { enableHandler = tabItem.GetAttribute("enableHandler", string.Empty); } else { enableHandler = tabItem.GetAttribute("enableHandler2", string.Empty); } if (!String.IsNullOrEmpty(enableHandler)) { ICommandEnableHandler enHandler = (ICommandEnableHandler)AssemblyUtil.LoadObject(enableHandler); if (enHandler != null && !enHandler.IsEnable(sender, param)) { continue; } } string imageUrl = tabItem.GetAttribute("imageUrl", string.Empty); if (String.IsNullOrEmpty(imageUrl)) { imageUrl = "~/App_Themes/Default/Images/ext/default/s.gif"; } string type = tabItem.GetAttribute("contentType", string.Empty).ToLower(); if (String.IsNullOrEmpty(type)) { type = "default"; } string configUrl = tabItem.GetAttribute("configUrl", string.Empty); string checkUrl = configUrl; if (checkUrl.IndexOf("?") >= 0) { checkUrl = checkUrl.Substring(0, checkUrl.IndexOf("?")); } if (type.Equals("default") && String.IsNullOrEmpty(checkUrl)) { checkUrl = "~/Apps/Shell/Pages/TreeSource.aspx"; configUrl = "~/Apps/Shell/Pages/TreeSource.aspx?tab=" + id; } if (File.Exists(Server.MapPath(checkUrl))) { switch (type) { case "default": ClientScript.RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("leftTemplate_ECFAddMenuTab('{0}', '{1}', '{2}');", id, title, ResolveClientUrl(configUrl)), true); break; case "custom": break; default: break; } } dr["Title"] = title; dr["ImageUrl"] = imageUrl; dt.Rows.Add(dr); } TabItems.DataSource = dt.DefaultView; TabItems.DataBind(); RegisterScripts(); //Register navigation commands IList <XmlCommand> list = XmlCommand.GetListNavigationCommands("", "", ""); CommandManager cm = CommandManager.GetCurrent(this.Page); foreach (XmlCommand cmd in list) { cm.AddCommand("", "", "", cmd.CommandName); } }