Пример #1
0
    /// <summary>
    /// Returns basic testing information.
    /// </summary>
    private string GetBasicInfo()
    {
        StringBuilder sb = new StringBuilder();

        sb.Append("<table>",
                  "<tr><td><strong>",
                  ResHelper.GetString("cmstesting.livesiteurl"),
                  "</strong></td><td>",
                  URLHelper.GetApplicationUrl(),
                  "</td></tr>",
                  "<tr><td><strong>",
                  ResHelper.GetString("cmstesting.buildnumber"),
                  "</strong></td><td>",
                  GetCMSVersion(),
                  "</td></tr>",
                  "<tr><td><strong>",
                  ResHelper.GetString("cmstesting.currentuser"),
                  "</strong></td><td>",
                  CMSContext.CurrentUser.UserName,
                  "</td></tr>",
                  "<tr><td><strong>",
                  ResHelper.GetString("cmstesting.useragent"),
                  "</strong></td><td>",
                  BrowserHelper.GetUserAgent(),
                  "</td></tr>",
                  "<tr><td><strong>",
                  ResHelper.GetString("cmstesting.connectionstrings"),
                  "</strong></td><td>",
                  GetConnectionStringsInfo(),
                  "</td></tr>",
                  "</table>");

        return(sb.ToString());
    }
Пример #2
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (!StopProcessing)
        {
            // Trim blank characters
            string rawSmallDeviceURL = SmallDeviceRedirectionURL.Trim();
            string rawLargeDeviceURL = LargeDeviceRedirectionURL.Trim();

            // Get redirect cookie
            string redirected = CookieHelper.GetValue(CookieName.MobileRedirected);

            if ((AlwaysRedirect || String.IsNullOrEmpty(redirected)) && PortalContext.ViewMode.IsLiveSite())
            {
                string redirectUrl = null;

                // Get user agent name or user agent string
                string userAgent = BrowserHelper.GetUserAgent();

                if (!string.IsNullOrEmpty(userAgent))
                {
                    UserAgentEnum userAgentEnum = GetUserAgentName(userAgent);

                    if (userAgentEnum != UserAgentEnum.Unknown)
                    {
                        redirectUrl = GetRedirectUrl(userAgent, userAgentEnum, rawSmallDeviceURL, rawLargeDeviceURL);
                    }
                    else
                    {
                        redirectUrl = CheckUsersRedirection(userAgent, rawSmallDeviceURL, rawLargeDeviceURL);
                    }

                    // Check if some address is specified
                    if (!string.IsNullOrEmpty(redirectUrl))
                    {
                        string newURL = URLHelper.ResolveUrl(redirectUrl);

                        newURL = EnsureQueryValues(newURL);

                        // If current URL is same as set, no redirection is done
                        if ((!RequestContext.CurrentURL.EqualsCSafe(newURL, true)) && (!URLHelper.GetAbsoluteUrl(RequestContext.CurrentURL).EqualsCSafe(newURL, true)))
                        {
                            // Set redirected cookie
                            CookieHelper.SetValue(CookieName.MobileRedirected, "true", DateTimeHelper.ZERO_TIME);
                            URLHelper.ResponseRedirect(newURL);
                        }
                    }
                }
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (!StopProcessing)
        {
            // Trim blank characters
            string rawSmallDeviceURL = SmallDeviceRedirectionURL.Trim();
            string rawLargeDeviceURL = LargeDeviceRedirectionURL.Trim();

            // Get redirect cookie
            string redirected = CookieHelper.GetValue("CMSMobileRedirected");

            if ((AlwaysRedirect || String.IsNullOrEmpty(redirected)) && (CMSContext.ViewMode == ViewModeEnum.LiveSite))
            {
                string redirectUrl = null;

                // Get user agent name or user agent string
                string userAgent = BrowserHelper.GetUserAgent();

                if (!string.IsNullOrEmpty(userAgent))
                {
                    UserAgentEnum userAgentEnum    = GetUserAgentName(userAgent);
                    string        redirectSettings = null;
                    switch (userAgentEnum)
                    {
                    case UserAgentEnum.BlackBerry:
                        redirectSettings = RedirectBlackBerry;
                        break;

                    case UserAgentEnum.IPhone:
                        redirectSettings = RedirectIPhone;
                        break;

                    case UserAgentEnum.IPad:
                        redirectSettings = RedirectIPad;
                        break;

                    case UserAgentEnum.Nokia:
                        redirectSettings = RedirectNokia;
                        break;

                    case UserAgentEnum.Android:
                        redirectSettings = RedirectAndroid;
                        break;
                    }

                    if (redirectSettings != null)
                    {
                        redirectUrl = GetRedirectUrl(redirectSettings, userAgent, userAgentEnum, rawSmallDeviceURL, rawLargeDeviceURL);
                    }
                    else
                    {
                        redirectUrl = CheckUsersRedirection(userAgent, rawSmallDeviceURL, rawLargeDeviceURL);
                    }
                }

                // Check if some address is specified
                if (!string.IsNullOrEmpty(redirectUrl))
                {
                    string newURL = URLHelper.ResolveUrl(redirectUrl);

                    // If current URL is same as set, no redirection is done
                    if ((URLHelper.CurrentURL != newURL) && (URLHelper.GetAbsoluteUrl(URLHelper.CurrentURL) != newURL))
                    {
                        // Set redirected cookie
                        CookieHelper.SetValue("CMSMobileRedirected", "true", DateTimeHelper.ZERO_TIME);
                        URLHelper.ResponseRedirect(newURL);
                    }
                }
            }
        }
    }