示例#1
0
    /// <summary>
    /// Sets the browser class to the body class.
    /// </summary>
    /// <param name="bodyClass">The body class.</param>
    /// <param name="generateCultureClass">if set to true generate culture class.</param>
    internal static string EnsureBodyClass(string bodyClass, bool generateCultureClass = true)
    {
        // Add browser type
#pragma warning disable CS0618 // Type or member is obsolete
        string browserClass = BrowserHelper.GetBrowserClass();
#pragma warning restore CS0618 // Type or member is obsolete
        if (!String.IsNullOrEmpty(browserClass))
        {
            bodyClass = string.Format("{0} {1}", bodyClass, browserClass).Trim();
        }

        if (generateCultureClass)
        {
            // Add culture type
            string cultureClass = DocumentContext.GetUICultureClass();
            if (!String.IsNullOrEmpty(cultureClass))
            {
                bodyClass = string.Format("{0} {1}", bodyClass, cultureClass).Trim();
            }
        }
        // Add bootstrap
        PortalUIHelper.EnsureBootstrapBodyClass(ref bodyClass, PortalContext.ViewMode, PageContext.CurrentPage);

        return(bodyClass);
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CMSPage page = Parent.Page as CMSPage;

        var developmentMode = (page != null) ? page.CurrentMaster.DevelopmentMode : SystemContext.DevelopmentMode;

        if (developmentMode && MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
        {
            // UI Element
            var elem = UIContext.UIElement;
            if (elem != null)
            {
                ltlActions.Text += PortalUIHelper.GetResourceUIElementsLink(elem.ElementResourceID, elem.ElementID);
            }

            // Debug
            string urlDebug  = URLHelper.GetAbsoluteUrl("~/CMSModules/System/Debug/System_ViewRequest.aspx?guid=" + DebugContext.CurrentRequestLogs.RequestGUID);
            string textDebug = GetString("general.debug");
            ltlDebug.Text = String.Format("<a target=\"_blank\" href=\"{0}\">{1}</a>", urlDebug, UIHelper.GetAccessibleIconTag("icon-bug", textDebug, FontIconSizeEnum.Standard));

            // Localize
            string textLocalize = GetString("localizable.localize");
            ltlLocalize.Text          = UIHelper.GetAccessibleIconTag("icon-earth", textLocalize, FontIconSizeEnum.Standard);
            btnLocalize.Image.Visible = false;

            // Do not move to the markup - could cause life cycle issues
            btnLocalize.HorizontalPosition  = HorizontalPositionEnum.Right;
            btnLocalize.OffsetY             = -20;
            btnLocalize.OffsetX             = 1;
            btnLocalize.MouseButton         = MouseButtonEnum.Both;
            btnLocalize.ContextMenuCssClass = "dev-tools-context-menu";
            btnLocalize.MenuControlPath     = "~/CMSAdminControls/UI/Development/Localize.ascx";
        }
        else
        {
            Visible = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            return;
        }

        string localizationCulture = PortalHelper.GetUILocalizationCulture();

        uniMenu.ResourceCulture = localizationCulture;

        // Handle the pre-selection
        mPreselectedItem = QueryHelper.GetString(QueryParameterName, "");
        if (mPreselectedItem.StartsWith("cms.", StringComparison.OrdinalIgnoreCase))
        {
            mPreselectedItem = mPreselectedItem.Substring(4);
        }

        uniMenu.HighlightItem = mPreselectedItem;

        // 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.EndsWith("ascx", StringComparison.OrdinalIgnoreCase) && (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"], ""), localizationCulture);
                if (group.Caption == String.Empty)
                {
                    group.Caption = ResHelper.LocalizeString(ValidationHelper.GetString(dr["ElementDisplayName"], ""), localizationCulture);
                }
                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.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) && !DisableEditIcon)
        {
            var link = PortalUIHelper.GetResourceUIElementLink(ModuleName, ElementName);
            if (!String.IsNullOrEmpty(link))
            {
                ltlAfter.Text += $"<div class=\"UIElementsLink\" >{link}</div>";
            }
        }
    }