Exemplo n.º 1
0
        /// <summary>
        /// 语言名称
        /// </summary>
        /// <param name="siteid"></param>
        /// <returns></returns>
        public string LanguageName(string langids)
        {
            if (langids == "")
            {
                return("");
            }
            string           res   = "";
            List <Lebi_Site> sites = Shop.Bussiness.Site.Instance.Sites();

            foreach (Lebi_Site site in sites)
            {
                List <Lebi_Language> langs = B_Lebi_Language.GetList("Site_id=" + site.id + " and id in (" + langids + ")", "");
                if (langs.Count > 0)
                {
                    if (sites.Count > 1)
                    {
                        if (res == "")
                        {
                            res = site.SubName + ":";
                        }
                        else
                        {
                            res += "|" + site.SubName + ":";
                        }
                    }
                    foreach (Lebi_Language lang in langs)
                    {
                        res += lang.Code + " ";
                    }
                }
            }
            return(res);
        }
Exemplo n.º 2
0
        public static string SiteLanguageOption(string Code, string LanuageCode)
        {
            Site             sitem = new Site();
            List <Lebi_Site> sites = B_Lebi_Site.GetList("", "Sort desc", sitem.SiteCount, 1);
            string           str   = "";

            foreach (Lebi_Site site in sites)
            {
                List <Lebi_Language> models = B_Lebi_Language.GetList("Site_id=" + site.id + "", "");
                foreach (Lebi_Language model in models)
                {
                    string sel = "";
                    if (Code == model.Code)
                    {
                        sel = "selected";
                    }
                    string oname = model.Name;
                    if (sitem.SiteCount > 1)
                    {
                        oname = model.Name + "[" + Content(site.Name, LanuageCode) + "]";
                    }
                    str += "<option value=\"" + model.id + "\" " + sel + ">" + oname + "</option>";
                }
            }
            return(str);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 后台编辑页面语言切换标签
        /// </summary>
        /// <param name="sel"></param>
        /// <param name="ex"></param>
        /// <param name="href"></param>
        /// <returns></returns>
        public static string AdminLanguageTab(int siteid, string ex, string href)
        {
            List <Lebi_Language> models = B_Lebi_Language.GetList("Site_id=" + siteid + "", "");
            string str  = "<ul class=\"tablist languagetab\">";
            Site   site = new Site();

            foreach (Lebi_Language model in models)
            {
                string s = "";
                str += "<li id=\"li_" + model.Code + "\" " + s + " onclick=\"LanguageTab_EditPage('" + model.Code + "')\">";
                str += "<a><span>";
                if (model.ImageUrl != "")
                {
                    str += "<em><img src=\"" + site.WebPath + model.ImageUrl + "\" /></em>";
                    str += "<strong>" + model.Name + "</strong>";
                }
                else
                {
                    str += "" + model.Name + "";
                }
                str += "</span></a></li>";
            }
            str += "<li onclick=\"" + href + "\">";
            str += "<a ><span>";
            str += "" + ex + "";
            str += "</span></a></li>";
            str += "</ul>";
            return(str);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 载入主题
 /// </summary>
 /// <param name="code"></param>
 public void LoadTheme(string tcode, string pcode)
 {
     CurrentTheme_              = B_Lebi_Theme.GetList("Code='" + tcode + "'", "").FirstOrDefault();
     CurrentLanguage_           = B_Lebi_Language.GetList("Code='" + CurrentTheme.Language + "'", "").FirstOrDefault();
     Session["CurrentTheme"]    = CurrentTheme_;//session主要是为那些没有LoadTheme方法的页面服务的,如ajax
     Session["CurrentLanguage"] = CurrentLanguage_;
     CurrentPage = B_Lebi_Theme_Page.GetModel("Code='" + pcode + "'");
 }
Exemplo n.º 5
0
        /// <summary>
        /// 站点语言
        /// </summary>
        /// <param name="InputName"></param>
        /// <param name="Code"></param>
        /// <returns></returns>
        public static string SiteLanguageCheckbox(string InputName, string Code, string languagecode, Lebi_Administrator admin = null)
        {
            string where = "";
            if (admin != null)
            {
                if (admin.Site_ids != "" && Site.Instance.SiteCount > 1)
                {
                    where = "id in (" + admin.Site_ids + ")";
                }
            }
            List <Lebi_Site> sites = B_Lebi_Site.GetList(where, "Sort desc", Site.Instance.SiteCount, 1);
            string           str   = "";

            Code = "," + Code + ",";
            foreach (Lebi_Site site in sites)
            {
                if (Site.Instance.SiteCount > 1)
                {
                    if (!string.IsNullOrEmpty(RequestTool.GetConfigKey("SystemAdmin").Trim()))
                    {
                        str += "<div class=\"col-sm-12\"><div class=\"row\"><div class=\"input-group\"><label for=\"\">" + site.SubName + ":</label>";
                    }
                    else
                    {
                        if (str == "")
                        {
                            str = site.SubName + ":";
                        }
                        else
                        {
                            str += "<br/>" + site.SubName + ":";
                        }
                    }
                }
                List <Lebi_Language> models = B_Lebi_Language.GetList("Site_id=" + site.id + "", "");
                foreach (Lebi_Language model in models)
                {
                    string sel = "";
                    if (Code.Contains("," + model.id + ","))
                    {
                        sel = "checked";
                    }
                    if (!string.IsNullOrEmpty(RequestTool.GetConfigKey("SystemAdmin").Trim()))
                    {
                        str += "<label class=\"custom-control custom-checkbox m-r-20\"><input type=\"checkbox\" id=\"" + InputName + "" + model.id + "\" name=\"" + InputName + "\" value=\"" + model.id + "\" class=\"custom-control-input\" shop=\"true\" " + sel + "><span class=\"custom-control-label\">" + model.Name + "</span></label>";
                    }
                    else
                    {
                        str += "<input type=\"checkbox\" name=\"" + InputName + "\" id=\"" + InputName + "" + model.id + "\" shop=\"true\" value=\"" + model.id + "\" " + sel + "><label for=\"" + InputName + "" + model.id + "\">" + model.Name + "</label>";
                    }
                }
                if (!string.IsNullOrEmpty(RequestTool.GetConfigKey("SystemAdmin").Trim()))
                {
                    str += "</div></div></div>";
                }
            }
            return(str);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 站点语言
        /// </summary>
        /// <param name="InputName"></param>
        /// <param name="Code"></param>
        /// <returns></returns>
        public static string SiteLanguageCheckbox(string InputName, string Code, string languagecode, Lebi_Administrator admin = null)
        {
            string where = "";
            if (admin != null)
            {
                if (admin.Site_ids != "" && Site.Instance.SiteCount > 1)
                {
                    where = "id in (" + admin.Site_ids + ")";
                }
            }
            List <Lebi_Site> sites = B_Lebi_Site.GetList(where, "Sort desc", Site.Instance.SiteCount, 1);
            string           str   = "";

            Code = "," + Code + ",";
            foreach (Lebi_Site site in sites)
            {
                if (Site.Instance.SiteCount > 1)
                {
                    if (str == "")
                    {
                        str = site.SubName + ":";
                    }
                    else
                    {
                        str += "<br/>" + site.SubName + ":";
                    }
                }
                List <Lebi_Language> models = B_Lebi_Language.GetList("Site_id=" + site.id + "", "");
                foreach (Lebi_Language model in models)
                {
                    string sel = "";
                    if (Code.Contains("," + model.id + ","))
                    {
                        sel = "checked";
                    }
                    str += "<label><input type=\"checkbox\" name=\"" + InputName + "\" id=\"" + InputName + "\" shop=\"true\" value=\"" + model.id + "\" " + sel + ">" + model.Name + "</label>&nbsp;";
                }
            }
            return(str);
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
0
        /// <summary>
        /// 根据主题重新设置系统图片尺寸
        /// </summary>
        public static void UpdteImageSize()
        {
            BaseConfig           mx    = ShopCache.GetBaseConfig();
            List <Lebi_Language> langs = B_Lebi_Language.GetList("", "");
            Lebi_ImageSize       model;

            string ids = "0";

            //检查系统默认的规格
            model = B_Lebi_ImageSize.GetModel("Width=" + mx.ImageBigWidth + " and Height=" + mx.ImageBigHeight + "");
            if (model == null)
            {
                model        = new Lebi_ImageSize();
                model.Width  = mx.ImageBigWidth;
                model.Height = mx.ImageBigHeight;
                B_Lebi_ImageSize.Add(model);
                ids += "," + B_Lebi_ImageSize.GetMaxId();
            }
            else
            {
                ids += "," + model.id;
            }
            model = B_Lebi_ImageSize.GetModel("Width=" + mx.ImageMediumWidth + " and Height=" + mx.ImageMediumHeight + "");
            if (model == null)
            {
                model        = new Lebi_ImageSize();
                model.Width  = mx.ImageMediumWidth;
                model.Height = mx.ImageMediumHeight;
                B_Lebi_ImageSize.Add(model);
                ids += "," + B_Lebi_ImageSize.GetMaxId();
            }
            else
            {
                ids += "," + model.id;
            }
            model = B_Lebi_ImageSize.GetModel("Width=" + mx.ImageSmallWidth + " and Height=" + mx.ImageSmallHeight + "");
            if (model == null)
            {
                model        = new Lebi_ImageSize();
                model.Width  = mx.ImageSmallWidth;
                model.Height = mx.ImageSmallHeight;
                B_Lebi_ImageSize.Add(model);
                ids += "," + B_Lebi_ImageSize.GetMaxId();
            }
            else
            {
                ids += "," + model.id;
            }
            foreach (Lebi_Language lang in langs)
            {
                Lebi_Theme theme = B_Lebi_Theme.GetModel(lang.Theme_id);
                if (theme == null)
                {
                    continue;
                }
                //model = B_Lebi_ImageSize.GetModel("Width=" + theme.ImageBig_Width + " and Height=" + theme.ImageBig_Height + "");
                //if (model == null)
                //{
                //    model = new Lebi_ImageSize();
                //    model.Width = theme.ImageBig_Width;
                //    model.Height = theme.ImageBig_Height;
                //    B_Lebi_ImageSize.Add(model);
                //    ids += "," + B_Lebi_ImageSize.GetMaxId();
                //}
                //else
                //{
                //    ids += "," + model.id;
                //}
                model = B_Lebi_ImageSize.GetModel("Width=" + theme.ImageMedium_Width + " and Height=" + theme.ImageMedium_Height + "");
                if (model == null)
                {
                    model        = new Lebi_ImageSize();
                    model.Width  = theme.ImageMedium_Width;
                    model.Height = theme.ImageMedium_Height;
                    B_Lebi_ImageSize.Add(model);
                    ids += "," + B_Lebi_ImageSize.GetMaxId();
                }
                else
                {
                    ids += "," + model.id;
                }
                //model = B_Lebi_ImageSize.GetModel("Width=" + theme.ImageSmall_Width + " and Height=" + theme.ImageSmall_Height + "");
                //if (model == null)
                //{
                //    model = new Lebi_ImageSize();
                //    model.Width = theme.ImageSmall_Width;
                //    model.Height = theme.ImageSmall_Height;
                //    B_Lebi_ImageSize.Add(model);
                //    ids += "," + B_Lebi_ImageSize.GetMaxId();
                //}
                //else
                //{
                //    ids += "," + model.id;
                //}
            }
            B_Lebi_ImageSize.Delete("id not in (" + ids + ")");
        }
Exemplo n.º 9
0
        /// <summary>
        /// 返回站点语言
        /// </summary>
        /// <param name="siteid"></param>
        /// <returns></returns>
        public static List <Lebi_Language> SiteLanguages(int siteid)
        {
            List <Lebi_Language> tmodels = B_Lebi_Language.GetList("Site_id=" + siteid + "", "Sort desc");

            return(tmodels);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 返回用户的语种
        /// </summary>
        /// <returns></returns>
        public static List <Lebi_Language> AllLanguages()
        {
            List <Lebi_Language> tmodels = B_Lebi_Language.GetList("", "Sort desc");

            return(tmodels);
        }