Пример #1
0
    /// <summary>
    /// Generates panel with buttons loaded from given UI Element.
    /// </summary>
    /// <param name="uiElementId">ID of the UI Element</param>
    protected Panel GetButtons(int uiElementId)
    {
        const int bigButtonMinimalWidth   = 40;
        const int smallButtonMinimalWidth = 66;

        Panel pnlButtons = null;

        // Load the buttons manually from UI Element
        DataSet ds = UIElementInfoProvider.GetChildUIElements(uiElementId);

        // When no child found
        if (DataHelper.DataSourceIsEmpty(ds))
        {
            // Try to use group element as button
            ds = UIElementInfoProvider.GetUIElements("ElementID = " + uiElementId, null);

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                DataRow dr  = ds.Tables[0].Rows[0];
                string  url = ValidationHelper.GetString(dr["ElementTargetURL"], "");

                // Use group element as button only if it has URL specified
                if (string.IsNullOrEmpty(url))
                {
                    ds = null;
                }
            }
        }

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            // Filter the dataset according to UI Profile
            FilterElements(ds);

            int small = 0;
            int count = ds.Tables[0].Rows.Count;

            // No buttons, render nothing
            if (count == 0)
            {
                return(null);
            }

            // Prepare the panel
            pnlButtons          = new Panel();
            pnlButtons.CssClass = "ActionButtons";

            // Prepare the table
            Table    tabGroup    = new Table();
            TableRow tabGroupRow = new TableRow();

            tabGroup.CellPadding        = 0;
            tabGroup.CellSpacing        = 0;
            tabGroup.EnableViewState    = false;
            tabGroupRow.EnableViewState = false;
            tabGroup.Rows.Add(tabGroupRow);

            List <Panel> panels = new List <Panel>();

            for (int i = 0; i < count; i++)
            {
                // Get current and next button
                UIElementInfo uiElement = new UIElementInfo(ds.Tables[0].Rows[i]);

                UIElementInfo sel = UIContextHelper.CheckSelectedElement(uiElement, UIContext);
                if (sel != null)
                {
                    String selectionSuffix = ValidationHelper.GetString(UIContext["selectionSuffix"], String.Empty);
                    StartingPage  = UIContextHelper.GetElementUrl(sel, UIContext) + selectionSuffix;
                    HighlightItem = uiElement.ElementName;
                }

                // Raise button creating event
                if (OnButtonCreating != null)
                {
                    OnButtonCreating(this, new UniMenuArgs {
                        UIElement = uiElement
                    });
                }

                UIElementInfo uiElementNext = null;
                if (i < count - 1)
                {
                    uiElementNext = new UIElementInfo(ds.Tables[0].Rows[i + 1]);
                }

                // Set the first button
                if (mFirstUIElement == null)
                {
                    mFirstUIElement = uiElement;
                }

                // Get the sizes of current and next button. Button is large when it is the only in the group
                bool isSmall     = (uiElement.ElementSize == UIElementSizeEnum.Regular) && (count > 1);
                bool isResized   = (uiElement.ElementSize == UIElementSizeEnum.Regular) && (!isSmall);
                bool isNextSmall = (uiElementNext != null) && (uiElementNext.ElementSize == UIElementSizeEnum.Regular);

                // Set the CSS class according to the button size
                string cssClass    = (isSmall ? "SmallButton" : "BigButton");
                string elementName = uiElement.ElementName;

                // Display only caption - do not substitute with Display name when empty
                string elementCaption = ResHelper.LocalizeString(uiElement.ElementCaption);

                // Create main button panel
                CMSPanel pnlButton = new CMSPanel()
                {
                    ID      = "pnlButton" + elementName,
                    ShortID = "b" + elementName
                };

                pnlButton.Attributes.Add("name", elementName);
                pnlButton.CssClass = cssClass;

                // Remember the first button
                if (firstPanel == null)
                {
                    firstPanel = pnlButton;
                }

                // Remember the selected button
                if ((preselectedPanel == null) && elementName.EqualsCSafe(HighlightItem, true))
                {
                    preselectedPanel = pnlButton;

                    // Set the selected button
                    if (mHighlightedUIElement == null)
                    {
                        mHighlightedUIElement = uiElement;
                    }
                }

                // URL or behavior
                string url = uiElement.ElementTargetURL;

                if (!string.IsNullOrEmpty(url) && url.StartsWithCSafe("javascript:", true))
                {
                    pnlButton.Attributes["onclick"] = url.Substring("javascript:".Length);
                }
                else
                {
                    url = UIContextHelper.GetElementUrl(uiElement, UIContext);

                    if (url != String.Empty)
                    {
                        string buttonSelection = (RememberSelectedItem ? "SelectButton(this);" : "");

                        // Ensure hash code if required
                        url = MacroResolver.Resolve(URLHelper.EnsureHashToQueryParameters(url));

                        if (!String.IsNullOrEmpty(TargetFrameset))
                        {
                            if (uiElement.ElementType == UIElementTypeEnum.PageTemplate)
                            {
                                url = URLHelper.UpdateParameterInUrl(url, "displaytitle", "false");
                            }

                            String target = UseIFrame ? String.Format("frames['{0}']", TargetFrameset) : String.Format("parent.frames['{0}']", TargetFrameset);
                            pnlButton.Attributes["onclick"] = String.Format("{0}{1}.location.href = '{2}';", buttonSelection, target, UrlResolver.ResolveUrl(url));
                        }
                        else
                        {
                            pnlButton.Attributes["onclick"] = String.Format("{0}self.location.href = '{1}';", buttonSelection, UrlResolver.ResolveUrl(url));
                        }
                    }
                }

                // Tooltip
                if (!string.IsNullOrEmpty(uiElement.ElementDescription))
                {
                    pnlButton.ToolTip = ResHelper.LocalizeString(uiElement.ElementDescription);
                }
                else
                {
                    pnlButton.ToolTip = elementCaption;
                }
                pnlButton.EnableViewState = false;

                // Ensure correct grouping of small buttons
                if (isSmall && (small == 0))
                {
                    small++;

                    Panel pnlSmallGroup = new Panel()
                    {
                        ID = "pnlGroupSmall" + uiElement.ElementName
                    };
                    if (IsRTL)
                    {
                        pnlSmallGroup.Style.Add("float", "right");
                        pnlSmallGroup.Style.Add("text-align", "right");
                    }
                    else
                    {
                        pnlSmallGroup.Style.Add("float", "left");
                        pnlSmallGroup.Style.Add("text-align", "left");
                    }

                    pnlSmallGroup.EnableViewState = false;
                    pnlSmallGroup.Controls.Add(pnlButton);
                    panels.Add(pnlSmallGroup);
                }

                // Generate button link
                HyperLink buttonLink = new HyperLink()
                {
                    ID = "lnkButton" + uiElement.ElementName,
                    EnableViewState = false
                };

                // Generate button image
                Image buttonImage = new Image()
                {
                    ID              = "imgButton" + uiElement.ElementName,
                    ImageAlign      = (isSmall ? ImageAlign.AbsMiddle : ImageAlign.Top),
                    AlternateText   = elementCaption,
                    EnableViewState = false
                };

                // Use icon path
                if (!string.IsNullOrEmpty(uiElement.ElementIconPath))
                {
                    string iconPath = GetImagePath(uiElement.ElementIconPath);

                    // Check if element size was changed
                    if (isResized)
                    {
                        // Try to get larger icon
                        string largeIconPath = iconPath.Replace("list.png", "module.png");
                        if (FileHelper.FileExists(largeIconPath))
                        {
                            iconPath = largeIconPath;
                        }
                    }

                    buttonImage.ImageUrl = GetImageUrl(iconPath);
                    buttonLink.Controls.Add(buttonImage);
                }
                // Use Icon class
                else if (!string.IsNullOrEmpty(uiElement.ElementIconClass))
                {
                    var icon = new CMSIcon
                    {
                        ID = string.Format("ico_{0}_{1}", identifier, i),
                        EnableViewState = false,
                        ToolTip         = pnlButton.ToolTip,
                        CssClass        = "cms-icon-80 " + uiElement.ElementIconClass
                    };
                    buttonLink.Controls.Add(icon);
                }
                // Load default module icon if ElementIconPath is not specified
                else
                {
                    buttonImage.ImageUrl = GetImageUrl("CMSModules/module.png");
                    buttonLink.Controls.Add(buttonImage);
                }


                // Generate caption text
                Literal captionLiteral = new Literal()
                {
                    ID              = "ltlCaption" + uiElement.ElementName,
                    Text            = (isSmall ? "\n" : "<br />") + elementCaption,
                    EnableViewState = false
                };
                buttonLink.Controls.Add(captionLiteral);


                //Generate button table (IE7 issue)
                Table     tabButton     = new Table();
                TableRow  tabRow        = new TableRow();
                TableCell tabCellLeft   = new TableCell();
                TableCell tabCellMiddle = new TableCell();
                TableCell tabCellRight  = new TableCell();

                tabButton.CellPadding = 0;
                tabButton.CellSpacing = 0;

                tabButton.EnableViewState     = false;
                tabRow.EnableViewState        = false;
                tabCellLeft.EnableViewState   = false;
                tabCellMiddle.EnableViewState = false;
                tabCellRight.EnableViewState  = false;

                tabButton.Rows.Add(tabRow);
                tabRow.Cells.Add(tabCellLeft);
                tabRow.Cells.Add(tabCellMiddle);
                tabRow.Cells.Add(tabCellRight);

                // Generate left border
                Panel pnlLeft = new Panel()
                {
                    ID              = "pnlLeft" + uiElement.ElementName,
                    CssClass        = "Left" + cssClass,
                    EnableViewState = false
                };

                // Generate middle part of button
                Panel pnlMiddle = new Panel()
                {
                    ID       = "pnlMiddle" + uiElement.ElementName,
                    CssClass = "Middle" + cssClass
                };
                pnlMiddle.Controls.Add(buttonLink);
                Panel pnlMiddleTmp = new Panel()
                {
                    EnableViewState = false
                };
                if (isSmall)
                {
                    pnlMiddle.Style.Add("min-width", smallButtonMinimalWidth + "px");
                    // IE7 issue with min-width
                    pnlMiddleTmp.Style.Add("width", smallButtonMinimalWidth + "px");
                    pnlMiddle.Controls.Add(pnlMiddleTmp);
                }
                else
                {
                    pnlMiddle.Style.Add("min-width", bigButtonMinimalWidth + "px");
                    // IE7 issue with min-width
                    pnlMiddleTmp.Style.Add("width", bigButtonMinimalWidth + "px");
                    pnlMiddle.Controls.Add(pnlMiddleTmp);
                }
                pnlMiddle.EnableViewState = false;

                // Generate right border
                Panel pnlRight = new Panel()
                {
                    ID              = "pnlRight" + uiElement.ElementName,
                    CssClass        = "Right" + cssClass,
                    EnableViewState = false
                };

                // Add inner controls
                tabCellLeft.Controls.Add(pnlLeft);
                tabCellMiddle.Controls.Add(pnlMiddle);
                tabCellRight.Controls.Add(pnlRight);

                pnlButton.Controls.Add(tabButton);

                // If there were two small buttons in a row end the grouping div
                if ((small == 2) || (isSmall && !isNextSmall))
                {
                    small = 0;

                    // Add the button to the small buttons grouping panel
                    panels[panels.Count - 1].Controls.Add(pnlButton);
                }
                else
                {
                    if (small == 0)
                    {
                        // Add the generated button into collection
                        panels.Add(pnlButton);
                    }
                }
                if (small == 1)
                {
                    small++;
                }

                // Raise button created event
                if (OnButtonCreated != null)
                {
                    OnButtonCreated(this, new UniMenuArgs {
                        UIElement = uiElement, TargetUrl = url, ButtonControl = pnlButton, ImageControl = buttonImage
                    });
                }
            }

            // Add all panels to control
            foreach (Panel panel in panels)
            {
                TableCell tabGroupCell = new TableCell()
                {
                    VerticalAlign   = VerticalAlign.Top,
                    EnableViewState = false
                };

                tabGroupCell.Controls.Add(panel);
                tabGroupRow.Cells.Add(tabGroupCell);
            }

            pnlButtons.Controls.Add(tabGroup);
        }

        return(pnlButtons);
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            return;
        }

        // Handle the pre-selection
        preselectedItem = QueryHelper.GetString(QueryParameterName, "");
        if (preselectedItem.StartsWithCSafe("cms.", true))
        {
            preselectedItem = preselectedItem.Substring(4);
        }

        uniMenu.HighlightItem = preselectedItem;

        // If element name is not set, use root module element
        string elemName = ElementName;

        if (String.IsNullOrEmpty(elemName))
        {
            elemName = ModuleName.Replace(".", "");
        }

        // Get the UI elements
        DataSet ds = UIElementInfoProvider.GetChildUIElements(ModuleName, elemName);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            FilterElements(ds);

            // Prepare the list of elements
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string            url  = ValidationHelper.GetString(dr["ElementTargetURL"], "");
                UIElementTypeEnum type = ValidationHelper.GetString(dr["ElementType"], "").ToEnum <UIElementTypeEnum>();

                Group group = new Group();
                if (url.EndsWithCSafe("ascx") && (type == UIElementTypeEnum.UserControl))
                {
                    group.ControlPath = url;
                }
                else
                {
                    group.UIElementID = ValidationHelper.GetInteger(dr["ElementID"], 0);
                }

                group.CssClass = "ContentMenuGroup";

                if (GenerateElementCssClass)
                {
                    string name = ValidationHelper.GetString(dr["ElementName"], String.Empty).Replace(".", String.Empty);
                    group.CssClass         += " ContentMenuGroup" + name;
                    group.SeparatorCssClass = "UniMenuSeparator" + name;
                }

                group.Caption = ResHelper.LocalizeString(ValidationHelper.GetString(dr["ElementCaption"], ""));
                if (group.Caption == String.Empty)
                {
                    group.Caption = ResHelper.LocalizeString(ValidationHelper.GetString(dr["ElementDisplayName"], ""));
                }
                uniMenu.Groups.Add(group);
            }

            // Raise groups created event
            RaiseOnGroupsCreated(this, uniMenu.Groups);

            // Button created & filtered event handler
            uniMenu.OnButtonCreating += uniMenu_OnButtonCreating;
            uniMenu.OnButtonCreated  += uniMenu_OnButtonCreated;
            uniMenu.OnButtonFiltered += uniMenu_OnButtonFiltered;
        }

        // Add editing icon in development mode
        if (SystemContext.DevelopmentMode && MembershipContext.AuthenticatedUser.IsGlobalAdministrator && !DisableEditIcon)
        {
            var link = UIContextHelper.GetResourceUIElementLink(ModuleName, ElementName);
            if (!String.IsNullOrEmpty(link))
            {
                ltlAfter.Text += String.Format("<div class=\"UIElementsLink\" >{0}</div>", link);
            }
        }
    }
Пример #3
0
    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>";
                }
            }
        }
    }
    protected void ContextMenu_OnReloadData(object sender, EventArgs e)
    {
        int nodeId = ValidationHelper.GetInteger(ContextMenu.Parameter, 0);

        // Get the node
        var tree = new TreeProvider(MembershipContext.AuthenticatedUser);
        var node = tree.SelectSingleNode(nodeId);

        if (node != null)
        {
            if (plcProperties.Visible)
            {
                // Properties menu
                var elements = UIElementInfoProvider.GetChildUIElements("CMS.Content", "Properties");
                if (!DataHelper.DataSourceIsEmpty(elements))
                {
                    var      index = 0;
                    UserInfo user  = MembershipContext.AuthenticatedUser;

                    foreach (var element in elements)
                    {
                        // Skip elements not relevant for given node
                        if (DocumentUIHelper.IsElementHiddenForNode(element, node))
                        {
                            continue;
                        }

                        var elementName = element.ElementName.ToLowerInvariant();

                        // If UI element is available and user has permission to show it then add it
                        if (UIContextHelper.CheckElementAvailabilityInUI(element) && user.IsAuthorizedPerUIElement(element.ElementResourceID, elementName))
                        {
                            switch (elementName)
                            {
                            case "properties.languages":
                                if (!CultureSiteInfoProvider.IsSiteMultilingual(SiteContext.CurrentSiteName) || !CultureSiteInfoProvider.LicenseVersionCheck())
                                {
                                    continue;
                                }
                                break;

                            case "properties.variants":
                                if (!LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.ContentPersonalization, ModuleName.ONLINEMARKETING) ||
                                    !ResourceSiteInfoProvider.IsResourceOnSite("CMS.ContentPersonalization", SiteContext.CurrentSiteName) ||
                                    !PortalContext.ContentPersonalizationEnabled ||
                                    (VariantHelper.GetVariantID(VariantModeEnum.ContentPersonalization, node.GetUsedPageTemplateId(), String.Empty) <= 0))
                                {
                                    continue;
                                }
                                break;

                            case "properties.workflow":
                            case "properties.versions":
                                if (node.GetWorkflow() == null)
                                {
                                    continue;
                                }
                                break;
                            }

                            var item = new ContextMenuItem();
                            item.ID = "p" + index;
                            item.Attributes.Add("onclick", String.Format("Properties(GetContextMenuParameter('nodeMenu'), '{0}');", elementName));

                            // UI elements could have a different display name if content only document is selected
                            item.Text = DocumentUIHelper.GetUIElementDisplayName(element, node);

                            pnlPropertiesMenu.Controls.Add(item);

                            index++;
                        }
                    }

                    if (index == 0)
                    {
                        // Hide 'Properties' menu if user has no permission for at least one properties section
                        plcProperties.Visible = false;
                    }
                }
            }
        }
        else
        {
            iNoNode.Visible = true;
            plcFirstLevelContainer.Visible = false;
        }
    }
Пример #5
0
    protected void ContextMenu_OnReloadData(object sender, EventArgs e)
    {
        int nodeId = ValidationHelper.GetInteger(ContextMenu.Parameter, 0);

        // Get the node
        var tree = new TreeProvider(MembershipContext.AuthenticatedUser);
        var node = tree.SelectSingleNode(nodeId);

        if (node != null)
        {
            if (node.IsLink)
            {
                cmcNew.Visible = false;
            }

            if (plcProperties.Visible)
            {
                // Properties menu
                var elements = UIElementInfoProvider.GetChildUIElements("CMS.Content", "Properties");
                if (!DataHelper.DataSourceIsEmpty(elements))
                {
                    var      index = 0;
                    UserInfo user  = MembershipContext.AuthenticatedUser;

                    foreach (var element in elements)
                    {
                        // Skip elements not relevant for given node
                        if (DocumentUIHelper.IsElementHiddenForNode(element, node))
                        {
                            continue;
                        }

                        var elementName = element.ElementName.ToLowerInvariant();

                        // If UI element is available and user has permission to show it then add it
                        if (UIContextHelper.CheckElementAvailabilityInUI(element) && user.IsAuthorizedPerUIElement(element.ElementResourceID, elementName))
                        {
                            var item = new ContextMenuItem();
                            item.ID = "p" + index;
                            item.Attributes.Add("onclick", String.Format("Properties(GetContextMenuParameter('nodeMenu'), '{0}');", elementName));

                            item.Text = ResHelper.LocalizeString(element.ElementDisplayName);

                            pnlPropertiesMenu.Controls.Add(item);

                            index++;
                        }
                    }

                    if (index == 0)
                    {
                        // Hide 'Properties' menu if user has no permission for at least one properties section
                        plcProperties.Visible = false;
                    }
                }
            }
        }
        else
        {
            iNoNode.Visible = true;
            plcFirstLevelContainer.Visible = false;
        }
    }
Пример #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Handle the preselection
        preselectedItem = QueryHelper.GetString(this.QueryParameterName, "");
        if (preselectedItem.StartsWith("cms.", StringComparison.InvariantCultureIgnoreCase))
        {
            preselectedItem = preselectedItem.Substring(4);
        }

        uniMenu.HighlightItem = preselectedItem;

        // If element name is not set, use root module element
        string elemName = this.ElementName;

        if (String.IsNullOrEmpty(elemName))
        {
            elemName = this.ModuleName.Replace(".", "");
        }

        // Get the UI elements
        DataSet ds = UIElementInfoProvider.GetChildUIElements(this.ModuleName, elemName);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            FilterElements(ds);

            int count = ds.Tables[0].Rows.Count;
            string[,] groups = new string[count, 4];

            // Prepare the list of elements
            int i = 0;
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string url = ValidationHelper.GetString(dr["ElementTargetURL"], "");

                if (url.EndsWith("ascx"))
                {
                    groups[i, 1] = url;
                }
                else
                {
                    groups[i, 3] = ValidationHelper.GetString(dr["ElementID"], "");
                }

                groups[i, 2] = "ContentMenuGroup";
                groups[i, 0] = ResHelper.LocalizeString(ValidationHelper.GetString(dr["ElementCaption"], ""));

                i++;
            }

            uniMenu.Groups = groups;

            // Button created & filtered event handler
            if (OnButtonCreated != null)
            {
                uniMenu.OnButtonCreated += new CMSAdminControls_UI_UniMenu_UniMenu.ButtonCreatedEventHandler(uniMenu_OnButtonCreated);
            }
            if (OnButtonFiltered != null)
            {
                uniMenu.OnButtonFiltered += new CMSAdminControls_UI_UniMenu_UniMenu.ButtonFilterEventHandler(uniMenu_OnButtonFiltered);
            }
        }

        // Add editing icon in development mode
        if (SettingsKeyProvider.DevelopmentMode && CMSContext.CurrentUser.IsGlobalAdministrator)
        {
            ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(this.ModuleName);
            if (ri != null)
            {
                ltlAfter.Text += UIHelper.GetResourceUIElementsLink(this.Page, ri.ResourceId);
            }
        }
    }