Exemple #1
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        var cui = CurrentUser;

        if (cui != null)
        {
            if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHighlight"))
            {
                // Highlight button
                MenuItem highlightItem = new MenuItem();
                highlightItem.CssClass      = "BigButton";
                highlightItem.ImageAlign    = ImageAlign.Top;
                highlightItem.IconClass     = "icon-square-dashed-line";
                highlightItem.OnClientClick = "OEHighlightToggle(event, this);";
                highlightItem.Text          = PortalHelper.LocalizeStringForUI("onsiteedit.highlight");
                highlightItem.Tooltip       = PortalHelper.LocalizeStringForUI("onsiteedit.highlighttooltip");
                highlightItem.ImageAltText  = PortalHelper.LocalizeStringForUI("onsiteedit.highlight");

                otherMenu.Buttons.Add(highlightItem);
            }

            if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHidden"))
            {
                // Hidden button
                MenuItem hiddenItem = new MenuItem();
                hiddenItem.CssClass     = "BigButton OnSiteHiddenButton";
                hiddenItem.ImageAlign   = ImageAlign.Top;
                hiddenItem.IconClass    = "icon-eye-slash";
                hiddenItem.Text         = PortalHelper.LocalizeStringForUI("general.hidden");
                hiddenItem.Tooltip      = PortalHelper.LocalizeStringForUI("onsiteedit.hiddentooltip");
                hiddenItem.ImageAltText = PortalHelper.LocalizeStringForUI("general.hidden");

                // Add temporary empty sub menu item to ensure generating of the sub menu functions
                SubMenuItem epmtyItem = new SubMenuItem();
                hiddenItem.SubItems.Add(epmtyItem);

                otherMenu.Buttons.Add(hiddenItem);
            }
        }
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        var cui = CurrentUser;

        if (cui != null)
        {
            if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHighlight"))
            {
                // Highlight button
                MenuItem highlightItem = new MenuItem();
                highlightItem.CssClass = "BigButton";
                highlightItem.ImageAlign = ImageAlign.Top;
                highlightItem.IconClass = "icon-square-dashed-line";
                highlightItem.OnClientClick = "OEHighlightToggle(event, this);";
                highlightItem.Text = GetString("onsiteedit.highlight");
                highlightItem.Tooltip = GetString("onsiteedit.highlighttooltip");
                highlightItem.ImageAltText = GetString("onsiteedit.highlight");

                otherMenu.Buttons.Add(highlightItem);
            }

            if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHidden"))
            {
                // Hidden button
                MenuItem hiddenItem = new MenuItem();
                hiddenItem.CssClass = "BigButton OnSiteHiddenButton";
                hiddenItem.ImageAlign = ImageAlign.Top;
                hiddenItem.IconClass = "icon-eye-slash";
                hiddenItem.Text = GetString("general.hidden");
                hiddenItem.Tooltip = GetString("onsiteedit.hiddentooltip");
                hiddenItem.ImageAltText = GetString("general.hidden");

                // Add temporary empty sub menu item to ensure generating of the sub menu functions
                SubMenuItem epmtyItem = new SubMenuItem();
                hiddenItem.SubItems.Add(epmtyItem);

                otherMenu.Buttons.Add(hiddenItem);
            }
        }
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentUserInfo cui = CurrentUser;

        if (cui != null)
        {
            if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHighlight"))
            {
                // Highlight button
                MenuItem highlightItem = new MenuItem();
                highlightItem.CssClass      = "BigButton OnSiteHighlightButton";
                highlightItem.ImageAlign    = ImageAlign.Top;
                highlightItem.ImagePath     = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/highlight.png");
                highlightItem.OnClientClick = "OEHighlightToggle(event, this);";
                highlightItem.Text          = GetString("onsiteedit.highlight");
                highlightItem.Tooltip       = GetString("onsiteedit.highlighttooltip");
                highlightItem.ImageAltText  = GetString("onsiteedit.highlight");

                otherMenu.Buttons.Add(highlightItem);
            }

            if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHidden"))
            {
                // Hidden button
                MenuItem hiddenItem = new MenuItem();
                hiddenItem.CssClass     = "BigButton OnSiteHiddenButton";
                hiddenItem.ImageAlign   = ImageAlign.Top;
                hiddenItem.ImagePath    = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/hidden.png");
                hiddenItem.Text         = GetString("general.hidden");
                hiddenItem.Tooltip      = GetString("onsiteedit.hiddentooltip");
                hiddenItem.ImageAltText = GetString("general.hidden");

                // Add temporary empty sub menu item to ensure generating of the sub menu functions
                SubMenuItem epmtyItem = new SubMenuItem();
                hiddenItem.SubItems.Add(epmtyItem);

                otherMenu.Buttons.Add(hiddenItem);
            }
        }
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentUserInfo cui = CurrentUser;

        if (cui != null)
        {
            if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHighlight"))
            {
                // Highlight button
                MenuItem highlightItem = new MenuItem();
                highlightItem.CssClass = "BigButton OnSiteHighlightButton";
                highlightItem.ImageAlign = ImageAlign.Top;
                highlightItem.ImagePath = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/highlight.png");
                highlightItem.OnClientClick = "OEHighlightToggle(event, this);";
                highlightItem.Text = GetString("onsiteedit.highlight");
                highlightItem.Tooltip = GetString("onsiteedit.highlighttooltip");
                highlightItem.ImageAltText = GetString("onsiteedit.highlight");

                otherMenu.Buttons.Add(highlightItem);
            }

            if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHidden"))
            {
                // Hidden button
                MenuItem hiddenItem = new MenuItem();
                hiddenItem.CssClass = "BigButton OnSiteHiddenButton";
                hiddenItem.ImageAlign = ImageAlign.Top;
                hiddenItem.ImagePath = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/hidden.png");
                hiddenItem.Text = GetString("general.hidden");
                hiddenItem.Tooltip = GetString("onsiteedit.hiddentooltip");
                hiddenItem.ImageAltText = GetString("general.hidden");

                // Add temporary empty sub menu item to ensure generating of the sub menu functions
                SubMenuItem epmtyItem = new SubMenuItem();
                hiddenItem.SubItems.Add(epmtyItem);

                otherMenu.Buttons.Add(hiddenItem);
            }
        }
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        string prefferedCultureCode = LocalizationContext.PreferredCultureCode;
        string defaultString = GetString("general.default");

        InfoDataSet<CultureInfo> siteCultures = CultureSiteInfoProvider.GetSiteCultures(SiteContext.CurrentSiteName);
        pi = DocumentContext.CurrentPageInfo ?? DocumentContext.CurrentCultureInvariantPageInfo ?? new PageInfo();

        // Cultures button
        MenuItem cultureItem = new MenuItem();
        cultureItem.CssClass = "BigButton";
        cultureItem.ImageAlign = ImageAlign.Top;
        cultureItem.ImagePath = URLHelper.UnResolveUrl(UIHelper.GetFlagIconUrl(Page, prefferedCultureCode, "16x16"), SystemContext.ApplicationPath);
        cultureItem.Text = GetString("general.cultures");
        cultureItem.Tooltip = GetString("onsiteedit.languageselector");
        cultureItem.ImageAltText = GetString("general.cultures");

        // Add all cultures to the sub menu
        foreach (CultureInfo culture in siteCultures)
        {
            string iconUrl = UIHelper.GetFlagIconUrl(Page, culture.CultureCode, "16x16");
            string cultureName = culture.CultureName;
            string cultureCode = culture.CultureCode;
            string cultureShortName = culture.CultureShortName;

            if (cultureCode != prefferedCultureCode)
            {
                SubMenuItem menuItem = new SubMenuItem()
                {
                    Text = cultureName,
                    Tooltip = cultureName,
                    ImagePath = iconUrl,
                    ImageAltText = cultureName
                };

                // Build the web part image html
                bool translationExists = NodeCultures.ContainsKey(cultureCode);

                if (translationExists)
                {
                    // Assign click action which changes the document culture
                    menuItem.OnClientClick = "document.location.replace(" + ScriptHelper.GetString(URLHelper.UpdateParameterInUrl(RequestContext.CurrentURL, URLHelper.LanguageParameterName, cultureCode)) + ");";
                }
                else
                {
                    // Display the "Not translated" image
                    menuItem.RightImageIconClass = "icon-ban-sign";
                    menuItem.RightImageAltText = GetString("onsitedit.culturenotavailable");

                    // Assign click action -> Create new document culture
                    menuItem.OnClientClick = "NewDocumentCulture(" + pi.NodeID + ",'" + cultureCode + "');";
                }

                cultureItem.SubItems.Add(menuItem);
            }
            else
            {
                // Current culture
                cultureItem.Text = culture.CultureShortName;
                cultureItem.Tooltip = cultureName;
                cultureItem.ImagePath = iconUrl;
                cultureItem.ImageAltText = cultureName;
            }
        }

        btnCulture.Buttons.Add(cultureItem);
    }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        string prefferedCultureCode = CMSContext.PreferredCultureCode;
        string defaultSmallIconUrl  = GetImageUrl("CMSModules/CMS_DeviceProfiles/default_list.png");
        string defaultBigIconUrl    = GetImageUrl("CMSModules/CMS_DeviceProfiles/default.png");
        string defaultString        = GetString("general.default");

        InfoDataSet <CultureInfo> siteCultures = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);

        pi = CMSContext.CurrentPageInfo ?? OnSiteEditHelper.PageInfoForPageNotFound;

        // Cultures button
        MenuItem cultureItem = new MenuItem();

        cultureItem.CssClass     = "BigButton";
        cultureItem.ImageAlign   = ImageAlign.Top;
        cultureItem.ImagePath    = URLHelper.UnResolveUrl(UIHelper.GetFlagIconUrl(Page, prefferedCultureCode, "16x16"), URLHelper.ApplicationPath);
        cultureItem.Text         = GetString("general.cultures");
        cultureItem.Tooltip      = GetString("onsiteedit.languageselector");
        cultureItem.ImageAltText = GetString("general.cultures");

        // Add all cultures to the sub menu
        foreach (CultureInfo culture in siteCultures)
        {
            string iconUrl          = UIHelper.GetFlagIconUrl(Page, culture.CultureCode, "16x16");
            string cultureName      = culture.CultureName;
            string cultureCode      = culture.CultureCode;
            string cultureShortName = culture.CultureShortName;

            if (cultureCode != prefferedCultureCode)
            {
                SubMenuItem menuItem = new SubMenuItem()
                {
                    Text         = cultureName,
                    Tooltip      = cultureName,
                    ImagePath    = iconUrl,
                    ImageAltText = cultureName
                };

                // Build the web part image html
                bool translationExists = NodeCultures.ContainsKey(cultureCode);

                if (translationExists)
                {
                    // Assign click action which changes the document culture
                    menuItem.OnClientClick = "document.location.replace(" + ScriptHelper.GetString(URLHelper.UpdateParameterInUrl(URLHelper.CurrentURL, URLHelper.LanguageParameterName, cultureCode)) + ");";
                }
                else
                {
                    // Display the "Not translated" image
                    menuItem.RightImagePath    = GetImageUrl("/CMSModules/CMS_PortalEngine/OnSiteEdit/no_culture.png");
                    menuItem.RightImageAltText = GetString("onsitedit.culturenotavailable");

                    // Assign click action -> Create new document culture
                    menuItem.OnClientClick = "NewDocumentCulture(" + pi.NodeID + ",'" + cultureCode + "');";
                }

                cultureItem.SubItems.Add(menuItem);
            }
            else
            {
                // Current culture
                cultureItem.Text         = culture.CultureShortName;
                cultureItem.Tooltip      = cultureName;
                cultureItem.ImagePath    = iconUrl;
                cultureItem.ImageAltText = cultureName;
            }
        }

        btnCulture.Buttons.Add(cultureItem);
    }
    /// <summary>
    /// Loads device profile menu.
    /// </summary>
    private void LoadDevicesMenu()
    {
        string defaultSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default_list.png");
        string defaultBigIconUrl   = GetImageUrl("CMSModules/CMS_DeviceProfile/default.png");

        if ((Page is PortalPage) || (Page is TemplatePage))
        {
            // Display grayscale icon in On-site editing
            defaultBigIconUrl   = GetImageUrl("CMSModules/CMS_DeviceProfile/default_grayscale.png");
            defaultSmallIconUrl = defaultBigIconUrl;
        }

        string deviceSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/list.png");
        string deviceBigIconUrl   = GetImageUrl("CMSModules/CMS_DeviceProfile/module.png");

        string defaultString = HTMLHelper.HTMLEncode(GetString("general.default"));

        MenuItem devMenuItem = new MenuItem
        {
            Text         = defaultString,
            Tooltip      = defaultString,
            ImagePath    = defaultBigIconUrl,
            ImageAltText = defaultString
        };

        SetStyles(devMenuItem);
        buttons.Buttons.Add(devMenuItem);

        // Load enabled profiles
        InfoDataSet <DeviceProfileInfo> ds = DeviceProfileInfoProvider.GetDeviceProfileInfos("ProfileEnabled = 1", "ProfileOrder");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            // Create default item
            SubMenuItem defaultMenuItem = new SubMenuItem
            {
                Text          = defaultString,
                Tooltip       = defaultString,
                ImagePath     = defaultSmallIconUrl,
                ImageAltText  = defaultString,
                OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice('');", ScriptHelper.GetString(defaultString), ScriptHelper.GetString(ResolveUrl(defaultBigIconUrl)))
            };

            devMenuItem.SubItems.Add(defaultMenuItem);

            foreach (DeviceProfileInfo profileInfo in ds.Items)
            {
                string bigIconUrl   = null;
                string smallIconUrl = null;
                if (profileInfo.ProfileIconGuid == Guid.Empty)
                {
                    smallIconUrl = deviceSmallIconUrl;
                    bigIconUrl   = deviceBigIconUrl;
                }
                else
                {
                    string iconUrl = MetaFileURLProvider.GetMetaFileUrl(profileInfo.ProfileIconGuid, profileInfo.ProfileName);
                    smallIconUrl = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "16");
                    bigIconUrl   = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "24");
                }

                string      profileName = GetString(profileInfo.ProfileDisplayName);
                SubMenuItem menuItem    = new SubMenuItem
                {
                    Text          = HTMLHelper.HTMLEncode(profileName),
                    Tooltip       = HTMLHelper.HTMLEncode(profileName),
                    ImagePath     = smallIconUrl,
                    ImageAltText  = HTMLHelper.HTMLEncode(profileName),
                    OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice({2});", ScriptHelper.GetString(profileName), ScriptHelper.GetString(ResolveUrl(bigIconUrl)), ScriptHelper.GetString(profileInfo.ProfileName))
                };

                devMenuItem.SubItems.Add(menuItem);

                // Update main button if current device profile is equal currently processed profile
                if ((currentDevice != null) && (currentDevice.ProfileName.CompareToCSafe(profileInfo.ProfileName, true) == 0))
                {
                    devMenuItem.Text         = HTMLHelper.HTMLEncode(profileName);
                    devMenuItem.Tooltip      = HTMLHelper.HTMLEncode(profileName);
                    devMenuItem.ImagePath    = bigIconUrl;
                    devMenuItem.ImageAltText = HTMLHelper.HTMLEncode(profileName);
                }
            }
        }
    }
Exemple #8
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        string preferredCultureCode            = LocalizationContext.PreferredCultureCode;
        InfoDataSet <CultureInfo> siteCultures = CultureSiteInfoProvider.GetSiteCultures(SiteContext.CurrentSiteName);

        pi = DocumentContext.CurrentPageInfo ?? DocumentContext.CurrentCultureInvariantPageInfo ?? new PageInfo();

        // Cultures button
        MenuItem cultureItem = new MenuItem();

        cultureItem.CssClass     = "BigButton";
        cultureItem.ImageAlign   = ImageAlign.Top;
        cultureItem.ImagePath    = URLHelper.UnResolveUrl(UIHelper.GetFlagIconUrl(Page, preferredCultureCode, "16x16"), SystemContext.ApplicationPath);
        cultureItem.Text         = PortalHelper.LocalizeStringForUI("general.cultures");
        cultureItem.Tooltip      = PortalHelper.LocalizeStringForUI("onsiteedit.languageselector");
        cultureItem.ImageAltText = PortalHelper.LocalizeStringForUI("general.cultures");

        // Add all cultures to the sub menu
        foreach (CultureInfo culture in siteCultures)
        {
            string iconUrl     = UIHelper.GetFlagIconUrl(Page, culture.CultureCode, "16x16");
            string cultureName = culture.CultureName;
            string cultureCode = culture.CultureCode;

            if (cultureCode != preferredCultureCode)
            {
                SubMenuItem menuItem = new SubMenuItem
                {
                    Text         = cultureName,
                    Tooltip      = cultureName,
                    ImagePath    = iconUrl,
                    ImageAltText = cultureName
                };

                // Build the web part image html
                bool translationExists = NodeCultures.ContainsKey(cultureCode);

                if (translationExists)
                {
                    // Assign click action which changes the document culture
                    menuItem.OnClientClick = "document.location.replace(" + ScriptHelper.GetString(URLHelper.UpdateParameterInUrl(RequestContext.CurrentURL, URLHelper.LanguageParameterName, cultureCode)) + ");";
                }
                else
                {
                    // Display the "Not translated" image
                    menuItem.RightImageIconClass = "icon-ban-sign";
                    menuItem.RightImageAltText   = PortalHelper.LocalizeStringForUI("onsitedit.culturenotavailable");

                    // Assign click action -> Create new document culture
                    menuItem.OnClientClick = "NewDocumentCulture(" + pi.NodeID + ",'" + cultureCode + "');";
                }

                cultureItem.SubItems.Add(menuItem);
            }
            else
            {
                // Current culture
                cultureItem.Text         = culture.CultureShortName;
                cultureItem.Tooltip      = cultureName;
                cultureItem.ImagePath    = iconUrl;
                cultureItem.ImageAltText = cultureName;
            }
        }

        btnCulture.Buttons.Add(cultureItem);
    }
    /// <summary>
    /// Method for adding sub menu item into menu.
    /// </summary>
    /// <param name="pnlMenu">Menu container control</param>
    /// <param name="item">Sub menu item definition</param>
    /// <param name="cssClass">Button css class</param>
    /// <param name="subIdentifier">Button identifier</param>
    private void AddSubMenuItem(CMSPanel pnlMenu, SubMenuItem item, string cssClass, int subIdentifier)
    {
        if (String.IsNullOrEmpty(item.ControlPath))
        {
            // Generate sub item
            CMSPanel pnlItem = new CMSPanel();
            pnlItem.ID = "pnlSubItem" + subIdentifier;
            pnlItem.ShortID = "pi" + subIdentifier;
            pnlItem.CssClass = "Item ItemPadding";
            pnlItem.ToolTip = item.Tooltip;

            if (!String.IsNullOrEmpty(item.OnClientClick))
            {
                pnlItem.Attributes["onclick"] = item.OnClientClick.Replace("##BUTTON##", "$cmsj(this).parents('." + cssClass + "').get(0)");
            }

            if (!String.IsNullOrEmpty(item.ImagePath))
            {
                string altText = String.IsNullOrEmpty(item.ImageAltText) ? item.Text : item.ImageAltText;

                // Generate sub items text
                CMSPanel pnlIcon = new CMSPanel();
                pnlIcon.ID = "pnlIcon";
                pnlIcon.ShortID = "pii" + subIdentifier;
                pnlIcon.CssClass = "Icon";
                Literal subItemImage = new Literal();
                subItemImage.ID = "ltlSubItemImage" + subIdentifier;
                subItemImage.EnableViewState = false;
                subItemImage.Text = String.Format("<img src=\"{0}\" alt=\"{1}\" />&nbsp;",
                        ResolveUrl(item.ImagePath),
                        GetString(altText));

                pnlIcon.Controls.Add(subItemImage);
                pnlItem.Controls.Add(pnlIcon);
            }

            // Add custom HTML attributes
            foreach (var htmlAttribute in item.HtmlAttributes)
            {
                pnlItem.Attributes[htmlAttribute.Key] = HTMLHelper.HTMLEncode(htmlAttribute.Value);
            }

            // Generate sub items text
            CMSPanel pnlText = new CMSPanel();
            pnlText.ID = "pnlText";
            pnlText.ShortID = "pt" + subIdentifier;
            pnlText.CssClass = "Name";
            Label subItemText = new Label();
            subItemText.ID = "ltlSubItem" + subIdentifier;
            subItemText.EnableViewState = false;
            subItemText.Text = GetString(item.Text);

            pnlText.Controls.Add(subItemText);
            pnlItem.Controls.Add(pnlText);

            if (!String.IsNullOrEmpty(item.RightImagePath))
            {
                string altText = String.IsNullOrEmpty(item.RightImageAltText) ? item.Text : item.RightImageAltText;

                // Generate sub item right icon
                Literal subRightItemImage = new Literal();
                subRightItemImage.ID = "ltlSubRightItemImage" + subIdentifier;
                subRightItemImage.EnableViewState = false;
                subRightItemImage.Text = String.Format("<img class=\"RightIcon\" src=\"{0}\" alt=\"{1}\" />&nbsp;",
                        ResolveUrl(item.RightImagePath),
                        GetString(altText));

                CMSPanel pnlRightIcon = CreateRightIconPanel(subIdentifier);
                pnlRightIcon.Controls.Add(subRightItemImage);
                pnlItem.Controls.Add(pnlRightIcon);
            }
            else if (!string.IsNullOrEmpty(item.RightImageIconClass))
            {
                string altText = String.IsNullOrEmpty(item.RightImageAltText) ? item.Text : item.RightImageAltText;

                var icon = new CMSIcon
                {
                    ID = "ico" + subIdentifier,
                    EnableViewState = false,
                    ToolTip = GetString(altText),
                    CssClass = "cms-icon-80 " + item.RightImageIconClass
                };

                CMSPanel pnlRightIcon = CreateRightIconPanel(subIdentifier);
                pnlRightIcon.Controls.Add(icon);
                pnlItem.Controls.Add(pnlRightIcon);
            }

            pnlMenu.Controls.Add(pnlItem);
        }
        else
        {
            // Load menu item control
            Control ctrl = LoadUserControl(item.ControlPath);
            if (ctrl != null)
            {
                pnlMenu.Controls.Add(ctrl);
            }
        }
    }
    /// <summary>
    /// Method for adding sub menu item into menu.
    /// </summary>
    /// <param name="pnlMenu">Menu container control</param>
    /// <param name="item">Sub menu item definition</param>
    /// <param name="cssClass">Button css class</param>
    /// <param name="subIdentifier">Button identifier</param>
    private void AddSubMenuItem(CMSPanel pnlMenu, SubMenuItem item, string cssClass, int subIdentifier)
    {
        if (String.IsNullOrEmpty(item.ControlPath))
        {
            // Generate sub item
            CMSPanel pnlItem = new CMSPanel();
            pnlItem.ID = "pnlSubItem" + subIdentifier;
            pnlItem.ShortID = "pi" + subIdentifier;
            pnlItem.CssClass = "Item ItemPadding";
            pnlItem.ToolTip = item.Tooltip;

            if (!String.IsNullOrEmpty(item.OnClientClick))
            {
                pnlItem.Attributes["onclick"] = item.OnClientClick.Replace("##BUTTON##", "$j(this).parents('." + cssClass + "').get(0)");
            }

            if (!String.IsNullOrEmpty(item.ImagePath))
            {
                string altText = String.IsNullOrEmpty(item.ImageAltText) ? item.Text : item.ImageAltText;

                // Generate sub items text
                CMSPanel pnlIcon = new CMSPanel();
                pnlIcon.ID = "pnlIcon";
                pnlIcon.ShortID = "pii" + subIdentifier;
                pnlIcon.CssClass = "Icon";
                Literal subItemImage = new Literal();
                subItemImage.ID = "ltlSubItemImage" + subIdentifier;
                subItemImage.EnableViewState = false;
                subItemImage.Text = String.Format("<img src=\"{0}\" alt=\"{1}\" />&nbsp;",
                        ResolveUrl(item.ImagePath),
                        GetString(altText));

                pnlIcon.Controls.Add(subItemImage);
                pnlItem.Controls.Add(pnlIcon);
            }

            // Generate sub items text
            CMSPanel pnlText = new CMSPanel();
            pnlText.ID = "pnlText";
            pnlText.ShortID = "pt" + subIdentifier;
            pnlText.CssClass = "Name";
            Label subItemText = new Label();
            subItemText.ID = "ltlSubItem" + subIdentifier;
            subItemText.EnableViewState = false;
            subItemText.Text = GetString(item.Text);

            pnlText.Controls.Add(subItemText);
            pnlItem.Controls.Add(pnlText);

            if (!String.IsNullOrEmpty(item.RightImagePath))
            {
                string altText = String.IsNullOrEmpty(item.RightImageAltText) ? item.Text : item.RightImageAltText;

                // Generate sub item right icon
                CMSPanel pnlRightIcon = new CMSPanel();
                pnlRightIcon.ID = "pnlRightIcon";
                pnlRightIcon.ShortID = "pri" + subIdentifier;
                pnlRightIcon.CssClass = "Icon IconRight";
                Literal subRightItemImage = new Literal();
                subRightItemImage.ID = "ltlSubRightItemImage" + subIdentifier;
                subRightItemImage.EnableViewState = false;
                subRightItemImage.Text = String.Format("<img class=\"RightIcon\" src=\"{0}\" alt=\"{1}\" />&nbsp;",
                        ResolveUrl(item.RightImagePath),
                        GetString(altText));

                pnlRightIcon.Controls.Add(subRightItemImage);
                pnlItem.Controls.Add(pnlRightIcon);
            }

            pnlMenu.Controls.Add(pnlItem);
        }
        else
        {
            // Load menu item control
            Control ctrl = this.LoadUserControl(item.ControlPath);
            if (ctrl != null)
            {
                pnlMenu.Controls.Add(ctrl);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSAdminControls/UI/UniMenu/UniMenu.js");

        currentSiteName = (SiteID != 0) ? SiteInfoProvider.GetSiteName(SiteID) : CMSContext.CurrentSiteName;
        DataSet siteCulturesDS = CultureInfoProvider.GetSiteCultures(currentSiteName);
        if (!DataHelper.DataSourceIsEmpty(siteCulturesDS))
        {
            // Register jQuery cookie script
            ScriptHelper.RegisterJQueryCookie(Page);

            string defaultCulture = CultureHelper.GetDefaultCulture(currentSiteName);
            DataTable siteCultures = siteCulturesDS.Tables[0];

            culturesCount = siteCultures.Rows.Count;
            if ((culturesCount <= MaxCulturesInRow) && (culturesCount > 1))
            {
                // Disable cultures menu
                btnCultures.StopProcessing = true;

                for (int i = 0; i < culturesCount; i++)
                {
                    string cultureCode = siteCultures.Rows[i]["CultureCode"].ToString();
                    string cultureShortName = siteCultures.Rows[i]["CultureShortName"].ToString();
                    string cultureLongName = ResHelper.LocalizeString(siteCultures.Rows[i]["CultureName"].ToString());

                    if (CMSString.Compare(cultureCode, defaultCulture, true) == 0)
                    {
                        cultureLongName += " " + GetString("general.defaultchoice");
                    }

                    MenuItem item = new MenuItem();
                    item.Text = HTMLHelper.HTMLEncode(cultureShortName);
                    item.Tooltip = cultureLongName;
                    item.CssClass = "BigButton";
                    item.OnClientClick = "ChangeLanguage('" + cultureCode + "')";
                    item.ImagePath = GetFlagIconUrl(cultureCode, "48x48");
                    item.ImageAltText = cultureLongName;
                    item.ImageAlign = ImageAlign.Top;
                    item.MinimalWidth = 48;
                    buttons.Buttons.Add(item);

                    if (SelectedCulture.ToLowerCSafe() == cultureCode.ToLowerCSafe())
                    {
                        buttons.SelectedIndex = i;
                    }
                }
            }
            else
            {
                // Do not show culture selection buttons
                buttons.StopProcessing = true;

                CultureInfo ci = CultureInfoProvider.GetCultureInfo(SelectedCulture);

                MenuItem item = new MenuItem();
                item.Text = ci.CultureShortName;
                item.Tooltip = GetString(ci.CultureName);
                item.ImagePath = GetFlagIconUrl(SelectedCulture, UseSmallLanguageButton ? "16x16" : "48x48");
                item.ImageAltText = GetString(ci.CultureName);

                SetStyles(item);

                // Generate submenu only if more cultures to choose from
                if (culturesCount > 1)
                {
                    foreach (DataRow row in siteCultures.Rows)
                    {
                        string cultureCode = row["CultureCode"].ToString();
                        string cultureShortName = row["CultureShortName"].ToString();
                        string cultureLongName = GetString(row["CultureName"].ToString());

                        if (CMSString.Compare(cultureCode, defaultCulture, true) == 0)
                        {
                            cultureLongName += " " + GetString("general.defaultchoice");
                        }

                        string flagUrl = GetFlagIconUrl(cultureCode, "16x16");
                        string flagBigUrl = GetFlagIconUrl(cultureCode, "48x48");
                        SubMenuItem menuItem = new SubMenuItem()
                        {
                            Text = cultureLongName,
                            Tooltip = cultureLongName,
                            ImagePath = flagUrl,
                            ImageAltText = cultureShortName,
                            OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeLanguage({2});", ScriptHelper.GetString(cultureShortName), ScriptHelper.GetString(ResolveUrl(flagBigUrl)), ScriptHelper.GetString(cultureCode))
                        };

                        item.SubItems.Add(menuItem);
                    }
                }

                btnCultures.Buttons.Add(item);
            }

            if (culturesCount > 1)
            {
                string compare = GetString("SplitMode.Compare");

                // Split mode button
                MenuItem splitItem = new MenuItem();
                splitItem.Text = compare;
                splitItem.Tooltip = GetString("SplitMode.CompareLangVersions");
                splitItem.OnClientClick = "ChangeSplitMode()";
                splitItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/Compare.png");
                splitItem.ImageAltText = compare;
                splitItem.AllowToggle = true;
                splitItem.IsToggled = CMSContext.DisplaySplitMode;

                SetStyles(splitItem);

                splitView.Buttons.Add(splitItem);
            }
            else
            {
                splitView.StopProcessing = true;
            }
        }
    }
    /// <summary>
    /// Loads device profile menu.
    /// </summary>
    private void LoadDevicesMenu()
    {
        if (UseSmallButton)
        {
            plcSmallButton.Visible = true;
        }
        else
        {
            plcBigButton.Visible = true;
        }

        string defaultString = HTMLHelper.HTMLEncode(GetString("deviceselector.default", ResourceCulture));
        StringBuilder sbDeviceProfiles = new StringBuilder();
        MenuItem devMenuItem = null;

        if (!UseSmallButton)
        {
            devMenuItem = new MenuItem
            {
                Text = defaultString,
                Tooltip = defaultString,
            };

            // Display icon in On-site editing
            if ((Page is PortalPage) || (Page is TemplatePage))
            {
                devMenuItem.IconClass = "icon-monitor-smartphone";
            }

            SetStyles(devMenuItem);
            buttons.Buttons.Add(devMenuItem);
        }

        // Load enabled profiles
        InfoDataSet<DeviceProfileInfo> ds = DeviceProfileInfoProvider.GetDeviceProfiles()
            .WhereEquals("ProfileEnabled", 1)
            .OrderBy("ProfileOrder")
            .TypedResult;

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            // Create default item
            SubMenuItem defaultMenuItem = new SubMenuItem
                                              {
                                                  Text = defaultString,
                                                  Tooltip = defaultString,
                                                  OnClientClick = "ChangeDevice('');",
                                              };

            if (UseSmallButton)
            {
                // Insert the current device profile to the button
                btnProfilesSelector.Actions.Add(new CMSButtonAction()
                {
                    OnClientClick = String.Format("ChangeDevice({0}); return false;", ScriptHelper.GetString(defaultString)),
                    Text = defaultString
                });
            }
            else
            {
                // Insert the current device profile to the context menu
                devMenuItem.SubItems.Add(defaultMenuItem);
            }

            // Load the profiles list
            foreach (DeviceProfileInfo profileInfo in ds.Items)
            {
                string profileName = GetString(profileInfo.ProfileDisplayName, ResourceCulture);
                CMSButtonAction deviceButton = null;

                if (UseSmallButton)
                {
                    deviceButton = new CMSButtonAction()
                    {
                        OnClientClick = String.Format("ChangeDevice({0}); return false;", ScriptHelper.GetString(profileInfo.ProfileName)),
                        Text = profileName,
                        Name = profileName
                    };

                    btnProfilesSelector.Actions.Add(deviceButton);
                }
                else
                {
                    SubMenuItem menuItem = new SubMenuItem
                                               {
                                                   Text = HTMLHelper.HTMLEncode(profileName),
                                                   Tooltip = HTMLHelper.HTMLEncode(profileName),
                                                   OnClientClick = String.Format("ChangeDevice({0});", ScriptHelper.GetString(profileInfo.ProfileName))
                                               };
                    devMenuItem.SubItems.Add(menuItem);
                }

                // Update main button if current device profile is equal currently processed profile
                if ((currentDevice != null) && (currentDevice.ProfileName.CompareToCSafe(profileInfo.ProfileName, true) == 0))
                {
                    if (UseSmallButton)
                    {
                        btnProfilesSelector.SelectedActionName = profileName;
                    }
                    else
                    {
                        devMenuItem.Text = HTMLHelper.HTMLEncode(profileName);
                        devMenuItem.Tooltip = HTMLHelper.HTMLEncode(profileName);
                    }
                }

            }
        }
    }
Exemple #13
0
    /// <summary>
    /// Method for adding sub menu item into menu.
    /// </summary>
    /// <param name="pnlMenu">Menu container control</param>
    /// <param name="item">Sub menu item definition</param>
    /// <param name="cssClass">Button css class</param>
    /// <param name="subIdentifier">Button identifier</param>
    private void AddSubMenuItem(CMSPanel pnlMenu, SubMenuItem item, string cssClass, int subIdentifier)
    {
        if (String.IsNullOrEmpty(item.ControlPath))
        {
            // Generate sub item
            CMSPanel pnlItem = new CMSPanel();
            pnlItem.ID       = "pnlSubItem" + subIdentifier;
            pnlItem.ShortID  = "pi" + subIdentifier;
            pnlItem.CssClass = "Item ItemPadding";
            pnlItem.ToolTip  = item.Tooltip;

            if (!String.IsNullOrEmpty(item.OnClientClick))
            {
                pnlItem.Attributes["onclick"] = item.OnClientClick.Replace("##BUTTON##", "$j(this).parents('." + cssClass + "').get(0)");
            }

            if (!String.IsNullOrEmpty(item.ImagePath))
            {
                string altText = String.IsNullOrEmpty(item.ImageAltText) ? item.Text : item.ImageAltText;

                // Generate sub items text
                CMSPanel pnlIcon = new CMSPanel();
                pnlIcon.ID       = "pnlIcon";
                pnlIcon.ShortID  = "pii" + subIdentifier;
                pnlIcon.CssClass = "Icon";
                Literal subItemImage = new Literal();
                subItemImage.ID = "ltlSubItemImage" + subIdentifier;
                subItemImage.EnableViewState = false;
                subItemImage.Text            = String.Format("<img src=\"{0}\" alt=\"{1}\" />&nbsp;",
                                                             ResolveUrl(item.ImagePath),
                                                             GetString(altText));

                pnlIcon.Controls.Add(subItemImage);
                pnlItem.Controls.Add(pnlIcon);
            }

            // Generate sub items text
            CMSPanel pnlText = new CMSPanel();
            pnlText.ID       = "pnlText";
            pnlText.ShortID  = "pt" + subIdentifier;
            pnlText.CssClass = "Name";
            Label subItemText = new Label();
            subItemText.ID = "ltlSubItem" + subIdentifier;
            subItemText.EnableViewState = false;
            subItemText.Text            = GetString(item.Text);

            pnlText.Controls.Add(subItemText);
            pnlItem.Controls.Add(pnlText);

            if (!String.IsNullOrEmpty(item.RightImagePath))
            {
                string altText = String.IsNullOrEmpty(item.RightImageAltText) ? item.Text : item.RightImageAltText;

                // Generate sub item right icon
                CMSPanel pnlRightIcon = new CMSPanel();
                pnlRightIcon.ID       = "pnlRightIcon";
                pnlRightIcon.ShortID  = "pri" + subIdentifier;
                pnlRightIcon.CssClass = "Icon IconRight";
                Literal subRightItemImage = new Literal();
                subRightItemImage.ID = "ltlSubRightItemImage" + subIdentifier;
                subRightItemImage.EnableViewState = false;
                subRightItemImage.Text            = String.Format("<img class=\"RightIcon\" src=\"{0}\" alt=\"{1}\" />&nbsp;",
                                                                  ResolveUrl(item.RightImagePath),
                                                                  GetString(altText));

                pnlRightIcon.Controls.Add(subRightItemImage);
                pnlItem.Controls.Add(pnlRightIcon);
            }

            pnlMenu.Controls.Add(pnlItem);
        }
        else
        {
            // Load menu item control
            Control ctrl = this.LoadUserControl(item.ControlPath);
            if (ctrl != null)
            {
                pnlMenu.Controls.Add(ctrl);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterScriptFile(Page, "~/CMSAdminControls/UI/UniMenu/UniMenu.js");

        currentSiteName = (SiteID != 0) ? SiteInfoProvider.GetSiteName(SiteID) : CMSContext.CurrentSiteName;
        DataSet siteCulturesDS = CultureInfoProvider.GetSiteCultures(currentSiteName);

        if (!DataHelper.DataSourceIsEmpty(siteCulturesDS))
        {
            // Register jQuery cookie script
            ScriptHelper.RegisterJQueryCookie(Page);

            string    defaultCulture = CultureHelper.GetDefaultCulture(currentSiteName);
            DataTable siteCultures   = siteCulturesDS.Tables[0];

            culturesCount = siteCultures.Rows.Count;
            if ((culturesCount <= MaxCulturesInRow) && (culturesCount > 1))
            {
                // Disable cultures menu
                btnCultures.StopProcessing = true;

                for (int i = 0; i < culturesCount; i++)
                {
                    string cultureCode      = siteCultures.Rows[i]["CultureCode"].ToString();
                    string cultureShortName = siteCultures.Rows[i]["CultureShortName"].ToString();
                    string cultureLongName  = ResHelper.LocalizeString(siteCultures.Rows[i]["CultureName"].ToString());

                    if (CMSString.Compare(cultureCode, defaultCulture, true) == 0)
                    {
                        cultureLongName += " " + GetString("general.defaultchoice");
                    }

                    MenuItem item = new MenuItem();
                    item.Text          = HTMLHelper.HTMLEncode(cultureShortName);
                    item.Tooltip       = cultureLongName;
                    item.CssClass      = "BigButton";
                    item.OnClientClick = "ChangeLanguage('" + cultureCode + "')";
                    item.ImagePath     = GetFlagIconUrl(cultureCode, "48x48");
                    item.ImageAltText  = cultureLongName;
                    item.ImageAlign    = ImageAlign.Top;
                    item.MinimalWidth  = 48;
                    buttons.Buttons.Add(item);

                    if (SelectedCulture.ToLowerCSafe() == cultureCode.ToLowerCSafe())
                    {
                        buttons.SelectedIndex = i;
                    }
                }
            }
            else
            {
                // Do not show culture selection buttons
                buttons.StopProcessing = true;

                CultureInfo ci = CultureInfoProvider.GetCultureInfo(SelectedCulture);

                MenuItem item = new MenuItem();
                item.Text         = ci.CultureShortName;
                item.Tooltip      = GetString(ci.CultureName);
                item.ImagePath    = GetFlagIconUrl(SelectedCulture, UseSmallLanguageButton ? "16x16" : "48x48");
                item.ImageAltText = GetString(ci.CultureName);

                SetStyles(item);

                // Generate submenu only if more cultures to choose from
                if (culturesCount > 1)
                {
                    foreach (DataRow row in siteCultures.Rows)
                    {
                        string cultureCode      = row["CultureCode"].ToString();
                        string cultureShortName = row["CultureShortName"].ToString();
                        string cultureLongName  = GetString(row["CultureName"].ToString());

                        if (CMSString.Compare(cultureCode, defaultCulture, true) == 0)
                        {
                            cultureLongName += " " + GetString("general.defaultchoice");
                        }

                        string      flagUrl    = GetFlagIconUrl(cultureCode, "16x16");
                        string      flagBigUrl = GetFlagIconUrl(cultureCode, "48x48");
                        SubMenuItem menuItem   = new SubMenuItem()
                        {
                            Text          = cultureLongName,
                            Tooltip       = cultureLongName,
                            ImagePath     = flagUrl,
                            ImageAltText  = cultureShortName,
                            OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeLanguage({2});", ScriptHelper.GetString(cultureShortName), ScriptHelper.GetString(ResolveUrl(flagBigUrl)), ScriptHelper.GetString(cultureCode))
                        };

                        item.SubItems.Add(menuItem);
                    }
                }

                btnCultures.Buttons.Add(item);
            }

            if (culturesCount > 1)
            {
                string compare = GetString("SplitMode.Compare");

                // Split mode button
                MenuItem splitItem = new MenuItem();
                splitItem.Text          = compare;
                splitItem.Tooltip       = GetString("SplitMode.CompareLangVersions");
                splitItem.OnClientClick = "ChangeSplitMode()";
                splitItem.ImagePath     = GetImageUrl("CMSModules/CMS_Content/Menu/Compare.png");
                splitItem.ImageAltText  = compare;
                splitItem.AllowToggle   = true;
                splitItem.IsToggled     = CMSContext.DisplaySplitMode;

                SetStyles(splitItem);

                splitView.Buttons.Add(splitItem);
            }
            else
            {
                splitView.StopProcessing = true;
            }
        }
    }
    /// <summary>
    /// Loads device profile menu.
    /// </summary>
    private void LoadDevicesMenu()
    {
        string defaultSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default_list.png");
        string defaultBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default.png");
        if ((Page is PortalPage) || (Page is TemplatePage))
        {
            // Display grayscale icon in On-site editing
            defaultBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default_grayscale.png");
            defaultSmallIconUrl = defaultBigIconUrl;
        }

        string deviceSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/list.png");
        string deviceBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/module.png");

        string defaultString = HTMLHelper.HTMLEncode(GetString("general.default"));

        MenuItem devMenuItem = new MenuItem
        {
            Text = defaultString,
            Tooltip = defaultString,
            ImagePath = defaultBigIconUrl,
            ImageAltText = defaultString
        };
        SetStyles(devMenuItem);
        buttons.Buttons.Add(devMenuItem);

        // Load enabled profiles
        InfoDataSet<DeviceProfileInfo> ds = DeviceProfileInfoProvider.GetDeviceProfileInfos("ProfileEnabled = 1", "ProfileOrder");
        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            // Create default item
            SubMenuItem defaultMenuItem = new SubMenuItem
                                              {
                                                  Text = defaultString,
                                                  Tooltip = defaultString,
                                                  ImagePath = defaultSmallIconUrl,
                                                  ImageAltText = defaultString,
                                                  OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice('');", ScriptHelper.GetString(defaultString), ScriptHelper.GetString(ResolveUrl(defaultBigIconUrl)))
                                              };

            devMenuItem.SubItems.Add(defaultMenuItem);

            foreach (DeviceProfileInfo profileInfo in ds.Items)
            {
                string bigIconUrl = null;
                string smallIconUrl = null;
                if (profileInfo.ProfileIconGuid == Guid.Empty)
                {
                    smallIconUrl = deviceSmallIconUrl;
                    bigIconUrl = deviceBigIconUrl;
                }
                else
                {
                    string iconUrl = MetaFileURLProvider.GetMetaFileUrl(profileInfo.ProfileIconGuid, profileInfo.ProfileName);
                    smallIconUrl = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "16");
                    bigIconUrl = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "24");
                }

                string profileName = GetString(profileInfo.ProfileDisplayName);
                SubMenuItem menuItem = new SubMenuItem
                                           {
                                               Text = HTMLHelper.HTMLEncode(profileName),
                                               Tooltip = HTMLHelper.HTMLEncode(profileName),
                                               ImagePath = smallIconUrl,
                                               ImageAltText = HTMLHelper.HTMLEncode(profileName),
                                               OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice({2});", ScriptHelper.GetString(profileName), ScriptHelper.GetString(ResolveUrl(bigIconUrl)), ScriptHelper.GetString(profileInfo.ProfileName))
                                           };

                devMenuItem.SubItems.Add(menuItem);

                // Update main button if current device profile is equal currently processed profile
                if ((currentDevice != null) && (currentDevice.ProfileName.CompareToCSafe(profileInfo.ProfileName, true) == 0))
                {
                    devMenuItem.Text = HTMLHelper.HTMLEncode(profileName);
                    devMenuItem.Tooltip = HTMLHelper.HTMLEncode(profileName);
                    devMenuItem.ImagePath = bigIconUrl;
                    devMenuItem.ImageAltText = HTMLHelper.HTMLEncode(profileName);
                }
            }
        }
    }
    /// <summary>
    /// Loads device profile menu.
    /// </summary>
    private void LoadDevicesMenu()
    {
        if (UseSmallButton)
        {
            plcSmallButton.Visible = true;
        }
        else
        {
            plcBigButton.Visible = true;
        }

        string        defaultString    = HTMLHelper.HTMLEncode(GetString("deviceselector.default", ResourceCulture));
        StringBuilder sbDeviceProfiles = new StringBuilder();
        MenuItem      devMenuItem      = null;

        if (!UseSmallButton)
        {
            devMenuItem = new MenuItem
            {
                Text    = defaultString,
                Tooltip = defaultString,
            };

            // Display icon in On-site editing
            if ((Page is PortalPage) || (Page is TemplatePage))
            {
                devMenuItem.IconClass = "icon-monitor-smartphone";
            }

            SetStyles(devMenuItem);
            buttons.Buttons.Add(devMenuItem);
        }

        // Load enabled profiles
        InfoDataSet <DeviceProfileInfo> ds = DeviceProfileInfoProvider.GetDeviceProfiles()
                                             .WhereEquals("ProfileEnabled", 1)
                                             .OrderBy("ProfileOrder")
                                             .TypedResult;

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            // Create default item
            SubMenuItem defaultMenuItem = new SubMenuItem
            {
                Text          = defaultString,
                Tooltip       = defaultString,
                OnClientClick = "ChangeDevice('');",
            };

            if (UseSmallButton)
            {
                // Insert the current device profile to the button
                btnProfilesSelector.Actions.Add(new CMSButtonAction()
                {
                    OnClientClick = String.Format("ChangeDevice({0}); return false;", ScriptHelper.GetString(defaultString)),
                    Text          = defaultString
                });
            }
            else
            {
                // Insert the current device profile to the context menu
                devMenuItem.SubItems.Add(defaultMenuItem);
            }

            // Load the profiles list
            foreach (DeviceProfileInfo profileInfo in ds.Items)
            {
                string          profileName  = GetString(profileInfo.ProfileDisplayName, ResourceCulture);
                CMSButtonAction deviceButton = null;

                if (UseSmallButton)
                {
                    deviceButton = new CMSButtonAction()
                    {
                        OnClientClick = String.Format("ChangeDevice({0}); return false;", ScriptHelper.GetString(profileInfo.ProfileName)),
                        Text          = profileName,
                        Name          = profileName
                    };

                    btnProfilesSelector.Actions.Add(deviceButton);
                }
                else
                {
                    SubMenuItem menuItem = new SubMenuItem
                    {
                        Text          = HTMLHelper.HTMLEncode(profileName),
                        Tooltip       = HTMLHelper.HTMLEncode(profileName),
                        OnClientClick = String.Format("ChangeDevice({0});", ScriptHelper.GetString(profileInfo.ProfileName))
                    };
                    devMenuItem.SubItems.Add(menuItem);
                }

                // Update main button if current device profile is equal currently processed profile
                if ((currentDevice != null) && (currentDevice.ProfileName.CompareToCSafe(profileInfo.ProfileName, true) == 0))
                {
                    if (UseSmallButton)
                    {
                        btnProfilesSelector.SelectedActionName = profileName;
                    }
                    else
                    {
                        devMenuItem.Text    = HTMLHelper.HTMLEncode(profileName);
                        devMenuItem.Tooltip = HTMLHelper.HTMLEncode(profileName);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Method for adding sub menu item into menu.
    /// </summary>
    /// <param name="pnlMenu">Menu container control</param>
    /// <param name="item">Sub menu item definition</param>
    /// <param name="cssClass">Button css class</param>
    /// <param name="subIdentifier">Button identifier</param>
    private void AddSubMenuItem(CMSPanel pnlMenu, SubMenuItem item, string cssClass, int subIdentifier)
    {
        if (String.IsNullOrEmpty(item.ControlPath))
        {
            // Generate sub item
            CMSPanel pnlItem = new CMSPanel();
            pnlItem.ID       = "pnlSubItem" + subIdentifier;
            pnlItem.ShortID  = "pi" + subIdentifier;
            pnlItem.CssClass = "Item ItemPadding";
            pnlItem.ToolTip  = item.Tooltip;

            if (!String.IsNullOrEmpty(item.OnClientClick))
            {
                pnlItem.Attributes["onclick"] = item.OnClientClick.Replace("##BUTTON##", "$cmsj(this).parents('." + cssClass + "').get(0)");
            }

            if (!String.IsNullOrEmpty(item.ImagePath))
            {
                string altText = String.IsNullOrEmpty(item.ImageAltText) ? item.Text : item.ImageAltText;

                // Generate sub items text
                CMSPanel pnlIcon = new CMSPanel();
                pnlIcon.ID       = "pnlIcon";
                pnlIcon.ShortID  = "pii" + subIdentifier;
                pnlIcon.CssClass = "Icon";
                Literal subItemImage = new Literal();
                subItemImage.ID = "ltlSubItemImage" + subIdentifier;
                subItemImage.EnableViewState = false;
                subItemImage.Text            = String.Format("<img src=\"{0}\" alt=\"{1}\" />&nbsp;",
                                                             ResolveUrl(item.ImagePath),
                                                             GetString(altText));

                pnlIcon.Controls.Add(subItemImage);
                pnlItem.Controls.Add(pnlIcon);
            }

            // Add custom HTML attributes
            foreach (var htmlAttribute in item.HtmlAttributes)
            {
                pnlItem.Attributes[htmlAttribute.Key] = HTMLHelper.HTMLEncode(htmlAttribute.Value);
            }

            // Generate sub items text
            CMSPanel pnlText = new CMSPanel();
            pnlText.ID       = "pnlText";
            pnlText.ShortID  = "pt" + subIdentifier;
            pnlText.CssClass = "Name";
            Label subItemText = new Label();
            subItemText.ID = "ltlSubItem" + subIdentifier;
            subItemText.EnableViewState = false;
            subItemText.Text            = GetString(item.Text);

            pnlText.Controls.Add(subItemText);
            pnlItem.Controls.Add(pnlText);

            if (!String.IsNullOrEmpty(item.RightImagePath))
            {
                string altText = String.IsNullOrEmpty(item.RightImageAltText) ? item.Text : item.RightImageAltText;

                // Generate sub item right icon
                Literal subRightItemImage = new Literal();
                subRightItemImage.ID = "ltlSubRightItemImage" + subIdentifier;
                subRightItemImage.EnableViewState = false;
                subRightItemImage.Text            = String.Format("<img class=\"RightIcon\" src=\"{0}\" alt=\"{1}\" />&nbsp;",
                                                                  ResolveUrl(item.RightImagePath),
                                                                  GetString(altText));

                CMSPanel pnlRightIcon = CreateRightIconPanel(subIdentifier);
                pnlRightIcon.Controls.Add(subRightItemImage);
                pnlItem.Controls.Add(pnlRightIcon);
            }
            else if (!string.IsNullOrEmpty(item.RightImageIconClass))
            {
                string altText = String.IsNullOrEmpty(item.RightImageAltText) ? item.Text : item.RightImageAltText;

                var icon = new CMSIcon
                {
                    ID = "ico" + subIdentifier,
                    EnableViewState = false,
                    ToolTip         = GetString(altText),
                    CssClass        = "cms-icon-80 " + item.RightImageIconClass
                };

                CMSPanel pnlRightIcon = CreateRightIconPanel(subIdentifier);
                pnlRightIcon.Controls.Add(icon);
                pnlItem.Controls.Add(pnlRightIcon);
            }

            pnlMenu.Controls.Add(pnlItem);
        }
        else
        {
            // Load menu item control
            Control ctrl = LoadUserControl(item.ControlPath);
            if (ctrl != null)
            {
                pnlMenu.Controls.Add(ctrl);
            }
        }
    }