private string GetPageIndexContent(DataRow dr, int pageIndex) { string content = string.Empty; string[] strArray = null; DataTable table = this.CreateDataTable(); string str2 = string.Empty; int pageSize = this.TotalContentPageNumber(dr); if (this.CheckColumn(dr, "content")) { string str5; MatchCollection matchs; string str6; string labelContent; string vote; string uploadPath = (string)dr["uploadPath"]; content = dr["content"].ToString().Replace("{Ky:PAGE}", "┃"); content = new B_ConvertImage(this.SiteModel.Domain, uploadPath).ConvertContent(content); strArray = content.Split(new char[] { '┃' }); if (strArray.Length > 1) { int num2 = 0; foreach (string str4 in strArray) { DataRow row = table.NewRow(); row["DtId"] = num2; str5 = ""; matchs = Regex.Matches(str4, "{Ky_.*?}", RegexOptions.IgnoreCase); if (matchs.Count > 0) { str6 = ""; foreach (Match match in matchs) { str6 = match.Value; } labelContent = this.GetLabelContent(str6); if (labelContent != "") { vote = this.GetVote(labelContent); str5 = str4.Replace(str6, vote); } else { str5 = str4.Replace(str6, ""); } } else { str5 = str4; } row["DtCon"] = str5; table.Rows.Add(row); num2++; } str2 = table.Rows[pageIndex - 1]["DtCon"].ToString(); } else { str5 = ""; matchs = Regex.Matches(content, "{Ky_.*?}", RegexOptions.IgnoreCase); if (matchs.Count > 0) { str6 = ""; foreach (Match match in matchs) { str6 = match.Value; } labelContent = this.GetLabelContent(str6); if (labelContent != "") { vote = this.GetVote(labelContent); str5 = content.Replace(str6, vote); } else { str5 = content.Replace(str6, ""); } } if (str5 != "") { str2 = str5; } else { str2 = content; } } } return (str2 + this.GetPageSize(dr, pageIndex, pageSize)); }
protected void AddNewsBtn_Click(object sender, EventArgs e) { bool checkForm = CheckValidate(); if (checkForm) { M_Article Articlemodel = new M_Article(); Articlemodel.Id = ArticleId; #region 所有情况下 Articlemodel.Author = txtAuthor.Text.Trim(); if (!string.IsNullOrEmpty(Request.Form["ddlColId"])) Articlemodel.ColId = int.Parse(Request.Form["ddlColId"]); //添加时间 if (txtAddTime.Text.Trim().Length != 0) { if (Function.IsDate(txtAddTime.Text.Trim().ToString())) Articlemodel.AddTime = DateTime.Parse(txtAddTime.Text.Trim().ToString()); else Function.ShowSysMsg(0, "<li>你输入的日期格式不对</li><li><a href='javascript:window.history.back()'>返回上一步</a></li>"); } else Articlemodel.AddTime = DateTime.Now; Articlemodel.ExpireTime = Convert.ToDateTime(txtExpireTime.Text.Trim()); Articlemodel.ViewEndTime = txtViewEndTime.Text.Trim(); Articlemodel.UpdateTime = DateTime.Now; Articlemodel.ShortContent = SiteBll.GetFiltering(txtShortContent.Text.Trim()); Articlemodel.Source = txtSource.Text.Trim(); #region 关键字 string tagIdStr = string.Empty; string nameStr = txtTagNameStr.Text.Trim(); nameStr = Regex.Replace(nameStr, @"\s+", "|", RegexOptions.IgnoreCase); if (nameStr.Length != 0) { if (nameStr.StartsWith("|")) nameStr = nameStr.Substring(1, nameStr.Length - 1); if (nameStr.EndsWith("|")) nameStr = nameStr.Substring(0, nameStr.Length - 1); B_Tag tagBll = new B_Tag(); DataRow dr = tagBll.AddTagStr(nameStr, ChannelModel.ModelType, 0, "后台管理员"); if (dr != null) { tagIdStr = "|" + dr[0] + "|"; nameStr = "|" + dr[1] + "|"; } else { tagIdStr = ""; nameStr = ""; } } Articlemodel.TagIdStr = tagIdStr; Articlemodel.TagNameStr = nameStr; #endregion Articlemodel.IsFocus = chkBoxIsFocus.Checked; Articlemodel.IsHeader = chkBoxIsHeader.Checked; Articlemodel.IsIrregular = chkBoxIsIrregular.Checked; Articlemodel.IsRecommend = chkBoxIsRecommend.Checked; Articlemodel.IsShowCommentLink = IsShowCommentLink.Checked; Articlemodel.IsSideShow = chkBoxIsSideShow.Checked; Articlemodel.IsTop = chkBoxIsTop.Checked; Articlemodel.Title = SiteBll.GetFiltering(txtTitle.Text.Trim()); Articlemodel.LongTitle = SiteBll.GetFiltering(txtLongTitle.Text.Trim()); Articlemodel.TitleColor = txtTitleColor.Text.Trim(); Articlemodel.TitleFontType = Int32.Parse(ddlTitleFontType.SelectedValue.Trim()); Articlemodel.UId = AdminModel.UserId; Articlemodel.UName = AdminModel.LoginName; Articlemodel.AdminUId = AdminModel.UserId; Articlemodel.AdminUName = AdminModel.AdminName; Articlemodel.UserType = 1; Articlemodel.Status = 3; //头条文章属性设置 Articlemodel.HeaderFont = txtHeaderFont.Text.Trim() + "|" + ddlHeaderProPerty.SelectedValue + "|" + ddlHeaderSize.SelectedValue + "|" + txtHeaderColor.Text.Trim(); Articlemodel.HeaderImgPath = txtHeaderImgPath.Value; #endregion if (rbOuter.Checked == true) { Articlemodel.OuterUrl = txtOuterUrl.Text.Trim(); } #region 不是外部链接地址情况 if (rbComm.Checked == true) { Articlemodel.TitleType = 1; } else if (rbImg.Checked == true) { Articlemodel.TitleType = 2; Articlemodel.TitleImgPath = Request.Form["txtTitleImgPath"].Trim(); } if (!rbOuter.Checked) { if (Request.Form["ChargeTypeRadioButtonList"] == "2") Articlemodel.ChargeHourCount = Int32.Parse(txtChargeHourCount.Text.Trim()); //重复收费方式 if (rdBtnChargeType1.Checked) Articlemodel.ChargeType = 1; if (rdBtnChargeType2.Checked) { Articlemodel.ChargeType = 2; Articlemodel.ChargeHourCount = Int32.Parse(txtChargeHourCount.Text.Trim()); } if (rdBtnChargeType3.Checked) { Articlemodel.ChargeType = 3; Articlemodel.ChargeViewCount = Int32.Parse(txtChargeViewCount.Text.Trim()); } if (rdBtnChargeType4.Checked) { Articlemodel.ChargeType = 4; Articlemodel.ChargeHourCount = Int32.Parse(txtChargeHourCount.Text.Trim()); Articlemodel.ChargeViewCount = Int32.Parse(txtChargeViewCount.Text.Trim()); } if (rdBtnChargeType5.Checked) { Articlemodel.ChargeType = 5; Articlemodel.ChargeHourCount = Int32.Parse(txtChargeHourCount.Text.Trim()); Articlemodel.ChargeViewCount = Int32.Parse(txtChargeViewCount.Text.Trim()); } if (rdBtnChargeType6.Checked) Articlemodel.ChargeType = 6; B_ConvertImage convertBll = new B_ConvertImage(SiteModel.Domain, InfoModel.UploadPath); if (chkBoxRemoteSaveImage.Checked) { txtContent.Value = convertBll.ConvertLocalImagePath(txtContent.Value); } else { txtContent.Value = convertBll.ConvertImgePath(txtContent.Value); } Articlemodel.Content = SiteBll.GetFiltering(txtContent.Value); Articlemodel.Content = Articlemodel.Content.Replace(@"<div style=""page-break-after: always""><span style=""display: none""> </span></div>", "{Ky:PAGE}"); //生成的格式 Articlemodel.PageType = int.Parse(rdBtnPageType.SelectedValue); Articlemodel.IsOpened = int.Parse(rdBtnIsOpened.SelectedValue.Trim()); if (Articlemodel.IsOpened == 0) { string groupIdstr = string.Empty; foreach (ListItem li in chkBoxGroupIdStr.Items) { if (li.Selected) { groupIdstr += li.Value + "|"; } } Articlemodel.GroupIdStr = "|" + groupIdstr; } else { Articlemodel.GroupIdStr = ""; } Articlemodel.HitCount = Int32.Parse(txtHitCount.Text.Trim()); Articlemodel.IsAllowComment = chkBoxIsAllowComment.Checked; Articlemodel.PointCount = Int32.Parse(txtPointCount.Text.Trim()); Articlemodel.StarLevel = ddlStarLevel.SelectedValue.Trim(); //文章所属数据表 Articlemodel.TableName=""; Articlemodel.TemplatePath = Request.Form["txtTemplatePath"].Trim(); //文章所属专题 string idStr = string.Empty; for (int i = 0; i < lBoxTopicIdStr.Items.Count; i++) { if (lBoxTopicIdStr.Items[i].Selected) { idStr += lBoxTopicIdStr.Items[i].Value + "|"; } } if (idStr != "") Articlemodel.SpecialIdStr = "|" + idStr; else Articlemodel.SpecialIdStr = ""; if (txtViewer.Text.Trim() != string.Empty) { Articlemodel.ViewUName = "|" + txtViewer.Text.Trim() + "|"; if (txtViewEndTime.Text.Trim() == "") { litMsg.Text = "<script>alert('签收结束时间必须填写');</script>"; return; } } else Articlemodel.ViewUName = string.Empty; } #endregion #region 保存 if (!CheckValidate()) { return; } B_Article AddArticle = new B_Article(); if (ArticleId > 0) { //返回文章ID ArticleId = AddArticle.Update(Articlemodel); } else { ArticleId = AddArticle.Add(Articlemodel); } if (chkBoxIsCreate.Checked) { DataRow dr = CreateBll.GetInfoById("kyarticle", ArticleId); CreateBll.CreateSingleInfo(dr); } Response.Redirect("InfoList.aspx?ChId=" + ChannelId + "&ColId=" + Articlemodel.ColId); #endregion 保存 } }
private string GetContent(M_Collection collectionM, string contentStr) { this.ColumnM = this.ColumnBll.GetColumn(collectionM.ColId); this.ChannelM = this.ChannelBll.GetChannel(this.ColumnM.ChId); this.ModelM = this.InfoModelBll.GetModel(this.ChannelM.ModelType); this.SiteModel = this.SiteBll.GetSiteModel(); B_ConvertImage image = new B_ConvertImage(this.SiteModel.Domain, this.ModelM.UploadPath); string simpleFilterRule = collectionM.SimpleFilterRule; string pattern = string.Empty; string complexityFilterRule = collectionM.ComplexityFilterRule; if (complexityFilterRule != "") { string[] strArray = complexityFilterRule.Split(new char[] { ',' }); for (int i = 0; i < strArray.Length; i++) { this.SuperiorM = this.SuperiorBll.GetIdBySuperior(int.Parse(strArray[i].ToString())); pattern = this.TransferStr(this.SuperiorM.StartCode) + "((?:.|\n)*?)" + this.TransferStr(this.SuperiorM.EndCode); contentStr = this.SuperiorHtml(contentStr, pattern); } } if (simpleFilterRule != "") { string[] strArray2 = simpleFilterRule.Split(new char[] { ',' }); for (int j = 0; j < (strArray2.Length - 1); j++) { switch (int.Parse(strArray2[j].ToString())) { case 0: contentStr = this.FilterObject(contentStr); break; case 1: contentStr = this.FilterScript(contentStr); break; case 2: contentStr = this.FilterStyle(contentStr); break; case 3: contentStr = this.FilterDiv(contentStr); break; case 4: contentStr = this.FilterSpan(contentStr); break; case 5: contentStr = this.FilterTableProtery(contentStr); break; case 6: contentStr = this.FilterImg(contentStr); break; case 7: contentStr = this.FilterFont(contentStr); break; case 8: contentStr = this.FilterA(contentStr); break; case 9: contentStr = this.RemoveHtml(contentStr); break; } } } contentStr = image.ConvertLocalImagePath(contentStr); contentStr = image.ConvertContent(contentStr); return contentStr; }
private void ShowInfo(int ArticleId) { #region 文章基本信息修改 B_Article ArticleBll = new B_Article(); M_Article Articlemodel = ArticleBll.GetArticle(ArticleId); if (Articlemodel == null || Articlemodel.Status == -1) { Function.ShowSysMsg(0, "<li>所选文章不存在或已经被删除</li>"); } txtAuthor.Text = Articlemodel.Author; //重复收费方式 switch (Articlemodel.ChargeType) { case 1: rdBtnChargeType1.Checked = true; break; case 2: txtChargeHourCount.Text = Articlemodel.ChargeHourCount.ToString(); rdBtnChargeType2.Checked = true; break; case 3: rdBtnChargeType3.Checked = true; txtChargeViewCount.Text = Articlemodel.ChargeViewCount.ToString(); break; case 4: txtChargeHourCount.Text = Articlemodel.ChargeHourCount.ToString(); txtChargeViewCount.Text = Articlemodel.ChargeViewCount.ToString(); rdBtnChargeType4.Checked = true; break; case 5: txtChargeHourCount.Text = Articlemodel.ChargeHourCount.ToString(); txtChargeViewCount.Text = Articlemodel.ChargeViewCount.ToString(); rdBtnChargeType5.Checked = true; break; case 6: rdBtnChargeType6.Checked = true; break; } B_ConvertImage convertBll = new B_ConvertImage(SiteModel.Domain, InfoModel.UploadPath); txtContent.Value = convertBll.ConvertContent(Articlemodel.Content); txtContent.Value = txtContent.Value.Replace("{Ky:PAGE}", @"<div style=""page-break-after: always""><span style=""display: none""> </span></div>"); rdBtnPageType.SelectedValue = Articlemodel.PageType.ToString(); txtUpdateDateTime.Text = DateTime.Now.ToString(); //添加时间 txtAddTime.Text = Articlemodel.AddTime.ToString(); txtExpireTime.Text = Articlemodel.ExpireTime.ToString("yyyy-MM-dd"); if (Articlemodel.ViewEndTime != "") txtViewEndTime.Text = Convert.ToDateTime(Articlemodel.ViewEndTime).ToString("yyyy-MM-dd"); rdBtnIsOpened.SelectedValue = Articlemodel.IsOpened.ToString(); foreach (ListItem li in chkBoxGroupIdStr.Items) { if (Articlemodel.GroupIdStr.IndexOf("|" + li.Value + "|") != -1) li.Selected = true; } txtHitCount.Text = Articlemodel.HitCount.ToString(); txtOuterUrl.Text = Articlemodel.OuterUrl; if (txtOuterUrl.Text.Trim() != string.Empty) { rbOuter.Checked = true; } chkBoxIsAllowComment.Checked = Articlemodel.IsAllowComment; chkBoxIsFocus.Checked = Articlemodel.IsFocus; chkBoxIsHeader.Checked = Articlemodel.IsHeader; chkBoxIsIrregular.Checked = Articlemodel.IsIrregular; chkBoxIsRecommend.Checked = Articlemodel.IsRecommend; IsShowCommentLink.Checked = Articlemodel.IsShowCommentLink; chkBoxIsSideShow.Checked = Articlemodel.IsSideShow; chkBoxIsTop.Checked = Articlemodel.IsTop; txtPointCount.Text = Articlemodel.PointCount.ToString(); txtShortContent.Text = Articlemodel.ShortContent; txtSource.Text = Articlemodel.Source; try { ddlStarLevel.SelectedValue = Articlemodel.StarLevel.ToString(); } catch { } //关键字 string tagNameStr = string.Empty; tagNameStr = Articlemodel.TagNameStr; //Response.End(); if (!string.IsNullOrEmpty(tagNameStr)) { if (tagNameStr.StartsWith("|") && tagNameStr.EndsWith("|")) { tagNameStr = tagNameStr.Substring(0, tagNameStr.Length - 1); tagNameStr = tagNameStr.Substring(1, tagNameStr.Length - 1); } } tagNameStr = tagNameStr.Replace("|", " "); txtTagNameStr.Text = tagNameStr; txtTemplatePath.Text = Articlemodel.TemplatePath; txtTitle.Text = Articlemodel.Title; txtLongTitle.Text = Articlemodel.LongTitle; txtTitleColor.Text = Articlemodel.TitleColor.ToString(); ddlTitleFontType.SelectedValue = Articlemodel.TitleFontType.ToString(); switch (int.Parse(Articlemodel.TitleType.ToString())) { case 1: rbComm.Checked = true; break; case 2: rbImg.Checked = true; txtTitleImgPath.Text = Articlemodel.TitleImgPath; break; } //文章所属专题 string[] arraySpecialIdStr = Articlemodel.SpecialIdStr.Split('|'); for (int i = 0; i < arraySpecialIdStr.Length; i++) { for (int j = 0; j < lBoxTopicIdStr.Items.Count; j++) { if (lBoxTopicIdStr.Items[j].Value == arraySpecialIdStr[i]) { lBoxTopicIdStr.Items[j].Selected = true; } } } //签收用户 string viewUName = Articlemodel.ViewUName; if (viewUName != string.Empty && viewUName.StartsWith("|") && viewUName.EndsWith("|")) { viewUName = viewUName.Substring(0, viewUName.Length - 1); viewUName = viewUName.Substring(1, viewUName.Length - 1); txtViewer.Text = viewUName; } txtViewer.Text = viewUName; //头条文章属性设置 if (Articlemodel.HeaderFont.Length != 0) { string[] headerArray = Articlemodel.HeaderFont.Split('|'); txtHeaderFont.Text = headerArray[0]; ddlHeaderProPerty.SelectedValue = headerArray[1]; ddlHeaderSize.SelectedValue = headerArray[2]; txtHeaderColor.Text = headerArray[3]; } txtHeaderImgPath.Value = Articlemodel.HeaderImgPath; #endregion btnAddNewsSave.Text = "确定修改"; }
private void ShowInfo(int articleId) { ArticleModel = ArticleBll.GetArticle(articleId); hfIsOpened.Value = ArticleModel.IsOpened.ToString(); if (ArticleModel == null) Function.ShowMsg(0, "<li>所选" + ChannelModel.TypeName + "不存在或已经被删除</li><li><a href='javascript:history.back()'>返回上一级</a></li>"); if (ArticleModel.Status == 1 || ArticleModel.Status == 2 || ArticleModel.Status == 3) Function.ShowMsg(0, "<li>你没有修改此稿件的权限</li><li><a href='javascript:history.back()'>返回上一级</a></li>"); txtTitle.Text = ArticleModel.Title.Trim(); txtAuthor.Text = ArticleModel.Author.Trim(); txtSource.Text = ArticleModel.Source.Trim(); string tagNameStr = ArticleModel.TagNameStr; if (tagNameStr != string.Empty && tagNameStr.StartsWith("|") && tagNameStr.EndsWith("|")) { tagNameStr = tagNameStr.Substring(0, tagNameStr.Length - 1); tagNameStr = tagNameStr.Substring(1, tagNameStr.Length - 1); } txtTagNameStr.Text = tagNameStr; ddlUserCate.SelectedValue = ArticleModel.UserCateId.ToString(); txtShortContent.Text = ArticleModel.ShortContent.Trim(); B_ConvertImage convertBll = new B_ConvertImage(SiteModel.Domain, InfoModel.UploadPath); txtContent.Value = convertBll.ConvertContent(ArticleModel.Content); txtContent.Value = txtContent.Value.Replace("{Ky:PAGE}", @"<div style=""page-break-after: always""><span style=""display: none""> </span></div>"); txtPoint.Text = ArticleModel.PointCount.ToString().Trim(); btnAddCateSave.Visible = false; btnSaveCaoGao.Visible = false; btnUpdate.Visible = true; }