Пример #1
0
        public static Customer SkinBaseHook(int SkinID, Customer ThisCustomer)
        {
            if (!MobileHelper.isMobile())
            {
                MobileHelper.SetDesktopSkinLocale(ThisCustomer, SkinID);
            }
            else
            {
                MobileHelper.SetCustomerToMobileSkinId(ThisCustomer);

                string pageName = CommonLogic.IIF(
                    HttpContext.Current.Items["RequestedPage"] != null,
                    HttpContext.Current.Items["RequestedPage"].ToString(),
                    CommonLogic.GetThisPageName(false));

                PageType pt = GetPageType(pageName, CommonLogic.GetThisPageName(false), HttpContext.Current.Handler);


                switch (pt)
                {
                case PageType.Driver:
                    //continue to page - place exceptions here.
                    break;

                case PageType.PageWithRedirect:
                    String redirect = GetRedirect(pageName, CommonLogic.GetThisPageName(false));
                    if (CommonLogic.ServerVariables("QUERY_STRING").Length > 0)
                    {
                        redirect += "?" + CommonLogic.ServerVariables("QUERY_STRING");
                    }
                    HttpContext.Current.Response.Redirect(redirect);
                    break;

                case PageType.DesktopPageWithoutRedirect:
                    String middleManRedirect = pageName;
                    String referer           = "js";
                    if (HttpContext.Current.Request.UrlReferrer != null)
                    {
                        string tmp       = HttpContext.Current.Request.UrlReferrer.ToString();
                        int    lastindex = tmp.LastIndexOf('/') + 1;
                        if (lastindex > -1)
                        {
                            tmp = tmp.Substring(lastindex, tmp.Length - lastindex);
                        }
                        referer = tmp == "" ? "js" : tmp.ToString();
                    }
                    HttpContext.Current.Response.Redirect(AppLogic.GetStoreHTTPLocation(true) + "mobiledesktopwarning.aspx?currentpage=" + Security.UrlEncode(referer) + "&targetpage=" + Security.UrlEncode(pageName));
                    break;

                case PageType.Mobile:
                    //continue to page
                    break;

                default:
                    break;
                }
            }

            return(ThisCustomer);
        }
        public static string XmlPackageHook(string xmlPackage, Customer thisCustomer)
        {
            if (xmlPackage == "")
            {
                xmlPackage = "entity.DNE.xml.config";
            }

            // check for the mobile skin, if not return the default xml package.
            if (!MobileHelper.isMobile())
            {
                return(xmlPackage);
            }

            MobileXmlPackageType mobileType = MobileXmlPackageType.None;

            // Strip prefix from xml package name.
            if (xmlPackage.StartsWith(MobileXmlPackageType.Product.ToString(), StringComparison.InvariantCultureIgnoreCase))
            {
                mobileType = MobileXmlPackageType.Product;
            }
            else if (xmlPackage.StartsWith(MobileXmlPackageType.Entity.ToString(), StringComparison.InvariantCultureIgnoreCase))
            {
                mobileType = MobileXmlPackageType.Entity;
            }



            string mobileXmlPackage = string.Format("mobile.{0}", xmlPackage);
            string urlPath          = string.Format("~/App_Templates/Skin_{0}/XmlPackages/{1}", thisCustomer.SkinID, mobileXmlPackage);
            string fileName         = HttpContext.Current.Server.MapPath(urlPath);

            // Test for existance of xml package.
            if (!CommonLogic.FileExists(fileName))
            {
                urlPath  = string.Format("~/XmlPackages/{1}", thisCustomer.SkinID, mobileXmlPackage);
                fileName = HttpContext.Current.Server.MapPath(urlPath);
                if (!CommonLogic.FileExists(fileName))
                {
                    return(DefaultXmlPackage(xmlPackage, mobileType));
                }
            }


            // we found a matching package, so return the name
            return(mobileXmlPackage);
        }
Пример #3
0
 public bool IsMobileUserAgent()
 {
     return(MobileHelper.isMobile(false));
 }