/// <summary> /// 检查模板的页面与结点是否相符 /// </summary> /// <param name="tid"></param> private void CheckCode(Lebi_Theme theme) { //Lebi_Theme theme = B_Lebi_Theme.GetModel(tid); List <Lebi_Theme_Page> nodes = B_Lebi_Theme_Page.GetList("", ""); foreach (Lebi_Theme_Page node in nodes) { if (node.Code == "") { continue; } Lebi_Theme_Skin skin = B_Lebi_Theme_Skin.GetList("Theme_id=" + theme.id + " and Code='" + node.Code + "' and IsPage=1", "").FirstOrDefault(); if (skin == null) { skin = new Lebi_Theme_Skin(); skin.Code = node.Code; skin.IsPage = 1; skin.Name = Language.Content(node.Name, "CN"); skin.PageName = node.PageName; skin.PageParameter = node.PageParameter; skin.Path_Skin = node.PageName.Replace("aspx", "html"); //skin.Path_Create = node.pat skin.Sort = 0; skin.StaticPageName = node.StaticPageName; skin.Theme_id = theme.id; B_Lebi_Theme_Skin.Add(skin); } } }
/// <summary> /// /// </summary> /// <param name="theme"></param> /// <param name="skin"></param> /// <returns></returns> private string GetSkinStr(Lebi_Theme theme, Lebi_Theme_Skin skin) { string str = ""; string path = theme.Path_Files + "/" + skin.Path_Skin; path = ThemeUrl.GetFullPath(path); str = HtmlEngine.ReadTxt(path); return(str); }
/// <summary> /// 生成页面皮肤 /// 针对单个皮肤生成的情况 /// </summary> /// <returns></returns> public void CreateSkin() { string Msg = ""; int ThemeID = 0; int SkinID = 0; string Content = ""; string SkinPath = ""; //皮肤路径 string Path = ""; //输入Path要包含路径及文件名 SkinID = RequestTool.RequestInt("id", 0); Lebi_Theme_Skin skin = B_Lebi_Theme_Skin.GetModel(SkinID); Lebi_Theme theme; if (skin == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } ThemeID = skin.Theme_id; theme = B_Lebi_Theme.GetModel(ThemeID); SkinPath = theme.Path_Files + "/" + skin.Path_Skin; SkinPath = ThemeUrl.GetFullPath(SkinPath); Content = HtmlEngine.ReadTxt(SkinPath); List <Lebi_Language> langs = B_Lebi_Language.GetList("Theme_id=" + theme.id + "", ""); if (langs.Count == 0) { Response.Write("{\"msg\":\"" + Tag("请在站点语言设置中关联此模板") + "\"}"); return; } Site site = new Site(); foreach (Lebi_Language lang in langs) { if (lang.Theme_id != ThemeID) { continue; } Lebi_Site s = B_Lebi_Site.GetModel(lang.Site_id); if (s == null) { Path = lang.Path + "/" + skin.PageName; } else { Path = s.Path + lang.Path + "/" + skin.PageName; } Msg = Shop.Bussiness.Theme.CreatAspx(s, lang, theme, skin, Path, Content); } Response.Write("{\"msg\":\"" + Msg + "\"}"); }
/// <summary> /// 编辑模板-页面 /// </summary> public void Skin_Edit() { if (RequestTool.GetConfigKey("OnlineFileEdit").Trim() != "1") { AjaxNoPower(); return; } int id = RequestTool.RequestInt("id", 0); Lebi_Theme_Skin model = B_Lebi_Theme_Skin.GetModel(id); if (model == null) { model = new Lebi_Theme_Skin(); } B_Lebi_Theme_Skin.BindForm(model); //if (model.IsPage == 1) // model.Code = ""; if (model.id == 0) { if (!EX_Admin.Power("theme_skin_add", "添加模板页面")) { AjaxNoPower(); return; } B_Lebi_Theme_Skin.Add(model); id = B_Lebi_Theme_Skin.GetMaxId(); Log.Add("添加模板-页面", "Theme_Skin", id.ToString(), CurrentAdmin, model.Name); } else { if (!EX_Admin.Power("theme_skin_edit", "编辑模板页面")) { AjaxNoPower(); return; } B_Lebi_Theme_Skin.Update(model); Log.Add("编辑模板-页面", "Theme_Skin", id.ToString(), CurrentAdmin, model.Name); } //生成页面 string SkinContent = Request["SkinContent"]; if (SkinContent != "" && model.Path_Skin != "") //如果模板内容为空则不生成页面 by lebi.kingdge 2015-02-25 { Lebi_Theme theme = B_Lebi_Theme.GetModel(model.Theme_id); string SkinPath = theme.Path_Files + "/" + model.Path_Skin; GreatSkin(SkinPath, SkinContent); } string result = "{\"msg\":\"OK\", \"id\":\"" + id + "\"}"; Response.Write(result); }
protected void Page_Load(object sender, EventArgs e) { int tid = RequestTool.RequestInt("tid", 0); int id = RequestTool.RequestInt("id", 0); if (RequestTool.GetConfigKey("OnlineFileEdit").Trim() != "1") { PageReturnMsg = PageNoEditMsg(); } if (id == 0) { if (!EX_Admin.Power("theme_skin_add", "添加模板页面")) { PageReturnMsg = PageNoPowerMsg(); } } else { if (!EX_Admin.Power("theme_skin_edit", "编辑模板页面")) { PageReturnMsg = PageNoPowerMsg(); } } model = B_Lebi_Theme_Skin.GetModel(id); if (model != null) { tid = model.Theme_id; } else { model = new Lebi_Theme_Skin(); } theme = B_Lebi_Theme.GetModel(tid); if (theme == null) { theme = new Lebi_Theme(); } SkinContent = GetSkinStr(theme, model); tpage = B_Lebi_Theme_Page.GetModel("Code='" + model.Code + "'"); if (tpage == null) { tpage = new Lebi_Theme_Page(); model.IsPage = 1; } }
/// <summary> /// 删除模板-页面 /// </summary> public void Skin_Del() { if (!EX_Admin.Power("theme_skin_del", "删除模板页面")) { AjaxNoPower(); return; } if (RequestTool.GetConfigKey("OnlineFileEdit").Trim() != "1") { AjaxNoPower(); return; } int id = RequestTool.RequestInt("id", 0); Lebi_Theme_Skin model = B_Lebi_Theme_Skin.GetModel(id); if (model == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } Log.Add("删除模板-页面", "Theme_Skin", id.ToString(), CurrentAdmin, model.Name); B_Lebi_Theme_Skin.Delete(id); Response.Write("{\"msg\":\"OK\"}"); }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_Theme_Skin model) { D_Lebi_Theme_Skin.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Theme_Skin model) { return(D_Lebi_Theme_Skin.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Theme_Skin SafeBindForm(Lebi_Theme_Skin model) { return(D_Lebi_Theme_Skin.Instance.SafeBindForm(model)); }
/// <summary> /// 执行代码替换 /// 在${...}$内 /// </summary> /// <param name="strIn"></param> /// <returns></returns> public static string DoCodeConvert(string strIn, string type, string webpath, string mediapath) { strIn = DoLayout(strIn, type, webpath, mediapath); //====================================================== string[] PartArry = RegexTool.GetSimpleRegResultArray(strIn, @"({[Mm][Oo][Dd]:.*?})"); string partTag = ""; string partConten = ""; string partPara = ""; webpath = webpath.TrimEnd('/'); Lebi_Theme_Skin partskin = new Lebi_Theme_Skin(); foreach (string partStr in PartArry) { partTag = ""; partConten = ""; partPara = ""; if (partStr.Contains("(")) { partTag = RegexTool.GetRegValue(partStr, @"{[Mm][Oo][Dd]:(.*?)\(.*?}"); partPara = RegexTool.GetRegValue(partStr, @"{[Mm][Oo][Dd]:.*?\((.*?)\)}"); } else { partTag = RegexTool.GetRegValue(partStr, @"{[Mm][Oo][Dd]:(.*?)}"); } if (partTag != "") { //模块提取优先级 //1插件中的BLOCK文件夹 //2模板中的自定义设置 //3系统块 string[] plugins = ShopCache.GetBaseConfig().PluginUsed.ToLower().Split(','); foreach (string plugin in plugins) { partConten = HtmlEngine.ReadTxt(webpath + "/plugin/" + plugin + "/systempage/" + type + "/block/" + partTag + ".html"); if (partConten == "") { partConten = HtmlEngine.ReadTxt(webpath + "/plugin/" + plugin + "/block/" + partTag + ".html"); } if (partConten != "") { break; } } if (partConten == "") { partConten = HtmlEngine.ReadTxt(ThemeUrl.GetFullPath(webpath + "/system/" + type + "/block/" + partTag + ".html")); } if (partConten == "") { partConten = HtmlEngine.ReadTxt(ThemeUrl.GetFullPath(webpath + "/system/block/" + partTag + ".html")); } if (partConten != "") { partConten = "<!--MOD_start:" + partTag + "-->\r\n" + DoCodeConvert(partConten, type, webpath, "") + "<!--MOD_end:" + partTag + "-->\r\n"; strIn = RegexTool.ReplaceRegValue(strIn, @"{[Mm][Oo][Dd]:" + partTag + ".*?}", partConten); } } } //========================================================= string str = ""; Type t = typeof(ShopPage); string temp = ""; int[,] d = IndexFlagArry(strIn);//记录开始,结尾标记的数组 if (d.Length > 0) { int begin = 0; string[,] tempArry = new string[d.GetUpperBound(0) + 1, 2];//用于存放一个外层标记的临时数组 for (int i = 0; i < d.GetUpperBound(0); i++) { temp += RegexTool.GetSubString(strIn, begin, d[i, 0]) + "$$$" + i + "$$$";//挑选非标记部组合,将标记部分替换为$$$0$$$,$$$1$$$形式 begin = d[i, 1] + 2; tempArry[i, 0] = "$$$" + i + "$$$"; tempArry[i, 1] = RegexTool.GetSubString(strIn, d[i, 0] + 2, d[i, 1]);//截取不包含开始,结尾标记的块 } temp += RegexTool.GetSubString(strIn, begin, strIn.Length); str = temp;//str已经替除了全部的标记块 for (int i = 0; i < tempArry.GetUpperBound(0); i++) { temp = DoPart(tempArry[i, 1], type, webpath); str = str.Replace("$$$" + i + "$$$", temp); } } return(str); }
/// <summary> /// 绑定表单数据 /// </summary> public static Lebi_Theme_Skin BindForm(Lebi_Theme_Skin model) { return D_Lebi_Theme_Skin.Instance.BindForm(model); }
/// <summary> /// 载入主题 /// </summary> /// <param name="themecode"></param> /// <param name="siteid"></param> /// <param name="languagecode"></param> /// <param name="pcode"></param> /// <param name="checklogin">是否检查用户登录</param> public void LoadTheme(string themecode, int siteid, string languagecode, string pcode, bool checklogin) { CurrentSite_ = B_Lebi_Site.GetModel(siteid); if (ShopCache.GetMainSite().id == CurrentSite_.id || CurrentSite_.Domain == "") { IsMainSite = true; } CurrentLanguage_ = B_Lebi_Language.GetModel("Code='" + languagecode + "' and Site_id=" + siteid + ""); if (CurrentLanguage_ == null) { CurrentLanguage_ = new Lebi_Language(); } if (IsMainSite) { CurrentLanguage_.Path = (CurrentSite_.Path + CurrentLanguage_.Path).Replace("//", "/").TrimEnd('/'); } if (checklogin) { if (CurrentUser.id == 0 || CurrentUser.IsAnonymous == 1) { HttpContext.Current.Response.Redirect(URL("P_Login", "" + HttpUtility.UrlEncode(RequestTool.GetRequestUrlNonDomain()) + "," + GetUrlToken(RequestTool.GetRequestUrlNonDomain()) + "")); } } CurrentTheme_ = B_Lebi_Theme.GetModel("Code='" + themecode + "'"); CurrentPage = B_Lebi_Theme_Page.GetModel("Code='" + pcode + "'"); if (CurrentTheme_ == null) { CurrentTheme_ = new Lebi_Theme(); } Lebi_Theme_Skin skin = B_Lebi_Theme_Skin.GetModel("Theme_id=" + CurrentTheme_.id + " and Code='" + pcode + "'"); if (skin != null) { if (skin.PageSize > 0) { PageSize = skin.PageSize; } } if (CurrentSite_ != null) { SYS.Copyright = CurrentSite_.Copyright; SYS.Domain = CurrentSite_.Domain; SYS.Email = CurrentSite_.Email; SYS.Fax = CurrentSite_.Fax; SYS.Keywords = CurrentSite_.Keywords; SYS.Logoimg = CurrentSite_.Logoimg; SYS.Description = CurrentSite_.Description; SYS.Phone = CurrentSite_.Phone; SYS.QQ = CurrentSite_.QQ; SYS.ServiceP = CurrentSite_.ServiceP; SYS.Name = CurrentSite_.Name; SYS.Title = CurrentSite_.Title; SYS.FootHtml = CurrentSite_.FootHtml; SYS.TopAreaid = CurrentLanguage_.TopAreaid.ToString(); } LBTITLE = ""; LBTITLE += " - Powered by LebiShop"; //底部版权信息 //if (CurrentPage != null) //{ // StringBuilder sb = new StringBuilder(); // sb.Append("Powered by <a style=\"font-size:12px;color:#00497f\" href=\"http://www.lebi.cn\" target=\"_blank\" title=\"LebiShop多语言网上商店系统\">LebiShop</a> "); // sb.Append("V" + SYS.Version + "." + SYS.Version_Son); // try // { // Label label = (Label)this.Page.FindControl("LeBiLicense"); // label.Text = sb.ToString(); // } // catch (System.NullReferenceException) // { // Response.Write("<div style=\"height:100px;padding-top:10px;text-align:left;font-size:12;\">内部错误,请到【配置】=》【站点语言】栏目中重新生成网站<br>"); // Response.Write(sb.ToString() + "</div>"); // Response.End(); // } //} Session["CurrentTheme"] = CurrentTheme_;//session主要是为那些没有LoadTheme方法的页面服务的,如ajax Session["CurrentLanguage"] = CurrentLanguage_; Session["CurrentSite"] = CurrentSite_; //写入cookie NameValueCollection nvs = new NameValueCollection(); nvs.Add("theme", CurrentTheme_.Code); nvs.Add("language", CurrentLanguage_.Code); nvs.Add("site", CurrentSite_.id.ToString()); CookieTool.WriteCookie("ThemeStatus", nvs, 10); //多站点商品显示 if (Shop.Bussiness.Site.Instance.SiteCount > 1) { //if (Shop.LebiAPI.Service.Instanse.Check("domain3admin")) //{ if (DataBase.DBType == "sqlserver") { ProductWhere = "(Charindex('," + CurrentSite_.id + ",',','+Site_ids+',')>0 or Site_ids='') and Product_id = 0 and Type_id_ProductStatus = 101"; ProductCategoryWhere = "(Charindex('," + CurrentSite_.id + ",',','+Site_ids+',')>0 or Site_ids='')"; } if (DataBase.DBType == "access") { ProductWhere = "(Instr(','+Site_ids+',','," + CurrentSite_.id + ",')>0 or Site_ids='') and Product_id = 0 and Type_id_ProductStatus = 101"; ProductCategoryWhere = "(Instr(','+Site_ids+',','," + CurrentSite_.id + ",')>0 or Site_ids='')"; } //} //else //{ // ProductWhere = "Product_id = 0 and Type_id_ProductStatus = 101"; //} } else { ProductWhere = "Product_id = 0 and Type_id_ProductStatus = 101"; ProductCategoryWhere = "1=1"; } //ProductWhere += " and (UserLevel_ids_show='' or UserLevel_ids_show is null or ','+UserLevel_ids_show+',' like '%," + CurrentUserLevel.id + ",%' )"; ProductWhere += " and (IsDel!=1 or IsDel is null)"; }