protected void Page_Load(object sender, EventArgs e) { CurrentUserInfo currentUser = CMSContext.CurrentUser; // Fill the menu with UIElement data for specified module if (!String.IsNullOrEmpty(this.ModuleName) & (currentUser != null)) { DataSet dsModules = UIElementInfoProvider.GetUIMenuElements(ModuleName); List<object[]> categoriesTmp = new List<object[]>(); if (!DataHelper.DataSourceIsEmpty(dsModules)) { foreach (DataRow drModule in dsModules.Tables[0].Rows) { UIElementInfo moduleElement = new UIElementInfo(drModule); // Proceed if user has permissions for this UI element if (currentUser.IsAuthorizedPerUIElement(this.ModuleName, moduleElement.ElementName)) { // Category title string categoryTitle = ResHelper.LocalizeString(moduleElement.ElementDisplayName); // Category name string categoryName = ResHelper.LocalizeString(moduleElement.ElementName); // Category URL string categoryUrl = CMSContext.ResolveMacros(URLHelper.EnsureHashToQueryParameters(moduleElement.ElementTargetURL)); // Category image URL string categoryImageUrl = this.GetImagePath(moduleElement.ElementIconPath.Replace("list.png", "module.png")); if (!FileHelper.FileExists(categoryImageUrl)) { categoryImageUrl = this.GetImagePath("CMSModules/module.png"); } // Category tooltip string categoryTooltip = ResHelper.LocalizeString(moduleElement.ElementDescription); // Category actions DataSet dsActions = UIElementInfoProvider.GetChildUIElements(moduleElement.ElementID); List<string[]> actionsTmp = new List<string[]>(); foreach (DataRow drAction in dsActions.Tables[0].Rows) { UIElementInfo actionElement = new UIElementInfo(drAction); // Proceed if user has permissions for this UI element if (currentUser.IsAuthorizedPerUIElement(this.ModuleName, actionElement.ElementName)) { actionsTmp.Add(new string[] { ResHelper.LocalizeString(actionElement.ElementDisplayName), CMSContext.ResolveMacros(URLHelper.EnsureHashToQueryParameters(actionElement.ElementTargetURL)) }); } } int actionsCount = actionsTmp.Count; string[,] categoryActions = new string[actionsCount, 2]; for (int i = 0; i < actionsCount; i++) { categoryActions[i, 0] = actionsTmp[i][0]; categoryActions[i, 1] = actionsTmp[i][1]; } CategoryCreatedEventArgs args = new CategoryCreatedEventArgs(moduleElement, categoryName, categoryTitle, categoryUrl, categoryImageUrl, categoryTooltip, categoryActions); // Raise additional initialization events for this category if (this.CategoryCreated != null) { this.CategoryCreated(this, args); } // Add to categories, if further processing of this category was not cancelled if (!args.Cancel) { categoriesTmp.Add(new object[] { args.CategoryTitle, args.CategoryName, args.CategoryURL, args.CategoryImageURL, args.CategoryTooltip, args.CategoryActions }); } } } } int categoriesCount = categoriesTmp.Count; object[,] categories = new object[categoriesCount, 6]; for (int i = 0; i < categoriesCount; i++) { categories[i, 0] = categoriesTmp[i][0]; categories[i, 1] = categoriesTmp[i][1]; categories[i, 2] = categoriesTmp[i][2]; categories[i, 3] = categoriesTmp[i][3]; categories[i, 4] = categoriesTmp[i][4]; categories[i, 5] = categoriesTmp[i][5]; } if (categoriesCount > 0) { this.panelMenu.Categories = categories; this.panelMenu.ColumnsCount = this.ColumnsCount; } else { RedirectToUINotAvailable(); } // Add editing icon in development mode if (SettingsKeyProvider.DevelopmentMode && currentUser.IsGlobalAdministrator) { ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(this.ModuleName); if (ri != null) { ltlAfter.Text += "<div class=\"AlignRight\">" + UIHelper.GetResourceUIElementsLink(this.Page, ri.ResourceId) + "</div>"; } } } }
protected void Page_Load(object sender, EventArgs e) { CurrentUserInfo currentUser = CMSContext.CurrentUser; // Fill the menu with UIElement data for specified module if (!String.IsNullOrEmpty(ModuleName) & (currentUser != null)) { DataSet dsModules = UIElementInfoProvider.GetUIMenuElements(ModuleName); List <object[]> categoriesTmp = new List <object[]>(); if (!DataHelper.DataSourceIsEmpty(dsModules)) { foreach (DataRow drModule in dsModules.Tables[0].Rows) { UIElementInfo moduleElement = new UIElementInfo(drModule); // Proceed if user has permissions for this UI element if (currentUser.IsAuthorizedPerUIElement(ModuleName, moduleElement.ElementName)) { // Category title string categoryTitle = ResHelper.LocalizeString(moduleElement.ElementDisplayName); // Category name string categoryName = ResHelper.LocalizeString(moduleElement.ElementName); // Category URL string categoryUrl = CMSContext.ResolveMacros(URLHelper.EnsureHashToQueryParameters(moduleElement.ElementTargetURL)); // Category image URL string categoryImageUrl = GetImagePath(moduleElement.ElementIconPath.Replace("list.png", "module.png")); if (!FileHelper.FileExists(categoryImageUrl)) { categoryImageUrl = GetImagePath("CMSModules/module.png"); } categoryImageUrl = UIHelper.ResolveImageUrl(categoryImageUrl); // Category tooltip string categoryTooltip = ResHelper.LocalizeString(moduleElement.ElementDescription); // Category actions DataSet dsActions = UIElementInfoProvider.GetChildUIElements(moduleElement.ElementID); List <string[]> actionsTmp = new List <string[]>(); foreach (DataRow drAction in dsActions.Tables[0].Rows) { UIElementInfo actionElement = new UIElementInfo(drAction); // Proceed if user has permissions for this UI element if (currentUser.IsAuthorizedPerUIElement(ModuleName, actionElement.ElementName)) { actionsTmp.Add(new string[] { ResHelper.LocalizeString(actionElement.ElementDisplayName), CMSContext.ResolveMacros(URLHelper.EnsureHashToQueryParameters(actionElement.ElementTargetURL)) }); } } int actionsCount = actionsTmp.Count; string[,] categoryActions = new string[actionsCount, 2]; for (int i = 0; i < actionsCount; i++) { categoryActions[i, 0] = actionsTmp[i][0]; categoryActions[i, 1] = actionsTmp[i][1]; } CategoryCreatedEventArgs args = new CategoryCreatedEventArgs(moduleElement, categoryName, categoryTitle, categoryUrl, categoryImageUrl, categoryTooltip, categoryActions); // Raise additional initialization events for this category if (CategoryCreated != null) { CategoryCreated(this, args); } // Add to categories, if further processing of this category was not cancelled if (!args.Cancel) { categoriesTmp.Add(new object[] { args.CategoryTitle, args.CategoryName, args.CategoryURL, args.CategoryImageURL, args.CategoryTooltip, args.CategoryActions }); } } } } int categoriesCount = categoriesTmp.Count; object[,] categories = new object[categoriesCount, 6]; for (int i = 0; i < categoriesCount; i++) { categories[i, 0] = categoriesTmp[i][0]; categories[i, 1] = categoriesTmp[i][1]; categories[i, 2] = categoriesTmp[i][2]; categories[i, 3] = categoriesTmp[i][3]; categories[i, 4] = categoriesTmp[i][4]; categories[i, 5] = categoriesTmp[i][5]; } if (categoriesCount > 0) { panelMenu.Categories = categories; panelMenu.ColumnsCount = ColumnsCount; } else { RedirectToUINotAvailable(); } // Add editing icon in development mode if (SettingsKeyProvider.DevelopmentMode && currentUser.IsGlobalAdministrator) { ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(ModuleName); if (ri != null) { ltlAfter.Text += "<div class=\"AlignRight\">" + UIHelper.GetResourceUIElementsLink(Page, ri.ResourceId) + "</div>"; } } } }