예제 #1
0
파일: ThemeUrl.cs 프로젝트: zwkjgs/LebiShop
        /// <summary>
        ///
        /// </summary>
        /// <param name="code">页面标记的代码</param>
        /// <param name="ParaStr">参数字符串</param>
        /// <param name="url">跳转地址</param>
        /// <param name="theme">主题</param>
        /// <returns></returns>
        public static string GetURL(string code, string ParaStr, string url, Lebi_Site site, Lebi_Language lang)
        {
            code = code.Trim();
            if (url != "" && url != null)
            {
                if (url.ToLower().IndexOf("http") == 0)
                {
                    return(url);
                }
                if (url.Contains(":"))
                {
                    string[] arr = url.Split(':');
                    return(GetURL(arr[0], arr[1], "", site, lang));
                }
                return(url);
            }
            List <Lebi_Theme_Page> nodes = ShopCache.GetThemePage();
            Lebi_Theme_Page        node  = (from m in nodes
                                            where m.Code == code
                                            select m).ToList().FirstOrDefault();


            // Lebi_Theme_Page node = B_Lebi_Theme_Page.GetModel("Code='" + code + "'");
            if (node == null)
            {
                return("");
            }

            //Lebi_Theme_Skin skin = B_Lebi_Theme_Skin.GetList("Theme_id=" + theme.id + " and Code='" + code + "'", "").FirstOrDefault();
            //if (skin == null)
            //    return "";
            string res      = "";
            string PageName = "";

            switch (node.Type_id_PublishType)
            {
            case 120:
                res = "";
                break;

            case 121:    //动态地址
                //if (skin.PageName == "")
                PageName = node.PageName;
                //else
                //    PageName = skin.PageName;
                if (node.PageParameter == "")
                {
                    res = "/" + PageName;
                }
                else
                {
                    res = "/" + PageName + "?" + node.PageParameter;
                    res = ConvertURL(ParaStr, res, 121, PageName, node.PageParameter);
                }

                break;

            case 122:    //静态地址
                if (node.StaticPageName != "")
                {
                    res = "/" + node.StaticPath + "/" + node.StaticPageName;
                    res = ConvertURL(ParaStr, res, 122, "", "");
                }
                else
                {
                    //没有设置静态参数时按照动态地址发布
                    PageName = node.PageName;
                    if (node.PageParameter == "")
                    {
                        res = "/" + PageName;
                    }
                    else
                    {
                        res = "/" + PageName + "?" + node.PageParameter;
                        res = ConvertURL(ParaStr, res, 121, PageName, node.PageParameter);
                    }
                }
                break;

            case 123:    //伪静态地址
                if (node.StaticPageName != "")
                {
                    res = "/" + node.StaticPath + "/" + node.StaticPageName;
                    res = ConvertURL(ParaStr, res, 123, "", "");
                }
                else
                {
                    //没有设置伪静态参数时按照动态地址发布
                    PageName = node.PageName;
                    if (node.PageParameter == "")
                    {
                        res = "/" + PageName;
                    }
                    else
                    {
                        res = "/" + PageName + "?" + node.PageParameter;
                        res = ConvertURL(ParaStr, res, 121, PageName, node.PageParameter);
                    }
                }
                break;
            }
            //if (ShopCache.GetMainSite().id != site.id && site.Path != "")
            //    res = Site.Instance.WebPath + "/" + site.Path + "/" + lang.Path + "/" + res;
            //else
            res = Site.Instance.WebPath + "/" + lang.Path + "/" + res;
            //else
            //{
            //    lang.Path = lang.Path.Replace(site.Path, "");
            //    res = Site.Instance.WebPath + "/" + lang.Path + "/" + res;
            //}
            Regex r = new Regex(@"//*/", RegexOptions.Singleline);//目的:防止类似“///”“////”“//////”的情况

            res = r.Replace(res, "/");
            //string urlpara = RequestTool.GetConfigKey("URLPara");
            //if (urlpara != "")
            //{
            //    NameValueCollection nv = LB.Tools.CookieTool.GetCookie(urlpara);
            //    if (nv.Count > 0)
            //    {
            //        string str = "";
            //        foreach (string key in nv.Keys)
            //        {
            //            str += "&" + key + "=" + nv.Get(key);
            //        }
            //        if (res.Contains("?"))
            //            res = res + str;
            //        else
            //            res = res + "?" + str.TrimStart('&');
            //    }
            //}
            return(res);
        }