Пример #1
0
        /// <summary>
        /// 生成帮助中心
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public static bool Greate_Help(Lebi_Theme_Page page)
        {
            string               url;
            Site                 site    = new Site();
            Lebi_Node            pnode   = NodePage.GetNodeByCode("Help");
            List <Lebi_Language> langs   = Language.AllLanguages();
            string               urlpath = "http://" + HttpContext.Current.Request.Url.Authority + site.WebPath;

            foreach (Lebi_Language lang in langs)
            {
                string           path  = lang.Path + "/" + page.StaticPath + "/" + page.StaticPageName;
                string           file  = "";
                List <Lebi_Node> nodes = B_Lebi_Node.GetList("parentid=" + pnode.id + " and Language_Code like '%" + lang.Code + "%'", "");
                foreach (Lebi_Node node in nodes)
                {
                    url  = page.PageName + "?" + page.PageParameter;
                    url  = url.Replace("{0}", node.id.ToString());
                    url  = urlpath + "/" + url;
                    file = path.Replace("{0}", node.id.ToString());
                    file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                    url  = RegexTool.ReplaceRegValue(url, @"{.*?}", "");
                    url  = ThemeUrl.CheckURL(url);
                    HtmlEngine.Instance.CreatHtml(url, file);
                }
            }
            return(true);
        }
Пример #2
0
        /// <summary>
        /// 商品分类页面
        /// </summary>
        public static bool Greate_OnePage(Lebi_Theme_Page page)
        {
            Site site = new Site();
            //Lebi_Theme_Page page = B_Lebi_Theme_Page.GetModel("Code='P_AllProductCategories'");
            string urlpath = "http://" + HttpContext.Current.Request.Url.Authority + site.WebPath;
            string url     = "";
            string file    = "";

            foreach (Lebi_Language lang in Language.AllLanguages())
            {
                string path = lang.Path + "/" + page.StaticPath + "/" + page.StaticPageName;
                url  = page.PageName + "?" + page.PageParameter;
                url  = urlpath + "/" + url;
                file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                url  = RegexTool.ReplaceRegValue(url, @"{.*?}", "");
                url  = ThemeUrl.CheckURL(url);
                HtmlEngine.Instance.CreatHtml(url, file);
            }
            return(true);
        }
Пример #3
0
 public string MenuUrl(string url, int t)
 {
     if (url.IndexOf("http") == 0)
     {
         return(url);
     }
     url = site.AdminPath + "/" + url;
     if (t == 1)
     {
         if (url.Contains("?"))
         {
             url = url + "&desk=1";
         }
         else
         {
             url = url + "?desk=1";
         }
     }
     url = ThemeUrl.CheckURL(url);
     return(url);
 }
Пример #4
0
        /// <summary>
        /// 关于我们页面/新闻/文章
        /// </summary>
        public static bool Greate_InfoPage(Lebi_Page model, Lebi_Theme_Page page)
        {
            Site site = new Site();

            string[] langcodes = model.Language.Split(',');
            string   urlpath   = "http://" + HttpContext.Current.Request.Url.Authority + site.WebPath;
            string   url       = "";
            string   file      = "";

            foreach (string langcode in langcodes)
            {
                Lebi_Language lang = B_Lebi_Language.GetModel("Code='" + langcode + "'");
                string        path = lang.Path + "/" + page.StaticPath + "/" + page.StaticPageName;
                url  = page.PageName + "?" + page.PageParameter;
                url  = url.Replace("{0}", model.id.ToString());
                url  = urlpath + "/" + url;
                file = path.Replace("{0}", model.id.ToString());
                file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                url  = RegexTool.ReplaceRegValue(url, @"{.*?}", "");
                url  = ThemeUrl.CheckURL(url);
                HtmlEngine.Instance.CreatHtml(url, file);
            }
            return(true);
        }
Пример #5
0
        /// <summary>
        /// 生成地址重写规则
        /// </summary>
        public static void CreateURLRewrite()
        {
            StringBuilder sb  = new StringBuilder();
            StringBuilder sb1 = new StringBuilder();

            sb.AppendLine("[ISAPI_Rewrite]");
            sb1.AppendLine("RewriteEngine On");
            sb1.AppendLine("RewriteCompatibility2 On");
            sb1.AppendLine("RepeatLimit 200");
            sb1.AppendLine("RewriteBase");

            List <Lebi_Language>   langs  = B_Lebi_Language.GetList("", "Sort desc,id asc");
            List <Lebi_Theme_Page> models = B_Lebi_Theme_Page.GetList("Type_id_PublishType=123", "");
            string str1     = "";
            string str2     = "";
            string language = "";

            foreach (Lebi_Theme_Page model in models)
            {
                if (model.PageParameter == "")
                {
                    str1 = model.PageName;
                    str2 = model.StaticPath + "/" + model.StaticPageName;
                    str2 = ThemeUrl.CheckURL(str2);
                    str1 = str1.Trim('/');
                    str2 = str2.Trim('/');
                    str1 = str1.Replace(".", @"\.");
                    str2 = str2.Replace(".", @"\.");
                    foreach (Lebi_Language lang in langs)
                    {
                        Lebi_Site site = B_Lebi_Site.GetModel(lang.Site_id);
                        if (site == null)
                        {
                            site = new Lebi_Site();
                        }
                        language = site.Path + lang.Path.TrimEnd('/');
                        language = language.Replace("//", "/");
                        if (language == "")
                        {
                            continue;
                        }
                        sb.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*) /$1" + language + "/" + str1 + " [N,I]");
                        sb1.AppendLine(@"RewriteRule " + language + "/" + str2 + "(.*)$ " + language + "/" + str1 + " [NC,N]");
                    }
                    sb.AppendLine(@"RewriteRule /(.*)" + str2 + "(.*) /$1" + str1 + " [N,I]");
                    sb1.AppendLine(@"RewriteRule /" + str2 + "(.*)$ /" + str1 + " [NC,N]");
                    //RewriteRule /CN/(.*)$ /CN/Basket\.aspx\?Basket\.html$1 [NC,N]
                    //RewriteRule /(.*)$ /Basket\.aspx\?Basket\.html$1 [NC,N]
                }
                else
                {
                    str1 = model.PageName + @"\?" + model.PageParameter;
                    str2 = model.StaticPath + "/" + model.StaticPageName;
                    str2 = ThemeUrl.CheckURL(str2);
                    str1 = str1.Trim('/');
                    str2 = str2.Trim('/');
                    str1 = str1.Replace(".", @"\.");
                    str2 = str2.Replace(".", @"\.");
                    str1 = RegexTool.ReplaceRegValue(str1, @"{\d+}", ",");
                    str2 = RegexTool.ReplaceRegValue(str2, @"{\d+}", "(.*)");
                    string[] arr     = str1.Split(',');
                    int      j       = 1;
                    string   str_ini = "";
                    string   str_hta = "";
                    foreach (string ar in arr)
                    {
                        if (ar != "")
                        {
                            str_hta += ar + "$" + j;
                        }
                        j++;
                        if (ar != "")
                        {
                            str_ini += ar + "$" + j;
                        }
                    }
                    foreach (Lebi_Language lang in langs)
                    {
                        Lebi_Site site = B_Lebi_Site.GetModel(lang.Site_id);
                        if (site == null)
                        {
                            site = new Lebi_Site();
                        }
                        language = site.Path + lang.Path.TrimEnd('/');
                        language = language.Replace("//", "/");
                        if (language == "")
                        {
                            continue;
                        }
                        sb.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*) /$1" + language + "/" + str_ini + " [N,I]");
                        sb1.AppendLine(@"RewriteRule " + language + "/" + str2 + "(.*)$ " + language + "/" + str_hta + " [NC,N]");
                    }
                    sb.AppendLine(@"RewriteRule /(.*)" + str2 + "(.*) /$1" + str_ini + " [N,I]");
                    sb1.AppendLine(@"RewriteRule /" + str2 + "(.*)$ /" + str_hta + " [NC,N]");
                }
            }
            //生成商品分类重写规则
            List <Lebi_Pro_Type> tps   = B_Lebi_Pro_Type.GetList("", "");
            Lebi_Theme_Page      tpage = B_Lebi_Theme_Page.GetModel("Code='P_ProductCategory'");

            str1 = tpage.PageName + @"\?" + tpage.PageParameter;
            str1 = str1.Trim('/');
            str1 = str1.Replace(".", @"\.");
            str1 = RegexTool.ReplaceRegValue(str1, @"{\d+}", ",");
            string[] arr1     = str1.Split(',');
            string   str_ini1 = "";
            string   str_hta1 = "";

            //foreach (string ar in arr1)
            //{
            //    if (ar != "")
            //        str_hta1 += ar + "$" + j1;
            //    j1++;
            //    if (ar != "")
            //        str_ini1 += ar + "$" + j1;

            //}

            foreach (Lebi_Pro_Type tp in tps)
            {
                str_hta1 = arr1[0] + tp.id;
                str_ini1 = arr1[0] + tp.id;
                foreach (Lebi_Language lang in langs)
                {
                    if (Language.Content(tp.IsUrlrewrite, lang.Code) != "1")
                    {
                        continue;
                    }
                    str2 = Language.Content(tp.Url, lang.Code);
                    if (str2 == "")
                    {
                        continue;
                    }



                    str2 = ThemeUrl.CheckURL(str2);
                    str2 = str2.Trim('/');
                    str2 = str2.Replace(".", @"\.");
                    str2 = RegexTool.ReplaceRegValue(str2, @"{\d+}", "(.*)");


                    Lebi_Site site = B_Lebi_Site.GetModel(lang.Site_id);
                    if (site == null)
                    {
                        site = new Lebi_Site();
                    }
                    language = site.Path + lang.Path.TrimEnd('/');
                    language = language.Replace("//", "/");
                    language = language.TrimEnd('/');
                    sb.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*) /$1" + language + "/" + str_ini1 + " [N,I]");
                    sb1.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*)$ /$1" + language + "/" + str_hta1 + " [NC,N]");
                }
            }
            HtmlEngine save = new HtmlEngine();

            save.CreateFile("httpd.ini", sb.ToString(), "ascii");
            save.CreateFile(".htaccess", sb1.ToString(), "ascii");
            CreateURLRewrite_shop();
        }
Пример #6
0
 /// <summary>
 /// 返回图片的显示路径
 /// </summary>
 /// <param name="img"></param>
 /// <returns></returns>
 public string GetImage(string img)
 {
     img = WebPath + "/" + img;
     img = ThemeUrl.CheckURL(img);
     return(img);
 }
Пример #7
0
 /// <summary>
 /// 返回相应主题的跳转地址
 /// </summary>
 /// <param name="url"></param>
 /// <returns></returns>
 public string JumpURL(string url)
 {
     url = "/" + CurrentLanguage.Path + "/" + url;
     url = ThemeUrl.CheckURL(url);
     return(url);
 }