();
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 += "" + UIHelper.GetResourceUIElementsLink(Page, ri.ResourceId) + "
";
}
}
}
}
#endregion
#region "Classes"
///
/// Event arguments class for UIPanelMenu OnCategoryCreated event.
///
public class CategoryCreatedEventArgs : CMSEventArgs
{
#region "Properties"
///
/// Base UI element for this category.
///
public UIElementInfo UIElement
{
get;
protected set;
}
///
/// Category name.
///
public string CategoryName
{
get;
set;
}
///
/// Category title.
///
public string CategoryTitle
{
get;
set;
}
///
/// Category URL.
///
public string CategoryURL
{
get;
set;
}
///
/// Category image url.
///
public string CategoryImageURL
{
get;
set;
}
///
/// Category tooltip.
///
public string CategoryTooltip
{
get;
set;
}
///
/// Category actions.
///
public string[,] CategoryActions
{
get;
protected set;
}
///
/// Indicates if further processing of this category will be done or not.
///
public bool Cancel
{
get;
set;
}
#endregion
#region "Constructors"
///
/// Initiliazes new instance of class.
///
/// Category title
/// Category URL
/// Category image URL
/// Category tooltip
/// Category actions
public CategoryCreatedEventArgs(UIElementInfo element, string categoryName, string categoryTitle, string categoryUrl, string categoryImageUrl, string categoryTooltip, string[,] categoryActions)
{
UIElement = element;
CategoryName = categoryName;
CategoryTitle = categoryTitle;
CategoryURL = categoryUrl;
CategoryImageURL = categoryImageUrl;
CategoryTooltip = categoryTooltip;
CategoryActions = categoryActions;
Cancel = false;
}
#endregion
}
#endregion
}