/// <summary> /// 删除模板 /// </summary> public void Theme_Del() { if (!EX_Admin.Power("theme_del", "删除模板")) { EX_Admin.NoPower(); return; } int id = RequestTool.RequestInt("id", 0); Lebi_Theme model = B_Lebi_Theme.GetModel(id); if (model == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } int count = B_Lebi_Language.Counts("Theme_id=" + model.id + ""); if (count > 0) { Response.Write("{\"msg\":\"" + Tag("模板正在使用中,不能删除") + "\"}"); return; } Log.Add("删除模板", "Theme", id.ToString(), CurrentAdmin, model.Name); B_Lebi_Theme.Delete(id); B_Lebi_Theme_Advert.Delete("Theme_id=" + id + ""); B_Lebi_Theme_Skin.Delete("Theme_id=" + id + ""); B_Lebi_Advert.Delete("Theme_id=" + id + ""); Response.Write("{\"msg\":\"OK\"}"); }
/// <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); } } }
protected void Page_Load(object sender, EventArgs e) { if (!EX_Admin.Power("theme_skin_list", "模板页面列表")) { PageReturnMsg = PageNoPowerMsg(); } id = RequestTool.RequestInt("id", 0); key = RequestTool.RequestString("key"); //int tid = RequestTool.RequestInt("tid", 0); theme = B_Lebi_Theme.GetModel(id); if (theme == null) { Response.Write("参数错误"); Response.End(); theme = new Lebi_Theme(); } CheckCode(theme); string where = "IsPage=1 and Theme_id=" + id; if (key != "") { where += " and (Code like lbsql{'%" + key + "%'} or Name like lbsql{'%" + key + "%'} or PageName like lbsql{'%" + key + "%'})"; } ispage = RequestTool.RequestInt("ispage", 2); //if (ispage == 0 || ispage == 1) //{ // where += " and IsPage=" + ispage; //} PageSize = RequestTool.getpageSize(25); models = B_Lebi_Theme_Skin.GetList(where, "Code asc,Sort desc", PageSize, page); int recordCount = B_Lebi_Theme_Skin.Counts(where); PageString = Pager.GetPaginationString("?id=" + theme.id + "&ispage=" + ispage + "&page={0}", page, PageSize, recordCount); }
/// <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 ThemePage_Edit() { int id = RequestTool.RequestInt("id", 0); Lebi_Theme_Page model = B_Lebi_Theme_Page.GetModel(id); if (model == null) { model = new Lebi_Theme_Page(); } B_Lebi_Theme_Page.BindForm(model); //model.Name = Language.RequestString("Name"); model.StaticPath = "/" + model.StaticPath; model.StaticPath = ThemeUrl.CheckURL(model.StaticPath).TrimEnd('/'); if (model.id == 0) { if (!EX_Admin.Power("themepage_add", "添加页面")) { AjaxNoPower(); return; } B_Lebi_Theme_Page.Add(model); id = B_Lebi_Theme_Page.GetMaxId(); string action = Tag("添加页面"); Log.Add(action, "ThemePage", model.id.ToString(), CurrentAdmin); } else { if (!EX_Admin.Power("themepage_edit", "编辑页面")) { AjaxNoPower(); return; } B_Lebi_Theme_Page.Update(model); string action = Tag("编辑页面"); Log.Add(action, "ThemePage", model.id.ToString(), CurrentAdmin); } //更新模板中的生成路径 List <Lebi_Theme_Skin> pages = B_Lebi_Theme_Skin.GetList("Code='" + model.Code + "'", ""); foreach (Lebi_Theme_Skin page in pages) { page.PageName = model.PageName; page.PageParameter = model.PageParameter; page.StaticPageName = model.StaticPageName; B_Lebi_Theme_Skin.Update(page); } //处理静态 ThemeUrl.CreateURLRewrite(); ShopCache.SetThemePage(); Response.Write("{\"msg\":\"OK\",\"id\":\"" + id + "\"}"); }
/// <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 void Theme_Copy() { if (!EX_Admin.Power("theme_edit", "编辑模板")) { AjaxNoPower(); return; } int id = RequestTool.RequestInt("id", 0); Lebi_Theme theme = B_Lebi_Theme.GetModel(id); if (theme == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } string oldfilepath = theme.Path_Files.Clone().ToString(); theme.Code = ""; theme.LebiUser = SYS.LicenseUserName; theme.LebiUser_id = 0; theme.Path_Advert = theme.Path_Advert.Replace(theme.Path_Files, theme.Path_Files + "_[copy]"); theme.Path_CSS = theme.Path_CSS.Replace(theme.Path_Files, theme.Path_Files + "_[copy]"); theme.Path_Image = theme.Path_Image.Replace(theme.Path_Files, theme.Path_Files + "_[copy]"); theme.Path_JS = theme.Path_JS.Replace(theme.Path_Files, theme.Path_Files + "_[copy]"); theme.Path_Files = theme.Path_Files + "_[copy]"; theme.Name = theme.Name + "_[copy]"; theme.Time_Add = System.DateTime.Now; B_Lebi_Theme.Add(theme); theme.id = B_Lebi_Theme.GetMaxId(); theme.Code = SYS.LicenseUserName + "_" + theme.id; B_Lebi_Theme.Update(theme); //复制皮肤 List <Lebi_Theme_Skin> skins = B_Lebi_Theme_Skin.GetList("Theme_id=" + id + "", ""); foreach (Lebi_Theme_Skin skin in skins) { skin.Theme_id = theme.id; B_Lebi_Theme_Skin.Add(skin); } //复制广告位 List <Lebi_Theme_Advert> adverts = B_Lebi_Theme_Advert.GetList("Theme_id=" + id + "", ""); foreach (Lebi_Theme_Advert advert in adverts) { advert.Theme_id = theme.id; B_Lebi_Theme_Advert.Add(advert); int adid = B_Lebi_Theme_Advert.GetMaxId(); //复制广告 List <Lebi_Advert> ads = B_Lebi_Advert.GetList("Theme_Advert_id=" + advert.id + "", ""); foreach (Lebi_Advert ad in ads) { ad.Theme_id = theme.id; ad.Theme_Advert_id = adid; B_Lebi_Advert.Add(ad); } } //============================================== //复制文件 string varFromDirectory = HttpContext.Current.Server.MapPath(@"~/" + oldfilepath); string varToDirectory = HttpContext.Current.Server.MapPath(@"~/" + theme.Path_Files); FileTool.CopyFiles(varFromDirectory, varToDirectory); Response.Write("{\"msg\":\"" + Tag("OK") + "\"}"); }