/// <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> /// <param name="files">文件对象</param> /// <param name="content">内容(如果有的话)</param> /// <param name="explain">阐述(如果有的话)</param> /// <param name="wmPoint">水印位置</param> /// <param name="wmPath">水印文件路径</param> /// <returns>附件列表</returns> public string SaveAs(HttpFileCollection files, ref string content, ref string explain, int wmPoint, string wmPath) { string result = string.Empty; for (int i = 0; i < files.Count; i++) { if (files[i] != null && files[i].ContentLength > 0) { FileInfo tempFileInfo = new FileInfo(files[i].FileName); if (!string.IsNullOrEmpty(tempFileInfo.Extension)) { //保存文件 string saveFolder = "Attach/" + DateTime.Now.ToString("yyyyMM") + "/"; string savePath = saveFolder + DateTime.Now.ToString("ddHHmmss") + "-" + tempFileInfo.Name; if (!Directory.Exists(Path.Combine(SiteCfg.Router, saveFolder))) { Directory.CreateDirectory(Path.Combine(SiteCfg.Router, saveFolder)); } if (wmPoint > 0 && File.Exists(wmPath) && (tempFileInfo.Extension.ToLower() == ".bmp" || tempFileInfo.Extension.ToLower() == ".gif" || tempFileInfo.Extension.ToLower() == ".jpg" || tempFileInfo.Extension.ToLower() == ".png")) { files[i].SaveAs(Path.Combine(SiteCfg.Router, "Common/Temp/" + tempFileInfo.Name)); new SiteWatermark().HandleImage(Path.Combine(SiteCfg.Router, "Common/Temp/" + tempFileInfo.Name), Path.Combine(SiteCfg.Router, savePath), wmPath, wmPoint, true); } else { files[i].SaveAs(Path.Combine(SiteCfg.Router, savePath)); } //创建附件信息 AttachmentItem attVal = new AttachmentItem(); attVal.Name = tempFileInfo.Name; attVal.Path = savePath; attVal.Type = files[i].ContentType; attVal.Size = files[i].ContentLength; int tmpId = new AttachmentData(conn).InsertAttachment(attVal); result += string.Format("{0},", tmpId); //判断文件 string replaceTag = string.Format("[LocalUpload_{0}]", i); string replaceImgHtml = string.Format("<span class=\"sysAttachImage\"><img src=\"{0}\"/></span>", SiteCfg.Path + savePath); string replaceFileHtml = string.Format("<span class=\"sysAttachDownload\"><a href=\"{0}\">{1}</a></span>", SiteCfg.Path + savePath, SiteDat.GetLan("ClickDown")); string replaceMusicHtml = string.Format("<span class=\"sysAttachMusic\"><embed type=\"application/x-shockwave-flash\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-4445535400000\" src=\"{0}Common/Editor/player.swf?soundFile={1}&t=swf\" wmode=\"opaque\" quality=\"high\" menu=\"false\" play=\"true\" loop=\"true\" allowfullscreen=\"true\" height=\"26\" width=\"300\" /></span>", SiteCfg.Path, SiteFun.UrlEncode(SiteCfg.Path + savePath)); //格式化内容数据 if (tempFileInfo.Extension.ToUpper() == ".BMP" || tempFileInfo.Extension.ToUpper() == ".GIF" || tempFileInfo.Extension.ToUpper() == ".JPG" || tempFileInfo.Extension.ToUpper() == ".PNG") { if (!string.IsNullOrEmpty(content)) { content = content.Replace(replaceTag, replaceImgHtml); } if (!string.IsNullOrEmpty(explain)) { explain = explain.Replace(replaceTag, replaceImgHtml); } } else if (tempFileInfo.Extension.ToUpper() == ".MP3") { if (!string.IsNullOrEmpty(content)) { content = content.Replace(replaceTag, replaceMusicHtml); } if (!string.IsNullOrEmpty(explain)) { explain = explain.Replace(replaceTag, replaceMusicHtml); } } else { if (!string.IsNullOrEmpty(content)) { content = content.Replace(replaceTag, replaceFileHtml); } if (!string.IsNullOrEmpty(explain)) { explain = explain.Replace(replaceTag, replaceFileHtml); } } } } } if (result.Length > 0) { result = result.Remove(result.Length - 1); } return result; }
/// <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(); }
/// <summary> /// 提交文章窗体 /// </summary> /// <param name="mode">模式:A-文章,P-单页</param> /// <returns>返回发布文章控件代码</returns> public string Post(string mode) { StringBuilder sr = new StringBuilder(); if (mode == "A" || mode == "P") { bool isArticle = mode == "A"; SettingItem setting = new SettingData(conn).GetSetting(); string theme = new SettingData(conn).GetTheme; string tmpFilePath = Path.Combine(SiteCfg.Router, "Common/Temp/post_cache.tmp"); int id = SiteFun.ToInt(SiteFun.Query("id")); PostData artData = new PostData(conn); ColumnData cData = new ColumnData(conn); TagData tagData = new TagData(conn); //取得默认值 string[] myUserInfo = _ac.Get(); UserItem myUser = new UserData(conn).CheckUser(myUserInfo[0], SiteFun.Encryption(myUserInfo[1]), true); PostItem old = artData.GetPost(id); ColumnItem oldColumn = new ColumnData(conn).GetColumn(old.ColumnID); if (old.ID == 0) { //默认显示、可评论并自动审核,可发通告 old.Show = true; old.SwitchComment = true; old.AutoVerifyComment = true; old.SwitchTrackback = true; } if (string.IsNullOrEmpty(old.Author)) { old.Author = myUser.Name; } if (SiteFun.IsPost) { //处理文章数据 PostItem postVal = new PostItem(); string content = SiteFun.HtmlMatch(SiteFun.Post("content")); string explain = content; if (!string.IsNullOrEmpty(explain)) { explain = Regex.Replace(explain, SiteCfg.PageBreakRegular, SiteCfg.PageBreakSymbol, RegexOptions.Multiline | RegexOptions.IgnoreCase); if (explain.IndexOf(SiteCfg.PageBreakSymbol) > 0) { explain = explain.Substring(0, explain.IndexOf(SiteCfg.PageBreakSymbol)); explain = SiteFun.HtmlMatch(explain); } explain = explain.Replace(SiteCfg.PageBreakSymbol, string.Empty); } postVal.ID = id; postVal.ColumnID = SiteFun.ToInt(SiteFun.Post("cid")); postVal.Title = SiteFun.Post("title"); postVal.Tags = SiteFun.Post("tags"); postVal.Local = SiteFun.Post("local"); postVal.Explain = explain; postVal.Content = content; postVal.Author = SiteFun.Post("author"); postVal.Publish = SiteFun.ToDate(SiteFun.Post("publish")); postVal.Password = SiteFun.Post("pwd"); postVal.Vote = SiteFun.ToInt(SiteFun.Post("vote")); postVal.Reader = SiteFun.ToInt(SiteFun.Post("reader")); postVal.Fine = SiteFun.ToInt(SiteFun.Post("fine")) == 0 ? false : true; postVal.Show = SiteFun.ToInt(SiteFun.Post("show")) == 0 ? false : true; postVal.PostCount = old.PostCount; postVal.SwitchComment = SiteFun.ToInt(SiteFun.Post("switchCmt")) == 0 ? false : true; postVal.SwitchTrackback = SiteFun.ToInt(SiteFun.Post("switchTb")) == 0 ? false : true; postVal.AutoVerifyComment = SiteFun.ToInt(SiteFun.Post("avcmt")) == 0 ? false : true; postVal.AutoVerifyTrackback = SiteFun.ToInt(SiteFun.Post("avtb")) == 0 ? false : true; postVal.Attachments = old.Attachments; //分类 ColumnItem postColumn = new ColumnData(conn).GetColumn(postVal.ColumnID); if (string.IsNullOrEmpty(postVal.Title)) { sr.Append(AdminUI.ErrorBox(SiteDat.GetLan("MsgNoTitle"))); } else { if (!string.IsNullOrEmpty(postVal.Local)) { postVal.Local = postVal.Local.Replace(" ", "-"); } if (!string.IsNullOrEmpty(postVal.Local) && (!SiteFun.IsLocal(postVal.Local) || artData.ExistsLocal(postVal.Local, postVal.ID))) { sr.Append(AdminUI.ErrorBox(SiteDat.GetLan("MsgNoLocalOrExists"))); } else { //处理上传图片的内容循环替换 if (!string.IsNullOrEmpty(postVal.Content)) { string[] tmpFilesHandle = { postVal.Content, postVal.Explain }; string atts = new _AdminUpload(conn).SaveAs(HttpContext.Current.Request.Files, ref tmpFilesHandle[0], ref tmpFilesHandle[1], SiteFun.ToInt(SiteFun.Post("ws")), Path.Combine(SiteCfg.Router, setting.Parameter.WatermarkPath)); postVal.Content = tmpFilesHandle[0]; postVal.Explain = tmpFilesHandle[1]; if (!string.IsNullOrEmpty(atts)) { if (string.IsNullOrEmpty(postVal.Attachments)) { postVal.Attachments = atts; } else { postVal.Attachments += "," + atts; } } } //保存或新增文章数据处理 if (postVal.ID == 0) { artData.InsertPost(postVal, mode); //标签处理 tagData.InsertTagList(postVal.Tags); //分类统计 //cData.CountCategoryPost(postVal.Category.ID); sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgArtInsertSucc"), "?act=post&mode=list&M=" + mode)); } else { artData.UpdatePost(postVal); //标签处理 tagData.InsertTagList(postVal.Tags); //类统计 cData.CountColumnPost(oldColumn.ID); cData.CountColumnPost(postColumn.ID); //更新修改后的显示 sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgArtUpdateSucc"), "?act=post&mode=list&M=" + mode)); } try { File.Delete(tmpFilePath); } catch { } } } //处理引用通告 TrackbackLogData tbld = new TrackbackLogData(conn); SettingBasicItem sbi = setting.Basic; string tbUrls = SiteFun.Post("tbUrls"); if (!string.IsNullOrEmpty(tbUrls)) { foreach (string vItem in tbUrls.Split('\n')) { if (!string.IsNullOrEmpty(vItem)) { string[] tbState = new SiteTrackback().SendTrackback(vItem, string.Format(SitePath.ArticleLinkFormat, sbi.URL + SiteCfg.Path, postVal.Local), sbi.Name, postVal.Title, SiteFun.ClearHtml(postVal.Explain)).Split('|'); TrackbackLogItem tbVal = new TrackbackLogItem(); tbVal.Error = SiteFun.ToInt(tbState[0]) == 0 ? false : true; tbVal.Message = tbState[1]; tbVal.URL = vItem; tbld.InsertTrackbackLog(tbVal); } } } ClearCache(); old = postVal; } //设置分类数据 DataList<ColumnItem> cateList = cData.SelectColumn(-1, 0, true); ArrayList values = new ArrayList(); ArrayList captions = new ArrayList(); for (int i = 0; i < cateList.Count; i++) { values.Add(cateList[i].ID); captions.Add(cateList[i].Name); } sr.Append(AdminUI.AdminBoxStart(true)); sr.Append(HtmlUI.FormStart(null, true)); sr.Append(HtmlUI.TableStart("onCenter advancedBox")); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Title")) + HtmlUI.CreateTd(HtmlUI.Input("title", 50, null, SiteFun.HtmlEncode(old.Title)) + (isArticle ? HtmlUI.CreateSelect("cid", values, captions, oldColumn.ID) : string.Empty))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TrStart()); if (Regex.IsMatch(old.Local, @"^\d+$")) { old.Local = string.Empty; } sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Local")) + HtmlUI.CreateTd(string.Format((isArticle ? SitePath.ArticleLinkFormat : SitePath.PageLinkFormat), null, HtmlUI.Input("local", 30, null, SiteFun.HtmlEncode(old.Local))))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Content")) + HtmlUI.CreateTd(AdminUI.Editor("content", SiteFun.HtmlEncode(old.Content)))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh() + HtmlUI.CreateTd((File.Exists(tmpFilePath) ? "<a id=\"reInsertContent\">" + SiteDat.GetLan("MsgClickArtReload") + "</a>" : string.Empty) + string.Format(SiteDat.GetLan("MsgArtAutoSaveState"), "<span id=\"autoSaveCountdown\">--</span>", "<a id=\"autoSaveButton\">--</a>", "<span id=\"autoSaveIs\"></span>"))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Attach") + ", <a id=\"addFilesA\">" + SiteDat.GetLan("Add") + "</a>") + HtmlUI.CreateTd(string.Format("<span id=\"filesMainBox\">{0}</span><a id=\"filesMainInsertA\">{1}</a><div id=\"filesAttBox\"></div>", HtmlUI.FileInput(null, "files"), SiteDat.GetLan("Insert")))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TableFinal()); sr.Append(HtmlUI.TableStart("onCenter hidden advancedBox")); string attsHtml = string.Empty; DataList<AttachmentItem> attachments = new AttachmentData(conn).SelectAttachment(old.Attachments); foreach (AttachmentItem att in attachments) { attsHtml += HtmlUI.Link(att.Name, att.Path, att.Type, true) + string.Format(", {0}, {1}, {2}<br/>", att.Publish, att.Size, att.Type); } if (attachments.Count > 0) { sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Attach")) + HtmlUI.CreateTd(attsHtml)); sr.Append(HtmlUI.TrFinal()); } sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Tag")) + HtmlUI.CreateTd(HtmlUI.Input("tags", "tags", 50, null, SiteFun.HtmlEncode(old.Tags)))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh() + HtmlUI.CreateTd(HtmlUI.Button("getInputTags", SiteDat.GetLan("BtnTagsNow")) + "<div id=\"getInputTagsDsp\"></div>")); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Author")) + HtmlUI.CreateTd(HtmlUI.Input("author", 10, null, SiteFun.HtmlEncode(old.Author)))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Time")) + HtmlUI.CreateTd(HtmlUI.Input("timeInput", "publish", 20, null, old.Publish) + HtmlUI.Button("updateTime", SiteDat.GetLan("BtnUpdateTime")))); sr.Append(HtmlUI.TrFinal()); if (isArticle) { sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Pwd")) + HtmlUI.CreateTd(HtmlUI.Input("pwd", 30, null, old.Password))); sr.Append(HtmlUI.TrFinal()); } sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("VoteNum")) + HtmlUI.CreateTd(HtmlUI.Input("vote", 5, null, old.Vote))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Reader")) + HtmlUI.CreateTd(HtmlUI.Input("reader", 5, null, old.Reader))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Virtue")) + HtmlUI.CreateTd((isArticle ? HtmlUI.CheckBoxInput(SiteDat.GetLan("Top"), "fine", 1, old.Fine) : string.Empty) + HtmlUI.CheckBoxInput(SiteDat.GetLan("Show"), "show", 1, old.Show))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TrStart()); ArrayList wmValues = new ArrayList(); ArrayList caps = new ArrayList(); for (int wmI = 0; wmI <= 9; wmI++) { wmValues.Add(wmI); } caps.Add("--" + SiteDat.GetLan("WmPosition") + "--"); caps.Add(SiteDat.GetLan("PTopLeft")); caps.Add(SiteDat.GetLan("PTopCen")); caps.Add(SiteDat.GetLan("PTopRight")); caps.Add(SiteDat.GetLan("PMdlLeft")); caps.Add(SiteDat.GetLan("PMdlCen")); caps.Add(SiteDat.GetLan("PMdlRight")); caps.Add(SiteDat.GetLan("PBtmLeft")); caps.Add(SiteDat.GetLan("PBtmCen")); caps.Add(SiteDat.GetLan("PBtmRight")); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Switch")) + HtmlUI.CreateTd(HtmlUI.CheckBoxInput(SiteDat.GetLan("InsertCmt"), "switchCmt", 1, old.SwitchComment) + HtmlUI.CheckBoxInput(SiteDat.GetLan("InsertTb"), "switchTb", 1, old.SwitchTrackback) + HtmlUI.CreateSelect("ws", wmValues, caps, setting.Parameter.WatermarkSeat))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("AutoVerify")) + HtmlUI.CreateTd(HtmlUI.CheckBoxInput(SiteDat.GetLan("VerifyCmt"), "avcmt", 1, old.AutoVerifyComment) + HtmlUI.CheckBoxInput(SiteDat.GetLan("VerifyTb"), "avtb", 1, old.AutoVerifyTrackback))); sr.Append(HtmlUI.TrFinal()); if (isArticle) { sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Trackback")) + HtmlUI.CreateTd(HtmlUI.Textarea("tbUrls", 5, 80, null))); sr.Append(HtmlUI.TrFinal()); } sr.Append(HtmlUI.TableFinal()); sr.Append(HtmlUI.TableStart("onCenter")); sr.Append(HtmlUI.TrStart()); sr.Append(HtmlUI.CreateTh() + HtmlUI.CreateTd(HtmlUI.SubmitButton() + HtmlUI.ResetButton() + HtmlUI.Button("advancedLink", SiteDat.GetLan("BtnAdvanced")))); sr.Append(HtmlUI.TrFinal()); sr.Append(HtmlUI.TableFinal()); sr.Append(HtmlUI.FormFinal()); sr.Append(AdminUI.AdminBoxFinal()); } return sr.ToString(); }
/// <summary> /// 获取缩略图 /// </summary> /// <param name="postId">资料编号</param> /// <param name="width">宽度</param> /// <param name="height">高度</param> /// <param name="limit">多少个图片</param> /// <param name="pf">后缀名,例如:“.png”</param> /// <returns>标准图片代码</returns> public string GetPostImage(int postId, int width, int height, int limit, string pf) { string defaPic = SiteCfg.Path + "Common/Images/Nopic.png"; if (limit < 1) { limit = 1; } string imgFormat = "<img src=\"{0}\" width=\"{1}\" height=\"{2}\" border=\"0\"/>"; string result = string.Empty; PostItem item = new PostItem(); if (SiteDat.GetDat(string.Format(SiteCache.PostFormat, postId)) == null) { SiteDat.SetDat(string.Format(SiteCache.PostFormat, postId), new PostData(conn).GetPost(postId)); } item = (PostItem)SiteDat.GetDat(string.Format(SiteCache.PostFormat, postId)); DataList<AttachmentItem> atts = new AttachmentData(conn).SelectAttachment(item.Attachments); if (atts.Count > 0) { int count = 0; foreach (AttachmentItem att in atts) { FileInfo fInfo = new FileInfo(Path.Combine(SiteCfg.Router, att.Path)); if (fInfo.Exists && !string.IsNullOrEmpty(fInfo.Extension)) { if (string.IsNullOrEmpty(pf)) { if (fInfo.Extension.ToUpper() == ".BMP" || fInfo.Extension.ToUpper() == ".GIF" || fInfo.Extension.ToUpper() == ".JPG" || fInfo.Extension.ToUpper() == ".PNG") { count++; result += string.Format(imgFormat, SiteCfg.Path + att.Path, width, height); } } else { if (fInfo.Extension.ToUpper() == pf.ToUpper()) { count++; result += string.Format(imgFormat, SiteCfg.Path + att.Path, width, height); } } } if (count >= limit) { break; } } } if (string.IsNullOrEmpty(result)) { result = string.Format(imgFormat, defaPic, width, height); } return result; }