/// <summary> /// 附件列表 /// </summary> /// <returns>附件列表区域</returns> public string List() { StringBuilder sr = new StringBuilder(); AttachmentData attData = new AttachmentData(conn); if (SiteFun.IsPost) { int id = SiteFun.ToInt(SiteFun.Post("id")); try { AttachmentItem delAttInfo = attData.GetAttachment(id); if (File.Exists(Path.Combine(SiteCfg.Router, delAttInfo.Path))) { File.Delete(Path.Combine(SiteCfg.Router, delAttInfo.Path)); } attData.DeleteAttachment(id); sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgDelFile"))); } catch (Exception err) { sr.Append(AdminUI.ErrorBox(err.Message)); } } sr.Append(AdminUI.AdminBoxStart(true)); sr.Append(HtmlUI.TableStart()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("FileName"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("FileType"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Size"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("DateTime"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Operate"))); sr.Append(HtmlUI.TrFinal()); //下面三行是分页设置 int page = SiteFun.ToInt(SiteFun.Query("page")); if (page < 1) { page = 1; } int pageSize = 20; DataList<AttachmentItem> list = attData.SelectAttachment(page, pageSize); int i = 1; foreach (AttachmentItem vItem in list) { i++; FileInfo fileInfo = new FileInfo(Path.Combine(SiteCfg.Router, vItem.Path)); sr.Append(HtmlUI.FormStart()); sr.Append(HtmlUI.TrStart(i % 2 == 0 ? " cRow" : null)); if (fileInfo.Exists) { sr.Append(HtmlUI.CreateTd(HtmlUI.Image("Common/Images/FileType/" + (fileInfo.Length > 1 ? fileInfo.Extension.Substring(1) + ".png" : string.Empty), SiteFun.HtmlEncode(vItem.Type)) + HtmlUI.Link(SiteFun.HtmlEncode(vItem.Name), SiteCfg.Path + vItem.Path, vItem.Path, true))); } else { sr.Append(HtmlUI.CreateTd("--")); } sr.Append(HtmlUI.CreateTd(SiteFun.HtmlEncode(vItem.Type))); sr.Append(HtmlUI.CreateTd(SiteFun.FormatLength(vItem.Size))); sr.Append(HtmlUI.CreateTd(vItem.Publish)); sr.Append(HtmlUI.CreateTd(HtmlUI.HiddenInput("id", vItem.ID) + HtmlUI.SubmitButton(SiteDat.GetLan("BtnDel")))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.FormFinal()); } sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTd(new SitePages().Make(list.Number, page, pageSize, "?act=attach&mode=list&page={0}"), 5, null)); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TableFinal()); sr.Append(AdminUI.AdminBoxFinal()); return sr.ToString(); }
/// <summary> /// 系统文章分类操作 /// </summary> /// <returns>分类列表及操作表单</returns> public string List() { StringBuilder sr = new StringBuilder(); DataList<ColumnItem> list = new ColumnData(conn).SelectColumn(-1, -1, true); if (list.Count > 0) { ColumnData cData = new ColumnData(conn); if (SiteFun.IsPost) { //取值 ColumnItem postVal = new ColumnItem(); postVal.ID = SiteFun.ToInt(SiteFun.Post("id")); postVal.Name = SiteFun.Post("name"); postVal.Sorting = SiteFun.ToInt(SiteFun.Post("sorting")); postVal.Show = SiteFun.ToInt(SiteFun.Post("show")) == 0 ? false : true; postVal.Nav = SiteFun.ToInt(SiteFun.Post("nav")) == 0 ? false : true; //处理 if (string.IsNullOrEmpty(postVal.Name)) { sr.Append(AdminUI.ErrorBox(SiteDat.GetLan("MsgNoName"))); } else { if (postVal.ID > 0) { if (SiteFun.ToInt(SiteFun.Post("del")) == 0) { cData.UpdateColumnSome(postVal.ID, postVal.Name, postVal.Sorting, postVal.Nav, postVal.Show); sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgUpdateDat"))); } else { PostData pData = new PostData(conn); foreach (PostItem tmpPost in pData.SelectPost(postVal.ID, 1, int.MaxValue, null)) { //删除附件 if (!string.IsNullOrEmpty(tmpPost.Attachments)) { AttachmentData attData = new AttachmentData(conn); foreach (AttachmentItem delAtt in attData.SelectAttachment(tmpPost.Attachments)) { File.Delete(Path.Combine(SiteCfg.Router, delAtt.Path)); } attData.DeleteAttachment(tmpPost.Attachments); } } cData.DeleteColumn(postVal.ID); sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgDelDat"))); } } } ClearCache(); } sr.Append(AdminUI.AdminBoxStart(true)); sr.Append(HtmlUI.TableStart()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Name"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Article"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Sorting"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Nav"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Show"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Delete"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Operate"))); sr.Append(HtmlUI.TrFinal()); int i = 1; foreach (ColumnItem vItem in list) { i++; sr.Append(HtmlUI.FormStart()); sr.Append(HtmlUI.TrStart(i % 2 == 0 ? " cRow" : null)); sr.Append(HtmlUI.CreateTd(HtmlUI.HiddenInput("id", vItem.ID) + HtmlUI.Input("name", 10, null, SiteFun.HtmlEncode(vItem.Name)) + HtmlUI.Link(SiteDat.GetLan("Edit"), string.Format("?act=column&mode=post&id={0}", vItem.ID)))); sr.Append(HtmlUI.CreateTd(vItem.PostCount)); sr.Append(HtmlUI.CreateTd(HtmlUI.Input("sorting", 5, null, vItem.Sorting))); sr.Append(HtmlUI.CreateTd(HtmlUI.CheckBoxInput("nav", 1, vItem.Nav))); sr.Append(HtmlUI.CreateTd(HtmlUI.CheckBoxInput("show", 1, vItem.Show))); sr.Append(HtmlUI.CreateTd(HtmlUI.CheckBoxInput("del", 1, false))); sr.Append(HtmlUI.CreateTd(HtmlUI.SubmitButton(SiteDat.GetLan("BtnSave")))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.FormFinal()); } sr.Append(HtmlUI.TableFinal()); sr.Append(AdminUI.AdminBoxFinal()); } else { sr.Append(Post()); } return sr.ToString(); }
/// <summary> /// 取得文章列表窗体 /// </summary> /// <param name="mode">模式:A-文章,P-单页</param> /// <returns>返回文章列表代码</returns> public string List(string mode) { StringBuilder sr = new StringBuilder(); int cid = SiteFun.ToInt(SiteFun.Query("cid")); string key = SiteFun.Query("key"); //下面三行是分页设置 int page = SiteFun.ToInt(SiteFun.Query("page")); if (page < 1) { page = 1; } int pageSize = 20; PostData pData = new PostData(conn); DataList<PostItem> list = pData.SelectPost(cid, null, key, page, pageSize, 0, mode, true); if (list.Count > 0) { if (mode == "A" || mode == "P") { bool isArticle = mode == "A"; if (SiteFun.IsPost) { int id = SiteFun.ToInt(SiteFun.Post("id")); bool del = SiteFun.ToInt(SiteFun.Post("del")) == 0 ? false : true; if (del) { PostItem tmpPost = pData.GetPost(id); //删除附件 if (!string.IsNullOrEmpty(tmpPost.Attachments)) { AttachmentData attData = new AttachmentData(conn); foreach (AttachmentItem delAtt in attData.SelectAttachment(tmpPost.Attachments)) { File.Delete(Path.Combine(SiteCfg.Router, delAtt.Path)); } attData.DeleteAttachment(tmpPost.Attachments); } pData.DeletePost(id); sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgArtDelSucc"))); } else { bool fine = SiteFun.ToInt(SiteFun.Post("fine")) == 0 ? false : true; bool show = SiteFun.ToInt(SiteFun.Post("show")) == 0 ? false : true; pData.UpdatePostFineAndShow(id, fine, show); sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgUpdateDat"))); } ClearCache(); } if (isArticle) { //设置分类数据 DataList<ColumnItem> cateList = new ColumnData(conn).SelectColumn(-1, 0, false); ArrayList values = new ArrayList(); ArrayList captions = new ArrayList(); values.Add(0); captions.Add("--" + SiteDat.GetLan("Category") + "--"); for (int j = 0; j < cateList.Count; j++) { values.Add(cateList[j].ID); captions.Add(cateList[j].Name); } //搜索 sr.Append(AdminUI.AdminBoxStart(true)); sr.Append(HtmlUI.FormStart(false, null, false)); sr.Append(HtmlUI.TableStart("onCenter")); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Search") + HtmlUI.HiddenInput("act", "post") + HtmlUI.HiddenInput("mode", "list") + HtmlUI.HiddenInput("m", mode))); sr.Append(HtmlUI.CreateTd(HtmlUI.CreateSelect("cid", values, captions, cid) + HtmlUI.Input("key", 30, null, SiteFun.HtmlEncode(key)) + HtmlUI.SubmitButton(SiteDat.GetLan("Search")))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TableFinal()); sr.Append(HtmlUI.FormFinal()); sr.Append(AdminUI.AdminBoxFinal()); } //正常列表 sr.Append(AdminUI.AdminBoxStart(true)); sr.Append(HtmlUI.TableStart()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Title"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Local"))); if (isArticle) { sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Category"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Top"))); } sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Show"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Delete"))); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Operate"))); sr.Append(HtmlUI.TrFinal()); int i = 1; foreach (PostItem vItem in list) { i++; sr.Append(HtmlUI.FormStart()); sr.Append(HtmlUI.TrStart(i % 2 == 0 ? " cRow" : null)); sr.Append(HtmlUI.CreateTd(HtmlUI.Link(SiteFun.HtmlEncode(SiteFun.StrCut(vItem.Title, 50)), string.Format("?act=post&mode=post&m={1}&id={0}", vItem.ID, mode)))); sr.Append(HtmlUI.CreateTd(SiteFun.HtmlEncode(SiteFun.StrCut(vItem.Local, 30)))); if (isArticle) { sr.Append(HtmlUI.CreateTd(SiteFun.HtmlEncode(new ColumnData(conn).GetColumn(vItem.ColumnID).Name))); sr.Append(HtmlUI.CreateTd(HtmlUI.CheckBoxInput("fine", 1, vItem.Fine))); } sr.Append(HtmlUI.CreateTd(HtmlUI.CheckBoxInput("show", 1, vItem.Show))); sr.Append(HtmlUI.CreateTd(HtmlUI.CheckBoxInput("del", 1, false))); sr.Append(HtmlUI.CreateTd(HtmlUI.HiddenInput("id", vItem.ID) + HtmlUI.SubmitButton(SiteDat.GetLan("BtnSave")))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.FormFinal()); } sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTd(new SitePages().Make(list.Number, page, pageSize, "?act=post&mode=list&cid=" + cid + "&key=" + SiteFun.UrlEncode(key) + "&m=" + mode + "&page={0}"), (isArticle ? 7 : 5), null)); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TableFinal()); sr.Append(AdminUI.AdminBoxFinal()); } } else { sr.Append(Post(mode)); } return sr.ToString(); }